Pods – Custom Content Types and Fields - Version 2.7.17

Version Description

  • March 26th 2020 =

New Features & Enhancements * Added: New callout for our Friends of Pods program will show up on the Pods Admin > Pods list so we can let people know how to donate. #5571 (@nicdford, @sc0ttkclark, @JoryHogeveen) * Added: Freemius integration to support our new Friends of Pods add-ons and enable us to let people opt-in to usage stats for planning future compatibility decisions. #5624 (@sc0ttkclark) * Added: New not_found tag to the Pods shortcode to return default string if no output is empty. #5580 (@JoryHogeveen) * Added: New hooks when saving field table definitions (table-based Pods). #5623 (@sc0ttkclark) * Added: New custom multi-relationship display format. #5612 (@JoryHogeveen) * Added: Support traversing into post thumbnails objects. #5610 (@JoryHogeveen) * Compatibility: Add ACF backwards compatibility functions/shortcode. #4855 (@sc0ttkclark) * Compatibility: WordPress 5.4 - Add user Pod fields to privacy export data. #5606 (@JoryHogeveen) * Compatibility: Match WordPress 5.4 CSS changes. #5608 (@JoryHogeveen) * Enhancement: Shortcodes now automatically revert to the current queried object. #5598 (@JoryHogeveen) * Enhancement: Add "full" to available image sizes. #5185 (@JoryHogeveen) * Enhancement: Set Pods current queried object detection based on class instances instead of class parameters. #5617 (@JoryHogeveen) * Docs: Update inline docs for pick field selected logic. #5014 & #5017 (@sc0ttkclark)

Bug Fixes * Fixed: Date/Time - Correct empty value validation. #5534 & #5544 (@JoryHogeveen) * Fixed: Date/Time - Allow midnight (00:00:00) as time value. #5616 (@JoryHogeveen) * Fixed: Number/Currency - Parsing error for number format 9'999.99. #5559 & #5597 (@JoryHogeveen) * Fixed: Number/Currency - Do not set default value of 0 if field is empty. #5539 (@JoryHogeveen) * Fixed: CLI export/export-item commands. #5041 (@0xLBF) * Fixed: Allow No (0) as an answer for radio and select boolean fields. #5549 (@JoryHogeveen) * Fixed: Prevent get_meta() cache loop. #5577 (@JoryHogeveen) * Fixed: Pods component descriptions. #5543 (@JoryHogeveen) * Fixed: PHP 7.4 - Array and string offset access syntax with curly braces is deprecated. #5582 (@JoryHogeveen) * Fixed: PHP 7.4 - Trying to access array offset on value of type bool. #5556 & #5615 (@JoryHogeveen) * Fixed: PHP 7.4 - Array access notices. #5631 (@JoryHogeveen) * Fixed: Replaced hook used for meta boxes in admin for custom component integrations to avoid deprecated notices from WordPress. #5622 (@sc0ttkclark) * Fixed: Prevented potential fatal errors on Pod Template editor screen when pod configuration is broken. #5622 (@sc0ttkclark) * Docs: Link to Gallery Documentation in Image field inline help doc. #5541 (@wpacademy)

Download this release

Release Info

Developer sc0ttkclark
Plugin Icon 128x128 Pods – Custom Content Types and Fields
Version 2.7.17
Comparing to
See all releases

Code changes from version 2.7.16.2 to 2.7.17

Files changed (71) hide show
  1. CODE_OF_CONDUCT.md +76 -0
  2. classes/Pods.php +108 -112
  3. classes/PodsAPI.php +86 -22
  4. classes/PodsAdmin.php +171 -51
  5. classes/PodsData.php +2 -2
  6. classes/PodsI18n.php +4 -2
  7. classes/PodsInit.php +240 -0
  8. classes/PodsMeta.php +12 -30
  9. classes/PodsMigrate.php +37 -4
  10. classes/PodsUI.php +416 -381
  11. classes/cli/Pods_CLI_Command.php +1 -1
  12. classes/fields/boolean.php +16 -7
  13. classes/fields/currency.php +17 -53
  14. classes/fields/datetime.php +9 -28
  15. classes/fields/file.php +3 -1
  16. classes/fields/number.php +56 -37
  17. classes/fields/pick.php +67 -21
  18. components/Advanced-Content-Types.php +1 -3
  19. components/Advanced-Relationships.php +1 -2
  20. components/Builder/Builder.php +1 -2
  21. components/Helpers.php +2 -3
  22. components/I18n/I18n.php +1 -1
  23. components/Markdown.php +6 -7
  24. components/Migrate-CPTUI/Migrate-CPTUI.php +1 -2
  25. components/Migrate-Packages/Migrate-Packages.php +1 -2
  26. components/Pages.php +2 -10
  27. components/Roles/Roles.php +1 -4
  28. components/Roles/ui/edit.php +1 -1
  29. components/Table-Storage.php +1 -2
  30. components/Templates/Templates.php +2 -3
  31. components/Templates/class-pods_templates.php +7 -4
  32. components/Templates/includes/functions-pod_reference.php +7 -1
  33. includes/compatibility/acf.php +414 -0
  34. includes/data.php +55 -12
  35. includes/general.php +109 -38
  36. init.php +2 -2
  37. readme.txt +34 -1
  38. ui/admin/form.php +1 -1
  39. ui/admin/help.php +123 -113
  40. ui/admin/settings.php +46 -35
  41. ui/admin/setup-edit.php +1 -1
  42. ui/admin/view.php +1 -1
  43. ui/fields/datetime.php +1 -8
  44. ui/images/pods-logo-notext-rgb-transparent.png +0 -0
  45. ui/styles/dist/pods-form.css +1 -1
  46. ui/styles/dist/pods.css +3 -1
  47. vendor/freemius/wordpress-sdk/LICENSE.txt +674 -0
  48. vendor/freemius/wordpress-sdk/assets/css/admin/account.css +1 -0
  49. vendor/freemius/wordpress-sdk/assets/css/admin/add-ons.css +2 -0
  50. vendor/freemius/wordpress-sdk/assets/css/admin/affiliation.css +1 -0
  51. vendor/freemius/wordpress-sdk/assets/css/admin/checkout.css +1 -0
  52. vendor/freemius/wordpress-sdk/assets/css/admin/common.css +2 -0
  53. vendor/freemius/wordpress-sdk/assets/css/admin/connect.css +1 -0
  54. vendor/freemius/wordpress-sdk/assets/css/admin/debug.css +1 -0
  55. vendor/freemius/wordpress-sdk/assets/css/admin/dialog-boxes.css +2 -0
  56. vendor/freemius/wordpress-sdk/assets/css/admin/gdpr-optin-notice.css +1 -0
  57. vendor/freemius/wordpress-sdk/assets/css/admin/index.php +3 -0
  58. vendor/freemius/wordpress-sdk/assets/css/admin/plugins.css +1 -0
  59. vendor/freemius/wordpress-sdk/assets/css/customizer.css +1 -0
  60. vendor/freemius/wordpress-sdk/assets/css/index.php +3 -0
  61. vendor/freemius/wordpress-sdk/assets/img/index.php +3 -0
  62. vendor/freemius/wordpress-sdk/assets/img/plugin-icon.png +0 -0
  63. vendor/freemius/wordpress-sdk/assets/img/theme-icon.png +0 -0
  64. vendor/freemius/wordpress-sdk/assets/index.php +3 -0
  65. vendor/freemius/wordpress-sdk/assets/js/index.php +3 -0
  66. vendor/freemius/wordpress-sdk/assets/js/nojquery.ba-postmessage.js +140 -0
  67. vendor/freemius/wordpress-sdk/assets/js/nojquery.ba-postmessage.min.js +12 -0
  68. vendor/freemius/wordpress-sdk/assets/js/postmessage.js +135 -0
  69. vendor/freemius/wordpress-sdk/config.php +388 -0
  70. vendor/freemius/wordpress-sdk/includes/class-freemius-abstract.php +597 -0
  71. vendor/freemius/wordpress-sdk/includes/class-freemius.php +14274 -0
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at contact@podsfoundation.org. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
classes/Pods.php CHANGED
@@ -288,16 +288,16 @@ class Pods implements Iterator {
288
  if ( $queried_object ) {
289
  $id_lookup = true;
290
 
291
- if ( isset( $queried_object->post_type ) ) {
292
  // Post Type Singular.
293
  $pod = $queried_object->post_type;
294
- } elseif ( isset( $queried_object->taxonomy ) ) {
295
  // Term Archive.
296
  $pod = $queried_object->taxonomy;
297
- } elseif ( isset( $queried_object->user_login ) ) {
298
  // Author Archive.
299
  $pod = 'user';
300
- } elseif ( isset( $queried_object->public, $queried_object->name ) ) {
301
  // Post Type Archive.
302
  $pod = $queried_object->name;
303
 
@@ -1007,82 +1007,15 @@ class Pods implements Iterator {
1007
  }
1008
  }
1009
 
1010
- if ( 'post_type' === $this->pod_data['type'] && ! isset( $this->fields[ $params->name ] ) ) {
1011
- if ( ! isset( $this->fields['post_thumbnail'] ) && ( 'post_thumbnail' === $params->name || 0 === strpos( $params->name, 'post_thumbnail.' ) ) ) {
1012
- $size = 'thumbnail';
1013
-
1014
- if ( 0 === strpos( $params->name, 'post_thumbnail.' ) ) {
1015
- $field_names = explode( '.', $params->name );
1016
-
1017
- if ( isset( $field_names[1] ) ) {
1018
- $size = $field_names[1];
1019
- }
1020
- }
1021
-
1022
- // Pods will auto-get the thumbnail ID if this isn't an attachment.
1023
- $value = pods_image( $this->id(), $size, 0, null, true );
1024
-
1025
- $object_field_found = true;
1026
- } elseif ( ! isset( $this->fields['post_thumbnail_url'] ) && ( 'post_thumbnail_url' === $params->name || 0 === strpos( $params->name, 'post_thumbnail_url.' ) ) ) {
1027
- $size = 'thumbnail';
1028
-
1029
- if ( 0 === strpos( $params->name, 'post_thumbnail_url.' ) ) {
1030
- $field_names = explode( '.', $params->name );
1031
-
1032
- if ( isset( $field_names[1] ) ) {
1033
- $size = $field_names[1];
1034
- }
1035
- }
1036
-
1037
- // Pods will auto-get the thumbnail ID if this isn't an attachment.
1038
- $value = pods_image_url( $this->id(), $size, 0, true );
1039
-
1040
- $object_field_found = true;
1041
- } elseif ( 0 === strpos( $params->name, 'image_attachment.' ) ) {
1042
- $size = 'thumbnail';
1043
-
1044
- $image_id = 0;
1045
-
1046
- $field_names = explode( '.', $params->name );
1047
-
1048
- if ( isset( $field_names[1] ) ) {
1049
- $image_id = $field_names[1];
1050
- }
1051
-
1052
- if ( isset( $field_names[2] ) ) {
1053
- $size = $field_names[2];
1054
- }
1055
-
1056
- if ( ! empty( $image_id ) ) {
1057
- $value = pods_image( $image_id, $size, 0, null, true );
1058
-
1059
- if ( ! empty( $value ) ) {
1060
- $object_field_found = true;
1061
- }
1062
- }
1063
- } elseif ( 0 === strpos( $params->name, 'image_attachment_url.' ) ) {
1064
- $size = 'thumbnail';
1065
-
1066
- $image_id = 0;
1067
-
1068
- $field_names = explode( '.', $params->name );
1069
-
1070
- if ( isset( $field_names[1] ) ) {
1071
- $image_id = $field_names[1];
1072
- }
1073
-
1074
- if ( isset( $field_names[2] ) ) {
1075
- $size = $field_names[2];
1076
- }
1077
-
1078
- if ( ! empty( $image_id ) ) {
1079
- $value = pods_image_url( $image_id, $size, 0, true );
1080
 
1081
- if ( ! empty( $value ) ) {
1082
- $object_field_found = true;
1083
- }
1084
- }
1085
- }//end if
1086
  } elseif ( 'user' === $this->pod_data['type'] && ! isset( $this->fields[ $params->name ] ) ) {
1087
  if ( ! isset( $this->fields['avatar'] ) && ( 'avatar' === $params->name || 0 === strpos( $params->name, 'avatar.' ) ) ) {
1088
  $size = null;
@@ -1103,51 +1036,114 @@ class Pods implements Iterator {
1103
 
1104
  $object_field_found = true;
1105
  }
1106
- } elseif ( 0 === strpos( $params->name, 'image_attachment.' ) ) {
1107
- $size = 'thumbnail';
1108
 
1109
- $image_id = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1110
 
1111
- $field_names = explode( '.', $params->name );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1112
 
1113
- if ( isset( $field_names[1] ) ) {
1114
- $image_id = $field_names[1];
1115
- }
 
 
 
 
 
 
 
 
 
 
 
1116
 
1117
- if ( isset( $field_names[2] ) ) {
1118
- $size = $field_names[2];
1119
- }
1120
 
1121
- if ( ! empty( $image_id ) ) {
1122
- $value = pods_image( $image_id, $size, 0, null, true );
 
1123
 
1124
- if ( ! empty( $value ) ) {
1125
- $object_field_found = true;
1126
- }
1127
- }
1128
- } elseif ( 0 === strpos( $params->name, 'image_attachment_url.' ) ) {
1129
- $size = 'thumbnail';
1130
 
1131
- $image_id = 0;
 
 
1132
 
1133
- $field_names = explode( '.', $params->name );
 
1134
 
1135
- if ( isset( $field_names[1] ) ) {
1136
- $image_id = $field_names[1];
1137
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1138
 
1139
- if ( isset( $field_names[2] ) ) {
1140
- $size = $field_names[2];
1141
- }
 
 
 
 
 
1142
 
1143
- if ( ! empty( $image_id ) ) {
1144
- $value = pods_image_url( $image_id, $size, 0, true );
 
 
 
1145
 
1146
- if ( ! empty( $value ) ) {
1147
- $object_field_found = true;
1148
- }
1149
- }
1150
- }//end if
1151
 
1152
  if ( false === $object_field_found ) {
1153
  $params->traverse = array( $params->name );
288
  if ( $queried_object ) {
289
  $id_lookup = true;
290
 
291
+ if ( $queried_object instanceof WP_Post ) {
292
  // Post Type Singular.
293
  $pod = $queried_object->post_type;
294
+ } elseif ( $queried_object instanceof WP_Term ) {
295
  // Term Archive.
296
  $pod = $queried_object->taxonomy;
297
+ } elseif ( $queried_object instanceof WP_User ) {
298
  // Author Archive.
299
  $pod = 'user';
300
+ } elseif ( $queried_object instanceof WP_Post_Type ) {
301
  // Post Type Archive.
302
  $pod = $queried_object->name;
303
 
1007
  }
1008
  }
1009
 
1010
+ // Default image field handlers.
1011
+ $image_fields = array(
1012
+ 'image_attachment',
1013
+ 'image_attachment_url',
1014
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1015
 
1016
+ if ( 'post_type' === $this->pod_data['type'] ) {
1017
+ $image_fields[] = 'post_thumbnail';
1018
+ $image_fields[] = 'post_thumbnail_url';
 
 
1019
  } elseif ( 'user' === $this->pod_data['type'] && ! isset( $this->fields[ $params->name ] ) ) {
1020
  if ( ! isset( $this->fields['avatar'] ) && ( 'avatar' === $params->name || 0 === strpos( $params->name, 'avatar.' ) ) ) {
1021
  $size = null;
1036
 
1037
  $object_field_found = true;
1038
  }
1039
+ }
 
1040
 
1041
+ if ( ! $object_field_found ) {
1042
+ foreach ( $image_fields as $image_field ) {
1043
+ if ( isset( $this->fields[ $image_field ] ) ) {
1044
+ // Skip any names that are registered fields within this Pod.
1045
+ continue;
1046
+ }
1047
+ if (
1048
+ $image_field === $params->name ||
1049
+ 0 === strpos( $params->name, $image_field . '.' )
1050
+ ) {
1051
+ // Is it a URL request?
1052
+ $url = '_url' === substr( $image_field, -4 );
1053
+ if ( $url ) {
1054
+ $image_field = substr( $image_field, 0, -4 );
1055
+ }
1056
 
1057
+ // Results in an empty array if no traversal names are passed.
1058
+ $traverse_names = explode( '.', $params->name );
1059
+ array_shift( $traverse_names );
1060
+
1061
+ $attachment_id = 0;
1062
+ switch ( $image_field ) {
1063
+ case 'post_thumbnail':
1064
+ $attachment_id = get_post_thumbnail_id( $this->id() );
1065
+ break;
1066
+ case 'image_attachment':
1067
+ if ( isset( $traverse_names[0] ) ) {
1068
+ $attachment_id = $traverse_names[0];
1069
+ array_shift( $traverse_names );
1070
+ }
1071
+ break;
1072
+ }
1073
 
1074
+ if ( $attachment_id ) {
1075
+
1076
+ $size = 'thumbnail';
1077
+ if ( isset( $traverse_names[0] ) ) {
1078
+ $size = $traverse_names[0];
1079
+ $sizes = get_intermediate_image_sizes();
1080
+ // Not shown by default.
1081
+ $sizes[] = 'full';
1082
+ $sizes[] = 'original';
1083
+ if ( ! in_array( $size, $sizes, true ) ) {
1084
+ // No valid image size found.
1085
+ $size = false;
1086
+ }
1087
+ }
1088
 
1089
+ if ( $url ) {
1090
+ $value = pods_image_url( $attachment_id, $size, 0, true );
 
1091
 
1092
+ $object_field_found = true;
1093
+ break;
1094
+ }
1095
 
1096
+ if ( $size ) {
1097
+ // Pods will auto-get the thumbnail ID if this isn't an attachment.
1098
+ $value = pods_image( $attachment_id, $size, 0, null, true );
 
 
 
1099
 
1100
+ $object_field_found = true;
1101
+ break;
1102
+ }
1103
 
1104
+ // Fallback to attachment Post object to look for other image properties.
1105
+ $media = pods( 'media', $attachment_id );
1106
 
1107
+ if ( $media && $media->valid() && $media->exists() ) {
1108
+ $value = $media->field( implode( '.', $traverse_names ) );
1109
+ } else {
1110
+ // Fallback to default attachment object.
1111
+ $attachment = get_post( $attachment_id );
1112
+ $value = pods_v( implode( '.', $traverse_names ), $attachment, '' );
1113
+ if ( ! $value ) {
1114
+ $meta_key = array_shift( $traverse_names );
1115
+ $value = get_post_meta( $attachment_id, $meta_key, true );
1116
+
1117
+ // Maybe traverse.
1118
+ if ( count( $traverse_names ) ) {
1119
+ if ( is_array( $value ) ) {
1120
+ foreach ( $traverse_names as $field ) {
1121
+ if ( ! isset( $value[ $field ] ) ) {
1122
+ $value = null;
1123
+
1124
+ break;
1125
+ }
1126
 
1127
+ $value = $value[ $field ];
1128
+ }
1129
+ } else {
1130
+ $value = null;
1131
+ }
1132
+ }
1133
+ }
1134
+ }
1135
 
1136
+ if ( null !== $value ) {
1137
+ $object_field_found = true;
1138
+ break;
1139
+ }
1140
+ }
1141
 
1142
+ // Already found a matching field name. Stop foreach loop.
1143
+ break;
1144
+ } //end if
1145
+ } //end foreach
1146
+ }
1147
 
1148
  if ( false === $object_field_found ) {
1149
  $params->traverse = array( $params->name );
classes/PodsAPI.php CHANGED
@@ -324,7 +324,7 @@ class PodsAPI {
324
  if ( isset( $fields[ $meta_key ] ) ) {
325
  $field_data = $fields[ $meta_key ];
326
 
327
- $simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
328
  }
329
 
330
  if ( $simple ) {
@@ -619,7 +619,7 @@ class PodsAPI {
619
  if ( isset( $fields[ $meta_key ] ) ) {
620
  $field_data = $fields[ $meta_key ];
621
 
622
- $simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
623
  }
624
 
625
  if ( $simple ) {
@@ -785,7 +785,7 @@ class PodsAPI {
785
  if ( isset( $fields[ $meta_key ] ) ) {
786
  $field_data = $fields[ $meta_key ];
787
 
788
- $simple = ( 'pick' === $field_data['type'] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
789
  }
790
 
791
  if ( $simple ) {
@@ -2871,7 +2871,7 @@ class PodsAPI {
2871
 
2872
  $field['id'] = $params->id;
2873
 
2874
- $simple = ( 'pick' === $field['type'] && in_array( pods_var( 'pick_object', $field['options'] ), $simple_tableless_objects ) );
2875
 
2876
  $definition = false;
2877
 
@@ -2885,42 +2885,106 @@ class PodsAPI {
2885
 
2886
  $sister_id = (int) pods_var( 'sister_id', $field['options'], 0 );
2887
 
 
 
2888
  if ( $table_operation && 'table' === $pod['storage'] && ! pods_tableless() ) {
2889
  if ( ! empty( $old_id ) ) {
2890
- if ( ( $field['type'] !== $old_type || $old_simple != $simple ) && empty( $definition ) ) {
2891
- pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` DROP COLUMN `{$old_name}`", false );
2892
  } elseif ( 0 < strlen( $definition ) ) {
2893
  if ( $old_name !== $field['name'] || $old_simple !== $simple || $old_definition !== $definition ) {
2894
- $test = false;
2895
 
2896
  if ( 0 < strlen( $old_definition ) ) {
2897
- $test = pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` CHANGE `{$old_name}` {$definition}", false );
2898
- }
2899
-
2900
- // If the old field doesn't exist, continue to add a new field
2901
- if ( false === $test ) {
2902
- pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` ADD COLUMN {$definition}", __( 'Cannot create new field', 'pods' ) );
2903
  }
2904
  } elseif ( null !== $old_definition && $definition !== $old_definition ) {
2905
- $test = pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` CHANGE `{$old_name}` {$definition}", false );
2906
-
2907
- // If the old field doesn't exist, continue to add a new field
2908
- if ( false === $test ) {
2909
- pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` ADD COLUMN {$definition}", __( 'Cannot create new field', 'pods' ) );
2910
- }
2911
  }
2912
  }
2913
  } elseif ( 0 < strlen( $definition ) ) {
2914
- $test = false;
2915
 
2916
  if ( 0 < strlen( $old_definition ) ) {
2917
- $test = pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` CHANGE `" . $field['name'] . "` {$definition}", false );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2918
  }
2919
 
2920
  // If the old field doesn't exist, continue to add a new field
2921
- if ( false === $test ) {
2922
  pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` ADD COLUMN {$definition}", __( 'Cannot create new field', 'pods' ) );
2923
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2924
  }
2925
  }
2926
 
324
  if ( isset( $fields[ $meta_key ] ) ) {
325
  $field_data = $fields[ $meta_key ];
326
 
327
+ $simple = ( 'pick' === pods_v( 'type', $field_data ) && in_array( pods_v( 'pick_object', $field_data ), $simple_tableless_objects ) );
328
  }
329
 
330
  if ( $simple ) {
619
  if ( isset( $fields[ $meta_key ] ) ) {
620
  $field_data = $fields[ $meta_key ];
621
 
622
+ $simple = ( 'pick' === pods_v( 'type', $field_data ) && in_array( pods_v( 'pick_object', $field_data ), $simple_tableless_objects ) );
623
  }
624
 
625
  if ( $simple ) {
785
  if ( isset( $fields[ $meta_key ] ) ) {
786
  $field_data = $fields[ $meta_key ];
787
 
788
+ $simple = ( 'pick' === pods_v( 'type', $field_data ) && in_array( pods_v( 'pick_object', $field_data ), $simple_tableless_objects ) );
789
  }
790
 
791
  if ( $simple ) {
2871
 
2872
  $field['id'] = $params->id;
2873
 
2874
+ $simple = ( 'pick' === $field['type'] && in_array( pods_v( 'pick_object', $field['options'] ), $simple_tableless_objects, true ) );
2875
 
2876
  $definition = false;
2877
 
2885
 
2886
  $sister_id = (int) pods_var( 'sister_id', $field['options'], 0 );
2887
 
2888
+ $definition_mode = 'bypass';
2889
+
2890
  if ( $table_operation && 'table' === $pod['storage'] && ! pods_tableless() ) {
2891
  if ( ! empty( $old_id ) ) {
2892
+ if ( ( $field['type'] !== $old_type || $old_simple !== $simple ) && empty( $definition ) ) {
2893
+ $definition_mode = 'drop';
2894
  } elseif ( 0 < strlen( $definition ) ) {
2895
  if ( $old_name !== $field['name'] || $old_simple !== $simple || $old_definition !== $definition ) {
2896
+ $definition_mode = 'add';
2897
 
2898
  if ( 0 < strlen( $old_definition ) ) {
2899
+ $definition_mode = 'change';
 
 
 
 
 
2900
  }
2901
  } elseif ( null !== $old_definition && $definition !== $old_definition ) {
2902
+ $definition_mode = 'change';
 
 
 
 
 
2903
  }
2904
  }
2905
  } elseif ( 0 < strlen( $definition ) ) {
2906
+ $definition_mode = 'add';
2907
 
2908
  if ( 0 < strlen( $old_definition ) ) {
2909
+ $definition_mode = 'change';
2910
+ }
2911
+ }
2912
+
2913
+ if ( 'bypass' !== $definition_mode ) {
2914
+ /**
2915
+ * Allow hooking into before the table has been altered for any custom functionality needed.
2916
+ *
2917
+ * @since 2.7.17
2918
+ *
2919
+ * @param string $definition_mode The definition mode used for the table field.
2920
+ * @param array $pod The pod object.
2921
+ * @param string $type The field type.
2922
+ * @param array $field The field object.
2923
+ * @param array $extra_info {
2924
+ * Extra information about the field.
2925
+ *
2926
+ * @type bool $simple Whether the field is a simple tableless field.
2927
+ * @type string $definition The field definition.
2928
+ * @type null|string $old_name The old field name (if preexisting).
2929
+ * @type null|string $old_definition The old field definition (if preexisting).
2930
+ * @type null|array $old_options The old field options (if preexisting).
2931
+ * }
2932
+ */
2933
+ do_action( 'pods_api_save_field_table_pre_alter', $definition_mode, $pod, $field['type'], $field, [
2934
+ 'simple' => $simple,
2935
+ 'definition' => $definition,
2936
+ 'old_name' => $old_name,
2937
+ 'old_definition' => $old_definition,
2938
+ 'old_options' => $old_options,
2939
+ ] );
2940
+
2941
+ if ( 'drop' === $definition_mode ) {
2942
+ // Drop field column.
2943
+ pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` DROP COLUMN `{$old_name}`", false );
2944
+ } elseif ( 'change' === $definition_mode ) {
2945
+ // Change field column definition.
2946
+ if ( $old_name && $old_name !== $field['name'] ) {
2947
+ $test = pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` CHANGE `{$old_name}` {$definition}", false );
2948
+ } else {
2949
+ $test = pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` MODIFY {$definition}", false );
2950
+ }
2951
+
2952
+ if ( false === $test ) {
2953
+ $definition_mode = 'add';
2954
+ }
2955
  }
2956
 
2957
  // If the old field doesn't exist, continue to add a new field
2958
+ if ( 'add' === $definition_mode ) {
2959
  pods_query( "ALTER TABLE `@wp_pods_{$params->pod}` ADD COLUMN {$definition}", __( 'Cannot create new field', 'pods' ) );
2960
  }
2961
+
2962
+ /**
2963
+ * Allow hooking into after the table has been altered for any custom functionality needed.
2964
+ *
2965
+ * @since 2.7.17
2966
+ *
2967
+ * @param string $definition_mode The definition mode used for the table field.
2968
+ * @param array $pod The pod object.
2969
+ * @param string $type The field type.
2970
+ * @param array $field The field object.
2971
+ * @param array $extra_info {
2972
+ * Extra information about the field.
2973
+ *
2974
+ * @type bool $simple Whether the field is a simple tableless field.
2975
+ * @type string $definition The field definition.
2976
+ * @type null|string $old_name The old field name (if preexisting).
2977
+ * @type null|string $old_definition The old field definition (if preexisting).
2978
+ * @type null|array $old_options The old field options (if preexisting).
2979
+ * }
2980
+ */
2981
+ do_action( 'pods_api_save_field_table_altered', $definition_mode, $pod, $field['type'], $field, [
2982
+ 'simple' => $simple,
2983
+ 'definition' => $definition,
2984
+ 'old_name' => $old_name,
2985
+ 'old_definition' => $old_definition,
2986
+ 'old_options' => $old_options,
2987
+ ] );
2988
  }
2989
  }
2990
 
classes/PodsAdmin.php CHANGED
@@ -417,6 +417,7 @@ class PodsAdmin {
417
  }
418
  }
419
 
 
420
  if ( ! pods_is_admin(
421
  array(
422
  'pods',
@@ -433,36 +434,36 @@ class PodsAdmin {
433
  continue;
434
  }
435
 
 
 
 
 
 
 
436
  $page_title = pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', $pod['name'] ) ), true );
437
  $page_title = apply_filters( 'pods_admin_menu_page_title', $page_title, $pod );
438
 
439
  $menu_label = pods_v( 'menu_name', $pod['options'], $page_title, true );
440
  $menu_label = apply_filters( 'pods_admin_menu_label', $menu_label, $pod );
441
 
442
- $menu_position = pods_v( 'menu_position', $pod['options'], '', true );
443
- $menu_icon = pods_evaluate_tags( pods_v( 'menu_icon', $pod['options'], '', true ), true );
444
-
445
- if ( empty( $menu_position ) ) {
446
- $menu_position = null;
447
- }
448
-
449
  $menu_slug = 'edit-tags.php?taxonomy=' . $pod['name'];
450
- $menu_location = pods_v( 'menu_location', $pod['options'], 'default' );
451
  $menu_location_custom = pods_v( 'menu_location_custom', $pod['options'], '' );
452
 
453
- if ( 'default' === $menu_location ) {
454
- continue;
 
455
  }
456
 
457
  $taxonomy_data = get_taxonomy( $pod['name'] );
458
 
459
  foreach ( (array) $taxonomy_data->object_type as $post_type ) {
460
  if ( 'post' === $post_type ) {
461
- remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . $pod['name'] );
462
  } elseif ( 'attachment' === $post_type ) {
463
- remove_submenu_page( 'upload.php', 'edit-tags.php?taxonomy=' . $pod['name'] . '&amp;post_type=' . $post_type );
464
  } else {
465
- remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . $pod['name'] . '&amp;post_type=' . $post_type );
466
  }
467
  }
468
 
@@ -470,12 +471,7 @@ class PodsAdmin {
470
  add_options_page( $page_title, $menu_label, 'read', $menu_slug );
471
  } elseif ( 'appearances' === $menu_location ) {
472
  add_theme_page( $page_title, $menu_label, 'read', $menu_slug );
473
- } elseif ( 'objects' === $menu_location ) {
474
- if ( empty( $menu_position ) ) {
475
- $menu_position = null;
476
- }
477
- add_menu_page( $page_title, $menu_label, 'read', $menu_slug, '', $menu_icon, $menu_position );
478
- } elseif ( 'top' === $menu_location ) {
479
  add_menu_page( $page_title, $menu_label, 'read', $menu_slug, '', $menu_icon, $menu_position );
480
  } elseif ( 'submenu' === $menu_location && ! empty( $menu_location_custom ) ) {
481
  if ( ! isset( $submenu_items[ $menu_location_custom ] ) ) {
@@ -506,9 +502,9 @@ class PodsAdmin {
506
  $menu_label = pods_v( 'menu_name', $pod['options'], $page_title, true );
507
  $menu_label = apply_filters( 'pods_admin_menu_label', $menu_label, $pod );
508
 
509
- $menu_position = pods_v( 'menu_position', $pod['options'], '', true );
510
- $menu_icon = pods_evaluate_tags( pods_v( 'menu_icon', $pod['options'], '', true ), true );
511
 
 
512
  if ( empty( $menu_position ) ) {
513
  $menu_position = null;
514
  }
@@ -516,38 +512,14 @@ class PodsAdmin {
516
  $menu_slug = 'pods-settings-' . $pod['name'];
517
  $menu_location = pods_v( 'menu_location', $pod['options'], 'settings' );
518
  $menu_location_custom = pods_v( 'menu_location_custom', $pod['options'], '' );
 
519
 
520
  if ( 'settings' === $menu_location ) {
521
- add_options_page(
522
- $page_title, $menu_label, 'read', $menu_slug, array(
523
- $this,
524
- 'admin_content_settings',
525
- )
526
- );
527
  } elseif ( 'appearances' === $menu_location ) {
528
- add_theme_page(
529
- $page_title, $menu_label, 'read', $menu_slug, array(
530
- $this,
531
- 'admin_content_settings',
532
- )
533
- );
534
- } elseif ( 'objects' === $menu_location ) {
535
- if ( empty( $menu_position ) ) {
536
- $menu_position = null;
537
- }
538
- add_menu_page(
539
- $page_title, $menu_label, 'read', $menu_slug, array(
540
- $this,
541
- 'admin_content_settings',
542
- ), $menu_icon, $menu_position
543
- );
544
- } elseif ( 'top' === $menu_location ) {
545
- add_menu_page(
546
- $page_title, $menu_label, 'read', $menu_slug, array(
547
- $this,
548
- 'admin_content_settings',
549
- ), $menu_icon, $menu_position
550
- );
551
  } elseif ( 'submenu' === $menu_location && ! empty( $menu_location_custom ) ) {
552
  if ( ! isset( $submenu_items[ $menu_location_custom ] ) ) {
553
  $submenu_items[ $menu_location_custom ] = array();
@@ -559,7 +531,8 @@ class PodsAdmin {
559
  $menu_label,
560
  'read',
561
  $menu_slug,
562
- array( $this, 'admin_content_settings' ),
 
563
  );
564
  }//end if
565
  }//end foreach
@@ -1085,9 +1058,142 @@ class PodsAdmin {
1085
  }
1086
  }
1087
 
 
 
 
 
 
 
1088
  pods_ui( $ui );
1089
  }
1090
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1091
  /**
1092
  * Get the add page of an object
1093
  *
@@ -2721,6 +2827,9 @@ class PodsAdmin {
2721
  */
2722
  public function admin_settings() {
2723
 
 
 
 
2724
  pods_view( PODS_DIR . 'ui/admin/settings.php', compact( array_keys( get_defined_vars() ) ) );
2725
  }
2726
 
@@ -2911,6 +3020,12 @@ class PodsAdmin {
2911
  $ui['views']['dev'] = __( 'Developer Preview', 'pods' );
2912
  }
2913
 
 
 
 
 
 
 
2914
  pods_ui( $ui );
2915
  }
2916
 
@@ -3055,6 +3170,11 @@ class PodsAdmin {
3055
  */
3056
  public function admin_help() {
3057
 
 
 
 
 
 
3058
  pods_view( PODS_DIR . 'ui/admin/help.php', compact( array_keys( get_defined_vars() ) ) );
3059
  }
3060
 
417
  }
418
  }
419
 
420
+ // Check capabilities.
421
  if ( ! pods_is_admin(
422
  array(
423
  'pods',
434
  continue;
435
  }
436
 
437
+ $menu_location = pods_v( 'menu_location', $pod['options'], 'default' );
438
+
439
+ if ( 'default' === $menu_location ) {
440
+ continue;
441
+ }
442
+
443
  $page_title = pods_v( 'label', $pod, ucwords( str_replace( '_', ' ', $pod['name'] ) ), true );
444
  $page_title = apply_filters( 'pods_admin_menu_page_title', $page_title, $pod );
445
 
446
  $menu_label = pods_v( 'menu_name', $pod['options'], $page_title, true );
447
  $menu_label = apply_filters( 'pods_admin_menu_label', $menu_label, $pod );
448
 
449
+ $menu_icon = pods_evaluate_tags( pods_v( 'menu_icon', $pod['options'], '', true ), true );
 
 
 
 
 
 
450
  $menu_slug = 'edit-tags.php?taxonomy=' . $pod['name'];
 
451
  $menu_location_custom = pods_v( 'menu_location_custom', $pod['options'], '' );
452
 
453
+ $menu_position = pods_v( 'menu_position', $pod['options'], '', true );
454
+ if ( empty( $menu_position ) ) {
455
+ $menu_position = null;
456
  }
457
 
458
  $taxonomy_data = get_taxonomy( $pod['name'] );
459
 
460
  foreach ( (array) $taxonomy_data->object_type as $post_type ) {
461
  if ( 'post' === $post_type ) {
462
+ remove_submenu_page( 'edit.php', $menu_slug );
463
  } elseif ( 'attachment' === $post_type ) {
464
+ remove_submenu_page( 'upload.php', $menu_slug . '&amp;post_type=' . $post_type );
465
  } else {
466
+ remove_submenu_page( 'edit.php?post_type=' . $post_type, $menu_slug . '&amp;post_type=' . $post_type );
467
  }
468
  }
469
 
471
  add_options_page( $page_title, $menu_label, 'read', $menu_slug );
472
  } elseif ( 'appearances' === $menu_location ) {
473
  add_theme_page( $page_title, $menu_label, 'read', $menu_slug );
474
+ } elseif ( 'objects' === $menu_location || 'top' === $menu_location ) {
 
 
 
 
 
475
  add_menu_page( $page_title, $menu_label, 'read', $menu_slug, '', $menu_icon, $menu_position );
476
  } elseif ( 'submenu' === $menu_location && ! empty( $menu_location_custom ) ) {
477
  if ( ! isset( $submenu_items[ $menu_location_custom ] ) ) {
502
  $menu_label = pods_v( 'menu_name', $pod['options'], $page_title, true );
503
  $menu_label = apply_filters( 'pods_admin_menu_label', $menu_label, $pod );
504
 
505
+ $menu_icon = pods_evaluate_tags( pods_v( 'menu_icon', $pod['options'], '', true ), true );
 
506
 
507
+ $menu_position = pods_v( 'menu_position', $pod['options'], '', true );
508
  if ( empty( $menu_position ) ) {
509
  $menu_position = null;
510
  }
512
  $menu_slug = 'pods-settings-' . $pod['name'];
513
  $menu_location = pods_v( 'menu_location', $pod['options'], 'settings' );
514
  $menu_location_custom = pods_v( 'menu_location_custom', $pod['options'], '' );
515
+ $menu_callback = array( $this, 'admin_content_settings' );
516
 
517
  if ( 'settings' === $menu_location ) {
518
+ add_options_page( $page_title, $menu_label, 'read', $menu_slug, $menu_callback, $menu_position );
 
 
 
 
 
519
  } elseif ( 'appearances' === $menu_location ) {
520
+ add_theme_page( $page_title, $menu_label, 'read', $menu_slug, $menu_callback, $menu_position );
521
+ } elseif ( 'objects' === $menu_location || 'top' === $menu_location ) {
522
+ add_menu_page( $page_title, $menu_label, 'read', $menu_slug, $menu_callback, $menu_icon, $menu_position );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  } elseif ( 'submenu' === $menu_location && ! empty( $menu_location_custom ) ) {
524
  if ( ! isset( $submenu_items[ $menu_location_custom ] ) ) {
525
  $submenu_items[ $menu_location_custom ] = array();
531
  $menu_label,
532
  'read',
533
  $menu_slug,
534
+ $menu_callback,
535
+ $menu_position,
536
  );
537
  }//end if
538
  }//end foreach
1058
  }
1059
  }
1060
 
1061
+ // Add our custom callouts.
1062
+ $this->handle_callouts_updates();
1063
+
1064
+ add_filter( 'pods_ui_manage_custom_container_classes', array( $this, 'admin_manage_container_class' ) );
1065
+ add_action( 'pods_ui_manage_after_container', array( $this, 'admin_manage_callouts' ) );
1066
+
1067
  pods_ui( $ui );
1068
  }
1069
 
1070
+ /**
1071
+ * Get list of callouts to show.
1072
+ *
1073
+ * @since 2.7.17
1074
+ *
1075
+ * @return array List of callouts.
1076
+ */
1077
+ public function get_callouts() {
1078
+ $force_callouts = false;
1079
+
1080
+ $page = pods_v( 'page' );
1081
+
1082
+ if ( in_array( $page, array( 'pods-settings', 'pods-help' ), true ) ) {
1083
+ $force_callouts = true;
1084
+ }
1085
+
1086
+ $callouts = get_option( 'pods_callouts' );
1087
+
1088
+ if ( ! $callouts ) {
1089
+ $callouts = array(
1090
+ 'friends_2020' => 1,
1091
+ );
1092
+ }
1093
+
1094
+ // Handle Friends of Pods 2020 callout logic.
1095
+ $callouts['friends_2020'] = ! isset( $callouts['friends_2020'] ) || $callouts['friends_2020'] || $force_callouts ? 1 : 0;
1096
+
1097
+ /**
1098
+ * Allow hooking into whether or not the specific callouts should show.
1099
+ *
1100
+ * @since 2.7.17
1101
+ *
1102
+ * @param array List of callouts to enable.
1103
+ */
1104
+ $callouts = apply_filters( 'pods_admin_callouts', $callouts );
1105
+
1106
+ return $callouts;
1107
+ }
1108
+
1109
+ /**
1110
+ * Handle callouts update logic.
1111
+ *
1112
+ * @since 2.7.17
1113
+ */
1114
+ public function handle_callouts_updates() {
1115
+ $callouts = get_option( 'pods_callouts' );
1116
+
1117
+ if ( ! $callouts ) {
1118
+ $callouts = array();
1119
+ }
1120
+
1121
+ $disable_pods = pods_v( 'pods_callout_dismiss' );
1122
+
1123
+ // Disable Friends of Pods 2020 callout.
1124
+ if ( 'friends_2020' === $disable_pods ) {
1125
+ $callouts['friends_2020'] = 0;
1126
+
1127
+ update_option( 'pods_callouts', $callouts );
1128
+ } elseif ( 'reset' === $disable_pods ) {
1129
+ $callouts = array();
1130
+
1131
+ update_option( 'pods_callouts', $callouts );
1132
+ }
1133
+ }
1134
+
1135
+ /**
1136
+ * Add class to container if we have callouts to show.
1137
+ *
1138
+ * @since 2.7.17
1139
+ *
1140
+ * @param array $classes List of classes to use.
1141
+ *
1142
+ * @return array List of classes to use.
1143
+ */
1144
+ public function admin_manage_container_class( $classes ) {
1145
+ $callouts = $this->get_callouts();
1146
+
1147
+ // Only get enabled callouts.
1148
+ $callouts = array_filter( $callouts );
1149
+
1150
+ if ( ! empty( $callouts ) ) {
1151
+ $classes[] = 'pods-admin--flex';
1152
+ }
1153
+
1154
+ return $classes;
1155
+ }
1156
+
1157
+ /**
1158
+ * Add callouts to let admins know about certain things.
1159
+ *
1160
+ * @since 2.7.17
1161
+ */
1162
+ public function admin_manage_callouts() {
1163
+ $force_callouts = false;
1164
+
1165
+ $page = pods_v( 'page' );
1166
+
1167
+ if ( in_array( $page, array( 'pods-settings', 'pods-help' ), true ) ) {
1168
+ $force_callouts = true;
1169
+ }
1170
+
1171
+ $callouts = $this->get_callouts();
1172
+
1173
+ if ( ! empty( $callouts['friends_2020'] ) ) {
1174
+ ?>
1175
+ <div class="pods-admin_friends-callout_container">
1176
+ <?php if ( ! $force_callouts ) : ?>
1177
+ <a href="<?php echo esc_url( add_query_arg( 'pods_callout_dismiss', 'friends_2020' ) ); ?>" class="pods-admin_friends-callout_close">
1178
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 125" enable-background="new 0 0 100 100" xml:space="preserve"><polygon points="95,17 83,5 50,38 17,5 5,17 38,50 5,83 17,95 50,62 83,95 95,83 62,50 "/></svg>
1179
+ </a>
1180
+ <?php endif; ?>
1181
+ <div class="pods-admin_friends-callout_logo-container">
1182
+ <svg version="1.1" viewBox="0 0 305 111" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>Friends of Pods Logo</title> <defs> <path id="a" d="m0.14762 49.116c0 27.103 21.919 49.075 48.956 49.075 19.888 0 37.007-11.888 44.669-28.962-2.1342-6.538-3.9812-18.041 3.3854-29.538-0.3152-1.624-0.71019-3.219-1.1807-4.781-22.589 22.49-40.827 24.596-54.558 24.229-0.12701-4e-3 -0.58883-0.079-0.71152-0.35667 0 0-0.20016-0.89933 0.38502-0.89933 26.307 0 41.29-15.518 53.531-26.865-0.66763-1.687-1.4264-3.3273-2.2695-4.9167-13.196-3.6393-18.267-14.475-20.067-20.221-6.9007-3.7267-14.796-5.8413-23.184-5.8413-27.037 0-48.956 21.972-48.956 49.076zm62.283-34.287s18.69-2.039 24.194 21.114c-20.424-1.412-24.194-21.114-24.194-21.114zm-7.4779 9.7423s16.57-0.55467 20.342 20.219c-17.938-2.602-20.342-20.219-20.342-20.219zm-9.1018 8.256s14.912-0.97567 18.728 17.626c-16.209-1.8273-18.728-17.626-18.728-17.626zm40.774 3.116c0.021279 0.0013333 0.040563 0.0026667 0.061842 0.0043333l-0.044886 0.067667c-0.0056523-0.024-0.011304-0.048-0.016957-0.072zm-48.709 3.445s13.103-0.859 16.456 15.486c-14.243-1.6047-16.456-15.486-16.456-15.486zm-10.498 1.6027s12.587-0.82333 15.808 14.877c-13.68-1.5417-15.808-14.877-15.808-14.877zm-10.391 0.72233s11.423-0.74667 14.347 13.502c-12.417-1.3997-14.347-13.502-14.347-13.502zm-11.298 2.0857s9.5832-2.526 13.712 9.0523c-0.44919 0.036667-0.88474 0.054333-1.3073 0.054333-9.6148-3.333e-4 -12.405-9.1067-12.405-9.1067zm81.565 0.964c-0.0073147-0.021333-0.014962-0.043667-0.021612-0.064667l0.066497 0.018333c-0.014962 0.015333-0.029924 0.030667-0.044886 0.046333 7.1338 21.557-5.5721 33.29-5.5721 33.29s-8.9279-18.395 5.5721-33.29zm-11.999 0.027333c0.017622 0.0023333 0.035576 5e-3 0.053198 0.0076667l-0.041561 0.056c-0.0036573-0.021667-0.0073147-0.042-0.011637-0.063667zm-10.716 5.6627c0.015959 2e-3 0.032916 0.0036666 0.048543 0.0056666l-0.036573 0.051c-0.0039899-0.019667-0.0076472-0.037333-0.01197-0.056667zm12.212 1.8693c-0.0023274-0.021-0.0046548-0.043333-0.0066497-0.064667l0.056523 0.035667c-0.016624 0.01-0.032916 0.019333-0.049873 0.029 2.2323 21.678-11.682 28.793-11.682 28.793s-4.4962-19.303 11.682-28.793zm-57.318 0.52633-0.018619 0.037333c-0.0039899-0.011667-0.0086447-0.023667-0.012302-0.034667 0.010307-1e-3 0.020614-0.0016667 0.030921-0.0026667zm34.9 2.0257c0.013964 0.0013333 0.027264 3e-3 0.041561 0.0043333l-0.031254 0.046333c-0.0036573-0.017-0.0069822-0.034-0.010307-0.050667zm-22.998 0.34067c0.012302 0.0016666 0.025269 3e-3 0.037571 0.0043333l-0.028594 0.039c-0.0029924-0.014667-0.0056523-0.028667-0.0089771-0.043333zm-16.9 3.542s8.0594-7.693 18.254 0.88467c-3.1137 2.6673-6.0605 3.5853-8.642 3.5853-5.6965 0-9.6125-4.47-9.6125-4.47zm28.752-2.8893c0.013632 0.0013334 0.027264 3e-3 0.040896 0.0043334l-0.030589 0.045c-0.0033249-0.016-0.0069822-0.033333-0.010307-0.049333zm21.183 2.4917c3.325e-4 -0.019 3.325e-4 -0.039333 6.65e-4 -0.058333l0.046548 0.039667c-0.015959 0.0063334-0.031254 0.012333-0.047213 0.018667-0.19118 19.436-13.172 23.733-13.172 23.733s-2.0415-17.662 13.172-23.733zm-31.651 1.257v0.05c-0.0099746-0.0083333-0.019617-0.016333-0.029259-0.024667 0.0093096-0.0086666 0.019284-0.017 0.029259-0.025333zm-6.6234 10.543s4.296-11.202 16.634-9.0197c-3.5273 8.062-9.0759 9.5947-12.782 9.5947-2.2719 0-3.8515-0.575-3.8515-0.575zm16.651-9.0593 0.018287 0.046c-0.01197-2e-3 -0.023606-0.0043334-0.035576-0.0063334 0.0059848-0.013333 0.011637-0.026333 0.017289-0.039667zm10.12 0.685c0.0029923-0.016333 0.0059847-0.033333 0.0089771-0.049667l0.034911 0.043c-0.014629 0.0023333-0.029259 0.0046667-0.043888 0.0066667-2.9518 16.71-14.755 17.762-14.755 17.762s0.77369-15.639 14.755-17.762z"/> </defs> <g fill="none" fill-rule="evenodd"> <g transform="translate(6.3172 6.3333)"> <mask id="b" fill="white"> <use xlink:href="#a"/> </mask> <polygon points="-3.1772 -3.2937 100.48 -3.2937 100.48 101.52 -3.1772 101.52" fill="#fff" mask="url(#b)"/> </g> <path d="m55.303 3.569c-28.538 0-51.754 23.273-51.754 51.88 0 28.607 23.216 51.88 51.754 51.88 28.538 0 51.754-23.273 51.754-51.88 0-28.607-23.217-51.88-51.754-51.88m0 107.18c-30.417 0-55.163-24.807-55.163-55.298 0-30.492 24.746-55.298 55.163-55.298 30.417 0 55.164 24.807 55.164 55.298 0 30.491-24.747 55.298-55.164 55.298" fill="#fff"/> <path d="m137.42 77.263-2.7699 22.725h-14.958l8.2174-67.434h22.252c4.001 0 7.4249 0.48597 10.272 1.4579 2.8469 0.97195 5.1859 2.3141 7.0171 4.0266 1.8312 1.7125 3.1777 3.7335 4.0395 6.0631 0.86176 2.3296 1.2926 4.8366 1.2926 7.521 0 3.6718-0.56167 7.0736-1.685 10.205-1.1234 3.1318-2.8392 5.8394-5.1474 8.1227s-5.232 4.0729-8.7714 5.3688-7.725 1.9439-12.557 1.9439h-7.2018zm4.1549-33.463-2.7238 22.123h7.248c2.1544 0 3.9625-0.31626 5.4244-0.9488 1.4619-0.63254 2.6468-1.5273 3.5547-2.6844 0.90792-1.1571 1.5619-2.5378 1.962-4.1423 0.4001-1.6045 0.60015-3.3632 0.60015-5.2763 0-1.3268-0.17696-2.5456-0.5309-3.6564-0.35394-1.1108-0.90022-2.0673-1.6389-2.8695-0.73865-0.80224-1.6696-1.4271-2.793-1.8745-1.1234-0.4474-2.4544-0.6711-3.9933-0.6711h-7.1095zm48.956 46.283c1.6004 0 3.0315-0.48597 4.2934-1.4579 1.2619-0.97195 2.3313-2.2987 3.2085-3.9803 0.87714-1.6816 1.5542-3.6409 2.0313-5.8779 0.47704-2.237 0.71556-4.6206 0.71556-7.1507 0-3.4867-0.46934-5.9782-1.408-7.4747-0.9387-1.4965-2.4698-2.2447-4.5934-2.2447-1.6004 0-3.0315 0.48597-4.2934 1.4579-1.2619 0.97195-2.3313 2.291-3.2085 3.9572s-1.5542 3.6255-2.0313 5.8779c-0.47704 2.2525-0.71556 4.6437-0.71556 7.1739 0 3.425 0.46934 5.9011 1.408 7.4284 0.9387 1.5273 2.4698 2.291 4.5934 2.291zm-1.2926 10.645c-2.6776 0-5.1782-0.4474-7.5019-1.3422-2.3237-0.89481-4.3395-2.1984-6.0477-3.9109-1.7081-1.7125-3.0469-3.8261-4.0164-6.3408-0.96948-2.5147-1.4542-5.4074-1.4542-8.6781 0-4.2581 0.70017-8.1689 2.1005-11.733 1.4004-3.5638 3.2854-6.6416 5.6552-9.2335s5.1166-4.6129 8.2405-6.0631 6.4093-2.1753 9.8563-2.1753c2.6776 0 5.1705 0.4474 7.4788 1.3422 2.3083 0.89481 4.3164 2.1984 6.0246 3.9109 1.7081 1.7125 3.0546 3.8261 4.0395 6.3408 0.98486 2.5147 1.4773 5.4074 1.4773 8.6781 0 4.1963-0.70017 8.0764-2.1005 11.64-1.4004 3.5638-3.2854 6.6493-5.6552 9.2566-2.3698 2.6073-5.1166 4.6437-8.2405 6.1094-3.1239 1.4656-6.4093 2.1984-9.8563 2.1984zm62.6-0.74053c-0.89253 0-1.6389-0.11571-2.239-0.34712-0.60015-0.23142-1.0772-0.54768-1.4311-0.9488s-0.60015-0.87937-0.73864-1.4348c-0.1385-0.5554-0.20774-1.1571-0.20774-1.805v-4.0266c-2.1852 2.9004-4.6011 5.176-7.248 6.8267-2.6468 1.6508-5.4629 2.4761-8.4482 2.4761-1.9697 0-3.7702-0.34712-5.4013-1.0414-1.6312-0.69425-3.0392-1.7819-4.2241-3.263s-2.1082-3.3709-2.7699-5.6697c-0.66171-2.2987-0.99255-5.0525-0.99255-8.2615 0-2.777 0.29238-5.4845 0.87714-8.1227 0.58476-2.6381 1.4003-5.1143 2.4468-7.4284s2.2929-4.4354 3.7394-6.3639c1.4465-1.9285 3.0392-3.5792 4.7781-4.9523 1.7389-1.3731 3.5778-2.4453 5.5168-3.2167s3.9394-1.1571 6.0015-1.1571c1.9697 0 3.7471 0.33169 5.3321 0.99508 1.585 0.66339 2.9777 1.535 4.178 2.615l3.0469-24.16h14.034l-8.5867 69.286h-7.6634zm-14.588-10.182c0.98486 0 2.0082-0.37026 3.07-1.1108s2.0928-1.7587 3.0931-3.0547 1.9312-2.8155 2.793-4.5589c0.86176-1.7433 1.6004-3.6178 2.2159-5.6234l1.4773-11.663c-0.89253-0.70968-1.8851-1.2188-2.9777-1.5273s-2.1313-0.46283-3.1162-0.46283c-1.662 0-3.1931 0.55539-4.5934 1.6662s-2.6083 2.5687-3.624 4.3737c-1.0156 1.805-1.8081 3.8646-2.3775 6.1788s-0.85406 4.6746-0.85406 7.0813c0 3.0547 0.44626 5.2685 1.3388 6.6416 0.89253 1.3731 2.0774 2.0596 3.5547 2.0596zm63.465-27.724c-0.43088 0.5554-0.83097 0.95651-1.2003 1.2034s-0.86175 0.37026-1.4773 0.37026-1.2234-0.13885-1.8235-0.41655-1.2465-0.59396-1.9389-0.9488c-0.69248-0.35484-1.4773-0.6711-2.3544-0.9488-0.87714-0.2777-1.8851-0.41655-3.0238-0.41655-2.1236 0-3.6394 0.40883-4.5473 1.2265-0.90792 0.81767-1.3619 1.8745-1.3619 3.1704 0 0.8331 0.25391 1.5428 0.76173 2.129 0.50782 0.58625 1.1772 1.1108 2.0082 1.5736 0.83098 0.46283 1.7774 0.88709 2.8392 1.2728 1.0618 0.38569 2.1467 0.81766 3.2547 1.2959 1.108 0.47826 2.1928 1.0259 3.2547 1.643s2.0082 1.3731 2.8392 2.2679c0.83098 0.89481 1.5004 1.9593 2.0082 3.1935 0.50782 1.2342 0.76173 2.6998 0.76173 4.3969 0 2.4067-0.47704 4.6823-1.4311 6.8267-0.95409 2.1445-2.3236 4.0112-4.1087 5.6002-1.7851 1.5891-3.9471 2.8541-6.4862 3.7952-2.5391 0.94109-5.3936 1.4116-8.5637 1.4116-1.5081 0-3.0007-0.15428-4.478-0.46283-1.4773-0.30856-2.8699-0.7251-4.178-1.2496s-2.5006-1.1494-3.5778-1.8745c-1.0772-0.7251-1.9543-1.5042-2.6314-2.3373l3.5086-5.2763c0.43088-0.61711 0.931-1.1031 1.5004-1.4579 0.56938-0.35484 1.2695-0.53225 2.1005-0.53225 0.76942 0 1.4311 0.18513 1.9851 0.5554 0.55399 0.37027 1.1541 0.77138 1.8004 1.2034s1.4157 0.83309 2.3083 1.2034c0.89253 0.37027 2.062 0.5554 3.5086 0.5554 2.0313 0 3.5393-0.45511 4.5242-1.3653 0.98486-0.91024 1.4773-1.9824 1.4773-3.2167 0-0.95652-0.25391-1.7433-0.76173-2.3604-0.50782-0.61711-1.1772-1.1494-2.0082-1.5968-0.83098-0.4474-1.7697-0.84852-2.8161-1.2034-1.0464-0.35484-2.1236-0.74824-3.2316-1.1802s-2.1852-0.93337-3.2316-1.5042c-1.0464-0.57083-1.9851-1.2882-2.8161-2.1522-0.83098-0.86395-1.5004-1.9285-2.0082-3.1935-0.50782-1.2651-0.76173-2.7924-0.76173-4.582 0-2.2216 0.40779-4.3814 1.2234-6.4796s2.0313-3.9572 3.6471-5.5771c1.6158-1.6199 3.624-2.9235 6.0246-3.9109s5.2013-1.4811 8.4021-1.4811c3.2008 0 6.0553 0.55539 8.5637 1.6662 2.5083 1.1108 4.578 2.4684 6.2092 4.0729l-3.6932 5.0911z" fill="#fff"/> <g transform="translate(128.86 3.5426)" fill="#fff"> <path d="m14.411 3.7958h-8.3873l-0.77821 6.399h7.0759l-0.3891 3.0104h-7.0471l-1.052 8.6095h-3.7613l2.5652-21.029h12.149l-0.37469 3.0104zm-0.59086 18.019 1.8014-14.936h1.8014c0.34587 0 0.62929 0.077562 0.85026 0.23269 0.22097 0.15513 0.33146 0.40236 0.33146 0.7417v0.050901c0 0.033934-0.0048037 0.13331-0.014411 0.29813s-0.019215 0.42417-0.028822 0.77806c-0.0096075 0.35388-0.028822 0.85077-0.057645 1.4907 0.60527-1.1732 1.2682-2.0797 1.9887-2.7196 0.72056-0.6399 1.4699-0.95985 2.2482-0.95985 0.39391 0 0.79262 0.087258 1.1961 0.26178l-0.6485 3.4322c-0.48038-0.2036-0.93673-0.30541-1.3691-0.30541-0.85507 0-1.6044 0.41205-2.2482 1.2362-0.6437 0.82411-1.1721 2.1136-1.5852 3.8685l-0.77821 6.5299h-3.4875zm16.083-14.921-1.7726 14.921h-3.5163l1.7726-14.921h3.5163zm0.8935-4.3484c0 0.31025-0.06485 0.60111-0.19455 0.87259-0.1297 0.27147-0.29783 0.50901-0.50439 0.71261-0.20656 0.2036-0.44434 0.366-0.71336 0.48719-0.26901 0.12119-0.54762 0.18179-0.83585 0.18179-0.27862 0-0.55003-0.060596-0.81423-0.18179-0.26421-0.12119-0.49719-0.28359-0.69894-0.48719s-0.36268-0.44114-0.48278-0.71261c-0.12009-0.27147-0.18014-0.56233-0.18014-0.87259s0.062448-0.60596 0.18735-0.88713 0.28822-0.52597 0.48998-0.73443c0.20176-0.20845 0.43474-0.37327 0.69894-0.49447 0.26421-0.12119 0.53562-0.18179 0.81423-0.18179 0.28823 0 0.56684 0.060596 0.83585 0.18179 0.26901 0.12119 0.50679 0.28359 0.71336 0.48719 0.20656 0.2036 0.37229 0.44599 0.49719 0.72716s0.18735 0.58172 0.18735 0.90167zm13.402 7.8097c0 0.66899-0.1321 1.2798-0.39631 1.8324-0.26421 0.55264-0.73737 1.0471-1.4195 1.4834-0.68213 0.4363-1.6068 0.81199-2.7742 1.1271-1.1673 0.3151-2.6541 0.56476-4.4603 0.74897v0.18906c0 2.3463 0.98476 3.5194 2.9543 3.5194 0.42273 0 0.79742-0.041205 1.1241-0.12362s0.61248-0.18179 0.85747-0.29813 0.46596-0.24723 0.66292-0.39266c0.19695-0.14543 0.37949-0.27632 0.54763-0.39266 0.16813-0.11635 0.33386-0.21572 0.49719-0.29813 0.16333-0.082411 0.34106-0.12362 0.53322-0.12362 0.11529 0 0.23058 0.026662 0.34587 0.079987 0.11529 0.053325 0.21136 0.13331 0.28822 0.23996l0.90791 1.1053c-0.5092 0.51386-1.0088 0.95984-1.4988 1.338-0.48998 0.37812-0.98957 0.68837-1.4988 0.93076-0.5092 0.24239-1.0472 0.42175-1.6141 0.5381-0.56684 0.11635-1.1865 0.17452-1.859 0.17452-0.86468 0-1.6477-0.14785-2.349-0.44356-0.70135-0.29571-1.3018-0.71261-1.8014-1.2507-0.49959-0.5381-0.88629-1.1877-1.1601-1.9488-0.27381-0.76109-0.41072-1.6119-0.41072-2.5523 0-0.78533 0.084065-1.5561 0.2522-2.3124 0.16813-0.75625 0.41072-1.4737 0.72777-2.1524 0.31705-0.67868 0.70615-1.304 1.1673-1.8761 0.46116-0.57203 0.98236-1.0665 1.5636-1.4834 0.58126-0.4169 1.2201-0.7417 1.9167-0.97439 0.69655-0.23269 1.4435-0.34903 2.2409-0.34903 0.77821 0 1.4579 0.1115 2.0392 0.33449 0.58126 0.223 1.0664 0.51143 1.4555 0.86532 0.3891 0.35388 0.67973 0.74897 0.87188 1.1853 0.19215 0.4363 0.28822 0.86289 0.28822 1.2798zm-4.8566-1.1634c-0.48038 0-0.92712 0.099377-1.3402 0.29813-0.41312 0.19876-0.78541 0.4775-1.1169 0.83623-0.33146 0.35873-0.61968 0.78775-0.86467 1.2871-0.24499 0.49932-0.43954 1.0447-0.58365 1.6361 1.1913-0.16482 2.1497-0.34419 2.875-0.5381 0.72537-0.19391 1.2874-0.40721 1.6861-0.6399 0.39871-0.23269 0.66292-0.47992 0.79262-0.7417 0.1297-0.26178 0.19455-0.54294 0.19455-0.8435 0-0.14543-0.031224-0.29571-0.093673-0.45084-0.062449-0.15513-0.15852-0.29329-0.28822-0.41448-0.1297-0.12119-0.29783-0.22299-0.50439-0.30541-0.20656-0.082411-0.45876-0.12362-0.75659-0.12362zm6.0095 12.623 1.7726-14.936h1.8158c0.37469 0 0.66532 0.092105 0.87188 0.27632 0.20656 0.18421 0.30984 0.47992 0.30984 0.88713l-0.10088 1.9342c0.74939-1.115 1.5804-1.9464 2.4931-2.4941 0.91272-0.54779 1.8542-0.82169 2.8246-0.82169 0.54763 0 1.0448 0.099377 1.4916 0.29813s0.82864 0.48962 1.1457 0.87259 0.56204 0.85319 0.73497 1.4107c0.17294 0.55749 0.2594 1.1998 0.2594 1.927 0 0.18421-0.0072055 0.37085-0.021617 0.55991s-0.031224 0.38539-0.050439 0.589l-1.1097 9.4967h-3.5596c0.19215-1.6385 0.35548-3.0274 0.48998-4.1666 0.13451-1.1392 0.24499-2.0869 0.33146-2.8432 0.086468-0.75625 0.15372-1.3501 0.20176-1.7815 0.048038-0.43145 0.084065-0.75866 0.10808-0.98166 0.024019-0.223 0.03843-0.37085 0.043234-0.44356s0.0072056-0.13331 0.0072056-0.18179c0-0.6399-0.11529-1.1029-0.34587-1.3889s-0.59086-0.42902-1.0808-0.42902c-0.39391 0-0.80222 0.11634-1.225 0.34903-0.42273 0.23269-0.82624 0.56233-1.2105 0.98893-0.3843 0.4266-0.73497 0.94045-1.052 1.5416-0.31705 0.60112-0.57645 1.2701-0.77821 2.0069l-0.80703 7.3297h-3.5596zm25.738 0c-0.43234 0-0.73497-0.1018-0.90791-0.30541-0.17294-0.2036-0.2594-0.46053-0.2594-0.77078l0.11529-2.1815c-0.71096 1.0665-1.5084 1.9124-2.3923 2.5378-0.88389 0.62536-1.8254 0.93803-2.8246 0.93803-0.61488 0-1.1745-0.11392-1.6789-0.34176-0.5044-0.22784-0.93433-0.5696-1.2898-1.0253s-0.62929-1.0326-0.82144-1.7306c-0.19215-0.69807-0.28822-1.5222-0.28822-2.4723 0-0.8435 0.086466-1.67 0.2594-2.4796 0.17294-0.80957 0.41792-1.5779 0.73497-2.3051 0.31705-0.72716 0.69414-1.3961 1.1313-2.0069 0.43714-0.61081 0.92472-1.1392 1.4627-1.5852 0.53802-0.44599 1.1121-0.79502 1.7221-1.0471s1.2418-0.37812 1.8951-0.37812c0.66292 0 1.2634 0.12119 1.8014 0.36358 0.53802 0.24239 1.0088 0.57203 1.4123 0.98893l0.96555-7.8097h3.4875l-2.6373 21.611h-1.8879zm-4.8854-2.6032c-0.60527 0-1.076-0.2545-1.4123-0.76351-0.33626-0.50901-0.50439-1.2871-0.50439-2.3342 0-0.80472 0.10088-1.607 0.30264-2.4069 0.20176-0.79988 0.48758-1.5198 0.85747-2.1597 0.36989-0.6399 0.81423-1.1586 1.333-1.5561 0.51881-0.39751 1.0952-0.59627 1.7293-0.59627 0.40352 0 0.81663 0.072715 1.2394 0.21815s0.79742 0.39751 1.1241 0.75624l-0.44675 3.6212c-0.23058 0.73685-0.50679 1.4228-0.82865 2.0579-0.32185 0.63505-0.67012 1.1877-1.0448 1.6579-0.37469 0.47023-0.76379 0.83865-1.1673 1.1053s-0.79742 0.39994-1.1817 0.39994zm19.549-9.5612c-0.10501 0.15274-0.20525 0.26014-0.30071 0.32219-0.095464 0.062051-0.21956 0.093077-0.37231 0.093077-0.16229 0-0.32935-0.047731-0.50118-0.14319-0.17183-0.095464-0.36992-0.20286-0.59426-0.32219-0.22434-0.11933-0.48209-0.22672-0.77325-0.32219s-0.64199-0.14319-1.0525-0.14319c-0.75416 0-1.3317 0.16945-1.7327 0.50834-0.40095 0.3389-0.60142 0.76132-0.60142 1.2673 0 0.29594 0.083529 0.54653 0.25059 0.75177s0.38424 0.38424 0.65154 0.53698c0.2673 0.15274 0.57278 0.29355 0.91645 0.42242s0.69688 0.2673 1.0596 0.41526 0.71597 0.31503 1.0596 0.50118c0.34367 0.18615 0.64915 0.41288 0.91645 0.68017 0.2673 0.2673 0.48447 0.58948 0.65154 0.96656s0.25059 0.82814 0.25059 1.3532c0 0.70643-0.14081 1.3794-0.42242 2.019-0.28162 0.63961-0.68495 1.2004-1.21 1.6825-0.52505 0.48209-1.1599 0.86394-1.9045 1.1456-0.74462 0.28162-1.5751 0.42242-2.4916 0.42242-0.46777 0-0.91883-0.045344-1.3532-0.13603-0.43436-0.09069-0.84246-0.21718-1.2243-0.37947-0.38185-0.16229-0.7279-0.35321-1.0382-0.57278-0.31026-0.21957-0.57516-0.45822-0.79473-0.71597l0.85917-1.346c0.10501-0.16229 0.2315-0.28639 0.37947-0.37231 0.14797-0.085917 0.32219-0.12888 0.52266-0.12888s0.38185 0.06205 0.54414 0.18615c0.16229 0.1241 0.35321 0.26014 0.57278 0.4081s0.48447 0.284 0.79473 0.4081 0.70881 0.18615 1.1957 0.18615c0.3914 0 0.73745-0.052504 1.0382-0.15751 0.30071-0.10501 0.55369-0.2482 0.75893-0.42958 0.20525-0.18138 0.36037-0.3914 0.46538-0.63006 0.10501-0.23866 0.15751-0.49163 0.15751-0.75893 0-0.32458-0.081143-0.59426-0.24343-0.80905-0.16229-0.21479-0.37946-0.40094-0.65154-0.55846-0.27207-0.15751-0.57994-0.29594-0.92361-0.41526s-0.69449-0.24582-1.0525-0.37947c-0.35799-0.13365-0.70643-0.28639-1.0453-0.45822s-0.64437-0.38901-0.91645-0.65154c-0.27207-0.26252-0.48925-0.58232-0.65154-0.9594-0.16229-0.37708-0.24343-0.83769-0.24343-1.3818 0-0.64915 0.1241-1.2816 0.37231-1.8973 0.24821-0.61574 0.61335-1.1599 1.0954-1.6324 0.48209-0.47254 1.074-0.85201 1.7756-1.1384 0.70166-0.28639 1.5059-0.42958 2.4128-0.42958 0.93554 0 1.7637 0.1599 2.4844 0.4797 0.72075 0.3198 1.3293 0.7279 1.8257 1.2243l-0.91645 1.2888z"/> <path d="m57.693 40.297c0.49639 0 0.94473-0.14341 1.345-0.43023 0.40031-0.28682 0.74258-0.6706 1.0268-1.1513 0.28422-0.48073 0.50239-1.0402 0.65451-1.6785 0.15212-0.63828 0.22818-1.3089 0.22818-2.0118 0-1.0099-0.17013-1.7533-0.5104-2.2299-0.34027-0.47669-0.85466-0.71504-1.5432-0.71504-0.49639 0-0.94473 0.14139-1.345 0.42417s-0.74058 0.66656-1.0208 1.1513c-0.28022 0.48477-0.49639 1.0463-0.6485 1.6846-0.15212 0.63828-0.22818 1.3129-0.22818 2.0239 0 1.0099 0.16813 1.7512 0.50439 2.2239s0.84866 0.70898 1.5372 0.70898zm-0.26421 2.3027c-0.68053 0-1.311-0.11513-1.8915-0.3454s-1.0808-0.56758-1.5012-1.012-0.75058-0.98974-0.99077-1.6361c-0.24019-0.64636-0.36028-1.3856-0.36028-2.2178 0-1.0746 0.17013-2.0764 0.5104-3.0056 0.34027-0.92915 0.80462-1.7331 1.3931-2.4117 0.58846-0.67868 1.275-1.2119 2.0596-1.5997 0.78461-0.38782 1.6213-0.58172 2.51-0.58172 0.68053 0 1.311 0.11513 1.8915 0.3454s1.0828 0.56758 1.5072 1.012c0.42433 0.44438 0.75659 0.98974 0.99678 1.6361 0.24019 0.64636 0.36028 1.3856 0.36028 2.2178 0 1.0665-0.17213 2.0623-0.5164 2.9874-0.34427 0.92511-0.81063 1.729-1.3991 2.4117-0.58846 0.68272-1.275 1.22-2.0596 1.6119-0.78461 0.39186-1.6213 0.58778-2.51 0.58778zm12.177-10.374-1.1649 9.6833-0.61248 2.2784c-0.11209 0.3959-0.28622 0.69888-0.52241 0.90894-0.23619 0.21007-0.57044 0.3151-1.0028 0.3151h-1.1889l1.5732-13.186-0.94874-0.16967c-0.17614-0.032318-0.32025-0.098973-0.43234-0.19997-0.11209-0.10099-0.16813-0.2444-0.16813-0.43023 0-0.0080796 0.0020015-0.024238 0.0060047-0.048477 0.0040031-0.024239 0.010008-0.078775 0.018014-0.16361 0.0080063-0.084835 0.022017-0.21411 0.042033-0.38782 0.020016-0.17371 0.050039-0.41811 0.09007-0.73322h1.6573l0.10808-0.92106c0.088069-0.711 0.27421-1.3493 0.55843-1.9148 0.28422-0.56557 0.6445-1.0463 1.0808-1.4422 0.43634-0.3959 0.93873-0.69888 1.5072-0.90894 0.56845-0.21007 1.1809-0.3151 1.8374-0.3151 0.5124 0 0.98476 0.076755 1.4171 0.23027l-0.26421 1.5513c-0.016013 0.088875-0.054042 0.15957-0.11409 0.21209-0.060047 0.052517-0.1341 0.090894-0.22217 0.11513s-0.18614 0.040398-0.29423 0.048477c-0.10808 0.0080796-0.21817 0.012119-0.33026 0.012119-0.32025 0-0.61448 0.044437-0.88269 0.13331s-0.50439 0.23228-0.70855 0.43023c-0.20416 0.19795-0.37229 0.45649-0.50439 0.77563-0.1321 0.31914-0.22618 0.70897-0.28222 1.1695l-0.096075 0.82411h2.7622l-0.27622 2.133h-2.6421z"/> </g> </g> </svg>
1183
+ </div>
1184
+ <div class="pods-admin_friends-callout_content-container">
1185
+ <h2 class="pods-admin_friends-callout_headline"><?php printf( esc_html__( 'We need %1$sYOU%2$s in 2020 and beyond', 'pods' ), '<span class="pods-admin_friends-you">', '</span>' ); ?></h2>
1186
+ <p class="pods-admin_friends-callout_text"><?php esc_html_e( 'Things are changing for Pods and we want you to be a part of it! Our goal is to be fully funded by users like you. Help us reach our goal of 200 recurring donors in 2020.', 'pods' ); ?></p>
1187
+ <div class="pods-admin_friends-callout_button-group">
1188
+ <a href="https://friends.pods.io/?utm_source=pods_plugin_callout&utm_medium=link&utm_campaign=friends_of_pods_2020" class="pods-admin_friends-callout_button"><?php esc_html_e( 'Learn More', 'pods' ); ?></a>
1189
+ <a href="https://friends.pods.io/membership-levels/?utm_source=pods_plugin_callout&utm_medium=link&utm_campaign=friends_of_pods_2020" class="pods-admin_friends-callout_button--join"><?php esc_html_e( 'Join Now', 'pods' ); ?></a>
1190
+ </div>
1191
+ </div>
1192
+ </div>
1193
+ <?php
1194
+ }
1195
+ }
1196
+
1197
  /**
1198
  * Get the add page of an object
1199
  *
2827
  */
2828
  public function admin_settings() {
2829
 
2830
+ // Add our custom callouts.
2831
+ add_action( 'pods_admin_after_settings', array( $this, 'admin_manage_callouts' ) );
2832
+
2833
  pods_view( PODS_DIR . 'ui/admin/settings.php', compact( array_keys( get_defined_vars() ) ) );
2834
  }
2835
 
3020
  $ui['views']['dev'] = __( 'Developer Preview', 'pods' );
3021
  }
3022
 
3023
+ // Add our custom callouts.
3024
+ $this->handle_callouts_updates();
3025
+
3026
+ add_filter( 'pods_ui_manage_custom_container_classes', array( $this, 'admin_manage_container_class' ) );
3027
+ add_action( 'pods_ui_manage_after_container', array( $this, 'admin_manage_callouts' ) );
3028
+
3029
  pods_ui( $ui );
3030
  }
3031
 
3170
  */
3171
  public function admin_help() {
3172
 
3173
+ // Add our custom callouts.
3174
+ $this->handle_callouts_updates();
3175
+
3176
+ add_action( 'pods_admin_after_help', array( $this, 'admin_manage_callouts' ) );
3177
+
3178
  pods_view( PODS_DIR . 'ui/admin/help.php', compact( array_keys( get_defined_vars() ) ) );
3179
  }
3180
 
classes/PodsData.php CHANGED
@@ -1023,7 +1023,7 @@ class PodsData {
1023
  }
1024
 
1025
  if ( ! empty( $params->orderby ) ) {
1026
- if ( 'post_type' === $pod['type'] && 'meta' === $pod['storage'] && is_array( $params->orderby ) ) {
1027
 
1028
  foreach ( $params->orderby as $i => $orderby ) {
1029
  if ( strpos( $orderby, '.meta_value_num' ) ) {
@@ -2332,7 +2332,7 @@ class PodsData {
2332
  $params->sql = self::prepare( $sql[0], array( $sql[1], $sql[2], $sql[3] ) );
2333
  }
2334
  } else {
2335
- $params = array_merge( $params, $sql );
2336
  }
2337
 
2338
  if ( 1 === (int) pods_v( 'pods_debug_sql_all', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
1023
  }
1024
 
1025
  if ( ! empty( $params->orderby ) ) {
1026
+ if ( ! empty( $pod ) && 'post_type' === $pod['type'] && 'meta' === $pod['storage'] && is_array( $params->orderby ) ) {
1027
 
1028
  foreach ( $params->orderby as $i => $orderby ) {
1029
  if ( strpos( $orderby, '.meta_value_num' ) ) {
2332
  $params->sql = self::prepare( $sql[0], array( $sql[1], $sql[2], $sql[3] ) );
2333
  }
2334
  } else {
2335
+ $params = (object) array_merge( get_object_vars( $params ), $sql );
2336
  }
2337
 
2338
  if ( 1 === (int) pods_v( 'pods_debug_sql_all', 'get', 0 ) && pods_is_admin( array( 'pods' ) ) ) {
classes/PodsI18n.php CHANGED
@@ -466,8 +466,10 @@ final class PodsI18n {
466
  */
467
  $lang_data = apply_filters( 'pods_get_current_language', $lang_data, $translator );
468
 
469
- self::$current_language = $lang_data['language'];
470
- self::$current_language_data = $lang_data;
 
 
471
 
472
  return $lang_data;
473
 
466
  */
467
  $lang_data = apply_filters( 'pods_get_current_language', $lang_data, $translator );
468
 
469
+ if ( $lang_data ) {
470
+ self::$current_language = $lang_data['language'];
471
+ self::$current_language_data = $lang_data;
472
+ }
473
 
474
  return $lang_data;
475
 
classes/PodsInit.php CHANGED
@@ -79,6 +79,15 @@ class PodsInit {
79
  */
80
  public static $upgrade_needed = false;
81
 
 
 
 
 
 
 
 
 
 
82
  /**
83
  * Singleton handling for a basic pods_init() request
84
  *
@@ -128,6 +137,7 @@ class PodsInit {
128
 
129
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
130
  add_action( 'plugins_loaded', array( $this, 'activate_install' ), 9 );
 
131
 
132
  add_action( 'wp_loaded', array( $this, 'flush_rewrite_rules' ) );
133
 
@@ -150,6 +160,195 @@ class PodsInit {
150
 
151
  load_plugin_textdomain( 'pods' );
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  }
154
 
155
  /**
@@ -1384,6 +1583,8 @@ class PodsInit {
1384
  */
1385
  public function deactivate() {
1386
 
 
 
1387
  pods_api()->cache_flush_pods();
1388
 
1389
  }
@@ -1665,6 +1866,9 @@ class PodsInit {
1665
  // Show admin bar links
1666
  add_action( 'admin_bar_menu', array( $this, 'admin_bar_links' ), 81 );
1667
 
 
 
 
1668
  // Compatibility for Query Monitor conditionals
1669
  add_filter( 'query_monitor_conditionals', array( $this, 'filter_query_monitor_conditionals' ) );
1670
 
@@ -1863,6 +2067,42 @@ class PodsInit {
1863
 
1864
  }
1865
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1866
  /**
1867
  * Add Pods conditional functions to Query Monitor.
1868
  *
79
  */
80
  public static $upgrade_needed = false;
81
 
82
+ /**
83
+ * Freemius object.
84
+ *
85
+ * @since 1.0.0
86
+ *
87
+ * @var \Freemius
88
+ */
89
+ protected $freemius;
90
+
91
  /**
92
  * Singleton handling for a basic pods_init() request
93
  *
137
 
138
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
139
  add_action( 'plugins_loaded', array( $this, 'activate_install' ), 9 );
140
+ add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
141
 
142
  add_action( 'wp_loaded', array( $this, 'flush_rewrite_rules' ) );
143
 
160
 
161
  load_plugin_textdomain( 'pods' );
162
 
163
+ $this->freemius();
164
+
165
+ }
166
+
167
+ /**
168
+ * Handle Freemius SDK registration.
169
+ *
170
+ * @since 1.0.0
171
+ *
172
+ * @return \Freemius
173
+ */
174
+ public function freemius() {
175
+ if ( $this->freemius ) {
176
+ return $this->freemius;
177
+ }
178
+
179
+ require_once dirname( __DIR__ ) . '/vendor/freemius/wordpress-sdk/start.php';
180
+
181
+ try {
182
+ $this->freemius = fs_dynamic_init( array(
183
+ 'id' => '5347',
184
+ 'slug' => 'pods',
185
+ 'type' => 'plugin',
186
+ 'public_key' => 'pk_737105490825babae220297e18920',
187
+ 'is_premium' => false,
188
+ 'has_addons' => true,
189
+ 'has_paid_plans' => false,
190
+ 'menu' => array(
191
+ 'slug' => 'pods-settings',
192
+ 'contact' => false,
193
+ 'support' => false,
194
+ 'affiliation' => false,
195
+ 'account' => true,
196
+ 'pricing' => false,
197
+ 'addons' => true,
198
+ 'parent' => array(
199
+ 'slug' => 'pods',
200
+ ),
201
+ ),
202
+ ) );
203
+
204
+ $this->override_freemius_strings();
205
+
206
+ add_filter( 'fs_plugins_api', array( $this, 'filter_freemius_plugins_api_data' ), 15 );
207
+
208
+ $this->freemius->add_filter( 'templates/add-ons.php', array( $this, 'filter_freemius_addons_html' ) );
209
+ $this->freemius->add_filter( 'download_latest_url', array( $this, 'get_freemius_action_link' ) );
210
+
211
+ /**
212
+ * Allow hooking into the Freemius registration after Pods has registered it's own Freemius.
213
+ */
214
+ do_action( 'pods_freemius_init' );
215
+ } catch ( \Exception $exception ) {
216
+ return null;
217
+ }
218
+
219
+ return $this->freemius;
220
+ }
221
+
222
+ /**
223
+ * Override Freemius strings.
224
+ */
225
+ public function override_freemius_strings() {
226
+ $override_text = array(
227
+ 'free' => 'Free (WordPress.org)',
228
+ 'install-free-version-now' => 'Install Now',
229
+ 'download-latest' => 'Donate',
230
+ );
231
+
232
+ $freemius_addons = $this->get_freemius_addons();
233
+
234
+ fs_override_i18n( $override_text, 'pods' );
235
+
236
+ foreach ( $freemius_addons as $addon_slug => $addon ) {
237
+ fs_override_i18n( $override_text, $addon_slug );
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Filter the Freemius plugins API data.
243
+ *
244
+ * @since TBD
245
+ *
246
+ * @param object $data Freemius plugins API data.
247
+ *
248
+ * @return object Freemius plugins API data.
249
+ */
250
+ public function filter_freemius_plugins_api_data( $data ) {
251
+ if ( empty( $data->sections['features'] ) ) {
252
+ return $data;
253
+ }
254
+
255
+ $data->sections['features'] = preg_replace( '/(<span\s+class="fs-price"><\/span>)/Uim', '<span class="fs-price">Friends-only</span>', $data->sections['features'] );
256
+
257
+ return $data;
258
+ }
259
+
260
+ /**
261
+ * Filter the Freemius add-ons HTML.
262
+ *
263
+ * @since TBD
264
+ *
265
+ * @param string $html Freemius add-ons HTML.
266
+ *
267
+ * @return string Freemius add-ons HTML.
268
+ */
269
+ public function filter_freemius_addons_html( $html ) {
270
+ $freemius_friends_addons = $this->get_freemius_friends_addons();
271
+
272
+ // Replace blank prices with Friends-only.
273
+ $html = preg_replace( '/<span\s+class="fs-price"><\/span>/Uim', '<span class="fs-price">Friends-only</span>', $html );
274
+
275
+ // Remove dropdown arrow for action links.
276
+ $html = preg_replace( '/<div\s+class="button button-primary fs-dropdown-arrow-button">/Uim', '<div class="hidden">', $html );
277
+
278
+ // Use landing page for Become a Friend link.
279
+ $replace = '$1<a target="_blank" href="' . esc_url( $this->get_freemius_action_link() ) . '"$2class="$3">';
280
+
281
+ // Replace all Friends-only add-on links.
282
+ foreach ( $freemius_friends_addons as $addon_slug => $addon ) {
283
+ $pattern = '/(<li class="fs-card fs-addon" data-slug="' . preg_quote( esc_attr( $addon_slug ), '/' ) . '">\s+)<a href="[^"]+"([^>]+)class="thickbox([^>]+)">/Uim';
284
+
285
+ $html = preg_replace( $pattern, $replace, $html );
286
+ }
287
+
288
+ return $html;
289
+ }
290
+
291
+ /**
292
+ * Get action link URL.
293
+ *
294
+ * @since TBD
295
+ *
296
+ * @param string $url Action link URL.
297
+ *
298
+ * @return string Action link URL.
299
+ */
300
+ public function get_freemius_action_link( $url = null ) {
301
+ return 'https://friends.pods.io/add-ons/';
302
+ }
303
+
304
+ /**
305
+ * Get list of add-ons for Freemius.
306
+ *
307
+ * @since TBD
308
+ *
309
+ * @return array List of add-ons for Freemius.
310
+ */
311
+ public function get_freemius_addons() {
312
+ return array(
313
+ 'pods-beaver-builder-themer-add-on' => 'Pods Beaver Themer Add-On',
314
+ 'pods-gravity-forms' => 'Pods Gravity Forms Add-On',
315
+ 'pods-alternative-cache' => 'Pods Alternative Cache',
316
+ 'pods-simple-relationships' => 'Pods Simple Relationships',
317
+ 'pods-seo' => 'Pods SEO',
318
+ 'pods-ajax-views' => 'Pods AJAX Views',
319
+ );
320
+ }
321
+
322
+ /**
323
+ * Get list of Friends-only add-ons for Freemius.
324
+ *
325
+ * @since TBD
326
+ *
327
+ * @return array List of Friends-only add-ons for Freemius.
328
+ */
329
+ public function get_freemius_friends_addons() {
330
+ return array(
331
+ 'pods-simple-relationships' => 'Pods Simple Relationships',
332
+ );
333
+ }
334
+
335
+ /**
336
+ * Add compatibility for other plugins.
337
+ *
338
+ * @since 2.7.17
339
+ */
340
+ public function after_setup_theme() {
341
+
342
+ if ( ! defined( 'PODS_COMPATIBILITY' ) ) {
343
+ define( 'PODS_COMPATIBILITY', true );
344
+ }
345
+
346
+ if ( ! PODS_COMPATIBILITY ) {
347
+ return;
348
+ }
349
+
350
+ require_once PODS_DIR . 'includes/compatibility/acf.php';
351
+
352
  }
353
 
354
  /**
1583
  */
1584
  public function deactivate() {
1585
 
1586
+ delete_option( 'pods_callouts' );
1587
+
1588
  pods_api()->cache_flush_pods();
1589
 
1590
  }
1866
  // Show admin bar links
1867
  add_action( 'admin_bar_menu', array( $this, 'admin_bar_links' ), 81 );
1868
 
1869
+ // Compatibility with WP 5.4 privacy export.
1870
+ add_filter( 'wp_privacy_additional_user_profile_data', array( $this, 'filter_wp_privacy_additional_user_profile_data' ), 10, 3 );
1871
+
1872
  // Compatibility for Query Monitor conditionals
1873
  add_filter( 'query_monitor_conditionals', array( $this, 'filter_query_monitor_conditionals' ) );
1874
 
2067
 
2068
  }
2069
 
2070
+ /**
2071
+ * Add Pod fields to user export.
2072
+ * Requires WordPress 5.4+
2073
+ *
2074
+ * @since 2.7.17
2075
+ *
2076
+ * @param array $additional_user_profile_data {
2077
+ * An array of name-value pairs of additional user data items. Default: the empty array.
2078
+ *
2079
+ * @type string $name The user-facing name of an item name-value pair, e.g. 'IP Address'.
2080
+ * @type string $value The user-facing value of an item data pair, e.g. '50.60.70.0'.
2081
+ * }
2082
+ * @param WP_User $user The user whose data is being exported.
2083
+ * @param array $reserved_names An array of reserved names. Any item in
2084
+ * `$additional_user_data` that uses one of these
2085
+ * for it's `name` will not be included in the export.
2086
+ *
2087
+ * @return array
2088
+ */
2089
+ public function filter_wp_privacy_additional_user_profile_data( $additional_user_profile_data, $user, $reserved_names ) {
2090
+ $pod = pods( 'user', $user->ID );
2091
+
2092
+ if ( ! $pod->valid() ) {
2093
+ return $additional_user_profile_data;
2094
+ }
2095
+
2096
+ foreach ( $pod->fields as $name => $field ) {
2097
+ $additional_user_profile_data[] = array(
2098
+ 'name' => apply_filters( 'pods_form_ui_label_text', $field['label'], $name, '', $field ),
2099
+ 'value' => $pod->display( $name ),
2100
+ );
2101
+ }
2102
+
2103
+ return $additional_user_profile_data;
2104
+ }
2105
+
2106
  /**
2107
  * Add Pods conditional functions to Query Monitor.
2108
  *
classes/PodsMeta.php CHANGED
@@ -3089,49 +3089,31 @@ class PodsMeta {
3089
 
3090
  foreach ( $meta_keys as $meta_k ) {
3091
  if ( ! empty( $pod ) ) {
3092
- if ( isset( $pod->fields[ $meta_k ] ) ) {
 
 
 
 
 
 
3093
  $key_found = true;
3094
 
3095
  $meta_cache[ $meta_k ] = $pod->field( array(
3096
  'name' => $meta_k,
3097
  'single' => $single,
3098
- 'get_meta' => true
3099
  ) );
3100
 
3101
- if ( ( ! is_array( $meta_cache[ $meta_k ] ) || ! isset( $meta_cache[ $meta_k ][0] ) ) ) {
3102
- if ( empty( $meta_cache[ $meta_k ] ) && ! is_array( $meta_cache[ $meta_k ] ) && $single ) {
3103
  $meta_cache[ $meta_k ] = array();
3104
  } else {
3105
  $meta_cache[ $meta_k ] = array( $meta_cache[ $meta_k ] );
3106
  }
3107
  }
3108
 
3109
- if ( in_array( $pod->fields[ $meta_k ]['type'], PodsForm::tableless_field_types() ) && isset( $meta_cache[ '_pods_' . $meta_k ] ) ) {
3110
- unset( $meta_cache[ '_pods_' . $meta_k ] );
3111
- }
3112
- } elseif ( false !== strpos( $meta_k, '.' ) ) {
3113
- $key_found = true;
3114
-
3115
- $first = current( explode( '.', $meta_k ) );
3116
-
3117
- if ( isset( $pod->fields[ $first ] ) ) {
3118
- $meta_cache[ $meta_k ] = $pod->field( array(
3119
- 'name' => $meta_k,
3120
- 'single' => $single,
3121
- 'get_meta' => true
3122
- ) );
3123
-
3124
- if ( ( ! is_array( $meta_cache[ $meta_k ] ) || ! isset( $meta_cache[ $meta_k ][0] ) ) && $single ) {
3125
- if ( empty( $meta_cache[ $meta_k ] ) && ! is_array( $meta_cache[ $meta_k ] ) && $single ) {
3126
- $meta_cache[ $meta_k ] = array();
3127
- } else {
3128
- $meta_cache[ $meta_k ] = array( $meta_cache[ $meta_k ] );
3129
- }
3130
- }
3131
-
3132
- if ( in_array( $pod->fields[ $first ]['type'], PodsForm::tableless_field_types() ) && isset( $meta_cache[ '_pods_' . $first ] ) ) {
3133
- unset( $meta_cache[ '_pods_' . $first ] );
3134
- }
3135
  }
3136
  }
3137
  }
3089
 
3090
  foreach ( $meta_keys as $meta_k ) {
3091
  if ( ! empty( $pod ) ) {
3092
+ $first_meta_key = $meta_k;
3093
+ if ( false !== strpos( $first_meta_key, '.' ) ) {
3094
+ // Get the first meta key.
3095
+ $first_meta_key = current( explode( '.', $first_meta_key ) );
3096
+ }
3097
+
3098
+ if ( isset( $pod->fields[ $first_meta_key ] ) ) {
3099
  $key_found = true;
3100
 
3101
  $meta_cache[ $meta_k ] = $pod->field( array(
3102
  'name' => $meta_k,
3103
  'single' => $single,
3104
+ 'get_meta' => true,
3105
  ) );
3106
 
3107
+ if ( $single && ( ! is_array( $meta_cache[ $meta_k ] ) || ! isset( $meta_cache[ $meta_k ][0] ) ) ) {
3108
+ if ( empty( $meta_cache[ $meta_k ] ) && ! is_array( $meta_cache[ $meta_k ] ) ) {
3109
  $meta_cache[ $meta_k ] = array();
3110
  } else {
3111
  $meta_cache[ $meta_k ] = array( $meta_cache[ $meta_k ] );
3112
  }
3113
  }
3114
 
3115
+ if ( in_array( $pod->fields[ $first_meta_key ]['type'], PodsForm::tableless_field_types() ) && isset( $meta_cache[ '_pods_' . $first_meta_key ] ) ) {
3116
+ unset( $meta_cache[ '_pods_' . $first_meta_key ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3117
  }
3118
  }
3119
  }
classes/PodsMigrate.php CHANGED
@@ -111,6 +111,21 @@ class PodsMigrate {
111
 
112
  $this->data = array_merge( $defaults, (array) $data );
113
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  /**
116
  * Importing / Parsing / Validating Code
@@ -570,7 +585,9 @@ class PodsMigrate {
570
 
571
  $head = substr( $head, 0, - 1 );
572
 
573
- foreach ( $this->data['items'] as $item ) {
 
 
574
  $line = '';
575
 
576
  foreach ( $this->data['columns'] as $column => $label ) {
@@ -636,10 +653,12 @@ class PodsMigrate {
636
  return false;
637
  }
638
 
639
- $head = '<' . '?' . 'xml version="1.0" encoding="utf-8" ' . '?' . '>' . "\r\n<items count=\"" . count( $this->data['items'] ) . "\">\r\n";
 
 
640
  $lines = '';
641
 
642
- foreach ( $this->data['items'] as $item ) {
643
  $line = "\t<item>\r\n";
644
 
645
  foreach ( $this->data['columns'] as $column => $label ) {
@@ -1258,10 +1277,24 @@ class PodsMigrate {
1258
  }
1259
 
1260
  $migrate_data = array(
1261
- 'items' => array( $data ),
1262
  'single' => $single,
1263
  );
1264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1265
  $migrate = new self( $format, null, $migrate_data );
1266
 
1267
  // Handle processing the data into the format needed.
111
 
112
  $this->data = array_merge( $defaults, (array) $data );
113
  }
114
+
115
+ /**
116
+ * Get items.
117
+ *
118
+ * @since 2.7.17
119
+ *
120
+ * @return array List of data items.
121
+ */
122
+ private function get_items() {
123
+
124
+ return empty( $this->data['single'] ) ?
125
+ $this->data['items'] :
126
+ array( $this->data['items'] );
127
+
128
+ }
129
 
130
  /**
131
  * Importing / Parsing / Validating Code
585
 
586
  $head = substr( $head, 0, - 1 );
587
 
588
+ $items = $this->get_items();
589
+
590
+ foreach ( $items as $item ) {
591
  $line = '';
592
 
593
  foreach ( $this->data['columns'] as $column => $label ) {
653
  return false;
654
  }
655
 
656
+ $items = $this->get_items();
657
+
658
+ $head = '<' . '?' . 'xml version="1.0" encoding="utf-8" ' . '?' . '>' . "\r\n<items count=\"" . count( $items ) . "\">\r\n";
659
  $lines = '';
660
 
661
+ foreach ( $items as $item ) {
662
  $line = "\t<item>\r\n";
663
 
664
  foreach ( $this->data['columns'] as $column => $label ) {
1277
  }
1278
 
1279
  $migrate_data = array(
1280
+ 'items' => $data,
1281
  'single' => $single,
1282
  );
1283
 
1284
+ // Try to guess the column labels based on the supplied data.
1285
+ $first_item = null;
1286
+
1287
+ if ( $single ) {
1288
+ $first_item = $data;
1289
+ } elseif ( is_array( $data ) ) {
1290
+ $first_item = reset( $data );
1291
+ }
1292
+
1293
+ if ( is_array( $first_item ) ) {
1294
+ $fields = array_keys( $first_item );
1295
+ $migrate_data['columns'] = array_combine( $fields, $fields );
1296
+ }
1297
+
1298
  $migrate = new self( $format, null, $migrate_data );
1299
 
1300
  // Handle processing the data into the format needed.
classes/PodsUI.php CHANGED
@@ -433,6 +433,7 @@ class PodsUI {
433
  */
434
  public $save = false;
435
  // Allow custom save handling for tables that aren't Pod-based
 
436
  /**
437
  * Generate UI for Data Management
438
  *
@@ -518,7 +519,7 @@ class PodsUI {
518
  if ( ( ! is_object( $this->pod ) || 'Pods' != get_class( $this->pod ) ) && false === $this->sql['table'] && false === $this->data ) {
519
  echo $this->error( __( '<strong>Error:</strong> Pods UI needs a Pods object or a Table definition to run from, see the User Guide for more information.', 'pods' ) );
520
 
521
- return false;
522
  }
523
 
524
  // Assign pod labels
@@ -1477,7 +1478,7 @@ class PodsUI {
1477
  return;
1478
  }
1479
  ?>
1480
- <div id="message" class="<?php echo esc_attr( $class ); ?> fade">
1481
  <p><?php echo $msg; ?></p>
1482
  </div>
1483
  <?php
@@ -1658,7 +1659,7 @@ class PodsUI {
1658
  /**
1659
  * @param bool $duplicate
1660
  *
1661
- * @return mixed
1662
  */
1663
  public function edit( $duplicate = false ) {
1664
 
@@ -2168,7 +2169,7 @@ class PodsUI {
2168
  $check = $wpdb->query( $wpdb->prepare( "INSERT INTO $this->sql['table'] SET $field_sql", $values ) );
2169
  }
2170
  if ( $check ) {
2171
- if ( 0 == $this->insert_id ) {
2172
  $this->insert_id = $wpdb->insert_id;
2173
  }
2174
  $this->message( sprintf( __( '<strong>Success!</strong> %1\$s %2\$s successfully.', 'pods' ), $this->item, $action ) );
@@ -2363,9 +2364,9 @@ class PodsUI {
2363
  <ul>
2364
  <?php foreach ( $this->pod->fields() as $field_name => $field ) { ?>
2365
  <li>
2366
- <label for="bulk_export_fields_<?php echo esc_attr( $field['name'] ); ?>">
2367
- <input type="checkbox" name="bulk_export_fields[]" id="bulk_export_fields_<?php echo esc_attr( $field['name'] ); ?>" value="<?php echo esc_attr( $field['name'] ); ?>" />
2368
- <?php echo esc_html( $field['label'] ); ?>
2369
  </label>
2370
  </li>
2371
  <?php } ?>
@@ -2374,7 +2375,7 @@ class PodsUI {
2374
  <p class="submit">
2375
  <?php _e( 'Export as:', 'pods' ); ?>&nbsp;&nbsp;
2376
  <?php foreach ( $this->export['formats'] as $format => $separator ) { ?>
2377
- <input type="submit" id="export_type_<?php echo esc_attr( strtoupper( $format ) ); ?>" value=" <?php echo esc_attr( strtoupper( $format ) ); ?> " name="bulk_export_type" class="button-primary" />
2378
  <?php } ?>
2379
  </p>
2380
  </form>
@@ -2821,389 +2822,423 @@ class PodsUI {
2821
  $icon_style = ' style="background-position:0 0;background-size:100%;background-image:url(' . esc_url( $this->icon ) . ');"';
2822
  }
2823
 
 
 
 
 
 
 
 
 
 
 
 
 
2824
  ?>
2825
- <div class="wrap pods-admin pods-ui">
2826
- <div id="icon-edit-pages" class="icon32"<?php echo $icon_style; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>>
2827
- <br />
2828
- </div>
2829
- <h2>
2830
- <?php
2831
- if ( true === $reorder ) {
2832
- echo wp_kses_post( $this->header['reorder'] );
 
2833
 
2834
- if ( ! in_array( 'manage', $this->actions_disabled ) && ! in_array( 'manage', $this->actions_hidden ) && ! $this->restricted( 'manage' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2835
  $link = pods_query_arg(
2836
  array(
2837
- 'action' . $this->num => 'manage',
2838
  'id' . $this->num => '',
2839
- ), self::$allowed, $this->exclusion()
 
 
2840
  );
2841
 
2842
- if ( ! empty( $this->action_links['manage'] ) ) {
2843
- $link = $this->action_links['manage'];
2844
  }
2845
- ?>
2846
- <small>(<a href="<?php echo esc_url( $link ); ?>">&laquo; <?php echo sprintf( __( 'Back to %s', 'pods' ), $this->heading['manage'] ); ?></a>)</small>
2847
- <?php
2848
  }
2849
- } else {
2850
- echo wp_kses_post( $this->header['manage'] );}
2851
-
2852
- if ( ! in_array( 'add', $this->actions_disabled ) && ! in_array( 'add', $this->actions_hidden ) && ! $this->restricted( 'add' ) ) {
2853
- $link = pods_query_arg(
2854
- array(
2855
- 'action' . $this->num => 'add',
2856
- 'id' . $this->num => '',
2857
- 'do' . $this->num => '',
2858
- ), self::$allowed, $this->exclusion()
2859
- );
2860
 
2861
- if ( ! empty( $this->action_links['add'] ) ) {
2862
- $link = $this->action_links['add'];}
 
 
 
 
 
2863
  ?>
2864
- <a href="<?php echo esc_url( $link ); ?>" class="add-new-h2"><?php echo wp_kses_post( $this->label['add_new'] ); ?></a>
2865
- <?php
2866
- }
2867
- if ( ! in_array( 'reorder', $this->actions_disabled ) && ! in_array( 'reorder', $this->actions_hidden ) && false !== $this->reorder['on'] && ! $this->restricted( 'reorder' ) ) {
2868
- $link = pods_query_arg( array( 'action' . $this->num => 'reorder' ), self::$allowed, $this->exclusion() );
2869
 
2870
- if ( ! empty( $this->action_links['reorder'] ) ) {
2871
- $link = $this->action_links['reorder'];}
2872
- ?>
2873
- <a href="<?php echo esc_url( $link ); ?>" class="add-new-h2"><?php echo wp_kses_post( $this->label['reorder'] ); ?></a>
2874
  <?php
2875
- }
2876
- ?>
2877
- </h2>
2878
-
2879
- <form id="posts-filter" action="" method="get">
2880
- <?php
2881
- $excluded_filters = array(
2882
- 'search' . $this->num,
2883
- 'pg' . $this->num,
2884
- 'action' . $this->num,
2885
- 'action_bulk' . $this->num,
2886
- 'action_bulk_ids' . $this->num,
2887
- '_wpnonce' . $this->num,
2888
- );
2889
 
2890
- $filters = $this->filters;
2891
 
2892
- foreach ( $filters as $k => $filter ) {
2893
- if ( isset( $this->pod->fields[ $filter ] ) ) {
2894
- $filter_field = $this->pod->fields[ $filter ];
2895
- } elseif ( isset( $this->fields['manage'][ $filter ] ) ) {
2896
- $filter_field = $this->fields['manage'][ $filter ];
2897
- } else {
2898
- unset( $filters[ $k ] );
2899
- continue;
2900
- }
2901
 
2902
- if ( in_array( $filter_field['type'], array( 'date', 'datetime', 'time' ) ) ) {
2903
- if ( '' == pods_var_raw( 'filter_' . $filter . '_start', 'get', '', null, true ) && '' == pods_var_raw( 'filter_' . $filter . '_end', 'get', '', null, true ) ) {
 
 
 
 
2904
  unset( $filters[ $k ] );
2905
  continue;
2906
  }
2907
- } elseif ( '' === pods_var_raw( 'filter_' . $filter, 'get', '' ) ) {
2908
- unset( $filters[ $k ] );
2909
- continue;
2910
- }
2911
 
2912
- $excluded_filters[] = 'filter_' . $filter . '_start';
2913
- $excluded_filters[] = 'filter_' . $filter . '_end';
2914
- $excluded_filters[] = 'filter_' . $filter;
2915
- }//end foreach
2916
 
2917
- $get = $_GET;
2918
 
2919
- foreach ( $get as $k => $v ) {
2920
- if ( is_array( $v ) || in_array( $k, $excluded_filters ) || strlen( $v ) < 1 ) {
2921
- continue;}
2922
- ?>
2923
- <input type="hidden" name="<?php echo esc_attr( $k ); ?>" value="<?php echo esc_attr( $v ); ?>" />
2924
- <?php
2925
- }
 
2926
 
2927
- if ( false !== $this->callback( 'header', $reorder ) ) {
2928
- return null;
2929
- }
2930
 
2931
- if ( false === $this->data ) {
2932
- $this->get_data();} elseif ( $this->sortable ) {
2933
- // we have the data already as an array
2934
- $this->sort_data();}
 
2935
 
2936
- if ( ! in_array( 'export', $this->actions_disabled ) && 'export' === $this->action ) {
2937
- $this->export();}
2938
 
2939
- if ( ( ! empty( $this->data ) || false !== $this->search || ( $this->filters_enhanced && ! empty( $this->views ) ) ) && ( ( $this->filters_enhanced && ! empty( $this->views ) ) || false !== $this->searchable ) ) {
2940
- if ( $this->filters_enhanced ) {
2941
- $this->filters();} else {
2942
- ?>
2943
- <p class="search-box" align="right">
2944
- <?php
2945
- $excluded_filters = array( 'search' . $this->num, 'pg' . $this->num );
 
2946
 
2947
- foreach ( $this->filters as $filter ) {
2948
- $excluded_filters[] = 'filter_' . $filter . '_start';
2949
- $excluded_filters[] = 'filter_' . $filter . '_end';
2950
- $excluded_filters[] = 'filter_' . $filter;
2951
- }
2952
 
2953
- $this->hidden_vars( $excluded_filters );
2954
 
2955
- foreach ( $this->filters as $filter ) {
2956
- if ( isset( $this->pod->fields[ $filter ] ) ) {
2957
- $filter_field = $this->pod->fields[ $filter ];
2958
- } elseif ( isset( $this->fields['manage'][ $filter ] ) ) {
2959
- $filter_field = $this->fields['manage'][ $filter ];
2960
- } else {
2961
- continue;
2962
- }
2963
 
2964
- if ( in_array( $filter_field['type'], array( 'date', 'datetime', 'time' ) ) ) {
2965
- $start = pods_var_raw( 'filter_' . $filter . '_start', 'get', pods_var_raw( 'filter_default', $filter_field, '', null, true ), null, true );
2966
- $end = pods_var_raw( 'filter_' . $filter . '_end', 'get', pods_var_raw( 'filter_ongoing_default', $filter_field, '', null, true ), null, true );
2967
 
2968
- // override default value
2969
- $filter_field['options']['default_value'] = '';
2970
- $filter_field['options'][ $filter_field['type'] . '_allow_empty' ] = 1;
2971
 
2972
- if ( ! empty( $start ) && ! in_array( $start, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) {
2973
- $start = PodsForm::field_method( $filter_field['type'], 'convert_date', $start, 'n/j/Y' );}
 
2974
 
2975
- if ( ! empty( $end ) && ! in_array( $end, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) {
2976
- $end = PodsForm::field_method( $filter_field['type'], 'convert_date', $end, 'n/j/Y' );}
2977
- ?>
2978
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>_start">
2979
- <?php echo esc_html( $filter_field['label'] ); ?>
2980
- </label>
2981
- <?php echo PodsForm::field( 'filter_' . $filter . '_start', $start, $filter_field['type'], $filter_field ); ?>
2982
-
2983
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>_end">
2984
- to
2985
- </label>
2986
- <?php
2987
- echo PodsForm::field( 'filter_' . $filter . '_end', $end, $filter_field['type'], $filter_field );
2988
- } elseif ( 'pick' === $filter_field['type'] ) {
2989
- $value = pods_var_raw( 'filter_' . $filter );
 
2990
 
2991
- if ( strlen( $value ) < 1 ) {
2992
- $value = pods_var_raw( 'filter_default', $filter_field );}
2993
 
2994
- // override default value
2995
- $filter_field['options']['default_value'] = '';
2996
 
2997
- $filter_field['options']['pick_format_type'] = 'single';
2998
- $filter_field['options']['pick_format_single'] = 'dropdown';
2999
 
3000
- $filter_field['options']['input_helper'] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields['search'], array(), null, true ), array(), null, true ), '', null, true );
3001
- $filter_field['options']['input_helper'] = pods_var_raw( 'ui_input_helper', $filter_field['options'], $filter_field['options']['input_helper'], null, true );
3002
 
3003
- $options = array_merge( $filter_field, $filter_field['options'] );
3004
- ?>
3005
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>">
3006
- <?php echo esc_html( $filter_field['label'] ); ?>
3007
- </label>
3008
- <?php
3009
- echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options );
3010
- } elseif ( 'boolean' === $filter_field['type'] ) {
3011
- $value = pods_var_raw( 'filter_' . $filter, 'get', '' );
3012
 
3013
- if ( strlen( $value ) < 1 ) {
3014
- $value = pods_var_raw( 'filter_default', $filter_field );}
3015
 
3016
- // override default value
3017
- $filter_field['options']['default_value'] = '';
3018
 
3019
- $filter_field['options']['pick_format_type'] = 'single';
3020
- $filter_field['options']['pick_format_single'] = 'dropdown';
3021
 
3022
- $filter_field['options']['pick_object'] = 'custom-simple';
3023
- $filter_field['options']['pick_custom'] = array(
3024
- '1' => pods_var_raw( 'boolean_yes_label', $filter_field['options'], __( 'Yes', 'pods' ), null, true ),
3025
- '0' => pods_var_raw( 'boolean_no_label', $filter_field['options'], __( 'No', 'pods' ), null, true ),
3026
- );
3027
 
3028
- $filter_field['options']['input_helper'] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields['search'], array(), null, true ), array(), null, true ), '', null, true );
3029
- $filter_field['options']['input_helper'] = pods_var_raw( 'ui_input_helper', $filter_field['options'], $filter_field['options']['input_helper'], null, true );
3030
 
3031
- $options = array_merge( $filter_field, $filter_field['options'] );
3032
- ?>
3033
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>">
3034
- <?php echo esc_html( $filter_field['label'] ); ?>
3035
- </label>
3036
- <?php
3037
- echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options );
3038
- } else {
3039
- $value = pods_var_raw( 'filter_' . $filter );
3040
 
3041
- if ( strlen( $value ) < 1 ) {
3042
- $value = pods_var_raw( 'filter_default', $filter_field );}
3043
 
3044
- // override default value
3045
- $filter_field['options']['default_value'] = '';
3046
 
3047
- $options = array();
3048
- $options['input_helper'] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields['search'], array(), null, true ), array(), null, true ), '', null, true );
3049
- $options['input_helper'] = pods_var_raw( 'ui_input_helper', $options, $options['input_helper'], null, true );
3050
- ?>
3051
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>">
3052
- <?php echo esc_html( $filter_field['label'] ); ?>
3053
- </label>
3054
- <?php
3055
- echo PodsForm::field( 'filter_' . $filter, $value, 'text', $options );
3056
- }//end if
3057
- }//end foreach
3058
-
3059
- if ( false !== $this->do_hook( 'filters_show_search', true ) ) {
3060
- ?>
3061
- &nbsp;&nbsp; <label<?php echo ( empty( $this->filters ) ) ? ' class="screen-reader-text"' : ''; ?> for="page-search<?php echo esc_attr( $this->num ); ?>-input"><?php _e( 'Search', 'pods' ); ?>:</label>
3062
- <?php echo PodsForm::field( 'search' . $this->num, $this->search, 'text', array( 'attributes' => array( 'id' => 'page-search' . $this->num . '-input' ) ) ); ?>
3063
- <?php
3064
- } else {
3065
- echo PodsForm::field( 'search' . $this->num, '', 'hidden' );
3066
- }
3067
- ?>
3068
- <?php echo PodsForm::submit_button( $this->header['search'], 'button', false, false, array( 'id' => 'search' . $this->num . '-submit' ) ); ?>
3069
- <?php
3070
- if ( 0 < strlen( $this->search ) ) {
3071
- $clear_filters = array(
3072
- 'search' . $this->num => false,
3073
- );
3074
-
3075
- foreach ( $this->filters as $filter ) {
3076
- $clear_filters[ 'filter_' . $filter . '_start' ] = false;
3077
- $clear_filters[ 'filter_' . $filter . '_end' ] = false;
3078
- $clear_filters[ 'filter_' . $filter ] = false;
3079
- }
3080
- ?>
3081
- <br class="clear" />
3082
- <small>[<a href="<?php echo esc_url( pods_query_arg( $clear_filters, array( 'orderby' . $this->num, 'orderby_dir' . $this->num, 'limit' . $this->num, 'page' ), $this->exclusion() ) ); ?>"><?php _e( 'Reset Filters', 'pods' ); ?></a>]</small>
3083
- <br class="clear" />
3084
- <?php
3085
- }
3086
- ?>
3087
- </p>
3088
- <?php
3089
- }//end if
3090
- } else {
3091
- ?>
3092
- <br class="clear" />
3093
- <?php
3094
- }//end if
3095
 
3096
- if ( ! empty( $this->data ) && ( false !== $this->pagination_total || false !== $this->pagination || true === $reorder ) || ( ! in_array( 'export', $this->actions_disabled ) && ! in_array( 'export', $this->actions_hidden ) ) || ! empty( $this->actions_disabled ) ) {
3097
- ?>
3098
- <div class="tablenav">
3099
- <?php
3100
- if ( ! empty( $this->data ) && ! empty( $this->actions_bulk ) ) {
3101
- ?>
3102
- <div class="alignleft actions">
3103
- <?php wp_nonce_field( 'pods-ui-action-bulk', '_wpnonce' . $this->num, false ); ?>
3104
 
3105
- <select name="action_bulk<?php echo esc_attr( $this->num ); ?>">
3106
- <option value="-1" selected="selected"><?php _e( 'Bulk Actions', 'pods' ); ?></option>
3107
 
3108
- <?php
3109
- foreach ( $this->actions_bulk as $action => $action_data ) {
3110
- if ( in_array( $action, $this->actions_hidden ) || in_array( $action, $this->actions_hidden ) ) {
3111
- continue;}
3112
 
3113
- if ( ! isset( $action_data['label'] ) ) {
3114
- $action_data['label'] = ucwords( str_replace( '_', ' ', $action ) );}
3115
- ?>
3116
- <option value="<?php echo esc_attr( $action ); ?>"><?php echo esc_html( $action_data['label'] ); ?></option>
3117
- <?php
 
 
 
 
 
3118
  }
3119
  ?>
3120
- </select>
3121
-
3122
- <input type="submit" id="doaction_bulk<?php echo esc_attr( $this->num ); ?>" class="button-secondary action" value="<?php esc_attr_e( 'Apply', 'pods' ); ?>">
3123
- </div>
3124
- <?php
 
 
3125
  }//end if
3126
 
3127
- if ( true !== $reorder && ( false !== $this->pagination_total || false !== $this->pagination ) ) {
3128
  ?>
3129
- <div class="tablenav-pages<?php echo esc_attr( ( $this->limit < $this->total_found || 1 < $this->page ) ? '' : ' one-page' ); ?>">
3130
- <?php $this->pagination( 1 ); ?>
3131
- </div>
3132
  <?php
3133
- }
 
 
 
3134
 
3135
- if ( true === $reorder ) {
3136
- $link = pods_query_arg(
3137
- array(
3138
- 'action' . $this->num => 'manage',
3139
- 'id' . $this->num => '',
3140
- ), self::$allowed, $this->exclusion()
3141
- );
3142
 
3143
- if ( ! empty( $this->action_links['manage'] ) ) {
3144
- $link = $this->action_links['manage'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3145
  }
3146
- ?>
3147
- <input type="button" value="<?php esc_attr_e( 'Update Order', 'pods' ); ?>" class="button" onclick="jQuery('form.admin_ui_reorder_form').submit();" />
3148
- <input type="button" value="<?php esc_attr_e( 'Cancel', 'pods' ); ?>" class="button" onclick="document.location='<?php echo esc_js( $link ); ?>';" />
3149
- </form>
3150
- <?php
3151
- } elseif ( ! in_array( 'export', $this->actions_disabled ) && ! in_array( 'export', $this->actions_hidden ) ) {
3152
- $export_document_location = pods_slash(
3153
- pods_query_arg(
3154
  array(
3155
- 'action_bulk' . $this->num => 'export',
3156
- '_wpnonce' => wp_create_nonce( 'pods-ui-action-bulk' ),
3157
  ), self::$allowed, $this->exclusion()
3158
- )
3159
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3160
  ?>
3161
- <div class="alignleft actions">
3162
- <input type="button" value="<?php echo esc_attr( sprintf( __( 'Export all %s', 'pods' ), $this->items ) ); ?>" class="button" onclick="document.location='<?php echo $export_document_location; ?>';" />
3163
  </div>
3164
  <?php
 
 
 
 
3165
  }//end if
 
 
 
 
3166
  ?>
3167
- <br class="clear" />
3168
- </div>
3169
  <?php
3170
- } else {
3171
  ?>
3172
- <br class="clear" />
3173
  <?php
3174
- }//end if
3175
- ?>
3176
- <div class="clear"></div>
3177
- <?php
3178
- if ( empty( $this->data ) && false !== $this->default_none && false === $this->search ) {
3179
- ?>
3180
- <p><?php _e( 'Please use the search filter(s) above to display data', 'pods' ); ?>
3181
- <?php
3182
- if ( $this->export ) {
3183
- ?>
3184
- , <?php _e( 'or click on an Export to download a full copy of the data', 'pods' ); ?><?php } ?>.</p>
3185
- <?php
3186
- } else {
3187
- $this->table( $reorder );}
3188
- if ( ! empty( $this->data ) ) {
3189
- if ( true !== $reorder && ( false !== $this->pagination_total || false !== $this->pagination ) ) {
3190
- ?>
3191
- <div class="tablenav">
3192
- <div class="tablenav-pages<?php echo esc_attr( ( $this->limit < $this->total_found || 1 < $this->page ) ? '' : ' one-page' ); ?>">
3193
- <?php $this->pagination( 0 ); ?>
3194
- <br class="clear" />
3195
  </div>
3196
- </div>
3197
- <?php
3198
  }
3199
- }
3200
 
3201
- ?>
3202
- </form>
 
 
 
 
 
 
 
 
 
 
3203
  </div>
3204
  <?php
3205
- if ( $this->filters_enhanced ) {
3206
- $this->filters_popup();}
 
3207
  }
3208
 
3209
  public function filters() {
@@ -3268,7 +3303,7 @@ class PodsUI {
3268
  $label = wp_kses_post( $label );
3269
  }
3270
  ?>
3271
- <li class="<?php echo esc_attr( $view ); ?>">
3272
  <?php
3273
  /* Escaped above to support links */
3274
  echo $label;
@@ -3318,7 +3353,7 @@ class PodsUI {
3318
  if ( false !== $this->do_hook( 'filters_show_search', true ) ) {
3319
  ?>
3320
  &nbsp;&nbsp;
3321
- <label class="screen-reader-text" for="page-search<?php echo esc_attr( $this->num ); ?>-input"><?php _e( 'Search', 'pods' ); ?>:</label>
3322
  <?php echo PodsForm::field( 'search' . $this->num, $this->search, 'text', array( 'attributes' => array( 'id' => 'page-search' . $this->num . '-input' ) ) ); ?>
3323
  <?php
3324
  } else {
@@ -3417,10 +3452,10 @@ class PodsUI {
3417
  $value_label = $value;
3418
  }
3419
  ?>
3420
- <li class="pods-ui-filter-bar-filter" data-filter="<?php echo esc_attr( $data_filter ); ?>">
3421
  <a href="#TB_inline?width=640&inlineId=pods-ui-posts-filter-popup" class="thickbox" title="<?php esc_attr_e( 'Advanced Filters', 'pods' ); ?>">
3422
- <strong><?php echo esc_html( $filter_field['label'] ); ?>:</strong>
3423
- <?php echo esc_html( $value_label ); ?>
3424
  </a>
3425
 
3426
  <a href="#remove-filter" class="remove-filter" title="<?php esc_attr_e( 'Remove Filter', 'pods' ); ?>">x</a>
@@ -3453,10 +3488,10 @@ class PodsUI {
3453
  jQuery( this ).remove();
3454
  } );
3455
 
3456
- jQuery( 'form#posts-filter [name="pg<?php echo esc_attr( $this->num ); ?>"]' ).prop( 'disabled', true );
3457
- jQuery( 'form#posts-filter [name="action<?php echo esc_attr( $this->num ); ?>"]' ).prop( 'disabled', true );
3458
- jQuery( 'form#posts-filter [name="action_bulk<?php echo esc_attr( $this->num ); ?>"]' ).prop( 'disabled', true );
3459
- jQuery( 'form#posts-filter [name="_wpnonce<?php echo esc_attr( $this->num ); ?>"]' ).prop( 'disabled', true );
3460
 
3461
  jQuery( 'form#posts-filter' ).submit();
3462
 
@@ -3501,7 +3536,7 @@ class PodsUI {
3501
  continue;
3502
  }
3503
  ?>
3504
- <input type="hidden" name="<?php echo esc_attr( $k ); ?>" value="<?php echo esc_attr( $v ); ?>" />
3505
  <?php
3506
  }
3507
 
@@ -3520,7 +3555,7 @@ class PodsUI {
3520
  continue;
3521
  }
3522
  ?>
3523
- <p class="pods-ui-posts-filter-toggled pods-ui-posts-filter-<?php echo esc_attr( $filter . ( $zebra ? ' clear' : '' ) ); ?>">
3524
  <?php
3525
  if ( in_array( $filter_field['type'], array( 'date', 'datetime', 'time' ) ) ) {
3526
  $start = pods_var_raw( 'filter_' . $filter . '_start', 'get', pods_var_raw( 'filter_default', $filter_field, '', null, true ), null, true );
@@ -3550,17 +3585,17 @@ class PodsUI {
3550
  $end = PodsForm::field_method( $filter_field['type'], 'convert_date', $end, 'n/j/Y' );
3551
  }
3552
  ?>
3553
- <span class="pods-ui-posts-filter-toggle toggle-on<?php echo esc_attr( ( empty( $start ) && empty( $end ) ) ? '' : ' pods-hidden' ); ?>">+</span>
3554
- <span class="pods-ui-posts-filter-toggle toggle-off<?php echo esc_attr( ( empty( $start ) && empty( $end ) ) ? ' pods-hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span>
3555
 
3556
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>_start">
3557
- <?php echo esc_html( $filter_field['label'] ); ?>
3558
  </label>
3559
 
3560
- <span class="pods-ui-posts-filter<?php echo esc_attr( ( empty( $start ) && empty( $end ) ) ? ' pods-hidden' : '' ); ?>">
3561
  <?php echo PodsForm::field( 'filter_' . $filter . '_start', $start, $filter_field['type'], $filter_field ); ?>
3562
 
3563
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>_end">to</label>
3564
  <?php echo PodsForm::field( 'filter_' . $filter . '_end', $end, $filter_field['type'], $filter_field ); ?>
3565
  </span>
3566
  <?php
@@ -3582,14 +3617,14 @@ class PodsUI {
3582
 
3583
  $options = array_merge( $filter_field, $filter_field['options'] );
3584
  ?>
3585
- <span class="pods-ui-posts-filter-toggle toggle-on<?php echo esc_attr( empty( $value ) ? '' : ' pods-hidden' ); ?>">+</span>
3586
- <span class="pods-ui-posts-filter-toggle toggle-off<?php echo esc_attr( empty( $value ) ? ' pods-hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span>
3587
 
3588
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>">
3589
- <?php echo esc_html( $filter_field['label'] ); ?>
3590
  </label>
3591
 
3592
- <span class="pods-ui-posts-filter<?php echo esc_attr( strlen( $value ) < 1 ? ' pods-hidden' : '' ); ?>">
3593
  <?php echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options ); ?>
3594
  </span>
3595
  <?php
@@ -3617,14 +3652,14 @@ class PodsUI {
3617
 
3618
  $options = array_merge( $filter_field, $filter_field['options'] );
3619
  ?>
3620
- <span class="pods-ui-posts-filter-toggle toggle-on<?php echo esc_attr( empty( $value ) ? '' : ' pods-hidden' ); ?>">+</span>
3621
- <span class="pods-ui-posts-filter-toggle toggle-off<?php echo esc_attr( empty( $value ) ? ' pods-hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span>
3622
 
3623
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>">
3624
- <?php echo esc_html( $filter_field['label'] ); ?>
3625
  </label>
3626
 
3627
- <span class="pods-ui-posts-filter<?php echo esc_attr( strlen( $value ) < 1 ? ' pods-hidden' : '' ); ?>">
3628
  <?php echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options ); ?>
3629
  </span>
3630
  <?php
@@ -3643,14 +3678,14 @@ class PodsUI {
3643
  $options['input_helper'] = $filter_field['options']['input_helper'];
3644
  }
3645
  ?>
3646
- <span class="pods-ui-posts-filter-toggle toggle-on<?php echo esc_attr( empty( $value ) ? '' : ' pods-hidden' ); ?>">+</span>
3647
- <span class="pods-ui-posts-filter-toggle toggle-off<?php echo esc_attr( empty( $value ) ? ' pods-hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span>
3648
 
3649
- <label for="pods-form-ui-filter-<?php echo esc_attr( $filter ); ?>">
3650
- <?php echo esc_html( $filter_field['label'] ); ?>
3651
  </label>
3652
 
3653
- <span class="pods-ui-posts-filter<?php echo esc_attr( empty( $value ) ? ' pods-hidden' : '' ); ?>">
3654
  <?php echo PodsForm::field( 'filter_' . $filter, $value, 'text', $options ); ?>
3655
  </span>
3656
  <?php
@@ -3662,16 +3697,16 @@ class PodsUI {
3662
  }//end foreach
3663
  ?>
3664
 
3665
- <p class="pods-ui-posts-filter-toggled pods-ui-posts-filter-search<?php echo esc_attr( $zebra ? ' clear' : '' ); ?>">
3666
- <label for="pods-form-ui-search<?php echo esc_attr( $this->num ); ?>"><?php _e( 'Search Text', 'pods' ); ?></label>
3667
  <?php echo PodsForm::field( 'search' . $this->num, pods_var_raw( 'search' . $this->num ), 'text' ); ?>
3668
  </p>
3669
 
3670
  <?php $zebra = empty( $zebra ); ?>
3671
  </div>
3672
 
3673
- <p class="submit<?php echo esc_attr( $zebra ? ' clear' : '' ); ?>">
3674
- <input type="submit" value="<?php echo esc_attr( $this->header['search'] ); ?>" class="button button-primary" />
3675
  </p>
3676
  </form>
3677
  </div>
@@ -3841,7 +3876,7 @@ class PodsUI {
3841
  if ( $fields[ $field ]['sortable'] ) {
3842
  $column_classes[] = 'sortable' . $current_sort;
3843
  ?>
3844
- <th scope="col"<?php echo $att_id; ?> class="<?php echo esc_attr( implode( ' ', $column_classes ) ); ?>"<?php echo $width; ?>>
3845
  <a href="
3846
  <?php
3847
  echo esc_url_raw(
@@ -3859,13 +3894,13 @@ class PodsUI {
3859
  );
3860
  ?>
3861
  ">
3862
- <span><?php echo esc_html( $attributes['label'] ); ?></span>
3863
  <span class="sorting-indicator"></span> </a>
3864
  </th>
3865
  <?php
3866
  } else {
3867
  ?>
3868
- <th scope="col"<?php echo $att_id; ?> class="<?php echo esc_attr( implode( ' ', $column_classes ) ); ?>"<?php echo $width; ?>><?php echo esc_html( $attributes['label'] ); ?></th>
3869
  <?php
3870
  }//end if
3871
  }//end foreach
@@ -3904,7 +3939,7 @@ class PodsUI {
3904
 
3905
  if ( $fields[ $field ]['sortable'] ) {
3906
  ?>
3907
- <th scope="col" class="manage-column column-<?php echo esc_attr( $id ); ?> sortable <?php echo esc_attr( $current_sort ); ?>"<?php echo $width; ?>>
3908
  <a href="
3909
  <?php
3910
  echo esc_url_raw(
@@ -3921,12 +3956,12 @@ class PodsUI {
3921
  )
3922
  );
3923
  ?>
3924
- "><span><?php echo esc_html( $attributes['label'] ); ?></span><span class="sorting-indicator"></span></a>
3925
  </th>
3926
  <?php
3927
  } else {
3928
  ?>
3929
- <th scope="col" class="manage-column column-<?php echo esc_attr( $id ); ?>"<?php echo $width; ?>><?php echo esc_html( $attributes['label'] ); ?></th>
3930
  <?php
3931
  }//end if
3932
  }//end foreach
@@ -3957,12 +3992,12 @@ class PodsUI {
3957
  }
3958
  }
3959
  ?>
3960
- <tr id="item-<?php echo esc_attr( $row[ $this->sql['field_id'] ] ); ?>" class="iedit<?php echo esc_attr( $toggle_class ); ?>">
3961
  <?php
3962
  if ( ! empty( $this->actions_bulk ) ) {
3963
  ?>
3964
  <th scope="row" class="check-column">
3965
- <input type="checkbox" name="action_bulk_ids<?php echo esc_attr( $this->num ); ?>[]" value="<?php echo esc_attr( $row[ $this->sql['field_id'] ] ); ?>">
3966
  </th>
3967
  <?php
3968
  }
@@ -4158,7 +4193,7 @@ class PodsUI {
4158
  $link = $this->do_template( $this->action_links['edit'], $row );
4159
  }
4160
  ?>
4161
- <td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>">
4162
  <strong><a class="row-title" href="<?php echo esc_url_raw( $link ); ?>" title="<?php esc_attr_e( 'Edit this item', 'pods' ); ?>">
4163
  <?php
4164
  /* Escaped above for non-HTML types */
@@ -4178,7 +4213,7 @@ class PodsUI {
4178
  $link = $this->do_template( $this->action_links['view'], $row );
4179
  }
4180
  ?>
4181
- <td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>">
4182
  <strong><a class="row-title" href="<?php echo esc_url_raw( $link ); ?>" title="<?php esc_attr_e( 'View this item', 'pods' ); ?>">
4183
  <?php
4184
  /* Escaped above for non-HTML types */
@@ -4191,7 +4226,7 @@ class PodsUI {
4191
  $css_classes[] = 'dragme';
4192
  }
4193
  ?>
4194
- <td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>">
4195
  <strong>
4196
  <?php
4197
  /* Escaped above for non-HTML types */
@@ -4209,7 +4244,7 @@ class PodsUI {
4209
 
4210
  if ( ! empty( $actions ) ) {
4211
  ?>
4212
- <div class="row-actions<?php echo esc_attr( $toggle ? ' row-actions-toggle' : '' ); ?>">
4213
  <?php
4214
  $this->callback( 'actions_start', $row, $actions );
4215
 
@@ -4222,7 +4257,7 @@ class PodsUI {
4222
  }
4223
  } else {
4224
  ?>
4225
- <input type="hidden" name="order[]" value="<?php echo esc_attr( $row[ $this->sql['field_id'] ] ); ?>" />
4226
  <?php
4227
  }//end if
4228
  ?>
@@ -4238,8 +4273,8 @@ class PodsUI {
4238
  $css_classes[] = 'date';
4239
  $css_classes[] = 'column-date';
4240
  ?>
4241
- <td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>" data-colname="<?php echo esc_attr( $attributes['label'] ); ?>">
4242
- <abbr title="<?php echo esc_attr( $row_value ); ?>"><?php echo wp_kses_post( $row_value ); ?></abbr>
4243
  <?php if ( $first_field ) { ?>
4244
  <button type="button" class="toggle-row">
4245
  <span class="screen-reader-text"><?php esc_html_e( 'Show more details', 'pods' ); ?></span>
@@ -4257,7 +4292,7 @@ class PodsUI {
4257
  $row_value = wp_kses_post( $row_value );
4258
  }
4259
  ?>
4260
- <td class="<?php echo esc_attr( implode( ' ', $css_classes ) ); ?>" data-colname="<?php echo esc_attr( $attributes['label'] ); ?>">
4261
  <span>
4262
  <?php
4263
  /* Escaped above for non-HTML types */
@@ -4522,8 +4557,8 @@ class PodsUI {
4522
  continue;
4523
  }
4524
  ?>
4525
- <label for="<?php echo esc_attr( $field ); ?>-hide">
4526
- <input class="hide-column-tog" name="<?php echo esc_attr( $this->unique_identifier ); ?>_<?php echo esc_attr( $field ); ?>-hide" type="checkbox" id="<?php echo esc_attr( $field ); ?>-hide" value="<?php echo esc_attr( $field ); ?>" checked="checked"><?php echo esc_html( $attributes['label'] ); ?>
4527
  </label>
4528
  <?php
4529
  }
@@ -4538,14 +4573,14 @@ class PodsUI {
4538
  <?php
4539
  if ( true === $this->pagination ) {
4540
  ?>
4541
- <input type="text" class="screen-per-page" name="wp_screen_options[value]" id="<?php echo esc_attr( $this->unique_identifier ); ?>_per_page" maxlength="3" value="20">
4542
- <label for="<?php echo esc_attr( $this->unique_identifier ); ?>_per_page"><?php echo esc_html( sprintf( __( '%s per page', 'pods' ), $this->items ) ); ?></label>
4543
  <?php
4544
  }
4545
  $this->do_hook( 'screen_meta_screen_submit' );
4546
  ?>
4547
  <input type="submit" name="screen-options-apply" id="screen-options-apply" class="button" value="<?php esc_attr_e( 'Apply', 'pods' ); ?>">
4548
- <input type="hidden" name="wp_screen_options[option]" value="<?php echo esc_attr( $this->unique_identifier ); ?>_per_page">
4549
  <?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?>
4550
  </div>
4551
  <?php
@@ -4669,12 +4704,12 @@ class PodsUI {
4669
  $classes .= ' button';
4670
  }
4671
  ?>
4672
- <a class="first-page<?php echo esc_attr( $classes ); ?>" title="<?php esc_attr_e( 'Go to the first page', 'pods' ); ?>" href="<?php echo $first_link; ?>">&laquo;</a>
4673
- <a class="prev-page<?php echo esc_attr( $classes ); ?>" title="<?php esc_attr_e( 'Go to the previous page', 'pods' ); ?>" href="<?php echo $prev_link; ?>">&lsaquo;</a>
4674
  <?php
4675
  if ( true == $header ) {
4676
  ?>
4677
- <span class="paging-input"><input class="current-page" title="<?php esc_attr_e( 'Current page', 'pods' ); ?>" type="text" name="pg<?php echo esc_attr( $this->num ); ?>" value="<?php echo esc_attr( absint( $this->page ) ); ?>" size="<?php echo esc_attr( strlen( $total_pages ) ); ?>"> <?php _e( 'of', 'pods' ); ?>
4678
  <span class="total-pages"><?php echo absint( $total_pages ); ?></span></span>
4679
  <script>
4680
 
@@ -4682,7 +4717,7 @@ class PodsUI {
4682
  var pageInput = $( 'input.current-page' );
4683
  var currentPage = pageInput.val();
4684
  pageInput.closest( 'form' ).submit( function ( e ) {
4685
- if ( ( 1 > $( 'select[name="action<?php echo esc_attr( $this->num ); ?>"]' ).length || $( 'select[name="action<?php echo esc_attr( $this->num ); ?>"]' ).val() == -1 ) && ( 1 > $( 'select[name="action_bulk<?php echo esc_attr( $this->num ); ?>"]' ).length || $( 'select[name="action_bulk<?php echo esc_attr( $this->num ); ?>"]' ).val() == -1 ) && pageInput.val() == currentPage ) {
4686
  pageInput.val( '1' );
4687
  }
4688
  } );
@@ -4703,8 +4738,8 @@ class PodsUI {
4703
  $classes .= ' button';
4704
  }
4705
  ?>
4706
- <a class="next-page<?php echo esc_attr( $classes ); ?>" title="<?php esc_attr_e( 'Go to the next page', 'pods' ); ?>" href="<?php echo $next_link; ?>">&rsaquo;</a>
4707
- <a class="last-page<?php echo esc_attr( $classes ); ?>" title="<?php esc_attr_e( 'Go to the last page', 'pods' ); ?>" href="<?php echo $last_link; ?>">&raquo</a>
4708
  <?php
4709
  }//end if
4710
  }//end if
@@ -4858,12 +4893,12 @@ class PodsUI {
4858
  if ( is_array( $v ) ) {
4859
  foreach ( $v as $vk => $vv ) {
4860
  ?>
4861
- <input type="hidden" name="<?php echo esc_attr( $k ); ?>[<?php echo esc_attr( $vk ); ?>]" value="<?php echo esc_attr( $vv ); ?>" />
4862
  <?php
4863
  }
4864
  } else {
4865
  ?>
4866
- <input type="hidden" name="<?php echo esc_attr( $k ); ?>" value="<?php echo esc_attr( $v ); ?>" />
4867
  <?php
4868
  }
4869
  }
433
  */
434
  public $save = false;
435
  // Allow custom save handling for tables that aren't Pod-based
436
+
437
  /**
438
  * Generate UI for Data Management
439
  *
519
  if ( ( ! is_object( $this->pod ) || 'Pods' != get_class( $this->pod ) ) && false === $this->sql['table'] && false === $this->data ) {
520
  echo $this->error( __( '<strong>Error:</strong> Pods UI needs a Pods object or a Table definition to run from, see the User Guide for more information.', 'pods' ) );
521
 
522
+ return null;
523
  }
524
 
525
  // Assign pod labels
1478
  return;
1479
  }
1480
  ?>
1481
+ <div id="message" class="<?php esc_attr_e( $class ); ?> fade">
1482
  <p><?php echo $msg; ?></p>
1483
  </div>
1484
  <?php
1659
  /**
1660
  * @param bool $duplicate
1661
  *
1662
+ * @return bool|mixed
1663
  */
1664
  public function edit( $duplicate = false ) {
1665
 
2169
  $check = $wpdb->query( $wpdb->prepare( "INSERT INTO $this->sql['table'] SET $field_sql", $values ) );
2170
  }
2171
  if ( $check ) {
2172
+ if ( empty( $this->insert_id ) ) {
2173
  $this->insert_id = $wpdb->insert_id;
2174
  }
2175
  $this->message( sprintf( __( '<strong>Success!</strong> %1\$s %2\$s successfully.', 'pods' ), $this->item, $action ) );
2364
  <ul>
2365
  <?php foreach ( $this->pod->fields() as $field_name => $field ) { ?>
2366
  <li>
2367
+ <label for="bulk_export_fields_<?php esc_attr_e( $field['name'] ); ?>">
2368
+ <input type="checkbox" name="bulk_export_fields[]" id="bulk_export_fields_<?php esc_attr_e( $field['name'] ); ?>" value="<?php esc_attr_e( $field['name'] ); ?>" />
2369
+ <?php esc_html_e( $field['label'] ); ?>
2370
  </label>
2371
  </li>
2372
  <?php } ?>
2375
  <p class="submit">
2376
  <?php _e( 'Export as:', 'pods' ); ?>&nbsp;&nbsp;
2377
  <?php foreach ( $this->export['formats'] as $format => $separator ) { ?>
2378
+ <input type="submit" id="export_type_<?php esc_attr_e( strtoupper( $format ) ); ?>" value=" <?php esc_attr_e( strtoupper( $format ) ); ?> " name="bulk_export_type" class="button-primary" />
2379
  <?php } ?>
2380
  </p>
2381
  </form>
2822
  $icon_style = ' style="background-position:0 0;background-size:100%;background-image:url(' . esc_url( $this->icon ) . ');"';
2823
  }
2824
 
2825
+ /**
2826
+ * Allow adding custom CSS classes to the Pods::manage() container.
2827
+ *
2828
+ * @since 2.6.8
2829
+ *
2830
+ * @param array $custom_container_classes List of custom classes to use.
2831
+ * @param PodsUI $this PodsUI instance.
2832
+ */
2833
+ $custom_container_classes = apply_filters( 'pods_ui_manage_custom_container_classes', array() );
2834
+
2835
+ $custom_container_classes = array_map( 'sanitize_html_class', $custom_container_classes );
2836
+ $custom_container_classes = implode( ' ', $custom_container_classes );
2837
  ?>
2838
+ <div class="wrap pods-admin pods-ui <?php echo esc_attr( $custom_container_classes ); ?>">
2839
+ <div class="pods-admin-container">
2840
+ <div id="icon-edit-pages" class="icon32"<?php echo $icon_style; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>>
2841
+ <br />
2842
+ </div>
2843
+ <h2>
2844
+ <?php
2845
+ if ( true === $reorder ) {
2846
+ echo wp_kses_post( $this->header['reorder'] );
2847
 
2848
+ if ( ! in_array( 'manage', $this->actions_disabled ) && ! in_array( 'manage', $this->actions_hidden ) && ! $this->restricted( 'manage' ) ) {
2849
+ $link = pods_query_arg(
2850
+ array(
2851
+ 'action' . $this->num => 'manage',
2852
+ 'id' . $this->num => '',
2853
+ ),
2854
+ self::$allowed, $this->exclusion()
2855
+ );
2856
+
2857
+ if ( ! empty( $this->action_links['manage'] ) ) {
2858
+ $link = $this->action_links['manage'];
2859
+ }
2860
+ ?>
2861
+ <small>(<a href="<?php echo esc_url( $link ); ?>">&laquo; <?php echo sprintf( __( 'Back to %s', 'pods' ), $this->heading['manage'] ); ?></a>)</small>
2862
+ <?php
2863
+ }
2864
+ } else {
2865
+ echo wp_kses_post( $this->header['manage'] );
2866
+ }
2867
+
2868
+ if ( ! in_array( 'add', $this->actions_disabled ) && ! in_array( 'add', $this->actions_hidden ) && ! $this->restricted( 'add' ) ) {
2869
  $link = pods_query_arg(
2870
  array(
2871
+ 'action' . $this->num => 'add',
2872
  'id' . $this->num => '',
2873
+ 'do' . $this->num => '',
2874
+ ),
2875
+ self::$allowed, $this->exclusion()
2876
  );
2877
 
2878
+ if ( ! empty( $this->action_links['add'] ) ) {
2879
+ $link = $this->action_links['add'];
2880
  }
2881
+ ?>
2882
+ <a href="<?php echo esc_url( $link ); ?>" class="add-new-h2"><?php echo wp_kses_post( $this->label['add_new'] ); ?></a>
2883
+ <?php
2884
  }
2885
+ if ( ! in_array( 'reorder', $this->actions_disabled ) && ! in_array( 'reorder', $this->actions_hidden ) && false !== $this->reorder['on'] && ! $this->restricted( 'reorder' ) ) {
2886
+ $link = pods_query_arg( array( 'action' . $this->num => 'reorder' ), self::$allowed, $this->exclusion() );
 
 
 
 
 
 
 
 
 
2887
 
2888
+ if ( ! empty( $this->action_links['reorder'] ) ) {
2889
+ $link = $this->action_links['reorder'];
2890
+ }
2891
+ ?>
2892
+ <a href="<?php echo esc_url( $link ); ?>" class="add-new-h2"><?php echo wp_kses_post( $this->label['reorder'] ); ?></a>
2893
+ <?php
2894
+ }
2895
  ?>
2896
+ </h2>
 
 
 
 
2897
 
2898
+ <form id="posts-filter" action="" method="get">
 
 
 
2899
  <?php
2900
+ $excluded_filters = array(
2901
+ 'search' . $this->num,
2902
+ 'pg' . $this->num,
2903
+ 'action' . $this->num,
2904
+ 'action_bulk' . $this->num,
2905
+ 'action_bulk_ids' . $this->num,
2906
+ '_wpnonce' . $this->num,
2907
+ );
 
 
 
 
 
 
2908
 
2909
+ $filters = $this->filters;
2910
 
2911
+ foreach ( $filters as $k => $filter ) {
2912
+ if ( isset( $this->pod->fields[ $filter ] ) ) {
2913
+ $filter_field = $this->pod->fields[ $filter ];
2914
+ } elseif ( isset( $this->fields['manage'][ $filter ] ) ) {
2915
+ $filter_field = $this->fields['manage'][ $filter ];
2916
+ } else {
2917
+ unset( $filters[ $k ] );
2918
+ continue;
2919
+ }
2920
 
2921
+ if ( in_array( $filter_field['type'], array( 'date', 'datetime', 'time' ) ) ) {
2922
+ if ( '' == pods_var_raw( 'filter_' . $filter . '_start', 'get', '', null, true ) && '' == pods_var_raw( 'filter_' . $filter . '_end', 'get', '', null, true ) ) {
2923
+ unset( $filters[ $k ] );
2924
+ continue;
2925
+ }
2926
+ } elseif ( '' === pods_var_raw( 'filter_' . $filter, 'get', '' ) ) {
2927
  unset( $filters[ $k ] );
2928
  continue;
2929
  }
 
 
 
 
2930
 
2931
+ $excluded_filters[] = 'filter_' . $filter . '_start';
2932
+ $excluded_filters[] = 'filter_' . $filter . '_end';
2933
+ $excluded_filters[] = 'filter_' . $filter;
2934
+ }//end foreach
2935
 
2936
+ $get = $_GET;
2937
 
2938
+ foreach ( $get as $k => $v ) {
2939
+ if ( is_array( $v ) || in_array( $k, $excluded_filters ) || 1 > strlen( $v ) ) {
2940
+ continue;
2941
+ }
2942
+ ?>
2943
+ <input type="hidden" name="<?php esc_attr_e( $k ); ?>" value="<?php esc_attr_e( $v ); ?>" />
2944
+ <?php
2945
+ }
2946
 
2947
+ if ( false !== $this->callback( 'header', $reorder ) ) {
2948
+ return null;
2949
+ }
2950
 
2951
+ if ( false === $this->data ) {
2952
+ $this->get_data();
2953
+ } elseif ( $this->sortable ) {
2954
+ // we have the data already as an array
2955
+ $this->sort_data();}
2956
 
2957
+ if ( ! in_array( 'export', $this->actions_disabled ) && 'export' === $this->action ) {
2958
+ $this->export();}
2959
 
2960
+ if ( ( ! empty( $this->data ) || false !== $this->search || ( $this->filters_enhanced && ! empty( $this->views ) ) ) && ( ( $this->filters_enhanced && ! empty( $this->views ) ) || false !== $this->searchable ) ) {
2961
+ if ( $this->filters_enhanced ) {
2962
+ $this->filters();
2963
+ } else {
2964
+ ?>
2965
+ <p class="search-box" align="right">
2966
+ <?php
2967
+ $excluded_filters = array( 'search' . $this->num, 'pg' . $this->num );
2968
 
2969
+ foreach ( $this->filters as $filter ) {
2970
+ $excluded_filters[] = 'filter_' . $filter . '_start';
2971
+ $excluded_filters[] = 'filter_' . $filter . '_end';
2972
+ $excluded_filters[] = 'filter_' . $filter;
2973
+ }
2974
 
2975
+ $this->hidden_vars( $excluded_filters );
2976
 
2977
+ foreach ( $this->filters as $filter ) {
2978
+ if ( isset( $this->pod->fields[ $filter ] ) ) {
2979
+ $filter_field = $this->pod->fields[ $filter ];
2980
+ } elseif ( isset( $this->fields['manage'][ $filter ] ) ) {
2981
+ $filter_field = $this->fields['manage'][ $filter ];
2982
+ } else {
2983
+ continue;
2984
+ }
2985
 
2986
+ if ( in_array( $filter_field['type'], array( 'date', 'datetime', 'time' ) ) ) {
2987
+ $start = pods_var_raw( 'filter_' . $filter . '_start', 'get', pods_var_raw( 'filter_default', $filter_field, '', null, true ), null, true );
2988
+ $end = pods_var_raw( 'filter_' . $filter . '_end', 'get', pods_var_raw( 'filter_ongoing_default', $filter_field, '', null, true ), null, true );
2989
 
2990
+ // override default value
2991
+ $filter_field['options']['default_value'] = '';
2992
+ $filter_field['options'][ $filter_field['type'] . '_allow_empty' ] = 1;
2993
 
2994
+ if ( ! empty( $start ) && ! in_array( $start, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) {
2995
+ $start = PodsForm::field_method( $filter_field['type'], 'convert_date', $start, 'n/j/Y' );
2996
+ }
2997
 
2998
+ if ( ! empty( $end ) && ! in_array( $end, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) {
2999
+ $end = PodsForm::field_method( $filter_field['type'], 'convert_date', $end, 'n/j/Y' );
3000
+ }
3001
+ ?>
3002
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>_start">
3003
+ <?php esc_html_e( $filter_field['label'] ); ?>
3004
+ </label>
3005
+ <?php echo PodsForm::field( 'filter_' . $filter . '_start', $start, $filter_field['type'], $filter_field ); ?>
3006
+
3007
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>_end">
3008
+ to
3009
+ </label>
3010
+ <?php
3011
+ echo PodsForm::field( 'filter_' . $filter . '_end', $end, $filter_field['type'], $filter_field );
3012
+ } elseif ( 'pick' === $filter_field['type'] ) {
3013
+ $value = pods_var_raw( 'filter_' . $filter );
3014
 
3015
+ if ( strlen( $value ) < 1 ) {
3016
+ $value = pods_var_raw( 'filter_default', $filter_field );}
3017
 
3018
+ // override default value
3019
+ $filter_field['options']['default_value'] = '';
3020
 
3021
+ $filter_field['options']['pick_format_type'] = 'single';
3022
+ $filter_field['options']['pick_format_single'] = 'dropdown';
3023
 
3024
+ $filter_field['options']['input_helper'] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields['search'], array(), null, true ), array(), null, true ), '', null, true );
3025
+ $filter_field['options']['input_helper'] = pods_var_raw( 'ui_input_helper', $filter_field['options'], $filter_field['options']['input_helper'], null, true );
3026
 
3027
+ $options = array_merge( $filter_field, $filter_field['options'] );
3028
+ ?>
3029
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>">
3030
+ <?php esc_html_e( $filter_field['label'] ); ?>
3031
+ </label>
3032
+ <?php
3033
+ echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options );
3034
+ } elseif ( 'boolean' === $filter_field['type'] ) {
3035
+ $value = pods_var_raw( 'filter_' . $filter, 'get', '' );
3036
 
3037
+ if ( strlen( $value ) < 1 ) {
3038
+ $value = pods_var_raw( 'filter_default', $filter_field );}
3039
 
3040
+ // override default value
3041
+ $filter_field['options']['default_value'] = '';
3042
 
3043
+ $filter_field['options']['pick_format_type'] = 'single';
3044
+ $filter_field['options']['pick_format_single'] = 'dropdown';
3045
 
3046
+ $filter_field['options']['pick_object'] = 'custom-simple';
3047
+ $filter_field['options']['pick_custom'] = array(
3048
+ '1' => pods_var_raw( 'boolean_yes_label', $filter_field['options'], __( 'Yes', 'pods' ), null, true ),
3049
+ '0' => pods_var_raw( 'boolean_no_label', $filter_field['options'], __( 'No', 'pods' ), null, true ),
3050
+ );
3051
 
3052
+ $filter_field['options']['input_helper'] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields['search'], array(), null, true ), array(), null, true ), '', null, true );
3053
+ $filter_field['options']['input_helper'] = pods_var_raw( 'ui_input_helper', $filter_field['options'], $filter_field['options']['input_helper'], null, true );
3054
 
3055
+ $options = array_merge( $filter_field, $filter_field['options'] );
3056
+ ?>
3057
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>">
3058
+ <?php esc_html_e( $filter_field['label'] ); ?>
3059
+ </label>
3060
+ <?php
3061
+ echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options );
3062
+ } else {
3063
+ $value = pods_var_raw( 'filter_' . $filter );
3064
 
3065
+ if ( strlen( $value ) < 1 ) {
3066
+ $value = pods_var_raw( 'filter_default', $filter_field );}
3067
 
3068
+ // override default value
3069
+ $filter_field['options']['default_value'] = '';
3070
 
3071
+ $options = array();
3072
+ $options['input_helper'] = pods_var_raw( 'ui_input_helper', pods_var_raw( 'options', pods_var_raw( $filter, $this->fields['search'], array(), null, true ), array(), null, true ), '', null, true );
3073
+ $options['input_helper'] = pods_var_raw( 'ui_input_helper', $options, $options['input_helper'], null, true );
3074
+ ?>
3075
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>">
3076
+ <?php esc_html_e( $filter_field['label'] ); ?>
3077
+ </label>
3078
+ <?php
3079
+ echo PodsForm::field( 'filter_' . $filter, $value, 'text', $options );
3080
+ }//end if
3081
+ }//end foreach
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3082
 
3083
+ if ( false !== $this->do_hook( 'filters_show_search', true ) ) {
3084
+ ?>
3085
+ <label<?php echo ( empty( $this->filters ) ) ? ' class="screen-reader-text"' : ''; ?> for="page-search<?php esc_attr_e( $this->num ); ?>-input"><?php _e( 'Search', 'pods' ); ?>:</label>
3086
+ <?php echo PodsForm::field( 'search' . $this->num, $this->search, 'text', array( 'attributes' => array( 'id' => 'page-search' . $this->num . '-input' ) ) ); ?>
3087
+ <?php
3088
+ } else {
3089
+ echo PodsForm::field( 'search' . $this->num, '', 'hidden' );
3090
+ }
3091
 
3092
+ echo PodsForm::submit_button( $this->header['search'], 'button', false, false, array( 'id' => 'search' . $this->num . '-submit' ) );
 
3093
 
3094
+ if ( 0 < strlen( $this->search ) ) {
3095
+ $clear_filters = array(
3096
+ 'search' . $this->num => false,
3097
+ );
3098
 
3099
+ foreach ( $this->filters as $filter ) {
3100
+ $clear_filters[ 'filter_' . $filter . '_start' ] = false;
3101
+ $clear_filters[ 'filter_' . $filter . '_end' ] = false;
3102
+ $clear_filters[ 'filter_' . $filter ] = false;
3103
+ }
3104
+ ?>
3105
+ <br class="clear" />
3106
+ <small>[<a href="<?php echo esc_url( pods_query_arg( $clear_filters, array( 'orderby' . $this->num, 'orderby_dir' . $this->num, 'limit' . $this->num, 'page' ), $this->exclusion() ) ); ?>"><?php _e( 'Reset Filters', 'pods' ); ?></a>]</small>
3107
+ <br class="clear" />
3108
+ <?php
3109
  }
3110
  ?>
3111
+ </p>
3112
+ <?php
3113
+ }//end if
3114
+ } else {
3115
+ ?>
3116
+ <br class="clear" />
3117
+ <?php
3118
  }//end if
3119
 
3120
+ if ( ! empty( $this->data ) && ( false !== $this->pagination_total || false !== $this->pagination || true === $reorder ) || ( ! in_array( 'export', $this->actions_disabled ) && ! in_array( 'export', $this->actions_hidden ) ) || ! empty( $this->actions_disabled ) ) {
3121
  ?>
3122
+ <div class="tablenav">
 
 
3123
  <?php
3124
+ if ( ! empty( $this->data ) && ! empty( $this->actions_bulk ) ) {
3125
+ ?>
3126
+ <div class="alignleft actions">
3127
+ <?php wp_nonce_field( 'pods-ui-action-bulk', '_wpnonce' . $this->num, false ); ?>
3128
 
3129
+ <select name="action_bulk<?php esc_attr_e( $this->num ); ?>">
3130
+ <option value="-1" selected="selected"><?php _e( 'Bulk Actions', 'pods' ); ?></option>
 
 
 
 
 
3131
 
3132
+ <?php
3133
+ foreach ( $this->actions_bulk as $action => $action_data ) {
3134
+ if ( in_array( $action, $this->actions_hidden ) || in_array( $action, $this->actions_hidden ) ) {
3135
+ continue;}
3136
+
3137
+ if ( ! isset( $action_data['label'] ) ) {
3138
+ $action_data['label'] = ucwords( str_replace( '_', ' ', $action ) );}
3139
+ ?>
3140
+ <option value="<?php esc_attr_e( $action ); ?>"><?php esc_html_e( $action_data['label'] ); ?></option>
3141
+ <?php
3142
+ }
3143
+ ?>
3144
+ </select>
3145
+
3146
+ <input type="submit" id="doaction_bulk<?php esc_attr_e( $this->num ); ?>" class="button-secondary action" value="<?php esc_attr_e( 'Apply', 'pods' ); ?>">
3147
+ </div>
3148
+ <?php
3149
+ }//end if
3150
+
3151
+ if ( true !== $reorder && ( false !== $this->pagination_total || false !== $this->pagination ) ) {
3152
+ ?>
3153
+ <div class="tablenav-pages<?php esc_attr_e( ( $this->limit < $this->total_found || 1 < $this->page ) ? '' : ' one-page' ); ?>">
3154
+ <?php $this->pagination( 1 ); ?>
3155
+ </div>
3156
+ <?php
3157
  }
3158
+
3159
+ if ( true === $reorder ) {
3160
+ $link = pods_query_arg(
 
 
 
 
 
3161
  array(
3162
+ 'action' . $this->num => 'manage',
3163
+ 'id' . $this->num => '',
3164
  ), self::$allowed, $this->exclusion()
3165
+ );
3166
+
3167
+ if ( ! empty( $this->action_links['manage'] ) ) {
3168
+ $link = $this->action_links['manage'];
3169
+ }
3170
+ ?>
3171
+ <input type="button" value="<?php esc_attr_e( 'Update Order', 'pods' ); ?>" class="button" onclick="jQuery('form.admin_ui_reorder_form').submit();" />
3172
+ <input type="button" value="<?php esc_attr_e( 'Cancel', 'pods' ); ?>" class="button" onclick="document.location='<?php echo esc_js( $link ); ?>';" />
3173
+ </form>
3174
+ <?php
3175
+ } elseif ( ! in_array( 'export', $this->actions_disabled ) && ! in_array( 'export', $this->actions_hidden ) ) {
3176
+ $export_document_location = pods_slash(
3177
+ pods_query_arg(
3178
+ array(
3179
+ 'action_bulk' . $this->num => 'export',
3180
+ '_wpnonce' => wp_create_nonce( 'pods-ui-action-bulk' ),
3181
+ ), self::$allowed, $this->exclusion()
3182
+ )
3183
+ );
3184
+ ?>
3185
+ <div class="alignleft actions">
3186
+ <input type="button" value="<?php esc_attr_e( sprintf( __( 'Export all %s', 'pods' ), $this->items ) ); ?>" class="button" onclick="document.location='<?php echo $export_document_location; ?>';" />
3187
+ </div>
3188
+ <?php
3189
+ }//end if
3190
  ?>
3191
+ <br class="clear" />
 
3192
  </div>
3193
  <?php
3194
+ } else {
3195
+ ?>
3196
+ <br class="clear" />
3197
+ <?php
3198
  }//end if
3199
+ ?>
3200
+ <div class="clear"></div>
3201
+ <?php
3202
+ if ( empty( $this->data ) && false !== $this->default_none && false === $this->search ) {
3203
  ?>
3204
+ <p><?php _e( 'Please use the search filter(s) above to display data', 'pods' ); ?>
 
3205
  <?php
3206
+ if ( $this->export ) {
3207
  ?>
3208
+ , <?php _e( 'or click on an Export to download a full copy of the data', 'pods' ); ?><?php } ?>.</p>
3209
  <?php
3210
+ } else {
3211
+ $this->table( $reorder );}
3212
+ if ( ! empty( $this->data ) ) {
3213
+ if ( true !== $reorder && ( false !== $this->pagination_total || false !== $this->pagination ) ) {
3214
+ ?>
3215
+ <div class="tablenav">
3216
+ <div class="tablenav-pages<?php esc_attr_e( ( $this->limit < $this->total_found || 1 < $this->page ) ? '' : ' one-page' ); ?>">
3217
+ <?php $this->pagination( 0 ); ?>
3218
+ <br class="clear" />
3219
+ </div>
 
 
 
 
 
 
 
 
 
 
 
3220
  </div>
3221
+ <?php
3222
+ }
3223
  }
 
3224
 
3225
+ ?>
3226
+ </form>
3227
+ </div>
3228
+
3229
+ <?php
3230
+ /**
3231
+ * Allow additional output after the container area of the Pods UI manage screen.
3232
+ *
3233
+ * @since 2.7.17
3234
+ */
3235
+ do_action( 'pods_ui_manage_after_container' );
3236
+ ?>
3237
  </div>
3238
  <?php
3239
+ if ( $this->filters_enhanced ) {
3240
+ $this->filters_popup();
3241
+ }
3242
  }
3243
 
3244
  public function filters() {
3303
  $label = wp_kses_post( $label );
3304
  }
3305
  ?>
3306
+ <li class="<?php esc_attr_e( $view ); ?>">
3307
  <?php
3308
  /* Escaped above to support links */
3309
  echo $label;
3353
  if ( false !== $this->do_hook( 'filters_show_search', true ) ) {
3354
  ?>
3355
  &nbsp;&nbsp;
3356
+ <label class="screen-reader-text" for="page-search<?php esc_attr_e( $this->num ); ?>-input"><?php _e( 'Search', 'pods' ); ?>:</label>
3357
  <?php echo PodsForm::field( 'search' . $this->num, $this->search, 'text', array( 'attributes' => array( 'id' => 'page-search' . $this->num . '-input' ) ) ); ?>
3358
  <?php
3359
  } else {
3452
  $value_label = $value;
3453
  }
3454
  ?>
3455
+ <li class="pods-ui-filter-bar-filter" data-filter="<?php esc_attr_e( $data_filter ); ?>">
3456
  <a href="#TB_inline?width=640&inlineId=pods-ui-posts-filter-popup" class="thickbox" title="<?php esc_attr_e( 'Advanced Filters', 'pods' ); ?>">
3457
+ <strong><?php esc_html_e( $filter_field['label'] ); ?>:</strong>
3458
+ <?php esc_html_e( $value_label ); ?>
3459
  </a>
3460
 
3461
  <a href="#remove-filter" class="remove-filter" title="<?php esc_attr_e( 'Remove Filter', 'pods' ); ?>">x</a>
3488
  jQuery( this ).remove();
3489
  } );
3490
 
3491
+ jQuery( 'form#posts-filter [name="pg<?php esc_attr_e( $this->num ); ?>"]' ).prop( 'disabled', true );
3492
+ jQuery( 'form#posts-filter [name="action<?php esc_attr_e( $this->num ); ?>"]' ).prop( 'disabled', true );
3493
+ jQuery( 'form#posts-filter [name="action_bulk<?php esc_attr_e( $this->num ); ?>"]' ).prop( 'disabled', true );
3494
+ jQuery( 'form#posts-filter [name="_wpnonce<?php esc_attr_e( $this->num ); ?>"]' ).prop( 'disabled', true );
3495
 
3496
  jQuery( 'form#posts-filter' ).submit();
3497
 
3536
  continue;
3537
  }
3538
  ?>
3539
+ <input type="hidden" name="<?php esc_attr_e( $k ); ?>" value="<?php esc_attr_e( $v ); ?>" />
3540
  <?php
3541
  }
3542
 
3555
  continue;
3556
  }
3557
  ?>
3558
+ <p class="pods-ui-posts-filter-toggled pods-ui-posts-filter-<?php esc_attr_e( $filter . ( $zebra ? ' clear' : '' ) ); ?>">
3559
  <?php
3560
  if ( in_array( $filter_field['type'], array( 'date', 'datetime', 'time' ) ) ) {
3561
  $start = pods_var_raw( 'filter_' . $filter . '_start', 'get', pods_var_raw( 'filter_default', $filter_field, '', null, true ), null, true );
3585
  $end = PodsForm::field_method( $filter_field['type'], 'convert_date', $end, 'n/j/Y' );
3586
  }
3587
  ?>
3588
+ <span class="pods-ui-posts-filter-toggle toggle-on<?php esc_attr_e( ( empty( $start ) && empty( $end ) ) ? '' : ' pods-hidden' ); ?>">+</span>
3589
+ <span class="pods-ui-posts-filter-toggle toggle-off<?php esc_attr_e( ( empty( $start ) && empty( $end ) ) ? ' pods-hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span>
3590
 
3591
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>_start">
3592
+ <?php esc_html_e( $filter_field['label'] ); ?>
3593
  </label>
3594
 
3595
+ <span class="pods-ui-posts-filter<?php esc_attr_e( ( empty( $start ) && empty( $end ) ) ? ' pods-hidden' : '' ); ?>">
3596
  <?php echo PodsForm::field( 'filter_' . $filter . '_start', $start, $filter_field['type'], $filter_field ); ?>
3597
 
3598
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>_end">to</label>
3599
  <?php echo PodsForm::field( 'filter_' . $filter . '_end', $end, $filter_field['type'], $filter_field ); ?>
3600
  </span>
3601
  <?php
3617
 
3618
  $options = array_merge( $filter_field, $filter_field['options'] );
3619
  ?>
3620
+ <span class="pods-ui-posts-filter-toggle toggle-on<?php esc_attr_e( empty( $value ) ? '' : ' pods-hidden' ); ?>">+</span>
3621
+ <span class="pods-ui-posts-filter-toggle toggle-off<?php esc_attr_e( empty( $value ) ? ' pods-hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span>
3622
 
3623
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>">
3624
+ <?php esc_html_e( $filter_field['label'] ); ?>
3625
  </label>
3626
 
3627
+ <span class="pods-ui-posts-filter<?php esc_attr_e( strlen( $value ) < 1 ? ' pods-hidden' : '' ); ?>">
3628
  <?php echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options ); ?>
3629
  </span>
3630
  <?php
3652
 
3653
  $options = array_merge( $filter_field, $filter_field['options'] );
3654
  ?>
3655
+ <span class="pods-ui-posts-filter-toggle toggle-on<?php esc_attr_e( empty( $value ) ? '' : ' pods-hidden' ); ?>">+</span>
3656
+ <span class="pods-ui-posts-filter-toggle toggle-off<?php esc_attr_e( empty( $value ) ? ' pods-hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span>
3657
 
3658
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>">
3659
+ <?php esc_html_e( $filter_field['label'] ); ?>
3660
  </label>
3661
 
3662
+ <span class="pods-ui-posts-filter<?php esc_attr_e( strlen( $value ) < 1 ? ' pods-hidden' : '' ); ?>">
3663
  <?php echo PodsForm::field( 'filter_' . $filter, $value, 'pick', $options ); ?>
3664
  </span>
3665
  <?php
3678
  $options['input_helper'] = $filter_field['options']['input_helper'];
3679
  }
3680
  ?>
3681
+ <span class="pods-ui-posts-filter-toggle toggle-on<?php esc_attr_e( empty( $value ) ? '' : ' pods-hidden' ); ?>">+</span>
3682
+ <span class="pods-ui-posts-filter-toggle toggle-off<?php esc_attr_e( empty( $value ) ? ' pods-hidden' : '' ); ?>"><?php _e( 'Clear', 'pods' ); ?></span>
3683
 
3684
+ <label for="pods-form-ui-filter-<?php esc_attr_e( $filter ); ?>">
3685
+ <?php esc_html_e( $filter_field['label'] ); ?>
3686
  </label>
3687
 
3688
+ <span class="pods-ui-posts-filter<?php esc_attr_e( empty( $value ) ? ' pods-hidden' : '' ); ?>">
3689
  <?php echo PodsForm::field( 'filter_' . $filter, $value, 'text', $options ); ?>
3690
  </span>
3691
  <?php
3697
  }//end foreach
3698
  ?>
3699
 
3700
+ <p class="pods-ui-posts-filter-toggled pods-ui-posts-filter-search<?php esc_attr_e( $zebra ? ' clear' : '' ); ?>">
3701
+ <label for="pods-form-ui-search<?php esc_attr_e( $this->num ); ?>"><?php _e( 'Search Text', 'pods' ); ?></label>
3702
  <?php echo PodsForm::field( 'search' . $this->num, pods_var_raw( 'search' . $this->num ), 'text' ); ?>
3703
  </p>
3704
 
3705
  <?php $zebra = empty( $zebra ); ?>
3706
  </div>
3707
 
3708
+ <p class="submit<?php esc_attr_e( $zebra ? ' clear' : '' ); ?>">
3709
+ <input type="submit" value="<?php esc_attr_e( $this->header['search'] ); ?>" class="button button-primary" />
3710
  </p>
3711
  </form>
3712
  </div>
3876
  if ( $fields[ $field ]['sortable'] ) {
3877
  $column_classes[] = 'sortable' . $current_sort;
3878
  ?>
3879
+ <th scope="col"<?php echo $att_id; ?> class="<?php esc_attr_e( implode( ' ', $column_classes ) ); ?>"<?php echo $width; ?>>
3880
  <a href="
3881
  <?php
3882
  echo esc_url_raw(
3894
  );
3895
  ?>
3896
  ">
3897
+ <span><?php esc_html_e( $attributes['label'] ); ?></span>
3898
  <span class="sorting-indicator"></span> </a>
3899
  </th>
3900
  <?php
3901
  } else {
3902
  ?>
3903
+ <th scope="col"<?php echo $att_id; ?> class="<?php esc_attr_e( implode( ' ', $column_classes ) ); ?>"<?php echo $width; ?>><?php esc_html_e( $attributes['label'] ); ?></th>
3904
  <?php
3905
  }//end if
3906
  }//end foreach
3939
 
3940
  if ( $fields[ $field ]['sortable'] ) {
3941
  ?>
3942
+ <th scope="col" class="manage-column column-<?php esc_attr_e( $id ); ?> sortable <?php esc_attr_e( $current_sort ); ?>"<?php echo $width; ?>>
3943
  <a href="
3944
  <?php
3945
  echo esc_url_raw(
3956
  )
3957
  );
3958
  ?>
3959
+ "><span><?php esc_html_e( $attributes['label'] ); ?></span><span class="sorting-indicator"></span></a>
3960
  </th>
3961
  <?php
3962
  } else {
3963
  ?>
3964
+ <th scope="col" class="manage-column column-<?php esc_attr_e( $id ); ?>"<?php echo $width; ?>><?php esc_html_e( $attributes['label'] ); ?></th>
3965
  <?php
3966
  }//end if
3967
  }//end foreach
3992
  }
3993
  }
3994
  ?>
3995
+ <tr id="item-<?php esc_attr_e( $row[ $this->sql['field_id'] ] ); ?>" class="iedit<?php esc_attr_e( $toggle_class ); ?>">
3996
  <?php
3997
  if ( ! empty( $this->actions_bulk ) ) {
3998
  ?>
3999
  <th scope="row" class="check-column">
4000
+ <input type="checkbox" name="action_bulk_ids<?php esc_attr_e( $this->num ); ?>[]" value="<?php esc_attr_e( $row[ $this->sql['field_id'] ] ); ?>">
4001
  </th>
4002
  <?php
4003
  }
4193
  $link = $this->do_template( $this->action_links['edit'], $row );
4194
  }
4195
  ?>
4196
+ <td class="<?php esc_attr_e( implode( ' ', $css_classes ) ); ?>">
4197
  <strong><a class="row-title" href="<?php echo esc_url_raw( $link ); ?>" title="<?php esc_attr_e( 'Edit this item', 'pods' ); ?>">
4198
  <?php
4199
  /* Escaped above for non-HTML types */
4213
  $link = $this->do_template( $this->action_links['view'], $row );
4214
  }
4215
  ?>
4216
+ <td class="<?php esc_attr_e( implode( ' ', $css_classes ) ); ?>">
4217
  <strong><a class="row-title" href="<?php echo esc_url_raw( $link ); ?>" title="<?php esc_attr_e( 'View this item', 'pods' ); ?>">
4218
  <?php
4219
  /* Escaped above for non-HTML types */
4226
  $css_classes[] = 'dragme';
4227
  }
4228
  ?>
4229
+ <td class="<?php esc_attr_e( implode( ' ', $css_classes ) ); ?>">
4230
  <strong>
4231
  <?php
4232
  /* Escaped above for non-HTML types */
4244
 
4245
  if ( ! empty( $actions ) ) {
4246
  ?>
4247
+ <div class="row-actions<?php esc_attr_e( $toggle ? ' row-actions-toggle' : '' ); ?>">
4248
  <?php
4249
  $this->callback( 'actions_start', $row, $actions );
4250
 
4257
  }
4258
  } else {
4259
  ?>
4260
+ <input type="hidden" name="order[]" value="<?php esc_attr_e( $row[ $this->sql['field_id'] ] ); ?>" />
4261
  <?php
4262
  }//end if
4263
  ?>
4273
  $css_classes[] = 'date';
4274
  $css_classes[] = 'column-date';
4275
  ?>
4276
+ <td class="<?php esc_attr_e( implode( ' ', $css_classes ) ); ?>" data-colname="<?php esc_attr_e( $attributes['label'] ); ?>">
4277
+ <abbr title="<?php esc_attr_e( $row_value ); ?>"><?php echo wp_kses_post( $row_value ); ?></abbr>
4278
  <?php if ( $first_field ) { ?>
4279
  <button type="button" class="toggle-row">
4280
  <span class="screen-reader-text"><?php esc_html_e( 'Show more details', 'pods' ); ?></span>
4292
  $row_value = wp_kses_post( $row_value );
4293
  }
4294
  ?>
4295
+ <td class="<?php esc_attr_e( implode( ' ', $css_classes ) ); ?>" data-colname="<?php esc_attr_e( $attributes['label'] ); ?>">
4296
  <span>
4297
  <?php
4298
  /* Escaped above for non-HTML types */
4557
  continue;
4558
  }
4559
  ?>
4560
+ <label for="<?php esc_attr_e( $field ); ?>-hide">
4561
+ <input class="hide-column-tog" name="<?php esc_attr_e( $this->unique_identifier ); ?>_<?php esc_attr_e( $field ); ?>-hide" type="checkbox" id="<?php esc_attr_e( $field ); ?>-hide" value="<?php esc_attr_e( $field ); ?>" checked="checked"><?php esc_html_e( $attributes['label'] ); ?>
4562
  </label>
4563
  <?php
4564
  }
4573
  <?php
4574
  if ( true === $this->pagination ) {
4575
  ?>
4576
+ <input type="text" class="screen-per-page" name="wp_screen_options[value]" id="<?php esc_attr_e( $this->unique_identifier ); ?>_per_page" maxlength="3" value="20">
4577
+ <label for="<?php esc_attr_e( $this->unique_identifier ); ?>_per_page"><?php esc_html_e( sprintf( __( '%s per page', 'pods' ), $this->items ) ); ?></label>
4578
  <?php
4579
  }
4580
  $this->do_hook( 'screen_meta_screen_submit' );
4581
  ?>
4582
  <input type="submit" name="screen-options-apply" id="screen-options-apply" class="button" value="<?php esc_attr_e( 'Apply', 'pods' ); ?>">
4583
+ <input type="hidden" name="wp_screen_options[option]" value="<?php esc_attr_e( $this->unique_identifier ); ?>_per_page">
4584
  <?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?>
4585
  </div>
4586
  <?php
4704
  $classes .= ' button';
4705
  }
4706
  ?>
4707
+ <a class="first-page<?php esc_attr_e( $classes ); ?>" title="<?php esc_attr_e( 'Go to the first page', 'pods' ); ?>" href="<?php echo $first_link; ?>">&laquo;</a>
4708
+ <a class="prev-page<?php esc_attr_e( $classes ); ?>" title="<?php esc_attr_e( 'Go to the previous page', 'pods' ); ?>" href="<?php echo $prev_link; ?>">&lsaquo;</a>
4709
  <?php
4710
  if ( true == $header ) {
4711
  ?>
4712
+ <span class="paging-input"><input class="current-page" title="<?php esc_attr_e( 'Current page', 'pods' ); ?>" type="text" name="pg<?php esc_attr_e( $this->num ); ?>" value="<?php esc_attr_e( absint( $this->page ) ); ?>" size="<?php esc_attr_e( strlen( $total_pages ) ); ?>"> <?php _e( 'of', 'pods' ); ?>
4713
  <span class="total-pages"><?php echo absint( $total_pages ); ?></span></span>
4714
  <script>
4715
 
4717
  var pageInput = $( 'input.current-page' );
4718
  var currentPage = pageInput.val();
4719
  pageInput.closest( 'form' ).submit( function ( e ) {
4720
+ if ( ( 1 > $( 'select[name="action<?php esc_attr_e( $this->num ); ?>"]' ).length || $( 'select[name="action<?php esc_attr_e( $this->num ); ?>"]' ).val() == -1 ) && ( 1 > $( 'select[name="action_bulk<?php esc_attr_e( $this->num ); ?>"]' ).length || $( 'select[name="action_bulk<?php esc_attr_e( $this->num ); ?>"]' ).val() == -1 ) && pageInput.val() == currentPage ) {
4721
  pageInput.val( '1' );
4722
  }
4723
  } );
4738
  $classes .= ' button';
4739
  }
4740
  ?>
4741
+ <a class="next-page<?php esc_attr_e( $classes ); ?>" title="<?php esc_attr_e( 'Go to the next page', 'pods' ); ?>" href="<?php echo $next_link; ?>">&rsaquo;</a>
4742
+ <a class="last-page<?php esc_attr_e( $classes ); ?>" title="<?php esc_attr_e( 'Go to the last page', 'pods' ); ?>" href="<?php echo $last_link; ?>">&raquo</a>
4743
  <?php
4744
  }//end if
4745
  }//end if
4893
  if ( is_array( $v ) ) {
4894
  foreach ( $v as $vk => $vv ) {
4895
  ?>
4896
+ <input type="hidden" name="<?php esc_attr_e( $k ); ?>[<?php esc_attr_e( $vk ); ?>]" value="<?php esc_attr_e( $vv ); ?>" />
4897
  <?php
4898
  }
4899
  } else {
4900
  ?>
4901
+ <input type="hidden" name="<?php esc_attr_e( $k ); ?>" value="<?php esc_attr_e( $v ); ?>" />
4902
  <?php
4903
  }
4904
  }
classes/cli/Pods_CLI_Command.php CHANGED
@@ -330,7 +330,7 @@ class Pods_CLI_Command extends WP_CLI_Command {
330
 
331
  unset( $assoc_args['pod'] );
332
 
333
- $pod = pods( $pod_name, null, false );
334
 
335
  if ( ! $pod->valid() ) {
336
  WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
330
 
331
  unset( $assoc_args['pod'] );
332
 
333
+ $pod = pods( $pod_name, array( 'limit' => -1 ), false );
334
 
335
  if ( ! $pod->valid() ) {
336
  WP_CLI::error( sprintf( __( 'Pod "%s" does not exist.', 'pods' ), $assoc_args['pod'] ) );
classes/fields/boolean.php CHANGED
@@ -79,10 +79,9 @@ class PodsField_Boolean extends PodsField {
79
 
80
  $is_empty = false;
81
 
82
- $value = filter_var( $value, FILTER_VALIDATE_BOOLEAN );
83
-
84
- if ( ! $value ) {
85
- $is_empty = true;
86
  }
87
 
88
  return $is_empty;
@@ -173,12 +172,22 @@ class PodsField_Boolean extends PodsField {
173
  * {@inheritdoc}
174
  */
175
  public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {
176
-
177
  $errors = array();
178
  $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params );
179
 
180
- if ( 1 === (int) pods_v( 'required', $options ) && 0 === $check ) {
181
- $errors[] = __( 'This field is required.', 'pods' );
 
 
 
 
 
 
 
 
 
 
182
  }
183
 
184
  if ( ! empty( $errors ) ) {
79
 
80
  $is_empty = false;
81
 
82
+ // Boolean false and integer 0 are non-empty values.
83
+ if ( ! is_bool( $value ) && ! is_int( $value ) && '0' !== $value ) {
84
+ $is_empty = empty( $value );
 
85
  }
86
 
87
  return $is_empty;
172
  * {@inheritdoc}
173
  */
174
  public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {
175
+
176
  $errors = array();
177
  $check = $this->pre_save( $value, $id, $name, $options, $fields, $pod, $params );
178
 
179
+ $yes_required = ( 'checkbox' === pods_v( static::$type . '_format_type', $options ) );
180
+
181
+ $required = (int) pods_v( 'required', $options );
182
+
183
+ if ( 1 === $required ) {
184
+ if ( $yes_required ) {
185
+ if ( 0 === $check ) {
186
+ $errors[] = __( 'This field is required.', 'pods' );
187
+ }
188
+ } elseif ( $this->is_empty( $value ) ) {
189
+ $errors[] = __( 'This field is required.', 'pods' );
190
+ }
191
  }
192
 
193
  if ( ! empty( $errors ) ) {
classes/fields/currency.php CHANGED
@@ -184,7 +184,7 @@ class PodsField_Currency extends PodsField_Number {
184
 
185
  $placement = pods_v( static::$type . '_format_placement', $options, 'before', true );
186
 
187
- // Currency placement policy
188
  // Single sign currencies: 100$, £100
189
  // Multiple sign currencies: 100 Fr, Kr 100
190
  $currency_gap = '';
@@ -240,10 +240,6 @@ class PodsField_Currency extends PodsField_Number {
240
  */
241
  public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {
242
 
243
- $format_args = $this->get_number_format_args( $options );
244
- $thousands = $format_args['thousands'];
245
- $dot = $format_args['dot'];
246
-
247
  $currency = 'usd';
248
 
249
  if ( isset( static::$currencies[ pods_v( static::$type . '_format_sign', $options, - 1 ) ] ) ) {
@@ -253,30 +249,19 @@ class PodsField_Currency extends PodsField_Number {
253
  $currency_sign = static::$currencies[ $currency ]['sign'];
254
  $currency_entity = static::$currencies[ $currency ]['entity'];
255
 
256
- // Remove currency and thousands symbols
257
- $check = str_replace(
258
  array(
259
- $thousands,
260
  $currency_sign,
261
  $currency_entity,
262
- html_entity_decode( $thousands ),
263
  html_entity_decode( $currency_sign ),
264
  html_entity_decode( $currency_entity ),
265
- ), '', $value
 
 
266
  );
267
- // Convert decimal type for numeric type
268
- $check = str_replace( $dot, '.', $check );
269
- $check = trim( $check );
270
 
271
- $check = preg_replace( '/[0-9\.\-\s]/', '', $check );
272
-
273
- $label = pods_v( 'label', $options, ucwords( str_replace( '_', ' ', $name ) ) );
274
-
275
- if ( 0 < strlen( $check ) ) {
276
- return sprintf( __( '%s is not numeric', 'pods' ), $label );
277
- }
278
-
279
- return true;
280
 
281
  }
282
 
@@ -285,11 +270,6 @@ class PodsField_Currency extends PodsField_Number {
285
  */
286
  public function pre_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
287
 
288
- $format_args = $this->get_number_format_args( $options );
289
- $thousands = $format_args['thousands'];
290
- $dot = $format_args['dot'];
291
- $decimals = $format_args['decimals'];
292
-
293
  $currency = 'usd';
294
 
295
  if ( isset( static::$currencies[ pods_v( static::$type . '_format_sign', $options, - 1 ) ] ) ) {
@@ -299,26 +279,19 @@ class PodsField_Currency extends PodsField_Number {
299
  $currency_sign = static::$currencies[ $currency ]['sign'];
300
  $currency_entity = static::$currencies[ $currency ]['entity'];
301
 
302
- // Convert decimal type for numeric type
303
  $value = str_replace(
304
  array(
305
- $thousands,
306
  $currency_sign,
307
  $currency_entity,
308
- html_entity_decode( $thousands ),
309
  html_entity_decode( $currency_sign ),
310
  html_entity_decode( $currency_entity ),
311
- ), '', $value
 
 
312
  );
313
- // Convert decimal type for numeric type
314
- $value = str_replace( $dot, '.', $value );
315
- $value = trim( $value );
316
 
317
- $value = preg_replace( '/[^0-9\.\-]/', '', $value );
318
-
319
- $value = number_format( (float) $value, $decimals, '.', '' );
320
-
321
- return $value;
322
 
323
  }
324
 
@@ -327,25 +300,16 @@ class PodsField_Currency extends PodsField_Number {
327
  */
328
  public function format( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
329
 
 
330
  if ( null === $value ) {
331
- // Don't enforce a default value here
332
- return null;
333
- }
334
-
335
- $format_args = $this->get_number_format_args( $options );
336
- $thousands = $format_args['thousands'];
337
- $dot = $format_args['dot'];
338
- $decimals = $format_args['decimals'];
339
-
340
- if ( 'i18n' === pods_v( static::$type . '_format', $options ) ) {
341
- $value = number_format_i18n( (float) $value, $decimals );
342
- } else {
343
- $value = number_format( (float) $value, $decimals, $dot, $thousands );
344
  }
345
 
346
  // Additional output handling for decimals
347
  $decimal_handling = pods_v( static::$type . '_decimal_handling', $options, 'none' );
348
  if ( 'none' !== $decimal_handling ) {
 
 
349
  $value_parts = explode( $dot, $value );
350
  // Make sure decimals are empty.
351
  if ( isset( $value_parts[1] ) && ! (int) $value_parts[1] ) {
@@ -371,7 +335,7 @@ class PodsField_Currency extends PodsField_Number {
371
  */
372
  public static function data_currencies() {
373
 
374
- // If it's already done, do not redo the filter
375
  if ( ! empty( static::$currencies ) ) {
376
  return static::$currencies;
377
  }
184
 
185
  $placement = pods_v( static::$type . '_format_placement', $options, 'before', true );
186
 
187
+ // Currency placement policy.
188
  // Single sign currencies: 100$, £100
189
  // Multiple sign currencies: 100 Fr, Kr 100
190
  $currency_gap = '';
240
  */
241
  public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {
242
 
 
 
 
 
243
  $currency = 'usd';
244
 
245
  if ( isset( static::$currencies[ pods_v( static::$type . '_format_sign', $options, - 1 ) ] ) ) {
249
  $currency_sign = static::$currencies[ $currency ]['sign'];
250
  $currency_entity = static::$currencies[ $currency ]['entity'];
251
 
252
+ // Remove currency and thousands symbols.
253
+ $value = str_replace(
254
  array(
 
255
  $currency_sign,
256
  $currency_entity,
 
257
  html_entity_decode( $currency_sign ),
258
  html_entity_decode( $currency_entity ),
259
+ ),
260
+ '',
261
+ $value
262
  );
 
 
 
263
 
264
+ return parent::validate( $value, $name, $options, $fields, $pod, $id, $params );
 
 
 
 
 
 
 
 
265
 
266
  }
267
 
270
  */
271
  public function pre_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
272
 
 
 
 
 
 
273
  $currency = 'usd';
274
 
275
  if ( isset( static::$currencies[ pods_v( static::$type . '_format_sign', $options, - 1 ) ] ) ) {
279
  $currency_sign = static::$currencies[ $currency ]['sign'];
280
  $currency_entity = static::$currencies[ $currency ]['entity'];
281
 
282
+ // Convert decimal type for numeric type.
283
  $value = str_replace(
284
  array(
 
285
  $currency_sign,
286
  $currency_entity,
 
287
  html_entity_decode( $currency_sign ),
288
  html_entity_decode( $currency_entity ),
289
+ ),
290
+ '',
291
+ $value
292
  );
 
 
 
293
 
294
+ return parent::pre_save( $value, $id, $name, $options, $fields, $pod, $params );
 
 
 
 
295
 
296
  }
297
 
300
  */
301
  public function format( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
302
 
303
+ $value = parent::format( $value, $name, $options, $pod, $id );
304
  if ( null === $value ) {
305
+ return $value;
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
 
308
  // Additional output handling for decimals
309
  $decimal_handling = pods_v( static::$type . '_decimal_handling', $options, 'none' );
310
  if ( 'none' !== $decimal_handling ) {
311
+ $format_args = $this->get_number_format_args( $options );
312
+ $dot = $format_args['dot'];
313
  $value_parts = explode( $dot, $value );
314
  // Make sure decimals are empty.
315
  if ( isset( $value_parts[1] ) && ! (int) $value_parts[1] ) {
335
  */
336
  public static function data_currencies() {
337
 
338
+ // If it's already done, do not redo the filter.
339
  if ( ! empty( static::$currencies ) ) {
340
  return static::$currencies;
341
  }
classes/fields/datetime.php CHANGED
@@ -251,7 +251,7 @@ class PodsField_DateTime extends PodsField {
251
 
252
  $value = trim( $value );
253
 
254
- if ( empty( $value ) || in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ), true ) ) {
255
  $is_empty = true;
256
  }
257
 
@@ -308,13 +308,7 @@ class PodsField_DateTime extends PodsField {
308
  */
309
  public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {
310
 
311
- if ( ! empty( $value ) && ( 0 === (int) pods_v( static::$type . '_allow_empty', $options, 1 ) || ! in_array(
312
- $value, array(
313
- '0000-00-00',
314
- '0000-00-00 00:00:00',
315
- '00:00:00',
316
- ), true
317
- ) ) ) {
318
  $js = true;
319
 
320
  if ( 'custom' !== pods_v( static::$type . '_type', $options, 'format' ) ) {
@@ -331,10 +325,9 @@ class PodsField_DateTime extends PodsField {
331
 
332
  return sprintf( esc_html__( '%1$s was not provided in a recognizable format: "%2$s"', 'pods' ), $label, $value );
333
  }
334
- }//end if
335
 
336
  return true;
337
-
338
  }
339
 
340
  /**
@@ -345,15 +338,9 @@ class PodsField_DateTime extends PodsField {
345
  // Value should always be passed as storage format since 2.7.15.
346
  $format = static::$storage_format;
347
 
348
- if ( ! empty( $value ) && ( 0 === (int) pods_v( static::$type . '_allow_empty', $options, 1 ) || ! in_array(
349
- $value, array(
350
- '0000-00-00',
351
- '0000-00-00 00:00:00',
352
- '00:00:00',
353
- ), true
354
- ) ) ) {
355
  $value = $this->convert_date( $value, static::$storage_format, $format );
356
- } elseif ( 1 === (int) pods_v( static::$type . '_allow_empty', $options, 1 ) ) {
357
  $value = static::$empty_value;
358
  } else {
359
  $value = date_i18n( static::$storage_format );
@@ -369,13 +356,7 @@ class PodsField_DateTime extends PodsField {
369
 
370
  $value = $this->display( $value, $name, $options, $pod, $id );
371
 
372
- if ( 1 === (int) pods_v( static::$type . '_allow_empty', $options, 1 ) && ( empty( $value ) || in_array(
373
- $value, array(
374
- '0000-00-00',
375
- '0000-00-00 00:00:00',
376
- '00:00:00',
377
- ), true
378
- ) ) ) {
379
  $value = false;
380
  }
381
 
@@ -396,7 +377,7 @@ class PodsField_DateTime extends PodsField {
396
 
397
  $format = $this->format_display( $options, $js );
398
 
399
- if ( ! empty( $value ) && ! in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ), true ) ) {
400
  // Try default storage format.
401
  $date = $this->createFromFormat( static::$storage_format, (string) $value );
402
 
@@ -416,7 +397,7 @@ class PodsField_DateTime extends PodsField {
416
  }
417
 
418
  $value = date_i18n( $format, $timestamp );
419
- } elseif ( 0 === (int) pods_v( static::$type . '_allow_empty', $options, 1 ) ) {
420
  $value = date_i18n( $format );
421
  } else {
422
  $value = '';
@@ -755,7 +736,7 @@ class PodsField_DateTime extends PodsField {
755
 
756
  $date = '';
757
 
758
- if ( ! empty( $value ) && ! in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ), true ) ) {
759
  $date = $this->createFromFormat( $original_format, (string) $value, $return_timestamp );
760
 
761
  if ( $date instanceof DateTime ) {
251
 
252
  $value = trim( $value );
253
 
254
+ if ( empty( $value ) || in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00' ), true ) ) {
255
  $is_empty = true;
256
  }
257
 
308
  */
309
  public function validate( $value, $name = null, $options = null, $fields = null, $pod = null, $id = null, $params = null ) {
310
 
311
+ if ( ! $this->is_empty( $value ) ) {
 
 
 
 
 
 
312
  $js = true;
313
 
314
  if ( 'custom' !== pods_v( static::$type . '_type', $options, 'format' ) ) {
325
 
326
  return sprintf( esc_html__( '%1$s was not provided in a recognizable format: "%2$s"', 'pods' ), $label, $value );
327
  }
328
+ }
329
 
330
  return true;
 
331
  }
332
 
333
  /**
338
  // Value should always be passed as storage format since 2.7.15.
339
  $format = static::$storage_format;
340
 
341
+ if ( ! $this->is_empty( $value ) ) {
 
 
 
 
 
 
342
  $value = $this->convert_date( $value, static::$storage_format, $format );
343
+ } elseif ( pods_v( static::$type . '_allow_empty', $options, 1 ) ) {
344
  $value = static::$empty_value;
345
  } else {
346
  $value = date_i18n( static::$storage_format );
356
 
357
  $value = $this->display( $value, $name, $options, $pod, $id );
358
 
359
+ if ( $this->is_empty( $value ) && pods_v( static::$type . '_allow_empty', $options, 1 ) ) {
 
 
 
 
 
 
360
  $value = false;
361
  }
362
 
377
 
378
  $format = $this->format_display( $options, $js );
379
 
380
+ if ( ! $this->is_empty( $value ) ) {
381
  // Try default storage format.
382
  $date = $this->createFromFormat( static::$storage_format, (string) $value );
383
 
397
  }
398
 
399
  $value = date_i18n( $format, $timestamp );
400
+ } elseif ( ! pods_v( static::$type . '_allow_empty', $options, 1 ) ) {
401
  $value = date_i18n( $format );
402
  } else {
403
  $value = '';
736
 
737
  $date = '';
738
 
739
+ if ( ! empty( $value ) && ! in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00' ), true ) ) {
740
  $date = $this->createFromFormat( $original_format, (string) $value, $return_timestamp );
741
 
742
  if ( $date instanceof DateTime ) {
classes/fields/file.php CHANGED
@@ -182,7 +182,7 @@ class PodsField_File extends PodsField {
182
  /* WP GALLERY OUTPUT */
183
  static::$type . '_wp_gallery_output' => array(
184
  'label' => __( 'Output as a WP Gallery', 'pods' ),
185
- 'help' => sprintf( __( '<a href="%s" target="_blank">Click here for more info</a>', 'pods' ), 'https://codex.wordpress.org/The_WordPress_Gallery' ),
186
  'depends-on' => array( static::$type . '_type' => 'images' ),
187
  'dependency' => true,
188
  'type' => 'boolean',
@@ -711,6 +711,8 @@ class PodsField_File extends PodsField {
711
  $data[ $image_size ] = ucwords( str_replace( '-', ' ', $image_size ) );
712
  }
713
 
 
 
714
  return apply_filters( 'pods_form_ui_field_pick_data_image_sizes', $data, $name, $value, $options, $pod, $id );
715
 
716
  }
182
  /* WP GALLERY OUTPUT */
183
  static::$type . '_wp_gallery_output' => array(
184
  'label' => __( 'Output as a WP Gallery', 'pods' ),
185
+ 'help' => sprintf( __( '<a href="%s" target="_blank">Click here for more info</a>', 'pods' ), 'https://wordpress.org/support/article/inserting-images-into-posts-and-pages/' ),
186
  'depends-on' => array( static::$type . '_type' => 'images' ),
187
  'dependency' => true,
188
  'type' => 'boolean',
711
  $data[ $image_size ] = ucwords( str_replace( '-', ' ', $image_size ) );
712
  }
713
 
714
+ $data['full'] = __( 'Full Size' ); // Translated by WordPress core.
715
+
716
  return apply_filters( 'pods_form_ui_field_pick_data_image_sizes', $data, $name, $value, $options, $pod, $id );
717
 
718
  }
classes/fields/number.php CHANGED
@@ -162,13 +162,14 @@ class PodsField_Number extends PodsField {
162
  }
163
 
164
  /**
 
165
  * {@inheritdoc}
166
  */
167
  public function is_empty( $value = null ) {
168
 
169
  $is_empty = false;
170
 
171
- $value += 0;
172
 
173
  if ( empty( $value ) ) {
174
  $is_empty = true;
@@ -195,6 +196,7 @@ class PodsField_Number extends PodsField {
195
 
196
  $options = (array) $options;
197
  $form_field_type = PodsForm::$field_type;
 
198
 
199
  if ( is_array( $value ) ) {
200
  $value = implode( '', $value );
@@ -208,15 +210,15 @@ class PodsField_Number extends PodsField {
208
 
209
  if ( isset( $options['name'] ) && false === PodsForm::permission( static::$type, $options['name'], $options, null, $pod, $id ) ) {
210
  if ( pods_v( 'read_only', $options, false ) ) {
211
- $options['readonly'] = true;
212
-
213
- $field_type = 'text';
214
-
215
- $value = $this->format( $value, $name, $options, $pod, $id );
216
  } else {
217
  return;
218
  }
219
  } elseif ( ! pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
 
 
 
 
220
  $options['readonly'] = true;
221
 
222
  $field_type = 'text';
@@ -250,11 +252,9 @@ class PodsField_Number extends PodsField {
250
  $dot = $format_args['dot'];
251
 
252
  $check = str_replace(
253
- array( $thousands, $dot, html_entity_decode( $thousands ) ), array(
254
- '',
255
- '.',
256
- '',
257
- ), $value
258
  );
259
  $check = trim( $check );
260
 
@@ -274,6 +274,11 @@ class PodsField_Number extends PodsField {
274
  */
275
  public function pre_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
276
 
 
 
 
 
 
277
  $format_args = $this->get_number_format_args( $options );
278
  $thousands = $format_args['thousands'];
279
  $dot = $format_args['dot'];
@@ -281,7 +286,11 @@ class PodsField_Number extends PodsField {
281
 
282
  if ( 'slider' !== pods_v( static::$type . '_format_type', $options ) ) {
283
  // Slider only supports `1234.00` format so no need for replacing characters.
284
- $value = str_replace( array( $thousands, $dot ), array( '', '.' ), $value );
 
 
 
 
285
  }
286
 
287
  $value = trim( $value );
@@ -303,7 +312,7 @@ class PodsField_Number extends PodsField {
303
  */
304
  public function format( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
305
 
306
- if ( null === $value ) {
307
  // Don't enforce a default value here.
308
  return null;
309
  }
@@ -366,30 +375,40 @@ class PodsField_Number extends PodsField {
366
  */
367
  public function get_number_format_args( $options ) {
368
 
369
- global $wp_locale;
370
-
371
- if ( '9.999,99' === pods_v( static::$type . '_format', $options ) ) {
372
- $thousands = '.';
373
- $dot = ',';
374
- } elseif ( '9,999.99' === pods_v( static::$type . '_format', $options ) ) {
375
- $thousands = ',';
376
- $dot = '.';
377
- } elseif ( '9\'999.99' === pods_v( static::$type . '_format', $options ) ) {
378
- $thousands = '\'';
379
- $dot = '.';
380
- } elseif ( '9 999,99' === pods_v( static::$type . '_format', $options ) ) {
381
- $thousands = ' ';
382
- $dot = ',';
383
- } elseif ( '9999.99' === pods_v( static::$type . '_format', $options ) ) {
384
- $thousands = '';
385
- $dot = '.';
386
- } elseif ( '9999,99' === pods_v( static::$type . '_format', $options ) ) {
387
- $thousands = '';
388
- $dot = ',';
389
- } else {
390
- $thousands = $wp_locale->number_format['thousands_sep'];
391
- $dot = $wp_locale->number_format['decimal_point'];
392
- }//end if
 
 
 
 
 
 
 
 
 
 
393
 
394
  $decimals = $this->get_max_decimals( $options );
395
 
162
  }
163
 
164
  /**
165
+ * @todo 2.8 Centralize the usage of this methoc. See PR #5540.
166
  * {@inheritdoc}
167
  */
168
  public function is_empty( $value = null ) {
169
 
170
  $is_empty = false;
171
 
172
+ $value += 0; // Convert to numeric.
173
 
174
  if ( empty( $value ) ) {
175
  $is_empty = true;
196
 
197
  $options = (array) $options;
198
  $form_field_type = PodsForm::$field_type;
199
+ $is_read_only = false;
200
 
201
  if ( is_array( $value ) ) {
202
  $value = implode( '', $value );
210
 
211
  if ( isset( $options['name'] ) && false === PodsForm::permission( static::$type, $options['name'], $options, null, $pod, $id ) ) {
212
  if ( pods_v( 'read_only', $options, false ) ) {
213
+ $is_read_only = true;
 
 
 
 
214
  } else {
215
  return;
216
  }
217
  } elseif ( ! pods_has_permissions( $options ) && pods_v( 'read_only', $options, false ) ) {
218
+ $is_read_only = true;
219
+ }
220
+
221
+ if ( $is_read_only ) {
222
  $options['readonly'] = true;
223
 
224
  $field_type = 'text';
252
  $dot = $format_args['dot'];
253
 
254
  $check = str_replace(
255
+ array( $thousands, $dot, html_entity_decode( $thousands ) ),
256
+ array( '', '.', '' ),
257
+ $value
 
 
258
  );
259
  $check = trim( $check );
260
 
274
  */
275
  public function pre_save( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
276
 
277
+ if ( $this->is_empty( $value ) && ( ! is_numeric( $value ) || 0.0 !== (float) $value ) ) {
278
+ // Don't enforce a default value here.
279
+ return null;
280
+ }
281
+
282
  $format_args = $this->get_number_format_args( $options );
283
  $thousands = $format_args['thousands'];
284
  $dot = $format_args['dot'];
286
 
287
  if ( 'slider' !== pods_v( static::$type . '_format_type', $options ) ) {
288
  // Slider only supports `1234.00` format so no need for replacing characters.
289
+ $value = str_replace(
290
+ array( $thousands, $dot, html_entity_decode( $thousands ) ),
291
+ array( '', '.', '' ),
292
+ $value
293
+ );
294
  }
295
 
296
  $value = trim( $value );
312
  */
313
  public function format( $value = null, $name = null, $options = null, $pod = null, $id = null ) {
314
 
315
+ if ( $this->is_empty( $value ) && ( ! is_numeric( $value ) || 0.0 !== (float) $value ) ) {
316
  // Don't enforce a default value here.
317
  return null;
318
  }
375
  */
376
  public function get_number_format_args( $options ) {
377
 
378
+ $format = pods_v( static::$type . '_format', $options );
379
+ $format = pods_unslash( $format );
380
+
381
+ switch ( $format ) {
382
+ case '9.999,99':
383
+ $thousands = '.';
384
+ $dot = ',';
385
+ break;
386
+ case '9,999.99':
387
+ $thousands = ',';
388
+ $dot = '.';
389
+ break;
390
+ case '9\'999.99':
391
+ $thousands = '\'';
392
+ $dot = '.';
393
+ break;
394
+ case '9 999,99':
395
+ $thousands = ' ';
396
+ $dot = ',';
397
+ break;
398
+ case '9999.99':
399
+ $thousands = '';
400
+ $dot = '.';
401
+ break;
402
+ case '9999,99':
403
+ $thousands = '';
404
+ $dot = ',';
405
+ break;
406
+ default:
407
+ global $wp_locale;
408
+ $thousands = $wp_locale->number_format['thousands_sep'];
409
+ $dot = $wp_locale->number_format['decimal_point'];
410
+ break;
411
+ }
412
 
413
  $decimals = $this->get_max_decimals( $options );
414
 
classes/fields/pick.php CHANGED
@@ -105,6 +105,7 @@ class PodsField_Pick extends PodsField {
105
  add_action( 'edit_category_form', array( $this, 'admin_modal_input' ) );
106
  add_action( 'edit_link_category_form', array( $this, 'admin_modal_input' ) );
107
  add_action( 'edit_tag_form', array( $this, 'admin_modal_input' ) );
 
108
  add_action( 'add_tag_form', array( $this, 'admin_modal_input' ) );
109
  add_action( 'pods_meta_box_pre', array( $this, 'admin_modal_input' ) );
110
 
@@ -168,6 +169,28 @@ class PodsField_Pick extends PodsField {
168
  ),
169
  'dependency' => true,
170
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  static::$type . '_allow_add_new' => array(
172
  'label' => __( 'Allow Add New', 'pods' ),
173
  'help' => __( 'Allow new related records to be created in a modal window', 'pods' ),
@@ -719,13 +742,23 @@ class PodsField_Pick extends PodsField {
719
  }
720
  }
721
 
722
- return pods_serial_comma(
723
- $value, array(
724
- 'field' => $name,
725
- 'fields' => $fields,
726
- )
727
  );
728
 
 
 
 
 
 
 
 
 
 
 
 
 
729
  }
730
 
731
  /**
@@ -1304,28 +1337,41 @@ class PodsField_Pick extends PodsField {
1304
  $edit_link = add_query_arg( array( 'pods_modal' => '1' ), $edit_link );
1305
  }
1306
 
1307
- // Determine if this is a selected item
 
1308
  $selected = false;
1309
 
1310
- if ( is_array( $args->value ) ) {
1311
- if ( ! isset( $args->value[0] ) ) {
1312
- $keys = array_map( 'strval', array_keys( $args->value ) );
1313
 
1314
- if ( in_array( (string) $item_id, $keys, true ) ) {
1315
- $selected = true;
1316
- }
1317
- }
 
1318
 
1319
- if ( ! $selected ) {
1320
- // Cast values in array as string.
1321
- $args->value = array_map( 'strval', $args->value );
1322
 
1323
- if ( in_array( (string) $item_id, $args->value, true ) ) {
1324
- $selected = true;
1325
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1326
  }
1327
- } elseif ( (string) $item_id === (string) $args->value ) {
1328
- $selected = true;
1329
  }
1330
 
1331
  $item = array(
105
  add_action( 'edit_category_form', array( $this, 'admin_modal_input' ) );
106
  add_action( 'edit_link_category_form', array( $this, 'admin_modal_input' ) );
107
  add_action( 'edit_tag_form', array( $this, 'admin_modal_input' ) );
108
+ // @todo add_tag_form is deprecated, replace our hook usage.
109
  add_action( 'add_tag_form', array( $this, 'admin_modal_input' ) );
110
  add_action( 'pods_meta_box_pre', array( $this, 'admin_modal_input' ) );
111
 
169
  ),
170
  'dependency' => true,
171
  ),
172
+ static::$type . '_display_format_multi' => array(
173
+ 'label' => __( 'Display Format', 'pods' ),
174
+ 'help' => __( 'Used as format for front-end display', 'pods' ),
175
+ 'depends-on' => array( static::$type . '_format_type' => 'multi' ),
176
+ 'default' => 'default',
177
+ 'type' => 'pick',
178
+ 'data' => array(
179
+ 'default' => __( 'Item 1, Item 2, and Item 3', 'pods' ),
180
+ 'custom' => __( 'Custom separator (with no "and")', 'pods' ),
181
+ ),
182
+ 'dependency' => true,
183
+ ),
184
+ static::$type . '_display_format_separator' => array(
185
+ 'label' => __( 'Display Format Separator', 'pods' ),
186
+ 'help' => __( 'Used as separator for front-end display. This also turns off the "and" portion of the formatting.', 'pods' ),
187
+ 'depends-on' => array(
188
+ static::$type . '_display_format_multi' => 'custom',
189
+ static::$type . '_format_type' => 'multi',
190
+ ),
191
+ 'default' => ', ',
192
+ 'type' => 'text',
193
+ ),
194
  static::$type . '_allow_add_new' => array(
195
  'label' => __( 'Allow Add New', 'pods' ),
196
  'help' => __( 'Allow new related records to be created in a modal window', 'pods' ),
742
  }
743
  }
744
 
745
+ $args = array(
746
+ 'field' => $name,
747
+ 'fields' => $fields,
 
 
748
  );
749
 
750
+ if ( 'custom' === pods_v( static::$type . '_display_format_multi', $options, 'default' ) ) {
751
+ $separator = pods_v( static::$type . '_display_format_separator', $options, ', ' );
752
+
753
+ if ( ! empty( $separator ) ) {
754
+ $args['separator'] = $separator;
755
+
756
+ // Replicate separator behavior.
757
+ $args['and'] = $args['separator'];
758
+ }
759
+ }
760
+
761
+ return pods_serial_comma( $value, $args );
762
  }
763
 
764
  /**
1337
  $edit_link = add_query_arg( array( 'pods_modal' => '1' ), $edit_link );
1338
  }
1339
 
1340
+ // Determine if this is a selected item.
1341
+ // Issue history for setting selected: #4753, #4892, #5014.
1342
  $selected = false;
1343
 
1344
+ $values = array();
 
 
1345
 
1346
+ // If we have values, let's cast them.
1347
+ if ( ! empty( $args->value ) ) {
1348
+ // The value may be a single non-array value.
1349
+ $values = (array) $args->value;
1350
+ }
1351
 
1352
+ // Cast values in array as string.
1353
+ $values = array_map( 'strval', $values );
 
1354
 
1355
+ // If the value array has keys as IDs, let's check for matches from the keys first.
1356
+ if ( ! isset( $values[0] ) ) {
1357
+ // Get values from keys.
1358
+ $key_values = array_keys( $values );
1359
+
1360
+ // Cast key values in array as string.
1361
+ $key_values = array_map( 'strval', $key_values );
1362
+
1363
+ // Let's check to see if the current $item_id matches any key values.
1364
+ if ( in_array( (string) $item_id, $key_values, true ) ) {
1365
+ $selected = true;
1366
+ }
1367
+ }
1368
+
1369
+ // If we do not have a key match, the normal values may still match.
1370
+ if ( ! $selected ) {
1371
+ // Let's check to see if the current $item_id matches any values.
1372
+ if ( in_array( (string) $item_id, $values, true ) ) {
1373
+ $selected = true;
1374
  }
 
 
1375
  }
1376
 
1377
  $item = array(
components/Advanced-Content-Types.php CHANGED
@@ -2,9 +2,7 @@
2
  /**
3
  * Name: Advanced Content Types
4
  *
5
- * Description: A content type that exists outside of the WordPress post and postmeta table and uses custom tables
6
- * instead. You most likely don't need these and we strongly recommend that you use Custom Post Types or Custom
7
- * Taxonomies instead. FOR ADVANCED USERS ONLY.
8
  *
9
  * Version: 2.3
10
  *
2
  /**
3
  * Name: Advanced Content Types
4
  *
5
+ * Description: A content type that exists outside of the WordPress post and postmeta table and uses custom tables instead. You most likely don't need these and we strongly recommend that you use Custom Post Types or Custom Taxonomies instead. FOR ADVANCED USERS ONLY.
 
 
6
  *
7
  * Version: 2.3
8
  *
components/Advanced-Relationships.php CHANGED
@@ -2,8 +2,7 @@
2
  /**
3
  * Name: Advanced Relationships
4
  *
5
- * Description: Add advanced relationship objects for relating to including Database Tables, Multisite Networks,
6
- * Multisite Sites, Themes, Page Templates, Sidebars, Post Type Objects, and Taxonomy Objects
7
  *
8
  * Version: 2.3
9
  *
2
  /**
3
  * Name: Advanced Relationships
4
  *
5
+ * Description: Add advanced relationship objects for relating to including Database Tables, Multisite Networks, Multisite Sites, Themes, Page Templates, Sidebars, Post Type Objects, and Taxonomy Objects
 
6
  *
7
  * Version: 2.3
8
  *
components/Builder/Builder.php CHANGED
@@ -2,8 +2,7 @@
2
  /**
3
  * Name: Builder Integration
4
  *
5
- * Description: Integration with the <a href="http://ithemes.com/">Builder</a> theme / child themes from <a
6
- * href="http://ithemes.com/">iThemes</a>; Adds new modules to the Layout engine
7
  *
8
  * Version: 1.0
9
  *
2
  /**
3
  * Name: Builder Integration
4
  *
5
+ * Description: Integration with the <a href="http://ithemes.com/">Builder</a> theme / child themes from <a href="http://ithemes.com/">iThemes</a>; Adds new modules to the Layout engine
 
6
  *
7
  * Version: 1.0
8
  *
components/Helpers.php CHANGED
@@ -2,8 +2,7 @@
2
  /**
3
  * Name: Helpers
4
  *
5
- * Description: A holdover from Pods 1.x for backwards compatibility purposes, you most likely don't need these and we
6
- * recommend you use our WP filters and actions instead.
7
  *
8
  * Version: 2.3
9
  *
@@ -73,7 +72,7 @@ class Pods_Helpers extends PodsComponent {
73
  if ( is_admin() ) {
74
  add_filter( 'post_updated_messages', array( $this, 'setup_updated_messages' ), 10, 1 );
75
 
76
- add_action( 'dbx_post_advanced', array( $this, 'edit_page_form' ) );
77
 
78
  add_action( 'pods_meta_groups', array( $this, 'add_meta_boxes' ) );
79
  add_filter( 'get_post_metadata', array( $this, 'get_meta' ), 10, 4 );
2
  /**
3
  * Name: Helpers
4
  *
5
+ * Description: A holdover from Pods 1.x for backwards compatibility purposes, you most likely don't need these and we recommend you use our WP filters and actions instead.
 
6
  *
7
  * Version: 2.3
8
  *
72
  if ( is_admin() ) {
73
  add_filter( 'post_updated_messages', array( $this, 'setup_updated_messages' ), 10, 1 );
74
 
75
+ add_action( 'add_meta_boxes_' . $this->object_type, array( $this, 'edit_page_form' ) );
76
 
77
  add_action( 'pods_meta_groups', array( $this, 'add_meta_boxes' ) );
78
  add_filter( 'get_post_metadata', array( $this, 'get_meta' ), 10, 4 );
components/I18n/I18n.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * Menu Name: Translate Pods
6
  *
7
- * Description: Allow UI of Pods and fields to be translated
8
  *
9
  * Version: 0.2
10
  *
4
  *
5
  * Menu Name: Translate Pods
6
  *
7
+ * Description: Allow UI of Pods and fields to be translated.
8
  *
9
  * Version: 0.2
10
  *
components/Markdown.php CHANGED
@@ -4,8 +4,7 @@
4
  *
5
  * Name: Markdown Syntax
6
  *
7
- * Description: Integration with Markdown (http://michelf.com/projects/php-markdown/); Adds an option to enable
8
- * Markdown syntax for Paragraph text fields.
9
  *
10
  * Version: 1.0
11
  *
@@ -1101,7 +1100,7 @@ if ( ! function_exists( 'Markdown' ) ) :
1101
  return $matches[0];
1102
  }
1103
 
1104
- $level = $matches[2]{0} == '=' ? 1 : 2;
1105
  $block = "<h$level>" . $this->runSpanGamut( $matches[1] ) . "</h$level>";
1106
 
1107
  return "\n" . $this->hashBlock( $block ) . "\n\n";
@@ -1449,7 +1448,7 @@ if ( ! function_exists( 'Markdown' ) ) :
1449
  } else {
1450
  // Other closing marker: close one em or strong and
1451
  // change current token state to match the other
1452
- $token_stack[0] = str_repeat( $token{0}, 3 - $token_len );
1453
  $tag = $token_len == 2 ? 'strong' : 'em';
1454
  $span = $text_stack[0];
1455
  $span = $this->runSpanGamut( $span );
@@ -1476,7 +1475,7 @@ if ( ! function_exists( 'Markdown' ) ) :
1476
  } else {
1477
  // Reached opening three-char emphasis marker. Push on token
1478
  // stack; will be handled by the special condition above.
1479
- $em = $token{0};
1480
  $strong = "$em$em";
1481
  array_unshift( $token_stack, $token );
1482
  array_unshift( $text_stack, '' );
@@ -1902,9 +1901,9 @@ if ( ! function_exists( 'Markdown' ) ) :
1902
  // Handle $token provided by parseSpan by determining its nature and
1903
  // returning the corresponding value that should replace it.
1904
  //
1905
- switch ( $token{0} ) {
1906
  case '\\':
1907
- return $this->hashPart( '&#' . ord( $token{1} ) . ';' );
1908
  case '`':
1909
  // Search for end marker in remaining text.
1910
  if ( preg_match( '/^(.*?[^`])' . preg_quote( $token ) . '(?!`)(.*)$/sm', $str, $matches ) ) {
4
  *
5
  * Name: Markdown Syntax
6
  *
7
+ * Description: Integration with Markdown (http://michelf.com/projects/php-markdown/); Adds an option to enable Markdown syntax for Paragraph text fields.
 
8
  *
9
  * Version: 1.0
10
  *
1100
  return $matches[0];
1101
  }
1102
 
1103
+ $level = $matches[2][0] == '=' ? 1 : 2;
1104
  $block = "<h$level>" . $this->runSpanGamut( $matches[1] ) . "</h$level>";
1105
 
1106
  return "\n" . $this->hashBlock( $block ) . "\n\n";
1448
  } else {
1449
  // Other closing marker: close one em or strong and
1450
  // change current token state to match the other
1451
+ $token_stack[0] = str_repeat( $token[0], 3 - $token_len );
1452
  $tag = $token_len == 2 ? 'strong' : 'em';
1453
  $span = $text_stack[0];
1454
  $span = $this->runSpanGamut( $span );
1475
  } else {
1476
  // Reached opening three-char emphasis marker. Push on token
1477
  // stack; will be handled by the special condition above.
1478
+ $em = $token[0];
1479
  $strong = "$em$em";
1480
  array_unshift( $token_stack, $token );
1481
  array_unshift( $text_stack, '' );
1901
  // Handle $token provided by parseSpan by determining its nature and
1902
  // returning the corresponding value that should replace it.
1903
  //
1904
+ switch ( $token[0] ) {
1905
  case '\\':
1906
+ return $this->hashPart( '&#' . ord( $token[1] ) . ';' );
1907
  case '`':
1908
  // Search for end marker in remaining text.
1909
  if ( preg_match( '/^(.*?[^`])' . preg_quote( $token ) . '(?!`)(.*)$/sm', $str, $matches ) ) {
components/Migrate-CPTUI/Migrate-CPTUI.php CHANGED
@@ -4,8 +4,7 @@
4
  *
5
  * Menu Name: Migrate CPT UI
6
  *
7
- * Description: Import Custom Post Types and Taxonomies from Custom Post Type UI (<a
8
- * href="http://webdevstudios.com/plugin/custom-post-type-ui/">http://webdevstudios.com/plugin/custom-post-type-ui/</a>)
9
  *
10
  * Category: Migration
11
  *
4
  *
5
  * Menu Name: Migrate CPT UI
6
  *
7
+ * Description: Import Custom Post Types and Taxonomies from Custom Post Type UI (<a href="http://webdevstudios.com/plugin/custom-post-type-ui/">http://webdevstudios.com/plugin/custom-post-type-ui/</a>)
 
8
  *
9
  * Category: Migration
10
  *
components/Migrate-Packages/Migrate-Packages.php CHANGED
@@ -4,8 +4,7 @@
4
  *
5
  * Menu Name: Migrate Packages
6
  *
7
- * Description: Import/Export your Pods, Fields, and other settings from any Pods site; Includes an API to
8
- * Import/Export Packages via PHP
9
  *
10
  * Version: 2.0
11
  *
4
  *
5
  * Menu Name: Migrate Packages
6
  *
7
+ * Description: Import/Export your Pods, Fields, and other settings from any Pods site; Includes an API to Import/Export Packages via PHP
 
8
  *
9
  * Version: 2.0
10
  *
components/Pages.php CHANGED
@@ -2,8 +2,7 @@
2
  /**
3
  * Name: Pages
4
  *
5
- * Description: Creates advanced URL structures using wildcards in order to enable the front-end display of Pods
6
- * Advanced Content Types. Not recommended for use with other content types.
7
  *
8
  * Version: 2.3
9
  *
@@ -106,7 +105,7 @@ class Pods_Pages extends PodsComponent {
106
  } else {
107
  add_filter( 'post_updated_messages', array( $this, 'setup_updated_messages' ), 10, 1 );
108
 
109
- add_action( 'dbx_post_advanced', array( $this, 'edit_page_form' ) );
110
 
111
  add_action( 'pods_meta_groups', array( $this, 'add_meta_boxes' ) );
112
  add_filter( 'get_post_metadata', array( $this, 'get_meta' ), 10, 4 );
@@ -374,13 +373,6 @@ class Pods_Pages extends PodsComponent {
374
  * @since 2.0.0
375
  */
376
  public function edit_page_form() {
377
-
378
- global $post_type;
379
-
380
- if ( $this->object_type != $post_type ) {
381
- return;
382
- }
383
-
384
  add_filter( 'enter_title_here', array( $this, 'set_title_text' ), 10, 2 );
385
  }
386
 
2
  /**
3
  * Name: Pages
4
  *
5
+ * Description: Creates advanced URL structures using wildcards in order to enable the front-end display of Pods Advanced Content Types. Not recommended for use with other content types.
 
6
  *
7
  * Version: 2.3
8
  *
105
  } else {
106
  add_filter( 'post_updated_messages', array( $this, 'setup_updated_messages' ), 10, 1 );
107
 
108
+ add_action( 'add_meta_boxes_' . $this->object_type, array( $this, 'edit_page_form' ) );
109
 
110
  add_action( 'pods_meta_groups', array( $this, 'add_meta_boxes' ) );
111
  add_filter( 'get_post_metadata', array( $this, 'get_meta' ), 10, 4 );
373
  * @since 2.0.0
374
  */
375
  public function edit_page_form() {
 
 
 
 
 
 
 
376
  add_filter( 'enter_title_here', array( $this, 'set_title_text' ), 10, 2 );
377
  }
378
 
components/Roles/Roles.php CHANGED
@@ -4,10 +4,7 @@
4
  *
5
  * Menu Name: Roles &amp; Capabilities
6
  *
7
- * Description: Create and Manage WordPress User Roles and Capabilities; Uses the '<a
8
- * href="http://wordpress.org/plugins/members/" target="_blank">Members</a>' plugin filters for additional plugin
9
- * integrations; Portions of code based on the '<a href="http://wordpress.org/plugins/members/"
10
- * target="_blank">Members</a>' plugin by Justin Tadlock
11
  *
12
  * Version: 1.0
13
  *
4
  *
5
  * Menu Name: Roles &amp; Capabilities
6
  *
7
+ * Description: Create and Manage WordPress User Roles and Capabilities; Uses the '<a href="http://wordpress.org/plugins/members/" target="_blank">Members</a>' plugin filters for additional plugin integrations; Portions of code based on the '<a href="http://wordpress.org/plugins/members/" target="_blank">Members</a>' plugin by Justin Tadlock
 
 
 
8
  *
9
  * Version: 1.0
10
  *
components/Roles/ui/edit.php CHANGED
@@ -30,7 +30,7 @@
30
 
31
  <p><?php _e( 'Choose below which Capabilities you would like this existing user role to have.', 'pods' ); ?></p>
32
 
33
- <div id="poststuff">
34
  <div id="post-body" class="metabox-holder columns-2">
35
 
36
  <div id="postbox-container-1" class="postbox-container">
30
 
31
  <p><?php _e( 'Choose below which Capabilities you would like this existing user role to have.', 'pods' ); ?></p>
32
 
33
+ <div id="poststuff" class="poststuff">
34
  <div id="post-body" class="metabox-holder columns-2">
35
 
36
  <div id="postbox-container-1" class="postbox-container">
components/Table-Storage.php CHANGED
@@ -2,8 +2,7 @@
2
  /**
3
  * Name: Table Storage
4
  *
5
- * Description: Enable a custom database table for your custom fields on Post Types, Media, Taxonomies, Users, and
6
- * Comments.
7
  *
8
  * Version: 2.3
9
  *
2
  /**
3
  * Name: Table Storage
4
  *
5
+ * Description: Enable a custom database table for your custom fields on Post Types, Media, Taxonomies, Users, and Comments.
 
6
  *
7
  * Version: 2.3
8
  *
components/Templates/Templates.php CHANGED
@@ -2,8 +2,7 @@
2
  /**
3
  * Name: Templates
4
  *
5
- * Description: An easy to use templating engine for Pods. Use {@field_name} magic tags to output values, within your
6
- * HTML markup.
7
  *
8
  * Version: 2.3
9
  *
@@ -100,7 +99,7 @@ class Pods_Templates extends PodsComponent {
100
  if ( is_admin() ) {
101
  add_filter( 'post_updated_messages', array( $this, 'setup_updated_messages' ), 10, 1 );
102
 
103
- add_action( 'dbx_post_advanced', array( $this, 'edit_page_form' ) );
104
 
105
  add_action( 'pods_meta_groups', array( $this, 'add_meta_boxes' ) );
106
 
2
  /**
3
  * Name: Templates
4
  *
5
+ * Description: An easy to use templating engine for Pods. Use {@field_name} magic tags to output values, within your HTML markup.
 
6
  *
7
  * Version: 2.3
8
  *
99
  if ( is_admin() ) {
100
  add_filter( 'post_updated_messages', array( $this, 'setup_updated_messages' ), 10, 1 );
101
 
102
+ add_action( 'add_meta_boxes_' . $this->object_type, array( $this, 'edit_page_form' ) );
103
 
104
  add_action( 'pods_meta_groups', array( $this, 'add_meta_boxes' ) );
105
 
components/Templates/class-pods_templates.php CHANGED
@@ -164,7 +164,7 @@ class Pods_Templates_Frontier {
164
  */
165
  public function activate_metaboxes() {
166
 
167
- add_action( 'add_meta_boxes', array( $this, 'add_metaboxes' ), 5, 4 );
168
  add_action( 'save_post', array( $this, 'save_post_metaboxes' ), 1, 2 );
169
 
170
  }
@@ -172,25 +172,28 @@ class Pods_Templates_Frontier {
172
  /**
173
  * setup meta boxes.
174
  *
175
- * @param $slug
176
  * @param bool $post
177
  *
178
  * @return null
179
  */
180
- public function add_metaboxes( $slug, $post = false ) {
181
 
182
  if ( ! empty( $post ) ) {
183
  if ( ! in_array( $post->post_type, array( '_pods_template' ), true ) ) {
184
  return;
185
  }
 
 
186
  } else {
187
  $screen = get_current_screen();
188
  if ( ! in_array( $screen->base, array( '_pods_template' ), true ) ) {
189
  return;
190
  }
 
 
191
  }
192
 
193
- $this->plugin_screen_hook_suffix[ $slug ] = $slug;
194
 
195
  // Required Styles for metabox
196
  wp_enqueue_style( $this->plugin_slug . '-view_template-styles', $this->get_url( 'assets/css/styles-view_template.css', __FILE__ ), array(), self::VERSION );
164
  */
165
  public function activate_metaboxes() {
166
 
167
+ add_action( 'add_meta_boxes__pods_template', array( $this, 'add_metaboxes' ), 5, 2 );
168
  add_action( 'save_post', array( $this, 'save_post_metaboxes' ), 1, 2 );
169
 
170
  }
172
  /**
173
  * setup meta boxes.
174
  *
 
175
  * @param bool $post
176
  *
177
  * @return null
178
  */
179
+ public function add_metaboxes( $post = false ) {
180
 
181
  if ( ! empty( $post ) ) {
182
  if ( ! in_array( $post->post_type, array( '_pods_template' ), true ) ) {
183
  return;
184
  }
185
+
186
+ $slug = $post->post_type;
187
  } else {
188
  $screen = get_current_screen();
189
  if ( ! in_array( $screen->base, array( '_pods_template' ), true ) ) {
190
  return;
191
  }
192
+
193
+ $slug = $screen->base;
194
  }
195
 
196
+ $this->plugin_screen_hook_suffix[ $slug ] = $post->post_type;
197
 
198
  // Required Styles for metabox
199
  wp_enqueue_style( $this->plugin_slug . '-view_template-styles', $this->get_url( 'assets/css/styles-view_template.css', __FILE__ ), array(), self::VERSION );
components/Templates/includes/functions-pod_reference.php CHANGED
@@ -45,7 +45,13 @@ function pq_recurse_pod_fields( $pod_name, $prefix = '', &$pods_visited = array(
45
  if ( empty( $pod_name ) ) {
46
  return $fields;
47
  }
48
- $pod = pods( $pod_name );
 
 
 
 
 
 
49
  $recurse_queue = array();
50
 
51
  foreach ( $pod->pod_data['object_fields'] as $name => $field ) {
45
  if ( empty( $pod_name ) ) {
46
  return $fields;
47
  }
48
+
49
+ $pod = pods( $pod_name );
50
+
51
+ if ( empty( $pod ) || ! $pod->valid() ) {
52
+ return $fields;
53
+ }
54
+
55
  $recurse_queue = array();
56
 
57
  foreach ( $pod->pod_data['object_fields'] as $name => $field ) {
includes/compatibility/acf.php ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Compatibility functions for integration with other plugins.
4
+ *
5
+ * @package Pods
6
+ */
7
+
8
+ /**
9
+ * Enable backwards compatibility with ACF functions.
10
+ *
11
+ * @param bool $acf_backwards_compatibility Whether to enable backwards compatibility for ACF functions.
12
+ *
13
+ * @since 2.7.17
14
+ */
15
+ $acf_backwards_compatibility = apply_filters( 'pods_acf_backwards_compatibility', true );
16
+
17
+ if ( $acf_backwards_compatibility ) {
18
+ if ( ! function_exists( 'the_field' ) ) {
19
+ /**
20
+ * Backwards compatibility function for the_field() from ACF.
21
+ *
22
+ * @param string|array $field The field name, or an associative array of parameters.
23
+ * @param mixed|false $id The ID or slug to load a single item, array of $params to run find.
24
+ *
25
+ * @since 2.7.17
26
+ */
27
+ function the_field( $field, $id = false ) {
28
+ // @codingStandardsIgnoreLine
29
+ echo pods_field_display( null, $id, $field, true );
30
+ }
31
+ }
32
+
33
+ if ( ! function_exists( 'get_field' ) ) {
34
+ /**
35
+ * Backwards compatibility function for get_field() from ACF.
36
+ *
37
+ * @param string|array $field The field name, or an associative array of parameters.
38
+ * @param mixed|false $id The ID or slug to load a single item, array of $params to run find.
39
+ *
40
+ * @return mixed Field value.
41
+ *
42
+ * @since 2.7.17
43
+ */
44
+ function get_field( $field, $id = false ) {
45
+ return pods_field( null, $id, $field, true );
46
+ }
47
+ }
48
+
49
+ if ( ! function_exists( 'update_field' ) ) {
50
+ /**
51
+ * Backwards compatibility function for update_field() from ACF.
52
+ *
53
+ * @param string|array $field The field name, or an associative array of parameters.
54
+ * @param mixed $value The value to save.
55
+ * @param mixed|false $id The ID or slug to load a single item, array of $params to run find.
56
+ *
57
+ * @return int|false The item ID or false if not saved.
58
+ *
59
+ * @since 2.7.17
60
+ */
61
+ function update_field( $field, $value, $id = false ) {
62
+ return pods_field_update( null, $id, $field, $value );
63
+ }
64
+ }
65
+
66
+ if ( ! function_exists( 'delete_field' ) ) {
67
+ /**
68
+ * Backwards compatibility function for delete_field() from ACF.
69
+ *
70
+ * @param string|array $field The field name, or an associative array of parameters.
71
+ * @param mixed|false $id The ID or slug to load a single item, array of $params to run find.
72
+ *
73
+ * @return int|false The item ID or false if not saved.
74
+ *
75
+ * @since 2.7.17
76
+ */
77
+ function delete_field( $field, $id = false ) {
78
+ return pods_field_update( null, $id, $field, null );
79
+ }
80
+ }
81
+
82
+ if ( ! shortcode_exists( 'acf' ) ) {
83
+ /**
84
+ * Backwards compatibility function for [acf] shortcode from ACF.
85
+ *
86
+ * @param array $tags An associative array of shortcode properties.
87
+ * @param string $content A string that represents a template override.
88
+ *
89
+ * @return string
90
+ *
91
+ * @since 2.7.17
92
+ */
93
+ function pods_acf_shortcode( $tags, $content ) {
94
+
95
+ $post_id = null;
96
+
97
+ if ( ! empty( $tags['post_id'] ) ) {
98
+ $post_id = $tags['post_id'];
99
+ }
100
+
101
+ $tags = array(
102
+ 'field' => $tags['field'],
103
+ 'id' => $post_id,
104
+ );
105
+
106
+ return pods_shortcode( $tags, $content );
107
+ }
108
+
109
+ add_shortcode( 'acf', 'pods_acf_shortcode' );
110
+ }//end if
111
+
112
+ /**
113
+ * These functions below will do nothing for now. We might add some sort of further compatibility later.
114
+ */
115
+
116
+ if ( ! function_exists( 'get_field_object' ) ) {
117
+ /**
118
+ * Backwards compatibility function for get_field_object() from ACF.
119
+ *
120
+ * @return array
121
+ *
122
+ * @since 2.7.17
123
+ */
124
+ function get_field_object() {
125
+ return array();
126
+ }
127
+ }
128
+
129
+ if ( ! function_exists( 'get_fields' ) ) {
130
+ /**
131
+ * Backwards compatibility function for get_fields() from ACF.
132
+ *
133
+ * @return array
134
+ *
135
+ * @since 2.7.17
136
+ */
137
+ function get_fields() {
138
+ return array();
139
+ }
140
+ }
141
+
142
+ if ( ! function_exists( 'get_field_objects' ) ) {
143
+ /**
144
+ * Backwards compatibility function for get_field_objects() from ACF.
145
+ *
146
+ * @return array
147
+ *
148
+ * @since 2.7.17
149
+ */
150
+ function get_field_objects() {
151
+ return array();
152
+ }
153
+ }
154
+
155
+ if ( ! function_exists( 'have_rows' ) ) {
156
+ /**
157
+ * Backwards compatibility function for have_rows() from ACF.
158
+ *
159
+ * @return false
160
+ *
161
+ * @since 2.7.17
162
+ */
163
+ function have_rows() {
164
+ return false;
165
+ }
166
+ }
167
+
168
+ if ( ! function_exists( 'get_sub_field' ) ) {
169
+ /**
170
+ * Backwards compatibility function for get_sub_field() from ACF.
171
+ *
172
+ * @return false
173
+ *
174
+ * @since 2.7.17
175
+ */
176
+ function get_sub_field() {
177
+ return false;
178
+ }
179
+ }
180
+
181
+ if ( ! function_exists( 'the_sub_field' ) ) {
182
+ /**
183
+ * Backwards compatibility function for the_sub_field() from ACF.
184
+ *
185
+ * @return null
186
+ *
187
+ * @since 2.7.17
188
+ */
189
+ function the_sub_field() {
190
+ return null;
191
+ }
192
+ }
193
+
194
+ if ( ! function_exists( 'get_sub_field_object' ) ) {
195
+ /**
196
+ * Backwards compatibility function for get_sub_field_object() from ACF.
197
+ *
198
+ * @return array
199
+ *
200
+ * @since 2.7.17
201
+ */
202
+ function get_sub_field_object() {
203
+ return array();
204
+ }
205
+ }
206
+
207
+ if ( ! function_exists( 'get_row' ) ) {
208
+ /**
209
+ * Backwards compatibility function for get_row() from ACF.
210
+ *
211
+ * @return array
212
+ *
213
+ * @since 2.7.17
214
+ */
215
+ function get_row() {
216
+ return array();
217
+ }
218
+ }
219
+
220
+ if ( ! function_exists( 'get_row_index' ) ) {
221
+ /**
222
+ * Backwards compatibility function for get_row_index() from ACF.
223
+ *
224
+ * @return int
225
+ *
226
+ * @since 2.7.17
227
+ */
228
+ function get_row_index() {
229
+ return 0;
230
+ }
231
+ }
232
+
233
+ if ( ! function_exists( 'get_row_layout' ) ) {
234
+ /**
235
+ * Backwards compatibility function for get_row_layout() from ACF.
236
+ *
237
+ * @return null
238
+ *
239
+ * @since 2.7.17
240
+ */
241
+ function get_row_layout() {
242
+ return null;
243
+ }
244
+ }
245
+
246
+ if ( ! function_exists( 'delete_sub_field' ) ) {
247
+ /**
248
+ * Backwards compatibility function for delete_sub_field() from ACF.
249
+ *
250
+ * @return null
251
+ *
252
+ * @since 2.7.17
253
+ */
254
+ function delete_sub_field() {
255
+ return null;
256
+ }
257
+ }
258
+
259
+ if ( ! function_exists( 'update_sub_field' ) ) {
260
+ /**
261
+ * Backwards compatibility function for update_sub_field() from ACF.
262
+ *
263
+ * @return null
264
+ *
265
+ * @since 2.7.17
266
+ */
267
+ function update_sub_field() {
268
+ return null;
269
+ }
270
+ }
271
+
272
+ if ( ! function_exists( 'add_row' ) ) {
273
+ /**
274
+ * Backwards compatibility function for add_row() from ACF.
275
+ *
276
+ * @return null
277
+ *
278
+ * @since 2.7.17
279
+ */
280
+ function add_row() {
281
+ return null;
282
+ }
283
+ }
284
+
285
+ if ( ! function_exists( 'update_row' ) ) {
286
+ /**
287
+ * Backwards compatibility function for update_row() from ACF.
288
+ *
289
+ * @return null
290
+ *
291
+ * @since 2.7.17
292
+ */
293
+ function update_row() {
294
+ return null;
295
+ }
296
+ }
297
+
298
+ if ( ! function_exists( 'delete_row' ) ) {
299
+ /**
300
+ * Backwards compatibility function for delete_row() from ACF.
301
+ *
302
+ * @return null
303
+ *
304
+ * @since 2.7.17
305
+ */
306
+ function delete_row() {
307
+ return null;
308
+ }
309
+ }
310
+
311
+ if ( ! function_exists( 'add_sub_row' ) ) {
312
+ /**
313
+ * Backwards compatibility function for add_sub_row() from ACF.
314
+ *
315
+ * @return null
316
+ *
317
+ * @since 2.7.17
318
+ */
319
+ function add_sub_row() {
320
+ return null;
321
+ }
322
+ }
323
+
324
+ if ( ! function_exists( 'update_sub_row' ) ) {
325
+ /**
326
+ * Backwards compatibility function for update_sub_row() from ACF.
327
+ *
328
+ * @return null
329
+ *
330
+ * @since 2.7.17
331
+ */
332
+ function update_sub_row() {
333
+ return null;
334
+ }
335
+ }
336
+
337
+ if ( ! function_exists( 'delete_sub_row' ) ) {
338
+ /**
339
+ * Backwards compatibility function for delete_sub_row() from ACF.
340
+ *
341
+ * @return null
342
+ *
343
+ * @since 2.7.17
344
+ */
345
+ function delete_sub_row() {
346
+ return null;
347
+ }
348
+ }
349
+
350
+ if ( ! function_exists( 'acf_add_options_page' ) ) {
351
+ /**
352
+ * Backwards compatibility function for acf_add_options_page() from ACF.
353
+ *
354
+ * @return null
355
+ *
356
+ * @since 2.7.17
357
+ */
358
+ function acf_add_options_page() {
359
+ return null;
360
+ }
361
+ }
362
+
363
+ if ( ! function_exists( 'acf_add_options_sub_page' ) ) {
364
+ /**
365
+ * Backwards compatibility function for acf_add_options_sub_page() from ACF.
366
+ *
367
+ * @return null
368
+ *
369
+ * @since 2.7.17
370
+ */
371
+ function acf_add_options_sub_page() {
372
+ return null;
373
+ }
374
+ }
375
+
376
+ if ( ! function_exists( 'acf_form_head' ) ) {
377
+ /**
378
+ * Backwards compatibility function for acf_form_head() from ACF.
379
+ *
380
+ * @return null
381
+ *
382
+ * @since 2.7.17
383
+ */
384
+ function acf_form_head() {
385
+ return null;
386
+ }
387
+ }
388
+
389
+ if ( ! function_exists( 'acf_form' ) ) {
390
+ /**
391
+ * Backwards compatibility function for acf_form() from ACF.
392
+ *
393
+ * @return null
394
+ *
395
+ * @since 2.7.17
396
+ */
397
+ function acf_form() {
398
+ return null;
399
+ }
400
+ }
401
+
402
+ if ( ! function_exists( 'acf_register_form' ) ) {
403
+ /**
404
+ * Backwards compatibility function for acf_register_form() from ACF.
405
+ *
406
+ * @return null
407
+ *
408
+ * @since 2.7.17
409
+ */
410
+ function acf_register_form() {
411
+ return null;
412
+ }
413
+ }
414
+ }//end if
includes/data.php CHANGED
@@ -1649,7 +1649,7 @@ function pods_serial_comma( $value, $field = null, $fields = null, $and = null,
1649
  'fields' => $fields,
1650
  'and' => $and,
1651
  'field_index' => $field_index,
1652
- 'separator' => ',',
1653
  'serial' => true,
1654
  );
1655
 
@@ -1711,12 +1711,6 @@ function pods_serial_comma( $value, $field = null, $fields = null, $and = null,
1711
  return $value;
1712
  }
1713
 
1714
- if ( null === $params->and ) {
1715
- $params->and = ' ' . __( 'and', 'pods' ) . ' ';
1716
- }
1717
-
1718
- $last = '';
1719
-
1720
  // If something happens with table info, and this is a single select relationship, avoid letting user pass through.
1721
  if ( isset( $value['user_pass'] ) ) {
1722
  unset( $value['user_pass'] );
@@ -1729,6 +1723,38 @@ function pods_serial_comma( $value, $field = null, $fields = null, $and = null,
1729
 
1730
  $original_value = $value;
1731
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1732
  if ( ! empty( $value ) ) {
1733
  $last = array_pop( $value );
1734
  }
@@ -1767,7 +1793,7 @@ function pods_serial_comma( $value, $field = null, $fields = null, $and = null,
1767
  if ( null !== $params->field_index && isset( $v[ $params->field_index ] ) ) {
1768
  $v = $v[ $params->field_index ];
1769
  } elseif ( $simple ) {
1770
- $v = trim( implode( $params->separator . ' ', $v ), $params->separator . ' ' );
1771
  } else {
1772
  unset( $value[ $k ] );
1773
 
@@ -1778,10 +1804,27 @@ function pods_serial_comma( $value, $field = null, $fields = null, $and = null,
1778
  $value[ $k ] = $v;
1779
  }
1780
 
1781
- if ( 1 == count( $value ) || ! $params->serial ) {
1782
- $value = trim( implode( $params->separator . ' ', $value ), $params->separator . ' ' );
1783
- } else {
1784
- $value = trim( implode( $params->separator . ' ', $value ), $params->separator . ' ' ) . apply_filters( 'pods_serial_comma', $params->separator . ' ', $value, $original_value, $params );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1785
  }
1786
 
1787
  $value = trim( $value );
1649
  'fields' => $fields,
1650
  'and' => $and,
1651
  'field_index' => $field_index,
1652
+ 'separator' => null,
1653
  'serial' => true,
1654
  );
1655
 
1711
  return $value;
1712
  }
1713
 
 
 
 
 
 
 
1714
  // If something happens with table info, and this is a single select relationship, avoid letting user pass through.
1715
  if ( isset( $value['user_pass'] ) ) {
1716
  unset( $value['user_pass'] );
1723
 
1724
  $original_value = $value;
1725
 
1726
+ if ( in_array( $params->separator, array( '', null ), true ) ) {
1727
+ $params->separator = ', ';
1728
+ }
1729
+
1730
+ if ( null === $params->and ) {
1731
+ $params->and = ' ' . __( 'and', 'pods' ) . ' ';
1732
+ }
1733
+
1734
+ /**
1735
+ * Allow filtering the "and" content used for pods_serial_comma.
1736
+ *
1737
+ * @since 2.7.17
1738
+ *
1739
+ * @param string|null $and The "and" content used, return null to disable.
1740
+ * @param string $value The value input into pods_serial_comma.
1741
+ * @param object $params The list of the setup parameters for pods_serial_comma.
1742
+ */
1743
+ $params->and = apply_filters( 'pods_serial_comma_and', $params->and, $value, $params );
1744
+
1745
+ /**
1746
+ * Allow filtering the "separator" content used for pods_serial_comma.
1747
+ *
1748
+ * @since 2.7.17
1749
+ *
1750
+ * @param string $separator The "separator" content used (default ", ").
1751
+ * @param string $value The value input into pods_serial_comma.
1752
+ * @param object $params The list of the setup parameters for pods_serial_comma.
1753
+ */
1754
+ $params->separator = apply_filters( 'pods_serial_comma_separator', $params->separator, $value, $params );
1755
+
1756
+ $last = '';
1757
+
1758
  if ( ! empty( $value ) ) {
1759
  $last = array_pop( $value );
1760
  }
1793
  if ( null !== $params->field_index && isset( $v[ $params->field_index ] ) ) {
1794
  $v = $v[ $params->field_index ];
1795
  } elseif ( $simple ) {
1796
+ $v = trim( implode( $params->separator, $v ), $params->separator . ' ' );
1797
  } else {
1798
  unset( $value[ $k ] );
1799
 
1804
  $value[ $k ] = $v;
1805
  }
1806
 
1807
+ $has_serial_comma = $params->serial && 1 < count( $value );
1808
+
1809
+ $value = trim( implode( $params->separator, $value ), $params->separator . ' ' );
1810
+
1811
+ // Add final serial comma.
1812
+ if ( $has_serial_comma ) {
1813
+ /**
1814
+ * Allow filtering the final serial comma (before the "and") used for pods_serial_comma.
1815
+ *
1816
+ * @since unknown
1817
+ *
1818
+ * @param string $serial_comma The serial comma content used, return an empty string to disable (default ", ").
1819
+ * @param string $value The formatted value.
1820
+ * @param string $original_value The original value input into pods_serial_comma.
1821
+ * @param object $params The list of the setup parameters for pods_serial_comma.
1822
+ */
1823
+ $serial_comma = apply_filters( 'pods_serial_comma', $params->separator, $value, $original_value, $params );
1824
+
1825
+ if ( '' !== $serial_comma ) {
1826
+ $value .= $serial_comma;
1827
+ }
1828
  }
1829
 
1830
  $value = trim( $value );
includes/general.php CHANGED
@@ -834,6 +834,7 @@ function pods_shortcode_run( $tags, $content = null ) {
834
  'fields' => null,
835
  'label' => null,
836
  'thank_you' => null,
 
837
  'view' => null,
838
  'cache_mode' => 'none',
839
  'expires' => 0,
@@ -876,13 +877,20 @@ function pods_shortcode_run( $tags, $content = null ) {
876
  if ( ! $tags['use_current'] && empty( $tags['name'] ) ) {
877
  $has_query_tags = array_intersect_key( array_diff( $tags, $defaults ), $default_query_tags );
878
 
879
- if ( ( in_the_loop() || is_singular() ) && ! $has_query_tags ) {
880
- $pod = pods( get_post_type(), get_the_ID(), false );
881
 
882
- if ( ! empty( $pod ) ) {
883
- $tags['name'] = get_post_type();
884
- $id = get_the_ID();
885
- $tags['id'] = get_the_ID();
 
 
 
 
 
 
 
886
  }
887
  }
888
 
@@ -1083,7 +1091,15 @@ function pods_shortcode_run( $tags, $content = null ) {
1083
  echo $pod->pagination( $tags['pagination_label'] );
1084
  }
1085
 
1086
- echo $pod->template( $tags['template'], $content );
 
 
 
 
 
 
 
 
1087
 
1088
  if ( ! $is_singular && 0 < $found && true === $tags['pagination'] && in_array(
1089
  $tags['pagination_location'], array(
@@ -1536,97 +1552,152 @@ function pods_by_title( $title, $output = OBJECT, $type = 'page', $status = null
1536
  }
1537
 
1538
  /**
1539
- * Get a field value from a Pod
1540
  *
1541
- * @param string $pod The pod name
1542
- * @param mixed $id (optional) The ID or slug, to load a single record; Provide array of $params to run
1543
- * 'find'
1544
- * @param string|array $name The field name, or an associative array of parameters
1545
- * @param boolean $single (optional) For tableless fields, to return the whole array or the just the first item
1546
  *
1547
- * @return mixed Field value
1548
  *
1549
  * @since 2.1.0
1550
  */
1551
- function pods_field( $pod, $id = false, $name = null, $single = false ) {
1552
 
1553
  // allow for pods_field( 'field_name' );
1554
  if ( null === $name ) {
1555
  $name = $pod;
1556
  $single = (boolean) $id;
1557
 
 
 
 
 
 
1558
  $pod = get_post_type();
1559
  $id = get_the_ID();
1560
  }
1561
 
1562
- $pod = pods( $pod, $id );
1563
 
1564
- if ( is_object( $pod ) ) {
1565
- return $pod->field( $name, $single );
1566
  }
1567
 
1568
  return null;
1569
  }
1570
 
1571
  /**
1572
- * Get a field display value from a Pod
1573
  *
1574
- * @param string $pod The pod name
1575
- * @param mixed $id (optional) The ID or slug, to load a single record; Provide array of $params to run
1576
- * 'find'
1577
- * @param string|array $name The field name, or an associative array of parameters
1578
- * @param boolean $single (optional) For tableless fields, to return the whole array or the just the first item
1579
  *
1580
- * @return mixed Field value
1581
  *
1582
  * @since 2.1.0
1583
  */
1584
- function pods_field_display( $pod, $id = false, $name = null, $single = false ) {
1585
 
1586
  // allow for pods_field_display( 'field_name' );
1587
  if ( null === $name ) {
1588
  $name = $pod;
1589
  $single = (boolean) $id;
1590
 
 
 
 
 
 
1591
  $pod = get_post_type();
1592
  $id = get_the_ID();
1593
  }
1594
 
1595
- $pod = pods( $pod, $id );
1596
 
1597
- if ( is_object( $pod ) ) {
1598
- return $pod->display( $name, $single );
1599
  }
1600
 
1601
  return null;
1602
  }
1603
 
1604
  /**
1605
- * Get a field raw value from a Pod
1606
  *
1607
- * @param string $pod The pod name
1608
- * @param mixed $id (optional) The ID or slug, to load a single record; Provide array of $params to run
1609
- * 'find'
1610
- * @param string|array $name The field name, or an associative array of parameters
1611
- * @param boolean $single (optional) For tableless fields, to return the whole array or the just the first item
1612
  *
1613
- * @return mixed Field value
1614
  *
1615
  * @since 2.1.0
1616
  */
1617
- function pods_field_raw( $pod, $id = false, $name = null, $single = false ) {
1618
 
1619
  // allow for pods_field_raw( 'field_name' );
1620
  if ( null === $name ) {
1621
  $name = $pod;
1622
  $single = (boolean) $id;
1623
 
 
 
 
 
 
1624
  $pod = get_post_type();
1625
  $id = get_the_ID();
1626
  }
1627
 
1628
- return pods( $pod, $id )->raw( $name, $single );
1629
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1630
  }
1631
 
1632
  /**
834
  'fields' => null,
835
  'label' => null,
836
  'thank_you' => null,
837
+ 'not_found' => null,
838
  'view' => null,
839
  'cache_mode' => 'none',
840
  'expires' => 0,
877
  if ( ! $tags['use_current'] && empty( $tags['name'] ) ) {
878
  $has_query_tags = array_intersect_key( array_diff( $tags, $defaults ), $default_query_tags );
879
 
880
+ // Only allow revert to current object if there are no query tags.
881
+ if ( ! $has_query_tags ) {
882
 
883
+ // Archives, Post type archives, singular posts.
884
+ if ( in_the_loop() ) {
885
+ $pod = pods( get_post_type(), get_the_ID(), false );
886
+
887
+ if ( ! empty( $pod ) ) {
888
+ $id = get_the_ID();
889
+ $tags['id'] = $id;
890
+ $tags['name'] = get_post_type();
891
+ }
892
+ } else {
893
+ $tags['use_current'] = true;
894
  }
895
  }
896
 
1091
  echo $pod->pagination( $tags['pagination_label'] );
1092
  }
1093
 
1094
+ $content = $pod->template( $tags['template'], $content );
1095
+ $content = trim( $content );
1096
+
1097
+ if ( empty( $content ) && ! empty( $tags['not_found'] ) ) {
1098
+ $content = $pod->do_magic_tags( $tags['not_found'] );
1099
+ }
1100
+
1101
+ // phpcs:ignore
1102
+ echo $content;
1103
 
1104
  if ( ! $is_singular && 0 < $found && true === $tags['pagination'] && in_array(
1105
  $tags['pagination_location'], array(
1552
  }
1553
 
1554
  /**
1555
+ * Get a field value from a Pod.
1556
  *
1557
+ * @param string|null $pod The pod name.
1558
+ * @param mixed|null $id The ID or slug of the item.
1559
+ * @param string|array $name The field name, or an associative array of parameters.
1560
+ * @param boolean $single For tableless fields, to return the whole array or the just the first item.
 
1561
  *
1562
+ * @return mixed Field value.
1563
  *
1564
  * @since 2.1.0
1565
  */
1566
+ function pods_field( $pod, $id = null, $name = null, $single = false ) {
1567
 
1568
  // allow for pods_field( 'field_name' );
1569
  if ( null === $name ) {
1570
  $name = $pod;
1571
  $single = (boolean) $id;
1572
 
1573
+ $pod = null;
1574
+ $id = null;
1575
+ }
1576
+
1577
+ if ( null === $pod && null === $id ) {
1578
  $pod = get_post_type();
1579
  $id = get_the_ID();
1580
  }
1581
 
1582
+ $pod_object = pods( $pod, $id );
1583
 
1584
+ if ( is_object( $pod_object ) && $pod_object->exists() ) {
1585
+ return $pod_object->field( $name, $single );
1586
  }
1587
 
1588
  return null;
1589
  }
1590
 
1591
  /**
1592
+ * Get a field display value from a Pod.
1593
  *
1594
+ * @param string|null $pod The pod name.
1595
+ * @param mixed|null $id The ID or slug of the item.
1596
+ * @param string|array $name The field name, or an associative array of parameters.
1597
+ * @param boolean $single For tableless fields, to return the whole array or the just the first item.
 
1598
  *
1599
+ * @return mixed Field value.
1600
  *
1601
  * @since 2.1.0
1602
  */
1603
+ function pods_field_display( $pod, $id = null, $name = null, $single = false ) {
1604
 
1605
  // allow for pods_field_display( 'field_name' );
1606
  if ( null === $name ) {
1607
  $name = $pod;
1608
  $single = (boolean) $id;
1609
 
1610
+ $pod = null;
1611
+ $id = null;
1612
+ }
1613
+
1614
+ if ( null === $pod && null === $id ) {
1615
  $pod = get_post_type();
1616
  $id = get_the_ID();
1617
  }
1618
 
1619
+ $pod_object = pods( $pod, $id );
1620
 
1621
+ if ( is_object( $pod_object ) && $pod_object->exists() ) {
1622
+ return $pod_object->display( $name, $single );
1623
  }
1624
 
1625
  return null;
1626
  }
1627
 
1628
  /**
1629
+ * Get a field raw value from a Pod.
1630
  *
1631
+ * @param string|null $pod The pod name.
1632
+ * @param mixed|null $id The ID or slug of the item.
1633
+ * @param string|array $name The field name, or an associative array of parameters.
1634
+ * @param boolean $single For tableless fields, to return the whole array or the just the first item.
 
1635
  *
1636
+ * @return mixed Field value.
1637
  *
1638
  * @since 2.1.0
1639
  */
1640
+ function pods_field_raw( $pod, $id = null, $name = null, $single = false ) {
1641
 
1642
  // allow for pods_field_raw( 'field_name' );
1643
  if ( null === $name ) {
1644
  $name = $pod;
1645
  $single = (boolean) $id;
1646
 
1647
+ $pod = null;
1648
+ $id = null;
1649
+ }
1650
+
1651
+ if ( null === $pod && null === $id ) {
1652
  $pod = get_post_type();
1653
  $id = get_the_ID();
1654
  }
1655
 
1656
+ $pod_object = pods( $pod, $id );
1657
 
1658
+ if ( is_object( $pod_object ) && $pod_object->exists() ) {
1659
+ return $pod_object->raw( $name, $single );
1660
+ }
1661
+
1662
+ return null;
1663
+
1664
+ }
1665
+
1666
+ /**
1667
+ * Update a field value for a Pod.
1668
+ *
1669
+ * @param string|null $pod The pod name.
1670
+ * @param mixed|null $id The ID or slug of the item.
1671
+ * @param string|array $name The field name, or an associative array of parameters.
1672
+ * @param boolean $value Value to save.
1673
+ *
1674
+ * @return int|false The item ID or false if not saved.
1675
+ *
1676
+ * @since 2.7.17
1677
+ */
1678
+ function pods_field_update( $pod, $id = null, $name = null, $value = null ) {
1679
+
1680
+ // allow for pods_field( 'field_name' );
1681
+ if ( null === $name ) {
1682
+ $name = $pod;
1683
+ $value = $id;
1684
+
1685
+ $pod = null;
1686
+ $id = null;
1687
+ }
1688
+
1689
+ if ( null === $pod && null === $id ) {
1690
+ $pod = get_post_type();
1691
+ $id = get_the_ID();
1692
+ }
1693
+
1694
+ $pod_object = pods( $pod, $id );
1695
+
1696
+ if ( is_object( $pod_object ) && $pod_object->exists() ) {
1697
+ return $pod_object->save( $name, $value );
1698
+ }
1699
+
1700
+ return false;
1701
  }
1702
 
1703
  /**
init.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Pods - Custom Content Types and Fields
4
  Plugin URI: https://pods.io/
5
  Description: Pods is a framework for creating, managing, and deploying customized content types and fields
6
- Version: 2.7.16.2
7
  Author: Pods Framework Team
8
  Author URI: https://pods.io/about/
9
  Text Domain: pods
@@ -36,7 +36,7 @@ if ( defined( 'PODS_VERSION' ) || defined( 'PODS_DIR' ) ) {
36
  add_action( 'init', 'pods_deactivate_pods_ui' );
37
  } else {
38
  // Current version
39
- define( 'PODS_VERSION', '2.7.16.2' );
40
 
41
  // Version tracking between DB updates themselves
42
  define( 'PODS_DB_VERSION', '2.3.5' );
3
  Plugin Name: Pods - Custom Content Types and Fields
4
  Plugin URI: https://pods.io/
5
  Description: Pods is a framework for creating, managing, and deploying customized content types and fields
6
+ Version: 2.7.17
7
  Author: Pods Framework Team
8
  Author URI: https://pods.io/about/
9
  Text Domain: pods
36
  add_action( 'init', 'pods_deactivate_pods_ui' );
37
  } else {
38
  // Current version
39
+ define( 'PODS_VERSION', '2.7.17' );
40
 
41
  // Version tracking between DB updates themselves
42
  define( 'PODS_DB_VERSION', '2.3.5' );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: pods, custom post types, custom taxonomies, content types, custom fields,
5
  Requires at least: 4.5
6
  Tested up to: 5.4
7
  Requires PHP: 5.3
8
- Stable tag: 2.7.16.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -190,6 +190,39 @@ We are also available through our [Live Slack Chat](https://pods.io/chat/) to he
190
 
191
  == Changelog ==
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  = 2.7.16.2 - November 14th 2019 =
194
 
195
  * Fixed: The last SVN tag was temporarily missing files, this release just ensures people get the update that has all files.
5
  Requires at least: 4.5
6
  Tested up to: 5.4
7
  Requires PHP: 5.3
8
+ Stable tag: 2.7.17
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
190
 
191
  == Changelog ==
192
 
193
+ = 2.7.17 - March 26th 2020 =
194
+
195
+ **New Features & Enhancements**
196
+ * Added: New callout for our Friends of Pods program will show up on the Pods Admin > Pods list so we can let people know how to donate. #5571 (@nicdford, @sc0ttkclark, @JoryHogeveen)
197
+ * Added: Freemius integration to support our new Friends of Pods add-ons and enable us to let people opt-in to usage stats for planning future compatibility decisions. #5624 (@sc0ttkclark)
198
+ * Added: New `not_found` tag to the Pods shortcode to return default string if no output is empty. #5580 (@JoryHogeveen)
199
+ * Added: New hooks when saving field table definitions (table-based Pods). #5623 (@sc0ttkclark)
200
+ * Added: New custom multi-relationship display format. #5612 (@JoryHogeveen)
201
+ * Added: Support traversing into post thumbnails objects. #5610 (@JoryHogeveen)
202
+ * Compatibility: Add ACF backwards compatibility functions/shortcode. #4855 (@sc0ttkclark)
203
+ * Compatibility: WordPress 5.4 - Add user Pod fields to privacy export data. #5606 (@JoryHogeveen)
204
+ * Compatibility: Match WordPress 5.4 CSS changes. #5608 (@JoryHogeveen)
205
+ * Enhancement: Shortcodes now automatically revert to the current queried object. #5598 (@JoryHogeveen)
206
+ * Enhancement: Add "full" to available image sizes. #5185 (@JoryHogeveen)
207
+ * Enhancement: Set Pods current queried object detection based on class instances instead of class parameters. #5617 (@JoryHogeveen)
208
+ * Docs: Update inline docs for pick field selected logic. #5014 & #5017 (@sc0ttkclark)
209
+
210
+ **Bug Fixes**
211
+ * Fixed: Date/Time - Correct empty value validation. #5534 & #5544 (@JoryHogeveen)
212
+ * Fixed: Date/Time - Allow midnight (00:00:00) as time value. #5616 (@JoryHogeveen)
213
+ * Fixed: Number/Currency - Parsing error for number format 9'999.99. #5559 & #5597 (@JoryHogeveen)
214
+ * Fixed: Number/Currency - Do not set default value of `0` if field is empty. #5539 (@JoryHogeveen)
215
+ * Fixed: CLI export/export-item commands. #5041 (@0xLBF)
216
+ * Fixed: Allow No (0) as an answer for radio and select boolean fields. #5549 (@JoryHogeveen)
217
+ * Fixed: Prevent get_meta() cache loop. #5577 (@JoryHogeveen)
218
+ * Fixed: Pods component descriptions. #5543 (@JoryHogeveen)
219
+ * Fixed: PHP 7.4 - Array and string offset access syntax with curly braces is deprecated. #5582 (@JoryHogeveen)
220
+ * Fixed: PHP 7.4 - Trying to access array offset on value of type bool. #5556 & #5615 (@JoryHogeveen)
221
+ * Fixed: PHP 7.4 - Array access notices. #5631 (@JoryHogeveen)
222
+ * Fixed: Replaced hook used for meta boxes in admin for custom component integrations to avoid deprecated notices from WordPress. #5622 (@sc0ttkclark)
223
+ * Fixed: Prevented potential fatal errors on Pod Template editor screen when pod configuration is broken. #5622 (@sc0ttkclark)
224
+ * Docs: Link to Gallery Documentation in Image field inline help doc. #5541 (@wpacademy)
225
+
226
  = 2.7.16.2 - November 14th 2019 =
227
 
228
  * Fixed: The last SVN tag was temporarily missing files, this release just ensures people get the update that has all files.
ui/admin/form.php CHANGED
@@ -179,7 +179,7 @@ if ( 0 < $pod->id() ) {
179
  */
180
  do_action( 'pods_meta_box_pre', $pod, $obj );
181
  ?>
182
- <div id="poststuff" class="metabox-holder has-right-sidebar"> <!-- class "has-right-sidebar" preps for a sidebar... always present? -->
183
  <div id="side-info-column" class="inner-sidebar">
184
  <?php
185
  /**
179
  */
180
  do_action( 'pods_meta_box_pre', $pod, $obj );
181
  ?>
182
+ <div id="poststuff" class="poststuff metabox-holder has-right-sidebar"> <!-- class "has-right-sidebar" preps for a sidebar... always present? -->
183
  <div id="side-info-column" class="inner-sidebar">
184
  <?php
185
  /**
ui/admin/help.php CHANGED
@@ -1,115 +1,125 @@
1
- <div class="wrap pods-admin">
2
- <div id="icon-pods" class="icon32"><br /></div>
3
- <h2><?php _e( 'Pods Help', 'pods' ); ?></h2>
4
- <img src="<?php echo esc_url( PODS_URL ); ?>ui/images/pods-logo-notext-rgb-transparent.png" class="pods-leaf-watermark-right" />
5
-
6
- <h3><?php _e( 'Pods Support' , 'pods'); ?></h3>
7
-
8
- <p><?php _e( 'There are many resources available to help you learn to use Pods on our site, <a href="https://pods.io/" target="_blank">Pods.io</a>:', 'pods'); ?></p>
9
- <ul class="ul-disc">
10
- <li><?php _e('To learn more about using Pods, see our <a href="https://pods.io/docs/" target="_blank">documentation</a> and subscribe to our <a href="https://www.youtube.com/user/podsframework/" target="_blank">YouTube Channel</a>', 'pods'); ?>.
11
-
12
- <li><?php _e( 'To get help with a specific issue, you can ask in our <a href="https://wordpress.org/support/plugin/pods" target="_blank">support forums</a>, or you can join <a href="https://pods.io/chat/" target="_blank">our Slack chat</a>', 'pods'); ?>.
13
-
14
- <li><?php _e('To report <strong>bugs or request features</strong>, go to our <a href="https://github.com/pods-framework/pods/issues?sort=updated&direction=desc&state=open" target="_blank">GitHub</a>.', 'pods' ); ?></li>
15
-
16
- <li><?php _e( "Pods is open source, so if you want to get into the code and submit your own fixes or features, go at it, we'd love to have you contribute on our project! With GitHub, it's really easy to contribute back, so why not give it a try?", 'pods'); ?></li>
17
- </ul>
18
-
19
- <hr />
20
-
21
- <?php
22
- include_once( ABSPATH . WPINC . '/feed.php' );
23
-
24
- $feed = fetch_feed( 'https://wordpress.org/support/plugin/pods/feed/' );
25
-
26
- if ( !is_wp_error( $feed ) ) {
27
- $max_items = $feed->get_item_quantity( 10 );
28
- $rss_items = $feed->get_items( 0, $max_items );
29
-
30
- if ( 0 < $max_items ) {
31
- ?>
32
- <h3><?php _e( 'Latest Forum Posts at <a href="https://wordpress.org/support/plugin/pods" target="_blank">wordpress.org</a>', 'pods'); ?></h3>
33
-
34
- <ul class="ul-disc">
35
- <?php
36
- foreach ( $rss_items as $item ) {
37
- $authors = $item->get_authors();
38
-
39
- $author_text = '';
40
-
41
- foreach ( $authors as $author ) {
42
- $author_text = '<br /> by ';
43
-
44
- if ( !empty( $author->link ) )
45
- $author_text .= '<a href="' . $author->link . '" target="_blank">';
46
-
47
- $author_text .= $author->name;
48
-
49
- if ( !empty( $author->link ) )
50
- $author_text .= '</a>';
51
- }
52
- ?>
53
- <li>
54
- <a href="<?php echo esc_url( $item->get_permalink() ); ?>"><?php echo html_entity_decode( esc_html( $item->get_title() ) ); ?></a>
55
- <?php echo $author_text; ?>
56
- <br />
57
- on <?php echo $item->get_date( 'm/d/Y' ); ?>
58
- </li>
59
- <?php
60
- }
61
- ?>
62
- </ul>
63
-
64
- <hr />
65
- <?php
66
- }
67
- }
68
-
69
- $feed = fetch_feed( 'https://github.com/pods-framework/pods/commits/2.x.atom' );
70
-
71
- if ( !is_wp_error( $feed ) ) {
72
- // Silence warnings due to a bug in SimplePie's date parser with PHP 7.1+
73
- // See: https://github.com/pods-framework/pods/issues/4363
74
- $max_items = @$feed->get_item_quantity( 10 );
75
- $rss_items = $feed->get_items( 0, $max_items );
76
-
77
- if ( 0 < $max_items ) {
78
- ?>
79
- <h3><?php _e( 'Latest Activity on <a href="http://github.com/pods-framework/pods" target="_blank">GitHub</a>', 'pods' ); ?></h3>
80
-
81
- <ul class="ul-disc">
82
- <?php
83
- foreach ( $rss_items as $item ) {
84
- $authors = $item->get_authors();
85
-
86
- $author_text = '';
87
-
88
- foreach ( $authors as $author ) {
89
- $author_text = '<br /> by ';
90
-
91
- if ( !empty( $author->link ) )
92
- $author_text .= '<a href="' . $author->link . '" target="_blank">';
93
-
94
- $author_text .= $author->name;
95
-
96
- if ( !empty( $author->link ) )
97
- $author_text .= '</a>';
98
- }
99
- ?>
100
- <li>
101
- <a href="<?php echo esc_url( $item->get_permalink() ); ?>">Commit</a>: <?php echo esc_html( $item->get_title() ); ?>
102
- <?php echo $author_text; ?>
103
- <br />
104
- on <?php echo $item->get_date( 'm/d/Y' ); ?>
105
- </li>
106
- <?php
107
- }
108
- ?>
109
- </ul>
110
- <?php
111
- }
112
- }
113
- ?>
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  </div>
1
+ <div class="wrap pods-admin pods-admin--flex">
2
+ <div class="pods-admin__content-container">
3
+ <div id="icon-pods" class="icon32"><br /></div>
4
+ <h2><?php _e( 'Pods Help', 'pods' ); ?></h2>
5
+ <img src="<?php echo esc_url( PODS_URL ); ?>ui/images/pods-logo-notext-rgb-transparent.png" class="pods-leaf-watermark-right" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ <h3><?php _e( 'Pods Support' , 'pods'); ?></h3>
8
+
9
+ <p><?php _e( 'There are many resources available to help you learn to use Pods on our site, <a href="https://pods.io/" target="_blank">Pods.io</a>:', 'pods'); ?></p>
10
+ <ul class="ul-disc">
11
+ <li><?php _e('To learn more about using Pods, see our <a href="https://pods.io/docs/" target="_blank">documentation</a> and subscribe to our <a href="https://www.youtube.com/user/podsframework/" target="_blank">YouTube Channel</a>', 'pods'); ?>.
12
+
13
+ <li><?php _e( 'To get help with a specific issue, you can ask in our <a href="https://wordpress.org/support/plugin/pods" target="_blank">support forums</a>, or you can join <a href="https://pods.io/chat/" target="_blank">our Slack chat</a>', 'pods'); ?>.
14
+
15
+ <li><?php _e('To report <strong>bugs or request features</strong>, go to our <a href="https://github.com/pods-framework/pods/issues?sort=updated&direction=desc&state=open" target="_blank">GitHub</a>.', 'pods' ); ?></li>
16
+
17
+ <li><?php _e( "Pods is open source, so if you want to get into the code and submit your own fixes or features, go at it, we'd love to have you contribute on our project! With GitHub, it's really easy to contribute back, so why not give it a try?", 'pods'); ?></li>
18
+ </ul>
19
+
20
+ <hr />
21
+
22
+ <?php
23
+ include_once( ABSPATH . WPINC . '/feed.php' );
24
+
25
+ $feed = fetch_feed( 'https://wordpress.org/support/plugin/pods/feed/' );
26
+
27
+ if ( !is_wp_error( $feed ) ) {
28
+ $max_items = $feed->get_item_quantity( 10 );
29
+ $rss_items = $feed->get_items( 0, $max_items );
30
+
31
+ if ( 0 < $max_items ) {
32
+ ?>
33
+ <h3><?php _e( 'Latest Forum Posts at <a href="https://wordpress.org/support/plugin/pods" target="_blank">wordpress.org</a>', 'pods'); ?></h3>
34
+
35
+ <ul class="ul-disc">
36
+ <?php
37
+ foreach ( $rss_items as $item ) {
38
+ $authors = $item->get_authors();
39
+
40
+ $author_text = '';
41
+
42
+ foreach ( $authors as $author ) {
43
+ $author_text = '<br /> by ';
44
+
45
+ if ( !empty( $author->link ) )
46
+ $author_text .= '<a href="' . $author->link . '" target="_blank">';
47
+
48
+ $author_text .= $author->name;
49
+
50
+ if ( !empty( $author->link ) )
51
+ $author_text .= '</a>';
52
+ }
53
+ ?>
54
+ <li>
55
+ <a href="<?php echo esc_url( $item->get_permalink() ); ?>"><?php echo html_entity_decode( esc_html( $item->get_title() ) ); ?></a>
56
+ <?php echo $author_text; ?>
57
+ <br />
58
+ on <?php echo $item->get_date( 'm/d/Y' ); ?>
59
+ </li>
60
+ <?php
61
+ }
62
+ ?>
63
+ </ul>
64
+
65
+ <hr />
66
+ <?php
67
+ }
68
+ }
69
+
70
+ $feed = fetch_feed( 'https://github.com/pods-framework/pods/commits/2.x.atom' );
71
+
72
+ if ( !is_wp_error( $feed ) ) {
73
+ // Silence warnings due to a bug in SimplePie's date parser with PHP 7.1+
74
+ // See: https://github.com/pods-framework/pods/issues/4363
75
+ $max_items = @$feed->get_item_quantity( 10 );
76
+ $rss_items = $feed->get_items( 0, $max_items );
77
+
78
+ if ( 0 < $max_items ) {
79
+ ?>
80
+ <h3><?php _e( 'Latest Activity on <a href="http://github.com/pods-framework/pods" target="_blank">GitHub</a>', 'pods' ); ?></h3>
81
+
82
+ <ul class="ul-disc">
83
+ <?php
84
+ foreach ( $rss_items as $item ) {
85
+ $authors = $item->get_authors();
86
+
87
+ $author_text = '';
88
+
89
+ foreach ( $authors as $author ) {
90
+ $author_text = '<br /> by ';
91
+
92
+ if ( !empty( $author->link ) )
93
+ $author_text .= '<a href="' . $author->link . '" target="_blank">';
94
+
95
+ $author_text .= $author->name;
96
+
97
+ if ( !empty( $author->link ) )
98
+ $author_text .= '</a>';
99
+ }
100
+ ?>
101
+ <li>
102
+ <a href="<?php echo esc_url( $item->get_permalink() ); ?>">Commit</a>: <?php echo esc_html( $item->get_title() ); ?>
103
+ <?php echo $author_text; ?>
104
+ <br />
105
+ on <?php echo $item->get_date( 'm/d/Y' ); ?>
106
+ </li>
107
+ <?php
108
+ }
109
+ ?>
110
+ </ul>
111
+ <?php
112
+ }
113
+ }
114
+ ?>
115
+ </div>
116
+
117
+ <?php
118
+ /**
119
+ * Allow additional output after the container area of the Pods help screen.
120
+ *
121
+ * @since 2.7.17
122
+ */
123
+ do_action( 'pods_admin_after_help' );
124
+ ?>
125
  </div>
ui/admin/settings.php CHANGED
@@ -1,47 +1,58 @@
1
- <div class="wrap pods-admin">
2
- <form action="" method="post">
 
3
 
4
- <div id="icon-pods" class="icon32"><br /></div>
5
 
6
- <?php
7
- $default = 'tools';
8
 
9
- $tabs = array(
10
- // 'settings' => __( 'Settings', 'pods' ),
11
- 'tools' => __( 'Tools', 'pods' ),
12
- 'reset' => __( 'Cleanup &amp; Reset', 'pods' ),
13
- );
14
- ?>
15
 
16
- <h2 class="nav-tab-wrapper">
17
- <?php
18
- foreach ( $tabs as $tab => $label ) {
19
- $class = '';
20
 
21
- if ( $tab == pods_v_sanitized( 'tab', 'get', $default ) ) {
22
- $class = ' nav-tab-active';
23
 
24
- $label = 'Pods ' . $label;
25
- }
26
 
27
- $url = pods_query_arg( array( 'tab' => $tab ), array( 'page' ) );
 
 
 
 
 
 
28
  ?>
29
- <a href="<?php echo esc_url( $url ); ?>" class="nav-tab<?php echo esc_attr( $class ); ?>">
30
- <?php echo $label; ?>
31
- </a>
32
- <?php
33
- }
34
- ?>
35
- </h2>
36
- <img src="<?php echo esc_url( PODS_URL ); ?>ui/images/pods-logo-notext-rgb-transparent.png" class="pods-leaf-watermark-right" />
37
 
38
- <?php
39
- wp_nonce_field( 'pods-settings' );
40
 
41
- $tab = pods_v_sanitized( 'tab', 'get', $default );
42
- $tab = sanitize_title( $tab );
43
 
44
- echo pods_view( PODS_DIR . 'ui/admin/settings-' . $tab . '.php' );
45
- ?>
46
- </form>
 
 
 
 
 
 
 
 
 
 
47
  </div>
1
+ <div class="wrap pods-admin pods-admin--flex">
2
+ <div class="pods-admin__content-container">
3
+ <form action="" method="post">
4
 
5
+ <div id="icon-pods" class="icon32"><br /></div>
6
 
7
+ <?php
8
+ $default = 'tools';
9
 
10
+ $tabs = array(
11
+ // 'settings' => __( 'Settings', 'pods' ),
12
+ 'tools' => __( 'Tools', 'pods' ),
13
+ 'reset' => __( 'Cleanup &amp; Reset', 'pods' ),
14
+ );
15
+ ?>
16
 
17
+ <h2 class="nav-tab-wrapper">
18
+ <?php
19
+ foreach ( $tabs as $tab => $label ) {
20
+ $class = '';
21
 
22
+ if ( $tab === pods_v_sanitized( 'tab', 'get', $default ) ) {
23
+ $class = ' nav-tab-active';
24
 
25
+ $label = 'Pods ' . $label;
26
+ }
27
 
28
+ $url = pods_query_arg( array( 'tab' => $tab ), array( 'page' ) );
29
+ ?>
30
+ <a href="<?php echo esc_url( $url ); ?>" class="nav-tab<?php echo esc_attr( $class ); ?>">
31
+ <?php echo $label; ?>
32
+ </a>
33
+ <?php
34
+ }
35
  ?>
36
+ </h2>
37
+ <img src="<?php echo esc_url( PODS_URL ); ?>ui/images/pods-logo-notext-rgb-transparent.png" class="pods-leaf-watermark-right" />
 
 
 
 
 
 
38
 
39
+ <?php
40
+ wp_nonce_field( 'pods-settings' );
41
 
42
+ $tab = pods_v_sanitized( 'tab', 'get', $default );
43
+ $tab = sanitize_title( $tab );
44
 
45
+ echo pods_view( PODS_DIR . 'ui/admin/settings-' . $tab . '.php' );
46
+ ?>
47
+ </form>
48
+ </div>
49
+
50
+ <?php
51
+ /**
52
+ * Allow additional output after the container area of the Pods settings screen.
53
+ *
54
+ * @since 2.7.17
55
+ */
56
+ do_action( 'pods_admin_after_settings' );
57
+ ?>
58
  </div>
ui/admin/setup-edit.php CHANGED
@@ -250,7 +250,7 @@ if ( isset( $_GET[ 'do' ] ) ) {
250
  }
251
  ?>
252
 
253
- <div id="poststuff">
254
  <img src="<?php echo esc_url( PODS_URL ); ?>ui/images/pods-logo-notext-rgb-transparent.png" class="pods-leaf-watermark-right" />
255
  <!-- /inner-sidebar -->
256
  <div id="post-body" class="meta-box-holder columns-2">
250
  }
251
  ?>
252
 
253
+ <div id="poststuff" class="poststuff">
254
  <img src="<?php echo esc_url( PODS_URL ); ?>ui/images/pods-logo-notext-rgb-transparent.png" class="pods-leaf-watermark-right" />
255
  <!-- /inner-sidebar -->
256
  <div id="post-body" class="meta-box-holder columns-2">
ui/admin/view.php CHANGED
@@ -8,7 +8,7 @@ wp_enqueue_style( 'pods-form' );
8
  ?>
9
 
10
  <div class="pods-submittable-fields">
11
- <div id="poststuff" class="metabox-holder has-right-sidebar"> <!-- class "has-right-sidebar" preps for a sidebar... always present? -->
12
  <div id="side-info-column" class="inner-sidebar">
13
  <div id="side-sortables" class="meta-box-sortables ui-sortable">
14
  <!-- BEGIN PUBLISH DIV -->
8
  ?>
9
 
10
  <div class="pods-submittable-fields">
11
+ <div id="poststuff" class="poststuff metabox-holder has-right-sidebar"> <!-- class "has-right-sidebar" preps for a sidebar... always present? -->
12
  <div id="side-info-column" class="inner-sidebar">
13
  <div id="side-sortables" class="meta-box-sortables ui-sortable">
14
  <!-- BEGIN PUBLISH DIV -->
ui/fields/datetime.php CHANGED
@@ -101,16 +101,9 @@ $date_default = PodsForm::field_method( $form_field_type, 'createFromFormat', $m
101
  $formatted_value = PodsForm::field_method( $form_field_type, 'format_value_display', $value, $options, true );
102
  $mysql_value = $value;
103
 
104
- $empty_values = array(
105
- '',
106
- '0000-00-00',
107
- '0000-00-00 00:00:00',
108
- '00:00:00',
109
- );
110
-
111
  if (
112
  pods_v( $form_field_type . '_allow_empty', $options, true )
113
- && in_array( $value, $empty_values, true )
114
  ) {
115
  $formatted_value = '';
116
  $value = '';
101
  $formatted_value = PodsForm::field_method( $form_field_type, 'format_value_display', $value, $options, true );
102
  $mysql_value = $value;
103
 
 
 
 
 
 
 
 
104
  if (
105
  pods_v( $form_field_type . '_allow_empty', $options, true )
106
+ && PodsForm::field_method( $form_field_type, 'is_empty', $value )
107
  ) {
108
  $formatted_value = '';
109
  $value = '';
ui/images/pods-logo-notext-rgb-transparent.png CHANGED
Binary file
ui/styles/dist/pods-form.css CHANGED
@@ -1,3 +1,3 @@
1
- @font-face{font-family:"pods";src:url("../../fonts/pods.eot");src:url("../../fonts/pods.eot?#iefix") format("embedded-opentype"),url("../../fonts/pods.woff") format("woff"),url("../../fonts/pods.ttf") format("truetype"),url("../../fonts/pods.svg#pods") format("svg");font-weight:normal;font-style:normal}[class^="pods-icon-"]:before,[class*=" pods-icon-"]:before{font-family:"pods" !important;font-style:normal !important;font-weight:normal !important;font-variant:normal !important;text-transform:none !important;speak:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.pods-icon-dashicon:before{content:"c"}#toplevel_page_pods .dashicons-before,#toplevel_page_pods .dashicons-before:before,.dashicons-pods:before{font-family:"pods" !important;font-size:20px;content:"c"}.pods-qtip-container{display:inline}#post-body{border:none;background:none}.pods-hidden{display:none}.pods-admin #navigation-actions .previous-item{display:block;text-align:left;float:left;width:50%}.pods-admin #navigation-actions .next-item{display:block;text-align:right;float:right;width:50%}.form-table tr.pods-field:last-child>th,.form-table tr.pods-field:last-child>td{border-bottom:none}.form-table td .pods-form-ui-field{max-width:95%}.form-table.pods-form-ui-table-type-avatar tr.form-field>td,.form-table.pods-form-ui-table-type-file tr.form-field>td{padding:0 10px}.pods-field{padding:10px 0}.pods-field label{cursor:pointer;display:block;padding:0 0 4px 2px}.pods-field input,.pods-field textarea{display:block}.pods-field .quicktags-toolbar input{display:inline-block;width:auto}.pods-field p.pods-field-comment{color:#aaa;font-size:.9em;font-style:italic;margin:5px 0 0 2px !important}div.pods-textfield input,.pods-textarea textarea{width:100%}.pods-field .wp-editor-container{background-color:#FFF}textarea.pods-form-ui-field-type-paragraph{font-family:monospace;min-height:100px;resize:vertical}.pods-link-options{background:#fff;padding:5px 10px 10px;border:1px solid #dfdfdf}.pods-link-options>div{display:inline-block}.pods-date input.pods-date-field.hasDatepicker{background:#fff url(../../images/calendar16.png) no-repeat 5px 5px;cursor:pointer;padding-left:25px !important;padding-top:6px !important;width:150px}input.pods-form-ui-field-type-color{width:80px}.pods-field .CodeMirror{border:1px solid #999;background-color:#fff;margin:0}.pods-currency-container{position:relative}.pods-currency-container code{position:absolute;transform:translate(0, -50%);top:50%;pointer-events:none;min-width:10px;text-align:center;padding:1px 5px;line-height:25px}.pods-currency-container input{padding-left:25px}.pods-boolean{position:relative;padding:0}.form-field .pods-boolean input,.pods-boolean input{display:block;min-height:16px;left:2px;margin-left:3px;padding:0;position:absolute;top:10px;width:auto;overflow:hidden}.pods-boolean label{padding:7px 5px 7px 26px;line-height:1;display:inline-block}.pods-pick select{display:block;min-width:125px}.pods-pick-values{border:1px solid #dfdfdf;border-radius:3px;min-width:125px;max-height:250px;overflow-y:auto;padding:2px 0}.pods-form-ui-field .pods-pick-values,.pods-form-ui-field .pods-pick-values li.pods-dfv-list-col{border:none;overflow:hidden;text-overflow:ellipsis}.pods-form-ui-row-type-pick .pods-form-ui-field select{width:25em}.pods-pick-values .pods-checkbox-view{border:1px solid #dfdfdf}select.pods-form-ui-field-type-pick[multiple]{background:#fff;border:1px solid #dfdfdf;border-radius:3px;width:100%;max-width:none;max-height:200px}select.pods-pick-multi{height:auto !important}.pods-pick-values ul{overflow:auto;margin:0;padding:0}.pods-pick-values li{background-color:#fff;border-bottom:1px solid #f4f4f4;line-height:1em;margin:0;padding:0}.pods-pick-values li:nth-child(even){background:#fcfcfc}.pods-pick-values .pods-dfv-list-item li{line-height:0}.pods-pick-values li li:nth-child(even),.pods-pick-values li li{background:transparent}.pods-pick-values li:hover{background:#f5f5f5}.pods-pick-values li:last-of-type{border-bottom:0}.pods-pick-values li .pods-field{padding:0}.pods-pick-values .pods-boolean label{display:block}.pods-pick-values .pods-radio{border:1px solid #dfdfdf}p.pods-add-file{padding:5px 0 10px}.pods-metabox tr.pods-field{border-top:1px solid #ececec}.pods-metabox tr.pods-field:first-child{border-top:0}.pods-form-ui-field .select2-container{width:100% !important}.pods-form-ui-field-type-select2{min-width:20%;width:auto;min-height:28px}.pods-ui-add-new{clear:both}#side-sortables .form-table .pods-field{display:block}#side-sortables .form-table th{display:block;width:100%;padding:0 0 10px;margin:0}#side-sortables .form-table tr.pods-field>td{display:block;line-height:inherit;padding:0;margin:0}.pods-form-front ul.pods-form-fields{list-style:none;margin:0}.pods-form-front .pods-field-label{width:20%;min-width:150px;padding-top:10px;float:left}.pods-form-front .pods-field-input{width:75%;min-width:200px;float:left}.pods-form-front .pods-field-input input,.pods-form .pods-field table.pods-metabox{width:95%}.pods-form .pods-field-input textarea{width:95%;min-height:200px}.pods-form-front .pods-field-input .quicktags-toolbar input{display:inline-block;width:auto}.pods-form-front .pods-field-input .pods-boolean input{width:auto}.pods-form-front .pods-field-input select{min-width:200px;border:1px solid #CCC;border-radius:3px;margin-top:10px}.pods-form-front .pods-field-input .CodeMirror{width:auto}.pods-form-front table.pods-metabox{width:100%}.pods-form-front ul.pods-dfv-list li.pods-dfv-list-icon img{width:40px}.pods-form-front .pods-file-add{display:block;margin:10px}.pods-form-front .pods-submit{float:right}.pods-form .pods-validate-error-message{color:#790000;font-weight:bold;padding:2px 0 5px;display:inline-block}.pods-form-front .pods-validate-error-message{padding:5px 10px 4px}.pods-form{overflow:hidden}.pods-form img.waiting{display:none;vertical-align:middle}.pods-form-front-success{color:#4F8A10;border:1px solid;margin:10px 0;padding:15px 10px 15px 50px;background:#DFF2BF url(../../images/green-check.png) no-repeat 10px center}.pods-form-ui-row-type-hidden{display:none;visibility:hidden}.pods-slider-field{max-width:300px}.pods-form div.pods-form-ui-field-type-avatar:after,.pods-form div.pods-form-ui-field-type-file:after,.pods-form div.pods-form-ui-field-type-pick:after,.pods-meta div.pods-form-ui-field-type-avatar:after,.pods-meta div.pods-form-ui-field-type-file:after,.pods-meta div.pods-form-ui-field-type-pick:after,.pods-form-front .pods-submittable-fields:after,.pods-form-front li.pods-field:after{content:"\00a0";clear:both;display:block;height:0}#wpbody .form-table td select.pods-form-ui-field-type-pick[multiple]{height:12em}.pods-related-add-new{margin-top:1em !important}@media screen and (max-width: 782px){.pods-boolean input,.form-field .pods-boolean input,.pods-pick-values li .pods-boolean input{height:25px;width:25px;top:4px;margin:0 3px}.pods-boolean label,.pods-pick-values .pods-boolean label{margin-left:36px;padding:10px 0}.form-table td .pods-form-ui-field{max-width:none}.form-table td input,.form-table td select{margin:0}.pods-metabox tr.pods-field>th{padding-top:15px}.pods-metabox tr.pods-field>td{padding-bottom:15px}.pods-form-ui-row-type-pick .pods-form-ui-field select{width:100%}}.pods-modal-frame.hide-menu .media-frame-title{left:0}.media-modal .media-modal-content .pods-modal-frame{height:100%}.media-modal .media-modal-content .pods-modal-frame .media-frame-iframe{height:100%;padding-top:50px;box-sizing:border-box}.media-modal .media-modal-content .pods-modal-frame .media-frame-iframe .media-iframe{height:100%;position:relative}.media-modal .media-modal-content .pods-modal-frame .media-frame-iframe .media-iframe iframe{position:absolute;height:100%;width:100%;border:none}ul.pods-dfv-list ul{list-style:none;margin:0;padding:0}ul.pods-dfv-list,.pods-dfv-field .pods-pick-values>ul{background:#fff;margin:0 0 5px 0;padding:0;border-radius:0;border:1px solid #dfdfdf;overflow:hidden;max-height:220px;overflow-y:auto}ul.pods-dfv-list:empty{display:none}ul.pods-dfv-list-meta{display:block;overflow:hidden;zoom:1;position:relative}ul.pods-dfv-list li.pods-dfv-list-col{float:left;margin:0;padding:0}ul.pods-dfv-list li.pods-dfv-list-icon{width:40px;margin:0 5px;height:32px;font-size:0;line-height:32px;text-align:center}ul.pods-dfv-list li.pods-dfv-list-icon img{display:inline-block;vertical-align:middle;float:none;border-radius:2px;margin:0;max-height:100%;width:auto}ul.pods-dfv-list li.pods-dfv-list-icon span.pinkynail{font-size:32px;width:32px;height:32px}ul.pods-dfv-list li.pods-dfv-list-handle{width:25px;height:32px;float:left;cursor:move}ul.pods-dfv-list li.pods-dfv-list-edit,ul.pods-dfv-list li.pods-dfv-list-link,ul.pods-dfv-list li.pods-dfv-list-download,ul.pods-dfv-list li.pods-dfv-list-remove{width:25px;height:32px;float:right}ul.pods-dfv-list li.pods-dfv-list-handle span,ul.pods-dfv-list li.pods-dfv-list-edit a,ul.pods-dfv-list li.pods-dfv-list-link a,ul.pods-dfv-list li.pods-dfv-list-download a,ul.pods-dfv-list li.pods-dfv-list-remove a{display:block;width:25px;height:32px;opacity:0.40;text-decoration:none;color:#616161}ul.pods-dfv-list li.pods-dfv-list-handle span:hover,ul.pods-dfv-list li.pods-dfv-list-edit a:hover,ul.pods-dfv-list li.pods-dfv-list-link a:hover,ul.pods-dfv-list li.pods-dfv-list-download a:hover,ul.pods-dfv-list li.pods-dfv-list-remove a:hover{opacity:1}ul.pods-dfv-list li.pods-dfv-list-handle span:focus,ul.pods-dfv-list li.pods-dfv-list-edit a:focus,ul.pods-dfv-list li.pods-dfv-list-link a:focus,ul.pods-dfv-list li.pods-dfv-list-download a:focus,ul.pods-dfv-list li.pods-dfv-list-remove a:focus{-webkit-box-shadow:none;box-shadow:none}ul.pods-dfv-list li.pods-dfv-list-handle span:before,ul.pods-dfv-list li.pods-dfv-list-edit a:before,ul.pods-dfv-list li.pods-dfv-list-link a:before,ul.pods-dfv-list li.pods-dfv-list-download a:before,ul.pods-dfv-list li.pods-dfv-list-remove a:before{margin:0 24px 0 -24px;font:400 20px/1 dashicons;line-height:32px}ul.pods-dfv-list li.pods-dfv-list-handle span:before{content:"\f156"}ul.pods-dfv-list li.pods-dfv-list-edit a:before{content:"\f464"}ul.pods-dfv-list li.pods-dfv-list-link a:before{content:"\f504"}ul.pods-dfv-list li.pods-dfv-list-download a:before{content:"\f316"}ul.pods-dfv-list li.pods-dfv-list-remove a:before{content:"\f158"}ul.pods-dfv-list li.pods-dfv-list-handle span,ul.pods-dfv-list li.pods-dfv-list-edit a,ul.pods-dfv-list li.pods-dfv-list-link a,ul.pods-dfv-list li.pods-dfv-list-download a,ul.pods-dfv-list li.pods-dfv-list-remove a{text-indent:100%;white-space:nowrap;overflow:hidden;box-shadow:none}ul.pods-dfv-list li.pods-dfv-list-name{position:absolute;left:80px;right:105px;padding:3px 0;line-height:24px;overflow:visible;white-space:nowrap}ul.pods-dfv-list li.pods-dfv-list-name input[type=text]{width:100% !important;font-size:1em;line-height:1;padding:.3vh 5px;margin:0}li.pods-dfv-list-item,.pods-pick-values li.pods-dfv-list-item{display:block;padding:6px 5px 6px 10px;margin:0;border-bottom:1px solid #efefef}li.pods-dfv-list-item:hover{background:#f5f5f5}li.pods-dfv-list-item:last-of-type{border-bottom:0}ul.pods-dfv-list-queue{margin:14px 0 5px}ul.pods-dfv-list-queue li.pods-dfv-list-name{position:relative;width:73%;left:auto;right:auto;padding-top:0}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress,ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress div.progress-bar{border-radius:10px;height:18px}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress{position:relative;width:23%;margin:2px 2% 0 0;background-color:#e8e8e8}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress div.progress-bar{width:0;background-color:#1073AA}li.pods-dfv-list-item:after,ul.pods-dfv-list li.pods-dfv-list-item ul.pods-dfv-list-meta:after,ul.pods-dfv-list-queue li.pods-dfv-list-item:after,ul.pods-dfv-list-queue li.pods-dfv-list-item ul.pods-dfv-list-meta:after{content:"";display:table;clear:both}.pods-field-template-tiles ul.pods-dfv-list{max-height:500px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-item{display:inline-block;width:150px;border-bottom:0;padding:5px 10px 10px;vertical-align:top}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-icon{width:auto;float:none;margin:32px 0 0;max-height:150px;height:150px;line-height:150px;text-align:center}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle span:before{content:"\f545"}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-icon img{max-width:none;max-height:none;float:none;display:inline-block;vertical-align:middle;margin:0}form.pods-form .pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-name{position:static;float:none}form.pods-form .pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-name input[type=text]{margin:0;padding:.3vh 6px}.pods-dfv-field .select2-container .select2-selection--single{height:30px}.pods-dfv-field .select2-container--default .select2-selection--single .select2-selection__clear{height:28px;line-height:26px}.pods-dfv-field .select2-container--default .select2-selection--multiple .select2-selection__rendered li{background:none}.pods-dfv-field .select2-container--default .select2-selection--multiple .select2-selection__choice__remove{margin-right:5px;line-height:1;vertical-align:top}.pods-dfv-field .select2-container--default .select2-selection--multiple li.select2-selection__choice{padding:3px 5px;background-color:#f5f5f5;border-color:#dfdfdf;line-height:1.2;margin:5px 5px 5px 0}.pods-dfv-field .select2-container--default .select2-selection--multiple li.select2-selection__choice:hover{background-color:#fafafa;border-color:#bbb;cursor:move}.pods-dfv-field .pods-select2 .select2-container-multi .select2-choices .select2-search-field input{height:auto}.pods-dfv-field .select2-container--default .select2-selection--multiple{border-color:#ddd;border-radius:1px}.pods-dfv-field .select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#5b9dd9;-webkit-box-shadow:0 0 2px rgba(30,140,190,0.8);box-shadow:0 0 2px rgba(30,140,190,0.8)}.pods-pick-values .select2-container li{padding:0;line-height:inherit}.select2-container .select2-selection--multiple .select2-search--inline{float:none}.select2-container .select2-selection--multiple .select2-search--inline:first-child .select2-search__field{width:100% !important}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-edit,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-link,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-download,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-remove{position:absolute;top:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle{left:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-edit{right:75px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-link{right:50px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-download{right:25px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-remove{right:0}ul.pods-dfv-list li.pods-dfv-list-actions{position:absolute;top:0;right:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-edit,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-link,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-download,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-remove{position:static;float:right}a.pods-quick-add,span.pods-quick-add{display:block;line-height:36px;float:right;margin-right:15px}div.open a.pods-quick-add,div.open span.pods-quick-add{display:none}.pods-ui-field .pods-dfv-list-add{margin-bottom:10px}
2
 
3
  /*# sourceMappingURL=../src/sourcemaps/pods-form.css.map */
1
+ @font-face{font-family:"pods";src:url("../../fonts/pods.eot");src:url("../../fonts/pods.eot?#iefix") format("embedded-opentype"),url("../../fonts/pods.woff") format("woff"),url("../../fonts/pods.ttf") format("truetype"),url("../../fonts/pods.svg#pods") format("svg");font-weight:normal;font-style:normal}[class^="pods-icon-"]:before,[class*=" pods-icon-"]:before{font-family:"pods" !important;font-style:normal !important;font-weight:normal !important;font-variant:normal !important;text-transform:none !important;speak:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.pods-icon-dashicon:before{content:"c"}#toplevel_page_pods .dashicons-before,#toplevel_page_pods .dashicons-before:before,.dashicons-pods:before{font-family:"pods" !important;font-size:20px;content:"c"}.pods-qtip-container{display:inline}#post-body{border:none;background:none}.pods-hidden{display:none}.pods-admin #navigation-actions .previous-item{display:block;text-align:left;float:left;width:50%}.pods-admin #navigation-actions .next-item{display:block;text-align:right;float:right;width:50%}.form-table tr.pods-field:last-child>th,.form-table tr.pods-field:last-child>td{border-bottom:none}.form-table td .pods-form-ui-field{max-width:95%}.form-table.pods-form-ui-table-type-avatar tr.form-field>td,.form-table.pods-form-ui-table-type-file tr.form-field>td{padding:0 10px}.pods-field{padding:10px 0}.pods-field label{cursor:pointer;display:block;padding:0 0 4px 2px}.pods-field input,.pods-field textarea{display:block}.pods-field .quicktags-toolbar input{display:inline-block;width:auto}.pods-field p.pods-field-comment{color:#aaa;font-size:.9em;font-style:italic;margin:5px 0 0 2px !important}div.pods-textfield input,.pods-textarea textarea{width:100%}.pods-field .wp-editor-container{background-color:#FFF}textarea.pods-form-ui-field-type-paragraph{font-family:monospace;min-height:100px;resize:vertical}.pods-link-options{background:#fff;padding:5px 10px 10px;border:1px solid #dfdfdf}.pods-link-options>div{display:inline-block}.pods-date input.pods-date-field.hasDatepicker{background:#fff url(../../images/calendar16.png) no-repeat 5px 5px;cursor:pointer;padding-left:25px !important;padding-top:6px !important;width:150px}input.pods-form-ui-field-type-color{width:80px}.pods-field .CodeMirror{border:1px solid #999;background-color:#fff;margin:0}.pods-currency-container{position:relative}.pods-currency-container code{position:absolute;transform:translate(0, -50%);top:50%;pointer-events:none;min-width:10px;text-align:center;padding:1px 5px;line-height:25px}.pods-currency-container input{padding-left:25px}.pods-boolean{position:relative;padding:0}.form-field .pods-boolean input,.pods-boolean input{display:block;min-height:16px;left:2px;margin-left:3px;padding:0;position:absolute;top:10px;overflow:hidden}.pods-boolean label{padding:7px 5px 7px 26px;line-height:1;display:inline-block}.pods-pick select{display:block;min-width:125px}.pods-pick-values{border:1px solid #dfdfdf;border-radius:3px;min-width:125px;max-height:250px;overflow-y:auto;padding:2px 0}.pods-form-ui-field .pods-pick-values,.pods-form-ui-field .pods-pick-values li.pods-dfv-list-col{border:none;overflow:hidden;text-overflow:ellipsis}.pods-form-ui-row-type-pick .pods-form-ui-field select{width:25em}.pods-pick-values .pods-checkbox-view{border:1px solid #dfdfdf}select.pods-form-ui-field-type-pick[multiple]{background:#fff;border:1px solid #dfdfdf;border-radius:3px;width:100%;max-width:none;max-height:200px}select.pods-pick-multi{height:auto !important}.pods-pick-values ul{overflow:auto;margin:0;padding:0}.pods-pick-values li{background-color:#fff;border-bottom:1px solid #f4f4f4;line-height:1em;margin:0;padding:0}.pods-pick-values li:nth-child(even){background:#fcfcfc}.pods-pick-values .pods-dfv-list-item li{line-height:0}.pods-pick-values li li:nth-child(even),.pods-pick-values li li{background:transparent}.pods-pick-values li:hover{background:#f5f5f5}.pods-pick-values li:last-of-type{border-bottom:0}.pods-pick-values li .pods-field{padding:0}.pods-pick-values .pods-boolean label{display:block}.pods-pick-values .pods-radio{border:1px solid #dfdfdf}p.pods-add-file{padding:5px 0 10px}.pods-metabox tr.pods-field{border-top:1px solid #ececec}.pods-metabox tr.pods-field:first-child{border-top:0}.pods-form-ui-field .select2-container{width:100% !important}.pods-form-ui-field-type-select2{min-width:20%;width:auto;min-height:28px}.pods-ui-add-new{clear:both}#side-sortables .form-table .pods-field{display:block}#side-sortables .form-table th{display:block;width:100%;padding:0 0 10px;margin:0}#side-sortables .form-table tr.pods-field>td{display:block;line-height:inherit;padding:0;margin:0}.pods-form-front ul.pods-form-fields{list-style:none;margin:0}.pods-form-front .pods-field-label{width:20%;min-width:150px;padding-top:10px;float:left}.pods-form-front .pods-field-input{width:75%;min-width:200px;float:left}.pods-form-front .pods-field-input input,.pods-form .pods-field table.pods-metabox{width:95%}.pods-form .pods-field-input textarea{width:95%;min-height:200px}.pods-form-front .pods-field-input .quicktags-toolbar input{display:inline-block;width:auto}.pods-form-front .pods-field-input .pods-boolean input{width:auto}.pods-form-front .pods-field-input select{min-width:200px;border:1px solid #CCC;border-radius:3px;margin-top:10px}.pods-form-front .pods-field-input .CodeMirror{width:auto}.pods-form-front table.pods-metabox{width:100%}.pods-form-front ul.pods-dfv-list li.pods-dfv-list-icon img{width:40px}.pods-form-front .pods-file-add{display:block;margin:10px}.pods-form-front .pods-submit{float:right}.pods-form .pods-validate-error-message{color:#790000;font-weight:bold;padding:2px 0 5px;display:inline-block}.pods-form-front .pods-validate-error-message{padding:5px 10px 4px}.pods-form{overflow:hidden}.pods-form img.waiting{display:none;vertical-align:middle}.pods-form-front-success{color:#4F8A10;border:1px solid;margin:10px 0;padding:15px 10px 15px 50px;background:#DFF2BF url(../../images/green-check.png) no-repeat 10px center}.pods-form-ui-row-type-hidden{display:none;visibility:hidden}.pods-slider-field{max-width:300px}.pods-form div.pods-form-ui-field-type-avatar:after,.pods-form div.pods-form-ui-field-type-file:after,.pods-form div.pods-form-ui-field-type-pick:after,.pods-meta div.pods-form-ui-field-type-avatar:after,.pods-meta div.pods-form-ui-field-type-file:after,.pods-meta div.pods-form-ui-field-type-pick:after,.pods-form-front .pods-submittable-fields:after,.pods-form-front li.pods-field:after{content:"\00a0";clear:both;display:block;height:0}#wpbody .form-table td select.pods-form-ui-field-type-pick[multiple]{height:12em}.pods-related-add-new{margin-top:1em !important}@media screen and (max-width: 782px){.pods-boolean input,.form-field .pods-boolean input,.pods-pick-values li .pods-boolean input{height:25px;width:25px;top:4px;margin:0 3px}.pods-boolean label,.pods-pick-values .pods-boolean label{margin-left:36px;padding:10px 0}.form-table td .pods-form-ui-field{max-width:none}.form-table td input,.form-table td select{margin:0}.pods-metabox tr.pods-field>th{padding-top:15px}.pods-metabox tr.pods-field>td{padding-bottom:15px}.pods-form-ui-row-type-pick .pods-form-ui-field select{width:100%}}.pods-modal-frame.hide-menu .media-frame-title{left:0}.media-modal .media-modal-content .pods-modal-frame{height:100%}.media-modal .media-modal-content .pods-modal-frame .media-frame-iframe{height:100%;padding-top:50px;box-sizing:border-box}.media-modal .media-modal-content .pods-modal-frame .media-frame-iframe .media-iframe{height:100%;position:relative}.media-modal .media-modal-content .pods-modal-frame .media-frame-iframe .media-iframe iframe{position:absolute;height:100%;width:100%;border:none}ul.pods-dfv-list ul{list-style:none;margin:0;padding:0}ul.pods-dfv-list,.pods-dfv-field .pods-pick-values>ul{background:#fff;margin:0 0 5px 0;padding:0;border-radius:0;border:1px solid #dfdfdf;overflow:hidden;max-height:220px;overflow-y:auto}ul.pods-dfv-list:empty{display:none}ul.pods-dfv-list-meta{display:block;overflow:hidden;zoom:1;position:relative}ul.pods-dfv-list li.pods-dfv-list-col{float:left;margin:0;padding:0}ul.pods-dfv-list li.pods-dfv-list-icon{width:40px;margin:0 5px;height:32px;font-size:0;line-height:32px;text-align:center}ul.pods-dfv-list li.pods-dfv-list-icon img{display:inline-block;vertical-align:middle;float:none;border-radius:2px;margin:0;max-height:100%;width:auto}ul.pods-dfv-list li.pods-dfv-list-icon span.pinkynail{font-size:32px;width:32px;height:32px}ul.pods-dfv-list li.pods-dfv-list-handle{width:25px;height:32px;float:left;cursor:move}ul.pods-dfv-list li.pods-dfv-list-edit,ul.pods-dfv-list li.pods-dfv-list-link,ul.pods-dfv-list li.pods-dfv-list-download,ul.pods-dfv-list li.pods-dfv-list-remove{width:25px;height:32px;float:right}ul.pods-dfv-list li.pods-dfv-list-handle span,ul.pods-dfv-list li.pods-dfv-list-edit a,ul.pods-dfv-list li.pods-dfv-list-link a,ul.pods-dfv-list li.pods-dfv-list-download a,ul.pods-dfv-list li.pods-dfv-list-remove a{display:block;width:25px;height:32px;opacity:0.40;text-decoration:none;color:#616161}ul.pods-dfv-list li.pods-dfv-list-handle span:hover,ul.pods-dfv-list li.pods-dfv-list-edit a:hover,ul.pods-dfv-list li.pods-dfv-list-link a:hover,ul.pods-dfv-list li.pods-dfv-list-download a:hover,ul.pods-dfv-list li.pods-dfv-list-remove a:hover{opacity:1}ul.pods-dfv-list li.pods-dfv-list-handle span:focus,ul.pods-dfv-list li.pods-dfv-list-edit a:focus,ul.pods-dfv-list li.pods-dfv-list-link a:focus,ul.pods-dfv-list li.pods-dfv-list-download a:focus,ul.pods-dfv-list li.pods-dfv-list-remove a:focus{-webkit-box-shadow:none;box-shadow:none}ul.pods-dfv-list li.pods-dfv-list-handle span:before,ul.pods-dfv-list li.pods-dfv-list-edit a:before,ul.pods-dfv-list li.pods-dfv-list-link a:before,ul.pods-dfv-list li.pods-dfv-list-download a:before,ul.pods-dfv-list li.pods-dfv-list-remove a:before{margin:0 24px 0 -24px;font:400 20px/1 dashicons;line-height:32px}ul.pods-dfv-list li.pods-dfv-list-handle span:before{content:"\f156"}ul.pods-dfv-list li.pods-dfv-list-edit a:before{content:"\f464"}ul.pods-dfv-list li.pods-dfv-list-link a:before{content:"\f504"}ul.pods-dfv-list li.pods-dfv-list-download a:before{content:"\f316"}ul.pods-dfv-list li.pods-dfv-list-remove a:before{content:"\f158"}ul.pods-dfv-list li.pods-dfv-list-handle span,ul.pods-dfv-list li.pods-dfv-list-edit a,ul.pods-dfv-list li.pods-dfv-list-link a,ul.pods-dfv-list li.pods-dfv-list-download a,ul.pods-dfv-list li.pods-dfv-list-remove a{text-indent:100%;white-space:nowrap;overflow:hidden;box-shadow:none}ul.pods-dfv-list li.pods-dfv-list-name{position:absolute;left:80px;right:105px;padding:3px 0;line-height:24px;overflow:visible;white-space:nowrap}ul.pods-dfv-list li.pods-dfv-list-name input[type=text]{width:100% !important;font-size:1em;line-height:1;padding:.3vh 5px;margin:0}li.pods-dfv-list-item,.pods-pick-values li.pods-dfv-list-item{display:block;padding:6px 5px 6px 10px;margin:0;border-bottom:1px solid #efefef}li.pods-dfv-list-item:hover{background:#f5f5f5}li.pods-dfv-list-item:last-of-type{border-bottom:0}ul.pods-dfv-list-queue{margin:14px 0 5px}ul.pods-dfv-list-queue li.pods-dfv-list-name{position:relative;width:73%;left:auto;right:auto;padding-top:0}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress,ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress div.progress-bar{border-radius:10px;height:18px}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress{position:relative;width:23%;margin:2px 2% 0 0;background-color:#e8e8e8}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress div.progress-bar{width:0;background-color:#1073AA}li.pods-dfv-list-item:after,ul.pods-dfv-list li.pods-dfv-list-item ul.pods-dfv-list-meta:after,ul.pods-dfv-list-queue li.pods-dfv-list-item:after,ul.pods-dfv-list-queue li.pods-dfv-list-item ul.pods-dfv-list-meta:after{content:"";display:table;clear:both}.pods-field-template-tiles ul.pods-dfv-list{max-height:500px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-item{display:inline-block;width:150px;border-bottom:0;padding:5px 10px 10px;vertical-align:top}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-icon{width:auto;float:none;margin:32px 0 0;max-height:150px;height:150px;line-height:150px;text-align:center}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle span:before{content:"\f545"}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-icon img{max-width:none;max-height:none;float:none;display:inline-block;vertical-align:middle;margin:0}form.pods-form .pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-name{position:static;float:none}form.pods-form .pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-name input[type=text]{margin:0;padding:.3vh 6px}.pods-dfv-field .select2-container .select2-selection--single{height:30px}.pods-dfv-field .select2-container--default .select2-selection--single .select2-selection__clear{height:28px;line-height:26px}.pods-dfv-field .select2-container--default .select2-selection--multiple .select2-selection__rendered li{background:none}.pods-dfv-field .select2-container--default .select2-selection--multiple .select2-selection__choice__remove{margin-right:5px;line-height:1;vertical-align:top}.pods-dfv-field .select2-container--default .select2-selection--multiple li.select2-selection__choice{padding:3px 5px;background-color:#f5f5f5;border-color:#dfdfdf;line-height:1.2;margin:5px 5px 5px 0}.pods-dfv-field .select2-container--default .select2-selection--multiple li.select2-selection__choice:hover{background-color:#fafafa;border-color:#bbb;cursor:move}.pods-dfv-field .pods-select2 .select2-container-multi .select2-choices .select2-search-field input{height:auto}.pods-dfv-field .select2-container--default .select2-selection--multiple{border-color:#ddd;border-radius:1px}.pods-dfv-field .select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#5b9dd9;-webkit-box-shadow:0 0 2px rgba(30,140,190,0.8);box-shadow:0 0 2px rgba(30,140,190,0.8)}.pods-pick-values .select2-container li{padding:0;line-height:inherit}.select2-container .select2-selection--multiple .select2-search--inline{float:none}.select2-container .select2-selection--multiple .select2-search--inline:first-child .select2-search__field{width:100% !important}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-edit,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-link,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-download,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-remove{position:absolute;top:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle{left:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-edit{right:75px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-link{right:50px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-download{right:25px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-remove{right:0}ul.pods-dfv-list li.pods-dfv-list-actions{position:absolute;top:0;right:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-edit,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-link,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-download,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-remove{position:static;float:right}a.pods-quick-add,span.pods-quick-add{display:block;line-height:36px;float:right;margin-right:15px}div.open a.pods-quick-add,div.open span.pods-quick-add{display:none}.pods-ui-field .pods-dfv-list-add{margin-bottom:10px}
2
 
3
  /*# sourceMappingURL=../src/sourcemaps/pods-form.css.map */
ui/styles/dist/pods.css CHANGED
@@ -1 +1,3 @@
1
- @font-face{font-family:"pods";src:url("../../fonts/pods.eot");src:url("../../fonts/pods.eot?#iefix") format("embedded-opentype"),url("../../fonts/pods.woff") format("woff"),url("../../fonts/pods.ttf") format("truetype"),url("../../fonts/pods.svg#pods") format("svg");font-weight:normal;font-style:normal}[class^="pods-icon-"]:before,[class*=" pods-icon-"]:before{font-family:"pods" !important;font-style:normal !important;font-weight:normal !important;font-variant:normal !important;text-transform:none !important;speak:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.pods-icon-dashicon:before{content:"c"}#toplevel_page_pods .dashicons-before,#toplevel_page_pods .dashicons-before:before,.dashicons-pods:before{font-family:"pods" !important;font-size:20px;content:"c"}.pods-hidden{display:none}.pods-admin .pods-leaf-watermark-right{position:fixed;width:236px;height:178px;bottom:50px;right:16px;z-index:-1}.pods-admin .pods_floatmenu{width:200px}.pods-admin .pods-icon{display:inline-block;padding:1px 0 0 5px;vertical-align:top}.icon32#icon-pods{background:url(../../images/icon32.png) no-repeat}.pods-admin .waiting{display:none;vertical-align:middle}.pods-admin button,.pods-admin a.button,.pods-admin a.button-secondary,.pods-admin a.button-primary{vertical-align:middle}.pods-admin .pods-validate.pods-validate-error{border-color:#C89797;color:#790000;background-color:#FFDFDF}.pods-admin .pods-validate-error-message{color:#790000;font-weight:bold;padding:5px 10px 4px;display:inline-block}.pods-admin .pods-advanced-toggle{font-size:12px;text-decoration:underline}.pods-admin .pods-advanced{display:none;width:100%}.pods-wizard p{font-size:14px}.pods-wizard #poststuff h1,.pods-wizard h2,.pods-wizard h3{margin-bottom:0 !important}.pods-admin #poststuff h3{font-size:14px;padding:8px 12px;margin:0;line-height:1.4}.pods-tabbed ul.pods-tabs:before{content:"";display:table}.pods-tabbed ul.pods-tabs:after{content:"";display:table;clear:both}.pods-tabbed ul.pods-tabs{zoom:1;margin-bottom:0}.pods-tabbed ul.pods-tabs li.pods-tab{float:left;margin:0}.pods-tabbed ul.pods-tabs li.pods-tab a{-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-moz-border-radius-topleft:5px;-moz-border-radius-topright:5px;-webkit-border-radius:5px 5px 0 0;background:#e9e9e9;border:1px solid #dfdfdf;border-radius:5px 5px 0 0;display:block;float:left;font-size:14px;margin-right:5px;padding:5px 10px;text-decoration:none}.pods-tabbed ul.pods-tabs li.pods-tab a.selected{background:#FFF;border-bottom:1px solid #FFF}.pods-tabbed .pods-tab-group h4{margin:5px 10px}.pods-tabbed .pods-tab-group .pods-tab{display:none;margin-bottom:15px;margin-top:-1px;width:99%;border:1px solid #dfdfdf;border-bottom:0}.pods-nav-tabbed .pods-nav-tab-group .pods-nav-tab{display:none}tbody.pods-manage-list div{overflow:hidden;zoom:1}tbody.pods-manage-list div.pods-manage-row-wrapper{max-width:500px;display:none;width:100%}tbody.pods-manage-list tr.pods-manage-row-expanded{background:#f1f1f1}tbody.pods-manage-list tr.pods-manage-row-expanded td.pods-manage-row-name,tbody.pods-manage-list tr.pods-manage-row-expanded td.pods-manage-row-type,tbody.pods-manage-list tr.pods-manage-row-expanded td.pods-manage-row-comment,tbody.pods-manage-list tr.pods-manage-row-expanded span.pods-manage-row-id,tbody.pods-manage-list tr.pods-manage-row-expanded div.row-actions,tbody.pods-manage-list tr.pods-manage-row-expanded th.pods-manage-sort img{display:none}tbody.pods-manage-list tr.pods-manage-row th.pods-manage-sort{cursor:move}tbody.pods-manage-list tr.pods-manage-row th.pods-manage-sort img{vertical-align:top;margin-top:7px;margin-left:-5px}tbody.pods-manage-list tr.pods-manage-row td>span.pods-manage-row-more{display:none;margin-left:5px;color:#999}tbody.pods-manage-list tr.pods-manage-row td:hover>span.pods-manage-row-more{display:inline}tbody.pods-manage-list tr div.pods-manage-row-wrapper .pods-manage-row-actions{margin-bottom:4px;overflow:visible}tbody.pods-manage-list tr div.pods-manage-row-wrapper .pods-manage-row-delete{float:left;text-align:left;width:40%}tbody.pods-manage-list tr div.pods-manage-row-wrapper .pods-manage-row-save{float:right;text-align:right}tbody.pods-manage-list tr.pods-field-new div.pods-manage-row-wrapper .pods-manage-row-delete a.submitdelete,tbody.pods-manage-list tr div.pods-manage-row-wrapper .pods-manage-row-save a.pods-button-add,tbody.pods-manage-list tr.pods-field-new div.pods-manage-row-wrapper .pods-manage-row-save a.pods-button-update{display:none}tbody.pods-manage-list tr.pods-field-new div.pods-manage-row-wrapper .pods-manage-row-save a.pods-button-add{display:inline-block}tbody.pods-manage-list .pods-manage-row th.check-field{border:5px solid transparent;border-right:0;padding:3px 5px;transition:border-color 300ms ease}tbody.pods-manage-list .pods-field-updated th.check-field{border-left-color:#95BF3B}tbody.pods-manage-list .pods-manage-row-expanded th.check-field,tbody.pods-manage-list .pods-field-new th.check-field{border-left-color:#E35036}.pods-toggled{clear:both;margin-top:30px}.pods-toggled.pods-toggled-only{margin-top:0}.pods-toggled h3{cursor:pointer}.pods-no-toggle h3{cursor:default}tr.pods-toggled-on{background-color:#FFF}tr.pods-toggled-off{background-color:#F4F4F4}.pods-depends-on,.pods-excludes-on,.pods-wildcard-on{display:none}.pods-tabbed div{overflow:hidden;zoom:1}.pods-tab.pods-basic-options{display:block}.pods-tab#pods-advanced-labels,.pods-tab#pods-advanced-settings-labels{display:block}div.pods-manage-field div{overflow:hidden;zoom:1}div.pods-manage-field .description{clear:both}div.pods-manage-field .pods-field-option,div.pods-manage-field .pods-field-option-group{background:#fcfcfc;border-bottom:1px solid #dfdfdf;padding:10px}div.pods-manage-field .pods-pick-values li,div.pods-manage-field .pods-field{position:relative}div.pods-manage-field .pods-pick-values li{margin:0}div.pods-manage-field .pods-field-option:nth-child(odd),div.pods-manage-field .pods-field-option-group:nth-child(odd){background:#fff}div.pods-manage-field .pods-field-option label,div.pods-manage-field .pods-field-option-group .pods-field-option-group-label{padding-top:4px;float:left;width:30%;max-width:150px;margin-right:2%}.pods-manage-field .pods-field.pods-boolean label,.pods-manage-field .pods-field-option .pods-pick-values label{float:none;width:auto;max-width:100%;display:block;margin-left:22px;padding:7px 0;line-height:14px;margin-right:0}.pods-manage-field .pods-field-option .pods-pick-values .pods-field.pods-boolean{float:none;margin-left:0;width:auto;max-width:100%}.pods-manage-field .pods-field-option input[type="text"],.pods-manage-field .pods-field-option select,.pods-manage-field .pods-field-option textarea,.pods-manage-field .pods-field-option .pods-field.pods-boolean,.pods-manage-field .pods-pick-values,.pods-manage-field .pods-field-option .pods-form-ui-field-type-file,.pods-manage-field .pods-slider-field{display:block;float:left;width:65%;max-width:25em}.pods-manage-field label+div .pods-pick-values{width:96%}.pods-manage-field .pods-field-option .pods-form-ui-field-type-wysiwyg textarea{max-width:100%}.pods-manage-field .pods-field-option div select{float:none;width:100%;margin:0;max-width:100%}.pods-manage-field .pods-field-option .pods-form-ui-field-type-file{padding-bottom:8px}.pods-manage-field .pods-field-option .pods-form-ui-field-type-file table.form-table tr.form-field td{padding:0;border-bottom:none}.pods-manage-field .pods-field-option .pods-form-ui-field-type-file table.form-table,.pods-manage-field .pods-field-option-group p.pods-field-option-group-label{margin-top:0}.pods-manage-field input[type="checkbox"],.pods-manage-field input[type="radio"]{display:inline-block;margin:6px 6px 6px 1px;float:left;vertical-align:middle;position:static}.pods-manage-field .pods-pick-values input[type="checkbox"],.pods-manage-field .pods-pick-values input[type="radio"]{margin:6px}.pods-manage-field .pods-pick-values ul{overflow:auto;margin:5px 0}.pods-manage-field .pods-pick-values ul .pods-field.pods-boolean,.pods-manage-field .pods-pick-values ul ul{margin:0}.pods-manage-field .pods-pick-values.pods-zebra{width:100%;max-width:100%}.pods-manage-field .pods-pick-values.pods-zebra li{margin-bottom:4px}.pods-manage-field .pods-pick-values.pods-zebra div.pods-boolean input{margin:4px}.pods-manage-field .pods-pick-values.pods-zebra div.pods-boolean label{margin-left:26px;padding:5px 0}.pods-manage-field .pods-pick-values li.pods-zebra-odd{display:block;width:50%;float:left;clear:both}.pods-manage-field .pods-pick-values li.pods-zebra-even{display:block;width:50%;float:left;clear:none}.pods-manage-field .pods-pick-values .regular-text{max-width:95%}.pods-manage-field li>.pods-field.pods-boolean:hover{background:#f5f5f5}.pods-manage-field input.pods-form-ui-no-label{position:relative}.pods-sluggable .pods-slug em{cursor:pointer}.pods-sluggable a.cancel{font-size:12px}.pods-sluggable .pods-slug-edit{display:none}.pods-admin ul.ul-disc span.resolved:before{content:"Resolved: ";background:green;color:white;padding:2px;border-radius:5px;margin-right:5px}.pods-manage-field .pods-dfv-field .pods-ui-file-list.pods-field-template-rows,.pods-manage-field .pods-dfv-field .pods-ui-list-autocomplete{width:65%;max-width:25em}tbody.pods-manage-list tr.flexible-row{display:none}.pods-admin .pods-float-right{float:right}.pods-admin p.pods-manage-row-add{text-align:right}div.row-actions.row-actions-toggle{display:block;visibility:visible}table.pods-admin{table-layout:fixed}#pods-rest-api label[for="pods-form-ui-no-dependencies"]{width:100%;max-width:initial}body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option input[type="text"],body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option select,body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option textarea,body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option .pods-field.pods-boolean,body[class*="settings_page_pods-"] .pods-manage-field .pods-pick-values,body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option .pods-form-ui-field-type-file,body[class*="settings_page_pods-"] .pods-manage-field .pods-slider-field{float:none}@media only screen and (max-width: 850px){.pods-admin .pods_floatmenu{position:static !important;float:none;display:block;width:100%}.pods-admin .pods_floatmenu .inner-sidebar{float:none;width:auto}}@media screen and (max-width: 782px){.wp-list-table td.column-secondary{display:block !important;margin-top:-10px;margin-bottom:5px}.wp-list-table .is-expanded td.column-secondary{margin-top:0;margin-bottom:0}div.pods-manage-field .pods-field-option label,div.pods-manage-field .pods-field-option-group .pods-field-option-group-label{float:none;display:block;width:100%;max-width:none;padding-bottom:4px;margin-bottom:0;line-height:22px}.pods-manage-field .pods-field-option input[type="text"],.pods-manage-field .pods-field-option select,.pods-manage-field .pods-field-option textarea,.pods-manage-field .pods-field-option .pods-field.pods-boolean,.pods-manage-field .pods-pick-values,.pods-manage-field .pods-field-option .pods-form-ui-field-type-file,.pods-manage-field .pods-slider-field{display:block;margin:0;width:100%;max-width:none}.pods-manage-field .pods-field.pods-boolean label,.pods-manage-field .pods-field-option .pods-pick-values label{line-height:22px;font-size:14px;margin-left:34px}.pods-manage-field .pods-pick-values li.pods-zebra-odd,.pods-manage-field .pods-pick-values li.pods-zebra-even{display:block;width:100%;float:none;clear:both}}.dialogWithDropShadow{-webkit-box-shadow:0 0 10px rgba(0,0,0,0.5);-moz-box-shadow:0 0 10px rgba(0,0,0,0.5);box-shadow:0 0 10px rgba(0,0,0,0.5)}#pods-parts-right{width:250px;margin-right:10px}.pods-parts-icon{display:inline-block;padding:10px 0 10px 25px;text-decoration:none}.pods-parts-icon-edit{background:url(../../images/page_white_edit.png) left center no-repeat}.pods-parts-icon-add{background:url(../../images/bullet_add.png) left center no-repeat}#pods-parts-left{margin-right:-260px;width:100%}#pods-parts-content-editors{margin-right:280px}.editor-wide{width:100%;height:369px;background:#f6f6f6;color:#666}.editor-wide:focus{background:#f9f9f9;color:#333}#pods-parts-popup label{width:70px;display:block;float:left;text-align:right;margin-right:10px;clear:left;margin-top:3px;font-size:12px;font-family:Georgia;font-style:italic;color:#6c6c6c;letter-spacing:.2px}#pods-parts-popup input[type=text],#pods-parts-popup select{width:188px;margin-bottom:10px;font-size:12px;padding:2px}#pods-parts-popup input[type=text]{padding:5px}#pods-parts-popup .button-primary{float:right;text-align:center}#pods-parts-popup p{color:#858585}#pods-parts-popup .blue{display:block}#pods-parts-popup .blue a{color:#21759B;text-decoration:none;font-weight:bold}#pods-parts-popup .gray{color:#9c9c9c;font-size:11px}#pods-parts-popup table{padding:0;margin:0}#pods-parts-popup table td .bluehighlight{padding:4px 6px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;margin:5px 0}#pods-parts-popup table td .bluehighlight .actions{display:none;font-size:11px}#pods-parts-popup table td .bluehighlight .actions a{color:#21759B;text-decoration:none}#pods-parts-popup table td .bluehighlight .actions a.deletepodspart{color:#ff0000}#pods-parts-popup table td .bluehighlight .actions a:hover{text-decoration:underline}#pods-parts-popup table td .bluehighlight:hover{background:#f6f6f6}#pods-parts-popup table td .bluehighlight:hover .actions{display:inline;float:right;text-align:right}#ui-dialog-title-pods-parts-popup{font-family:Georgia !important;font-weight:normal}.button-secondary{text-align:center}.lightgraybackground{background:#f6f6f6;padding:2px 7px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}#pods-parts-search{width:390px;float:left}#pods-parts-search label,#pods-parts-filter label,#pods-parts-display-per-page label{width:auto;margin-top:6px;font-family:Georgia;color:#6c6c6c;font-style:italic;letter-spacing:.5px}#pods-parts-display-per-page select{width:50px}#pods-parts-search .button-secondary{width:120px;margin-left:5px}#pods-parts-filter{width:320px;float:right;text-align:right}#pods-parts-filter select{width:115px}#pods-parts-filter .button-secondary{width:60px;margin-left:5px}.pods-parts-pagination .current-page{width:40px !important;margin:0 2px}.pods-parts-pagination a{margin:0 2px}ul.pods-dfv-list ul{list-style:none;margin:0;padding:0}ul.pods-dfv-list,.pods-dfv-field .pods-pick-values>ul{background:#fff;margin:0 0 5px 0;padding:0;border-radius:0;border:1px solid #dfdfdf;overflow:hidden;max-height:220px;overflow-y:auto}ul.pods-dfv-list:empty{display:none}ul.pods-dfv-list-meta{display:block;overflow:hidden;zoom:1;position:relative}ul.pods-dfv-list li.pods-dfv-list-col{float:left;margin:0;padding:0}ul.pods-dfv-list li.pods-dfv-list-icon{width:40px;margin:0 5px;height:32px;font-size:0;line-height:32px;text-align:center}ul.pods-dfv-list li.pods-dfv-list-icon img{display:inline-block;vertical-align:middle;float:none;border-radius:2px;margin:0;max-height:100%;width:auto}ul.pods-dfv-list li.pods-dfv-list-icon span.pinkynail{font-size:32px;width:32px;height:32px}ul.pods-dfv-list li.pods-dfv-list-handle{width:25px;height:32px;float:left;cursor:move}ul.pods-dfv-list li.pods-dfv-list-edit,ul.pods-dfv-list li.pods-dfv-list-link,ul.pods-dfv-list li.pods-dfv-list-download,ul.pods-dfv-list li.pods-dfv-list-remove{width:25px;height:32px;float:right}ul.pods-dfv-list li.pods-dfv-list-handle span,ul.pods-dfv-list li.pods-dfv-list-edit a,ul.pods-dfv-list li.pods-dfv-list-link a,ul.pods-dfv-list li.pods-dfv-list-download a,ul.pods-dfv-list li.pods-dfv-list-remove a{display:block;width:25px;height:32px;opacity:0.40;text-decoration:none;color:#616161}ul.pods-dfv-list li.pods-dfv-list-handle span:hover,ul.pods-dfv-list li.pods-dfv-list-edit a:hover,ul.pods-dfv-list li.pods-dfv-list-link a:hover,ul.pods-dfv-list li.pods-dfv-list-download a:hover,ul.pods-dfv-list li.pods-dfv-list-remove a:hover{opacity:1}ul.pods-dfv-list li.pods-dfv-list-handle span:focus,ul.pods-dfv-list li.pods-dfv-list-edit a:focus,ul.pods-dfv-list li.pods-dfv-list-link a:focus,ul.pods-dfv-list li.pods-dfv-list-download a:focus,ul.pods-dfv-list li.pods-dfv-list-remove a:focus{-webkit-box-shadow:none;box-shadow:none}ul.pods-dfv-list li.pods-dfv-list-handle span:before,ul.pods-dfv-list li.pods-dfv-list-edit a:before,ul.pods-dfv-list li.pods-dfv-list-link a:before,ul.pods-dfv-list li.pods-dfv-list-download a:before,ul.pods-dfv-list li.pods-dfv-list-remove a:before{margin:0 24px 0 -24px;font:400 20px/1 dashicons;line-height:32px}ul.pods-dfv-list li.pods-dfv-list-handle span:before{content:"\f156"}ul.pods-dfv-list li.pods-dfv-list-edit a:before{content:"\f464"}ul.pods-dfv-list li.pods-dfv-list-link a:before{content:"\f504"}ul.pods-dfv-list li.pods-dfv-list-download a:before{content:"\f316"}ul.pods-dfv-list li.pods-dfv-list-remove a:before{content:"\f158"}ul.pods-dfv-list li.pods-dfv-list-handle span,ul.pods-dfv-list li.pods-dfv-list-edit a,ul.pods-dfv-list li.pods-dfv-list-link a,ul.pods-dfv-list li.pods-dfv-list-download a,ul.pods-dfv-list li.pods-dfv-list-remove a{text-indent:100%;white-space:nowrap;overflow:hidden;box-shadow:none}ul.pods-dfv-list li.pods-dfv-list-name{position:absolute;left:80px;right:105px;padding:3px 0;line-height:24px;overflow:visible;white-space:nowrap}ul.pods-dfv-list li.pods-dfv-list-name input[type=text]{width:100% !important;font-size:1em;line-height:1;padding:.3vh 5px;margin:0}li.pods-dfv-list-item,.pods-pick-values li.pods-dfv-list-item{display:block;padding:6px 5px 6px 10px;margin:0;border-bottom:1px solid #efefef}li.pods-dfv-list-item:hover{background:#f5f5f5}li.pods-dfv-list-item:last-of-type{border-bottom:0}ul.pods-dfv-list-queue{margin:14px 0 5px}ul.pods-dfv-list-queue li.pods-dfv-list-name{position:relative;width:73%;left:auto;right:auto;padding-top:0}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress,ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress div.progress-bar{border-radius:10px;height:18px}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress{position:relative;width:23%;margin:2px 2% 0 0;background-color:#e8e8e8}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress div.progress-bar{width:0;background-color:#1073AA}li.pods-dfv-list-item:after,ul.pods-dfv-list li.pods-dfv-list-item ul.pods-dfv-list-meta:after,ul.pods-dfv-list-queue li.pods-dfv-list-item:after,ul.pods-dfv-list-queue li.pods-dfv-list-item ul.pods-dfv-list-meta:after{content:"";display:table;clear:both}.pods-field-template-tiles ul.pods-dfv-list{max-height:500px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-item{display:inline-block;width:150px;border-bottom:0;padding:5px 10px 10px;vertical-align:top}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-icon{width:auto;float:none;margin:32px 0 0;max-height:150px;height:150px;line-height:150px;text-align:center}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle span:before{content:"\f545"}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-icon img{max-width:none;max-height:none;float:none;display:inline-block;vertical-align:middle;margin:0}form.pods-form .pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-name{position:static;float:none}form.pods-form .pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-name input[type=text]{margin:0;padding:.3vh 6px}.pods-dfv-field .select2-container .select2-selection--single{height:30px}.pods-dfv-field .select2-container--default .select2-selection--single .select2-selection__clear{height:28px;line-height:26px}.pods-dfv-field .select2-container--default .select2-selection--multiple .select2-selection__rendered li{background:none}.pods-dfv-field .select2-container--default .select2-selection--multiple .select2-selection__choice__remove{margin-right:5px;line-height:1;vertical-align:top}.pods-dfv-field .select2-container--default .select2-selection--multiple li.select2-selection__choice{padding:3px 5px;background-color:#f5f5f5;border-color:#dfdfdf;line-height:1.2;margin:5px 5px 5px 0}.pods-dfv-field .select2-container--default .select2-selection--multiple li.select2-selection__choice:hover{background-color:#fafafa;border-color:#bbb;cursor:move}.pods-dfv-field .pods-select2 .select2-container-multi .select2-choices .select2-search-field input{height:auto}.pods-dfv-field .select2-container--default .select2-selection--multiple{border-color:#ddd;border-radius:1px}.pods-dfv-field .select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#5b9dd9;-webkit-box-shadow:0 0 2px rgba(30,140,190,0.8);box-shadow:0 0 2px rgba(30,140,190,0.8)}.pods-pick-values .select2-container li{padding:0;line-height:inherit}.select2-container .select2-selection--multiple .select2-search--inline{float:none}.select2-container .select2-selection--multiple .select2-search--inline:first-child .select2-search__field{width:100% !important}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-edit,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-link,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-download,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-remove{position:absolute;top:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle{left:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-edit{right:75px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-link{right:50px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-download{right:25px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-remove{right:0}ul.pods-dfv-list li.pods-dfv-list-actions{position:absolute;top:0;right:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-edit,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-link,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-download,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-remove{position:static;float:right}a.pods-quick-add,span.pods-quick-add{display:block;line-height:36px;float:right;margin-right:15px}div.open a.pods-quick-add,div.open span.pods-quick-add{display:none}.pods-ui-field .pods-dfv-list-add{margin-bottom:10px}form.pods-manage ol.form-fields{list-style:none;padding-left:0;margin:0}form.pods-manage .chzn-container{display:block}form.pods-manage .pods-field label{cursor:pointer;display:inline-block;padding:0 0 4px 2px}form.pods-manage .pods-field input,form.pods-manage .pods-field textarea{display:block;width:100%}form.pods-manage .pods-field textarea{font-family:monospace;height:100%;resize:none}form.pods-manage .pods-field p.pods-field-comment{color:#aaa;font-size:.9em;font-style:italic;margin:5px 0 0 2px !important}form.pods-manage .pods-pick select{display:block;min-width:125px;padding:4px}form.pods-manage .pods-boolean{position:relative;cursor:pointer}form.pods-manage .pods-boolean input{display:block;height:auto;left:2px;margin:1px 7px 0 0;padding:0;position:absolute;top:10px;width:auto}form.pods-manage .pods-boolean label{margin-left:20px}form.pods-manage .pods-dfv-list-item label{padding-bottom:8px}form.pods-manage .pods-dfv-list-item input{display:none}form.pods-manage ul.pods-dfv-list{background:#fbfbfb;border:1px solid #dfdfdf;border-bottom:0;border-radius:3px;list-style:none;margin:0;padding:0}form.pods-manage ul.pods-dfv-list li{background:#fff;border-bottom:1px solid #dfdfdf;margin:0;position:relative;padding-bottom:10px}form.pods-manage ul.pods-dfv-list li span{display:inline-block;float:none}form.pods-manage ul.pods-dfv-list li span.pods-file-reorder{left:3px;position:absolute;top:15px;width:30px}form.pods-manage ul.pods-dfv-list li span.pods-file-reorder img{cursor:move;display:block}form.pods-manage ul.pods-dfv-list li span.pods-file-thumb{left:35px;position:absolute;top:2px;width:45px}form.pods-manage ul.pods-dfv-list li span.pods-file-thumb .pinkynail{float:none;margin:0;max-width:40px !important;max-height:40px !important}form.pods-manage ul.pods-dfv-list li span.pods-dfv-list-name{padding:11px 35px 0 85px}form.pods-manage ul.pods-dfv-list li span.pods-file-remove{position:absolute;right:10px;top:10px;width:25px}form.pods-manage ul.pods-dfv-list li span.pods-file-remove img{cursor:pointer;display:block}form.pods-manage .pods-pick-values{background:#fff;border:1px solid #dfdfdf;border-radius:3px;min-width:125px;overflow:auto;padding:2px 0}form.pods-manage .pods-pick-values ul{overflow:auto}form.pods-manage .pods-pick-values li{border-bottom:1px solid #f4f4f4;line-height:1em;margin:0;padding:3px 6px 2px}form.pods-manage .pods-pick-values li:nth-child(even){background:#fcfcfc}form.pods-manage .pods-pick-values label{padding-bottom:3px;padding-top:3px}form.pods-manage .pods-pick-values li:last-of-type{border-bottom:0}form.pods-manage .pods-pick-values li .pods-field{padding:3px 0 2px}form.pods-manage .pods-pick-values li .pods-boolean input{top:5px}form.pods-manage .pods-pick-values li:hover{background:#f5f5f5}form.pods-manage select.pods-pick-multi{height:auto !important}form.pods-manage .pods-field,form.pods-manage p.pods-add-file{clear:both;padding:10px 0}form.pods-manage .pods-textfield input,form.pods-manage .pods-textarea textarea{width:100%}form.pods-manage .pods-textfield input,form.pods-manage .pods-textarea textarea{padding:5px 7px;color:#808080}form.pods-manage .pods-textarea textarea{resize:vertical}form.pods-manage .pods-textfield input:focus,form.pods-manage .pods-textarea textarea:focus{border-color:#a0a0a0;box-shadow:0 0 5px rgba(0,0,0,0.1);color:#000}form.pods-manage .pods-date input,form.pods-manage .pods-number input{min-width:125px}form.pods-manage .pods-date input.pods-date-field.hasDatepicker{background:#fff url(../../images/calendar16.png) no-repeat 5px 5px;cursor:pointer;padding-left:25px !important;padding-top:6px !important;width:150px}form.pods-manage .pods-slider-field{margin:10px 0}form.pods-manage .pods-slider-field-display{padding:10px 0}form.pods-manage ul.ui-sortable li{cursor:move}form.pods-manage ul.ui-sortable li:hover{background:#f5f5f5;cursor:move}form.pods-manage ul.ui-sortable li:hover{background:#f5f5f5}form.pods-manage .ui-slider-handle{z-index:0 !important}form.pods-manage table.plupload-queue tr.hide{display:none}form.pods-manage table.plupload-queue td.progress{width:175px}form.pods-manage table.plupload-queue td.progress .progress-bar{width:0;height:14px;background:black}form.pods-manage .plupload-queue{width:250px}form.pods-manage .plupload-progress{position:relative}form.pods-manage .plupload-progress .progress-bar{position:absolute;height:14px;width:0%;background:#4d4d4d;margin-left:10px}form.pods-manage .plupload-progress .file-name{vertical-align:top}form.pods-manage .pods-inline-files li{margin-top:10px}form.pods-manage .pods-inline-files li .file-name{vertical-align:top !important}form.pods-manage .pods-inline-files li .remove{cursor:pointer}form.pods-manage .pods-inline-files .plupload-progress{width:150px}table.DMB_metabox td,table.DMB_metabox th{border-bottom:1px solid #f5f5f5}table.DMB_metabox th{text-align:right;font-weight:bold}table.DMB_metabox th label{margin-top:6px;display:block}p.DMB_metabox_description{color:#AAA;font-style:italic;margin:2px 0 !important}span.DMB_metabox_description{color:#AAA;font-style:italic}input.DMB_text_small{width:100px;margin-right:15px}input.DMB_text_money{width:90px;margin-right:15px}input.DMB_text_medium{width:230px;margin-right:15px}table.DMB_metabox input,table.DMB_metabox textarea{font-size:11px;padding:5px}table.DMB_metabox li{font-size:11px;float:left;width:25%;margin:0 10px}table.DMB_metabox ul{padding-top:5px}table.DMB_metabox select{font-size:11px;padding:5px 10px}table.DMB_metabox input:focus,table.DMB_metabox textarea:focus{background:#fffff8}.DMB_metabox_title{margin:0 0 5px 0;padding:5px 0 0 0;font:italic 24px/35px Georgia, "Times New Roman", "Bitstream Charter", Times, serif}.DMB_radio_inline{padding:4px 0 0 0}.DMB_radio_inline_option{display:inline;padding-right:18px}table.DMB_metabox input[type="radio"]{margin-right:3px}table.DMB_metabox input[type="checkbox"]{margin-right:6px}table.DMB_metabox .mceLayout{border:1px solid #DFDFDF !important}table.DMB_metabox .meta_mce{width:97%}table.DMB_metabox .meta_mce textarea{width:100%}table.DMB_metabox .DMB_upload_status{margin:10px 0 0 0}table.DMB_metabox .DMB_upload_status .img_status{position:relative}table.DMB_metabox .DMB_upload_status .img_status img{border:1px solid #DFDFDF;background:#FAFAFA;max-width:350px;padding:5px;-moz-border-radius:2px;border-radius:2px}table.DMB_metabox .DMB_upload_status .img_status .remove_file_button{text-indent:-9999px;width:16px;height:16px}table.DMB_metabox thead tr{border-bottom:1px solid #ccc}.pods-modal-window{margin-top:-32px}.pods-modal-window.edit-tags-php #col-left,.pods-modal-window.edit-tags-php #col-left input,.pods-modal-window.edit-tags-php #col-left textarea{width:100%}.pods-modal-window #wpadminbar,.pods-modal-window #adminmenuback,.pods-modal-window #adminmenuwrap,.pods-modal-window #preview-action,.pods-modal-window #wpfooter,.pods-modal-window body.edit-tags-php #col-right,.pods-modal-window body.edit-tags-php .search-form{display:none}.pods-modal-window #wpbody-content{padding-bottom:0}.pods-modal-window #wpcontent{padding:0;margin:0 1.25em}.pods-modal-window .wrap{margin:0}.pods-ui-filter-bar{margin:10px 0 20px}.pods-ui-filter-bar-primary{padding:8px 15px;-webkit-border-radius:3px;border-radius:3px;background-color:#F9F9F9;border:1px solid #DFDFDF;position:relative;height:auto;line-height:35px;text-shadow:0 1px 0 white;overflow:hidden;word-wrap:break-word}.pods-ui-filter-bar-primary ul.subsubsub{margin:0 0 0 4px}.pods-ui-filter-bar-primary ul.subsubsub li{margin-right:5px}.pods-ui-filter-bar-primary ul.subsubsub li.pods-ui-filter-view-label{margin-right:8px;color:#222;font-size:14px}.pods-ui-filter-bar-primary ul.subsubsub li a{text-decoration:none;font-size:12px;line-height:13px;padding:3px 10px;cursor:pointer;border-radius:3px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;border:1px solid #BBB;color:#464646;background:#F2F2F2;text-shadow:#fff 0 1px 0}.pods-ui-filter-bar-primary ul.subsubsub li a:hover{color:#000}.pods-ui-filter-bar-primary ul.subsubsub li a:active{background:#EEE}.pods-ui-filter-bar-primary ul.subsubsub li a.current{border:none;font-weight:bold;color:white;background:#21759B;text-shadow:rgba(0,0,0,0.3) 0 -1px 0}.pods-ui-filter-bar-primary ul.subsubsub li a.current:hover{border-color:#13455B}.pods-ui-filter-bar-primary ul.subsubsub li a.current:active{background:#21759B repeat-x scroll left top}.pods-ui-filter-bar-primary ul.subsubsub li a.current:hover,.pods-ui-filter-bar-primary ul.subsubsub li a.current:active{color:#EAF2FA}.pods-ui-filter-bar-primary ul.subsubsub li a span{font-size:11px}.pods-ui-filter-bar-primary ul.subsubsub li a.current span{color:#F7F7F7}.pods-ui-filter-bar-primary p.search-box{margin:0}.pods-ui-filter-bar-primary p.search-box a.pods-ui-filter-reset{margin-right:6px;font-size:11px}body.branch-3-5 .pods-ui-filter-bar-primary p.search-box input[name="s"]{float:none;line-height:24px}body.branch-3-5 .pods-ui-filter-bar-primary p.search-box input.button{float:none;line-height:23px}.pods-ui-filter-bar-secondary{margin:0 auto;width:97%;background:#e1ecf2;border:1px solid #c0d4e0;padding:6px 8px;text-align:right;-webkit-border-bottom-right-radius:8px;-webkit-border-bottom-left-radius:8px;-moz-border-radius-bottomright:8px;-moz-border-radius-bottomleft:8px;border-bottom-right-radius:8px;border-bottom-left-radius:8px}.pods-ui-filter-bar-secondary ul.subsubsub{margin:0;float:none}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-add-filter{margin-right:8px}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-add-filter a{font-size:13px;font-weight:normal}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter{text-decoration:none;font-size:12px;line-height:13px;margin-left:8px;padding:4px 12px;cursor:pointer;-webkit-border-radius:11px;border-radius:11px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;border:none;background:#21759B;text-shadow:rgba(0,0,0,0.3) 0 -1px 0}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter a{color:white}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:hover{border-color:#13455B}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:active{background:#21759B}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:hover a:hover,.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:active a{color:#EAF2FA}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter a.remove-filter{padding-left:7px;margin-left:3px;border-left:1px solid #888;text-transform:uppercase;font-size:11px;color:#CCC}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:hover a.remove-filter{color:#CCC}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:hover a.remove-filter:hover{color:#CCC}.pods-ui-posts-filter-popup .pods-ui-posts-filters,.pods-ui-posts-filter-popup .pods-ui-posts-filters p.clear{clear:both}.pods-ui-posts-filter-popup label{display:block;margin-bottom:9px;font-weight:bold;font-size:15px;color:#282828;cursor:pointer}.pods-ui-posts-filter-popup .pods-ui-posts-filter label{margin:4px 0;font-size:13px}.pods-ui-posts-filter-popup .pods-ui-posts-filter-toggle{color:#2175A4;font-size:10px;line-height:15px;text-transform:uppercase;margin-left:9px;vertical-align:1px;float:right;cursor:pointer}.pods-ui-posts-filter-popup .pods-ui-posts-filter{clear:both;display:block;margin-bottom:4px}.pods-ui-posts-filter-popup .pods-ui-posts-filter.pods-hidden{display:none}.pods-ui-posts-filter-popup .pods-ui-posts-filter-toggle.toggle-on{font-size:14px}.pods-ui-posts-filter-popup .pods-ui-posts-filter-toggle:active,.pods-ui-posts-filter-popup .pods-ui-posts-filter-toggle:hover{color:#D54E21}.pods-ui-posts-filter-popup p{display:block;float:left;width:47%;margin:7px 0 20px 5%;border-bottom:1px solid #BABABA}.pods-ui-posts-filter-popup p.clear{margin-left:0}.pods-ui-posts-filter-popup p input,.pods-ui-posts-filter-popup p select,.pods-ui-posts-filter-popup p textarea{max-width:100%}.pods-ui-posts-filter-popup p input[type="text"],.pods-ui-posts-filter-popup p textarea{width:100%}.pods-ui-posts-filter-popup p.pods-ui-posts-filter-search{padding-bottom:0;border-bottom:none}.pods-ui-posts-filter-popup p.submit{margin-top:30px;padding:0 !important;border-bottom:none}body.branch-3-5 .pods-ui-posts-filter-popup p.submit{margin-top:36px}.pods-ui-posts-filter-popup p.submit.clear{clear:none;float:right;text-align:right}body.branch-3-4 .pods-ui-posts-filter-popup p.submit input.button{font-size:13px !important;padding:5px 32px}body.branch-3-5 .pods-ui-posts-filter-popup p.submit input.button{padding:0 32px}.pods-ui-posts-filter-popup p:after,.pods-ui-posts-filter-popup .pods-ui-posts-filters:after{content:".";display:block;height:0;clear:both;visibility:hidden}.pods-compat-container .CodeMirror{font-family:monospace;height:300px}.pods-compat-container .CodeMirror-scroll{overflow:auto}.pods-compat-container .CodeMirror-lines{padding:4px 0}.pods-compat-container .CodeMirror pre{padding:0 4px}.pods-compat-container .CodeMirror-scrollbar-filler,.pods-compat-container .CodeMirror-gutter-filler{background-color:white}.pods-compat-container .CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.pods-compat-container .CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;-moz-box-sizing:content-box;box-sizing:content-box}.pods-compat-container .CodeMirror-guttermarker{color:black}.pods-compat-container .CodeMirror-guttermarker-subtle{color:#999}.pods-compat-container .CodeMirror div.CodeMirror-cursor{border-left:1px solid black}.pods-compat-container .CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.pods-compat-container .CodeMirror.cm-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7}.pods-compat-container .CodeMirror.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.pods-compat-container .cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}@-moz-keyframes blink{0%{background:#7e7}50%{background:none}100%{background:#7e7}}@-webkit-keyframes blink{0%{background:#7e7}50%{background:none}100%{background:#7e7}}@keyframes blink{0%{background:#7e7}50%{background:none}100%{background:#7e7}}.pods-compat-container .cm-tab{display:inline-block;text-decoration:inherit}.pods-compat-container .CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.pods-compat-container .cm-s-default .cm-keyword{color:#708}.pods-compat-container .cm-s-default .cm-atom{color:#219}.pods-compat-container .cm-s-default .cm-number{color:#164}.pods-compat-container .cm-s-default .cm-def{color:#00f}.pods-compat-container .cm-s-default .cm-variable-2{color:#05a}.pods-compat-container .cm-s-default .cm-variable-3{color:#085}.pods-compat-container .cm-s-default .cm-comment{color:#a50}.pods-compat-container .cm-s-default .cm-string{color:#a11}.pods-compat-container .cm-s-default .cm-string-2{color:#f50}.pods-compat-container .cm-s-default .cm-meta{color:#555}.pods-compat-container .cm-s-default .cm-qualifier{color:#555}.pods-compat-container .cm-s-default .cm-builtin{color:#30a}.pods-compat-container .cm-s-default .cm-bracket{color:#997}.pods-compat-container .cm-s-default .cm-tag{color:#170}.pods-compat-container .cm-s-default .cm-attribute{color:#00c}.pods-compat-container .cm-s-default .cm-header{color:blue}.pods-compat-container .cm-s-default .cm-quote{color:#090}.pods-compat-container .cm-s-default .cm-hr{color:#999}.pods-compat-container .cm-s-default .cm-link{color:#00c}.pods-compat-container .cm-negative{color:#d44}.pods-compat-container .cm-positive{color:#292}.pods-compat-container .cm-header,.pods-compat-container .cm-strong{font-weight:bold}.pods-compat-container .cm-em{font-style:italic}.pods-compat-container .cm-link{text-decoration:underline}.pods-compat-container .cm-strikethrough{text-decoration:line-through}.pods-compat-container .cm-s-default .cm-error{color:#f00}.pods-compat-container .cm-invalidchar{color:#f00}.pods-compat-container div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}.pods-compat-container div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.pods-compat-container .CodeMirror-matchingtag{background:rgba(255,150,0,0.3)}.pods-compat-container .CodeMirror-activeline-background{background:#e8f2ff}.pods-compat-container .CodeMirror{background:none repeat scroll 0 0 white;color:black;line-height:1;margin:-6px -12px -12px;overflow:hidden;position:relative}.pods-compat-container .CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:none;position:relative;-moz-box-sizing:content-box;box-sizing:content-box;z-index:0}.pods-compat-container .CodeMirror-sizer{position:relative;border-right:30px solid transparent;-moz-box-sizing:content-box;box-sizing:content-box}.pods-compat-container .CodeMirror-vscrollbar,.pods-compat-container .CodeMirror-hscrollbar,.pods-compat-container .CodeMirror-scrollbar-filler,.pods-compat-container .CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.pods-compat-container .CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.pods-compat-container .CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.pods-compat-container .CodeMirror-scrollbar-filler{right:0;bottom:0}.pods-compat-container .CodeMirror-gutter-filler{left:0;bottom:0}.pods-compat-container .CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}.pods-compat-container .CodeMirror-gutter{white-space:normal;height:100%;-moz-box-sizing:content-box;box-sizing:content-box;padding-bottom:30px;margin-bottom:-32px;display:inline-block;*zoom:1;*display:inline}.pods-compat-container .CodeMirror-gutter-wrapper{position:absolute;z-index:4;height:100%}.pods-compat-container .CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.pods-compat-container .CodeMirror-lines{cursor:text;min-height:1px}.pods-compat-container .CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}.pods-compat-container .CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:break-all}.pods-compat-container .CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.pods-compat-container .CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.pods-compat-container .CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.pods-compat-container .CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.pods-compat-container .CodeMirror-measure pre{position:static}.pods-compat-container .CodeMirror div.CodeMirror-cursor{position:absolute;border-right:none;width:0}.pods-compat-container div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.pods-compat-container .CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.pods-compat-container .CodeMirror-selected{background:#d9d9d9}.pods-compat-container .CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.pods-compat-container .CodeMirror-crosshair{cursor:crosshair}.pods-compat-container .cm-searching{background:#ffa;background:rgba(255,255,0,0.4)}.pods-compat-container .CodeMirror span{*vertical-align:text-bottom}.pods-compat-container .cm-force-border{padding-right:.1px}@media print{.pods-compat-container .CodeMirror div.CodeMirror-cursors{visibility:hidden}}.pods-compat-container .cm-tab-wrap-hack:after{content:''}.pods-compat-container span.CodeMirror-selectedtext{background:none}.pods-compat-container .ui-timepicker-div .ui-widget-header{margin-bottom:8px}.pods-compat-container .ui-timepicker-div dl{text-align:left}.pods-compat-container .ui-timepicker-div dl dt{height:25px;margin-bottom:-25px}.pods-compat-container .ui-timepicker-div dl dd{margin:0 10px 10px 65px}.pods-compat-container .ui-timepicker-div td{font-size:90%}.pods-compat-container .ui-timepicker-div .ui_tpicker_unit_hide{display:none}.pods-compat-container .ui-timepicker-div .ui_tpicker_time_input{width:100%}.pods-compat-container .ui-tpicker-grid-label{background:none;border:none;margin:0;padding:0}.pods-compat-container .ui-timepicker-rtl{direction:rtl}.pods-compat-container .ui-timepicker-rtl dl{text-align:right}.pods-compat-container .ui-timepicker-rtl dl dd{margin:0 65px 10px 10px}.pods-compat-container .ui-helper-hidden{display:none}.pods-compat-container .ui-helper-hidden-accessible{position:absolute !important;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px)}.pods-compat-container .ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.pods-compat-container .ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.pods-compat-container .ui-helper-clearfix{display:inline-block}.pods-compat-container * html .ui-helper-clearfix{height:1%}.pods-compat-container .ui-helper-clearfix{display:block}.pods-compat-container .ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.pods-compat-container .ui-state-disabled{cursor:default !important}.pods-compat-container .ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.pods-compat-container .ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.pods-compat-container .ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.pods-compat-container .ui-widget .ui-widget{font-size:1em}.pods-compat-container .ui-widget input,.pods-compat-container .ui-widget select,.pods-compat-container .ui-widget textarea,.pods-compat-container .ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}.pods-compat-container .ui-widget-content{border:1px solid #aaaaaa;background:#fff url(../../images/smoothness/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;color:#222222}.pods-compat-container .ui-widget-content a{color:#222222}.pods-compat-container .ui-widget-header{border:1px solid #aaaaaa;background:#ccc url(../../images/smoothness/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;color:#222222;font-weight:bold}.pods-compat-container .ui-widget-header a{color:#222222}.pods-compat-container .ui-state-default,.pods-compat-container .ui-widget-content .ui-state-default,.pods-compat-container .ui-widget-header .ui-state-default{border:1px solid #d3d3d3;background:#e6e6e6 url(../../images/smoothness/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#555555}.pods-compat-container .ui-state-default a,.pods-compat-container .ui-state-default a:link,.pods-compat-container .ui-state-default a:visited{color:#555555;text-decoration:none}.pods-compat-container .ui-state-hover,.pods-compat-container .ui-widget-content .ui-state-hover,.pods-compat-container .ui-widget-header .ui-state-hover,.pods-compat-container .ui-state-focus,.pods-compat-container .ui-widget-content .ui-state-focus,.pods-compat-container .ui-widget-header .ui-state-focus{border:1px solid #999999;background:#dadada url(../../images/smoothness/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}.pods-compat-container .ui-state-hover a,.pods-compat-container .ui-state-hover a:hover{color:#212121;text-decoration:none}.pods-compat-container .ui-state-active,.pods-compat-container .ui-widget-content .ui-state-active,.pods-compat-container .ui-widget-header .ui-state-active{border:1px solid #aaaaaa;background:#fff url(../../images/smoothness/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}.pods-compat-container .ui-state-active a,.pods-compat-container .ui-state-active a:link,.pods-compat-container .ui-state-active a:visited{color:#212121;text-decoration:none}.pods-compat-container .ui-widget :active{outline:none}.pods-compat-container .ui-state-highlight,.pods-compat-container .ui-widget-content .ui-state-highlight,.pods-compat-container .ui-widget-header .ui-state-highlight{border:1px solid #fcefa1;background:#fbf9ee url(../../images/smoothness/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x;color:#363636}.pods-compat-container .ui-state-highlight a,.pods-compat-container .ui-widget-content .ui-state-highlight a,.pods-compat-container .ui-widget-header .ui-state-highlight a{color:#363636}.pods-compat-container .ui-state-error,.pods-compat-container .ui-widget-content .ui-state-error,.pods-compat-container .ui-widget-header .ui-state-error{border:1px solid #cd0a0a;background:#fef1ec url(../../images/smoothness/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x;color:#cd0a0a}.pods-compat-container .ui-state-error a,.pods-compat-container .ui-widget-content .ui-state-error a,.pods-compat-container .ui-widget-header .ui-state-error a{color:#cd0a0a}.pods-compat-container .ui-state-error-text,.pods-compat-container .ui-widget-content .ui-state-error-text,.pods-compat-container .ui-widget-header .ui-state-error-text{color:#cd0a0a}.pods-compat-container .ui-priority-primary,.pods-compat-container .ui-widget-content .ui-priority-primary,.pods-compat-container .ui-widget-header .ui-priority-primary{font-weight:bold}.pods-compat-container .ui-priority-secondary,.pods-compat-container .ui-widget-content .ui-priority-secondary,.pods-compat-container .ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.pods-compat-container .ui-state-disabled,.pods-compat-container .ui-widget-content .ui-state-disabled,.pods-compat-container .ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.pods-compat-container .ui-icon{width:16px;height:16px;background-image:url(../../images/smoothness/ui-icons_222222_256x240.png)}.pods-compat-container .ui-widget-content .ui-icon{background-image:url(../../images/smoothness/ui-icons_222222_256x240.png)}.pods-compat-container .ui-widget-header .ui-icon{background-image:url(../../images/smoothness/ui-icons_222222_256x240.png)}.pods-compat-container .ui-state-default .ui-icon{background-image:url(../../images/smoothness/ui-icons_888888_256x240.png)}.pods-compat-container .ui-state-hover .ui-icon,.pods-compat-container .ui-state-focus .ui-icon{background-image:url(../../images/smoothness/ui-icons_454545_256x240.png)}.pods-compat-container .ui-state-active .ui-icon{background-image:url(../../images/smoothness/ui-icons_454545_256x240.png)}.pods-compat-container .ui-state-highlight .ui-icon{background-image:url(../../images/smoothness/ui-icons_2e83ff_256x240.png)}.pods-compat-container .ui-state-error .ui-icon,.pods-compat-container .ui-state-error-text .ui-icon{background-image:url(../../images/smoothness/ui-icons_cd0a0a_256x240.png)}.pods-compat-container .ui-icon-carat-1-n{background-position:0 0}.pods-compat-container .ui-icon-carat-1-ne{background-position:-16px 0}.pods-compat-container .ui-icon-carat-1-e{background-position:-32px 0}.pods-compat-container .ui-icon-carat-1-se{background-position:-48px 0}.pods-compat-container .ui-icon-carat-1-s{background-position:-64px 0}.pods-compat-container .ui-icon-carat-1-sw{background-position:-80px 0}.pods-compat-container .ui-icon-carat-1-w{background-position:-96px 0}.pods-compat-container .ui-icon-carat-1-nw{background-position:-112px 0}.pods-compat-container .ui-icon-carat-2-n-s{background-position:-128px 0}.pods-compat-container .ui-icon-carat-2-e-w{background-position:-144px 0}.pods-compat-container .ui-icon-triangle-1-n{background-position:0 -16px}.pods-compat-container .ui-icon-triangle-1-ne{background-position:-16px -16px}.pods-compat-container .ui-icon-triangle-1-e{background-position:-32px -16px}.pods-compat-container .ui-icon-triangle-1-se{background-position:-48px -16px}.pods-compat-container .ui-icon-triangle-1-s{background-position:-64px -16px}.pods-compat-container .ui-icon-triangle-1-sw{background-position:-80px -16px}.pods-compat-container .ui-icon-triangle-1-w{background-position:-96px -16px}.pods-compat-container .ui-icon-triangle-1-nw{background-position:-112px -16px}.pods-compat-container .ui-icon-triangle-2-n-s{background-position:-128px -16px}.pods-compat-container .ui-icon-triangle-2-e-w{background-position:-144px -16px}.pods-compat-container .ui-icon-arrow-1-n{background-position:0 -32px}.pods-compat-container .ui-icon-arrow-1-ne{background-position:-16px -32px}.pods-compat-container .ui-icon-arrow-1-e{background-position:-32px -32px}.pods-compat-container .ui-icon-arrow-1-se{background-position:-48px -32px}.pods-compat-container .ui-icon-arrow-1-s{background-position:-64px -32px}.pods-compat-container .ui-icon-arrow-1-sw{background-position:-80px -32px}.pods-compat-container .ui-icon-arrow-1-w{background-position:-96px -32px}.pods-compat-container .ui-icon-arrow-1-nw{background-position:-112px -32px}.pods-compat-container .ui-icon-arrow-2-n-s{background-position:-128px -32px}.pods-compat-container .ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.pods-compat-container .ui-icon-arrow-2-e-w{background-position:-160px -32px}.pods-compat-container .ui-icon-arrow-2-se-nw{background-position:-176px -32px}.pods-compat-container .ui-icon-arrowstop-1-n{background-position:-192px -32px}.pods-compat-container .ui-icon-arrowstop-1-e{background-position:-208px -32px}.pods-compat-container .ui-icon-arrowstop-1-s{background-position:-224px -32px}.pods-compat-container .ui-icon-arrowstop-1-w{background-position:-240px -32px}.pods-compat-container .ui-icon-arrowthick-1-n{background-position:0 -48px}.pods-compat-container .ui-icon-arrowthick-1-ne{background-position:-16px -48px}.pods-compat-container .ui-icon-arrowthick-1-e{background-position:-32px -48px}.pods-compat-container .ui-icon-arrowthick-1-se{background-position:-48px -48px}.pods-compat-container .ui-icon-arrowthick-1-s{background-position:-64px -48px}.pods-compat-container .ui-icon-arrowthick-1-sw{background-position:-80px -48px}.pods-compat-container .ui-icon-arrowthick-1-w{background-position:-96px -48px}.pods-compat-container .ui-icon-arrowthick-1-nw{background-position:-112px -48px}.pods-compat-container .ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.pods-compat-container .ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.pods-compat-container .ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.pods-compat-container .ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.pods-compat-container .ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.pods-compat-container .ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.pods-compat-container .ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.pods-compat-container .ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.pods-compat-container .ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.pods-compat-container .ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.pods-compat-container .ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.pods-compat-container .ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.pods-compat-container .ui-icon-arrowreturn-1-w{background-position:-64px -64px}.pods-compat-container .ui-icon-arrowreturn-1-n{background-position:-80px -64px}.pods-compat-container .ui-icon-arrowreturn-1-e{background-position:-96px -64px}.pods-compat-container .ui-icon-arrowreturn-1-s{background-position:-112px -64px}.pods-compat-container .ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.pods-compat-container .ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.pods-compat-container .ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.pods-compat-container .ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.pods-compat-container .ui-icon-arrow-4{background-position:0 -80px}.pods-compat-container .ui-icon-arrow-4-diag{background-position:-16px -80px}.pods-compat-container .ui-icon-extlink{background-position:-32px -80px}.pods-compat-container .ui-icon-newwin{background-position:-48px -80px}.pods-compat-container .ui-icon-refresh{background-position:-64px -80px}.pods-compat-container .ui-icon-shuffle{background-position:-80px -80px}.pods-compat-container .ui-icon-transfer-e-w{background-position:-96px -80px}.pods-compat-container .ui-icon-transferthick-e-w{background-position:-112px -80px}.pods-compat-container .ui-icon-folder-collapsed{background-position:0 -96px}.pods-compat-container .ui-icon-folder-open{background-position:-16px -96px}.pods-compat-container .ui-icon-document{background-position:-32px -96px}.pods-compat-container .ui-icon-document-b{background-position:-48px -96px}.pods-compat-container .ui-icon-note{background-position:-64px -96px}.pods-compat-container .ui-icon-mail-closed{background-position:-80px -96px}.pods-compat-container .ui-icon-mail-open{background-position:-96px -96px}.pods-compat-container .ui-icon-suitcase{background-position:-112px -96px}.pods-compat-container .ui-icon-comment{background-position:-128px -96px}.pods-compat-container .ui-icon-person{background-position:-144px -96px}.pods-compat-container .ui-icon-print{background-position:-160px -96px}.pods-compat-container .ui-icon-trash{background-position:-176px -96px}.pods-compat-container .ui-icon-locked{background-position:-192px -96px}.pods-compat-container .ui-icon-unlocked{background-position:-208px -96px}.pods-compat-container .ui-icon-bookmark{background-position:-224px -96px}.pods-compat-container .ui-icon-tag{background-position:-240px -96px}.pods-compat-container .ui-icon-home{background-position:0 -112px}.pods-compat-container .ui-icon-flag{background-position:-16px -112px}.pods-compat-container .ui-icon-calendar{background-position:-32px -112px}.pods-compat-container .ui-icon-cart{background-position:-48px -112px}.pods-compat-container .ui-icon-pencil{background-position:-64px -112px}.pods-compat-container .ui-icon-clock{background-position:-80px -112px}.pods-compat-container .ui-icon-disk{background-position:-96px -112px}.pods-compat-container .ui-icon-calculator{background-position:-112px -112px}.pods-compat-container .ui-icon-zoomin{background-position:-128px -112px}.pods-compat-container .ui-icon-zoomout{background-position:-144px -112px}.pods-compat-container .ui-icon-search{background-position:-160px -112px}.pods-compat-container .ui-icon-wrench{background-position:-176px -112px}.pods-compat-container .ui-icon-gear{background-position:-192px -112px}.pods-compat-container .ui-icon-heart{background-position:-208px -112px}.pods-compat-container .ui-icon-star{background-position:-224px -112px}.pods-compat-container .ui-icon-link{background-position:-240px -112px}.pods-compat-container .ui-icon-cancel{background-position:0 -128px}.pods-compat-container .ui-icon-plus{background-position:-16px -128px}.pods-compat-container .ui-icon-plusthick{background-position:-32px -128px}.pods-compat-container .ui-icon-minus{background-position:-48px -128px}.pods-compat-container .ui-icon-minusthick{background-position:-64px -128px}.pods-compat-container .ui-icon-close{background-position:-80px -128px}.pods-compat-container .ui-icon-closethick{background-position:-96px -128px}.pods-compat-container .ui-icon-key{background-position:-112px -128px}.pods-compat-container .ui-icon-lightbulb{background-position:-128px -128px}.pods-compat-container .ui-icon-scissors{background-position:-144px -128px}.pods-compat-container .ui-icon-clipboard{background-position:-160px -128px}.pods-compat-container .ui-icon-copy{background-position:-176px -128px}.pods-compat-container .ui-icon-contact{background-position:-192px -128px}.pods-compat-container .ui-icon-image{background-position:-208px -128px}.pods-compat-container .ui-icon-video{background-position:-224px -128px}.pods-compat-container .ui-icon-script{background-position:-240px -128px}.pods-compat-container .ui-icon-alert{background-position:0 -144px}.pods-compat-container .ui-icon-info{background-position:-16px -144px}.pods-compat-container .ui-icon-notice{background-position:-32px -144px}.pods-compat-container .ui-icon-help{background-position:-48px -144px}.pods-compat-container .ui-icon-check{background-position:-64px -144px}.pods-compat-container .ui-icon-bullet{background-position:-80px -144px}.pods-compat-container .ui-icon-radio-off{background-position:-96px -144px}.pods-compat-container .ui-icon-radio-on{background-position:-112px -144px}.pods-compat-container .ui-icon-pin-w{background-position:-128px -144px}.pods-compat-container .ui-icon-pin-s{background-position:-144px -144px}.pods-compat-container .ui-icon-play{background-position:0 -160px}.pods-compat-container .ui-icon-pause{background-position:-16px -160px}.pods-compat-container .ui-icon-seek-next{background-position:-32px -160px}.pods-compat-container .ui-icon-seek-prev{background-position:-48px -160px}.pods-compat-container .ui-icon-seek-end{background-position:-64px -160px}.pods-compat-container .ui-icon-seek-start{background-position:-80px -160px}.pods-compat-container .ui-icon-seek-first{background-position:-80px -160px}.pods-compat-container .ui-icon-stop{background-position:-96px -160px}.pods-compat-container .ui-icon-eject{background-position:-112px -160px}.pods-compat-container .ui-icon-volume-off{background-position:-128px -160px}.pods-compat-container .ui-icon-volume-on{background-position:-144px -160px}.pods-compat-container .ui-icon-power{background-position:0 -176px}.pods-compat-container .ui-icon-signal-diag{background-position:-16px -176px}.pods-compat-container .ui-icon-signal{background-position:-32px -176px}.pods-compat-container .ui-icon-battery-0{background-position:-48px -176px}.pods-compat-container .ui-icon-battery-1{background-position:-64px -176px}.pods-compat-container .ui-icon-battery-2{background-position:-80px -176px}.pods-compat-container .ui-icon-battery-3{background-position:-96px -176px}.pods-compat-container .ui-icon-circle-plus{background-position:0 -192px}.pods-compat-container .ui-icon-circle-minus{background-position:-16px -192px}.pods-compat-container .ui-icon-circle-close{background-position:-32px -192px}.pods-compat-container .ui-icon-circle-triangle-e{background-position:-48px -192px}.pods-compat-container .ui-icon-circle-triangle-s{background-position:-64px -192px}.pods-compat-container .ui-icon-circle-triangle-w{background-position:-80px -192px}.pods-compat-container .ui-icon-circle-triangle-n{background-position:-96px -192px}.pods-compat-container .ui-icon-circle-arrow-e{background-position:-112px -192px}.pods-compat-container .ui-icon-circle-arrow-s{background-position:-128px -192px}.pods-compat-container .ui-icon-circle-arrow-w{background-position:-144px -192px}.pods-compat-container .ui-icon-circle-arrow-n{background-position:-160px -192px}.pods-compat-container .ui-icon-circle-zoomin{background-position:-176px -192px}.pods-compat-container .ui-icon-circle-zoomout{background-position:-192px -192px}.pods-compat-container .ui-icon-circle-check{background-position:-208px -192px}.pods-compat-container .ui-icon-circlesmall-plus{background-position:0 -208px}.pods-compat-container .ui-icon-circlesmall-minus{background-position:-16px -208px}.pods-compat-container .ui-icon-circlesmall-close{background-position:-32px -208px}.pods-compat-container .ui-icon-squaresmall-plus{background-position:-48px -208px}.pods-compat-container .ui-icon-squaresmall-minus{background-position:-64px -208px}.pods-compat-container .ui-icon-squaresmall-close{background-position:-80px -208px}.pods-compat-container .ui-icon-grip-dotted-vertical{background-position:0 -224px}.pods-compat-container .ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.pods-compat-container .ui-icon-grip-solid-vertical{background-position:-32px -224px}.pods-compat-container .ui-icon-grip-solid-horizontal{background-position:-48px -224px}.pods-compat-container .ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.pods-compat-container .ui-icon-grip-diagonal-se{background-position:-80px -224px}.pods-compat-container .ui-corner-all,.pods-compat-container .ui-corner-top,.pods-compat-container .ui-corner-left,.pods-compat-container .ui-corner-tl{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px}.pods-compat-container .ui-corner-all,.pods-compat-container .ui-corner-top,.pods-compat-container .ui-corner-right,.pods-compat-container .ui-corner-tr{-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;-khtml-border-top-right-radius:4px;border-top-right-radius:4px}.pods-compat-container .ui-corner-all,.pods-compat-container .ui-corner-bottom,.pods-compat-container .ui-corner-left,.pods-compat-container .ui-corner-bl{-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;-khtml-border-bottom-left-radius:4px;border-bottom-left-radius:4px}.pods-compat-container .ui-corner-all,.pods-compat-container .ui-corner-bottom,.pods-compat-container .ui-corner-right,.pods-compat-container .ui-corner-br{-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;-khtml-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.pods-compat-container .ui-widget-overlay{background:#aaa url(../../images/smoothness/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.30;filter:Alpha(Opacity=30)}.pods-compat-container .ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaa url(../../images/smoothness/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.30;filter:Alpha(Opacity=30);-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.pods-compat-container .ui-resizable{position:relative}.pods-compat-container .ui-resizable-handle{position:absolute;font-size:0.1px;z-index:99999;display:block}.pods-compat-container .ui-resizable-disabled .ui-resizable-handle,.pods-compat-container .ui-resizable-autohide .ui-resizable-handle{display:none}.pods-compat-container .ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.pods-compat-container .ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.pods-compat-container .ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.pods-compat-container .ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.pods-compat-container .ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.pods-compat-container .ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.pods-compat-container .ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.pods-compat-container .ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.pods-compat-container .ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.pods-compat-container .ui-accordion{width:100%}.pods-compat-container .ui-accordion .ui-accordion-header{cursor:pointer;position:relative;margin-top:1px;zoom:1}.pods-compat-container .ui-accordion .ui-accordion-li-fix{display:inline}.pods-compat-container .ui-accordion .ui-accordion-header-active{border-bottom:0 !important}.pods-compat-container .ui-accordion .ui-accordion-header a{display:block;font-size:1em;padding:.5em .5em .5em .7em}.pods-compat-container .ui-accordion-icons .ui-accordion-header a{padding-left:2.2em}.pods-compat-container .ui-accordion .ui-accordion-header .ui-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.pods-compat-container .ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;margin-top:-2px;position:relative;top:1px;margin-bottom:2px;overflow:auto;display:none;zoom:1}.pods-compat-container .ui-accordion .ui-accordion-content-active{display:block}.pods-compat-container .ui-autocomplete{position:absolute;cursor:default}.pods-compat-container * html .ui-autocomplete{width:1px}.pods-compat-container .ui-menu{list-style:none;padding:2px;margin:0;display:block;float:left}.pods-compat-container .ui-menu .ui-menu{margin-top:-3px}.pods-compat-container .ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;float:left;clear:left;width:100%}.pods-compat-container .ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:.2em .4em;line-height:1.5;zoom:1}.pods-compat-container .ui-menu .ui-menu-item a.ui-state-hover,.pods-compat-container .ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.pods-compat-container .ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;text-decoration:none !important;cursor:pointer;text-align:center;zoom:1;overflow:visible}.pods-compat-container .ui-button-icon-only{width:2.2em}.pods-compat-container button.ui-button-icon-only{width:2.4em}.pods-compat-container .ui-button-icons-only{width:3.4em}.pods-compat-container button.ui-button-icons-only{width:3.7em}.pods-compat-container .ui-button .ui-button-text{display:block;line-height:1.4}.pods-compat-container .ui-button-text-only .ui-button-text{padding:.4em 1em}.pods-compat-container .ui-button-icon-only .ui-button-text,.pods-compat-container .ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.pods-compat-container .ui-button-text-icon-primary .ui-button-text,.pods-compat-container .ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.pods-compat-container .ui-button-text-icon-secondary .ui-button-text,.pods-compat-container .ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.pods-compat-container .ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}.pods-compat-container input.ui-button{padding:.4em 1em}.pods-compat-container .ui-button-icon-only .ui-icon,.pods-compat-container .ui-button-text-icon-primary .ui-icon,.pods-compat-container .ui-button-text-icon-secondary .ui-icon,.pods-compat-container .ui-button-text-icons .ui-icon,.pods-compat-container .ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.pods-compat-container .ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.pods-compat-container .ui-button-text-icon-primary .ui-button-icon-primary,.pods-compat-container .ui-button-text-icons .ui-button-icon-primary,.pods-compat-container .ui-button-icons-only .ui-button-icon-primary{left:.5em}.pods-compat-container .ui-button-text-icon-secondary .ui-button-icon-secondary,.pods-compat-container .ui-button-text-icons .ui-button-icon-secondary,.pods-compat-container .ui-button-icons-only .ui-button-icon-secondary{right:.5em}.pods-compat-container .ui-button-text-icons .ui-button-icon-secondary,.pods-compat-container .ui-button-icons-only .ui-button-icon-secondary{right:.5em}.pods-compat-container .ui-buttonset{margin-right:7px}.pods-compat-container .ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}.pods-compat-container button.ui-button::-moz-focus-inner{border:0;padding:0}.pods-compat-container .ui-dialog{position:absolute;padding:.2em;width:300px;overflow:hidden}.pods-compat-container .ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.pods-compat-container .ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.pods-compat-container .ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.pods-compat-container .ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.pods-compat-container .ui-dialog .ui-dialog-titlebar-close:hover,.pods-compat-container .ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.pods-compat-container .ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto;zoom:1}.pods-compat-container .ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.pods-compat-container .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.pods-compat-container .ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.pods-compat-container .ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.pods-compat-container .ui-draggable .ui-dialog-titlebar{cursor:move}.pods-compat-container .ui-slider{position:relative;text-align:left}.pods-compat-container .ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.pods-compat-container .ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.pods-compat-container .ui-slider-horizontal{height:.8em}.pods-compat-container .ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.pods-compat-container .ui-slider-horizontal .ui-slider-range{top:0;height:100%}.pods-compat-container .ui-slider-horizontal .ui-slider-range-min{left:0}.pods-compat-container .ui-slider-horizontal .ui-slider-range-max{right:0}.pods-compat-container .ui-slider-vertical{width:.8em;height:100px}.pods-compat-container .ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.pods-compat-container .ui-slider-vertical .ui-slider-range{left:0;width:100%}.pods-compat-container .ui-slider-vertical .ui-slider-range-min{bottom:0}.pods-compat-container .ui-slider-vertical .ui-slider-range-max{top:0}.pods-compat-container .ui-tabs{position:relative;padding:.2em;zoom:1}.pods-compat-container .ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.pods-compat-container .ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:1px;margin:0 .2em 1px 0;border-bottom:0 !important;padding:0;white-space:nowrap}.pods-compat-container .ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.pods-compat-container .ui-tabs .ui-tabs-nav li.ui-tabs-selected{margin-bottom:0;padding-bottom:1px}.pods-compat-container .ui-tabs .ui-tabs-nav li.ui-tabs-selected a,.pods-compat-container .ui-tabs .ui-tabs-nav li.ui-state-disabled a,.pods-compat-container .ui-tabs .ui-tabs-nav li.ui-state-processing a{cursor:text}.pods-compat-container .ui-tabs .ui-tabs-nav li a,.pods-compat-container .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a{cursor:pointer}.pods-compat-container .ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none}.pods-compat-container .ui-tabs .ui-tabs-hide{display:none !important}.pods-compat-container .ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.pods-compat-container .ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.pods-compat-container .ui-datepicker .ui-datepicker-prev,.pods-compat-container .ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.pods-compat-container .ui-datepicker .ui-datepicker-prev-hover,.pods-compat-container .ui-datepicker .ui-datepicker-next-hover{top:1px}.pods-compat-container .ui-datepicker .ui-datepicker-prev{left:2px}.pods-compat-container .ui-datepicker .ui-datepicker-next{right:2px}.pods-compat-container .ui-datepicker .ui-datepicker-prev-hover{left:1px}.pods-compat-container .ui-datepicker .ui-datepicker-next-hover{right:1px}.pods-compat-container .ui-datepicker .ui-datepicker-prev span,.pods-compat-container .ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.pods-compat-container .ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.pods-compat-container .ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.pods-compat-container .ui-datepicker select.ui-datepicker-month-year{width:100%}.pods-compat-container .ui-datepicker select.ui-datepicker-month,.pods-compat-container .ui-datepicker select.ui-datepicker-year{width:49%}.pods-compat-container .ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.pods-compat-container .ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.pods-compat-container .ui-datepicker td{border:0;padding:1px}.pods-compat-container .ui-datepicker td span,.pods-compat-container .ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.pods-compat-container .ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.pods-compat-container .ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.pods-compat-container .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.pods-compat-container .ui-datepicker.ui-datepicker-multi{width:auto}.pods-compat-container .ui-datepicker-multi .ui-datepicker-group{float:left}.pods-compat-container .ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.pods-compat-container .ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.pods-compat-container .ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.pods-compat-container .ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.pods-compat-container .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.pods-compat-container .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.pods-compat-container .ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.pods-compat-container .ui-datepicker-row-break{clear:both;width:100%;font-size:0}.pods-compat-container .ui-datepicker-rtl{direction:rtl}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-group{float:right}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.pods-compat-container .ui-datepicker-cover{display:none;display/**/:block;position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px}.pods-compat-container .ui-progressbar{height:2em;text-align:left}.pods-compat-container .ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.pods-submittable .qtip{position:absolute;left:-28000px;top:-28000px;display:none;max-width:280px;min-width:50px;font-size:10.5px;line-height:12px;direction:ltr;box-shadow:none;padding:0}.pods-submittable .qtip-content{position:relative;padding:5px 9px;overflow:hidden;text-align:left;word-wrap:break-word}.pods-submittable .qtip-titlebar{position:relative;padding:5px 35px 5px 10px;overflow:hidden;border-width:0 0 1px;font-weight:700}.pods-submittable .qtip-titlebar+.qtip-content{border-top-width:0 !important}.pods-submittable .qtip-close{position:absolute;right:-9px;top:-9px;cursor:pointer;outline:medium none;border-width:1px;border-style:solid;border-color:transparent}.pods-submittable .qtip-titlebar .qtip-close{right:4px;top:50%;margin-top:-9px}.pods-submittable * html .qtip-titlebar .qtip-close{top:16px}.pods-submittable .qtip-titlebar .ui-icon,.pods-submittable .qtip-icon .ui-icon{display:block;text-indent:-1000em;direction:ltr}.pods-submittable .qtip-icon,.pods-submittable .qtip-icon .ui-icon{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;text-decoration:none}.pods-submittable .qtip-icon .ui-icon{width:18px;height:14px;line-height:14px;text-align:center;text-indent:0;font:400 bold 10px/13px Tahoma, sans-serif;color:inherit;background:transparent none no-repeat -100em -100em}.pods-submittable .qtip-default{border-width:1px;border-style:solid;border-color:#F1D031;background-color:#FFFFA3;color:#555}.pods-submittable .qtip-default .qtip-titlebar{background-color:#FFEF93}.pods-submittable .qtip-default .qtip-icon{border-color:#CCC;background:#F1F1F1;color:#777}.pods-submittable .qtip-default .qtip-titlebar .qtip-close{border-color:#AAA;color:#111}.pods-submittable .qtip-shadow{-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);-moz-box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15)}.pods-submittable .qtip-rounded,.pods-submittable .qtip-tipsy,.pods-submittable .qtip-bootstrap{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.pods-submittable .qtip-rounded .qtip-titlebar{-moz-border-radius:4px 4px 0 0;-webkit-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.pods-submittable .qtip-youtube{-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 3px #333;-moz-box-shadow:0 0 3px #333;box-shadow:0 0 3px #333;color:#fff;border-width:0;background:#4A4A4A;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #4A4A4A), color-stop(100%, #000));background-image:-webkit-linear-gradient(top, #4A4A4A 0, #000 100%);background-image:-moz-linear-gradient(top, #4A4A4A 0, #000 100%);background-image:-ms-linear-gradient(top, #4A4A4A 0, #000 100%);background-image:-o-linear-gradient(top, #4A4A4A 0, #000 100%)}.pods-submittable .qtip-youtube .qtip-titlebar{background-color:#4A4A4A;background-color:rgba(0,0,0,0)}.pods-submittable .qtip-youtube .qtip-content{padding:.75em;font:12px arial, sans-serif;filter:progid:DXImageTransform.Microsoft.Gradient( GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000 );-ms-filter:"progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);"}.pods-submittable .qtip-youtube .qtip-icon{border-color:#222}.pods-submittable .qtip-youtube .qtip-titlebar .ui-state-hover{border-color:#303030}.pods-submittable .qtip-jtools{background:#232323;background:rgba(0,0,0,0.7);background-image:-webkit-gradient(linear, left top, left bottom, from(#717171), to(#232323));background-image:-moz-linear-gradient(top, #717171, #232323);background-image:-webkit-linear-gradient(top, #717171, #232323);background-image:-ms-linear-gradient(top, #717171, #232323);background-image:-o-linear-gradient(top, #717171, #232323);border:2px solid #ddd;border:2px solid #f1f1f1;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 12px #333;-moz-box-shadow:0 0 12px #333;box-shadow:0 0 12px #333}.pods-submittable .qtip-jtools .qtip-titlebar{background-color:transparent;filter:progid:DXImageTransform.Microsoft.gradient( startColorstr=#717171, endColorstr=#4A4A4A );-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A)"}.pods-submittable .qtip-jtools .qtip-content{filter:progid:DXImageTransform.Microsoft.gradient( startColorstr=#4A4A4A, endColorstr=#232323 );-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323)"}.pods-submittable .qtip-jtools .qtip-titlebar,.pods-submittable .qtip-jtools .qtip-content{background:transparent;color:#fff;border:0 dashed transparent}.pods-submittable .qtip-jtools .qtip-icon{border-color:#555}.pods-submittable .qtip-jtools .qtip-titlebar .ui-state-hover{border-color:#333}.pods-submittable .qtip-cluetip{-webkit-box-shadow:4px 4px 5px rgba(0,0,0,0.4);-moz-box-shadow:4px 4px 5px rgba(0,0,0,0.4);box-shadow:4px 4px 5px rgba(0,0,0,0.4);background-color:#D9D9C2;color:#111;border:0 dashed transparent}.pods-submittable .qtip-cluetip .qtip-titlebar{background-color:#87876A;color:#fff;border:0 dashed transparent}.pods-submittable .qtip-cluetip .qtip-icon{border-color:#808064}.pods-submittable .qtip-cluetip .qtip-titlebar .ui-state-hover{border-color:#696952;color:#696952}.pods-submittable .qtip-tipsy{background:#000;background:rgba(0,0,0,0.87);color:#fff;border:0 solid transparent;font-size:11px;font-family:'Lucida Grande', sans-serif;font-weight:700;line-height:16px;text-shadow:0 1px #000}.pods-submittable .qtip-tipsy .qtip-titlebar{padding:6px 35px 0 10px;background-color:transparent}.pods-submittable .qtip-tipsy .qtip-content{padding:6px 10px}.pods-submittable .qtip-tipsy .qtip-icon{border-color:#222;text-shadow:none}.pods-submittable .qtip-tipsy .qtip-titlebar .ui-state-hover{border-color:#303030}.pods-submittable .qtip-tipped{border:3px solid #959FA9;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background-color:#F9F9F9;color:#454545;font-weight:400;font-family:serif}.pods-submittable .qtip-tipped .qtip-titlebar{border-bottom-width:0;color:#fff;background:#3A79B8;background-image:-webkit-gradient(linear, left top, left bottom, from(#3A79B8), to(#2E629D));background-image:-webkit-linear-gradient(top, #3A79B8, #2E629D);background-image:-moz-linear-gradient(top, #3A79B8, #2E629D);background-image:-ms-linear-gradient(top, #3A79B8, #2E629D);background-image:-o-linear-gradient(top, #3A79B8, #2E629D);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr=#3A79B8, endColorstr=#2E629D );-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D)"}.pods-submittable .qtip-tipped .qtip-icon{border:2px solid #285589;background:#285589}.pods-submittable .qtip-tipped .qtip-icon .ui-icon{background-color:#FBFBFB;color:#555}.pods-submittable .qtip-bootstrap{font-size:14px;line-height:20px;color:#333;padding:1px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.pods-submittable .qtip-bootstrap .qtip-titlebar{padding:8px 14px;margin:0;font-size:14px;font-weight:400;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.pods-submittable .qtip-bootstrap .qtip-titlebar .qtip-close{right:11px;top:45%;border-style:none}.pods-submittable .qtip-bootstrap .qtip-content{padding:9px 14px}.pods-submittable .qtip-bootstrap .qtip-icon{background:transparent}.pods-submittable .qtip-bootstrap .qtip-icon .ui-icon{width:auto;height:auto;float:right;font-size:20px;font-weight:700;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.pods-submittable .qtip-bootstrap .qtip-icon .ui-icon:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}.pods-submittable .qtip:not(.ie9haxors) div.qtip-content,.pods-submittable .qtip:not(.ie9haxors) div.qtip-titlebar{filter:none;-ms-filter:none}.pods-submittable .qtip .qtip-tip{margin:0 auto;overflow:hidden;z-index:10}.pods-submittable x:-o-prefocus,.pods-submittable .qtip .qtip-tip{visibility:hidden}.pods-submittable .qtip .qtip-tip,.pods-submittable .qtip .qtip-tip .qtip-vml,.pods-submittable .qtip .qtip-tip canvas{position:absolute;color:#123456;background:transparent;border:0 dashed transparent}.pods-submittable .qtip .qtip-tip canvas{top:0;left:0}.pods-submittable .qtip .qtip-tip .qtip-vml{behavior:url(#default#VML);display:inline-block;visibility:visible}.pods-submittable .cleditorMain{border:1px solid #999;padding:0 0 1px;background-color:white}.pods-submittable .cleditorMain iframe{border:none;margin:0;padding:0}.pods-submittable .cleditorMain textarea{border:none;margin:0;padding:0;overflow-y:scroll;font:10pt Arial,Verdana;resize:none;outline:none}.pods-submittable .cleditorToolbar{background-color:#f2f2f2;border-bottom:1px solid #999}.pods-submittable .cleditorGroup{float:left;height:26px}.pods-submittable .cleditorButton{float:left;width:24px;height:24px;margin:1px 0 1px 0;background:url("../../images/buttons.gif")}.pods-submittable .cleditorDisabled{opacity:0.3;filter:alpha(opacity=30)}.pods-submittable .cleditorDivider{float:left;width:1px;height:23px;margin:1px 0 1px 0;background:#CCC}.pods-submittable .cleditorPopup{border:solid 1px #999;background-color:white;position:absolute;font:10pt Arial,Verdana;cursor:default;z-index:10000}.pods-submittable .cleditorList div{padding:2px 4px 2px 4px}.pods-submittable .cleditorList p,.pods-submittable .cleditorList h1,.pods-submittable .cleditorList h2,.pods-submittable .cleditorList h3,.pods-submittable .cleditorList h4,.pods-submittable .cleditorList h5,.pods-submittable .cleditorList h6,.pods-submittable .cleditorList font{padding:0;margin:0;background-color:Transparent}.pods-submittable .cleditorColor{width:150px;padding:1px 0 0 1px}.pods-submittable .cleditorColor div{float:left;width:14px;height:14px;margin:0 1px 1px 0}.pods-submittable .cleditorPrompt{background-color:#F6F7F9;padding:4px;font-size:8.5pt}.pods-submittable .cleditorPrompt input,.pods-submittable .cleditorPrompt textarea{font:8.5pt Arial,Verdana}.pods-submittable .cleditorMsg{background-color:#FDFCEE;width:150px;padding:4px;font-size:8.5pt}.pods-submittable .pods-pick-values .select2-container .select2-selection--multiple .select2-selection__rendered{max-height:245px;overflow-y:scroll}.pods-qtip-container{display:inline}
 
 
1
+ @font-face{font-family:"pods";src:url("../../fonts/pods.eot");src:url("../../fonts/pods.eot?#iefix") format("embedded-opentype"),url("../../fonts/pods.woff") format("woff"),url("../../fonts/pods.ttf") format("truetype"),url("../../fonts/pods.svg#pods") format("svg");font-weight:normal;font-style:normal}[class^="pods-icon-"]:before,[class*=" pods-icon-"]:before{font-family:"pods" !important;font-style:normal !important;font-weight:normal !important;font-variant:normal !important;text-transform:none !important;speak:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.pods-icon-dashicon:before{content:"c"}#toplevel_page_pods .dashicons-before,#toplevel_page_pods .dashicons-before:before,.dashicons-pods:before{font-family:"pods" !important;font-size:20px;content:"c"}.pods-hidden{display:none}.pods-admin .pods-leaf-watermark-right{position:fixed;width:250px;bottom:-50px;right:-50px;z-index:-1;opacity:0.1}.pods-admin .pods_floatmenu{width:200px}.pods-admin .pods-icon{display:inline-block;padding:1px 0 0 5px;vertical-align:top}.icon32#icon-pods{background:url(../../images/icon32.png) no-repeat}.pods-admin .waiting{display:none;vertical-align:middle}.pods-admin button,.pods-admin a.button,.pods-admin a.button-secondary,.pods-admin a.button-primary{vertical-align:middle}.pods-admin .pods-validate.pods-validate-error{border-color:#C89797;color:#790000;background-color:#FFDFDF}.pods-admin .pods-validate-error-message{color:#790000;font-weight:bold;padding:5px 10px 4px;display:inline-block}.pods-admin .pods-advanced-toggle{font-size:12px;text-decoration:underline}.pods-admin .pods-advanced{display:none;width:100%}.pods-wizard p{font-size:14px}.pods-wizard #poststuff h1,.pods-wizard h2,.pods-wizard h3{margin-bottom:0 !important}.pods-admin #poststuff h3{font-size:14px;padding:8px 12px;margin:0;line-height:1.4}.pods-tabbed ul.pods-tabs:before{content:"";display:table}.pods-tabbed ul.pods-tabs:after{content:"";display:table;clear:both}.pods-tabbed ul.pods-tabs{zoom:1;margin-bottom:0}.pods-tabbed ul.pods-tabs li.pods-tab{float:left;margin:0}.pods-tabbed ul.pods-tabs li.pods-tab a{-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-moz-border-radius-topleft:5px;-moz-border-radius-topright:5px;-webkit-border-radius:5px 5px 0 0;background:#e9e9e9;border:1px solid #CCD0D4;border-radius:5px 5px 0 0;display:block;float:left;font-size:14px;margin-right:5px;padding:5px 10px;text-decoration:none}.pods-tabbed ul.pods-tabs li.pods-tab a.selected{background:#FFF;border-bottom:1px solid #FFF}.pods-tabbed .pods-tab-group h4{margin:5px 10px}.pods-tabbed .pods-tab-group .pods-tab{display:none;margin-bottom:15px;margin-top:-1px;width:99%;border:1px solid #CCD0D4;border-bottom:0}.pods-nav-tabbed .pods-nav-tab-group .pods-nav-tab{display:none}.pods-nav-tabbed .pods-nav-tab-group .pods-nav-tab.pods-submittable-fields{border:1px solid #CCD0D4;border-bottom:0}tbody.pods-manage-list div{overflow:hidden;zoom:1}tbody.pods-manage-list div.pods-manage-row-wrapper{max-width:500px;display:none;width:100%}tbody.pods-manage-list tr.pods-manage-row-expanded{background:#f1f1f1}tbody.pods-manage-list tr.pods-manage-row-expanded td.pods-manage-row-name,tbody.pods-manage-list tr.pods-manage-row-expanded td.pods-manage-row-type,tbody.pods-manage-list tr.pods-manage-row-expanded td.pods-manage-row-comment,tbody.pods-manage-list tr.pods-manage-row-expanded span.pods-manage-row-id,tbody.pods-manage-list tr.pods-manage-row-expanded div.row-actions,tbody.pods-manage-list tr.pods-manage-row-expanded th.pods-manage-sort img{display:none}tbody.pods-manage-list tr.pods-manage-row th.pods-manage-sort{cursor:move}tbody.pods-manage-list tr.pods-manage-row th.pods-manage-sort img{vertical-align:top;margin-top:7px;margin-left:-5px}tbody.pods-manage-list tr.pods-manage-row td>span.pods-manage-row-more{display:none;margin-left:5px;color:#999}tbody.pods-manage-list tr.pods-manage-row td:hover>span.pods-manage-row-more{display:inline}tbody.pods-manage-list tr div.pods-manage-row-wrapper .pods-manage-row-actions{margin-bottom:4px;overflow:visible}tbody.pods-manage-list tr div.pods-manage-row-wrapper .pods-manage-row-delete{float:left;text-align:left;width:40%}tbody.pods-manage-list tr div.pods-manage-row-wrapper .pods-manage-row-save{float:right;text-align:right}tbody.pods-manage-list tr.pods-field-new div.pods-manage-row-wrapper .pods-manage-row-delete a.submitdelete,tbody.pods-manage-list tr div.pods-manage-row-wrapper .pods-manage-row-save a.pods-button-add,tbody.pods-manage-list tr.pods-field-new div.pods-manage-row-wrapper .pods-manage-row-save a.pods-button-update{display:none}tbody.pods-manage-list tr.pods-field-new div.pods-manage-row-wrapper .pods-manage-row-save a.pods-button-add{display:inline-block}tbody.pods-manage-list .pods-manage-row th.check-field{border:5px solid transparent;border-right:0;padding:3px 5px;transition:border-color 300ms ease}tbody.pods-manage-list .pods-field-updated th.check-field{border-left-color:#95BF3B}tbody.pods-manage-list .pods-manage-row-expanded th.check-field,tbody.pods-manage-list .pods-field-new th.check-field{border-left-color:#E35036}.pods-toggled{clear:both;margin-top:30px}.pods-toggled.pods-toggled-only{margin-top:0}.pods-toggled h3{cursor:pointer}.pods-no-toggle h3{cursor:default}tr.pods-toggled-on{background-color:#FFF}tr.pods-toggled-off{background-color:#F4F4F4}.pods-depends-on,.pods-excludes-on,.pods-wildcard-on{display:none}.pods-tabbed div{overflow:hidden;zoom:1}.pods-tab.pods-basic-options{display:block}.pods-tab#pods-advanced-labels,.pods-tab#pods-advanced-settings-labels{display:block}div.pods-manage-field div{overflow:hidden;zoom:1}div.pods-manage-field .description{clear:both}div.pods-manage-field .pods-field-option,div.pods-manage-field .pods-field-option-group{background:#fcfcfc;border-bottom:1px solid #CCD0D4;padding:10px}div.pods-manage-field .pods-pick-values li,div.pods-manage-field .pods-field{position:relative}div.pods-manage-field .pods-pick-values li{margin:0}div.pods-manage-field .pods-field-option:nth-child(odd),div.pods-manage-field .pods-field-option-group:nth-child(odd){background:#fff}div.pods-manage-field .pods-field-option label,div.pods-manage-field .pods-field-option-group .pods-field-option-group-label{padding-top:4px;float:left;width:30%;max-width:150px;margin-right:2%}.pods-manage-field .pods-field.pods-boolean label,.pods-manage-field .pods-field-option .pods-pick-values label{float:none;width:auto;max-width:100%;display:block;margin-left:22px;padding:7px 0;line-height:14px;margin-right:0}.pods-manage-field .pods-field-option .pods-pick-values .pods-field.pods-boolean{float:none;margin-left:0;width:auto;max-width:100%}.pods-manage-field .pods-field-option input[type="text"],.pods-manage-field .pods-field-option select,.pods-manage-field .pods-field-option textarea,.pods-manage-field .pods-field-option .pods-field.pods-boolean,.pods-manage-field .pods-pick-values,.pods-manage-field .pods-field-option .pods-form-ui-field-type-file,.pods-manage-field .pods-slider-field{display:block;float:left;width:65%;max-width:25em}.pods-manage-field label+div .pods-pick-values{width:96%}.pods-manage-field .pods-field-option .pods-form-ui-field-type-wysiwyg textarea{max-width:100%}.pods-manage-field .pods-field-option div select{float:none;width:100%;margin:0;max-width:100%}.pods-manage-field .pods-field-option .pods-form-ui-field-type-file{padding-bottom:8px}.pods-manage-field .pods-field-option .pods-form-ui-field-type-file table.form-table tr.form-field td{padding:0;border-bottom:none}.pods-manage-field .pods-field-option .pods-form-ui-field-type-file table.form-table,.pods-manage-field .pods-field-option-group p.pods-field-option-group-label{margin-top:0}.pods-manage-field input[type="checkbox"],.pods-manage-field input[type="radio"]{display:inline-block;margin:6px 6px 6px 1px;float:left;vertical-align:middle;position:static}.pods-manage-field .pods-pick-values input[type="checkbox"],.pods-manage-field .pods-pick-values input[type="radio"]{margin:6px}.pods-manage-field .pods-pick-values ul{overflow:auto;margin:5px 0}.pods-manage-field .pods-pick-values ul .pods-field.pods-boolean,.pods-manage-field .pods-pick-values ul ul{margin:0}.pods-manage-field .pods-pick-values.pods-zebra{width:100%;max-width:100%}.pods-manage-field .pods-pick-values.pods-zebra li{margin-bottom:4px}.pods-manage-field .pods-pick-values.pods-zebra div.pods-boolean input{margin:4px}.pods-manage-field .pods-pick-values.pods-zebra div.pods-boolean label{margin-left:26px;padding:5px 0}.pods-manage-field .pods-pick-values li.pods-zebra-odd{display:block;width:50%;float:left;clear:both}.pods-manage-field .pods-pick-values li.pods-zebra-even{display:block;width:50%;float:left;clear:none}.pods-manage-field .pods-pick-values .regular-text{max-width:95%}.pods-manage-field li>.pods-field.pods-boolean:hover{background:#f5f5f5}.pods-manage-field input.pods-form-ui-no-label{position:relative}.pods-sluggable .pods-slug em{cursor:pointer}.pods-sluggable a.cancel{font-size:12px}.pods-sluggable .pods-slug-edit{display:none}.pods-admin ul.ul-disc span.resolved:before{content:"Resolved: ";background:green;color:white;padding:2px;border-radius:5px;margin-right:5px}.pods-manage-field .pods-dfv-field .pods-ui-file-list.pods-field-template-rows,.pods-manage-field .pods-dfv-field .pods-ui-list-autocomplete{width:65%;max-width:25em}tbody.pods-manage-list tr.flexible-row{display:none}.pods-admin .pods-float-right{float:right}.pods-admin p.pods-manage-row-add{text-align:right}div.row-actions.row-actions-toggle{display:block;visibility:visible}table.pods-admin{table-layout:fixed}#pods-rest-api label[for="pods-form-ui-no-dependencies"]{width:100%;max-width:initial}body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option input[type="text"],body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option select,body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option textarea,body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option .pods-field.pods-boolean,body[class*="settings_page_pods-"] .pods-manage-field .pods-pick-values,body[class*="settings_page_pods-"] .pods-manage-field .pods-field-option .pods-form-ui-field-type-file,body[class*="settings_page_pods-"] .pods-manage-field .pods-slider-field{float:none}@media only screen and (max-width: 850px){.pods-admin .pods_floatmenu{position:static !important;float:none;display:block;width:100%}.pods-admin .pods_floatmenu .inner-sidebar{float:none;width:auto}}@media screen and (max-width: 782px){.wp-list-table td.column-secondary{display:block !important;margin-top:-10px;margin-bottom:5px}.wp-list-table .is-expanded td.column-secondary{margin-top:0;margin-bottom:0}div.pods-manage-field .pods-field-option label,div.pods-manage-field .pods-field-option-group .pods-field-option-group-label{float:none;display:block;width:100%;max-width:none;padding-bottom:4px;margin-bottom:0;line-height:22px}.pods-manage-field .pods-field-option input[type="text"],.pods-manage-field .pods-field-option select,.pods-manage-field .pods-field-option textarea,.pods-manage-field .pods-field-option .pods-field.pods-boolean,.pods-manage-field .pods-pick-values,.pods-manage-field .pods-field-option .pods-form-ui-field-type-file,.pods-manage-field .pods-slider-field{display:block;margin:0;width:100%;max-width:none}.pods-manage-field .pods-field.pods-boolean label,.pods-manage-field .pods-field-option .pods-pick-values label{line-height:22px;font-size:14px;margin-left:34px}.pods-manage-field .pods-pick-values li.pods-zebra-odd,.pods-manage-field .pods-pick-values li.pods-zebra-even{display:block;width:100%;float:none;clear:both}}.pods-admin--flex{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.pods-admin--flex>*{flex-grow:1}.pods-admin_friends-callout_container{min-width:250px;width:100%;max-width:100%;border:1px solid #e5e5e5;border-bottom:5px solid #95bf3b;background:white;position:relative}@media (min-width: 851px){.pods-admin--flex{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row}.pods-admin_friends-callout_container{max-width:250px;margin-left:20px;margin-top:52px}}.pods-admin_friends-callout_logo-container{width:calc(100% - 40px);max-height:70px;background-color:#95BF3B;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;padding:23px 20px 20px}.pods-admin_friends-callout_logo-container svg{width:80%}.pods-admin_friends-callout_content-container{padding:0 20px 20px}.pods-admin_friends-callout_close{background:none;border:none;position:absolute;top:4px;right:5px;z-index:999;width:25px;height:25px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-transition:300ms ease background-color;-o-transition:300ms ease background-color;transition:300ms ease background-color;border-radius:100%}.pods-admin_friends-callout_close:hover{background-color:#85ab33;cursor:pointer}.pods-admin_friends-callout_close svg{width:15px;height:15px;display:block;fill:white;position:absolute;top:55%;left:50%;-webkit-transform:translate(-51%, -50%);-ms-transform:translate(-51%, -50%);transform:translate(-51%, -50%)}.pods-admin_friends-callout_logo{width:100%;max-width:175px}.pods-admin_friends-callout_headline{font-size:21px;line-height:1.3;font-weight:100;margin-bottom:.5em}.pods-admin_friends-callout_button-group{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.pods-admin_friends-callout_button{padding:0;color:#444;display:block;font-weight:600;-webkit-transition:300ms ease color;-o-transition:300ms ease color;transition:300ms ease color}.pods-admin_friends-callout_button:hover{color:#95bf3b}.pods-admin_friends-callout_button--join{padding:8px 10px;color:#444;background:#f6f6e8;display:block;text-align:center;-webkit-transition:300ms ease all;-o-transition:300ms ease all;transition:300ms ease all;font-weight:600;text-transform:uppercase;text-decoration:none;border:1px solid #f6f6e8}.pods-admin_friends-callout_button--join:hover{background:#ececce;color:#000}.pods-admin_friends-callout_button--join:last-child{background:#95bf3b;border:1px solid #f6f6e8;color:#f6f6e8}.pods-admin_friends-callout_button--join:last-child:hover{background:#85ab33;color:#fff}.pods-admin_friends-you{font-weight:700;font-size:24px}.pods-admin_friends-callout_date{display:block;font-size:70%}@media (min-width: 1600px){.pods-admin_friends-callout_container{margin-left:40px;margin-right:80px}}.dialogWithDropShadow{-webkit-box-shadow:0 0 10px rgba(0,0,0,0.5);-moz-box-shadow:0 0 10px rgba(0,0,0,0.5);box-shadow:0 0 10px rgba(0,0,0,0.5)}#pods-parts-right{width:250px;margin-right:10px}.pods-parts-icon{display:inline-block;padding:10px 0 10px 25px;text-decoration:none}.pods-parts-icon-edit{background:url(../../images/page_white_edit.png) left center no-repeat}.pods-parts-icon-add{background:url(../../images/bullet_add.png) left center no-repeat}#pods-parts-left{margin-right:-260px;width:100%}#pods-parts-content-editors{margin-right:280px}.editor-wide{width:100%;height:369px;background:#f6f6f6;color:#666}.editor-wide:focus{background:#f9f9f9;color:#333}#pods-parts-popup label{width:70px;display:block;float:left;text-align:right;margin-right:10px;clear:left;margin-top:3px;font-size:12px;font-family:Georgia;font-style:italic;color:#6c6c6c;letter-spacing:.2px}#pods-parts-popup input[type=text],#pods-parts-popup select{width:188px;margin-bottom:10px;font-size:12px;padding:2px}#pods-parts-popup input[type=text]{padding:5px}#pods-parts-popup .button-primary{float:right;text-align:center}#pods-parts-popup p{color:#858585}#pods-parts-popup .blue{display:block}#pods-parts-popup .blue a{color:#21759B;text-decoration:none;font-weight:bold}#pods-parts-popup .gray{color:#9c9c9c;font-size:11px}#pods-parts-popup table{padding:0;margin:0}#pods-parts-popup table td .bluehighlight{padding:4px 6px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;margin:5px 0}#pods-parts-popup table td .bluehighlight .actions{display:none;font-size:11px}#pods-parts-popup table td .bluehighlight .actions a{color:#21759B;text-decoration:none}#pods-parts-popup table td .bluehighlight .actions a.deletepodspart{color:#ff0000}#pods-parts-popup table td .bluehighlight .actions a:hover{text-decoration:underline}#pods-parts-popup table td .bluehighlight:hover{background:#f6f6f6}#pods-parts-popup table td .bluehighlight:hover .actions{display:inline;float:right;text-align:right}#ui-dialog-title-pods-parts-popup{font-family:Georgia !important;font-weight:normal}.button-secondary{text-align:center}.lightgraybackground{background:#f6f6f6;padding:2px 7px;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}#pods-parts-search{width:390px;float:left}#pods-parts-search label,#pods-parts-filter label,#pods-parts-display-per-page label{width:auto;margin-top:6px;font-family:Georgia;color:#6c6c6c;font-style:italic;letter-spacing:.5px}#pods-parts-display-per-page select{width:50px}#pods-parts-search .button-secondary{width:120px;margin-left:5px}#pods-parts-filter{width:320px;float:right;text-align:right}#pods-parts-filter select{width:115px}#pods-parts-filter .button-secondary{width:60px;margin-left:5px}.pods-parts-pagination .current-page{width:40px !important;margin:0 2px}.pods-parts-pagination a{margin:0 2px}ul.pods-dfv-list ul{list-style:none;margin:0;padding:0}ul.pods-dfv-list,.pods-dfv-field .pods-pick-values>ul{background:#fff;margin:0 0 5px 0;padding:0;border-radius:0;border:1px solid #dfdfdf;overflow:hidden;max-height:220px;overflow-y:auto}ul.pods-dfv-list:empty{display:none}ul.pods-dfv-list-meta{display:block;overflow:hidden;zoom:1;position:relative}ul.pods-dfv-list li.pods-dfv-list-col{float:left;margin:0;padding:0}ul.pods-dfv-list li.pods-dfv-list-icon{width:40px;margin:0 5px;height:32px;font-size:0;line-height:32px;text-align:center}ul.pods-dfv-list li.pods-dfv-list-icon img{display:inline-block;vertical-align:middle;float:none;border-radius:2px;margin:0;max-height:100%;width:auto}ul.pods-dfv-list li.pods-dfv-list-icon span.pinkynail{font-size:32px;width:32px;height:32px}ul.pods-dfv-list li.pods-dfv-list-handle{width:25px;height:32px;float:left;cursor:move}ul.pods-dfv-list li.pods-dfv-list-edit,ul.pods-dfv-list li.pods-dfv-list-link,ul.pods-dfv-list li.pods-dfv-list-download,ul.pods-dfv-list li.pods-dfv-list-remove{width:25px;height:32px;float:right}ul.pods-dfv-list li.pods-dfv-list-handle span,ul.pods-dfv-list li.pods-dfv-list-edit a,ul.pods-dfv-list li.pods-dfv-list-link a,ul.pods-dfv-list li.pods-dfv-list-download a,ul.pods-dfv-list li.pods-dfv-list-remove a{display:block;width:25px;height:32px;opacity:0.40;text-decoration:none;color:#616161}ul.pods-dfv-list li.pods-dfv-list-handle span:hover,ul.pods-dfv-list li.pods-dfv-list-edit a:hover,ul.pods-dfv-list li.pods-dfv-list-link a:hover,ul.pods-dfv-list li.pods-dfv-list-download a:hover,ul.pods-dfv-list li.pods-dfv-list-remove a:hover{opacity:1}ul.pods-dfv-list li.pods-dfv-list-handle span:focus,ul.pods-dfv-list li.pods-dfv-list-edit a:focus,ul.pods-dfv-list li.pods-dfv-list-link a:focus,ul.pods-dfv-list li.pods-dfv-list-download a:focus,ul.pods-dfv-list li.pods-dfv-list-remove a:focus{-webkit-box-shadow:none;box-shadow:none}ul.pods-dfv-list li.pods-dfv-list-handle span:before,ul.pods-dfv-list li.pods-dfv-list-edit a:before,ul.pods-dfv-list li.pods-dfv-list-link a:before,ul.pods-dfv-list li.pods-dfv-list-download a:before,ul.pods-dfv-list li.pods-dfv-list-remove a:before{margin:0 24px 0 -24px;font:400 20px/1 dashicons;line-height:32px}ul.pods-dfv-list li.pods-dfv-list-handle span:before{content:"\f156"}ul.pods-dfv-list li.pods-dfv-list-edit a:before{content:"\f464"}ul.pods-dfv-list li.pods-dfv-list-link a:before{content:"\f504"}ul.pods-dfv-list li.pods-dfv-list-download a:before{content:"\f316"}ul.pods-dfv-list li.pods-dfv-list-remove a:before{content:"\f158"}ul.pods-dfv-list li.pods-dfv-list-handle span,ul.pods-dfv-list li.pods-dfv-list-edit a,ul.pods-dfv-list li.pods-dfv-list-link a,ul.pods-dfv-list li.pods-dfv-list-download a,ul.pods-dfv-list li.pods-dfv-list-remove a{text-indent:100%;white-space:nowrap;overflow:hidden;box-shadow:none}ul.pods-dfv-list li.pods-dfv-list-name{position:absolute;left:80px;right:105px;padding:3px 0;line-height:24px;overflow:visible;white-space:nowrap}ul.pods-dfv-list li.pods-dfv-list-name input[type=text]{width:100% !important;font-size:1em;line-height:1;padding:.3vh 5px;margin:0}li.pods-dfv-list-item,.pods-pick-values li.pods-dfv-list-item{display:block;padding:6px 5px 6px 10px;margin:0;border-bottom:1px solid #efefef}li.pods-dfv-list-item:hover{background:#f5f5f5}li.pods-dfv-list-item:last-of-type{border-bottom:0}ul.pods-dfv-list-queue{margin:14px 0 5px}ul.pods-dfv-list-queue li.pods-dfv-list-name{position:relative;width:73%;left:auto;right:auto;padding-top:0}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress,ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress div.progress-bar{border-radius:10px;height:18px}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress{position:relative;width:23%;margin:2px 2% 0 0;background-color:#e8e8e8}ul.pods-dfv-list-queue li.pods-dfv-list-item li.pods-progress div.progress-bar{width:0;background-color:#1073AA}li.pods-dfv-list-item:after,ul.pods-dfv-list li.pods-dfv-list-item ul.pods-dfv-list-meta:after,ul.pods-dfv-list-queue li.pods-dfv-list-item:after,ul.pods-dfv-list-queue li.pods-dfv-list-item ul.pods-dfv-list-meta:after{content:"";display:table;clear:both}.pods-field-template-tiles ul.pods-dfv-list{max-height:500px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-item{display:inline-block;width:150px;border-bottom:0;padding:5px 10px 10px;vertical-align:top}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-icon{width:auto;float:none;margin:32px 0 0;max-height:150px;height:150px;line-height:150px;text-align:center}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle span:before{content:"\f545"}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-icon img{max-width:none;max-height:none;float:none;display:inline-block;vertical-align:middle;margin:0}form.pods-form .pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-name{position:static;float:none}form.pods-form .pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-name input[type=text]{margin:0;padding:.3vh 6px}.pods-dfv-field .select2-container .select2-selection--single{height:30px}.pods-dfv-field .select2-container--default .select2-selection--single .select2-selection__clear{height:28px;line-height:26px}.pods-dfv-field .select2-container--default .select2-selection--multiple .select2-selection__rendered li{background:none}.pods-dfv-field .select2-container--default .select2-selection--multiple .select2-selection__choice__remove{margin-right:5px;line-height:1;vertical-align:top}.pods-dfv-field .select2-container--default .select2-selection--multiple li.select2-selection__choice{padding:3px 5px;background-color:#f5f5f5;border-color:#dfdfdf;line-height:1.2;margin:5px 5px 5px 0}.pods-dfv-field .select2-container--default .select2-selection--multiple li.select2-selection__choice:hover{background-color:#fafafa;border-color:#bbb;cursor:move}.pods-dfv-field .pods-select2 .select2-container-multi .select2-choices .select2-search-field input{height:auto}.pods-dfv-field .select2-container--default .select2-selection--multiple{border-color:#ddd;border-radius:1px}.pods-dfv-field .select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#5b9dd9;-webkit-box-shadow:0 0 2px rgba(30,140,190,0.8);box-shadow:0 0 2px rgba(30,140,190,0.8)}.pods-pick-values .select2-container li{padding:0;line-height:inherit}.select2-container .select2-selection--multiple .select2-search--inline{float:none}.select2-container .select2-selection--multiple .select2-search--inline:first-child .select2-search__field{width:100% !important}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-edit,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-link,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-download,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-remove{position:absolute;top:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-handle{left:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-edit{right:75px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-link{right:50px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-download{right:25px}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-remove{right:0}ul.pods-dfv-list li.pods-dfv-list-actions{position:absolute;top:0;right:0}.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-edit,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-link,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-download,.pods-field-template-tiles ul.pods-dfv-list li.pods-dfv-list-actions li.pods-dfv-list-remove{position:static;float:right}a.pods-quick-add,span.pods-quick-add{display:block;line-height:36px;float:right;margin-right:15px}div.open a.pods-quick-add,div.open span.pods-quick-add{display:none}.pods-ui-field .pods-dfv-list-add{margin-bottom:10px}form.pods-manage ol.form-fields{list-style:none;padding-left:0;margin:0}form.pods-manage .chzn-container{display:block}form.pods-manage .pods-field label{cursor:pointer;display:inline-block;padding:0 0 4px 2px}form.pods-manage .pods-field input,form.pods-manage .pods-field textarea{display:block;width:100%}form.pods-manage .pods-field textarea{font-family:monospace;height:100%;resize:none}form.pods-manage .pods-field p.pods-field-comment{color:#aaa;font-size:.9em;font-style:italic;margin:5px 0 0 2px !important}form.pods-manage .pods-pick select{display:block;min-width:125px;padding:4px}form.pods-manage .pods-boolean{position:relative;cursor:pointer}form.pods-manage .pods-boolean input{display:block;height:auto;left:2px;margin:1px 7px 0 0;padding:0;position:absolute;top:10px;width:auto}form.pods-manage .pods-boolean label{margin-left:20px}form.pods-manage .pods-dfv-list-item label{padding-bottom:8px}form.pods-manage .pods-dfv-list-item input{display:none}form.pods-manage ul.pods-dfv-list{background:#fbfbfb;border:1px solid #dfdfdf;border-bottom:0;border-radius:3px;list-style:none;margin:0;padding:0}form.pods-manage ul.pods-dfv-list li{background:#fff;border-bottom:1px solid #dfdfdf;margin:0;position:relative;padding-bottom:10px}form.pods-manage ul.pods-dfv-list li span{display:inline-block;float:none}form.pods-manage ul.pods-dfv-list li span.pods-file-reorder{left:3px;position:absolute;top:15px;width:30px}form.pods-manage ul.pods-dfv-list li span.pods-file-reorder img{cursor:move;display:block}form.pods-manage ul.pods-dfv-list li span.pods-file-thumb{left:35px;position:absolute;top:2px;width:45px}form.pods-manage ul.pods-dfv-list li span.pods-file-thumb .pinkynail{float:none;margin:0;max-width:40px !important;max-height:40px !important}form.pods-manage ul.pods-dfv-list li span.pods-dfv-list-name{padding:11px 35px 0 85px}form.pods-manage ul.pods-dfv-list li span.pods-file-remove{position:absolute;right:10px;top:10px;width:25px}form.pods-manage ul.pods-dfv-list li span.pods-file-remove img{cursor:pointer;display:block}form.pods-manage .pods-pick-values{background:#fff;border:1px solid #dfdfdf;border-radius:3px;min-width:125px;overflow:auto;padding:2px 0}form.pods-manage .pods-pick-values ul{overflow:auto}form.pods-manage .pods-pick-values li{border-bottom:1px solid #f4f4f4;line-height:1em;margin:0;padding:3px 6px 2px}form.pods-manage .pods-pick-values li:nth-child(even){background:#fcfcfc}form.pods-manage .pods-pick-values label{padding-bottom:3px;padding-top:3px}form.pods-manage .pods-pick-values li:last-of-type{border-bottom:0}form.pods-manage .pods-pick-values li .pods-field{padding:3px 0 2px}form.pods-manage .pods-pick-values li .pods-boolean input{top:5px}form.pods-manage .pods-pick-values li:hover{background:#f5f5f5}form.pods-manage select.pods-pick-multi{height:auto !important}form.pods-manage .pods-field,form.pods-manage p.pods-add-file{clear:both;padding:10px 0}form.pods-manage .pods-textfield input,form.pods-manage .pods-textarea textarea{width:100%}form.pods-manage .pods-textfield input,form.pods-manage .pods-textarea textarea{padding:5px 7px;color:#808080}form.pods-manage .pods-textarea textarea{resize:vertical}form.pods-manage .pods-textfield input:focus,form.pods-manage .pods-textarea textarea:focus{border-color:#a0a0a0;box-shadow:0 0 5px rgba(0,0,0,0.1);color:#000}form.pods-manage .pods-date input,form.pods-manage .pods-number input{min-width:125px}form.pods-manage .pods-date input.pods-date-field.hasDatepicker{background:#fff url(../../images/calendar16.png) no-repeat 5px 5px;cursor:pointer;padding-left:25px !important;padding-top:6px !important;width:150px}form.pods-manage .pods-slider-field{margin:10px 0}form.pods-manage .pods-slider-field-display{padding:10px 0}form.pods-manage ul.ui-sortable li{cursor:move}form.pods-manage ul.ui-sortable li:hover{background:#f5f5f5;cursor:move}form.pods-manage ul.ui-sortable li:hover{background:#f5f5f5}form.pods-manage .ui-slider-handle{z-index:0 !important}form.pods-manage table.plupload-queue tr.hide{display:none}form.pods-manage table.plupload-queue td.progress{width:175px}form.pods-manage table.plupload-queue td.progress .progress-bar{width:0;height:14px;background:black}form.pods-manage .plupload-queue{width:250px}form.pods-manage .plupload-progress{position:relative}form.pods-manage .plupload-progress .progress-bar{position:absolute;height:14px;width:0%;background:#4d4d4d;margin-left:10px}form.pods-manage .plupload-progress .file-name{vertical-align:top}form.pods-manage .pods-inline-files li{margin-top:10px}form.pods-manage .pods-inline-files li .file-name{vertical-align:top !important}form.pods-manage .pods-inline-files li .remove{cursor:pointer}form.pods-manage .pods-inline-files .plupload-progress{width:150px}table.DMB_metabox td,table.DMB_metabox th{border-bottom:1px solid #f5f5f5}table.DMB_metabox th{text-align:right;font-weight:bold}table.DMB_metabox th label{margin-top:6px;display:block}p.DMB_metabox_description{color:#AAA;font-style:italic;margin:2px 0 !important}span.DMB_metabox_description{color:#AAA;font-style:italic}input.DMB_text_small{width:100px;margin-right:15px}input.DMB_text_money{width:90px;margin-right:15px}input.DMB_text_medium{width:230px;margin-right:15px}table.DMB_metabox input,table.DMB_metabox textarea{font-size:11px;padding:5px}table.DMB_metabox li{font-size:11px;float:left;width:25%;margin:0 10px}table.DMB_metabox ul{padding-top:5px}table.DMB_metabox select{font-size:11px;padding:5px 10px}table.DMB_metabox input:focus,table.DMB_metabox textarea:focus{background:#fffff8}.DMB_metabox_title{margin:0 0 5px 0;padding:5px 0 0 0;font:italic 24px/35px Georgia, "Times New Roman", "Bitstream Charter", Times, serif}.DMB_radio_inline{padding:4px 0 0 0}.DMB_radio_inline_option{display:inline;padding-right:18px}table.DMB_metabox input[type="radio"]{margin-right:3px}table.DMB_metabox input[type="checkbox"]{margin-right:6px}table.DMB_metabox .mceLayout{border:1px solid #DFDFDF !important}table.DMB_metabox .meta_mce{width:97%}table.DMB_metabox .meta_mce textarea{width:100%}table.DMB_metabox .DMB_upload_status{margin:10px 0 0 0}table.DMB_metabox .DMB_upload_status .img_status{position:relative}table.DMB_metabox .DMB_upload_status .img_status img{border:1px solid #DFDFDF;background:#FAFAFA;max-width:350px;padding:5px;-moz-border-radius:2px;border-radius:2px}table.DMB_metabox .DMB_upload_status .img_status .remove_file_button{text-indent:-9999px;width:16px;height:16px}table.DMB_metabox thead tr{border-bottom:1px solid #ccc}.pods-modal-window{margin-top:-32px}.pods-modal-window.edit-tags-php #col-left,.pods-modal-window.edit-tags-php #col-left input,.pods-modal-window.edit-tags-php #col-left textarea{width:100%}.pods-modal-window #wpadminbar,.pods-modal-window #adminmenuback,.pods-modal-window #adminmenuwrap,.pods-modal-window #preview-action,.pods-modal-window #wpfooter,.pods-modal-window body.edit-tags-php #col-right,.pods-modal-window body.edit-tags-php .search-form{display:none}.pods-modal-window #wpbody-content{padding-bottom:0}.pods-modal-window #wpcontent{padding:0;margin:0 1.25em}.pods-modal-window .wrap{margin:0}.pods-ui-filter-bar{margin:10px 0 20px}.pods-ui-filter-bar-primary{padding:8px 15px;background-color:#FFF;border:1px solid #CCD0D4;position:relative;height:auto;line-height:35px;text-shadow:0 1px 0 white;overflow:hidden;word-wrap:break-word}.pods-ui-filter-bar-primary ul.subsubsub{margin:0 0 0 4px}.pods-ui-filter-bar-primary ul.subsubsub li{margin-right:5px}.pods-ui-filter-bar-primary ul.subsubsub li.pods-ui-filter-view-label{margin-right:8px;color:#222;font-size:14px}.pods-ui-filter-bar-primary ul.subsubsub li a{text-decoration:none;font-size:12px;line-height:13px;padding:3px 10px;cursor:pointer;border-radius:3px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;border:1px solid #BBB;color:#464646;background:#F2F2F2;text-shadow:#fff 0 1px 0}.pods-ui-filter-bar-primary ul.subsubsub li a:hover{color:#000}.pods-ui-filter-bar-primary ul.subsubsub li a:active{background:#EEE}.pods-ui-filter-bar-primary ul.subsubsub li a.current{border:none;font-weight:bold;color:white;background:#21759B;text-shadow:rgba(0,0,0,0.3) 0 -1px 0}.pods-ui-filter-bar-primary ul.subsubsub li a.current:hover{border-color:#13455B}.pods-ui-filter-bar-primary ul.subsubsub li a.current:active{background:#21759B repeat-x scroll left top}.pods-ui-filter-bar-primary ul.subsubsub li a.current:hover,.pods-ui-filter-bar-primary ul.subsubsub li a.current:active{color:#EAF2FA}.pods-ui-filter-bar-primary ul.subsubsub li a span{font-size:11px}.pods-ui-filter-bar-primary ul.subsubsub li a.current span{color:#F7F7F7}.pods-ui-filter-bar-primary p.search-box{margin:0}.pods-ui-filter-bar-primary p.search-box a.pods-ui-filter-reset{margin-right:6px;font-size:11px}body.branch-3-5 .pods-ui-filter-bar-primary p.search-box input[name="s"]{float:none;line-height:24px}body.branch-3-5 .pods-ui-filter-bar-primary p.search-box input.button{float:none;line-height:23px}.pods-ui-filter-bar-secondary{margin:0 auto;width:97%;background:#e1ecf2;border:1px solid #c0d4e0;padding:6px 8px;text-align:right;-webkit-border-bottom-right-radius:8px;-webkit-border-bottom-left-radius:8px;-moz-border-radius-bottomright:8px;-moz-border-radius-bottomleft:8px;border-bottom-right-radius:8px;border-bottom-left-radius:8px}.pods-ui-filter-bar-secondary ul.subsubsub{margin:0;float:none}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-add-filter{margin-right:8px}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-add-filter a{font-size:13px;font-weight:normal}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter{text-decoration:none;font-size:12px;line-height:13px;margin-left:8px;padding:4px 12px;cursor:pointer;-webkit-border-radius:11px;border-radius:11px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;border:none;background:#21759B;text-shadow:rgba(0,0,0,0.3) 0 -1px 0}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter a{color:white}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:hover{border-color:#13455B}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:active{background:#21759B}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:hover a:hover,.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:active a{color:#EAF2FA}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter a.remove-filter{padding-left:7px;margin-left:3px;border-left:1px solid #888;text-transform:uppercase;font-size:11px;color:#CCC}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:hover a.remove-filter{color:#CCC}.pods-ui-filter-bar-secondary ul.subsubsub li.pods-ui-filter-bar-filter:hover a.remove-filter:hover{color:#CCC}.pods-ui-posts-filter-popup .pods-ui-posts-filters,.pods-ui-posts-filter-popup .pods-ui-posts-filters p.clear{clear:both}.pods-ui-posts-filter-popup label{display:block;margin-bottom:9px;font-weight:bold;font-size:15px;color:#282828;cursor:pointer}.pods-ui-posts-filter-popup .pods-ui-posts-filter label{margin:4px 0;font-size:13px}.pods-ui-posts-filter-popup .pods-ui-posts-filter-toggle{color:#2175A4;font-size:10px;line-height:15px;text-transform:uppercase;margin-left:9px;vertical-align:1px;float:right;cursor:pointer}.pods-ui-posts-filter-popup .pods-ui-posts-filter{clear:both;display:block;margin-bottom:4px}.pods-ui-posts-filter-popup .pods-ui-posts-filter.pods-hidden{display:none}.pods-ui-posts-filter-popup .pods-ui-posts-filter-toggle.toggle-on{font-size:14px}.pods-ui-posts-filter-popup .pods-ui-posts-filter-toggle:active,.pods-ui-posts-filter-popup .pods-ui-posts-filter-toggle:hover{color:#D54E21}.pods-ui-posts-filter-popup p{display:block;float:left;width:47%;margin:7px 0 20px 5%;border-bottom:1px solid #BABABA}.pods-ui-posts-filter-popup p.clear{margin-left:0}.pods-ui-posts-filter-popup p input,.pods-ui-posts-filter-popup p select,.pods-ui-posts-filter-popup p textarea{max-width:100%}.pods-ui-posts-filter-popup p input[type="text"],.pods-ui-posts-filter-popup p textarea{width:100%}.pods-ui-posts-filter-popup p.pods-ui-posts-filter-search{padding-bottom:0;border-bottom:none}.pods-ui-posts-filter-popup p.submit{margin-top:30px;padding:0 !important;border-bottom:none}body.branch-3-5 .pods-ui-posts-filter-popup p.submit{margin-top:36px}.pods-ui-posts-filter-popup p.submit.clear{clear:none;float:right;text-align:right}body.branch-3-4 .pods-ui-posts-filter-popup p.submit input.button{font-size:13px !important;padding:5px 32px}body.branch-3-5 .pods-ui-posts-filter-popup p.submit input.button{padding:0 32px}.pods-ui-posts-filter-popup p:after,.pods-ui-posts-filter-popup .pods-ui-posts-filters:after{content:".";display:block;height:0;clear:both;visibility:hidden}.pods-compat-container .CodeMirror{font-family:monospace;height:300px}.pods-compat-container .CodeMirror-scroll{overflow:auto}.pods-compat-container .CodeMirror-lines{padding:4px 0}.pods-compat-container .CodeMirror pre{padding:0 4px}.pods-compat-container .CodeMirror-scrollbar-filler,.pods-compat-container .CodeMirror-gutter-filler{background-color:white}.pods-compat-container .CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.pods-compat-container .CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;-moz-box-sizing:content-box;box-sizing:content-box}.pods-compat-container .CodeMirror-guttermarker{color:black}.pods-compat-container .CodeMirror-guttermarker-subtle{color:#999}.pods-compat-container .CodeMirror div.CodeMirror-cursor{border-left:1px solid black}.pods-compat-container .CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.pods-compat-container .CodeMirror.cm-fat-cursor div.CodeMirror-cursor{width:auto;border:0;background:#7e7}.pods-compat-container .CodeMirror.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.pods-compat-container .cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}@-moz-keyframes blink{0%{background:#7e7}50%{background:none}100%{background:#7e7}}@-webkit-keyframes blink{0%{background:#7e7}50%{background:none}100%{background:#7e7}}@keyframes blink{0%{background:#7e7}50%{background:none}100%{background:#7e7}}.pods-compat-container .cm-tab{display:inline-block;text-decoration:inherit}.pods-compat-container .CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.pods-compat-container .cm-s-default .cm-keyword{color:#708}.pods-compat-container .cm-s-default .cm-atom{color:#219}.pods-compat-container .cm-s-default .cm-number{color:#164}.pods-compat-container .cm-s-default .cm-def{color:#00f}.pods-compat-container .cm-s-default .cm-variable-2{color:#05a}.pods-compat-container .cm-s-default .cm-variable-3{color:#085}.pods-compat-container .cm-s-default .cm-comment{color:#a50}.pods-compat-container .cm-s-default .cm-string{color:#a11}.pods-compat-container .cm-s-default .cm-string-2{color:#f50}.pods-compat-container .cm-s-default .cm-meta{color:#555}.pods-compat-container .cm-s-default .cm-qualifier{color:#555}.pods-compat-container .cm-s-default .cm-builtin{color:#30a}.pods-compat-container .cm-s-default .cm-bracket{color:#997}.pods-compat-container .cm-s-default .cm-tag{color:#170}.pods-compat-container .cm-s-default .cm-attribute{color:#00c}.pods-compat-container .cm-s-default .cm-header{color:blue}.pods-compat-container .cm-s-default .cm-quote{color:#090}.pods-compat-container .cm-s-default .cm-hr{color:#999}.pods-compat-container .cm-s-default .cm-link{color:#00c}.pods-compat-container .cm-negative{color:#d44}.pods-compat-container .cm-positive{color:#292}.pods-compat-container .cm-header,.pods-compat-container .cm-strong{font-weight:bold}.pods-compat-container .cm-em{font-style:italic}.pods-compat-container .cm-link{text-decoration:underline}.pods-compat-container .cm-strikethrough{text-decoration:line-through}.pods-compat-container .cm-s-default .cm-error{color:#f00}.pods-compat-container .cm-invalidchar{color:#f00}.pods-compat-container div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}.pods-compat-container div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.pods-compat-container .CodeMirror-matchingtag{background:rgba(255,150,0,0.3)}.pods-compat-container .CodeMirror-activeline-background{background:#e8f2ff}.pods-compat-container .CodeMirror{background:none repeat scroll 0 0 white;color:black;line-height:1;margin:-6px -12px -12px;overflow:hidden;position:relative}.pods-compat-container .CodeMirror-scroll{margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:none;position:relative;-moz-box-sizing:content-box;box-sizing:content-box;z-index:0}.pods-compat-container .CodeMirror-sizer{position:relative;border-right:30px solid transparent;-moz-box-sizing:content-box;box-sizing:content-box}.pods-compat-container .CodeMirror-vscrollbar,.pods-compat-container .CodeMirror-hscrollbar,.pods-compat-container .CodeMirror-scrollbar-filler,.pods-compat-container .CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.pods-compat-container .CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.pods-compat-container .CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.pods-compat-container .CodeMirror-scrollbar-filler{right:0;bottom:0}.pods-compat-container .CodeMirror-gutter-filler{left:0;bottom:0}.pods-compat-container .CodeMirror-gutters{position:absolute;left:0;top:0;padding-bottom:30px;z-index:3}.pods-compat-container .CodeMirror-gutter{white-space:normal;height:100%;-moz-box-sizing:content-box;box-sizing:content-box;padding-bottom:30px;margin-bottom:-32px;display:inline-block;*zoom:1;*display:inline}.pods-compat-container .CodeMirror-gutter-wrapper{position:absolute;z-index:4;height:100%}.pods-compat-container .CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.pods-compat-container .CodeMirror-lines{cursor:text;min-height:1px}.pods-compat-container .CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:transparent;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible}.pods-compat-container .CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:break-all}.pods-compat-container .CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.pods-compat-container .CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.pods-compat-container .CodeMirror-wrap .CodeMirror-scroll{overflow-x:hidden}.pods-compat-container .CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.pods-compat-container .CodeMirror-measure pre{position:static}.pods-compat-container .CodeMirror div.CodeMirror-cursor{position:absolute;border-right:none;width:0}.pods-compat-container div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.pods-compat-container .CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.pods-compat-container .CodeMirror-selected{background:#d9d9d9}.pods-compat-container .CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.pods-compat-container .CodeMirror-crosshair{cursor:crosshair}.pods-compat-container .cm-searching{background:#ffa;background:rgba(255,255,0,0.4)}.pods-compat-container .CodeMirror span{*vertical-align:text-bottom}.pods-compat-container .cm-force-border{padding-right:.1px}@media print{.pods-compat-container .CodeMirror div.CodeMirror-cursors{visibility:hidden}}.pods-compat-container .cm-tab-wrap-hack:after{content:''}.pods-compat-container span.CodeMirror-selectedtext{background:none}.pods-compat-container .ui-timepicker-div .ui-widget-header{margin-bottom:8px}.pods-compat-container .ui-timepicker-div dl{text-align:left}.pods-compat-container .ui-timepicker-div dl dt{height:25px;margin-bottom:-25px}.pods-compat-container .ui-timepicker-div dl dd{margin:0 10px 10px 65px}.pods-compat-container .ui-timepicker-div td{font-size:90%}.pods-compat-container .ui-timepicker-div .ui_tpicker_unit_hide{display:none}.pods-compat-container .ui-timepicker-div .ui_tpicker_time_input{width:100%}.pods-compat-container .ui-tpicker-grid-label{background:none;border:none;margin:0;padding:0}.pods-compat-container .ui-timepicker-rtl{direction:rtl}.pods-compat-container .ui-timepicker-rtl dl{text-align:right}.pods-compat-container .ui-timepicker-rtl dl dd{margin:0 65px 10px 10px}.pods-compat-container .ui-helper-hidden{display:none}.pods-compat-container .ui-helper-hidden-accessible{position:absolute !important;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px)}.pods-compat-container .ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.pods-compat-container .ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.pods-compat-container .ui-helper-clearfix{display:inline-block}.pods-compat-container * html .ui-helper-clearfix{height:1%}.pods-compat-container .ui-helper-clearfix{display:block}.pods-compat-container .ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.pods-compat-container .ui-state-disabled{cursor:default !important}.pods-compat-container .ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.pods-compat-container .ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.pods-compat-container .ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.pods-compat-container .ui-widget .ui-widget{font-size:1em}.pods-compat-container .ui-widget input,.pods-compat-container .ui-widget select,.pods-compat-container .ui-widget textarea,.pods-compat-container .ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}.pods-compat-container .ui-widget-content{border:1px solid #aaaaaa;background:#fff url(../../images/smoothness/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;color:#222222}.pods-compat-container .ui-widget-content a{color:#222222}.pods-compat-container .ui-widget-header{border:1px solid #aaaaaa;background:#ccc url(../../images/smoothness/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;color:#222222;font-weight:bold}.pods-compat-container .ui-widget-header a{color:#222222}.pods-compat-container .ui-state-default,.pods-compat-container .ui-widget-content .ui-state-default,.pods-compat-container .ui-widget-header .ui-state-default{border:1px solid #d3d3d3;background:#e6e6e6 url(../../images/smoothness/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#555555}.pods-compat-container .ui-state-default a,.pods-compat-container .ui-state-default a:link,.pods-compat-container .ui-state-default a:visited{color:#555555;text-decoration:none}.pods-compat-container .ui-state-hover,.pods-compat-container .ui-widget-content .ui-state-hover,.pods-compat-container .ui-widget-header .ui-state-hover,.pods-compat-container .ui-state-focus,.pods-compat-container .ui-widget-content .ui-state-focus,.pods-compat-container .ui-widget-header .ui-state-focus{border:1px solid #999999;background:#dadada url(../../images/smoothness/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}.pods-compat-container .ui-state-hover a,.pods-compat-container .ui-state-hover a:hover{color:#212121;text-decoration:none}.pods-compat-container .ui-state-active,.pods-compat-container .ui-widget-content .ui-state-active,.pods-compat-container .ui-widget-header .ui-state-active{border:1px solid #aaaaaa;background:#fff url(../../images/smoothness/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}.pods-compat-container .ui-state-active a,.pods-compat-container .ui-state-active a:link,.pods-compat-container .ui-state-active a:visited{color:#212121;text-decoration:none}.pods-compat-container .ui-widget :active{outline:none}.pods-compat-container .ui-state-highlight,.pods-compat-container .ui-widget-content .ui-state-highlight,.pods-compat-container .ui-widget-header .ui-state-highlight{border:1px solid #fcefa1;background:#fbf9ee url(../../images/smoothness/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x;color:#363636}.pods-compat-container .ui-state-highlight a,.pods-compat-container .ui-widget-content .ui-state-highlight a,.pods-compat-container .ui-widget-header .ui-state-highlight a{color:#363636}.pods-compat-container .ui-state-error,.pods-compat-container .ui-widget-content .ui-state-error,.pods-compat-container .ui-widget-header .ui-state-error{border:1px solid #cd0a0a;background:#fef1ec url(../../images/smoothness/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x;color:#cd0a0a}.pods-compat-container .ui-state-error a,.pods-compat-container .ui-widget-content .ui-state-error a,.pods-compat-container .ui-widget-header .ui-state-error a{color:#cd0a0a}.pods-compat-container .ui-state-error-text,.pods-compat-container .ui-widget-content .ui-state-error-text,.pods-compat-container .ui-widget-header .ui-state-error-text{color:#cd0a0a}.pods-compat-container .ui-priority-primary,.pods-compat-container .ui-widget-content .ui-priority-primary,.pods-compat-container .ui-widget-header .ui-priority-primary{font-weight:bold}.pods-compat-container .ui-priority-secondary,.pods-compat-container .ui-widget-content .ui-priority-secondary,.pods-compat-container .ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.pods-compat-container .ui-state-disabled,.pods-compat-container .ui-widget-content .ui-state-disabled,.pods-compat-container .ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.pods-compat-container .ui-icon{width:16px;height:16px;background-image:url(../../images/smoothness/ui-icons_222222_256x240.png)}.pods-compat-container .ui-widget-content .ui-icon{background-image:url(../../images/smoothness/ui-icons_222222_256x240.png)}.pods-compat-container .ui-widget-header .ui-icon{background-image:url(../../images/smoothness/ui-icons_222222_256x240.png)}.pods-compat-container .ui-state-default .ui-icon{background-image:url(../../images/smoothness/ui-icons_888888_256x240.png)}.pods-compat-container .ui-state-hover .ui-icon,.pods-compat-container .ui-state-focus .ui-icon{background-image:url(../../images/smoothness/ui-icons_454545_256x240.png)}.pods-compat-container .ui-state-active .ui-icon{background-image:url(../../images/smoothness/ui-icons_454545_256x240.png)}.pods-compat-container .ui-state-highlight .ui-icon{background-image:url(../../images/smoothness/ui-icons_2e83ff_256x240.png)}.pods-compat-container .ui-state-error .ui-icon,.pods-compat-container .ui-state-error-text .ui-icon{background-image:url(../../images/smoothness/ui-icons_cd0a0a_256x240.png)}.pods-compat-container .ui-icon-carat-1-n{background-position:0 0}.pods-compat-container .ui-icon-carat-1-ne{background-position:-16px 0}.pods-compat-container .ui-icon-carat-1-e{background-position:-32px 0}.pods-compat-container .ui-icon-carat-1-se{background-position:-48px 0}.pods-compat-container .ui-icon-carat-1-s{background-position:-64px 0}.pods-compat-container .ui-icon-carat-1-sw{background-position:-80px 0}.pods-compat-container .ui-icon-carat-1-w{background-position:-96px 0}.pods-compat-container .ui-icon-carat-1-nw{background-position:-112px 0}.pods-compat-container .ui-icon-carat-2-n-s{background-position:-128px 0}.pods-compat-container .ui-icon-carat-2-e-w{background-position:-144px 0}.pods-compat-container .ui-icon-triangle-1-n{background-position:0 -16px}.pods-compat-container .ui-icon-triangle-1-ne{background-position:-16px -16px}.pods-compat-container .ui-icon-triangle-1-e{background-position:-32px -16px}.pods-compat-container .ui-icon-triangle-1-se{background-position:-48px -16px}.pods-compat-container .ui-icon-triangle-1-s{background-position:-64px -16px}.pods-compat-container .ui-icon-triangle-1-sw{background-position:-80px -16px}.pods-compat-container .ui-icon-triangle-1-w{background-position:-96px -16px}.pods-compat-container .ui-icon-triangle-1-nw{background-position:-112px -16px}.pods-compat-container .ui-icon-triangle-2-n-s{background-position:-128px -16px}.pods-compat-container .ui-icon-triangle-2-e-w{background-position:-144px -16px}.pods-compat-container .ui-icon-arrow-1-n{background-position:0 -32px}.pods-compat-container .ui-icon-arrow-1-ne{background-position:-16px -32px}.pods-compat-container .ui-icon-arrow-1-e{background-position:-32px -32px}.pods-compat-container .ui-icon-arrow-1-se{background-position:-48px -32px}.pods-compat-container .ui-icon-arrow-1-s{background-position:-64px -32px}.pods-compat-container .ui-icon-arrow-1-sw{background-position:-80px -32px}.pods-compat-container .ui-icon-arrow-1-w{background-position:-96px -32px}.pods-compat-container .ui-icon-arrow-1-nw{background-position:-112px -32px}.pods-compat-container .ui-icon-arrow-2-n-s{background-position:-128px -32px}.pods-compat-container .ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.pods-compat-container .ui-icon-arrow-2-e-w{background-position:-160px -32px}.pods-compat-container .ui-icon-arrow-2-se-nw{background-position:-176px -32px}.pods-compat-container .ui-icon-arrowstop-1-n{background-position:-192px -32px}.pods-compat-container .ui-icon-arrowstop-1-e{background-position:-208px -32px}.pods-compat-container .ui-icon-arrowstop-1-s{background-position:-224px -32px}.pods-compat-container .ui-icon-arrowstop-1-w{background-position:-240px -32px}.pods-compat-container .ui-icon-arrowthick-1-n{background-position:0 -48px}.pods-compat-container .ui-icon-arrowthick-1-ne{background-position:-16px -48px}.pods-compat-container .ui-icon-arrowthick-1-e{background-position:-32px -48px}.pods-compat-container .ui-icon-arrowthick-1-se{background-position:-48px -48px}.pods-compat-container .ui-icon-arrowthick-1-s{background-position:-64px -48px}.pods-compat-container .ui-icon-arrowthick-1-sw{background-position:-80px -48px}.pods-compat-container .ui-icon-arrowthick-1-w{background-position:-96px -48px}.pods-compat-container .ui-icon-arrowthick-1-nw{background-position:-112px -48px}.pods-compat-container .ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.pods-compat-container .ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.pods-compat-container .ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.pods-compat-container .ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.pods-compat-container .ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.pods-compat-container .ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.pods-compat-container .ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.pods-compat-container .ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.pods-compat-container .ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.pods-compat-container .ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.pods-compat-container .ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.pods-compat-container .ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.pods-compat-container .ui-icon-arrowreturn-1-w{background-position:-64px -64px}.pods-compat-container .ui-icon-arrowreturn-1-n{background-position:-80px -64px}.pods-compat-container .ui-icon-arrowreturn-1-e{background-position:-96px -64px}.pods-compat-container .ui-icon-arrowreturn-1-s{background-position:-112px -64px}.pods-compat-container .ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.pods-compat-container .ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.pods-compat-container .ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.pods-compat-container .ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.pods-compat-container .ui-icon-arrow-4{background-position:0 -80px}.pods-compat-container .ui-icon-arrow-4-diag{background-position:-16px -80px}.pods-compat-container .ui-icon-extlink{background-position:-32px -80px}.pods-compat-container .ui-icon-newwin{background-position:-48px -80px}.pods-compat-container .ui-icon-refresh{background-position:-64px -80px}.pods-compat-container .ui-icon-shuffle{background-position:-80px -80px}.pods-compat-container .ui-icon-transfer-e-w{background-position:-96px -80px}.pods-compat-container .ui-icon-transferthick-e-w{background-position:-112px -80px}.pods-compat-container .ui-icon-folder-collapsed{background-position:0 -96px}.pods-compat-container .ui-icon-folder-open{background-position:-16px -96px}.pods-compat-container .ui-icon-document{background-position:-32px -96px}.pods-compat-container .ui-icon-document-b{background-position:-48px -96px}.pods-compat-container .ui-icon-note{background-position:-64px -96px}.pods-compat-container .ui-icon-mail-closed{background-position:-80px -96px}.pods-compat-container .ui-icon-mail-open{background-position:-96px -96px}.pods-compat-container .ui-icon-suitcase{background-position:-112px -96px}.pods-compat-container .ui-icon-comment{background-position:-128px -96px}.pods-compat-container .ui-icon-person{background-position:-144px -96px}.pods-compat-container .ui-icon-print{background-position:-160px -96px}.pods-compat-container .ui-icon-trash{background-position:-176px -96px}.pods-compat-container .ui-icon-locked{background-position:-192px -96px}.pods-compat-container .ui-icon-unlocked{background-position:-208px -96px}.pods-compat-container .ui-icon-bookmark{background-position:-224px -96px}.pods-compat-container .ui-icon-tag{background-position:-240px -96px}.pods-compat-container .ui-icon-home{background-position:0 -112px}.pods-compat-container .ui-icon-flag{background-position:-16px -112px}.pods-compat-container .ui-icon-calendar{background-position:-32px -112px}.pods-compat-container .ui-icon-cart{background-position:-48px -112px}.pods-compat-container .ui-icon-pencil{background-position:-64px -112px}.pods-compat-container .ui-icon-clock{background-position:-80px -112px}.pods-compat-container .ui-icon-disk{background-position:-96px -112px}.pods-compat-container .ui-icon-calculator{background-position:-112px -112px}.pods-compat-container .ui-icon-zoomin{background-position:-128px -112px}.pods-compat-container .ui-icon-zoomout{background-position:-144px -112px}.pods-compat-container .ui-icon-search{background-position:-160px -112px}.pods-compat-container .ui-icon-wrench{background-position:-176px -112px}.pods-compat-container .ui-icon-gear{background-position:-192px -112px}.pods-compat-container .ui-icon-heart{background-position:-208px -112px}.pods-compat-container .ui-icon-star{background-position:-224px -112px}.pods-compat-container .ui-icon-link{background-position:-240px -112px}.pods-compat-container .ui-icon-cancel{background-position:0 -128px}.pods-compat-container .ui-icon-plus{background-position:-16px -128px}.pods-compat-container .ui-icon-plusthick{background-position:-32px -128px}.pods-compat-container .ui-icon-minus{background-position:-48px -128px}.pods-compat-container .ui-icon-minusthick{background-position:-64px -128px}.pods-compat-container .ui-icon-close{background-position:-80px -128px}.pods-compat-container .ui-icon-closethick{background-position:-96px -128px}.pods-compat-container .ui-icon-key{background-position:-112px -128px}.pods-compat-container .ui-icon-lightbulb{background-position:-128px -128px}.pods-compat-container .ui-icon-scissors{background-position:-144px -128px}.pods-compat-container .ui-icon-clipboard{background-position:-160px -128px}.pods-compat-container .ui-icon-copy{background-position:-176px -128px}.pods-compat-container .ui-icon-contact{background-position:-192px -128px}.pods-compat-container .ui-icon-image{background-position:-208px -128px}.pods-compat-container .ui-icon-video{background-position:-224px -128px}.pods-compat-container .ui-icon-script{background-position:-240px -128px}.pods-compat-container .ui-icon-alert{background-position:0 -144px}.pods-compat-container .ui-icon-info{background-position:-16px -144px}.pods-compat-container .ui-icon-notice{background-position:-32px -144px}.pods-compat-container .ui-icon-help{background-position:-48px -144px}.pods-compat-container .ui-icon-check{background-position:-64px -144px}.pods-compat-container .ui-icon-bullet{background-position:-80px -144px}.pods-compat-container .ui-icon-radio-off{background-position:-96px -144px}.pods-compat-container .ui-icon-radio-on{background-position:-112px -144px}.pods-compat-container .ui-icon-pin-w{background-position:-128px -144px}.pods-compat-container .ui-icon-pin-s{background-position:-144px -144px}.pods-compat-container .ui-icon-play{background-position:0 -160px}.pods-compat-container .ui-icon-pause{background-position:-16px -160px}.pods-compat-container .ui-icon-seek-next{background-position:-32px -160px}.pods-compat-container .ui-icon-seek-prev{background-position:-48px -160px}.pods-compat-container .ui-icon-seek-end{background-position:-64px -160px}.pods-compat-container .ui-icon-seek-start{background-position:-80px -160px}.pods-compat-container .ui-icon-seek-first{background-position:-80px -160px}.pods-compat-container .ui-icon-stop{background-position:-96px -160px}.pods-compat-container .ui-icon-eject{background-position:-112px -160px}.pods-compat-container .ui-icon-volume-off{background-position:-128px -160px}.pods-compat-container .ui-icon-volume-on{background-position:-144px -160px}.pods-compat-container .ui-icon-power{background-position:0 -176px}.pods-compat-container .ui-icon-signal-diag{background-position:-16px -176px}.pods-compat-container .ui-icon-signal{background-position:-32px -176px}.pods-compat-container .ui-icon-battery-0{background-position:-48px -176px}.pods-compat-container .ui-icon-battery-1{background-position:-64px -176px}.pods-compat-container .ui-icon-battery-2{background-position:-80px -176px}.pods-compat-container .ui-icon-battery-3{background-position:-96px -176px}.pods-compat-container .ui-icon-circle-plus{background-position:0 -192px}.pods-compat-container .ui-icon-circle-minus{background-position:-16px -192px}.pods-compat-container .ui-icon-circle-close{background-position:-32px -192px}.pods-compat-container .ui-icon-circle-triangle-e{background-position:-48px -192px}.pods-compat-container .ui-icon-circle-triangle-s{background-position:-64px -192px}.pods-compat-container .ui-icon-circle-triangle-w{background-position:-80px -192px}.pods-compat-container .ui-icon-circle-triangle-n{background-position:-96px -192px}.pods-compat-container .ui-icon-circle-arrow-e{background-position:-112px -192px}.pods-compat-container .ui-icon-circle-arrow-s{background-position:-128px -192px}.pods-compat-container .ui-icon-circle-arrow-w{background-position:-144px -192px}.pods-compat-container .ui-icon-circle-arrow-n{background-position:-160px -192px}.pods-compat-container .ui-icon-circle-zoomin{background-position:-176px -192px}.pods-compat-container .ui-icon-circle-zoomout{background-position:-192px -192px}.pods-compat-container .ui-icon-circle-check{background-position:-208px -192px}.pods-compat-container .ui-icon-circlesmall-plus{background-position:0 -208px}.pods-compat-container .ui-icon-circlesmall-minus{background-position:-16px -208px}.pods-compat-container .ui-icon-circlesmall-close{background-position:-32px -208px}.pods-compat-container .ui-icon-squaresmall-plus{background-position:-48px -208px}.pods-compat-container .ui-icon-squaresmall-minus{background-position:-64px -208px}.pods-compat-container .ui-icon-squaresmall-close{background-position:-80px -208px}.pods-compat-container .ui-icon-grip-dotted-vertical{background-position:0 -224px}.pods-compat-container .ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.pods-compat-container .ui-icon-grip-solid-vertical{background-position:-32px -224px}.pods-compat-container .ui-icon-grip-solid-horizontal{background-position:-48px -224px}.pods-compat-container .ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.pods-compat-container .ui-icon-grip-diagonal-se{background-position:-80px -224px}.pods-compat-container .ui-corner-all,.pods-compat-container .ui-corner-top,.pods-compat-container .ui-corner-left,.pods-compat-container .ui-corner-tl{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px}.pods-compat-container .ui-corner-all,.pods-compat-container .ui-corner-top,.pods-compat-container .ui-corner-right,.pods-compat-container .ui-corner-tr{-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;-khtml-border-top-right-radius:4px;border-top-right-radius:4px}.pods-compat-container .ui-corner-all,.pods-compat-container .ui-corner-bottom,.pods-compat-container .ui-corner-left,.pods-compat-container .ui-corner-bl{-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;-khtml-border-bottom-left-radius:4px;border-bottom-left-radius:4px}.pods-compat-container .ui-corner-all,.pods-compat-container .ui-corner-bottom,.pods-compat-container .ui-corner-right,.pods-compat-container .ui-corner-br{-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;-khtml-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.pods-compat-container .ui-widget-overlay{background:#aaa url(../../images/smoothness/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.30;filter:Alpha(Opacity=30)}.pods-compat-container .ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaa url(../../images/smoothness/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.30;filter:Alpha(Opacity=30);-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}.pods-compat-container .ui-resizable{position:relative}.pods-compat-container .ui-resizable-handle{position:absolute;font-size:0.1px;z-index:99999;display:block}.pods-compat-container .ui-resizable-disabled .ui-resizable-handle,.pods-compat-container .ui-resizable-autohide .ui-resizable-handle{display:none}.pods-compat-container .ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.pods-compat-container .ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.pods-compat-container .ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.pods-compat-container .ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.pods-compat-container .ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.pods-compat-container .ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.pods-compat-container .ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.pods-compat-container .ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.pods-compat-container .ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.pods-compat-container .ui-accordion{width:100%}.pods-compat-container .ui-accordion .ui-accordion-header{cursor:pointer;position:relative;margin-top:1px;zoom:1}.pods-compat-container .ui-accordion .ui-accordion-li-fix{display:inline}.pods-compat-container .ui-accordion .ui-accordion-header-active{border-bottom:0 !important}.pods-compat-container .ui-accordion .ui-accordion-header a{display:block;font-size:1em;padding:.5em .5em .5em .7em}.pods-compat-container .ui-accordion-icons .ui-accordion-header a{padding-left:2.2em}.pods-compat-container .ui-accordion .ui-accordion-header .ui-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.pods-compat-container .ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;margin-top:-2px;position:relative;top:1px;margin-bottom:2px;overflow:auto;display:none;zoom:1}.pods-compat-container .ui-accordion .ui-accordion-content-active{display:block}.pods-compat-container .ui-autocomplete{position:absolute;cursor:default}.pods-compat-container * html .ui-autocomplete{width:1px}.pods-compat-container .ui-menu{list-style:none;padding:2px;margin:0;display:block;float:left}.pods-compat-container .ui-menu .ui-menu{margin-top:-3px}.pods-compat-container .ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;float:left;clear:left;width:100%}.pods-compat-container .ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:.2em .4em;line-height:1.5;zoom:1}.pods-compat-container .ui-menu .ui-menu-item a.ui-state-hover,.pods-compat-container .ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.pods-compat-container .ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;text-decoration:none !important;cursor:pointer;text-align:center;zoom:1;overflow:visible}.pods-compat-container .ui-button-icon-only{width:2.2em}.pods-compat-container button.ui-button-icon-only{width:2.4em}.pods-compat-container .ui-button-icons-only{width:3.4em}.pods-compat-container button.ui-button-icons-only{width:3.7em}.pods-compat-container .ui-button .ui-button-text{display:block;line-height:1.4}.pods-compat-container .ui-button-text-only .ui-button-text{padding:.4em 1em}.pods-compat-container .ui-button-icon-only .ui-button-text,.pods-compat-container .ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.pods-compat-container .ui-button-text-icon-primary .ui-button-text,.pods-compat-container .ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.pods-compat-container .ui-button-text-icon-secondary .ui-button-text,.pods-compat-container .ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.pods-compat-container .ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}.pods-compat-container input.ui-button{padding:.4em 1em}.pods-compat-container .ui-button-icon-only .ui-icon,.pods-compat-container .ui-button-text-icon-primary .ui-icon,.pods-compat-container .ui-button-text-icon-secondary .ui-icon,.pods-compat-container .ui-button-text-icons .ui-icon,.pods-compat-container .ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.pods-compat-container .ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.pods-compat-container .ui-button-text-icon-primary .ui-button-icon-primary,.pods-compat-container .ui-button-text-icons .ui-button-icon-primary,.pods-compat-container .ui-button-icons-only .ui-button-icon-primary{left:.5em}.pods-compat-container .ui-button-text-icon-secondary .ui-button-icon-secondary,.pods-compat-container .ui-button-text-icons .ui-button-icon-secondary,.pods-compat-container .ui-button-icons-only .ui-button-icon-secondary{right:.5em}.pods-compat-container .ui-button-text-icons .ui-button-icon-secondary,.pods-compat-container .ui-button-icons-only .ui-button-icon-secondary{right:.5em}.pods-compat-container .ui-buttonset{margin-right:7px}.pods-compat-container .ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}.pods-compat-container button.ui-button::-moz-focus-inner{border:0;padding:0}.pods-compat-container .ui-dialog{position:absolute;padding:.2em;width:300px;overflow:hidden}.pods-compat-container .ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.pods-compat-container .ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.pods-compat-container .ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.pods-compat-container .ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.pods-compat-container .ui-dialog .ui-dialog-titlebar-close:hover,.pods-compat-container .ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.pods-compat-container .ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto;zoom:1}.pods-compat-container .ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.pods-compat-container .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.pods-compat-container .ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.pods-compat-container .ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.pods-compat-container .ui-draggable .ui-dialog-titlebar{cursor:move}.pods-compat-container .ui-slider{position:relative;text-align:left}.pods-compat-container .ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.pods-compat-container .ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.pods-compat-container .ui-slider-horizontal{height:.8em}.pods-compat-container .ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.pods-compat-container .ui-slider-horizontal .ui-slider-range{top:0;height:100%}.pods-compat-container .ui-slider-horizontal .ui-slider-range-min{left:0}.pods-compat-container .ui-slider-horizontal .ui-slider-range-max{right:0}.pods-compat-container .ui-slider-vertical{width:.8em;height:100px}.pods-compat-container .ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.pods-compat-container .ui-slider-vertical .ui-slider-range{left:0;width:100%}.pods-compat-container .ui-slider-vertical .ui-slider-range-min{bottom:0}.pods-compat-container .ui-slider-vertical .ui-slider-range-max{top:0}.pods-compat-container .ui-tabs{position:relative;padding:.2em;zoom:1}.pods-compat-container .ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.pods-compat-container .ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:1px;margin:0 .2em 1px 0;border-bottom:0 !important;padding:0;white-space:nowrap}.pods-compat-container .ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.pods-compat-container .ui-tabs .ui-tabs-nav li.ui-tabs-selected{margin-bottom:0;padding-bottom:1px}.pods-compat-container .ui-tabs .ui-tabs-nav li.ui-tabs-selected a,.pods-compat-container .ui-tabs .ui-tabs-nav li.ui-state-disabled a,.pods-compat-container .ui-tabs .ui-tabs-nav li.ui-state-processing a{cursor:text}.pods-compat-container .ui-tabs .ui-tabs-nav li a,.pods-compat-container .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a{cursor:pointer}.pods-compat-container .ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none}.pods-compat-container .ui-tabs .ui-tabs-hide{display:none !important}.pods-compat-container .ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.pods-compat-container .ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.pods-compat-container .ui-datepicker .ui-datepicker-prev,.pods-compat-container .ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.pods-compat-container .ui-datepicker .ui-datepicker-prev-hover,.pods-compat-container .ui-datepicker .ui-datepicker-next-hover{top:1px}.pods-compat-container .ui-datepicker .ui-datepicker-prev{left:2px}.pods-compat-container .ui-datepicker .ui-datepicker-next{right:2px}.pods-compat-container .ui-datepicker .ui-datepicker-prev-hover{left:1px}.pods-compat-container .ui-datepicker .ui-datepicker-next-hover{right:1px}.pods-compat-container .ui-datepicker .ui-datepicker-prev span,.pods-compat-container .ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.pods-compat-container .ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.pods-compat-container .ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.pods-compat-container .ui-datepicker select.ui-datepicker-month-year{width:100%}.pods-compat-container .ui-datepicker select.ui-datepicker-month,.pods-compat-container .ui-datepicker select.ui-datepicker-year{width:49%}.pods-compat-container .ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.pods-compat-container .ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.pods-compat-container .ui-datepicker td{border:0;padding:1px}.pods-compat-container .ui-datepicker td span,.pods-compat-container .ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.pods-compat-container .ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.pods-compat-container .ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.pods-compat-container .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.pods-compat-container .ui-datepicker.ui-datepicker-multi{width:auto}.pods-compat-container .ui-datepicker-multi .ui-datepicker-group{float:left}.pods-compat-container .ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.pods-compat-container .ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.pods-compat-container .ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.pods-compat-container .ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.pods-compat-container .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.pods-compat-container .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.pods-compat-container .ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.pods-compat-container .ui-datepicker-row-break{clear:both;width:100%;font-size:0}.pods-compat-container .ui-datepicker-rtl{direction:rtl}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-group{float:right}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.pods-compat-container .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.pods-compat-container .ui-datepicker-cover{display:none;display/**/:block;position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px}.pods-compat-container .ui-progressbar{height:2em;text-align:left}.pods-compat-container .ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.pods-submittable .qtip{position:absolute;left:-28000px;top:-28000px;display:none;max-width:280px;min-width:50px;font-size:10.5px;line-height:12px;direction:ltr;box-shadow:none;padding:0}.pods-submittable .qtip-content{position:relative;padding:5px 9px;overflow:hidden;text-align:left;word-wrap:break-word}.pods-submittable .qtip-titlebar{position:relative;padding:5px 35px 5px 10px;overflow:hidden;border-width:0 0 1px;font-weight:700}.pods-submittable .qtip-titlebar+.qtip-content{border-top-width:0 !important}.pods-submittable .qtip-close{position:absolute;right:-9px;top:-9px;cursor:pointer;outline:medium none;border-width:1px;border-style:solid;border-color:transparent}.pods-submittable .qtip-titlebar .qtip-close{right:4px;top:50%;margin-top:-9px}.pods-submittable * html .qtip-titlebar .qtip-close{top:16px}.pods-submittable .qtip-titlebar .ui-icon,.pods-submittable .qtip-icon .ui-icon{display:block;text-indent:-1000em;direction:ltr}.pods-submittable .qtip-icon,.pods-submittable .qtip-icon .ui-icon{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;text-decoration:none}.pods-submittable .qtip-icon .ui-icon{width:18px;height:14px;line-height:14px;text-align:center;text-indent:0;font:400 bold 10px/13px Tahoma, sans-serif;color:inherit;background:transparent none no-repeat -100em -100em}.pods-submittable .qtip-default{border-width:1px;border-style:solid;border-color:#F1D031;background-color:#FFFFA3;color:#555}.pods-submittable .qtip-default .qtip-titlebar{background-color:#FFEF93}.pods-submittable .qtip-default .qtip-icon{border-color:#CCC;background:#F1F1F1;color:#777}.pods-submittable .qtip-default .qtip-titlebar .qtip-close{border-color:#AAA;color:#111}.pods-submittable .qtip-shadow{-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);-moz-box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15);box-shadow:1px 1px 3px 1px rgba(0,0,0,0.15)}.pods-submittable .qtip-rounded,.pods-submittable .qtip-tipsy,.pods-submittable .qtip-bootstrap{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.pods-submittable .qtip-rounded .qtip-titlebar{-moz-border-radius:4px 4px 0 0;-webkit-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.pods-submittable .qtip-youtube{-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 3px #333;-moz-box-shadow:0 0 3px #333;box-shadow:0 0 3px #333;color:#fff;border-width:0;background:#4A4A4A;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #4A4A4A), color-stop(100%, #000));background-image:-webkit-linear-gradient(top, #4A4A4A 0, #000 100%);background-image:-moz-linear-gradient(top, #4A4A4A 0, #000 100%);background-image:-ms-linear-gradient(top, #4A4A4A 0, #000 100%);background-image:-o-linear-gradient(top, #4A4A4A 0, #000 100%)}.pods-submittable .qtip-youtube .qtip-titlebar{background-color:#4A4A4A;background-color:rgba(0,0,0,0)}.pods-submittable .qtip-youtube .qtip-content{padding:.75em;font:12px arial, sans-serif;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);-ms-filter:"progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);"}.pods-submittable .qtip-youtube .qtip-icon{border-color:#222}.pods-submittable .qtip-youtube .qtip-titlebar .ui-state-hover{border-color:#303030}.pods-submittable .qtip-jtools{background:#232323;background:rgba(0,0,0,0.7);background-image:-webkit-gradient(linear, left top, left bottom, from(#717171), to(#232323));background-image:-moz-linear-gradient(top, #717171, #232323);background-image:-webkit-linear-gradient(top, #717171, #232323);background-image:-ms-linear-gradient(top, #717171, #232323);background-image:-o-linear-gradient(top, #717171, #232323);border:2px solid #ddd;border:2px solid #f1f1f1;-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 12px #333;-moz-box-shadow:0 0 12px #333;box-shadow:0 0 12px #333}.pods-submittable .qtip-jtools .qtip-titlebar{background-color:transparent;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A)"}.pods-submittable .qtip-jtools .qtip-content{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323)"}.pods-submittable .qtip-jtools .qtip-titlebar,.pods-submittable .qtip-jtools .qtip-content{background:transparent;color:#fff;border:0 dashed transparent}.pods-submittable .qtip-jtools .qtip-icon{border-color:#555}.pods-submittable .qtip-jtools .qtip-titlebar .ui-state-hover{border-color:#333}.pods-submittable .qtip-cluetip{-webkit-box-shadow:4px 4px 5px rgba(0,0,0,0.4);-moz-box-shadow:4px 4px 5px rgba(0,0,0,0.4);box-shadow:4px 4px 5px rgba(0,0,0,0.4);background-color:#D9D9C2;color:#111;border:0 dashed transparent}.pods-submittable .qtip-cluetip .qtip-titlebar{background-color:#87876A;color:#fff;border:0 dashed transparent}.pods-submittable .qtip-cluetip .qtip-icon{border-color:#808064}.pods-submittable .qtip-cluetip .qtip-titlebar .ui-state-hover{border-color:#696952;color:#696952}.pods-submittable .qtip-tipsy{background:#000;background:rgba(0,0,0,0.87);color:#fff;border:0 solid transparent;font-size:11px;font-family:'Lucida Grande', sans-serif;font-weight:700;line-height:16px;text-shadow:0 1px #000}.pods-submittable .qtip-tipsy .qtip-titlebar{padding:6px 35px 0 10px;background-color:transparent}.pods-submittable .qtip-tipsy .qtip-content{padding:6px 10px}.pods-submittable .qtip-tipsy .qtip-icon{border-color:#222;text-shadow:none}.pods-submittable .qtip-tipsy .qtip-titlebar .ui-state-hover{border-color:#303030}.pods-submittable .qtip-tipped{border:3px solid #959FA9;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background-color:#F9F9F9;color:#454545;font-weight:400;font-family:serif}.pods-submittable .qtip-tipped .qtip-titlebar{border-bottom-width:0;color:#fff;background:#3A79B8;background-image:-webkit-gradient(linear, left top, left bottom, from(#3A79B8), to(#2E629D));background-image:-webkit-linear-gradient(top, #3A79B8, #2E629D);background-image:-moz-linear-gradient(top, #3A79B8, #2E629D);background-image:-ms-linear-gradient(top, #3A79B8, #2E629D);background-image:-o-linear-gradient(top, #3A79B8, #2E629D);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D)"}.pods-submittable .qtip-tipped .qtip-icon{border:2px solid #285589;background:#285589}.pods-submittable .qtip-tipped .qtip-icon .ui-icon{background-color:#FBFBFB;color:#555}.pods-submittable .qtip-bootstrap{font-size:14px;line-height:20px;color:#333;padding:1px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.pods-submittable .qtip-bootstrap .qtip-titlebar{padding:8px 14px;margin:0;font-size:14px;font-weight:400;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.pods-submittable .qtip-bootstrap .qtip-titlebar .qtip-close{right:11px;top:45%;border-style:none}.pods-submittable .qtip-bootstrap .qtip-content{padding:9px 14px}.pods-submittable .qtip-bootstrap .qtip-icon{background:transparent}.pods-submittable .qtip-bootstrap .qtip-icon .ui-icon{width:auto;height:auto;float:right;font-size:20px;font-weight:700;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.pods-submittable .qtip-bootstrap .qtip-icon .ui-icon:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}.pods-submittable .qtip:not(.ie9haxors) div.qtip-content,.pods-submittable .qtip:not(.ie9haxors) div.qtip-titlebar{filter:none;-ms-filter:none}.pods-submittable .qtip .qtip-tip{margin:0 auto;overflow:hidden;z-index:10}.pods-submittable x:-o-prefocus,.pods-submittable .qtip .qtip-tip{visibility:hidden}.pods-submittable .qtip .qtip-tip,.pods-submittable .qtip .qtip-tip .qtip-vml,.pods-submittable .qtip .qtip-tip canvas{position:absolute;color:#123456;background:transparent;border:0 dashed transparent}.pods-submittable .qtip .qtip-tip canvas{top:0;left:0}.pods-submittable .qtip .qtip-tip .qtip-vml{behavior:url(#default#VML);display:inline-block;visibility:visible}.pods-submittable .cleditorMain{border:1px solid #999;padding:0 0 1px;background-color:white}.pods-submittable .cleditorMain iframe{border:none;margin:0;padding:0}.pods-submittable .cleditorMain textarea{border:none;margin:0;padding:0;overflow-y:scroll;font:10pt Arial,Verdana;resize:none;outline:none}.pods-submittable .cleditorToolbar{background-color:#f2f2f2;border-bottom:1px solid #999}.pods-submittable .cleditorGroup{float:left;height:26px}.pods-submittable .cleditorButton{float:left;width:24px;height:24px;margin:1px 0 1px 0;background:url("../../images/buttons.gif")}.pods-submittable .cleditorDisabled{opacity:0.3;filter:alpha(opacity=30)}.pods-submittable .cleditorDivider{float:left;width:1px;height:23px;margin:1px 0 1px 0;background:#CCC}.pods-submittable .cleditorPopup{border:solid 1px #999;background-color:white;position:absolute;font:10pt Arial,Verdana;cursor:default;z-index:10000}.pods-submittable .cleditorList div{padding:2px 4px 2px 4px}.pods-submittable .cleditorList p,.pods-submittable .cleditorList h1,.pods-submittable .cleditorList h2,.pods-submittable .cleditorList h3,.pods-submittable .cleditorList h4,.pods-submittable .cleditorList h5,.pods-submittable .cleditorList h6,.pods-submittable .cleditorList font{padding:0;margin:0;background-color:Transparent}.pods-submittable .cleditorColor{width:150px;padding:1px 0 0 1px}.pods-submittable .cleditorColor div{float:left;width:14px;height:14px;margin:0 1px 1px 0}.pods-submittable .cleditorPrompt{background-color:#F6F7F9;padding:4px;font-size:8.5pt}.pods-submittable .cleditorPrompt input,.pods-submittable .cleditorPrompt textarea{font:8.5pt Arial,Verdana}.pods-submittable .cleditorMsg{background-color:#FDFCEE;width:150px;padding:4px;font-size:8.5pt}.pods-submittable .pods-pick-values .select2-container .select2-selection--multiple .select2-selection__rendered{max-height:245px;overflow-y:scroll}.pods-qtip-container{display:inline}
2
+
3
+ /*# sourceMappingURL=../src/sourcemaps/pods.css.map */
vendor/freemius/wordpress-sdk/LICENSE.txt ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ {one line to give the program's name and a brief idea of what it does.}
635
+ Copyright (C) {year} {name of author}
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ {project} Copyright (C) {year} {fullname}
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <http://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <http://www.gnu.org/philosophy/why-not-lgpl.html>.
vendor/freemius/wordpress-sdk/assets/css/admin/account.css ADDED
@@ -0,0 +1 @@
 
1
+ label.fs-tag,span.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}#fs_account .postbox,#fs_account .widefat{max-width:800px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account h3 .dashicons{width:26px;height:26px;font-size:1.3em}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}#fs_account_details .button-group{float:right}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}.fs-field-beta_program label{margin-left:7px}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_sites .fs-scrollable-table .fs-table-body{max-height:200px;overflow:auto;border:1px solid #e5e5e5}#fs_sites .fs-scrollable-table .fs-table-body>table.widefat{border:none !important}#fs_sites .fs-scrollable-table .fs-main-column{width:100%}#fs_sites .fs-scrollable-table .fs-site-details td:first-of-type{text-align:right;color:grey;width:1px}#fs_sites .fs-scrollable-table .fs-site-details td:last-of-type{text-align:right}#fs_sites .fs-scrollable-table .fs-install-details table tr td{width:1px;white-space:nowrap}#fs_sites .fs-scrollable-table .fs-install-details table tr td:last-of-type{width:auto}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons thead{white-space:nowrap}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}
vendor/freemius/wordpress-sdk/assets/css/admin/add-ons.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ .fs-badge{position:absolute;top:10px;right:0;background:#71ae00;color:white;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3)}#fs_addons .fs-cards-list{list-style:none}#fs_addons .fs-cards-list .fs-card{float:left;height:152px;width:310px;padding:0;margin:0 0 30px 30px;font-size:14px;list-style:none;border:1px solid #ddd;cursor:pointer;position:relative}#fs_addons .fs-cards-list .fs-card .fs-overlay{position:absolute;left:0;right:0;bottom:0;top:0;z-index:9}#fs_addons .fs-cards-list .fs-card .fs-inner{background-color:#fff;overflow:hidden;height:100%;position:relative}#fs_addons .fs-cards-list .fs-card .fs-inner>ul{-moz-transition:all,0.15s;-o-transition:all,0.15s;-ms-transition:all,0.15s;-webkit-transition:all,0.15s;transition:all,0.15s;left:0;right:0;top:0;position:absolute}#fs_addons .fs-cards-list .fs-card .fs-inner>ul>li{list-style:none;line-height:18px;padding:0 15px;width:100%;display:block;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-card-banner{padding:0;margin:0;line-height:0;display:block;height:100px;background-repeat:repeat-x;background-size:100% 100%;-moz-transition:all,0.15s;-o-transition:all,0.15s;-ms-transition:all,0.15s;-webkit-transition:all,0.15s;transition:all,0.15s}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-card-banner .fs-badge.fs-installed-addon-badge{font-size:1.02em;line-height:1.3em}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-title{margin:10px 0 0 0;height:18px;overflow:hidden;color:#000;white-space:nowrap;text-overflow:ellipsis;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-offer{font-size:0.9em}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-description{background-color:#f9f9f9;padding:10px 15px 100px 15px;border-top:1px solid #eee;margin:0 0 10px 0;color:#777}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-tag{position:absolute;top:10px;right:0px;background:greenyellow;display:block;padding:2px 10px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.3);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.3);box-shadow:1px 1px 1px rgba(0,0,0,0.3);text-transform:uppercase;font-size:0.9em;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-cta .button,#fs_addons .fs-cards-list .fs-card .fs-inner .fs-cta .button-group{position:absolute;top:112px;right:10px}@media screen and (min-width: 960px){#fs_addons .fs-cards-list .fs-card:hover .fs-overlay{border:2px solid #29abe1;margin-left:-1px;margin-top:-1px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner ul{top:-100px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-title,#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-offer{color:#29abe1}}
2
+ #TB_window,#TB_window iframe{width:821px !important}#plugin-information .fyi{width:266px !important}#plugin-information #section-holder{margin-right:299px}#plugin-information #section-description h2,#plugin-information #section-description h3,#plugin-information #section-description p,#plugin-information #section-description b,#plugin-information #section-description i,#plugin-information #section-description blockquote,#plugin-information #section-description li,#plugin-information #section-description ul,#plugin-information #section-description ol{clear:none}#plugin-information #section-description .fs-selling-points{padding-bottom:10px;border-bottom:1px solid #ddd}#plugin-information #section-description .fs-selling-points ul{margin:0}#plugin-information #section-description .fs-selling-points ul li{padding:0;list-style:none outside none}#plugin-information #section-description .fs-selling-points ul li i.dashicons{color:#71ae00;font-size:3em;vertical-align:middle;line-height:30px;float:left;margin:0 0 0 -15px}#plugin-information #section-description .fs-selling-points ul li h3{margin:1em 30px !important}#plugin-information #section-description .fs-screenshots:after{content:"";display:table;clear:both}#plugin-information #section-description .fs-screenshots ul{list-style:none;margin:0}#plugin-information #section-description .fs-screenshots ul li{width:225px;height:225px;float:left;margin-bottom:20px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}#plugin-information #section-description .fs-screenshots ul li a{display:block;width:100%;height:100%;border:1px solid;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);background-size:cover}#plugin-information #section-description .fs-screenshots ul li.odd{margin-right:20px}#plugin-information .plugin-information-pricing{margin:-16px;border-bottom:1px solid #ddd}#plugin-information .plugin-information-pricing .fs-plan h3{margin-top:0;padding:20px;font-size:16px}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper{border-bottom:1px solid #ddd}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab{cursor:pointer;position:relative;padding:0 10px;font-size:0.9em}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab label{text-transform:uppercase;color:green;background:greenyellow;position:absolute;left:-1px;right:-1px;bottom:100%;border:1px solid darkgreen;padding:2px;text-align:center;font-size:0.9em;line-height:1em}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab.nav-tab-active{cursor:default;background:#fffeec;border-bottom-color:#fffeec}#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle h3{background:#fffeec;margin:0;padding-bottom:0;color:#0073aa}#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle .nav-tab-wrapper,#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle .fs-billing-frequency{display:none}#plugin-information .plugin-information-pricing .fs-plan .fs-pricing-body{background:#fffeec;padding:20px}#plugin-information .plugin-information-pricing .fs-plan .button{width:100%;text-align:center;font-weight:bold;text-transform:uppercase;font-size:1.1em}#plugin-information .plugin-information-pricing .fs-plan label{white-space:nowrap}#plugin-information .plugin-information-pricing .fs-plan var{font-style:normal}#plugin-information .plugin-information-pricing .fs-plan .fs-billing-frequency,#plugin-information .plugin-information-pricing .fs-plan .fs-annual-discount{text-align:center;display:block;font-weight:bold;margin-bottom:10px;text-transform:uppercase;background:#F3F3F3;padding:2px;border:1px solid #ccc}#plugin-information .plugin-information-pricing .fs-plan .fs-annual-discount{text-transform:none;color:green;background:greenyellow}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms{font-size:0.9em}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms i{float:left;margin:0 0 0 -15px}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms li{margin:10px 0 0 0}#plugin-information #section-features .fs-features{margin:-20px -26px}#plugin-information #section-features table{width:100%;border-spacing:0;border-collapse:separate}#plugin-information #section-features table thead th{padding:10px 0}#plugin-information #section-features table thead .fs-price{color:#71ae00;font-weight:normal;display:block;text-align:center}#plugin-information #section-features table tbody td{border-top:1px solid #ccc;padding:10px 0;text-align:center;width:100px;color:#71ae00}#plugin-information #section-features table tbody td:first-child{text-align:left;width:auto;color:inherit;padding-left:26px}#plugin-information #section-features table tbody tr.fs-odd td{background:#fefefe}#plugin-information #section-features .dashicons-yes{width:30px;height:30px;font-size:30px}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .button,#plugin-information .fs-dropdown .button-group .button{position:relative;width:auto;top:0;right:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .button:focus,#plugin-information .fs-dropdown .button-group .button:focus{z-index:10}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .fs-dropdown-arrow,#plugin-information .fs-dropdown .button-group .fs-dropdown-arrow{border-top:6px solid white;border-right:4px solid transparent;border-left:4px solid transparent;top:12px;position:relative}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active:not(.up) .button:not(.fs-dropdown-arrow-button),#plugin-information .fs-dropdown.active:not(.up) .button:not(.fs-dropdown-arrow-button){border-bottom-left-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active:not(.up) .fs-dropdown-arrow-button,#plugin-information .fs-dropdown.active:not(.up) .fs-dropdown-arrow-button{border-bottom-right-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active.up .button:not(.fs-dropdown-arrow-button),#plugin-information .fs-dropdown.active.up .button:not(.fs-dropdown-arrow-button){border-top-left-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active.up .fs-dropdown-arrow-button,#plugin-information .fs-dropdown.active.up .fs-dropdown-arrow-button{border-top-right-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list,#plugin-information .fs-dropdown .fs-dropdown-list{position:absolute;right:-1px;top:100%;margin-left:auto;padding:3px 0;border:1px solid #bfbfbf;background-color:#fff;z-index:1;width:230px;text-align:left;-moz-box-shadow:0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);-webkit-box-shadow:0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);box-shadow:0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li,#plugin-information .fs-dropdown .fs-dropdown-list li{margin:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li a,#plugin-information .fs-dropdown .fs-dropdown-list li a{display:block;padding:5px 10px;text-decoration:none;text-shadow:none}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li:hover,#plugin-information .fs-dropdown .fs-dropdown-list li:hover{background-color:#0074a3;color:#fff}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li:hover a,#plugin-information .fs-dropdown .fs-dropdown-list li:hover a{color:#fff}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown:not(.up) .fs-dropdown-list,#plugin-information .fs-dropdown:not(.up) .fs-dropdown-list{-moz-border-radius:3px 0 3px 3px;-webkit-border-radius:3px 0 3px 3px;border-radius:3px 0 3px 3px}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.up .fs-dropdown-list,#plugin-information .fs-dropdown.up .fs-dropdown-list{-moz-border-radius:3px 3px 0 3px;-webkit-border-radius:3px 3px 0 3px;border-radius:3px 3px 0 3px}#plugin-information .fs-dropdown .button-group{width:100%}#plugin-information .fs-dropdown .button-group .button{float:none;font-size:14px;font-weight:normal;text-transform:none}#plugin-information .fs-dropdown .fs-dropdown-list{margin-top:1px}#plugin-information .fs-dropdown.up .fs-dropdown-list{top:auto;bottom:100%;margin-bottom:2px}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group{text-align:center;display:table}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group .button{display:table-cell}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group .button:not(.fs-dropdown-arrow-button){left:1px;width:100%}#plugin-information-footer>.button,#plugin-information-footer .fs-dropdown{position:relative;top:3px}#plugin-information-footer>.button.left,#plugin-information-footer .fs-dropdown.left{float:left}#plugin-information-footer>.right,#plugin-information-footer .fs-dropdown{float:right}@media screen and (max-width: 961px){#fs_addons .fs-cards-list .fs-card{height:265px}}
vendor/freemius/wordpress-sdk/assets/css/admin/affiliation.css ADDED
@@ -0,0 +1 @@
 
1
+ @charset "UTF-8";#fs_affiliation_content_wrapper #messages{margin-top:25px}#fs_affiliation_content_wrapper h3{font-size:24px;padding:0;margin-left:0}#fs_affiliation_content_wrapper ul li{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;list-style-type:none}#fs_affiliation_content_wrapper ul li:before{content:'✓';margin-right:10px;font-weight:bold}#fs_affiliation_content_wrapper p:not(.description),#fs_affiliation_content_wrapper li,#fs_affiliation_content_wrapper label{font-size:16px !important;line-height:26px !important}#fs_affiliation_content_wrapper .button{margin-top:20px;margin-bottom:7px;line-height:35px;height:40px;font-size:16px}#fs_affiliation_content_wrapper .button#cancel_button{margin-right:5px}#fs_affiliation_content_wrapper form .input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form .input-container .input-label{font-weight:bold;display:block;width:100%}#fs_affiliation_content_wrapper form .input-container.input-container-text label,#fs_affiliation_content_wrapper form .input-container.input-container-text input,#fs_affiliation_content_wrapper form .input-container.input-container-text textarea{display:block}#fs_affiliation_content_wrapper form .input-container #add_domain,#fs_affiliation_content_wrapper form .input-container .remove-domain{text-decoration:none;display:inline-block;margin-top:3px}#fs_affiliation_content_wrapper form .input-container #add_domain:focus,#fs_affiliation_content_wrapper form .input-container .remove-domain:focus{box-shadow:none}#fs_affiliation_content_wrapper form .input-container #add_domain.disabled,#fs_affiliation_content_wrapper form .input-container .remove-domain.disabled{color:#aaa;cursor:default}#fs_affiliation_content_wrapper form #extra_domains_container .description{margin-top:0;position:relative;top:-4px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain{display:inline-block;margin-right:5px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain:last-of-type{margin-bottom:0}
vendor/freemius/wordpress-sdk/assets/css/admin/checkout.css ADDED
@@ -0,0 +1 @@
 
1
+ @media screen and (max-width: 782px){#wpbody-content{padding-bottom:0 !important}}
vendor/freemius/wordpress-sdk/assets/css/admin/common.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ .fs-badge{position:absolute;top:10px;right:0;background:#71ae00;color:white;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3)}.theme-browser .theme .fs-premium-theme-badge-container{position:absolute;right:0;top:0}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge{position:relative;top:0;margin-top:10px;text-align:center}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-premium-theme-badge{font-size:1.1em}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-beta-theme-badge{background:#00a0d2}.fs-switch{position:relative;display:inline-block;color:#ccc;text-shadow:0 1px 1px rgba(255,255,255,0.8);height:18px;padding:6px 6px 5px 6px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);background:#ececec;box-shadow:0 0 4px rgba(0,0,0,0.1),inset 0 1px 3px 0 rgba(0,0,0,0.1);cursor:pointer}.fs-switch span{display:inline-block;width:35px;text-transform:uppercase}.fs-switch .fs-toggle{position:absolute;top:1px;width:37px;height:25px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.3);border-radius:4px;background:#fff;background-color:#fff;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #ececec), color-stop(1, #fff));background-image:-webkit-linear-gradient(top, #ececec, #fff);background-image:-moz-linear-gradient(top, #ececec, #fff);background-image:-ms-linear-gradient(top, #ececec, #fff);background-image:-o-linear-gradient(top, #ececec, #fff);background-image:linear-gradient(top, bottom, #ececec, #fff);box-shadow:inset 0 1px 0 0 rgba(255,255,255,0.5);z-index:999;-moz-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-o-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-ms-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);-webkit-transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1);transition:0.4s cubic-bezier(0.54, 1.6, 0.5, 1)}.fs-switch.fs-off .fs-toggle{left:2%}.fs-switch.fs-on .fs-toggle{left:54%}.fs-switch.fs-round{top:8px;padding:4px 25px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round .fs-toggle{top:0;width:24px;height:24px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round.fs-off .fs-toggle{left:-1px}.fs-switch.fs-round.fs-on{background:#0085ba}.fs-switch.fs-round.fs-on .fs-toggle{left:25px}.fs-switch.fs-small.fs-round{padding:1px 19px}.fs-switch.fs-small.fs-round .fs-toggle{top:0;width:18px;height:18px;-moz-border-radius:18px;-webkit-border-radius:18px;border-radius:18px}.fs-switch.fs-small.fs-round.fs-on .fs-toggle{left:19px}.fs-switch-feedback{margin-left:10px}.fs-switch-feedback.success{color:#71ae00}.rtl .fs-switch-feedback{margin-left:0;margin-right:10px}#fs_frame{line-height:0;font-size:0}.fs-full-size-wrapper{margin:40px 0 -65px -20px}@media (max-width: 600px){.fs-full-size-wrapper{margin:0 0 -65px -10px}}
2
+ .fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;top:100%;bottom:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}div.fs-notice.updated,div.fs-notice.success,div.fs-notice.promotion{display:block !important}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;-moz-box-shadow:0 2px 2px rgba(6,113,6,0.3);-webkit-box-shadow:0 2px 2px rgba(6,113,6,0.3);box-shadow:0 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}.fs-secure-notice a.fs-security-proof{color:green;text-decoration:none}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 600px){.fs-secure-notice{display:none}}@media screen and (max-width: 500px){#fs_promo_tab{display:none}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}.fs-submenu-item.pricing.upgrade-mode{color:greenyellow}.fs-submenu-item.pricing.trial-mode{color:#83e2ff}#adminmenu .update-plugins.fs-trial{background-color:#00b9eb}.fs-ajax-spinner{border:0;width:20px;height:20px;margin-right:5px;vertical-align:sub;display:inline-block;background:url("/wp-admin/images/wpspin_light-2x.gif");background-size:contain;margin-bottom:-2px}.wrap.fs-section h2{text-align:left}.plugins p.fs-upgrade-notice{border:0;background-color:#d54e21;padding:10px;color:#f9f9f9;margin-top:10px}
vendor/freemius/wordpress-sdk/assets/css/admin/connect.css ADDED
@@ -0,0 +1 @@
 
1
+ #fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content .fs-error{background:snow;color:#d3135a;border:1px solid #d3135a;-moz-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);text-align:center;padding:5px;margin-bottom:10px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-license-key-container{position:relative;width:280px;margin:10px auto 0 auto}#fs_connect .fs-license-key-container input{width:100%}#fs_connect .fs-license-key-container .dashicons{position:absolute;top:5px;right:5px}#fs_connect.require-license-key .fs-sites-list-container td{cursor:pointer}#fs_connect #delegate_to_site_admins{margin-right:15px;float:right;height:26px;vertical-align:middle;line-height:37px;font-weight:bold;border-bottom:1px dashed;text-decoration:none}#fs_connect #delegate_to_site_admins.rtl{margin-left:15px;margin-right:0}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-primary:after{content:' \279C'}#fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-license-sync-disclaimer{text-align:center;margin-top:0}#fs_connect .fs-permissions .fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li .fs-switch{float:right}#fs_connect .fs-permissions ul li .fs-permission-description{margin-left:55px}#fs_connect .fs-permissions ul li .fs-permission-description span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li .fs-permission-description p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-freemium-licensing{padding:8px;background:#777;color:#fff}#fs_connect .fs-freemium-licensing p{text-align:center;display:block;margin:0;padding:0}#fs_connect .fs-freemium-licensing a{color:#C2EEFF;text-decoration:underline}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}.fs-multisite-options-container{margin-top:10px;border:1px solid #ccc;padding:5px}.fs-multisite-options-container a{text-decoration:none}.fs-multisite-options-container a:focus{box-shadow:none}.fs-multisite-options-container a.selected{font-weight:bold}.fs-multisite-options-container.fs-apply-on-all-sites{border:0 none;padding:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options{border-spacing:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options td:not(:first-child){display:none}.fs-multisite-options-container .fs-sites-list-container{display:none;overflow:auto}.fs-multisite-options-container .fs-sites-list-container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-tooltip-trigger{position:relative}.fs-tooltip-trigger:not(a){cursor:help}.fs-tooltip-trigger .fs-tooltip{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:rgba(0,0,0,0.8);color:#fff;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:0;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left}.rtl .fs-tooltip-trigger .fs-tooltip{text-align:right}.fs-tooltip-trigger .fs-tooltip::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:rgba(0,0,0,0.8) transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl .fs-tooltip-trigger .fs-tooltip::after{right:21px;left:auto}.fs-tooltip-trigger:hover .fs-tooltip{visibility:visible;opacity:1}#fs_marketing_optin{display:none;margin-top:10px;border:1px solid #ccc;padding:10px;line-height:1.5em}#fs_marketing_optin .fs-message{display:block;margin-bottom:5px;font-size:1.05em;font-weight:600}#fs_marketing_optin.error{border:1px solid #d3135a;background:#fee}#fs_marketing_optin.error .fs-message{color:#d3135a}#fs_marketing_optin .fs-input-container{margin-top:5px}#fs_marketing_optin .fs-input-container label{margin-top:5px;display:block}#fs_marketing_optin .fs-input-container label input{float:left;margin:1px 0 0 0}#fs_marketing_optin .fs-input-container label:first-child{display:block;margin-bottom:2px}#fs_marketing_optin .fs-input-label{display:block;margin-left:20px}#fs_marketing_optin .fs-input-label .underlined{text-decoration:underline}.rtl #fs_marketing_optin .fs-input-container label input{float:right}.rtl #fs_marketing_optin .fs-input-label{margin-left:0;margin-right:20px}.rtl #fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}.rtl #fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}.rtl #fs_connect .fs-actions .button.button-primary:after{content:' \000bb'}.rtl #fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}.rtl #fs_connect .fs-actions .button.button-secondary{float:left}.rtl #fs_connect .fs-permissions ul li .fs-permission-description{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li .fs-switch{float:left}.rtl #fs_connect .fs-permissions ul li i.dashicons{float:right}.rtl #fs_connect .fs-visual .fs-site-icon{right:20px;left:auto}.rtl #fs_connect .fs-visual .fs-connect-logo{right:auto;left:20px}#fs_theme_connect_wrapper{position:fixed;top:0;height:100%;width:100%;z-index:99990;background:rgba(0,0,0,0.75);text-align:center;overflow-y:auto}#fs_theme_connect_wrapper:before{content:"";display:inline-block;vertical-align:middle;height:100%}#fs_theme_connect_wrapper>button.close{color:white;cursor:pointer;height:40px;width:40px;position:absolute;right:0;border:0;background-color:transparent;top:32px}#fs_theme_connect_wrapper #fs_connect{top:0;text-align:left;display:inline-block;vertical-align:middle;margin-top:52px;margin-bottom:20px}#fs_theme_connect_wrapper #fs_connect .fs-terms{background:rgba(140,140,140,0.64)}#fs_theme_connect_wrapper #fs_connect .fs-terms,#fs_theme_connect_wrapper #fs_connect .fs-terms a{color:#c5c5c5}.wp-pointer-content #fs_connect{margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none}.fs-opt-in-pointer .wp-pointer-content{padding:0}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow{border-bottom-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow-inner{border-bottom-color:#fafafa}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow{border-top-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow-inner{border-top-color:#fafafa}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow{border-right-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow-inner{border-right-color:#fafafa}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow{border-left-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow-inner{border-left-color:#fafafa}
vendor/freemius/wordpress-sdk/assets/css/admin/debug.css ADDED
@@ -0,0 +1 @@
 
1
+ .fs-switch-label{font-size:20px;line-height:31px;margin:0 5px}#fs_log_book table{font-family:Consolas,Monaco,monospace;font-size:12px}#fs_log_book table th{color:#ccc}#fs_log_book table tr{background:#232525}#fs_log_book table tr.alternate{background:#2b2b2b}#fs_log_book table tr td.fs-col--logger{color:#5a7435}#fs_log_book table tr td.fs-col--type{color:#ffc861}#fs_log_book table tr td.fs-col--function{color:#a7b7b1;font-weight:bold}#fs_log_book table tr td.fs-col--message,#fs_log_book table tr td.fs-col--message a{color:#9a73ac !important}#fs_log_book table tr td.fs-col--file{color:#d07922}#fs_log_book table tr td.fs-col--timestamp{color:#6596be}
vendor/freemius/wordpress-sdk/assets/css/admin/dialog-boxes.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ .fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.fs-modal .dashicons{vertical-align:middle}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal.fs-success .fs-modal-header{border-bottom-color:#46b450}.fs-modal.fs-success .fs-modal-body{background-color:#f7fff7}.fs-modal.fs-warn .fs-modal-header{border-bottom-color:#ffb900}.fs-modal.fs-warn .fs-modal-body{background-color:#fff8e5}.fs-modal.fs-error .fs-modal-header{border-bottom-color:#dc3232}.fs-modal.fs-error .fs-modal-body{background-color:#ffeaea}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-header{border-bottom:#eeeeee solid 1px;background:#fbfbfb;padding:15px 20px;position:relative;margin-bottom:-10px}.fs-modal .fs-modal-header h4{margin:0;padding:0;text-transform:uppercase;font-size:1.2em;font-weight:bold;color:#cacaca;text-shadow:1px 1px 1px #fff;letter-spacing:0.6px;-webkit-font-smoothing:antialiased}.fs-modal .fs-modal-header .fs-close{position:absolute;right:10px;top:12px;cursor:pointer;color:#bbb;-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;padding:3px;-moz-transition:all 0.2s ease-in-out;-o-transition:all 0.2s ease-in-out;-ms-transition:all 0.2s ease-in-out;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}.fs-modal .fs-modal-header .fs-close:hover{color:#fff;background:#aaa}.fs-modal .fs-modal-header .fs-close .dashicons,.fs-modal .fs-modal-header .fs-close:hover .dashicons{text-decoration:none}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body p{font-size:14px}.fs-modal .fs-modal-body h2{font-size:20px;line-height:1.5em}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:first-child{margin:0}.fs-modal .fs-modal-panel>.notice.inline{margin:0;display:none}.fs-modal .fs-modal-panel:not(.active){display:none}.rtl .fs-modal .fs-modal-header .fs-close{right:auto;left:20px}body.has-fs-modal{overflow:hidden}.fs-modal.fs-modal-deactivation-feedback .reason-input,.fs-modal.fs-modal-deactivation-feedback .internal-message{margin:3px 0 3px 22px}.fs-modal.fs-modal-deactivation-feedback .reason-input input,.fs-modal.fs-modal-deactivation-feedback .reason-input textarea,.fs-modal.fs-modal-deactivation-feedback .internal-message input,.fs-modal.fs-modal-deactivation-feedback .internal-message textarea{width:100%}.fs-modal.fs-modal-deactivation-feedback li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}@media (max-width: 650px){.fs-modal.fs-modal-deactivation-feedback li.reason li.reason{margin-bottom:10px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .reason-input,.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .internal-message{margin-left:29px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label{display:table}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.fs-modal-deactivation-feedback .anonymous-feedback-label{float:left}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel{margin-top:0 !important}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel h3{margin-top:0;line-height:1.5em}#the-list .deactivate>.fs-slug{display:none}.fs-modal.fs-modal-subscription-cancellation .fs-price-increase-warning{color:red;font-weight:bold;padding:0 25px;margin-bottom:0}.fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label input{float:left;top:5px;position:relative}.rtl .fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label input{float:right}.fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label span{display:block;margin-left:24px}.rtl .fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label span{margin-left:0;margin-right:24px}.fs-modal.fs-modal-license-activation .fs-modal-body input.fs-license-key{width:100%}.fs-license-options-container table,.fs-license-options-container table select,.fs-license-options-container table .fs-available-license-key{width:100%}.fs-license-options-container table td:first-child{width:1%}.fs-license-options-container table .fs-other-license-key-container label{position:relative;top:6px;float:left;margin-right:5px}.fs-license-options-container table .fs-other-license-key-container div{overflow:hidden;width:auto;height:30px;display:block;top:2px;position:relative}.fs-license-options-container table .fs-other-license-key-container div input{margin:0}.fs-sites-list-container td{cursor:pointer}.fs-modal.fs-modal-user-change .fs-modal-body input#fs_other_email_address{width:100%}.fs-user-change-options-container table{width:100%;border-collapse:collapse}.fs-user-change-options-container table tr{display:block;margin-bottom:2px}.fs-user-change-options-container table .fs-email-address-container td{display:inline-block}.fs-user-change-options-container table .fs-email-address-container input[type="radio"]{margin-bottom:0;margin-top:0}.fs-user-change-options-container table .fs-other-email-address-container{width:100%}.fs-user-change-options-container table .fs-other-email-address-container>div{display:table;width:100%}.fs-user-change-options-container table .fs-other-email-address-container>div label,.fs-user-change-options-container table .fs-other-email-address-container>div>div{display:table-cell}.fs-user-change-options-container table .fs-other-email-address-container>div label{width:1%;padding-left:3px;padding-right:3px}.fs-user-change-options-container table .fs-other-email-address-container>div>div{width:auto}.fs-user-change-options-container table .fs-other-email-address-container>div>div input{width:100%}.fs-modal.fs-modal-developer-license-debug-mode .fs-modal-body input.fs-license-or-user-key{width:100%}.fs-multisite-options-container{margin-top:10px;border:1px solid #ccc;padding:5px}.fs-multisite-options-container a{text-decoration:none}.fs-multisite-options-container a:focus{box-shadow:none}.fs-multisite-options-container a.selected{font-weight:bold}.fs-multisite-options-container.fs-apply-on-all-sites{border:0 none;padding:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options{border-spacing:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options td:not(:first-child){display:none}.fs-multisite-options-container .fs-sites-list-container{display:none;overflow:auto}.fs-multisite-options-container .fs-sites-list-container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-modal.fs-modal-license-key-resend .email-address-container{overflow:hidden;padding-right:2px}.fs-modal.fs-modal-license-key-resend.fs-freemium input.email-address{width:300px}.fs-modal.fs-modal-license-key-resend.fs-freemium label{display:block;margin-bottom:10px}.fs-modal.fs-modal-license-key-resend.fs-premium input.email-address{width:100%}.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{float:right;margin-left:7px}@media (max-width: 650px){.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{margin-top:2px}}
2
+ .rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .input-container>.email-address-container{padding-left:2px;padding-right:0}.rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .button-container{float:left;margin-right:7px;margin-left:0}a.show-license-resend-modal{margin-top:4px;display:inline-block}.fs-ajax-loader{position:relative;width:170px;height:20px;margin:auto}.fs-ajax-loader .fs-ajax-loader-bar{position:absolute;top:0;background-color:#0074a3;width:20px;height:20px;-webkit-animation-name:bounce_ajaxLoader;-moz-animation-name:bounce_ajaxLoader;-ms-animation-name:bounce_ajaxLoader;-o-animation-name:bounce_ajaxLoader;animation-name:bounce_ajaxLoader;-webkit-animation-duration:1.5s;-moz-animation-duration:1.5s;-ms-animation-duration:1.5s;-o-animation-duration:1.5s;animation-duration:1.5s;animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-webkit-animation-direction:normal;-moz-animation-direction:normal;-ms-animation-direction:normal;-o-animation-direction:normal;animation-direction:normal;-moz-transform:0.3;-o-transform:0.3;-ms-transform:0.3;-webkit-transform:0.3;transform:0.3}.fs-ajax-loader .fs-ajax-loader-bar-1{left:0px;animation-delay:0.6s;-o-animation-delay:0.6s;-ms-animation-delay:0.6s;-webkit-animation-delay:0.6s;-moz-animation-delay:0.6s}.fs-ajax-loader .fs-ajax-loader-bar-2{left:19px;animation-delay:0.75s;-o-animation-delay:0.75s;-ms-animation-delay:0.75s;-webkit-animation-delay:0.75s;-moz-animation-delay:0.75s}.fs-ajax-loader .fs-ajax-loader-bar-3{left:38px;animation-delay:0.9s;-o-animation-delay:0.9s;-ms-animation-delay:0.9s;-webkit-animation-delay:0.9s;-moz-animation-delay:0.9s}.fs-ajax-loader .fs-ajax-loader-bar-4{left:57px;animation-delay:1.05s;-o-animation-delay:1.05s;-ms-animation-delay:1.05s;-webkit-animation-delay:1.05s;-moz-animation-delay:1.05s}.fs-ajax-loader .fs-ajax-loader-bar-5{left:76px;animation-delay:1.2s;-o-animation-delay:1.2s;-ms-animation-delay:1.2s;-webkit-animation-delay:1.2s;-moz-animation-delay:1.2s}.fs-ajax-loader .fs-ajax-loader-bar-6{left:95px;animation-delay:1.35s;-o-animation-delay:1.35s;-ms-animation-delay:1.35s;-webkit-animation-delay:1.35s;-moz-animation-delay:1.35s}.fs-ajax-loader .fs-ajax-loader-bar-7{left:114px;animation-delay:1.5s;-o-animation-delay:1.5s;-ms-animation-delay:1.5s;-webkit-animation-delay:1.5s;-moz-animation-delay:1.5s}.fs-ajax-loader .fs-ajax-loader-bar-8{left:133px;animation-delay:1.65s;-o-animation-delay:1.65s;-ms-animation-delay:1.65s;-webkit-animation-delay:1.65s;-moz-animation-delay:1.65s}@-moz-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-ms-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-o-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-webkit-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}.fs-modal-auto-install #request-filesystem-credentials-form h2,.fs-modal-auto-install #request-filesystem-credentials-form .request-filesystem-credentials-action-buttons{display:none}.fs-modal-auto-install #request-filesystem-credentials-form input[type=password],.fs-modal-auto-install #request-filesystem-credentials-form input[type=email],.fs-modal-auto-install #request-filesystem-credentials-form input[type=text]{-webkit-appearance:none;padding:10px 10px 5px 10px;width:300px;max-width:100%}.fs-modal-auto-install #request-filesystem-credentials-form>div,.fs-modal-auto-install #request-filesystem-credentials-form label,.fs-modal-auto-install #request-filesystem-credentials-form fieldset{width:300px;max-width:100%;margin:0 auto;display:block}.button-primary.warn{box-shadow:0 1px 0 #d2593c;text-shadow:0 -1px 1px #d2593c,1px 0 1px #d2593c,0 1px 1px #d2593c,-1px 0 1px #d2593c;background:#f56a48;border-color:#ec6544 #d2593c #d2593c}.button-primary.warn:hover{background:#fd6d4a;border-color:#d2593c}.button-primary.warn:focus{box-shadow:0 1px 0 #dd6041,0 0 2px 1px #e4a796}.button-primary.warn:active{background:#dd6041;border-color:#d2593c;box-shadow:inset 0 2px 0 #d2593c}.button-primary.warn.disabled{color:#f5b3a1 !important;background:#e76444 !important;border-color:#d85e40 !important;text-shadow:0 -1px 0 rgba(0,0,0,0.1) !important}
vendor/freemius/wordpress-sdk/assets/css/admin/gdpr-optin-notice.css ADDED
@@ -0,0 +1 @@
 
1
+ .fs-notice[data-id^="gdpr_optin_actions"] .underlined{text-decoration:underline}.fs-notice[data-id^="gdpr_optin_actions"] ul .button,.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{vertical-align:middle}.fs-notice[data-id^="gdpr_optin_actions"] ul .action-description{display:inline-block;margin-left:3px}
vendor/freemius/wordpress-sdk/assets/css/admin/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
vendor/freemius/wordpress-sdk/assets/css/admin/plugins.css ADDED
@@ -0,0 +1 @@
 
1
+ label.fs-tag,span.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}.wp-list-table.plugins .plugin-title span.fs-tag{display:inline-block;margin-left:5px;line-height:10px}
vendor/freemius/wordpress-sdk/assets/css/customizer.css ADDED
@@ -0,0 +1 @@
 
1
+ #fs_customizer_upsell .fs-customizer-plan{padding:10px 20px 20px 20px;border-radius:3px;background:#fff}#fs_customizer_upsell .fs-customizer-plan h2{position:relative;margin:0;line-height:2em;text-transform:uppercase}#fs_customizer_upsell .fs-customizer-plan h2 .button-link{top:-2px}#fs_customizer_upsell .fs-feature{position:relative}#fs_customizer_upsell .dashicons-yes{color:#0085ba;font-size:2em;vertical-align:bottom;margin-left:-7px;margin-right:10px}.rtl #fs_customizer_upsell .dashicons-yes{margin-left:10px;margin-right:-7px}#fs_customizer_upsell .dashicons-editor-help{color:#bbb;cursor:help}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:#000;color:#fff;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:0;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{text-align:right}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:#000 transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{right:21px;left:auto}#fs_customizer_upsell .dashicons-editor-help:hover .fs-feature-desc{visibility:visible;opacity:1}#fs_customizer_upsell .button-primary{display:block;text-align:center;margin-top:10px}#fs_customizer_support{display:block !important}#fs_customizer_support .button{float:right}#fs_customizer_support .button-group{width:100%;display:block;margin-top:10px}#fs_customizer_support .button-group .button{float:none;width:50%;text-align:center}#customize-theme-controls #accordion-section-freemius_upsell{border-top:1px solid #0085ba !important;border-bottom:1px solid #0085ba !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title{color:#fff;background-color:#0085ba;border-left:4px solid #0085ba;transition:.15s background-color ease-in-out, .15s border-color ease-in-out;outline:none;border-bottom:none !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:hover{background-color:#008ec2;border-left-color:#0073aa}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:after{color:#fff}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title{border-left:none;border-right:4px solid #0085ba}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title:hover{border-right-color:#0073aa}
vendor/freemius/wordpress-sdk/assets/css/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
vendor/freemius/wordpress-sdk/assets/img/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
vendor/freemius/wordpress-sdk/assets/img/plugin-icon.png ADDED
Binary file
vendor/freemius/wordpress-sdk/assets/img/theme-icon.png ADDED
Binary file
vendor/freemius/wordpress-sdk/assets/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
vendor/freemius/wordpress-sdk/assets/js/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
vendor/freemius/wordpress-sdk/assets/js/nojquery.ba-postmessage.js ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery postMessage - v0.5 - 9/11/2009
3
+ * http://benalman.com/projects/jquery-postmessage-plugin/
4
+ *
5
+ * Copyright (c) 2009 "Cowboy" Ben Alman
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://benalman.com/about/license/
8
+ *
9
+ * Non-jQuery fork by Jeff Lee
10
+ *
11
+ * This fork consists of the following changes:
12
+ * 1. Basic code cleanup and restructuring, for legibility.
13
+ * 2. The `postMessage` and `receiveMessage` functions can be bound arbitrarily,
14
+ * in terms of both function names and object scope. Scope is specified by
15
+ * the the "this" context of NoJQueryPostMessageMixin();
16
+ * 3. I've removed the check for Opera 9.64, which used `$.browser`. There were
17
+ * at least three different GitHub users requesting the removal of this
18
+ * "Opera sniff" on the original project's Issues page, so I figured this
19
+ * would be a relatively safe change.
20
+ * 4. `postMessage` no longer uses `$.param` to serialize messages that are not
21
+ * strings. I actually prefer this structure anyway. `receiveMessage` does
22
+ * not implement a corresponding deserialization step, and as such it seems
23
+ * cleaner and more symmetric to leave both data serialization and
24
+ * deserialization to the client.
25
+ * 5. The use of `$.isFunction` is replaced by a functionally-identical check.
26
+ * 6. The `$:nomunge` YUI option is no longer necessary.
27
+ */
28
+
29
+ function NoJQueryPostMessageMixin(postBinding, receiveBinding) {
30
+
31
+ var setMessageCallback, unsetMessageCallback, currentMsgCallback,
32
+ intervalId, lastHash, cacheBust = 1;
33
+
34
+ if (window.postMessage) {
35
+
36
+ if (window.addEventListener) {
37
+ setMessageCallback = function(callback) {
38
+ window.addEventListener('message', callback, false);
39
+ }
40
+
41
+ unsetMessageCallback = function(callback) {
42
+ window.removeEventListener('message', callback, false);
43
+ }
44
+ } else {
45
+ setMessageCallback = function(callback) {
46
+ window.attachEvent('onmessage', callback);
47
+ }
48
+
49
+ unsetMessageCallback = function(callback) {
50
+ window.detachEvent('onmessage', callback);
51
+ }
52
+ }
53
+
54
+ this[postBinding] = function(message, targetUrl, target) {
55
+ if (!targetUrl) {
56
+ return;
57
+ }
58
+
59
+ // The browser supports window.postMessage, so call it with a targetOrigin
60
+ // set appropriately, based on the targetUrl parameter.
61
+ target.postMessage( message, targetUrl.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
62
+ }
63
+
64
+ // Since the browser supports window.postMessage, the callback will be
65
+ // bound to the actual event associated with window.postMessage.
66
+ this[receiveBinding] = function(callback, sourceOrigin, delay) {
67
+ // Unbind an existing callback if it exists.
68
+ if (currentMsgCallback) {
69
+ unsetMessageCallback(currentMsgCallback);
70
+ currentMsgCallback = null;
71
+ }
72
+
73
+ if (!callback) {
74
+ return false;
75
+ }
76
+
77
+ // Bind the callback. A reference to the callback is stored for ease of
78
+ // unbinding.
79
+ currentMsgCallback = setMessageCallback(function(e) {
80
+ switch(Object.prototype.toString.call(sourceOrigin)) {
81
+ case '[object String]':
82
+ if (sourceOrigin !== e.origin) {
83
+ return false;
84
+ }
85
+ break;
86
+ case '[object Function]':
87
+ if (sourceOrigin(e.origin)) {
88
+ return false;
89
+ }
90
+ break;
91
+ }
92
+
93
+ callback(e);
94
+ });
95
+ };
96
+
97
+ } else {
98
+
99
+ this[postBinding] = function(message, targetUrl, target) {
100
+ if (!targetUrl) {
101
+ return;
102
+ }
103
+
104
+ // The browser does not support window.postMessage, so set the location
105
+ // of the target to targetUrl#message. A bit ugly, but it works! A cache
106
+ // bust parameter is added to ensure that repeat messages trigger the
107
+ // callback.
108
+ target.location = targetUrl.replace( /#.*$/, '' ) + '#' + (+new Date) + (cacheBust++) + '&' + message;
109
+ }
110
+
111
+ // Since the browser sucks, a polling loop will be started, and the
112
+ // callback will be called whenever the location.hash changes.
113
+ this[receiveBinding] = function(callback, sourceOrigin, delay) {
114
+ if (intervalId) {
115
+ clearInterval(intervalId);
116
+ intervalId = null;
117
+ }
118
+
119
+ if (callback) {
120
+ delay = typeof sourceOrigin === 'number'
121
+ ? sourceOrigin
122
+ : typeof delay === 'number'
123
+ ? delay
124
+ : 100;
125
+
126
+ intervalId = setInterval(function(){
127
+ var hash = document.location.hash,
128
+ re = /^#?\d+&/;
129
+ if ( hash !== lastHash && re.test( hash ) ) {
130
+ lastHash = hash;
131
+ callback({ data: hash.replace( re, '' ) });
132
+ }
133
+ }, delay );
134
+ }
135
+ };
136
+
137
+ }
138
+
139
+ return this;
140
+ }
vendor/freemius/wordpress-sdk/assets/js/nojquery.ba-postmessage.min.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * nojquery-postmessage by Jeff Lee
3
+ * a non-jQuery fork of:
4
+ *
5
+ * jQuery postMessage - v0.5 - 9/11/2009
6
+ * http://benalman.com/projects/jquery-postmessage-plugin/
7
+ *
8
+ * Copyright (c) 2009 "Cowboy" Ben Alman
9
+ * Dual licensed under the MIT and GPL licenses.
10
+ * http://benalman.com/about/license/
11
+ */
12
+ function NoJQueryPostMessageMixin(g,a){var b,h,e,d,f,c=1;if(window.postMessage){if(window.addEventListener){b=function(i){window.addEventListener("message",i,false)};h=function(i){window.removeEventListener("message",i,false)}}else{b=function(i){window.attachEvent("onmessage",i)};h=function(i){window.detachEvent("onmessage",i)}}this[g]=function(i,k,j){if(!k){return}j.postMessage(i,k.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))};this[a]=function(k,j,i){if(e){h(e);e=null}if(!k){return false}e=b(function(l){switch(Object.prototype.toString.call(j)){case"[object String]":if(j!==l.origin){return false}break;case"[object Function]":if(j(l.origin)){return false}break}k(l)})}}else{this[g]=function(i,k,j){if(!k){return}j.location=k.replace(/#.*$/,"")+"#"+(+new Date)+(c++)+"&"+i};this[a]=function(k,j,i){if(d){clearInterval(d);d=null}if(k){i=typeof j==="number"?j:typeof i==="number"?i:100;d=setInterval(function(){var m=document.location.hash,l=/^#?\d+&/;if(m!==f&&l.test(m)){f=m;k({data:m.replace(l,"")})}},i)}}}return this};
vendor/freemius/wordpress-sdk/assets/js/postmessage.js ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($, undef) {
2
+ var global = this;
3
+
4
+ // Namespace.
5
+ global.FS = global.FS || {};
6
+
7
+ global.FS.PostMessage = function ()
8
+ {
9
+ var
10
+ _is_child = false,
11
+ _postman = new NoJQueryPostMessageMixin('postMessage', 'receiveMessage'),
12
+ _callbacks = {},
13
+ _base_url,
14
+ _parent_url = decodeURIComponent(document.location.hash.replace(/^#/, '')),
15
+ _parent_subdomain = _parent_url.substring(0, _parent_url.indexOf('/', ('https://' === _parent_url.substring(0, ('https://').length)) ? 8 : 7)),
16
+ _init = function () {
17
+ _postman.receiveMessage(function (e) {
18
+ var data = JSON.parse(e.data);
19
+
20
+ if (_callbacks[data.type]) {
21
+ for (var i = 0; i < _callbacks[data.type].length; i++) {
22
+ // Execute type callbacks.
23
+ _callbacks[data.type][i](data.data);
24
+ }
25
+ }
26
+ }, _base_url);
27
+ },
28
+ _hasParent = ('' !== _parent_url),
29
+ $window = $(window),
30
+ $html = $('html');
31
+
32
+ return {
33
+ init : function (url, iframes)
34
+ {
35
+ _base_url = url;
36
+ _init();
37
+
38
+ // Automatically receive forward messages.
39
+ FS.PostMessage.receiveOnce('forward', function (data){
40
+ window.location = data.url;
41
+ });
42
+
43
+ iframes = iframes || [];
44
+
45
+ if (iframes.length > 0) {
46
+ $window.on('scroll', function () {
47
+ for (var i = 0; i < iframes.length; i++) {
48
+ FS.PostMessage.postScroll(iframes[i]);
49
+ }
50
+ });
51
+ }
52
+ },
53
+ init_child : function ()
54
+ {
55
+ this.init(_parent_subdomain);
56
+
57
+ _is_child = true;
58
+
59
+ // Post height of a child right after window is loaded.
60
+ $(window).bind('load', function () {
61
+ FS.PostMessage.postHeight();
62
+
63
+ // Post message that window was loaded.
64
+ FS.PostMessage.post('loaded');
65
+ });
66
+ },
67
+ hasParent : function ()
68
+ {
69
+ return _hasParent;
70
+ },
71
+ postHeight : function (diff, wrapper) {
72
+ diff = diff || 0;
73
+ wrapper = wrapper || '#wrap_section';
74
+ this.post('height', {
75
+ height: diff + $(wrapper).outerHeight(true)
76
+ });
77
+ },
78
+ postScroll : function (iframe) {
79
+ this.post('scroll', {
80
+ top: $window.scrollTop(),
81
+ height: ($window.height() - parseFloat($html.css('paddingTop')) - parseFloat($html.css('marginTop')))
82
+ }, iframe);
83
+ },
84
+ post : function (type, data, iframe)
85
+ {
86
+ console.debug('PostMessage.post', type);
87
+
88
+ if (iframe)
89
+ {
90
+ // Post to iframe.
91
+ _postman.postMessage(JSON.stringify({
92
+ type: type,
93
+ data: data
94
+ }), iframe.src, iframe.contentWindow);
95
+ }
96
+ else {
97
+ // Post to parent.
98
+ _postman.postMessage(JSON.stringify({
99
+ type: type,
100
+ data: data
101
+ }), _parent_url, window.parent);
102
+ }
103
+ },
104
+ receive: function (type, callback)
105
+ {
106
+ console.debug('PostMessage.receive', type);
107
+
108
+ if (undef === _callbacks[type])
109
+ _callbacks[type] = [];
110
+
111
+ _callbacks[type].push(callback);
112
+ },
113
+ receiveOnce: function (type, callback)
114
+ {
115
+ if (this.is_set(type))
116
+ return;
117
+
118
+ this.receive(type, callback);
119
+ },
120
+ // Check if any callbacks assigned to a specified message type.
121
+ is_set: function (type)
122
+ {
123
+ return (undef != _callbacks[type]);
124
+ },
125
+ parent_url: function ()
126
+ {
127
+ return _parent_url;
128
+ },
129
+ parent_subdomain: function ()
130
+ {
131
+ return _parent_subdomain;
132
+ }
133
+ };
134
+ }();
135
+ })(jQuery);
vendor/freemius/wordpress-sdk/config.php ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ if ( ! defined( 'WP_FS__SLUG' ) ) {
14
+ define( 'WP_FS__SLUG', 'freemius' );
15
+ }
16
+ if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
17
+ define( 'WP_FS__DEV_MODE', false );
18
+ }
19
+
20
+ #--------------------------------------------------------------------------------
21
+ #region API Connectivity Issues Simulation
22
+ #--------------------------------------------------------------------------------
23
+
24
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
25
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
26
+ }
27
+ if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
28
+ define( 'WP_FS__SIMULATE_NO_CURL', false );
29
+ }
30
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
31
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
32
+ }
33
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
34
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
35
+ }
36
+ if ( WP_FS__SIMULATE_NO_CURL ) {
37
+ define( 'FS_SDK__SIMULATE_NO_CURL', true );
38
+ }
39
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
40
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
41
+ }
42
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
43
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
44
+ }
45
+
46
+ #endregion
47
+
48
+ if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) {
49
+ define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false );
50
+ }
51
+
52
+ if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
53
+ /**
54
+ * @since 1.1.7.3
55
+ * @author Vova Feldman (@svovaf)
56
+ *
57
+ * I'm not sure if shared servers periodically change IP, or the subdomain of the
58
+ * admin dashboard. Also, I've seen sites that have strange loop of switching
59
+ * between domains on a daily basis. Therefore, to eliminate the risk of
60
+ * multiple unwanted connectivity test pings, temporary ignore domain or
61
+ * server IP changes.
62
+ */
63
+ define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
64
+ }
65
+
66
+ /**
67
+ * If your dev environment supports custom public network IP setup
68
+ * like VVV, please update WP_FS__LOCALHOST_IP with your public IP
69
+ * and uncomment it during dev.
70
+ */
71
+ if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
72
+ // VVV default public network IP.
73
+ define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
74
+
75
+ // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
76
+ }
77
+
78
+ /**
79
+ * If true and running with secret key, the opt-in process
80
+ * will skip the email activation process which is invoked
81
+ * when the email of the context user already exist in Freemius
82
+ * database (as a security precaution, to prevent sharing user
83
+ * secret with unauthorized entity).
84
+ *
85
+ * IMPORTANT:
86
+ * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
87
+ * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
88
+ * CLOCK IS SYNCED.
89
+ */
90
+ if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
91
+ define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
92
+ }
93
+
94
+
95
+ #--------------------------------------------------------------------------------
96
+ #region Directories
97
+ #--------------------------------------------------------------------------------
98
+
99
+ if ( ! defined( 'WP_FS__DIR' ) ) {
100
+ define( 'WP_FS__DIR', dirname( __FILE__ ) );
101
+ }
102
+ if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) {
103
+ define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
104
+ }
105
+ if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) {
106
+ define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
107
+ }
108
+ if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) {
109
+ define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
110
+ }
111
+ if ( ! defined( 'WP_FS__DIR_CSS' ) ) {
112
+ define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
113
+ }
114
+ if ( ! defined( 'WP_FS__DIR_JS' ) ) {
115
+ define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
116
+ }
117
+ if ( ! defined( 'WP_FS__DIR_IMG' ) ) {
118
+ define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
119
+ }
120
+ if ( ! defined( 'WP_FS__DIR_SDK' ) ) {
121
+ define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
122
+ }
123
+
124
+ #endregion
125
+
126
+ /**
127
+ * Domain / URL / Address
128
+ */
129
+ define( 'WP_FS__ROOT_DOMAIN_PRODUCTION', 'freemius.com' );
130
+ define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
131
+ define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
132
+
133
+ if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
134
+ define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
135
+ }
136
+ if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
137
+ define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
138
+ }
139
+
140
+ if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
141
+ define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
142
+ }
143
+
144
+ #--------------------------------------------------------------------------------
145
+ #region HTTP
146
+ #--------------------------------------------------------------------------------
147
+
148
+ if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) {
149
+ define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) );
150
+ }
151
+
152
+ if ( ! defined( 'WP_FS__IS_HTTPS' ) ) {
153
+ define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
154
+ // Checks if CloudFlare's HTTPS (Flexible SSL support).
155
+ isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
156
+ 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
157
+ ) ||
158
+ // Check if HTTPS request.
159
+ ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
160
+ ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
161
+ );
162
+ }
163
+
164
+ if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) {
165
+ define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
166
+ strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
167
+ }
168
+
169
+ if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) {
170
+ define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
171
+ }
172
+
173
+ if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) {
174
+ if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
175
+ define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
176
+ } else {
177
+ define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
178
+ is_string( WP_FS__REMOTE_ADDR ) &&
179
+ ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' ||
180
+ WP_FS__REMOTE_ADDR === '::1' )
181
+ );
182
+ }
183
+ }
184
+
185
+ if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) {
186
+ define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
187
+ false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
188
+ }
189
+
190
+ #endregion
191
+
192
+ if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
193
+ // By default, run with Freemius production servers.
194
+ define( 'WP_FS__IS_PRODUCTION_MODE', true );
195
+ }
196
+
197
+ if ( ! defined( 'WP_FS__ADDRESS' ) ) {
198
+ define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
199
+ }
200
+
201
+
202
+ #--------------------------------------------------------------------------------
203
+ #region API
204
+ #--------------------------------------------------------------------------------
205
+
206
+ if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
207
+ define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius-local.com:8080' );
208
+ }
209
+ if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
210
+ define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
211
+ }
212
+
213
+ // Set API address for local testing.
214
+ if ( ! WP_FS__IS_PRODUCTION_MODE ) {
215
+ if ( ! defined( 'FS_API__ADDRESS' ) ) {
216
+ define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
217
+ }
218
+ if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
219
+ define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
220
+ }
221
+ }
222
+
223
+ #endregion
224
+
225
+ #--------------------------------------------------------------------------------
226
+ #region Checkout
227
+ #--------------------------------------------------------------------------------
228
+
229
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) {
230
+ define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' );
231
+ }
232
+
233
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
234
+ define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius-local.com:8080' );
235
+ }
236
+
237
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
238
+ define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) );
239
+ }
240
+
241
+ #endregion
242
+
243
+ define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
244
+
245
+ if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
246
+ define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
247
+ }
248
+ if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
249
+ define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
250
+ }
251
+ if ( ! defined( 'WP_FS__GDPR_OPTION_NAME' ) ) {
252
+ define( 'WP_FS__GDPR_OPTION_NAME', WP_FS___OPTION_PREFIX . 'gdpr' );
253
+ }
254
+ define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
255
+
256
+ /**
257
+ * Module types
258
+ *
259
+ * @since 1.2.2
260
+ */
261
+ define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' );
262
+ define( 'WP_FS__MODULE_TYPE_THEME', 'theme' );
263
+
264
+ /**
265
+ * Billing Frequencies
266
+ */
267
+ define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
268
+ define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
269
+ define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
270
+
271
+ /**
272
+ * Plans
273
+ */
274
+ define( 'WP_FS__PLAN_DEFAULT_PAID', false );
275
+ define( 'WP_FS__PLAN_FREE', 'free' );
276
+ define( 'WP_FS__PLAN_TRIAL', 'trial' );
277
+
278
+ /**
279
+ * Times in seconds
280
+ */
281
+ if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) {
282
+ define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
283
+ }
284
+ if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) {
285
+ define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
286
+ }
287
+ // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
288
+ if ( ! defined( 'WP_FS__TIME_12_HOURS_IN_SEC' ) ) {
289
+ define( 'WP_FS__TIME_12_HOURS_IN_SEC', 43200 );
290
+ }
291
+ if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) {
292
+ define( 'WP_FS__TIME_24_HOURS_IN_SEC', WP_FS__TIME_12_HOURS_IN_SEC * 2 );
293
+ }
294
+ if ( ! defined( 'WP_FS__TIME_WEEK_IN_SEC' ) ) {
295
+ define( 'WP_FS__TIME_WEEK_IN_SEC', 7 * WP_FS__TIME_24_HOURS_IN_SEC );
296
+ }
297
+
298
+ #--------------------------------------------------------------------------------
299
+ #region Debugging
300
+ #--------------------------------------------------------------------------------
301
+
302
+ if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
303
+ $debug_mode = get_option( 'fs_debug_mode', null );
304
+
305
+ if ( $debug_mode === null ) {
306
+ $debug_mode = false;
307
+ add_option( 'fs_debug_mode', $debug_mode );
308
+ }
309
+
310
+ define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
311
+ }
312
+
313
+ if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) {
314
+ define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
315
+ }
316
+ if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) {
317
+ define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' );
318
+ }
319
+ if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
320
+ define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
321
+ }
322
+
323
+ if ( WP_FS__ECHO_DEBUG_SDK ) {
324
+ error_reporting( E_ALL );
325
+ }
326
+
327
+ #endregion
328
+
329
+ if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) {
330
+ define( 'WP_FS__SCRIPT_START_TIME', time() );
331
+ }
332
+ if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) {
333
+ define( 'WP_FS__DEFAULT_PRIORITY', 10 );
334
+ }
335
+ if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) {
336
+ define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
337
+ }
338
+
339
+ #--------------------------------------------------------------------------------
340
+ #region Multisite Network
341
+ #--------------------------------------------------------------------------------
342
+
343
+ /**
344
+ * Do not use this define directly, it will have the wrong value
345
+ * during plugin uninstall/deletion when the inclusion of the plugin
346
+ * is triggered due to registration with register_uninstall_hook().
347
+ *
348
+ * Instead, use fs_is_network_admin().
349
+ *
350
+ * @author Vova Feldman (@svovaf)
351
+ */
352
+ if ( ! defined( 'WP_FS__IS_NETWORK_ADMIN' ) ) {
353
+ define( 'WP_FS__IS_NETWORK_ADMIN',
354
+ is_multisite() &&
355
+ ( is_network_admin() ||
356
+ ( ( defined( 'DOING_AJAX' ) && DOING_AJAX &&
357
+ ( isset( $_REQUEST['_fs_network_admin'] ) /*||
358
+ ( ! empty( $_REQUEST['action'] ) && 'delete-plugin' === $_REQUEST['action'] )*/ )
359
+ ) ||
360
+ // Plugin uninstall.
361
+ defined( 'WP_UNINSTALL_PLUGIN' ) )
362
+ )
363
+ );
364
+ }
365
+
366
+ /**
367
+ * Do not use this define directly, it will have the wrong value
368
+ * during plugin uninstall/deletion when the inclusion of the plugin
369
+ * is triggered due to registration with register_uninstall_hook().
370
+ *
371
+ * Instead, use fs_is_blog_admin().
372
+ *
373
+ * @author Vova Feldman (@svovaf)
374
+ */
375
+ if ( ! defined( 'WP_FS__IS_BLOG_ADMIN' ) ) {
376
+ define( 'WP_FS__IS_BLOG_ADMIN', is_blog_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['_fs_blog_admin'] ) ) );
377
+ }
378
+
379
+ if ( ! defined( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED' ) ) {
380
+ // Set to true to show network level settings even if delegated to site admins.
381
+ define( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED', false );
382
+ }
383
+
384
+ #endregion
385
+
386
+ if ( ! defined( 'WP_FS__DEMO_MODE' ) ) {
387
+ define( 'WP_FS__DEMO_MODE', false );
388
+ }
vendor/freemius/wordpress-sdk/includes/class-freemius-abstract.php ADDED
@@ -0,0 +1,597 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.7
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+
14
+ /**
15
+ * - Each instance of Freemius class represents a single plugin
16
+ * install by a single user (the installer of the plugin).
17
+ *
18
+ * - Each website can only have one install of the same plugin.
19
+ *
20
+ * - Install entity is only created after a user connects his account with Freemius.
21
+ *
22
+ * Class Freemius_Abstract
23
+ */
24
+ abstract class Freemius_Abstract {
25
+
26
+ #----------------------------------------------------------------------------------
27
+ #region Identity
28
+ #----------------------------------------------------------------------------------
29
+
30
+ /**
31
+ * Check if user has connected his account (opted-in).
32
+ *
33
+ * Note:
34
+ * If the user opted-in and opted-out on a later stage,
35
+ * this will still return true. If you want to check if the
36
+ * user is currently opted-in, use:
37
+ * `$fs->is_registered() && $fs->is_tracking_allowed()`
38
+ *
39
+ * @since 1.0.1
40
+ * @return bool
41
+ */
42
+ abstract function is_registered();
43
+
44
+ /**
45
+ * Check if the user skipped connecting the account with Freemius.
46
+ *
47
+ * @since 1.0.7
48
+ *
49
+ * @return bool
50
+ */
51
+ abstract function is_anonymous();
52
+
53
+ /**
54
+ * Check if the user currently in activation mode.
55
+ *
56
+ * @since 1.0.7
57
+ *
58
+ * @return bool
59
+ */
60
+ abstract function is_activation_mode();
61
+
62
+ #endregion
63
+
64
+ #----------------------------------------------------------------------------------
65
+ #region Usage Tracking
66
+ #----------------------------------------------------------------------------------
67
+
68
+ /**
69
+ * Returns TRUE if the user opted-in and didn't disconnect (opt-out).
70
+ *
71
+ * @author Leo Fajardo (@leorw)
72
+ * @since 1.2.1.5
73
+ *
74
+ * @return bool
75
+ */
76
+ abstract function is_tracking_allowed();
77
+
78
+ /**
79
+ * Returns TRUE if the user never opted-in or manually opted-out.
80
+ *
81
+ * @author Vova Feldman (@svovaf)
82
+ * @since 1.2.1.5
83
+ *
84
+ * @return bool
85
+ */
86
+ function is_tracking_prohibited() {
87
+ return ! $this->is_registered() || ! $this->is_tracking_allowed();
88
+ }
89
+
90
+ /**
91
+ * Opt-out from usage tracking.
92
+ *
93
+ * Note: This will not delete the account information but will stop all tracking.
94
+ *
95
+ * Returns:
96
+ * 1. FALSE - If the user never opted-in.
97
+ * 2. TRUE - If successfully opted-out.
98
+ * 3. object - API Result on failure.
99
+ *
100
+ * @author Leo Fajardo (@leorw)
101
+ * @since 1.2.1.5
102
+ *
103
+ * @return bool|object
104
+ */
105
+ abstract function stop_tracking();
106
+
107
+ /**
108
+ * Opt-in back into usage tracking.
109
+ *
110
+ * Note: This will only work if the user opted-in previously.
111
+ *
112
+ * Returns:
113
+ * 1. FALSE - If the user never opted-in.
114
+ * 2. TRUE - If successfully opted-in back to usage tracking.
115
+ * 3. object - API result on failure.
116
+ *
117
+ * @author Leo Fajardo (@leorw)
118
+ * @since 1.2.1.5
119
+ *
120
+ * @return bool|object
121
+ */
122
+ abstract function allow_tracking();
123
+
124
+ #endregion
125
+
126
+ #----------------------------------------------------------------------------------
127
+ #region Module Type
128
+ #----------------------------------------------------------------------------------
129
+
130
+ /**
131
+ * Checks if the plugin's type is "plugin". The other type is "theme".
132
+ *
133
+ * @author Leo Fajardo (@leorw)
134
+ * @since 1.2.2
135
+ *
136
+ * @return bool
137
+ */
138
+ abstract function is_plugin();
139
+
140
+ /**
141
+ * Checks if the module type is "theme". The other type is "plugin".
142
+ *
143
+ * @author Leo Fajardo (@leorw)
144
+ * @since 1.2.2
145
+ *
146
+ * @return bool
147
+ */
148
+ function is_theme() {
149
+ return ( ! $this->is_plugin() );
150
+ }
151
+
152
+ #endregion
153
+
154
+ #----------------------------------------------------------------------------------
155
+ #region Permissions
156
+ #----------------------------------------------------------------------------------
157
+
158
+ /**
159
+ * Check if plugin must be WordPress.org compliant.
160
+ *
161
+ * @since 1.0.7
162
+ *
163
+ * @return bool
164
+ */
165
+ abstract function is_org_repo_compliant();
166
+
167
+ /**
168
+ * Check if plugin is allowed to install executable files.
169
+ *
170
+ * @author Vova Feldman (@svovaf)
171
+ * @since 1.0.5
172
+ *
173
+ * @return bool
174
+ */
175
+ function is_allowed_to_install() {
176
+ return ( $this->is_premium() || ! $this->is_org_repo_compliant() );
177
+ }
178
+
179
+ #endregion
180
+
181
+ /**
182
+ * Check if user in trial or in free plan (not paying).
183
+ *
184
+ * @author Vova Feldman (@svovaf)
185
+ * @since 1.0.4
186
+ *
187
+ * @return bool
188
+ */
189
+ function is_not_paying() {
190
+ return ( $this->is_trial() || $this->is_free_plan() );
191
+ }
192
+
193
+ /**
194
+ * Check if the user has an activated and valid paid license on current plugin's install.
195
+ *
196
+ * @since 1.0.9
197
+ *
198
+ * @return bool
199
+ */
200
+ abstract function is_paying();
201
+
202
+ /**
203
+ * Check if the user is paying or in trial.
204
+ *
205
+ * @since 1.0.9
206
+ *
207
+ * @return bool
208
+ */
209
+ function is_paying_or_trial() {
210
+ return ( $this->is_paying() || $this->is_trial() );
211
+ }
212
+
213
+ /**
214
+ * Check if user in a trial or have feature enabled license.
215
+ *
216
+ * @author Vova Feldman (@svovaf)
217
+ * @since 1.1.7
218
+ *
219
+ * @return bool
220
+ */
221
+ abstract function can_use_premium_code();
222
+
223
+ #----------------------------------------------------------------------------------
224
+ #region Premium Only
225
+ #----------------------------------------------------------------------------------
226
+
227
+ /**
228
+ * All logic wrapped in methods with "__premium_only()" suffix will be only
229
+ * included in the premium code.
230
+ *
231
+ * Example:
232
+ * if ( freemius()->is__premium_only() ) {
233
+ * ...
234
+ * }
235
+ */
236
+
237
+ /**
238
+ * Returns true when running premium plugin code.
239
+ *
240
+ * @since 1.0.9
241
+ *
242
+ * @return bool
243
+ */
244
+ function is__premium_only() {
245
+ return $this->is_premium();
246
+ }
247
+
248
+ /**
249
+ * Check if the user has an activated and valid paid license on current plugin's install.
250
+ *
251
+ * @since 1.0.9
252
+ *
253
+ * @return bool
254
+ *
255
+ */
256
+ function is_paying__premium_only() {
257
+ return ( $this->is__premium_only() && $this->is_paying() );
258
+ }
259
+
260
+ /**
261
+ * All code wrapped in this statement will be only included in the premium code.
262
+ *
263
+ * @since 1.0.9
264
+ *
265
+ * @param string $plan Plan name.
266
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
267
+ *
268
+ * @return bool
269
+ */
270
+ function is_plan__premium_only( $plan, $exact = false ) {
271
+ return ( $this->is_premium() && $this->is_plan( $plan, $exact ) );
272
+ }
273
+
274
+ /**
275
+ * Check if plan matches active license' plan or active trial license' plan.
276
+ *
277
+ * All code wrapped in this statement will be only included in the premium code.
278
+ *
279
+ * @since 1.0.9
280
+ *
281
+ * @param string $plan Plan name.
282
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
283
+ *
284
+ * @return bool
285
+ */
286
+ function is_plan_or_trial__premium_only( $plan, $exact = false ) {
287
+ return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) );
288
+ }
289
+
290
+ /**
291
+ * Check if the user is paying or in trial.
292
+ *
293
+ * All code wrapped in this statement will be only included in the premium code.
294
+ *
295
+ * @since 1.0.9
296
+ *
297
+ * @return bool
298
+ */
299
+ function is_paying_or_trial__premium_only() {
300
+ return $this->is_premium() && $this->is_paying_or_trial();
301
+ }
302
+
303
+ /**
304
+ * Check if the user has an activated and valid paid license on current plugin's install.
305
+ *
306
+ * @since 1.0.4
307
+ *
308
+ * @return bool
309
+ *
310
+ * @deprecated Method name is confusing since it's not clear from the name the code will be removed.
311
+ * @using Alias to is_paying__premium_only()
312
+ */
313
+ function is_paying__fs__() {
314
+ return $this->is_paying__premium_only();
315
+ }
316
+
317
+ /**
318
+ * Check if user in a trial or have feature enabled license.
319
+ *
320
+ * All code wrapped in this statement will be only included in the premium code.
321
+ *
322
+ * @author Vova Feldman (@svovaf)
323
+ * @since 1.1.9
324
+ *
325
+ * @return bool
326
+ */
327
+ function can_use_premium_code__premium_only() {
328
+ return $this->is_premium() && $this->can_use_premium_code();
329
+ }
330
+
331
+ #endregion
332
+
333
+ #----------------------------------------------------------------------------------
334
+ #region Trial
335
+ #----------------------------------------------------------------------------------
336
+
337
+ /**
338
+ * Check if the user in a trial.
339
+ *
340
+ * @since 1.0.3
341
+ *
342
+ * @return bool
343
+ */
344
+ abstract function is_trial();
345
+
346
+ /**
347
+ * Check if trial already utilized.
348
+ *
349
+ * @since 1.0.9
350
+ *
351
+ * @return bool
352
+ */
353
+ abstract function is_trial_utilized();
354
+
355
+ #endregion
356
+
357
+ #----------------------------------------------------------------------------------
358
+ #region Plans
359
+ #----------------------------------------------------------------------------------
360
+
361
+ /**
362
+ * Check if the user is on the free plan of the product.
363
+ *
364
+ * @since 1.0.4
365
+ *
366
+ * @return bool
367
+ */
368
+ abstract function is_free_plan();
369
+
370
+ /**
371
+ * @since 1.0.2
372
+ *
373
+ * @param string $plan Plan name.
374
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
375
+ *
376
+ * @return bool
377
+ */
378
+ abstract function is_plan( $plan, $exact = false );
379
+
380
+ /**
381
+ * Check if plan based on trial. If not in trial mode, should return false.
382
+ *
383
+ * @since 1.0.9
384
+ *
385
+ * @param string $plan Plan name.
386
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
387
+ *
388
+ * @return bool
389
+ */
390
+ abstract function is_trial_plan( $plan, $exact = false );
391
+
392
+ /**
393
+ * Check if plan matches active license' plan or active trial license' plan.
394
+ *
395
+ * @since 1.0.9
396
+ *
397
+ * @param string $plan Plan name.
398
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
399
+ *
400
+ * @return bool
401
+ */
402
+ function is_plan_or_trial( $plan, $exact = false ) {
403
+ return $this->is_plan( $plan, $exact ) ||
404
+ $this->is_trial_plan( $plan, $exact );
405
+ }
406
+
407
+ /**
408
+ * Check if plugin has any paid plans.
409
+ *
410
+ * @author Vova Feldman (@svovaf)
411
+ * @since 1.0.7
412
+ *
413
+ * @return bool
414
+ */
415
+ abstract function has_paid_plan();
416
+
417
+ /**
418
+ * Check if plugin has any free plan, or is it premium only.
419
+ *
420
+ * Note: If no plans configured, assume plugin is free.
421
+ *
422
+ * @author Vova Feldman (@svovaf)
423
+ * @since 1.0.7
424
+ *
425
+ * @return bool
426
+ */
427
+ abstract function has_free_plan();
428
+
429
+ /**
430
+ * Check if plugin is premium only (no free plans).
431
+ *
432
+ * NOTE: is__premium_only() is very different method, don't get confused.
433
+ *
434
+ * @author Vova Feldman (@svovaf)
435
+ * @since 1.1.9
436
+ *
437
+ * @return bool
438
+ */
439
+ abstract function is_only_premium();
440
+
441
+ /**
442
+ * Check if module has a premium code version.
443
+ *
444
+ * Serviceware module might be freemium without any
445
+ * premium code version, where the paid features
446
+ * are all part of the service.
447
+ *
448
+ * @author Vova Feldman (@svovaf)
449
+ * @since 1.2.1.6
450
+ *
451
+ * @return bool
452
+ */
453
+ abstract function has_premium_version();
454
+
455
+ /**
456
+ * Check if module has any release on Freemius,
457
+ * or all plugin's code is on WordPress.org (Serviceware).
458
+ *
459
+ * @return bool
460
+ */
461
+ function has_release_on_freemius() {
462
+ return ! $this->is_org_repo_compliant() ||
463
+ $this->has_premium_version();
464
+ }
465
+
466
+ /**
467
+ * Checks if it's a freemium plugin.
468
+ *
469
+ * @author Vova Feldman (@svovaf)
470
+ * @since 1.1.9
471
+ *
472
+ * @return bool
473
+ */
474
+ function is_freemium() {
475
+ return $this->has_paid_plan() &&
476
+ $this->has_free_plan();
477
+ }
478
+
479
+ /**
480
+ * Check if module has only one plan.
481
+ *
482
+ * @author Vova Feldman (@svovaf)
483
+ * @since 1.2.1.7
484
+ *
485
+ * @return bool
486
+ */
487
+ abstract function is_single_plan();
488
+
489
+ #endregion
490
+
491
+ /**
492
+ * Check if running payments in sandbox mode.
493
+ *
494
+ * @since 1.0.4
495
+ *
496
+ * @return bool
497
+ */
498
+ abstract function is_payments_sandbox();
499
+
500
+ /**
501
+ * Check if running test vs. live plugin.
502
+ *
503
+ * @since 1.0.5
504
+ *
505
+ * @return bool
506
+ */
507
+ abstract function is_live();
508
+
509
+ /**
510
+ * Check if running premium plugin code.
511
+ *
512
+ * @since 1.0.5
513
+ *
514
+ * @return bool
515
+ */
516
+ abstract function is_premium();
517
+
518
+ /**
519
+ * Get upgrade URL.
520
+ *
521
+ * @author Vova Feldman (@svovaf)
522
+ * @since 1.0.2
523
+ *
524
+ * @param string $period Billing cycle.
525
+ *
526
+ * @return string
527
+ */
528
+ abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
529
+
530
+ /**
531
+ * Check if Freemius was first added in a plugin update.
532
+ *
533
+ * @author Vova Feldman (@svovaf)
534
+ * @since 1.1.5
535
+ *
536
+ * @return bool
537
+ */
538
+ function is_plugin_update() {
539
+ return ! $this->is_plugin_new_install();
540
+ }
541
+
542
+ /**
543
+ * Check if Freemius was part of the plugin when the user installed it first.
544
+ *
545
+ * @author Vova Feldman (@svovaf)
546
+ * @since 1.1.5
547
+ *
548
+ * @return bool
549
+ */
550
+ abstract function is_plugin_new_install();
551
+
552
+ #----------------------------------------------------------------------------------
553
+ #region Marketing
554
+ #----------------------------------------------------------------------------------
555
+
556
+ /**
557
+ * Check if current user purchased any other plugins before.
558
+ *
559
+ * @author Vova Feldman (@svovaf)
560
+ * @since 1.0.9
561
+ *
562
+ * @return bool
563
+ */
564
+ abstract function has_purchased_before();
565
+
566
+ /**
567
+ * Check if current user classified as an agency.
568
+ *
569
+ * @author Vova Feldman (@svovaf)
570
+ * @since 1.0.9
571
+ *
572
+ * @return bool
573
+ */
574
+ abstract function is_agency();
575
+
576
+ /**
577
+ * Check if current user classified as a developer.
578
+ *
579
+ * @author Vova Feldman (@svovaf)
580
+ * @since 1.0.9
581
+ *
582
+ * @return bool
583
+ */
584
+ abstract function is_developer();
585
+
586
+ /**
587
+ * Check if current user classified as a business.
588
+ *
589
+ * @author Vova Feldman (@svovaf)
590
+ * @since 1.0.9
591
+ *
592
+ * @return bool
593
+ */
594
+ abstract function is_business();
595
+
596
+ #endregion
597
+ }
vendor/freemius/wordpress-sdk/includes/class-freemius.php ADDED
@@ -0,0 +1,24591 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6
+ * @since 1.0.3
7
+ */
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ // "final class"
13
+ class Freemius extends Freemius_Abstract {
14
+ /**
15
+ * SDK Version
16
+ *
17
+ * @var string
18
+ */
19
+ public $version = WP_FS__SDK_VERSION;
20
+
21
+ #region Plugin Info
22
+
23
+ /**
24
+ * @since 1.0.1
25
+ *
26
+ * @var string
27
+ */
28
+ private $_slug;
29
+
30
+ /**
31
+ * @since 1.0.0
32
+ *
33
+ * @var string
34
+ */
35
+ private $_plugin_basename;
36
+ /**
37
+ * @since 2.2.1
38
+ *
39
+ * @var string
40
+ */
41
+ private $_premium_plugin_basename;
42
+ /**
43
+ * @since 1.0.0
44
+ *
45
+ * @var string
46
+ */
47
+ private $_free_plugin_basename;
48
+ /**
49
+ * @since 1.0.0
50
+ *
51
+ * @var string
52
+ */
53
+ private $_plugin_dir_path;
54
+ /**
55
+ * @since 1.0.0
56
+ *
57
+ * @var string
58
+ */
59
+ private $_plugin_dir_name;
60
+ /**
61
+ * @since 1.0.0
62
+ *
63
+ * @var string
64
+ */
65
+ private $_plugin_main_file_path;
66
+ /**
67
+ * @var string[]
68
+ */
69
+ private $_plugin_data;
70
+ /**
71
+ * @since 1.0.9
72
+ *
73
+ * @var string
74
+ */
75
+ private $_plugin_name;
76
+ /**
77
+ * @since 1.2.2
78
+ *
79
+ * @var string
80
+ */
81
+ private $_module_type;
82
+
83
+ #endregion Plugin Info
84
+
85
+ /**
86
+ * @since 1.0.9
87
+ *
88
+ * @var bool If false, don't turn Freemius on.
89
+ */
90
+ private $_is_on;
91
+
92
+ /**
93
+ * @since 1.1.3
94
+ *
95
+ * @var bool If false, don't turn Freemius on.
96
+ */
97
+ private $_is_anonymous;
98
+
99
+ /**
100
+ * @since 1.0.9
101
+ * @var bool If false, issues with connectivity to Freemius API.
102
+ */
103
+ private $_has_api_connection;
104
+
105
+ /**
106
+ * @since 1.0.9
107
+ * @since 2.0.0 Default to true since we need the property during the instance construction, prior to the dynamic_init() execution.
108
+ * @var bool Hints the SDK if plugin can support anonymous mode (if skip connect is visible).
109
+ */
110
+ private $_enable_anonymous = true;
111
+
112
+ /**
113
+ * @since 1.1.7.5
114
+ * @var bool Hints the SDK if plugin should run in anonymous mode (only adds feedback form).
115
+ */
116
+ private $_anonymous_mode;
117
+
118
+ /**
119
+ * @since 1.1.9
120
+ * @var bool Hints the SDK if plugin have any free plans.
121
+ */
122
+ private $_is_premium_only;
123
+
124
+ /**
125
+ * @since 1.2.1.6
126
+ * @var bool Hints the SDK if plugin have premium code version at all.
127
+ */
128
+ private $_has_premium_version;
129
+
130
+ /**
131
+ * @since 1.2.1.6
132
+ * @var bool Hints the SDK if plugin should ignore pending mode by simulating a skip.
133
+ */
134
+ private $_ignore_pending_mode;
135
+
136
+ /**
137
+ * @since 1.0.8
138
+ * @var bool Hints the SDK if the plugin has any paid plans.
139
+ */
140
+ private $_has_paid_plans;
141
+
142
+ /**
143
+ * @since 1.2.1.5
144
+ * @var int Hints the SDK if the plugin offers a trial period. If negative, no trial, if zero - has a trial but
145
+ * without a specified period, if positive - the number of trial days.
146
+ */
147
+ private $_trial_days = - 1;
148
+
149
+ /**
150
+ * @since 1.2.1.5
151
+ * @var bool Hints the SDK if the trial requires a payment method or not.
152
+ */
153
+ private $_is_trial_require_payment = false;
154
+
155
+ /**
156
+ * @since 1.0.7
157
+ * @var bool Hints the SDK if the plugin is WordPress.org compliant.
158
+ */
159
+ private $_is_org_compliant;
160
+
161
+ /**
162
+ * @since 1.0.7
163
+ * @var bool Hints the SDK if the plugin is has add-ons.
164
+ */
165
+ private $_has_addons;
166
+
167
+ /**
168
+ * @since 2.4.5
169
+ * @var string Navigation type: 'menu' or 'tabs'.
170
+ */
171
+ private $_navigation;
172
+
173
+ const NAVIGATION_MENU = 'menu';
174
+ const NAVIGATION_TABS = 'tabs';
175
+
176
+ /**
177
+ * @since 1.1.6
178
+ * @var string[]bool.
179
+ */
180
+ private $_permissions;
181
+
182
+ /**
183
+ * @var FS_Storage
184
+ */
185
+ private $_storage;
186
+
187
+ /**
188
+ * @since 1.2.2.7
189
+ * @var FS_Cache_Manager
190
+ */
191
+ private $_cache;
192
+
193
+ /**
194
+ * @since 1.0.0
195
+ *
196
+ * @var FS_Logger
197
+ */
198
+ private $_logger;
199
+ /**
200
+ * @since 1.0.4
201
+ *
202
+ * @var FS_Plugin
203
+ */
204
+ private $_plugin = false;
205
+ /**
206
+ * @since 1.0.4
207
+ *
208
+ * @var FS_Plugin|false
209
+ */
210
+ private $_parent_plugin = false;
211
+ /**
212
+ * @since 1.1.1
213
+ *
214
+ * @var Freemius
215
+ */
216
+ private $_parent = false;
217
+ /**
218
+ * @since 1.0.1
219
+ *
220
+ * @var FS_User
221
+ */
222
+ private $_user = false;
223
+ /**
224
+ * @since 1.0.1
225
+ *
226
+ * @var FS_Site
227
+ */
228
+ private $_site = false;
229
+ /**
230
+ * @since 1.0.1
231
+ *
232
+ * @var FS_Plugin_License
233
+ */
234
+ private $_license;
235
+ /**
236
+ * @since 1.0.2
237
+ *
238
+ * @var FS_Plugin_Plan[]
239
+ */
240
+ private $_plans = false;
241
+ /**
242
+ * @var FS_Plugin_License[]
243
+ * @since 1.0.5
244
+ */
245
+ private $_licenses = false;
246
+
247
+ /**
248
+ * @since 1.0.1
249
+ *
250
+ * @var FS_Admin_Menu_Manager
251
+ */
252
+ private $_menu;
253
+
254
+ /**
255
+ * @var FS_Admin_Notices
256
+ */
257
+ private $_admin_notices;
258
+
259
+ /**
260
+ * @since 1.1.6
261
+ *
262
+ * @var FS_Admin_Notices
263
+ */
264
+ private static $_global_admin_notices;
265
+
266
+ /**
267
+ * @var FS_Logger
268
+ * @since 1.0.0
269
+ */
270
+ private static $_static_logger;
271
+
272
+ /**
273
+ * @var FS_Options
274
+ * @since 1.0.2
275
+ */
276
+ private static $_accounts;
277
+
278
+ /**
279
+ * @since 1.2.2
280
+ *
281
+ * @var number
282
+ */
283
+ private $_module_id;
284
+
285
+ /**
286
+ * @var Freemius[]
287
+ */
288
+ private static $_instances = array();
289
+
290
+ /**
291
+ * @since 1.2.3
292
+ *
293
+ * @var FS_Affiliate
294
+ */
295
+ private $affiliate = null;
296
+
297
+ /**
298
+ * @since 1.2.3
299
+ *
300
+ * @var FS_AffiliateTerms
301
+ */
302
+ private $plugin_affiliate_terms = null;
303
+
304
+ /**
305
+ * @since 1.2.3
306
+ *
307
+ * @var FS_AffiliateTerms
308
+ */
309
+ private $custom_affiliate_terms = null;
310
+
311
+ /**
312
+ * @since 2.0.0
313
+ *
314
+ * @var bool
315
+ */
316
+ private $_is_multisite_integrated;
317
+
318
+ /**
319
+ * @since 2.0.0
320
+ *
321
+ * @var bool True if the current request is for a network admin screen and the plugin is network active.
322
+ */
323
+ private $_is_network_active;
324
+
325
+ /**
326
+ * @since 2.0.0
327
+ *
328
+ * @var int|null The original blog ID the plugin was loaded with.
329
+ */
330
+ private $_blog_id = null;
331
+
332
+ /**
333
+ * @since 2.0.0
334
+ *
335
+ * @var int|null The current execution context. When true, run on network context. When int, run on the specified blog context.
336
+ */
337
+ private $_context_is_network_or_blog_id = null;
338
+
339
+ /**
340
+ * @since 2.0.0
341
+ *
342
+ * @var string
343
+ */
344
+ private $_dynamically_added_top_level_page_hook_name = '';
345
+
346
+ /**
347
+ * @author Leo Fajardo (@leorw)
348
+ * @since 2.3.1
349
+ *
350
+ * @var bool
351
+ */
352
+ private $is_whitelabeled;
353
+
354
+ #region Uninstall Reasons IDs
355
+
356
+ const REASON_NO_LONGER_NEEDED = 1;
357
+ const REASON_FOUND_A_BETTER_PLUGIN = 2;
358
+ const REASON_NEEDED_FOR_A_SHORT_PERIOD = 3;
359
+ const REASON_BROKE_MY_SITE = 4;
360
+ const REASON_SUDDENLY_STOPPED_WORKING = 5;
361
+ const REASON_CANT_PAY_ANYMORE = 6;
362
+ const REASON_OTHER = 7;
363
+ const REASON_DIDNT_WORK = 8;
364
+ const REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION = 9;
365
+ const REASON_COULDNT_MAKE_IT_WORK = 10;
366
+ const REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE = 11;
367
+ const REASON_NOT_WORKING = 12;
368
+ const REASON_NOT_WHAT_I_WAS_LOOKING_FOR = 13;
369
+ const REASON_DIDNT_WORK_AS_EXPECTED = 14;
370
+ const REASON_TEMPORARY_DEACTIVATION = 15;
371
+
372
+ #endregion
373
+
374
+ /* Ctor
375
+ ------------------------------------------------------------------------------------------------------------------*/
376
+
377
+ /**
378
+ * Main singleton instance.
379
+ *
380
+ * @author Vova Feldman (@svovaf)
381
+ * @since 1.0.0
382
+ *
383
+ * @param number $module_id
384
+ * @param string|bool $slug
385
+ * @param bool $is_init Since 1.2.1 Is initiation sequence.
386
+ */
387
+ private function __construct( $module_id, $slug = false, $is_init = false ) {
388
+ if ( $is_init && is_numeric( $module_id ) && is_string( $slug ) ) {
389
+ $this->store_id_slug_type_path_map( $module_id, $slug );
390
+ }
391
+
392
+ $this->_module_id = $module_id;
393
+ $this->_slug = $this->get_slug();
394
+ $this->_module_type = $this->get_module_type();
395
+
396
+ $this->_blog_id = is_multisite() ? get_current_blog_id() : null;
397
+
398
+ $this->_storage = FS_Storage::instance( $this->_module_type, $this->_slug );
399
+
400
+ $this->_cache = FS_Cache_Manager::get_manager( WP_FS___OPTION_PREFIX . "cache_{$module_id}" );
401
+
402
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $this->get_unique_affix(), WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
403
+
404
+ $this->_plugin_main_file_path = $this->_find_caller_plugin_file( $is_init );
405
+ $this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
406
+ $this->_plugin_basename = $this->get_plugin_basename();
407
+ $this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
408
+
409
+ $this->_is_multisite_integrated = (
410
+ defined( "WP_FS__PRODUCT_{$module_id}_MULTISITE" ) &&
411
+ ( true === constant( "WP_FS__PRODUCT_{$module_id}_MULTISITE" ) )
412
+ );
413
+
414
+ $this->_is_network_active = (
415
+ is_multisite() &&
416
+ $this->_is_multisite_integrated &&
417
+ // Themes are always network activated, but the ACTUAL activation is per site.
418
+ $this->is_plugin() &&
419
+ (
420
+ is_plugin_active_for_network( $this->_plugin_basename ) ||
421
+ // Plugin network level activation or uninstall.
422
+ ( fs_is_network_admin() && is_plugin_inactive( $this->_plugin_basename ) )
423
+ )
424
+ );
425
+
426
+ $this->_storage->set_network_active(
427
+ $this->_is_network_active,
428
+ $this->is_delegated_connection()
429
+ );
430
+
431
+ if ( ! isset( $this->_storage->is_network_activated ) ) {
432
+ $this->_storage->is_network_activated = $this->_is_network_active;
433
+ }
434
+
435
+ if ( $this->_storage->is_network_activated != $this->_is_network_active ) {
436
+ // Update last activation level.
437
+ $this->_storage->is_network_activated = $this->_is_network_active;
438
+
439
+ $this->maybe_adjust_storage();
440
+ }
441
+
442
+ #region Migration
443
+
444
+ if ( is_multisite() ) {
445
+ /**
446
+ * If the install_timestamp exists on the site level but doesn't exist on the
447
+ * network level storage, it means that we need to process the storage with migration.
448
+ *
449
+ * The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, install_timestamp will be already set in the network level storage.
450
+ *
451
+ * @author Vova Feldman (@svovaf)
452
+ * @since 2.0.0
453
+ */
454
+ if ( false === $this->_storage->get( 'install_timestamp', false, true ) &&
455
+ false !== $this->_storage->get( 'install_timestamp', false, false )
456
+ ) {
457
+ // Initiate storage migration.
458
+ $this->_storage->migrate_to_network();
459
+
460
+ // Migrate module cache to network level storage.
461
+ $this->_cache->migrate_to_network();
462
+ }
463
+ }
464
+
465
+ #endregion
466
+
467
+ $base_name_split = explode( '/', $this->_plugin_basename );
468
+ $this->_plugin_dir_name = $base_name_split[0];
469
+
470
+ if ( $this->_logger->is_on() ) {
471
+ $this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
472
+ $this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
473
+ $this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
474
+ $this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
475
+ $this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
476
+ }
477
+
478
+ // Remember link between file to slug.
479
+ $this->store_file_slug_map();
480
+
481
+ // Store plugin's initial install timestamp.
482
+ if ( ! isset( $this->_storage->install_timestamp ) ) {
483
+ $this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
484
+ }
485
+
486
+ if ( ! is_object( $this->_plugin ) ) {
487
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->get();
488
+ }
489
+
490
+ $this->_admin_notices = FS_Admin_Notices::instance(
491
+ $this->_slug . ( $this->is_theme() ? ':theme' : '' ),
492
+ /**
493
+ * Ensure that the admin notice will always have a title by using the stored plugin title if available and
494
+ * retrieving the title via the "get_plugin_name" method if there is no stored plugin title available.
495
+ *
496
+ * @author Leo Fajardo (@leorw)
497
+ * @since 1.2.2
498
+ */
499
+ ( is_object( $this->_plugin ) ? $this->_plugin->title : $this->get_plugin_name() ),
500
+ $this->get_unique_affix()
501
+ );
502
+
503
+ if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ||
504
+ fs_request_is_action( 'restart_freemius' )
505
+ ) {
506
+ FS_Api::clear_cache();
507
+ $this->_cache->clear();
508
+ }
509
+
510
+ $this->register_constructor_hooks();
511
+
512
+ /**
513
+ * Starting from version 2.0.0, `FS_Site` entities no longer have the `plan` property and have `plan_id`
514
+ * instead. This should be called before calling `_load_account()`, otherwise, `$this->_site` will not be
515
+ * loaded in `_load_account` for versions of SDK starting from 2.0.0.
516
+ *
517
+ * @author Leo Fajardo (@leorw)
518
+ */
519
+ self::migrate_install_plan_to_plan_id( $this->_storage );
520
+
521
+ $this->_load_account();
522
+
523
+ $this->_version_updates_handler();
524
+ }
525
+
526
+ /**
527
+ * @author Leo Fajardo (@leorw)
528
+ * @since 2.3.0
529
+ */
530
+ private function maybe_adjust_storage() {
531
+ $install_timestamp = null;
532
+ $prev_is_premium = null;
533
+
534
+ $options_to_update = array();
535
+
536
+ $is_network_admin = fs_is_network_admin();
537
+
538
+ $network_install_timestamp = $this->_storage->get( 'install_timestamp', null, true );
539
+
540
+ if ( ! $is_network_admin ) {
541
+ if ( is_null( $network_install_timestamp ) ) {
542
+ // Plugin was not network-activated before.
543
+ return;
544
+ }
545
+
546
+ if ( is_null( $this->_storage->get( 'install_timestamp', null, false ) ) ) {
547
+ // Set the `install_timestamp` only if it's not yet set.
548
+ $install_timestamp = $network_install_timestamp;
549
+ }
550
+
551
+ $prev_is_premium = $this->_storage->get( 'prev_is_premium', null, true );
552
+ } else {
553
+ $current_wp_user = self::_get_current_wp_user();
554
+ $current_fs_user = self::_get_user_by_email( $current_wp_user->user_email );
555
+ $network_user_info = array();
556
+
557
+ $skips_count = 0;
558
+
559
+ $sites = self::get_sites();
560
+ $sites_count = count( $sites );
561
+
562
+ $blog_id_2_install_map = array();
563
+
564
+ $is_first_non_ignored_blog = true;
565
+
566
+ foreach ( $sites as $site ) {
567
+ $blog_id = self::get_site_blog_id( $site );
568
+
569
+ $blog_install_timestamp = $this->_storage->get( 'install_timestamp', null, $blog_id );
570
+
571
+ if ( is_null( $blog_install_timestamp ) ) {
572
+ // Plugin has not been installed on this blog.
573
+ continue;
574
+ }
575
+
576
+ $is_earlier_install = (
577
+ ! is_null( $install_timestamp ) &&
578
+ $blog_install_timestamp < $install_timestamp
579
+ );
580
+
581
+ $install = $this->get_install_by_blog_id( $blog_id );
582
+
583
+ $update_network_user_info = false;
584
+
585
+ if ( ! is_object( $install ) ) {
586
+ if ( ! $this->_storage->get( 'is_anonymous', false, $blog_id ) ) {
587
+ // The opt-in decision (whether to skip or opt in) is yet to be made.
588
+ continue;
589
+ }
590
+
591
+ $skips_count ++;
592
+ } else {
593
+ $blog_id_2_install_map[ $blog_id ] = $install;
594
+
595
+ if ( empty( $network_user_info ) ) {
596
+ // Set the network user info for the 1st time. Choose any user information whether or not it is for the current WP user.
597
+ $update_network_user_info = true;
598
+ }
599
+
600
+ if ( ! $update_network_user_info &&
601
+ is_object( $current_fs_user ) &&
602
+ $network_user_info['user_id'] != $current_fs_user->id &&
603
+ $install->user_id == $current_fs_user->id
604
+ ) {
605
+ // If an install that is owned by the current WP user is found, use its user information instead.
606
+ $update_network_user_info = true;
607
+ }
608
+
609
+ if ( ! $update_network_user_info &&
610
+ $is_earlier_install &&
611
+ ( ! is_object( $current_fs_user ) || $current_fs_user->id == $install->user_id )
612
+ ) {
613
+ // Update to the earliest install info if there's no install found so far that is owned by the current WP user; OR only if the found install is owned by the current WP user.
614
+ $update_network_user_info = true;
615
+ }
616
+ }
617
+
618
+ if ( $update_network_user_info ) {
619
+ $network_user_info = array(
620
+ 'user_id' => $install->user_id,
621
+ 'blog_id' => $blog_id
622
+ );
623
+ }
624
+
625
+ $site_prev_is_premium = $this->_storage->get( 'prev_is_premium', null, $blog_id );
626
+
627
+ if ( $is_first_non_ignored_blog ) {
628
+ $prev_is_premium = $site_prev_is_premium;
629
+
630
+ if ( is_null( $network_install_timestamp ) ) {
631
+ $install_timestamp = $blog_install_timestamp;
632
+ }
633
+
634
+ $is_first_non_ignored_blog = false;
635
+
636
+ continue;
637
+ }
638
+
639
+ if ( ! is_null( $prev_is_premium ) && $prev_is_premium !== $site_prev_is_premium ) {
640
+ // If a different `$site_prev_is_premium` value is found, do not include the option in the collection of options to update.
641
+ $prev_is_premium = null;
642
+ }
643
+
644
+ if ( $is_earlier_install ) {
645
+ // If an earlier install timestamp is found.
646
+ $install_timestamp = $blog_install_timestamp;
647
+ }
648
+ }
649
+
650
+ $installs_count = count( $blog_id_2_install_map );
651
+
652
+ if ( $sites_count === ( $installs_count + $skips_count ) ) {
653
+ if ( ! empty( $network_user_info ) ) {
654
+ $options_to_update['network_user_id'] = $network_user_info['user_id'];
655
+ $options_to_update['network_install_blog_id'] = $network_user_info['blog_id'];
656
+
657
+ foreach ( $blog_id_2_install_map as $blog_id => $install ) {
658
+ if ( $install->user_id == $network_user_info['user_id'] ) {
659
+ continue;
660
+ }
661
+
662
+ $this->_storage->store( 'is_delegated_connection', true, $blog_id );
663
+ }
664
+ }
665
+
666
+ if ( $sites_count === $skips_count ) {
667
+ /**
668
+ * Assume network-level skipping as the intended action if all actions identified were only
669
+ * skipping of the connection (i.e., no opt-ins and delegated connections so far).
670
+ */
671
+ $options_to_update['is_anonymous_ms'] = true;
672
+ } else if ( $sites_count === $installs_count ) {
673
+ /**
674
+ * Assume network-level opt-in as the intended action if all actions identified were only opt-ins
675
+ * (i.e., no delegation and skipping of the connections so far).
676
+ */
677
+ $options_to_update['is_network_connected'] = true;
678
+ }
679
+ }
680
+ }
681
+
682
+ if ( ! is_null( $install_timestamp ) ) {
683
+ $options_to_update['install_timestamp'] = $install_timestamp;
684
+ }
685
+
686
+ if ( ! is_null( $prev_is_premium ) ) {
687
+ $options_to_update['prev_is_premium'] = $prev_is_premium;
688
+ }
689
+
690
+ if ( ! empty( $options_to_update ) ) {
691
+ $this->adjust_storage( $options_to_update, $is_network_admin );
692
+ }
693
+ }
694
+
695
+ /**
696
+ * @author Leo Fajardo (@leorw)
697
+ * @since 2.3.0
698
+ *
699
+ * @param array $options
700
+ * @param bool $is_network_admin
701
+ */
702
+ private function adjust_storage( $options, $is_network_admin ) {
703
+ foreach ( $options as $name => $value ) {
704
+ $this->_storage->store( $name, $value, $is_network_admin ? true : null );
705
+ }
706
+ }
707
+
708
+ /**
709
+ * Checks whether this module has a settings menu.
710
+ *
711
+ * @author Leo Fajardo (@leorw)
712
+ * @since 1.2.2
713
+ *
714
+ * @return bool
715
+ */
716
+ function has_settings_menu() {
717
+ return ( $this->_is_network_active && fs_is_network_admin() ) ?
718
+ $this->_menu->has_network_menu() :
719
+ $this->_menu->has_menu();
720
+ }
721
+
722
+ /**
723
+ * If `true` the opt-in should be shown as a modal dialog box on the themes.php page. WordPress.org themes guidelines prohibit from redirecting the user from the themes.php page after activating a theme.
724
+ *
725
+ * @author Vova Feldman (@svovaf)
726
+ * @since 2.4.5
727
+ *
728
+ * @return bool
729
+ */
730
+ function show_opt_in_on_themes_page() {
731
+ if ( ! $this->is_free_wp_org_theme() ) {
732
+ return false;
733
+ }
734
+
735
+ if ( ! $this->has_settings_menu() ) {
736
+ return true;
737
+ }
738
+
739
+ return $this->show_settings_with_tabs();
740
+ }
741
+
742
+ /**
743
+ * If `true` the opt-in should be shown on the product's main setting page.
744
+ *
745
+ * @author Vova Feldman (@svovaf)
746
+ * @since 2.4.5
747
+ *
748
+ * @return bool
749
+ *
750
+ * @uses show_opt_in_on_themes_page();
751
+ */
752
+ function show_opt_in_on_setting_page() {
753
+ return ! $this->show_opt_in_on_themes_page();
754
+ }
755
+
756
+ /**
757
+ * If `true` the settings should be shown using tabs.
758
+ *
759
+ * @author Vova Feldman (@svovaf)
760
+ * @since 2.4.5
761
+ *
762
+ * @return bool
763
+ */
764
+ function show_settings_with_tabs() {
765
+ return ( self::NAVIGATION_TABS === $this->_navigation );
766
+ }
767
+
768
+ /**
769
+ * Check if the context module is free wp.org theme.
770
+ *
771
+ * This method is helpful because:
772
+ * 1. wp.org themes are limited to a single submenu item,
773
+ * and sub-submenu items are most likely not allowed (never verified).
774
+ * 2. wp.org themes are not allowed to redirect the user
775
+ * after the theme activation, therefore, the agreed UX
776
+ * is showing the opt-in as a modal dialog box after
777
+ * activation (approved by @otto42, @emiluzelac, @greenshady, @grapplerulrich).
778
+ *
779
+ * @author Vova Feldman (@svovaf)
780
+ * @since 1.2.2.7
781
+ *
782
+ * @return bool
783
+ */
784
+ function is_free_wp_org_theme() {
785
+ return (
786
+ $this->is_theme() &&
787
+ $this->is_org_repo_compliant() &&
788
+ ! $this->is_premium()
789
+ );
790
+ }
791
+
792
+ /**
793
+ * Checks whether this a submenu item is visible.
794
+ *
795
+ * @author Vova Feldman (@svovaf)
796
+ * @since 1.2.2.6
797
+ * @since 1.2.2.7 Even if the menu item was specified to be hidden, when it is the context page, then show the submenu item so the user will have the right context page.
798
+ *
799
+ * @param string $slug
800
+ * @param bool $is_tabs_visibility_check This is used to decide if the associated tab should be shown or hidden.
801
+ *
802
+ * @return bool
803
+ */
804
+ function is_submenu_item_visible( $slug, $is_tabs_visibility_check = false ) {
805
+ if ( $this->is_admin_page( $slug ) ) {
806
+ /**
807
+ * It is the current context page, so show the submenu item
808
+ * so the user will have the right context page, even if it
809
+ * was set to hidden.
810
+ */
811
+ return true;
812
+ }
813
+
814
+ if ( ! $this->has_settings_menu() ) {
815
+ // No menu settings at all.
816
+ return false;
817
+ }
818
+
819
+ if ( ! $is_tabs_visibility_check && $this->show_settings_with_tabs() ) {
820
+ /**
821
+ * wp.org themes are limited to a single submenu item, and
822
+ * sub-submenu items are most likely not allowed (never verified).
823
+ */
824
+ return false;
825
+ }
826
+
827
+ return $this->_menu->is_submenu_item_visible( $slug );
828
+ }
829
+
830
+ /**
831
+ * Check if a Freemius page should be accessible via the UI.
832
+ *
833
+ * @author Vova Feldman (@svovaf)
834
+ * @since 1.2.2.7
835
+ *
836
+ * @param string $slug
837
+ *
838
+ * @return bool
839
+ */
840
+ function is_page_visible( $slug ) {
841
+ if ( $this->is_admin_page( $slug ) ) {
842
+ return true;
843
+ }
844
+
845
+ return $this->_menu->is_submenu_item_visible( $slug, true, true );
846
+ }
847
+
848
+ /**
849
+ * @author Vova Feldman (@svovaf)
850
+ * @since 1.0.9
851
+ */
852
+ private function _version_updates_handler() {
853
+ if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
854
+ // Freemius version upgrade mode.
855
+ $this->_storage->sdk_last_version = $this->_storage->sdk_version;
856
+ $this->_storage->sdk_version = $this->version;
857
+
858
+ if ( empty( $this->_storage->sdk_last_version ) ||
859
+ version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
860
+ ) {
861
+ $this->_storage->sdk_upgrade_mode = true;
862
+ $this->_storage->sdk_downgrade_mode = false;
863
+ } else {
864
+ $this->_storage->sdk_downgrade_mode = true;
865
+ $this->_storage->sdk_upgrade_mode = false;
866
+
867
+ }
868
+
869
+ $this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
870
+ }
871
+
872
+ $plugin_version = $this->get_plugin_version();
873
+ if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
874
+ // Plugin version upgrade mode.
875
+ $this->_storage->plugin_last_version = $this->_storage->plugin_version;
876
+ $this->_storage->plugin_version = $plugin_version;
877
+
878
+ if ( empty( $this->_storage->plugin_last_version ) ||
879
+ version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
880
+ ) {
881
+ $this->_storage->plugin_upgrade_mode = true;
882
+ $this->_storage->plugin_downgrade_mode = false;
883
+ } else {
884
+ $this->_storage->plugin_downgrade_mode = true;
885
+ $this->_storage->plugin_upgrade_mode = false;
886
+ }
887
+
888
+ if ( ! empty( $this->_storage->plugin_last_version ) ) {
889
+ // Different version of the plugin was installed before, therefore it's an update.
890
+ $this->_storage->is_plugin_new_install = false;
891
+ }
892
+
893
+ $this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
894
+ }
895
+ }
896
+
897
+ #--------------------------------------------------------------------------------
898
+ #region Data Migration on SDK Update
899
+ #--------------------------------------------------------------------------------
900
+
901
+ /**
902
+ * @author Vova Feldman (@svovaf)
903
+ * @since 1.1.5
904
+ *
905
+ * @param string $sdk_prev_version
906
+ * @param string $sdk_version
907
+ */
908
+ function _sdk_version_update( $sdk_prev_version, $sdk_version ) {
909
+ /**
910
+ * @since 1.1.7.3 Fixed unwanted connectivity test cleanup.
911
+ */
912
+ if ( empty( $sdk_prev_version ) ) {
913
+ return;
914
+ }
915
+
916
+ if ( version_compare( $sdk_prev_version, '2.1.0', '<' ) &&
917
+ version_compare( $sdk_version, '2.1.0', '>=' )
918
+ ) {
919
+ $this->_storage->handle_gdpr_admin_notice = true;
920
+ }
921
+
922
+ if ( version_compare( $sdk_prev_version, '2.0.0', '<' ) &&
923
+ version_compare( $sdk_version, '2.0.0', '>=' )
924
+ ) {
925
+ $this->migrate_to_subscriptions_collection();
926
+
927
+ $this->consolidate_licenses();
928
+
929
+ // Clear trial_plan since it's now loaded from the plans collection when needed.
930
+ $this->_storage->remove( 'trial_plan', true, false );
931
+ }
932
+
933
+ if ( version_compare( $sdk_prev_version, '1.2.3', '<' ) &&
934
+ version_compare( $sdk_version, '1.2.3', '>=' )
935
+ ) {
936
+ /**
937
+ * Starting from version 1.2.3, paths are stored as relative instead of absolute and some of them can be
938
+ * invalid.
939
+ *
940
+ * @author Leo Fajardo (@leorw)
941
+ */
942
+ $this->remove_invalid_paths();
943
+ }
944
+
945
+ if ( version_compare( $sdk_prev_version, '1.1.5', '<' ) &&
946
+ version_compare( $sdk_version, '1.1.5', '>=' )
947
+ ) {
948
+ // On version 1.1.5 merged connectivity and is_on data.
949
+ if ( isset( $this->_storage->connectivity_test ) ) {
950
+ if ( ! isset( $this->_storage->is_on ) ) {
951
+ unset( $this->_storage->connectivity_test );
952
+ } else {
953
+ $connectivity_data = $this->_storage->connectivity_test;
954
+ $connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
955
+ $connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
956
+
957
+ // Override.
958
+ $this->_storage->connectivity_test = $connectivity_data;
959
+
960
+ // Remove previous structure.
961
+ unset( $this->_storage->is_on );
962
+ }
963
+
964
+ }
965
+ }
966
+
967
+ if (
968
+ version_compare( $sdk_prev_version, '2.2.1', '<' ) &&
969
+ version_compare( $sdk_version, '2.2.1', '>=' )
970
+ ) {
971
+ /**
972
+ * Clear the file cache without storing the previous path since it could be a wrong path. For example,
973
+ * in the versions of the SDK lower than 2.2.1, it's possible for the path of an add-on to be the same
974
+ * as the parent plugin's when the add-on was auto-installed since the relevant method names were not
975
+ * skipped in the logic that determines the right path in the `get_caller_main_file_and_type` method
976
+ * (e.g. `try_activate_plugin`). Since it was an auto-installation, the caller was the parent plugin
977
+ * and so its path was used. In case the stored path is wrong, clearing the cache will resolve issues
978
+ * related to data mix-up between plugins (e.g. titles and versions of an add-on and its parent plugin).
979
+ *
980
+ * @author Leo Fajardo (@leorw)
981
+ * @since 2.2.1
982
+ */
983
+ $this->clear_module_main_file_cache( false );
984
+ }
985
+ }
986
+
987
+ /**
988
+ * @author Leo Fajardo (@leorw)
989
+ * @since 2.0.0
990
+ *
991
+ * @param \FS_Storage $storage
992
+ * @param bool|int|null $blog_id
993
+ */
994
+ private static function migrate_install_plan_to_plan_id( FS_Storage $storage, $blog_id = null ) {
995
+ if ( empty( $storage->sdk_version ) ) {
996
+ // New installation of the plugin, no need to upgrade.
997
+ return;
998
+ }
999
+
1000
+ if ( ! version_compare( $storage->sdk_version, '2.0.0', '<' ) ) {
1001
+ // Previous version is >= 2.0.0, so no need to migrate.
1002
+ return;
1003
+ }
1004
+
1005
+ // Alias.
1006
+ $module_type = $storage->get_module_type();
1007
+ $module_slug = $storage->get_module_slug();
1008
+
1009
+ $installs = self::get_all_sites( $module_type, $blog_id );
1010
+ $install = isset( $installs[ $module_slug ] ) ? $installs[ $module_slug ] : null;
1011
+
1012
+ if ( ! is_object( $install ) ) {
1013
+ return;
1014
+ }
1015
+
1016
+ if ( isset( $install->plan ) && is_object( $install->plan ) ) {
1017
+ if ( isset( $install->plan->id ) && ! empty( $install->plan->id ) ) {
1018
+ $install->plan_id = self::_decrypt( $install->plan->id );
1019
+ }
1020
+
1021
+ unset( $install->plan );
1022
+
1023
+ $installs[ $module_slug ] = clone $install;
1024
+
1025
+ self::set_account_option_by_module(
1026
+ $module_type,
1027
+ 'sites',
1028
+ $installs,
1029
+ true,
1030
+ $blog_id
1031
+ );
1032
+ }
1033
+ }
1034
+
1035
+ /**
1036
+ * @author Leo Fajardo (@leorw)
1037
+ * @since 2.0.0
1038
+ */
1039
+ private function migrate_to_subscriptions_collection() {
1040
+ if ( ! is_object( $this->_site ) ) {
1041
+ return;
1042
+ }
1043
+
1044
+ if ( isset( $this->_storage->subscription ) && is_object( $this->_storage->subscription ) ) {
1045
+ $this->_storage->subscriptions = array( fs_get_entity( $this->_storage->subscription, FS_Subscription::get_class_name() ) );
1046
+ }
1047
+ }
1048
+
1049
+ /**
1050
+ * @author Leo Fajardo (@leorw)
1051
+ * @since 2.0.0
1052
+ */
1053
+ private function consolidate_licenses() {
1054
+ $plugin_licenses = self::get_account_option( 'licenses', WP_FS__MODULE_TYPE_PLUGIN );
1055
+ if ( isset( $plugin_licenses[ $this->_slug ] ) ) {
1056
+ $plugin_licenses = $plugin_licenses[ $this->_slug ];
1057
+ } else {
1058
+ $plugin_licenses = array();
1059
+ }
1060
+
1061
+ $theme_licenses = self::get_account_option( 'licenses', WP_FS__MODULE_TYPE_THEME );
1062
+ if ( isset( $theme_licenses[ $this->_slug ] ) ) {
1063
+ $theme_licenses = $theme_licenses[ $this->_slug ];
1064
+ } else {
1065
+ $theme_licenses = array();
1066
+ }
1067
+
1068
+ if ( empty( $plugin_licenses ) && empty( $theme_licenses ) ) {
1069
+ return;
1070
+ }
1071
+
1072
+ $all_licenses = array();
1073
+ $user_id_license_ids_map = array();
1074
+
1075
+ foreach ( $plugin_licenses as $user_id => $user_licenses ) {
1076
+ if ( is_array( $user_licenses ) ) {
1077
+ if ( ! isset( $user_license_ids[ $user_id ] ) ) {
1078
+ $user_id_license_ids_map[ $user_id ] = array();
1079
+ }
1080
+
1081
+ foreach ( $user_licenses as $user_license ) {
1082
+ $all_licenses[] = $user_license;
1083
+ $user_id_license_ids_map[ $user_id ][] = $user_license->id;
1084
+ }
1085
+ }
1086
+ }
1087
+
1088
+ foreach ( $theme_licenses as $user_id => $user_licenses ) {
1089
+ if ( is_array( $user_licenses ) ) {
1090
+ if ( ! isset( $user_license_ids[ $user_id ] ) ) {
1091
+ $user_id_license_ids_map[ $user_id ] = array();
1092
+ }
1093
+
1094
+ foreach ( $user_licenses as $user_license ) {
1095
+ $all_licenses[] = $user_license;
1096
+ $user_id_license_ids_map[ $user_id ][] = $user_license->id;
1097
+ }
1098
+ }
1099
+ }
1100
+
1101
+ self::store_user_id_license_ids_map(
1102
+ $user_id_license_ids_map,
1103
+ $this->_module_id
1104
+ );
1105
+
1106
+ $this->_store_licenses( true, $this->_module_id, $all_licenses );
1107
+ }
1108
+
1109
+ /**
1110
+ * Remove invalid paths.
1111
+ *
1112
+ * @author Leo Fajardo (@leorw)
1113
+ * @since 1.2.3
1114
+ */
1115
+ private function remove_invalid_paths() {
1116
+ // Remove invalid path that is still associated with the current slug if there's any.
1117
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
1118
+ foreach ( $file_slug_map as $plugin_basename => $slug ) {
1119
+ if ( $slug === $this->_slug &&
1120
+ $plugin_basename !== $this->_plugin_basename &&
1121
+ ! file_exists( $this->get_absolute_path( $plugin_basename ) )
1122
+ ) {
1123
+ unset( $file_slug_map[ $plugin_basename ] );
1124
+ self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
1125
+
1126
+ break;
1127
+ }
1128
+ }
1129
+ }
1130
+
1131
+ /**
1132
+ * @author Vova Feldman (@svovaf)
1133
+ * @since 1.2.2.7
1134
+ *
1135
+ * @param string $plugin_prev_version
1136
+ * @param string $plugin_version
1137
+ */
1138
+ function _after_version_update( $plugin_prev_version, $plugin_version ) {
1139
+ if ( $this->is_theme() ) {
1140
+ // Expire the cache of the previous tabs since the theme may
1141
+ // have setting updates.
1142
+ $this->_cache->expire( 'tabs' );
1143
+ $this->_cache->expire( 'tabs_stylesheets' );
1144
+ }
1145
+ }
1146
+
1147
+ /**
1148
+ * A special migration logic for the $_accounts, executed for all the plugins in the system:
1149
+ * - Moves some data to the network level storage.
1150
+ * - If the plugin's connection was skipped for all sites, set the plugin as if it was network skipped.
1151
+ * - If the plugin's connection was ignored for all sites, don't do anything in terms of the network connection.
1152
+ * - If the plugin was connected to all sites by the same super-admin, set the plugin as if was network opted-in for all sites.
1153
+ * - If there's at least one site that was connected by a super-admin, find the "main super-admin" (the one that installed the majority of the plugin installs) and set the plugin as if was network activated with the main super-admin, set all the sites that were skipped or opted-in with a different user to delegated mode. Then, prompt the currently logged super-admin to choose what to do with the ignored sites.
1154
+ * - If there are any sites in the network which the connection decision was not yet taken for, set this plugin into network activation mode so a super-admin can choose what to do with the rest of the sites.
1155
+ *
1156
+ * @author Vova Feldman (@svovaf)
1157
+ * @since 2.0.0
1158
+ */
1159
+ private static function migrate_accounts_to_network() {
1160
+ $sites = self::get_sites();
1161
+ $sites_count = count( $sites );
1162
+ $connection_status = array();
1163
+ $plugin_slugs = array();
1164
+ foreach ( $sites as $site ) {
1165
+ $blog_id = self::get_site_blog_id( $site );
1166
+
1167
+ self::$_accounts->migrate_to_network( $blog_id );
1168
+
1169
+ /**
1170
+ * Build a list of all Freemius powered plugins slugs.
1171
+ */
1172
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array(), $blog_id );
1173
+ foreach ( $id_slug_type_path_map as $module_id => $data ) {
1174
+ if ( WP_FS__MODULE_TYPE_PLUGIN === $data['type'] ) {
1175
+ $plugin_slugs[ $data['slug'] ] = true;
1176
+ }
1177
+ }
1178
+
1179
+ $installs = self::get_account_option( 'sites', WP_FS__MODULE_TYPE_PLUGIN, $blog_id );
1180
+
1181
+ if ( is_array( $installs ) ) {
1182
+ foreach ( $installs as $slug => $install ) {
1183
+ if ( ! isset( $connection_status[ $slug ] ) ) {
1184
+ $connection_status[ $slug ] = array();
1185
+ }
1186
+
1187
+ if ( is_object( $install ) &&
1188
+ FS_Site::is_valid_id( $install->id ) &&
1189
+ FS_User::is_valid_id( $install->user_id )
1190
+ ) {
1191
+ $connection_status[ $slug ][ $blog_id ] = $install->user_id;
1192
+ }
1193
+ }
1194
+ }
1195
+ }
1196
+
1197
+ foreach ( $plugin_slugs as $slug => $true ) {
1198
+ if ( ! isset( $connection_status[ $slug ] ) ) {
1199
+ $connection_status[ $slug ] = array();
1200
+ }
1201
+
1202
+ foreach ( $sites as $site ) {
1203
+ $blog_id = self::get_site_blog_id( $site );
1204
+
1205
+ if ( isset( $connection_status[ $slug ][ $blog_id ] ) ) {
1206
+ continue;
1207
+ }
1208
+
1209
+ $storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
1210
+
1211
+ $is_anonymous = $storage->get( 'is_anonymous', null, $blog_id );
1212
+
1213
+ if ( ! is_null( $is_anonymous ) ) {
1214
+ // Since 1.1.3 is_anonymous is an array.
1215
+ if ( is_array( $is_anonymous ) && isset( $is_anonymous['is'] ) ) {
1216
+ $is_anonymous = $is_anonymous['is'];
1217
+ }
1218
+
1219
+ if ( is_bool( $is_anonymous ) && true === $is_anonymous ) {
1220
+ $connection_status[ $slug ][ $blog_id ] = 'skipped';
1221
+ }
1222
+ }
1223
+
1224
+ if ( ! isset( $connection_status[ $slug ][ $blog_id ] ) ) {
1225
+ $connection_status[ $slug ][ $blog_id ] = 'ignored';
1226
+ }
1227
+ }
1228
+ }
1229
+
1230
+ $super_admins = array();
1231
+
1232
+ foreach ( $connection_status as $slug => $blogs_status ) {
1233
+ $skips = 0;
1234
+ $ignores = 0;
1235
+ $connections = 0;
1236
+ $opted_in_users = array();
1237
+ $opted_in_super_admins = array();
1238
+
1239
+ $storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
1240
+
1241
+ foreach ( $blogs_status as $blog_id => $status_or_user_id ) {
1242
+ if ( 'skipped' === $status_or_user_id ) {
1243
+ $skips ++;
1244
+ } else if ( 'ignored' === $status_or_user_id ) {
1245
+ $ignores ++;
1246
+ } else if ( FS_User::is_valid_id( $status_or_user_id ) ) {
1247
+ $connections ++;
1248
+
1249
+ if ( ! isset( $opted_in_users[ $status_or_user_id ] ) ) {
1250
+ $opted_in_users[ $status_or_user_id ] = array();
1251
+ }
1252
+
1253
+ $opted_in_users[ $status_or_user_id ][] = $blog_id;
1254
+
1255
+ if ( isset( $super_admins[ $status_or_user_id ] ) ||
1256
+ self::is_super_admin( $status_or_user_id )
1257
+ ) {
1258
+ // Cache super-admin data.
1259
+ $super_admins[ $status_or_user_id ] = true;
1260
+
1261
+ // Remember opted-in super-admins for the plugin.
1262
+ $opted_in_super_admins[ $status_or_user_id ] = true;
1263
+ }
1264
+ }
1265
+ }
1266
+
1267
+ $main_super_admin_user_id = null;
1268
+ $all_migrated = false;
1269
+ if ( $sites_count == $skips ) {
1270
+ // All sites were skipped -> network skip by copying the anonymous mode from any of the sites.
1271
+ $storage->is_anonymous_ms = $storage->is_anonymous;
1272
+
1273
+ $all_migrated = true;
1274
+ } else if ( $sites_count == $ignores ) {
1275
+ // Don't do anything, still in activation mode.
1276
+
1277
+ $all_migrated = true;
1278
+ } else if ( 0 < count( $opted_in_super_admins ) ) {
1279
+ // Find the super-admin with the majority of installs.
1280
+ $max_installs_by_super_admin = 0;
1281
+ foreach ( $opted_in_super_admins as $user_id => $true ) {
1282
+ $installs_count = count( $opted_in_users[ $user_id ] );
1283
+
1284
+ if ( $installs_count > $max_installs_by_super_admin ) {
1285
+ $max_installs_by_super_admin = $installs_count;
1286
+ $main_super_admin_user_id = $user_id;
1287
+ }
1288
+ }
1289
+
1290
+ if ( $sites_count == $connections && 1 == count( $opted_in_super_admins ) ) {
1291
+ // Super-admin opted-in for all sites in the network.
1292
+ $storage->is_network_connected = true;
1293
+
1294
+ $all_migrated = true;
1295
+ }
1296
+
1297
+ // Store network user.
1298
+ $storage->network_user_id = $main_super_admin_user_id;
1299
+
1300
+ $storage->network_install_blog_id = ( $sites_count == $connections ) ?
1301
+ // Since all sites are opted-in, associating with the main site.
1302
+ get_current_blog_id() :
1303
+ // Associating with the 1st found opted-in site.
1304
+ $opted_in_users[ $main_super_admin_user_id ][0];
1305
+
1306
+ /**
1307
+ * Make sure we migrate the plan ID of the network install, otherwise, if after the migration
1308
+ * the 1st page that will be loaded is the network level WP Admin and $storage->network_install_blog_id
1309
+ * is different than the main site of the network, the $this->_site will not be set since the plan_id
1310
+ * will be empty.
1311
+ */
1312
+ $storage->migrate_to_network();
1313
+ self::migrate_install_plan_to_plan_id( $storage, $storage->network_install_blog_id );
1314
+ } else {
1315
+ // At least one opt-in. All the opt-in were created by a non-super-admin.
1316
+ if ( 0 == $ignores ) {
1317
+ // All sites were opted-in or skipped, all by non-super-admin. So delegate all.
1318
+ $storage->store( 'is_delegated_connection', true, true );
1319
+
1320
+ $all_migrated = true;
1321
+ }
1322
+ }
1323
+
1324
+ if ( ! $all_migrated ) {
1325
+ /**
1326
+ * Delegate all sites that were:
1327
+ * 1) Opted-in by a user that is NOT the main-super-admin.
1328
+ * 2) Skipped and non of the sites was opted-in by a super-admin. If any site was opted-in by a super-admin, there will be a main-super-admin, and we consider the skip as if it was done by that user.
1329
+ */
1330
+ foreach ( $blogs_status as $blog_id => $status_or_user_id ) {
1331
+ if ( $status_or_user_id == $main_super_admin_user_id ) {
1332
+ continue;
1333
+ }
1334
+
1335
+ if ( FS_User::is_valid_id( $status_or_user_id ) ||
1336
+ ( 'skipped' === $status_or_user_id && is_null( $main_super_admin_user_id ) )
1337
+ ) {
1338
+ $storage->store( 'is_delegated_connection', true, $blog_id );
1339
+ }
1340
+ }
1341
+ }
1342
+
1343
+
1344
+ if ( ( $connections + $skips > 0 ) ) {
1345
+ if ( $ignores > 0 ) {
1346
+ /**
1347
+ * If admin already opted-in or skipped in any of the network sites, and also
1348
+ * have sites which the connection decision was not yet taken, set this plugin
1349
+ * into network activation mode so the super-admin can choose what to do with
1350
+ * the rest of the sites.
1351
+ */
1352
+ self::set_network_upgrade_mode( $storage );
1353
+ }
1354
+ }
1355
+ }
1356
+ }
1357
+
1358
+ /**
1359
+ * Set a module into network upgrade mode.
1360
+ *
1361
+ * @author Vova Feldman (@svovaf)
1362
+ * @since 2.0.0
1363
+ *
1364
+ * @param \FS_Storage $storage
1365
+ *
1366
+ * @return bool
1367
+ */
1368
+ private static function set_network_upgrade_mode( FS_Storage $storage ) {
1369
+ return $storage->is_network_activation = true;
1370
+ }
1371
+
1372
+ /**
1373
+ * Will return true after upgrading to the SDK with the network level integration,
1374
+ * when the super-admin involvement is required regarding the rest of the sites.
1375
+ *
1376
+ * @author Vova Feldman (@svovaf)
1377
+ * @since 2.0.0
1378
+ *
1379
+ * @return bool
1380
+ */
1381
+ function is_network_upgrade_mode() {
1382
+ return $this->_storage->get( 'is_network_activation' );
1383
+ }
1384
+
1385
+ /**
1386
+ * Clear flag after the upgrade mode completion.
1387
+ *
1388
+ * @author Vova Feldman (@svovaf)
1389
+ * @since 2.0.0
1390
+ *
1391
+ * @return bool True if network activation was on and now completed.
1392
+ */
1393
+ private function network_upgrade_mode_completed() {
1394
+ if ( fs_is_network_admin() && $this->is_network_upgrade_mode() ) {
1395
+ $this->_storage->remove( 'is_network_activation' );
1396
+
1397
+ return true;
1398
+ }
1399
+
1400
+ return false;
1401
+ }
1402
+
1403
+ #endregion
1404
+
1405
+ /**
1406
+ * This action is connected to the 'plugins_loaded' hook and helps to determine
1407
+ * if this is a new plugin installation or a plugin update.
1408
+ *
1409
+ * There are 3 different use-cases:
1410
+ * 1) New plugin installation right with Freemius:
1411
+ * 1.1 _activate_plugin_event_hook() will be executed first
1412
+ * 1.2 Since $this->_storage->is_plugin_new_install is not set,
1413
+ * and $this->_storage->plugin_last_version is not set,
1414
+ * $this->_storage->is_plugin_new_install will be set to TRUE.
1415
+ * 1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
1416
+ * be already set to TRUE.
1417
+ *
1418
+ * 2) Plugin update, didn't have Freemius before, and now have the SDK:
1419
+ * 2.1 _activate_plugin_event_hook() will not be executed, because
1420
+ * the activation hook do NOT fires on updates since WP 3.1.
1421
+ * 2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
1422
+ * be empty, therefore, it will be set to FALSE.
1423
+ *
1424
+ * 3) Plugin update, had Freemius in prev version as well:
1425
+ * 3.1 _version_updates_handler() will be executed 1st, since FS was installed
1426
+ * before, $this->_storage->plugin_last_version will NOT be empty,
1427
+ * therefore, $this->_storage->is_plugin_new_install will be set to FALSE.
1428
+ * 3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is
1429
+ * already set, therefore, it will not be modified.
1430
+ *
1431
+ * Use-case #3 is backward compatible, #3.1 will be executed since 1.0.9.
1432
+ *
1433
+ * NOTE:
1434
+ * The only fallback of this mechanism is if an admin updates a plugin based on use-case #2,
1435
+ * and then, the next immediate PageView is the plugin's main settings page, it will not
1436
+ * show the opt-in right away. The reason it will happen is because Freemius execution
1437
+ * will be turned off till the plugin is fully loaded at least once
1438
+ * (till $this->_storage->was_plugin_loaded is TRUE).
1439
+ *
1440
+ * @author Vova Feldman (@svovaf)
1441
+ * @since 1.1.9
1442
+ *
1443
+ */
1444
+ function _plugins_loaded() {
1445
+ // Update flag that plugin was loaded with Freemius at least once.
1446
+ $this->_storage->was_plugin_loaded = true;
1447
+
1448
+ /**
1449
+ * Bug fix - only set to false when it's a plugin, due to the
1450
+ * execution sequence of the theme hooks and our methods, if
1451
+ * this will be set for themes, Freemius will always assume
1452
+ * it's a theme update.
1453
+ *
1454
+ * @author Vova Feldman (@svovaf)
1455
+ * @since 1.2.2.2
1456
+ */
1457
+ if ( $this->is_plugin() &&
1458
+ ! isset( $this->_storage->is_plugin_new_install )
1459
+ ) {
1460
+ $this->_storage->is_plugin_new_install = false;
1461
+ }
1462
+ }
1463
+
1464
+ /**
1465
+ * Add special parameter to WP admin AJAX calls so when we
1466
+ * process AJAX calls we can identify its source properly.
1467
+ *
1468
+ * @author Leo Fajardo (@leorw)
1469
+ * @since 2.0.0
1470
+ */
1471
+ static function _enrich_ajax_url() {
1472
+ $admin_param = is_network_admin() ?
1473
+ '_fs_network_admin' :
1474
+ '_fs_blog_admin';
1475
+ ?>
1476
+ <script type="text/javascript">
1477
+ (function ($) {
1478
+ $(document).ajaxSend(function (event, jqxhr, settings) {
1479
+ if (settings.url &&
1480
+ -1 < settings.url.indexOf('admin-ajax.php') &&
1481
+ ! ( settings.url.indexOf( '<?php echo $admin_param ?>' ) > 0 )
1482
+ ) {
1483
+ if (settings.url.indexOf('?') > 0) {
1484
+ settings.url += '&';
1485
+ } else {
1486
+ settings.url += '?';
1487
+ }
1488
+
1489
+ settings.url += '<?php echo $admin_param ?>=true';
1490
+
1491
+ }
1492
+ });
1493
+ })(jQuery);
1494
+ </script>
1495
+ <?php
1496
+ }
1497
+
1498
+ /**
1499
+ * Opens the support forum subemenu item in a new browser page.
1500
+ *
1501
+ * @author Vova Feldman (@svovaf)
1502
+ * @since 2.1.4
1503
+ */
1504
+ static function _open_support_forum_in_new_page() {
1505
+ ?>
1506
+ <script type="text/javascript">
1507
+ (function ($) {
1508
+ $('.fs-submenu-item.wp-support-forum').parent().attr('target', '_blank');
1509
+ })(jQuery);
1510
+ </script>
1511
+ <?php
1512
+ }
1513
+
1514
+ /**
1515
+ * @author Vova Feldman (@svovaf)
1516
+ * @since 1.0.9
1517
+ */
1518
+ private function register_constructor_hooks() {
1519
+ $this->_logger->entrance();
1520
+
1521
+ if ( is_admin() ) {
1522
+ add_action( 'admin_init', array( &$this, '_hook_action_links_and_register_account_hooks' ) );
1523
+
1524
+ if ( $this->is_plugin() ) {
1525
+ if ( self::is_plugin_install_page() && true !== fs_request_get_bool( 'fs_allow_updater_and_dialog' ) ) {
1526
+ /**
1527
+ * Unless the `fs_allow_updater_and_dialog` URL param exists and its value is `true`, make
1528
+ * Freemius-related updates unavailable on the "Add Plugins" admin page (/plugin-install.php)
1529
+ * so that they won't interfere with the .org plugins' functionalities on that page (e.g.
1530
+ * updating of a .org plugin).
1531
+ */
1532
+ add_filter( 'site_transient_update_plugins', array( 'Freemius', '_remove_fs_updates_from_plugin_install_page' ), 10, 2 );
1533
+ } else if ( self::is_plugins_page() || self::is_updates_page() ) {
1534
+ /**
1535
+ * On the "Plugins" and "Updates" admin pages, if there are premium or non–org-compliant plugins, modify their details dialog URLs (add a Freemius-specific param) so that the SDK can determine if the plugin information dialog should show information from Freemius.
1536
+ *
1537
+ * @author Leo Fajardo (@leorw)
1538
+ * @since 2.2.3
1539
+ */
1540
+ add_action( 'admin_footer', array( 'Freemius', '_prepend_fs_allow_updater_and_dialog_flag_url_param' ) );
1541
+ }
1542
+
1543
+ $plugin_dir = dirname( $this->_plugin_dir_path ) . '/';
1544
+
1545
+ /**
1546
+ * @since 1.2.2
1547
+ *
1548
+ * Hook to both free and premium version activations to support
1549
+ * auto deactivation on the other version activation.
1550
+ */
1551
+ register_activation_hook(
1552
+ $plugin_dir . $this->_free_plugin_basename,
1553
+ array( &$this, '_activate_plugin_event_hook' )
1554
+ );
1555
+
1556
+ register_activation_hook(
1557
+ $plugin_dir . $this->premium_plugin_basename(),
1558
+ array( &$this, '_activate_plugin_event_hook' )
1559
+ );
1560
+ } else {
1561
+ add_action( 'after_switch_theme', array( &$this, '_activate_theme_event_hook' ), 10, 2 );
1562
+
1563
+ add_action( 'admin_footer', array( &$this, '_style_premium_theme' ) );
1564
+ }
1565
+
1566
+ /**
1567
+ * Part of the mechanism to identify new plugin install vs. plugin update.
1568
+ *
1569
+ * @author Vova Feldman (@svovaf)
1570
+ * @since 1.1.9
1571
+ */
1572
+ if ( empty( $this->_storage->was_plugin_loaded ) ) {
1573
+ /**
1574
+ * During the plugin activation (not theme), 'plugins_loaded' will be already executed
1575
+ * when the logic gets here since the activation logic first add the activate plugins,
1576
+ * then triggers 'plugins_loaded', and only then include the code of the plugin that
1577
+ * is activated. Which means that _plugins_loaded() will NOT be executed during the
1578
+ * plugin activation, and that IS intentional.
1579
+ *
1580
+ * @author Vova Feldman (@svovaf)
1581
+ */
1582
+ if ( $this->is_plugin() &&
1583
+ $this->is_activation_mode( false ) &&
1584
+ 0 == did_action( 'plugins_loaded' )
1585
+ ) {
1586
+ add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
1587
+ } else {
1588
+ // If was activated before, then it was already loaded before.
1589
+ $this->_plugins_loaded();
1590
+ }
1591
+ }
1592
+
1593
+ if ( ! self::is_ajax() ) {
1594
+ if ( ! $this->is_addon() ) {
1595
+ add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
1596
+ }
1597
+ }
1598
+
1599
+ if ( $this->_storage->handle_gdpr_admin_notice ) {
1600
+ add_action( 'init', array( &$this, '_maybe_show_gdpr_admin_notice' ) );
1601
+ }
1602
+
1603
+ add_action( 'init', array( &$this, '_maybe_add_gdpr_optin_ajax_handler') );
1604
+ }
1605
+
1606
+ if ( $this->is_plugin() ) {
1607
+ if ( $this->_is_network_active ) {
1608
+ add_action( 'wpmu_new_blog', array( $this, '_after_new_blog_callback' ), 10, 6 );
1609
+ }
1610
+
1611
+ register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
1612
+ }
1613
+
1614
+ if ( is_multisite() ) {
1615
+ add_action( 'deactivate_blog', array( &$this, '_after_site_deactivated_callback' ) );
1616
+ add_action( 'archive_blog', array( &$this, '_after_site_deactivated_callback' ) );
1617
+ add_action( 'make_spam_blog', array( &$this, '_after_site_deactivated_callback' ) );
1618
+ add_action( 'deleted_blog', array( &$this, '_after_site_deleted_callback' ), 10, 2 );
1619
+
1620
+ add_action( 'activate_blog', array( &$this, '_after_site_reactivated_callback' ) );
1621
+ add_action( 'unarchive_blog', array( &$this, '_after_site_reactivated_callback' ) );
1622
+ add_action( 'make_ham_blog', array( &$this, '_after_site_reactivated_callback' ) );
1623
+ }
1624
+
1625
+ if ( $this->is_theme() &&
1626
+ self::is_customizer() &&
1627
+ $this->apply_filters( 'show_customizer_upsell', true )
1628
+ ) {
1629
+ // Register customizer upsell.
1630
+ add_action( 'customize_register', array( &$this, '_customizer_register' ) );
1631
+ }
1632
+
1633
+ add_action( 'admin_init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
1634
+
1635
+ if ( $this->is_theme() ) {
1636
+ add_action( 'admin_init', array( &$this, '_add_tracking_links' ) );
1637
+ }
1638
+
1639
+ add_action( 'admin_init', array( &$this, '_add_license_activation' ) );
1640
+ add_action( 'admin_init', array( &$this, '_add_premium_version_upgrade_selection' ) );
1641
+ add_action( 'admin_init', array( &$this, '_add_beta_mode_update_handler' ) );
1642
+ add_action( 'admin_init', array( &$this, '_add_user_change_option' ) );
1643
+
1644
+ $this->add_ajax_action( 'update_billing', array( &$this, '_update_billing_ajax_action' ) );
1645
+ $this->add_ajax_action( 'start_trial', array( &$this, '_start_trial_ajax_action' ) );
1646
+ $this->add_ajax_action( 'set_data_debug_mode', array( &$this, '_set_data_debug_mode' ) );
1647
+
1648
+ if ( $this->_is_network_active && fs_is_network_admin() ) {
1649
+ $this->add_ajax_action( 'network_activate', array( &$this, '_network_activate_ajax_action' ) );
1650
+ }
1651
+
1652
+ $this->add_ajax_action( 'install_premium_version', array(
1653
+ &$this,
1654
+ '_install_premium_version_ajax_action'
1655
+ ) );
1656
+
1657
+ $this->add_ajax_action( 'submit_affiliate_application', array( &$this, '_submit_affiliate_application' ) );
1658
+
1659
+ $this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
1660
+
1661
+ $this->add_action( 'sdk_version_update', array( &$this, '_sdk_version_update' ), WP_FS__DEFAULT_PRIORITY, 2 );
1662
+
1663
+ $this->add_action(
1664
+ 'plugin_version_update',
1665
+ array( &$this, '_after_version_update' ),
1666
+ WP_FS__DEFAULT_PRIORITY,
1667
+ 2
1668
+ );
1669
+ $this->add_filter( 'after_code_type_change', array( &$this, '_after_code_type_change' ) );
1670
+
1671
+ add_action( 'admin_init', array( &$this, '_add_trial_notice' ) );
1672
+ add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) );
1673
+ add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_common_css' ) );
1674
+
1675
+ /**
1676
+ * Handle request to reset anonymous mode for `get_reconnect_url()`.
1677
+ *
1678
+ * @author Vova Feldman (@svovaf)
1679
+ * @since 1.2.1.5
1680
+ */
1681
+ if ( fs_request_is_action( 'reset_anonymous_mode' ) &&
1682
+ $this->get_unique_affix() === fs_request_get( 'fs_unique_affix' )
1683
+ ) {
1684
+ add_action( 'admin_init', array( &$this, 'connect_again' ) );
1685
+ }
1686
+ }
1687
+
1688
+ /**
1689
+ * Register the required hooks right after the settings parse is completed.
1690
+ *
1691
+ * @author Vova Feldman (@svovaf)
1692
+ * @since 2.3.1
1693
+ */
1694
+ private function register_after_settings_parse_hooks() {
1695
+ if ( is_admin() &&
1696
+ $this->is_theme() &&
1697
+ $this->is_premium() &&
1698
+ ! $this->has_active_valid_license()
1699
+ ) {
1700
+ $this->add_ajax_action(
1701
+ 'delete_theme_update_data',
1702
+ array( &$this, '_delete_theme_update_data_action' )
1703
+ );
1704
+ }
1705
+
1706
+ if ( $this->show_settings_with_tabs() ) {
1707
+ /**
1708
+ * Include the required hooks to capture the theme settings' page tabs
1709
+ * and cache them.
1710
+ *
1711
+ * @author Vova Feldman (@svovaf)
1712
+ * @since 1.2.2.7
1713
+ */
1714
+ if ( ! $this->_cache->has_valid( 'tabs' ) ) {
1715
+ add_action( 'admin_footer', array( &$this, '_tabs_capture' ) );
1716
+ // Add license activation AJAX callback.
1717
+ $this->add_ajax_action( 'store_tabs', array( &$this, '_store_tabs_ajax_action' ) );
1718
+
1719
+ add_action( 'admin_enqueue_scripts', array( &$this, '_store_tabs_styles' ), 9999999 );
1720
+ }
1721
+
1722
+ add_action(
1723
+ 'admin_footer',
1724
+ array( &$this, '_add_freemius_tabs' ),
1725
+ /**
1726
+ * The tabs JS code must be executed after the tabs capture logic (_tabs_capture()).
1727
+ * That's why the priority is 11 while the tabs capture logic is added
1728
+ * with priority 10.
1729
+ *
1730
+ * @author Vova Feldman (@svovaf)
1731
+ */
1732
+ 11
1733
+ );
1734
+ }
1735
+
1736
+ if ( ! self::is_ajax() ) {
1737
+ if ( ! $this->is_addon() || $this->is_only_premium() ) {
1738
+ add_action(
1739
+ ( $this->_is_network_active && fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu',
1740
+ array( &$this, '_prepare_admin_menu' ),
1741
+ WP_FS__LOWEST_PRIORITY
1742
+ );
1743
+ }
1744
+ }
1745
+ }
1746
+
1747
+ /**
1748
+ * Makes Freemius-related updates unavailable on the "Add Plugins" admin page (/plugin-install.php) so that
1749
+ * they won't interfere with the .org plugins' functionalities on that page (e.g. updating of a .org plugin).
1750
+ *
1751
+ * @author Leo Fajardo (@leorw)
1752
+ * @since 2.2.3
1753
+ *
1754
+ * @param object $updates
1755
+ * @param string|null $transient
1756
+ *
1757
+ * @return object
1758
+ */
1759
+ static function _remove_fs_updates_from_plugin_install_page( $updates, $transient = null ) {
1760
+ if ( is_object( $updates ) && isset( $updates->response ) ) {
1761
+ foreach ( $updates->response as $file => $plugin ) {
1762
+ if ( isset( $plugin->package ) && false !== strpos( $plugin->package, 'api.freemius' ) ) {
1763
+ unset( $updates->response[ $file ] );
1764
+ }
1765
+ }
1766
+ }
1767
+
1768
+ return $updates;
1769
+ }
1770
+
1771
+ /**
1772
+ * Prepends the `fs_allow_updater_and_dialog` param to the plugin information URLs to tell the SDK to handle
1773
+ * the information that is shown on the plugin details dialog that is shown when the relevant link is clicked.
1774
+ *
1775
+ * @author Leo Fajardo (@leorw)
1776
+ * @since 2.2.3
1777
+ *
1778
+ * @return string
1779
+ */
1780
+ static function _prepend_fs_allow_updater_and_dialog_flag_url_param() {
1781
+ $slug_basename_map = array();
1782
+ foreach ( self::$_instances as $instance ) {
1783
+ if ( ! $instance->is_plugin() ) {
1784
+ continue;
1785
+ }
1786
+
1787
+ $slug_basename_map[ $instance->get_slug() ] = $instance->premium_plugin_basename();
1788
+ }
1789
+ ?>
1790
+ <script type="text/javascript">
1791
+ (function( $ ) {
1792
+ var slugBasenameMap = <?php echo json_encode( $slug_basename_map ) ?>;
1793
+ for ( var slug in slugBasenameMap ) {
1794
+ var basename = slugBasenameMap[ slug ];
1795
+
1796
+ // Try to get the plugin rows if on the "Plugins" page.
1797
+ var $pluginRows = $( '.wp-list-table.plugins tr[data-plugin="' + basename + '"]');
1798
+
1799
+ if ( 0 === $pluginRows.length ) {
1800
+ // Try to get the plugin rows if on the "Updates" page.
1801
+ var $pluginCheckbox = $( '#update-plugins-table input[type="checkbox"][value="' + basename + '"]' );
1802
+ if ( 0 !== $pluginCheckbox.length ) {
1803
+ $pluginRows = $pluginCheckbox.parents( 'tr:first' );
1804
+ }
1805
+ }
1806
+
1807
+ if ( 0 === $pluginRows.length ) {
1808
+ // No plugin rows found.
1809
+ continue;
1810
+ }
1811
+
1812
+ // Find the "View details" links and add the `fs_allow_updater_and_dialog` param to the URL.
1813
+ $pluginRows.find( 'a[href*="plugin-install.php?tab=plugin-information"]' ).each(function() {
1814
+ var $this = $( this ),
1815
+ href = $this.attr( 'href' ).replace( '?tab=', '?fs_allow_updater_and_dialog=true&tab=');
1816
+
1817
+ $this.attr( 'href', href );
1818
+ });
1819
+ }
1820
+ })( jQuery );
1821
+ </script>
1822
+ <?php
1823
+ }
1824
+
1825
+ /**
1826
+ * @author Leo Fajardo (@leorw)
1827
+ * @since 2.3.0
1828
+ */
1829
+ static function _maybe_add_beta_label_styles() {
1830
+ $has_any_beta_version = false;
1831
+
1832
+ foreach ( self::$_instances as $instance ) {
1833
+ if ( $instance->is_beta() ) {
1834
+ $has_any_beta_version = true;
1835
+ break;
1836
+ }
1837
+ }
1838
+
1839
+ if ( $has_any_beta_version ) {
1840
+ fs_enqueue_local_style( 'fs_plugins', '/admin/plugins.css' );
1841
+ }
1842
+ }
1843
+
1844
+ /**
1845
+ * @author Leo Fajardo (@leorw)
1846
+ * @since 2.3.0
1847
+ */
1848
+ static function _maybe_add_beta_label_to_plugins_and_handle_confirmation() {
1849
+ $beta_data = array();
1850
+
1851
+ foreach ( self::$_instances as $instance ) {
1852
+ if ( ! $instance->is_premium() ) {
1853
+ continue;
1854
+ }
1855
+
1856
+ /**
1857
+ * If there's an available beta version update, a confirmation message will be shown when the
1858
+ * "Update now" link on the "Plugins" or "Themes" page is clicked.
1859
+ */
1860
+ $has_beta_update = $instance->has_beta_update();
1861
+
1862
+ $is_beta = (
1863
+ // The "Beta" label is added separately for themes.
1864
+ $instance->is_plugin() &&
1865
+ $instance->is_beta()
1866
+ );
1867
+
1868
+ if ( ! $is_beta && ! $has_beta_update ) {
1869
+ continue;
1870
+ }
1871
+
1872
+ $beta_data[ $instance->get_plugin_basename() ] = array( 'is_installed_version_beta' => $is_beta );
1873
+
1874
+ if ( ! $has_beta_update ) {
1875
+ continue;
1876
+ }
1877
+
1878
+ $beta_data[ $instance->get_plugin_basename() ]['beta_version_update_confirmation_message'] = sprintf(
1879
+ '%s %s',
1880
+ sprintf(
1881
+ fs_esc_attr_inline(
1882
+ 'An update to a Beta version will replace your installed version of %s with the latest Beta release - use with caution, and not on production sites. You have been warned.',
1883
+ 'beta-version-update-caution',
1884
+ $instance->get_slug()
1885
+ ),
1886
+ $instance->get_plugin_title()
1887
+ ),
1888
+ fs_esc_attr_inline( 'Would you like to proceed with the update?', 'update-confirmation', $instance->get_slug() )
1889
+ );
1890
+ }
1891
+
1892
+ if ( empty( $beta_data ) ) {
1893
+ return;
1894
+ }
1895
+ ?>
1896
+ <script type="text/javascript">
1897
+ ( function( $ ) {
1898
+ var betaData = <?php echo json_encode( $beta_data ) ?>;
1899
+
1900
+ for ( var pluginBasename in betaData ) {
1901
+ if ( ! betaData.hasOwnProperty( pluginBasename ) ) {
1902
+ continue;
1903
+ }
1904
+
1905
+ if ( ! betaData[ pluginBasename ].is_installed_version_beta ) {
1906
+ continue;
1907
+ }
1908
+
1909
+ var $parentContainer = $( '.wp-list-table.plugins tr[data-plugin="' + pluginBasename + '"]' );
1910
+ if ( 0 === $parentContainer.length ) {
1911
+ continue;
1912
+ }
1913
+
1914
+ $parentContainer.find( '.plugin-title > strong:first-child').append(
1915
+ '<span class="fs-tag fs-info"><?php fs_esc_js_echo_inline( 'Beta', 'beta' ) ?></span>'
1916
+ );
1917
+ }
1918
+
1919
+ setTimeout( function() {
1920
+ // Wait a little bit before adding the event handler, otherwise, it will be overridden by the core WP logic.
1921
+ $( '.plugins .update-message .update-link, .themes .theme .update-message' ).on( 'click', function() {
1922
+ var $parentContainer = $( this ).parents( 'tr:first' );
1923
+ pluginBasename = ( 0 !== $parentContainer.length ) ?
1924
+ $parentContainer.data( 'plugin' ) :
1925
+ $( this ).parents( '.theme:first' ).data( 'slug' );
1926
+
1927
+ if (
1928
+ betaData[ pluginBasename ] &&
1929
+ betaData[ pluginBasename ].beta_version_update_confirmation_message &&
1930
+ ! confirm( betaData[ pluginBasename ].beta_version_update_confirmation_message )
1931
+ ) {
1932
+ return false;
1933
+ }
1934
+ } );
1935
+ }, 20 );
1936
+ } )( jQuery );
1937
+ </script>
1938
+ <?php
1939
+ }
1940
+
1941
+ /**
1942
+ * Keeping the uninstall hook registered for free or premium plugin version may result to a fatal error that
1943
+ * could happen when a user tries to uninstall either version while one of them is still active. Uninstalling a
1944
+ * plugin will trigger inclusion of the free or premium version and if one of them is active during the
1945
+ * uninstallation, a fatal error may occur in case the plugin's class or functions are already defined.
1946
+ *
1947
+ * @author Leo Fajardo (@leorw)
1948
+ *
1949
+ * @since 1.2.0
1950
+ */
1951
+ private function unregister_uninstall_hook() {
1952
+ $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
1953
+ unset( $uninstallable_plugins[ $this->_free_plugin_basename ] );
1954
+ unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] );
1955
+
1956
+ update_option( 'uninstall_plugins', $uninstallable_plugins );
1957
+ }
1958
+
1959
+ /**
1960
+ * @since 1.2.0 Invalidate module's main file cache, otherwise, FS_Plugin_Updater will not fetch updates.
1961
+ *
1962
+ * @param bool $store_prev_path
1963
+ */
1964
+ private function clear_module_main_file_cache( $store_prev_path = true ) {
1965
+ if ( ! isset( $this->_storage->plugin_main_file ) ||
1966
+ empty( $this->_storage->plugin_main_file->path )
1967
+ ) {
1968
+ return;
1969
+ }
1970
+
1971
+ if ( ! $store_prev_path ) {
1972
+ /**
1973
+ * Storing the previous path is not needed when clearing the cache after an SDK version update since
1974
+ * the main purpose of the cache clearing in that event is to correct a wrong plugin main file path
1975
+ * which causes data mix-up between plugins (e.g. titles and versions of an add-on and its parent plugin).
1976
+ *
1977
+ * @author Leo Fajardo (@leorw)
1978
+ * @since 2.2.1
1979
+ */
1980
+ unset( $this->_storage->plugin_main_file->path );
1981
+ } else {
1982
+ $plugin_main_file = clone $this->_storage->plugin_main_file;
1983
+
1984
+ // Store cached path (2nd layer cache).
1985
+ $plugin_main_file->prev_path = $plugin_main_file->path;
1986
+
1987
+ // Clear cached path.
1988
+ unset( $plugin_main_file->path );
1989
+
1990
+ $this->_storage->plugin_main_file = $plugin_main_file;
1991
+ }
1992
+
1993
+ /**
1994
+ * Clear global cached path.
1995
+ *
1996
+ * @author Leo Fajardo (@leorw)
1997
+ * @since 1.2.2
1998
+ */
1999
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map' );
2000
+ unset( $id_slug_type_path_map[ $this->_module_id ]['path'] );
2001
+ self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
2002
+ }
2003
+
2004
+ /**
2005
+ * @author Leo Fajardo (@leorw)
2006
+ * @since 2.0.0
2007
+ */
2008
+ function _hook_action_links_and_register_account_hooks() {
2009
+ $this->_add_tracking_links();
2010
+
2011
+ if ( self::is_plugins_page() && $this->is_plugin() ) {
2012
+ $this->hook_plugin_action_links();
2013
+ }
2014
+
2015
+ $this->_register_account_hooks();
2016
+ }
2017
+
2018
+ /**
2019
+ * @author Vova Feldman (@svovaf)
2020
+ * @since 1.0.9
2021
+ */
2022
+ private function _register_account_hooks() {
2023
+ if ( ! is_admin() ) {
2024
+ return;
2025
+ }
2026
+
2027
+ /**
2028
+ * Always show the deactivation feedback form since we added
2029
+ * automatic free version deactivation upon premium code activation.
2030
+ *
2031
+ * @since 1.2.1.6
2032
+ */
2033
+ $this->add_ajax_action(
2034
+ 'submit_uninstall_reason',
2035
+ array( &$this, '_submit_uninstall_reason_action' )
2036
+ );
2037
+
2038
+ $this->add_ajax_action(
2039
+ 'cancel_subscription_or_trial',
2040
+ array( &$this, 'cancel_subscription_or_trial_ajax_action' )
2041
+ );
2042
+
2043
+ if ( ! $this->is_addon() || $this->is_parent_plugin_installed() ) {
2044
+ if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
2045
+ ( $this->is_theme() && self::is_themes_page() )
2046
+ ) {
2047
+ add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
2048
+ }
2049
+ }
2050
+ }
2051
+
2052
+ /**
2053
+ * Leverage backtrace to find caller plugin file path.
2054
+ *
2055
+ * @author Vova Feldman (@svovaf)
2056
+ * @since 1.0.6
2057
+ *
2058
+ * @param bool $is_init Is initiation sequence.
2059
+ *
2060
+ * @return string
2061
+ */
2062
+ private function _find_caller_plugin_file( $is_init = false ) {
2063
+ // Try to load the cached value of the file path.
2064
+ if ( isset( $this->_storage->plugin_main_file ) ) {
2065
+ $plugin_main_file = $this->_storage->plugin_main_file;
2066
+ if ( ! empty( $plugin_main_file->path ) ) {
2067
+ $absolute_path = $this->get_absolute_path( $plugin_main_file->path );
2068
+ if ( file_exists( $absolute_path ) ) {
2069
+ return $absolute_path;
2070
+ }
2071
+ }
2072
+ }
2073
+
2074
+ /**
2075
+ * @since 1.2.1
2076
+ *
2077
+ * `clear_module_main_file_cache()` is clearing the plugin's cached path on
2078
+ * deactivation. Therefore, if any plugin/theme was initiating `Freemius`
2079
+ * with that plugin's slug, it was overriding the empty plugin path with a wrong path.
2080
+ *
2081
+ * So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path`
2082
+ * when the class instantiator isn't the module.
2083
+ */
2084
+ if ( ! $is_init ) {
2085
+ // Fetch prev path cache.
2086
+ if ( isset( $this->_storage->plugin_main_file ) &&
2087
+ ! empty( $this->_storage->plugin_main_file->prev_path )
2088
+ ) {
2089
+ $absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path );
2090
+ if ( file_exists( $absolute_path ) ) {
2091
+ return $absolute_path;
2092
+ }
2093
+ }
2094
+
2095
+ wp_die(
2096
+ $this->get_text_inline( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'failed-finding-main-path' ) .
2097
+ " Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";",
2098
+ $this->get_text_inline( 'Error', 'error' ),
2099
+ array( 'back_link' => true )
2100
+ );
2101
+ }
2102
+
2103
+ /**
2104
+ * @since 1.2.1
2105
+ *
2106
+ * Only the original instantiator that calls dynamic_init can modify the module's path.
2107
+ */
2108
+ // Find caller module.
2109
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
2110
+ $this->_storage->plugin_main_file = (object) array(
2111
+ 'path' => $id_slug_type_path_map[ $this->_module_id ]['path'],
2112
+ );
2113
+
2114
+ return $this->get_absolute_path( $id_slug_type_path_map[ $this->_module_id ]['path'] );
2115
+ }
2116
+
2117
+ /**
2118
+ * @author Leo Fajardo (@leorw)
2119
+ * @since 1.2.3
2120
+ *
2121
+ * @param string $path
2122
+ *
2123
+ * @return string
2124
+ */
2125
+ private function get_relative_path( $path ) {
2126
+ $module_root_dir = $this->get_module_root_dir_path();
2127
+ if ( 0 === strpos( $path, $module_root_dir ) ) {
2128
+ $path = substr( $path, strlen( $module_root_dir ) );
2129
+ }
2130
+
2131
+ return $path;
2132
+ }
2133
+
2134
+ /**
2135
+ * @author Leo Fajardo (@leorw)
2136
+ * @since 1.2.3
2137
+ *
2138
+ * @param string $path
2139
+ * @param string|bool $module_type
2140
+ *
2141
+ * @return string
2142
+ */
2143
+ private function get_absolute_path( $path, $module_type = false ) {
2144
+ $module_root_dir = $this->get_module_root_dir_path( $module_type );
2145
+ if ( 0 !== strpos( $path, $module_root_dir ) ) {
2146
+ $path = fs_normalize_path( $module_root_dir . $path );
2147
+ }
2148
+
2149
+ return $path;
2150
+ }
2151
+
2152
+ /**
2153
+ * @author Leo Fajardo (@leorw)
2154
+ * @since 1.2.3
2155
+ *
2156
+ * @param string|bool $module_type
2157
+ *
2158
+ * @return string
2159
+ */
2160
+ private function get_module_root_dir_path( $module_type = false ) {
2161
+ $is_plugin = empty( $module_type ) ?
2162
+ $this->is_plugin() :
2163
+ ( WP_FS__MODULE_TYPE_PLUGIN === $module_type );
2164
+
2165
+ return fs_normalize_path( trailingslashit( $is_plugin ?
2166
+ WP_PLUGIN_DIR :
2167
+ get_theme_root( get_stylesheet() ) ) );
2168
+ }
2169
+
2170
+ /**
2171
+ * @author Leo Fajardo (@leorw)
2172
+ *
2173
+ * @param number $module_id
2174
+ * @param string $slug
2175
+ *
2176
+ * @since 1.2.2
2177
+ */
2178
+ private function store_id_slug_type_path_map( $module_id, $slug ) {
2179
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
2180
+
2181
+ $store_option = false;
2182
+
2183
+ if ( ! isset( $id_slug_type_path_map[ $module_id ] ) ) {
2184
+ $id_slug_type_path_map[ $module_id ] = array(
2185
+ 'slug' => $slug
2186
+ );
2187
+
2188
+ $store_option = true;
2189
+ }
2190
+
2191
+ if ( empty( $id_slug_type_path_map[ $module_id ]['path'] ) ||
2192
+ /**
2193
+ * This verification is for cases when suddenly the same module
2194
+ * is installed but with a different folder name.
2195
+ *
2196
+ * @author Vova Feldman (@svovaf)
2197
+ * @since 1.2.3
2198
+ */
2199
+ ! file_exists( $this->get_absolute_path(
2200
+ $id_slug_type_path_map[ $module_id ]['path'],
2201
+ $id_slug_type_path_map[ $module_id ]['type']
2202
+ ) )
2203
+ ) {
2204
+ $caller_main_file_and_type = $this->get_caller_main_file_and_type();
2205
+
2206
+ $id_slug_type_path_map[ $module_id ]['type'] = $caller_main_file_and_type->module_type;
2207
+ $id_slug_type_path_map[ $module_id ]['path'] = $caller_main_file_and_type->path;
2208
+
2209
+ $store_option = true;
2210
+ }
2211
+
2212
+ if ( $store_option ) {
2213
+ self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
2214
+ }
2215
+ }
2216
+
2217
+ /**
2218
+ * Identifies the caller type: plugin or theme.
2219
+ *
2220
+ * @author Leo Fajardo (@leorw)
2221
+ * @since 1.2.2
2222
+ *
2223
+ * @author Vova Feldman (@svovaf)
2224
+ * @since 1.2.2.3 Find the earliest module in the call stack that calls to the SDK. This fix is for cases when
2225
+ * add-ons are relying on loading the SDK from the parent module, and also allows themes including the
2226
+ * SDK an internal file instead of directly from functions.php.
2227
+ * @since 1.2.1.7 Knows how to handle cases when an add-on includes the parent module logic.
2228
+ */
2229
+ private function get_caller_main_file_and_type() {
2230
+ self::require_plugin_essentials();
2231
+
2232
+ $all_plugins = fs_get_plugins( true );
2233
+ $all_plugins_paths = array();
2234
+
2235
+ // Get active plugin's main files real full names (might be symlinks).
2236
+ foreach ( $all_plugins as $relative_path => $data ) {
2237
+ if ( false === strpos( fs_normalize_path( $relative_path ), '/' ) ) {
2238
+ /**
2239
+ * Ignore plugins that don't have a folder (e.g. Hello Dolly) since they
2240
+ * can't really include the SDK.
2241
+ *
2242
+ * @author Vova Feldman
2243
+ * @since 1.2.1.7
2244
+ */
2245
+ continue;
2246
+ }
2247
+
2248
+ $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
2249
+ }
2250
+
2251
+ $caller_file_candidate = false;
2252
+ $caller_map = array();
2253
+ $module_type = WP_FS__MODULE_TYPE_PLUGIN;
2254
+ $themes_dir = fs_normalize_path( get_theme_root( get_stylesheet() ) );
2255
+ $plugin_dir_to_skip = false;
2256
+
2257
+ for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
2258
+ if ( empty( $bt[ $i ]['file'] ) ) {
2259
+ continue;
2260
+ }
2261
+
2262
+ if ( $i > 1 && ! empty( $bt[ $i - 1 ]['file'] ) && $bt[ $i ]['file'] === $bt[ $i - 1 ]['file'] ) {
2263
+ // If file same as the prev file in the stack, skip it.
2264
+ continue;
2265
+ }
2266
+
2267
+ if ( ! empty( $bt[ $i ]['function'] ) && in_array( $bt[ $i ]['function'], array(
2268
+ 'do_action',
2269
+ 'apply_filter',
2270
+ // The string split is stupid, but otherwise, theme check
2271
+ // throws info notices.
2272
+ 'requir' . 'e_once',
2273
+ 'requir' . 'e',
2274
+ 'includ' . 'e_once',
2275
+ 'includ' . 'e',
2276
+ 'install_and_activate_plugin',
2277
+ 'try_activate_plugin',
2278
+ 'activate_plugin'
2279
+ ) )
2280
+ ) {
2281
+ if ( 'activate_plugin' === $bt[ $i ]['function'] ) {
2282
+ /**
2283
+ * Store the directory of the activator plugin so that any other file that starts with it
2284
+ * cannot be mistakenly chosen as a candidate caller file.
2285
+ *
2286
+ * @author Leo Fajardo
2287
+ *
2288
+ * @since 2.3.0
2289
+ */
2290
+ $caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
2291
+
2292
+ foreach ( $all_plugins_paths as $plugin_path ) {
2293
+ $plugin_dir = fs_normalize_path( dirname( $plugin_path ) . '/' );
2294
+ if ( false !== strpos( $caller_file_path, $plugin_dir ) ) {
2295
+ $plugin_dir_to_skip = $plugin_dir;
2296
+
2297
+ break;
2298
+ }
2299
+ }
2300
+ }
2301
+
2302
+ // Ignore call stack hooks and files inclusion.
2303
+ continue;
2304
+ }
2305
+
2306
+ $caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
2307
+
2308
+ if ( ! empty( $plugin_dir_to_skip ) ) {
2309
+ /**
2310
+ * Skip if it's an activator plugin file to avoid mistakenly choosing it as a candidate caller file.
2311
+ *
2312
+ * @author Leo Fajardo
2313
+ *
2314
+ * @since 2.3.0
2315
+ */
2316
+ if ( 0 === strpos( $caller_file_path, $plugin_dir_to_skip ) ) {
2317
+ continue;
2318
+ }
2319
+ }
2320
+
2321
+ if ( 'functions.php' === basename( $caller_file_path ) ) {
2322
+ /**
2323
+ * 1. Assumes that theme's starting execution file is functions.php.
2324
+ * 2. This complex logic fixes symlink issues (e.g. with Vargant).
2325
+ *
2326
+ * @author Vova Feldman (@svovaf)
2327
+ * @since 1.2.2.5
2328
+ */
2329
+
2330
+ if ( $caller_file_path == fs_normalize_path( realpath( trailingslashit( $themes_dir ) . basename( dirname( $caller_file_path ) ) . '/' . basename( $caller_file_path ) ) ) ) {
2331
+ $module_type = WP_FS__MODULE_TYPE_THEME;
2332
+
2333
+ /**
2334
+ * Relative path of the theme, e.g.:
2335
+ * `my-theme/functions.php`
2336
+ *
2337
+ * @author Leo Fajardo (@leorw)
2338
+ */
2339
+ $caller_file_candidate = basename( dirname( $caller_file_path ) ) .
2340
+ '/' .
2341
+ basename( $caller_file_path );
2342
+
2343
+ continue;
2344
+ }
2345
+ }
2346
+
2347
+ $caller_file_hash = md5( $caller_file_path );
2348
+
2349
+ if ( ! isset( $caller_map[ $caller_file_hash ] ) ) {
2350
+ foreach ( $all_plugins_paths as $plugin_path ) {
2351
+ if ( empty( $plugin_path ) ) {
2352
+ continue;
2353
+ }
2354
+
2355
+ if ( false !== strpos( $caller_file_path, fs_normalize_path( dirname( $plugin_path ) . '/' ) ) ) {
2356
+ $caller_map[ $caller_file_hash ] = fs_normalize_path( $plugin_path );
2357
+ break;
2358
+ }
2359
+ }
2360
+ }
2361
+
2362
+ if ( isset( $caller_map[ $caller_file_hash ] ) ) {
2363
+ $module_type = WP_FS__MODULE_TYPE_PLUGIN;
2364
+ $caller_file_candidate = plugin_basename( $caller_map[ $caller_file_hash ] );
2365
+ }
2366
+ }
2367
+
2368
+ return (object) array(
2369
+ 'module_type' => $module_type,
2370
+ 'path' => $caller_file_candidate
2371
+ );
2372
+ }
2373
+
2374
+ #----------------------------------------------------------------------------------
2375
+ #region Deactivation Feedback Form
2376
+ #----------------------------------------------------------------------------------
2377
+
2378
+ /**
2379
+ * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
2380
+ * page.
2381
+ *
2382
+ * @author Vova Feldman (@svovaf)
2383
+ * @author Leo Fajardo (@leorw)
2384
+ *
2385
+ * @since 1.1.2
2386
+ */
2387
+ function _add_deactivation_feedback_dialog_box() {
2388
+ $subscription_cancellation_dialog_box_template_params = $this->apply_filters( 'show_deactivation_subscription_cancellation', true ) ?
2389
+ $this->_get_subscription_cancellation_dialog_box_template_params() :
2390
+ array();
2391
+
2392
+ /**
2393
+ * @since 2.3.0 Developers can optionally hide the deactivation feedback form using the 'show_deactivation_feedback_form' filter.
2394
+ */
2395
+ $show_deactivation_feedback_form = true;
2396
+ if ( $this->has_filter( 'show_deactivation_feedback_form' ) ) {
2397
+ $show_deactivation_feedback_form = $this->apply_filters( 'show_deactivation_feedback_form', true );
2398
+ } else if ( $this->is_addon() ) {
2399
+ /**
2400
+ * If the add-on's 'show_deactivation_feedback_form' is not set, try to inherit the value from the parent.
2401
+ */
2402
+ $show_deactivation_feedback_form = $this->get_parent_instance()->apply_filters( 'show_deactivation_feedback_form', true );
2403
+ }
2404
+
2405
+ $uninstall_confirmation_message = $this->apply_filters( 'uninstall_confirmation_message', '' );
2406
+
2407
+ if (
2408
+ empty( $subscription_cancellation_dialog_box_template_params ) &&
2409
+ ! $show_deactivation_feedback_form &&
2410
+ empty( $uninstall_confirmation_message )
2411
+ ) {
2412
+ return;
2413
+ }
2414
+
2415
+ $vars = array( 'id' => $this->_module_id );
2416
+
2417
+ if ( $show_deactivation_feedback_form ) {
2418
+ /* Check the type of user:
2419
+ * 1. Long-term (long-term)
2420
+ * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
2421
+ * 3. Short-term (short-term)
2422
+ */
2423
+ $is_long_term_user = true;
2424
+
2425
+ // Check if the site is at least 2 days old.
2426
+ $time_installed = $this->_storage->install_timestamp;
2427
+
2428
+ // Difference in seconds.
2429
+ $date_diff = time() - $time_installed;
2430
+
2431
+ // Convert seconds to days.
2432
+ $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
2433
+
2434
+ if ( $date_diff_days < 2 ) {
2435
+ $is_long_term_user = false;
2436
+ }
2437
+
2438
+ $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
2439
+
2440
+ if ( $is_long_term_user ) {
2441
+ $user_type = 'long-term';
2442
+ } else {
2443
+ if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
2444
+ $user_type = 'non-registered-and-non-anonymous-short-term';
2445
+ } else {
2446
+ $user_type = 'short-term';
2447
+ }
2448
+ }
2449
+
2450
+ $uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
2451
+
2452
+ $vars['reasons'] = $uninstall_reasons;
2453
+ }
2454
+
2455
+ $vars['subscription_cancellation_dialog_box_template_params'] = &$subscription_cancellation_dialog_box_template_params;
2456
+ $vars['show_deactivation_feedback_form'] = $show_deactivation_feedback_form;
2457
+ $vars['uninstall_confirmation_message'] = $uninstall_confirmation_message;
2458
+
2459
+ /**
2460
+ * Load the HTML template for the deactivation feedback dialog box.
2461
+ *
2462
+ * @todo Deactivation form core functions should be loaded only once! Otherwise, when there are multiple Freemius powered plugins the same code is loaded multiple times. The only thing that should be loaded differently is the various deactivation reasons object based on the state of the plugin.
2463
+ */
2464
+ fs_require_template( 'forms/deactivation/form.php', $vars );
2465
+ }
2466
+
2467
+ /**
2468
+ * @author Leo Fajardo (@leorw)
2469
+ * @since 1.1.2
2470
+ *
2471
+ * @param string $user_type
2472
+ *
2473
+ * @return array The uninstall reasons for the specified user type.
2474
+ */
2475
+ function _get_uninstall_reasons( $user_type = 'long-term' ) {
2476
+ $module_type = $this->_module_type;
2477
+
2478
+ $internal_message_template_var = array(
2479
+ 'id' => $this->_module_id
2480
+ );
2481
+
2482
+ $plan = $this->get_plan();
2483
+
2484
+ if ( $this->is_registered() && is_object( $plan ) && $plan->has_technical_support() ) {
2485
+ $contact_support_template = fs_get_template( 'forms/deactivation/contact.php', $internal_message_template_var );
2486
+ } else {
2487
+ $contact_support_template = '';
2488
+ }
2489
+
2490
+ $reason_found_better_plugin = array(
2491
+ 'id' => self::REASON_FOUND_A_BETTER_PLUGIN,
2492
+ 'text' => sprintf( $this->get_text_inline( 'I found a better %s', 'reason-found-a-better-plugin' ), $module_type ),
2493
+ 'input_type' => 'textfield',
2494
+ 'input_placeholder' => sprintf( $this->get_text_inline( "What's the %s's name?", 'placeholder-plugin-name' ), $module_type ),
2495
+ );
2496
+
2497
+ $reason_temporary_deactivation = array(
2498
+ 'id' => self::REASON_TEMPORARY_DEACTIVATION,
2499
+ 'text' => sprintf(
2500
+ $this->get_text_inline( "It's a temporary %s. I'm just debugging an issue.", 'reason-temporary-x' ),
2501
+ strtolower( $this->is_plugin() ?
2502
+ $this->get_text_inline( 'Deactivation', 'deactivation' ) :
2503
+ $this->get_text_inline( 'Theme Switch', 'theme-switch' )
2504
+ )
2505
+ ),
2506
+ 'input_type' => '',
2507
+ 'input_placeholder' => ''
2508
+ );
2509
+
2510
+ $reason_other = array(
2511
+ 'id' => self::REASON_OTHER,
2512
+ 'text' => $this->get_text_inline( 'Other', 'reason-other' ),
2513
+ 'input_type' => 'textfield',
2514
+ 'input_placeholder' => ''
2515
+ );
2516
+
2517
+ $long_term_user_reasons = array(
2518
+ array(
2519
+ 'id' => self::REASON_NO_LONGER_NEEDED,
2520
+ 'text' => sprintf( $this->get_text_inline( 'I no longer need the %s', 'reason-no-longer-needed' ), $module_type ),
2521
+ 'input_type' => '',
2522
+ 'input_placeholder' => ''
2523
+ ),
2524
+ $reason_found_better_plugin,
2525
+ array(
2526
+ 'id' => self::REASON_NEEDED_FOR_A_SHORT_PERIOD,
2527
+ 'text' => sprintf( $this->get_text_inline( 'I only needed the %s for a short period', 'reason-needed-for-a-short-period' ), $module_type ),
2528
+ 'input_type' => '',
2529
+ 'input_placeholder' => ''
2530
+ ),
2531
+ array(
2532
+ 'id' => self::REASON_BROKE_MY_SITE,
2533
+ 'text' => sprintf( $this->get_text_inline( 'The %s broke my site', 'reason-broke-my-site' ), $module_type ),
2534
+ 'input_type' => '',
2535
+ 'input_placeholder' => '',
2536
+ 'internal_message' => $contact_support_template
2537
+ ),
2538
+ array(
2539
+ 'id' => self::REASON_SUDDENLY_STOPPED_WORKING,
2540
+ 'text' => sprintf( $this->get_text_inline( 'The %s suddenly stopped working', 'reason-suddenly-stopped-working' ), $module_type ),
2541
+ 'input_type' => '',
2542
+ 'input_placeholder' => '',
2543
+ 'internal_message' => $contact_support_template
2544
+ )
2545
+ );
2546
+
2547
+ if ( $this->is_paying() ) {
2548
+ $long_term_user_reasons[] = array(
2549
+ 'id' => self::REASON_CANT_PAY_ANYMORE,
2550
+ 'text' => $this->get_text_inline( "I can't pay for it anymore", 'reason-cant-pay-anymore' ),
2551
+ 'input_type' => 'textfield',
2552
+ 'input_placeholder' => $this->get_text_inline( 'What price would you feel comfortable paying?', 'placeholder-comfortable-price' )
2553
+ );
2554
+ }
2555
+
2556
+ $reason_dont_share_info = array(
2557
+ 'id' => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
2558
+ 'text' => $this->get_text_inline( "I don't like to share my information with you", 'reason-dont-like-to-share-my-information' ),
2559
+ 'input_type' => '',
2560
+ 'input_placeholder' => ''
2561
+ );
2562
+
2563
+ /**
2564
+ * If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
2565
+ * user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
2566
+ * (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
2567
+ * enabled and the user's account is currently not in pending activation state (similar to the way the Skip
2568
+ * button in the opt-in form is shown/hidden).
2569
+ */
2570
+ if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
2571
+ $reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
2572
+ }
2573
+
2574
+ $uninstall_reasons = array(
2575
+ 'long-term' => $long_term_user_reasons,
2576
+ 'non-registered-and-non-anonymous-short-term' => array(
2577
+ array(
2578
+ 'id' => self::REASON_DIDNT_WORK,
2579
+ 'text' => sprintf( $this->get_text_inline( "The %s didn't work", 'reason-didnt-work' ), $module_type ),
2580
+ 'input_type' => '',
2581
+ 'input_placeholder' => ''
2582
+ ),
2583
+ $reason_dont_share_info,
2584
+ $reason_found_better_plugin
2585
+ ),
2586
+ 'short-term' => array(
2587
+ array(
2588
+ 'id' => self::REASON_COULDNT_MAKE_IT_WORK,
2589
+ 'text' => $this->get_text_inline( "I couldn't understand how to make it work", 'reason-couldnt-make-it-work' ),
2590
+ 'input_type' => '',
2591
+ 'input_placeholder' => '',
2592
+ 'internal_message' => $contact_support_template
2593
+ ),
2594
+ $reason_found_better_plugin,
2595
+ array(
2596
+ 'id' => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
2597
+ 'text' => sprintf( $this->get_text_inline( "The %s is great, but I need specific feature that you don't support", 'reason-great-but-need-specific-feature' ), $module_type ),
2598
+ 'input_type' => 'textarea',
2599
+ 'input_placeholder' => $this->get_text_inline( 'What feature?', 'placeholder-feature' )
2600
+ ),
2601
+ array(
2602
+ 'id' => self::REASON_NOT_WORKING,
2603
+ 'text' => sprintf( $this->get_text_inline( 'The %s is not working', 'reason-not-working' ), $module_type ),
2604
+ 'input_type' => 'textarea',
2605
+ 'input_placeholder' => $this->get_text_inline( "Kindly share what didn't work so we can fix it for future users...", 'placeholder-share-what-didnt-work' )
2606
+ ),
2607
+ array(
2608
+ 'id' => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
2609
+ 'text' => $this->get_text_inline( "It's not what I was looking for", 'reason-not-what-i-was-looking-for' ),
2610
+ 'input_type' => 'textarea',
2611
+ 'input_placeholder' => $this->get_text_inline( "What you've been looking for?", 'placeholder-what-youve-been-looking-for' )
2612
+ ),
2613
+ array(
2614
+ 'id' => self::REASON_DIDNT_WORK_AS_EXPECTED,
2615
+ 'text' => sprintf( $this->get_text_inline( "The %s didn't work as expected", 'reason-didnt-work-as-expected' ), $module_type ),
2616
+ 'input_type' => 'textarea',
2617
+ 'input_placeholder' => $this->get_text_inline( 'What did you expect?', 'placeholder-what-did-you-expect' )
2618
+ )
2619
+ )
2620
+ );
2621
+
2622
+ // Randomize the reasons for the current user type.
2623
+ shuffle( $uninstall_reasons[ $user_type ] );
2624
+
2625
+ // Keep the following reasons as the last items in the list.
2626
+ $uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
2627
+ $uninstall_reasons[ $user_type ][] = $reason_other;
2628
+
2629
+ $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
2630
+
2631
+ return $uninstall_reasons[ $user_type ];
2632
+ }
2633
+
2634
+ /**
2635
+ * Called after the user has submitted his reason for deactivating the plugin.
2636
+ *
2637
+ * @author Leo Fajardo (@leorw)
2638
+ * @since 1.1.2
2639
+ */
2640
+ function _submit_uninstall_reason_action() {
2641
+ $this->_logger->entrance();
2642
+
2643
+ $this->check_ajax_referer( 'submit_uninstall_reason' );
2644
+
2645
+ $reason_id = fs_request_get( 'reason_id' );
2646
+
2647
+ // Check if the given reason ID is an unsigned integer.
2648
+ if ( ! ctype_digit( $reason_id ) ) {
2649
+ exit;
2650
+ }
2651
+
2652
+ $reason_info = trim( fs_request_get( 'reason_info', '' ) );
2653
+ if ( ! empty( $reason_info ) ) {
2654
+ $reason_info = substr( $reason_info, 0, 128 );
2655
+ }
2656
+
2657
+ $reason = (object) array(
2658
+ 'id' => $reason_id,
2659
+ 'info' => $reason_info,
2660
+ 'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
2661
+ );
2662
+
2663
+ $this->_storage->store( 'uninstall_reason', $reason );
2664
+
2665
+ /**
2666
+ * If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do
2667
+ * not support uninstall hook.
2668
+ *
2669
+ * @author Leo Fajardo (@leorw)
2670
+ * @since 1.2.2
2671
+ */
2672
+ if ( $this->is_theme() ) {
2673
+ if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
2674
+ FS_Plugin_Updater::instance( $this )->delete_update_data();
2675
+ }
2676
+
2677
+ $this->_uninstall_plugin_event( false );
2678
+ $this->remove_sdk_reference();
2679
+ }
2680
+
2681
+ // Print '1' for successful operation.
2682
+ echo 1;
2683
+ exit;
2684
+ }
2685
+
2686
+ /**
2687
+ * @author Leo Fajardo (@leorw)
2688
+ * @since 2.1.4
2689
+ */
2690
+ function cancel_subscription_or_trial_ajax_action() {
2691
+ $this->_logger->entrance();
2692
+
2693
+ $this->check_ajax_referer( 'cancel_subscription_or_trial' );
2694
+
2695
+ $result = $this->cancel_subscription_or_trial( fs_request_get( 'plugin_id', $this->get_id() ), false );
2696
+
2697
+ if ( $this->is_api_error( $result ) ) {
2698
+ $this->shoot_ajax_failure( $result->error->message );
2699
+ }
2700
+
2701
+ $this->shoot_ajax_success();
2702
+ }
2703
+
2704
+ /**
2705
+ * @author Leo Fajardo (@leorw)
2706
+ * @since 2.1.4
2707
+ *
2708
+ * @param number $plugin_id
2709
+ *
2710
+ * @return object
2711
+ */
2712
+ private function cancel_subscription_or_trial( $plugin_id ) {
2713
+ $fs = null;
2714
+ if ( $plugin_id == $this->get_id() ) {
2715
+ $fs = $this;
2716
+ } else if ( $this->is_addon_activated( $plugin_id ) ) {
2717
+ $fs = self::get_instance_by_id( $plugin_id );
2718
+ }
2719
+
2720
+ $result = null;
2721
+
2722
+ if ( ! is_null( $fs ) ) {
2723
+ $result = $fs->is_paid_trial() ?
2724
+ $fs->_cancel_trial() :
2725
+ $fs->_downgrade_site();
2726
+ }
2727
+
2728
+ return $result;
2729
+ }
2730
+
2731
+ /**
2732
+ * @author Leo Fajardo (@leorw)
2733
+ * @since 2.0.2
2734
+ */
2735
+ function _delete_theme_update_data_action() {
2736
+ FS_Plugin_Updater::instance( $this )->delete_update_data();
2737
+ }
2738
+
2739
+ #endregion
2740
+
2741
+ #----------------------------------------------------------------------------------
2742
+ #region Instance
2743
+ #----------------------------------------------------------------------------------
2744
+
2745
+ /**
2746
+ * Main singleton instance.
2747
+ *
2748
+ * @author Vova Feldman (@svovaf)
2749
+ * @since 1.0.0
2750
+ *
2751
+ * @param number $module_id
2752
+ * @param string|bool $slug
2753
+ * @param bool $is_init Is initiation sequence.
2754
+ *
2755
+ * @return Freemius|false
2756
+ */
2757
+ static function instance( $module_id, $slug = false, $is_init = false ) {
2758
+ if ( empty( $module_id ) ) {
2759
+ return false;
2760
+ }
2761
+
2762
+ /**
2763
+ * Load the essential static data prior to initiating FS_Plugin_Manager since there's an essential MS network migration logic that needs to be executed prior to the initiation.
2764
+ */
2765
+ self::_load_required_static();
2766
+
2767
+ if ( ! is_numeric( $module_id ) ) {
2768
+ if ( ! $is_init && true === $slug ) {
2769
+ $is_init = true;
2770
+ }
2771
+
2772
+ $slug = $module_id;
2773
+
2774
+ $module = FS_Plugin_Manager::instance( $slug )->get();
2775
+
2776
+ if ( is_object( $module ) ) {
2777
+ $module_id = $module->id;
2778
+ }
2779
+ }
2780
+
2781
+ $key = 'm_' . $module_id;
2782
+
2783
+ if ( ! isset( self::$_instances[ $key ] ) ) {
2784
+ self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init );
2785
+ }
2786
+
2787
+ return self::$_instances[ $key ];
2788
+ }
2789
+
2790
+ /**
2791
+ * @author Vova Feldman (@svovaf)
2792
+ * @since 1.0.6
2793
+ *
2794
+ * @param number $addon_id
2795
+ *
2796
+ * @return bool
2797
+ */
2798
+ private static function has_instance( $addon_id ) {
2799
+ return isset( self::$_instances[ 'm_' . $addon_id ] );
2800
+ }
2801
+
2802
+ /**
2803
+ * @author Leo Fajardo (@leorw)
2804
+ * @since 1.2.2
2805
+ *
2806
+ * @param string|number $id_or_slug
2807
+ * @param string $module_type
2808
+ *
2809
+ * @return number|false
2810
+ */
2811
+ private static function get_module_id( $id_or_slug, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
2812
+ if ( is_numeric( $id_or_slug ) ) {
2813
+ return $id_or_slug;
2814
+ }
2815
+
2816
+ foreach ( self::$_instances as $instance ) {
2817
+ // Also check the module type since there can be a plugin and a theme with the same slug.
2818
+ if ( ( $module_type === $instance->get_module_type() ) && ( $id_or_slug === $instance->get_slug() ) ) {
2819
+ return $instance->get_id();
2820
+ }
2821
+ }
2822
+
2823
+ return false;
2824
+ }
2825
+
2826
+ /**
2827
+ * @author Vova Feldman (@svovaf)
2828
+ * @since 1.0.6
2829
+ *
2830
+ * @param number $id
2831
+ *
2832
+ * @return false|Freemius
2833
+ */
2834
+ static function get_instance_by_id( $id ) {
2835
+ return isset ( self::$_instances[ 'm_' . $id ] ) ?
2836
+ self::$_instances[ 'm_' . $id ] :
2837
+ false;
2838
+ }
2839
+
2840
+ /**
2841
+ *
2842
+ * @author Vova Feldman (@svovaf)
2843
+ * @since 1.0.1
2844
+ *
2845
+ * @param string $plugin_file
2846
+ * @param string $module_type
2847
+ *
2848
+ * @return false|Freemius
2849
+ */
2850
+ static function get_instance_by_file( $plugin_file, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
2851
+ $slug = self::find_slug_by_basename( $plugin_file );
2852
+
2853
+ return ( false !== $slug ) ?
2854
+ self::instance( self::get_module_id( $slug, $module_type ) ) :
2855
+ false;
2856
+ }
2857
+
2858
+ /**
2859
+ * @author Vova Feldman (@svovaf)
2860
+ * @since 1.0.6
2861
+ *
2862
+ * @return false|Freemius
2863
+ */
2864
+ function get_parent_instance() {
2865
+ return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
2866
+ }
2867
+
2868
+ /**
2869
+ * @author Vova Feldman (@svovaf)
2870
+ * @since 1.0.6
2871
+ *
2872
+ * @param string|number $id_or_slug
2873
+ *
2874
+ * @return false|Freemius
2875
+ */
2876
+ function get_addon_instance( $id_or_slug ) {
2877
+ $addon_id = self::get_module_id( $id_or_slug );
2878
+
2879
+ return self::instance( $addon_id );
2880
+ }
2881
+
2882
+ #endregion ------------------------------------------------------------------
2883
+
2884
+ /**
2885
+ * @author Vova Feldman (@svovaf)
2886
+ * @since 1.0.6
2887
+ *
2888
+ * @return bool
2889
+ */
2890
+ function is_parent_plugin_installed() {
2891
+ $is_active = self::has_instance( $this->_plugin->parent_plugin_id );
2892
+
2893
+ if ( $is_active ) {
2894
+ return true;
2895
+ }
2896
+
2897
+ /**
2898
+ * Parent module might be a theme. If that's the case, the add-on's FS
2899
+ * instance will be loaded prior to the theme's FS instance, therefore,
2900
+ * we need to check if it's active with a "look ahead".
2901
+ *
2902
+ * @author Vova Feldman
2903
+ * @since 1.2.2.3
2904
+ */
2905
+ global $fs_active_plugins;
2906
+ if ( is_object( $fs_active_plugins ) && is_array( $fs_active_plugins->plugins ) ) {
2907
+ $active_theme = wp_get_theme();
2908
+
2909
+ foreach ( $fs_active_plugins->plugins as $sdk => $module ) {
2910
+ if ( WP_FS__MODULE_TYPE_THEME === $module->type ) {
2911
+ if ( $module->plugin_path == $active_theme->get_stylesheet() ) {
2912
+ // Parent module is a theme and it's currently active.
2913
+ return true;
2914
+ }
2915
+ }
2916
+ }
2917
+ }
2918
+
2919
+ return false;
2920
+ }
2921
+
2922
+ /**
2923
+ * Check if add-on parent plugin in activation mode.
2924
+ *
2925
+ * @author Vova Feldman (@svovaf)
2926
+ * @since 1.0.7
2927
+ *
2928
+ * @return bool
2929
+ */
2930
+ function is_parent_in_activation() {
2931
+ $parent_fs = $this->get_parent_instance();
2932
+ if ( ! is_object( $parent_fs ) ) {
2933
+ return false;
2934
+ }
2935
+
2936
+ return ( $parent_fs->is_activation_mode() );
2937
+ }
2938
+
2939
+ /**
2940
+ * Is plugin in activation mode.
2941
+ *
2942
+ * @author Vova Feldman (@svovaf)
2943
+ * @since 1.0.7
2944
+ *
2945
+ * @param bool $and_on
2946
+ *
2947
+ * @return bool
2948
+ */
2949
+ function is_activation_mode( $and_on = true ) {
2950
+ return fs_is_network_admin() ?
2951
+ $this->is_network_activation_mode( $and_on ) :
2952
+ $this->is_site_activation_mode( $and_on );
2953
+ }
2954
+
2955
+ /**
2956
+ * Is plugin in activation mode.
2957
+ *
2958
+ * @author Vova Feldman (@svovaf)
2959
+ * @since 1.0.7
2960
+ *
2961
+ * @param bool $and_on
2962
+ *
2963
+ * @return bool
2964
+ */
2965
+ function is_site_activation_mode( $and_on = true ) {
2966
+ return (
2967
+ ( $this->is_on() || ! $and_on ) &&
2968
+ (
2969
+ ( $this->is_premium() && true === $this->_storage->require_license_activation ) ||
2970
+ (
2971
+ ( ! $this->is_registered() ||
2972
+ ( $this->is_only_premium() && ! $this->has_features_enabled_license() ) ) &&
2973
+ ( ! $this->is_enable_anonymous() ||
2974
+ ( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
2975
+ )
2976
+ )
2977
+ );
2978
+ }
2979
+
2980
+ /**
2981
+ * Checks if the SDK in network activation mode.
2982
+ *
2983
+ * @author Leo Fajardo (@leorw)
2984
+ * @since 2.0.0
2985
+ *
2986
+ * @param bool $and_on
2987
+ *
2988
+ * @return bool
2989
+ */
2990
+ private function is_network_activation_mode( $and_on = true ) {
2991
+ if ( ! $this->_is_network_active ) {
2992
+ // Not network activated.
2993
+ return false;
2994
+ }
2995
+
2996
+ if ( $this->is_network_upgrade_mode() ) {
2997
+ // Special flag to enforce network activation mode to decide what to do with the sites that are not yet opted-in nor skipped.
2998
+ return true;
2999
+ }
3000
+
3001
+ if ( ! $this->is_site_activation_mode( $and_on ) ) {
3002
+ // Whether the context is single site or the network, if the plugin is no longer in activation mode then it is not in network activation mode as well.
3003
+ return false;
3004
+ }
3005
+
3006
+ if ( $this->is_network_delegated_connection() ) {
3007
+ // Super-admin delegated the connection to the site admins -> not activation mode.
3008
+ return false;
3009
+ }
3010
+
3011
+ if ( $this->is_network_anonymous() && true !== $this->_storage->require_license_activation ) {
3012
+ // Super-admin skipped the connection network wide -> not activation mode.
3013
+ return false;
3014
+ }
3015
+
3016
+ if ( $this->is_network_registered() ) {
3017
+ // Super-admin connected at least one site -> not activation mode.
3018
+ return false;
3019
+ }
3020
+
3021
+ return true;
3022
+ }
3023
+
3024
+ /**
3025
+ * Check if current page is the opt-in/pending-activation page.
3026
+ *
3027
+ * @author Vova Feldman (@svovaf)
3028
+ * @since 1.2.1.7
3029
+ *
3030
+ * @return bool
3031
+ */
3032
+ function is_activation_page() {
3033
+ if ( $this->_menu->is_activation_page( $this->show_opt_in_on_themes_page() ) ) {
3034
+ return true;
3035
+ }
3036
+
3037
+ if ( ! $this->is_activation_mode() ) {
3038
+ return false;
3039
+ }
3040
+
3041
+ // Check if current page is matching the activation page.
3042
+ return $this->is_matching_url( $this->get_activation_url() );
3043
+ }
3044
+
3045
+ /**
3046
+ * Check if URL path's are matching and that all querystring
3047
+ * arguments of the $sub_url exist in the $url with the same values.
3048
+ *
3049
+ * WARNING:
3050
+ * 1. This method doesn't check if the sub/domain are matching.
3051
+ * 2. Ignore case sensitivity.
3052
+ *
3053
+ * @author Vova Feldman (@svovaf)
3054
+ * @since 1.2.1.7
3055
+ *
3056
+ * @param string $sub_url
3057
+ * @param string $url If argument is not set, check if the sub_url matching the current's page URL.
3058
+ *
3059
+ * @return bool
3060
+ */
3061
+ private function is_matching_url( $sub_url, $url = '' ) {
3062
+ if ( empty( $url ) ) {
3063
+ $url = $_SERVER['REQUEST_URI'];
3064
+ }
3065
+
3066
+ $url = strtolower( $url );
3067
+ $sub_url = strtolower( $sub_url );
3068
+
3069
+ if ( parse_url( $sub_url, PHP_URL_PATH ) !== parse_url( $url, PHP_URL_PATH ) ) {
3070
+ // Different path - DO NOT OVERRIDE PAGE.
3071
+ return false;
3072
+ }
3073
+
3074
+ $url_params = array();
3075
+ parse_str( parse_url( $url, PHP_URL_QUERY ), $url_params );
3076
+
3077
+ $sub_url_params = array();
3078
+ parse_str( parse_url( $sub_url, PHP_URL_QUERY ), $sub_url_params );
3079
+
3080
+ foreach ( $sub_url_params as $key => $val ) {
3081
+ if ( ! isset( $url_params[ $key ] ) || $val != $url_params[ $key ] ) {
3082
+ // Not matching query string - DO NOT OVERRIDE PAGE.
3083
+ return false;
3084
+ }
3085
+ }
3086
+
3087
+ return true;
3088
+ }
3089
+
3090
+ /**
3091
+ * Get the basenames of all active plugins for specific blog. Including network activated plugins.
3092
+ *
3093
+ * @author Vova Feldman (@svovaf)
3094
+ * @since 2.0.0
3095
+ *
3096
+ * @param int $blog_id
3097
+ *
3098
+ * @return string[]
3099
+ */
3100
+ private static function get_active_plugins_basenames( $blog_id = 0 ) {
3101
+ if ( is_multisite() && $blog_id > 0 ) {
3102
+ $active_basenames = get_blog_option( $blog_id, 'active_plugins' );
3103
+ } else {
3104
+ $active_basenames = get_option( 'active_plugins' );
3105
+ }
3106
+
3107
+ if ( ! is_array( $active_basenames ) ) {
3108
+ $active_basenames = array();
3109
+ }
3110
+
3111
+ if ( is_multisite() ) {
3112
+ $network_active_basenames = get_site_option( 'active_sitewide_plugins' );
3113
+
3114
+ if ( is_array( $network_active_basenames ) && ! empty( $network_active_basenames ) ) {
3115
+ $active_basenames = array_merge( $active_basenames, array_keys( $network_active_basenames ) );
3116
+ }
3117
+ }
3118
+
3119
+ return $active_basenames;
3120
+ }
3121
+
3122
+ /**
3123
+ * @author Leo Fajardo (@leorw)
3124
+ * @since 2.3.0
3125
+ *
3126
+ * @param int $blog_id
3127
+ *
3128
+ * @return array
3129
+ */
3130
+ static function get_active_plugins_directories_map( $blog_id = 0 ) {
3131
+ $active_basenames = self::get_active_plugins_basenames( $blog_id );
3132
+
3133
+ $map = array();
3134
+
3135
+ foreach ( $active_basenames as $active_basename ) {
3136
+ $active_basename = fs_normalize_path( $active_basename );
3137
+
3138
+ if ( false === strpos( $active_basename, '/' ) ) {
3139
+ continue;
3140
+ }
3141
+
3142
+ $map[ dirname( $active_basename ) ] = true;
3143
+ }
3144
+
3145
+ return $map;
3146
+ }
3147
+
3148
+ /**
3149
+ * Get collection of all active plugins. Including network activated plugins.
3150
+ *
3151
+ * @author Vova Feldman (@svovaf)
3152
+ * @since 1.0.9
3153
+ *
3154
+ * @param int $blog_id Since 2.0.0
3155
+ *
3156
+ * @return array[string]array
3157
+ */
3158
+ private static function get_active_plugins( $blog_id = 0 ) {
3159
+ self::require_plugin_essentials();
3160
+
3161
+ $active_plugin = array();
3162
+ $all_plugins = fs_get_plugins();
3163
+ $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id );
3164
+
3165
+ foreach ( $active_plugins_basenames as $plugin_basename ) {
3166
+ $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
3167
+ }
3168
+
3169
+ return $active_plugin;
3170
+ }
3171
+
3172
+ /**
3173
+ * Get collection of all site active plugins for a specified blog.
3174
+ *
3175
+ * @author Vova Feldman (@svovaf)
3176
+ * @since 2.0.0
3177
+ *
3178
+ * @param int $blog_id
3179
+ *
3180
+ * @return array[string]array
3181
+ */
3182
+ private static function get_site_active_plugins( $blog_id = 0 ) {
3183
+ $active_basenames = ( is_multisite() && $blog_id > 0 ) ?
3184
+ get_blog_option( $blog_id, 'active_plugins' ) :
3185
+ get_option( 'active_plugins' );
3186
+
3187
+ $active = array();
3188
+
3189
+ if ( ! is_array( $active_basenames ) ) {
3190
+ return $active;
3191
+ }
3192
+
3193
+ foreach ( $active_basenames as $basename ) {
3194
+ $active[ $basename ] = array(
3195
+ 'is_active' => true,
3196
+ 'Version' => '1.0', // Dummy version.
3197
+ 'slug' => self::get_plugin_slug( $basename ),
3198
+ );
3199
+ }
3200
+
3201
+ return $active;
3202
+ }
3203
+
3204
+ /**
3205
+ * Get collection of all plugins with their activation status for a specified blog.
3206
+ *
3207
+ * @author Vova Feldman (@svovaf)
3208
+ * @since 1.1.8
3209
+ *
3210
+ * @param int $blog_id Since 2.0.0
3211
+ *
3212
+ * @return array Key is the plugin file path and the value is an array of the plugin data.
3213
+ */
3214
+ private static function get_all_plugins( $blog_id = 0 ) {
3215
+ self::require_plugin_essentials();
3216
+
3217
+ $all_plugins = fs_get_plugins();
3218
+
3219
+ $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id );
3220
+
3221
+ foreach ( $all_plugins as $basename => &$data ) {
3222
+ // By default set to inactive (next foreach update the active plugins).
3223
+ $data['is_active'] = false;
3224
+ // Enrich with plugin slug.
3225
+ $data['slug'] = self::get_plugin_slug( $basename );
3226
+ }
3227
+
3228
+ // Flag active plugins.
3229
+ foreach ( $active_plugins_basenames as $basename ) {
3230
+ if ( isset( $all_plugins[ $basename ] ) ) {
3231
+ $all_plugins[ $basename ]['is_active'] = true;
3232
+ }
3233
+ }
3234
+
3235
+ return $all_plugins;
3236
+ }
3237
+
3238
+ /**
3239
+ * Get collection of all plugins and if they are network level activated.
3240
+ *
3241
+ * @author Vova Feldman (@svovaf)
3242
+ * @since 2.0.0
3243
+ *
3244
+ * @return array Key is the plugin basename and the value is an array of the plugin data.
3245
+ */
3246
+ private static function get_network_plugins() {
3247
+ self::require_plugin_essentials();
3248
+
3249
+ $all_plugins = fs_get_plugins();
3250
+
3251
+ $network_active_basenames = is_multisite() ?
3252
+ get_site_option( 'active_sitewide_plugins' ) :
3253
+ array();
3254
+
3255
+ foreach ( $all_plugins as $basename => &$data ) {
3256
+ // By default set to inactive (next foreach update the active plugins).
3257
+ $data['is_active'] = false;
3258
+ // Enrich with plugin slug.
3259
+ $data['slug'] = self::get_plugin_slug( $basename );
3260
+ }
3261
+
3262
+ // Flag active plugins.
3263
+ foreach ( $network_active_basenames as $basename ) {
3264
+ if ( isset( $all_plugins[ $basename ] ) ) {
3265
+ $all_plugins[ $basename ]['is_active'] = true;
3266
+ }
3267
+ }
3268
+
3269
+ return $all_plugins;
3270
+ }
3271
+
3272
+ /**
3273
+ * Cached result of get_site_transient( 'update_plugins' )
3274
+ *
3275
+ * @author Vova Feldman (@svovaf)
3276
+ * @since 1.1.8
3277
+ *
3278
+ * @var object
3279
+ */
3280
+ private static $_plugins_info;
3281
+
3282
+ /**
3283
+ * Helper function to get specified plugin's slug.
3284
+ *
3285
+ * @author Vova Feldman (@svovaf)
3286
+ * @since 1.1.8
3287
+ *
3288
+ * @param $basename
3289
+ *
3290
+ * @return string
3291
+ */
3292
+ private static function get_plugin_slug( $basename ) {
3293
+ if ( ! isset( self::$_plugins_info ) ) {
3294
+ self::$_plugins_info = get_site_transient( 'update_plugins' );
3295
+ }
3296
+
3297
+ $slug = '';
3298
+
3299
+ if ( is_object( self::$_plugins_info ) ) {
3300
+ if ( isset( self::$_plugins_info->no_update ) &&
3301
+ isset( self::$_plugins_info->no_update[ $basename ] ) &&
3302
+ ! empty( self::$_plugins_info->no_update[ $basename ]->slug )
3303
+ ) {
3304
+ $slug = self::$_plugins_info->no_update[ $basename ]->slug;
3305
+ } else if ( isset( self::$_plugins_info->response ) &&
3306
+ isset( self::$_plugins_info->response[ $basename ] ) &&
3307
+ ! empty( self::$_plugins_info->response[ $basename ]->slug )
3308
+ ) {
3309
+ $slug = self::$_plugins_info->response[ $basename ]->slug;
3310
+ }
3311
+ }
3312
+
3313
+ if ( empty( $slug ) ) {
3314
+ // Try to find slug from FS data.
3315
+ $slug = self::find_slug_by_basename( $basename );
3316
+ }
3317
+
3318
+ if ( empty( $slug ) ) {
3319
+ // Fallback to plugin's folder name.
3320
+ $slug = dirname( $basename );
3321
+ }
3322
+
3323
+ return $slug;
3324
+ }
3325
+
3326
+ private static $_statics_loaded = false;
3327
+
3328
+ /**
3329
+ * Load static resources.
3330
+ *
3331
+ * @author Vova Feldman (@svovaf)
3332
+ * @since 1.0.1
3333
+ */
3334
+ private static function _load_required_static() {
3335
+ if ( self::$_statics_loaded ) {
3336
+ return;
3337
+ }
3338
+
3339
+ self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
3340
+
3341
+ self::$_static_logger->entrance();
3342
+
3343
+ self::$_accounts = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
3344
+
3345
+ if ( is_multisite() ) {
3346
+ $has_skipped_migration = (
3347
+ // 'id_slug_type_path_map' - was never stored on older versions, therefore, not exists on the site level.
3348
+ null === self::$_accounts->get_option( 'id_slug_type_path_map', null, false ) &&
3349
+ // 'file_slug_map' stored on the site level, so it was running an SDK version before it was integrated with MS-network.
3350
+ null !== self::$_accounts->get_option( 'file_slug_map', null, false )
3351
+ );
3352
+
3353
+ /**
3354
+ * If the file_slug_map exists on the site level but doesn't exist on the
3355
+ * network level storage, it means that we need to process the storage with migration.
3356
+ *
3357
+ * The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, file_slug_map will be already set in the network level storage.
3358
+ *
3359
+ * @author Vova Feldman (@svovaf)
3360
+ * @since 2.0.0
3361
+ */
3362
+ if (
3363
+ ( $has_skipped_migration && true !== self::$_accounts->get_option( 'ms_migration_complete', false, true ) ) ||
3364
+ ( null === self::$_accounts->get_option( 'file_slug_map', null, true ) &&
3365
+ null !== self::$_accounts->get_option( 'file_slug_map', null, false ) )
3366
+ ) {
3367
+ self::migrate_options_to_network();
3368
+ }
3369
+ }
3370
+
3371
+ self::$_global_admin_notices = FS_Admin_Notices::instance( 'global' );
3372
+
3373
+ if ( ! WP_FS__DEMO_MODE ) {
3374
+ add_action( ( fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu', array(
3375
+ 'Freemius',
3376
+ '_add_debug_section'
3377
+ ) );
3378
+ }
3379
+
3380
+ add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) );
3381
+
3382
+ self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) );
3383
+
3384
+ self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) );
3385
+
3386
+ self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) );
3387
+
3388
+ if ( 0 == did_action( 'plugins_loaded' ) ) {
3389
+ add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
3390
+ }
3391
+
3392
+ add_action( 'admin_footer', array( 'Freemius', '_enrich_ajax_url' ) );
3393
+ add_action( 'admin_footer', array( 'Freemius', '_open_support_forum_in_new_page' ) );
3394
+
3395
+ if ( self::is_plugins_page() || self::is_themes_page() ) {
3396
+ add_action( 'admin_print_footer_scripts', array( 'Freemius', '_maybe_add_beta_label_styles' ), 9 );
3397
+
3398
+ /**
3399
+ * Specifically use this hook so that the JS event handlers will work properly on the "Themes"
3400
+ * page.
3401
+ *
3402
+ * @author Leo Fajardo (@leorw)
3403
+ * @since 2.3.0
3404
+ */
3405
+ add_action( 'admin_footer-' . self::get_current_page(), array( 'Freemius', '_maybe_add_beta_label_to_plugins_and_handle_confirmation') );
3406
+ }
3407
+
3408
+ self::$_statics_loaded = true;
3409
+ }
3410
+
3411
+ /**
3412
+ * @author Leo Fajardo (@leorw)
3413
+ *
3414
+ * @since 2.1.3
3415
+ */
3416
+ private static function migrate_options_to_network() {
3417
+ self::migrate_accounts_to_network();
3418
+
3419
+ // Migrate API options from site level to network level.
3420
+ $api_network_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true, true );
3421
+ $api_network_options->migrate_to_network();
3422
+
3423
+ // Migrate API cache to network level storage.
3424
+ FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME )->migrate_to_network();
3425
+
3426
+ self::$_accounts->set_option( 'ms_migration_complete', true, true );
3427
+ }
3428
+
3429
+ #----------------------------------------------------------------------------------
3430
+ #region Localization
3431
+ #----------------------------------------------------------------------------------
3432
+
3433
+ /**
3434
+ * Load framework's text domain.
3435
+ *
3436
+ * @author Vova Feldman (@svovaf)
3437
+ * @since 1.2.1
3438
+ */
3439
+ static function _load_textdomain() {
3440
+ if ( ! is_admin() ) {
3441
+ return;
3442
+ }
3443
+
3444
+ global $fs_active_plugins;
3445
+
3446
+ // Works both for plugins and themes.
3447
+ load_plugin_textdomain(
3448
+ 'freemius',
3449
+ false,
3450
+ $fs_active_plugins->newest->sdk_path . '/languages/'
3451
+ );
3452
+ }
3453
+
3454
+ #endregion
3455
+
3456
+ #----------------------------------------------------------------------------------
3457
+ #region Debugging
3458
+ #----------------------------------------------------------------------------------
3459
+
3460
+ /**
3461
+ * @author Vova Feldman (@svovaf)
3462
+ * @since 1.0.8
3463
+ */
3464
+ static function _add_debug_section() {
3465
+ if ( ! is_super_admin() ) {
3466
+ // Add debug page only for super-admins.
3467
+ return;
3468
+ }
3469
+
3470
+ self::$_static_logger->entrance();
3471
+
3472
+ $title = sprintf( '%s [v.%s]', fs_text_inline( 'Freemius Debug' ), WP_FS__SDK_VERSION );
3473
+
3474
+ if ( WP_FS__DEV_MODE ) {
3475
+ // Add top-level debug menu item.
3476
+ $hook = FS_Admin_Menu_Manager::add_page(
3477
+ $title,
3478
+ $title,
3479
+ 'manage_options',
3480
+ 'freemius',
3481
+ array( 'Freemius', '_debug_page_render' )
3482
+ );
3483
+ } else {
3484
+ // Add hidden debug page.
3485
+ $hook = FS_Admin_Menu_Manager::add_subpage(
3486
+ null,
3487
+ $title,
3488
+ $title,
3489
+ 'manage_options',
3490
+ 'freemius',
3491
+ array( 'Freemius', '_debug_page_render' )
3492
+ );
3493
+ }
3494
+
3495
+ if ( ! empty( $hook ) ) {
3496
+ add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
3497
+ }
3498
+ }
3499
+
3500
+ /**
3501
+ * @author Vova Feldman (@svovaf)
3502
+ * @since 1.1.7.3
3503
+ */
3504
+ static function _toggle_debug_mode() {
3505
+ if ( ! is_super_admin() ) {
3506
+ return;
3507
+ }
3508
+
3509
+ $is_on = fs_request_get( 'is_on', false, 'post' );
3510
+
3511
+ if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
3512
+ update_option( 'fs_debug_mode', $is_on );
3513
+
3514
+ // Turn on/off storage logging.
3515
+ FS_Logger::_set_storage_logging( ( 1 == $is_on ) );
3516
+ }
3517
+
3518
+ exit;
3519
+ }
3520
+
3521
+ /**
3522
+ * @author Vova Feldman (@svovaf)
3523
+ * @since 1.2.1.6
3524
+ */
3525
+ static function _get_debug_log() {
3526
+ $logs = FS_Logger::load_db_logs(
3527
+ fs_request_get( 'filters', false, 'post' ),
3528
+ ! empty( $_POST['limit'] ) && is_numeric( $_POST['limit'] ) ? $_POST['limit'] : 200,
3529
+ ! empty( $_POST['offset'] ) && is_numeric( $_POST['offset'] ) ? $_POST['offset'] : 0
3530
+ );
3531
+
3532
+ self::shoot_ajax_success( $logs );
3533
+ }
3534
+
3535
+ /**
3536
+ * @author Vova Feldman (@svovaf)
3537
+ * @since 1.2.1.7
3538
+ */
3539
+ static function _get_db_option() {
3540
+ check_admin_referer( 'fs_get_db_option' );
3541
+
3542
+ $option_name = fs_request_get( 'option_name' );
3543
+
3544
+ if ( ! is_super_admin() ||
3545
+ ! fs_starts_with( $option_name, 'fs_' )
3546
+ ) {
3547
+ self::shoot_ajax_failure();
3548
+ }
3549
+
3550
+ $value = get_option( $option_name );
3551
+
3552
+ $result = array(
3553
+ 'name' => $option_name,
3554
+ );
3555
+
3556
+ if ( false !== $value ) {
3557
+ if ( ! is_string( $value ) ) {
3558
+ $value = json_encode( $value );
3559
+ }
3560
+
3561
+ $result['value'] = $value;
3562
+ }
3563
+
3564
+ self::shoot_ajax_success( $result );
3565
+ }
3566
+
3567
+ /**
3568
+ * @author Vova Feldman (@svovaf)
3569
+ * @since 1.2.1.7
3570
+ */
3571
+ static function _set_db_option() {
3572
+ check_admin_referer( 'fs_set_db_option' );
3573
+
3574
+ $option_name = fs_request_get( 'option_name' );
3575
+
3576
+ if ( ! is_super_admin() ||
3577
+ ! fs_starts_with( $option_name, 'fs_' )
3578
+ ) {
3579
+ self::shoot_ajax_failure();
3580
+ }
3581
+
3582
+ $option_value = fs_request_get( 'option_value' );
3583
+
3584
+ if ( ! empty( $option_value ) ) {
3585
+ update_option( $option_name, $option_value );
3586
+ }
3587
+
3588
+ self::shoot_ajax_success();
3589
+ }
3590
+
3591
+ /**
3592
+ * @author Vova Feldman (@svovaf)
3593
+ * @since 1.0.8
3594
+ */
3595
+ static function _debug_page_actions() {
3596
+ self::_clean_admin_content_section();
3597
+
3598
+ if ( fs_request_is_action( 'restart_freemius' ) ) {
3599
+ check_admin_referer( 'restart_freemius' );
3600
+
3601
+ if ( ! is_multisite() ) {
3602
+ // Clear accounts data.
3603
+ self::$_accounts->clear( null, true );
3604
+ } else {
3605
+ $sites = self::get_sites();
3606
+ foreach ( $sites as $site ) {
3607
+ $blog_id = self::get_site_blog_id( $site );
3608
+ self::$_accounts->clear( $blog_id, true );
3609
+ }
3610
+
3611
+ // Clear network level storage.
3612
+ self::$_accounts->clear( true, true );
3613
+ }
3614
+
3615
+ // Clear SDK reference cache.
3616
+ delete_option( 'fs_active_plugins' );
3617
+ } else if ( fs_request_is_action( 'clear_updates_data' ) ) {
3618
+ check_admin_referer( 'clear_updates_data' );
3619
+
3620
+ if ( ! is_multisite() ) {
3621
+ set_site_transient( 'update_plugins', null );
3622
+ set_site_transient( 'update_themes', null );
3623
+ } else {
3624
+ $current_blog_id = get_current_blog_id();
3625
+
3626
+ $sites = self::get_sites();
3627
+ foreach ( $sites as $site ) {
3628
+ switch_to_blog( self::get_site_blog_id( $site ) );
3629
+
3630
+ set_site_transient( 'update_plugins', null );
3631
+ set_site_transient( 'update_themes', null );
3632
+ }
3633
+
3634
+ switch_to_blog( $current_blog_id );
3635
+ }
3636
+ } else if ( fs_request_is_action( 'simulate_trial' ) ) {
3637
+ check_admin_referer( 'simulate_trial' );
3638
+
3639
+ $fs = freemius( fs_request_get( 'module_id' ) );
3640
+
3641
+ // Update SDK install to at least 24 hours before.
3642
+ $fs->_storage->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
3643
+ // Unset the trial shown timestamp.
3644
+ unset( $fs->_storage->trial_promotion_shown );
3645
+ } else if ( fs_request_is_action( 'simulate_network_upgrade' ) ) {
3646
+ check_admin_referer( 'simulate_network_upgrade' );
3647
+
3648
+ $fs = freemius( fs_request_get( 'module_id' ) );
3649
+
3650
+ self::set_network_upgrade_mode( $fs->_storage );
3651
+ } else if ( fs_request_is_action( 'delete_install' ) ) {
3652
+ check_admin_referer( 'delete_install' );
3653
+
3654
+ self::_delete_site_by_slug(
3655
+ fs_request_get( 'slug' ),
3656
+ fs_request_get( 'module_type' ),
3657
+ true,
3658
+ fs_request_get( 'blog_id', null )
3659
+ );
3660
+ } else if ( fs_request_is_action( 'delete_user' ) ) {
3661
+ check_admin_referer( 'delete_user' );
3662
+
3663
+ self::delete_user( fs_request_get( 'user_id' ) );
3664
+ } else if ( fs_request_is_action( 'download_logs' ) ) {
3665
+ check_admin_referer( 'download_logs' );
3666
+
3667
+ $download_url = FS_Logger::download_db_logs(
3668
+ fs_request_get( 'filters', false, 'post' )
3669
+ );
3670
+
3671
+ if ( false === $download_url ) {
3672
+ wp_die( 'Oops... there was an error while generating the logs download file. Please try again and if it doesn\'t work contact support@freemius.com.' );
3673
+ }
3674
+
3675
+ fs_redirect( $download_url );
3676
+ } else if ( fs_request_is_action( 'migrate_options_to_network' ) ) {
3677
+ check_admin_referer( 'migrate_options_to_network' );
3678
+
3679
+ self::migrate_options_to_network();
3680
+ }
3681
+ }
3682
+
3683
+ /**
3684
+ * @author Vova Feldman (@svovaf)
3685
+ * @since 1.0.8
3686
+ */
3687
+ static function _debug_page_render() {
3688
+ self::$_static_logger->entrance();
3689
+
3690
+ if ( ! is_multisite() ) {
3691
+ $all_plugins_installs = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );
3692
+ $all_themes_installs = self::get_all_sites( WP_FS__MODULE_TYPE_THEME );
3693
+ } else {
3694
+ $sites = self::get_sites();
3695
+
3696
+ $all_plugins_installs = array();
3697
+ $all_themes_installs = array();
3698
+
3699
+ foreach ( $sites as $site ) {
3700
+ $blog_id = self::get_site_blog_id( $site );
3701
+
3702
+ $plugins_installs = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN, $blog_id );
3703
+
3704
+ foreach ( $plugins_installs as $slug => $install ) {
3705
+ if ( ! isset( $all_plugins_installs[ $slug ] ) ) {
3706
+ $all_plugins_installs[ $slug ] = array();
3707
+ }
3708
+
3709
+ $install->blog_id = $blog_id;
3710
+
3711
+ $all_plugins_installs[ $slug ][] = $install;
3712
+ }
3713
+
3714
+ $themes_installs = self::get_all_sites( WP_FS__MODULE_TYPE_THEME, $blog_id );
3715
+
3716
+ foreach ( $themes_installs as $slug => $install ) {
3717
+ if ( ! isset( $all_themes_installs[ $slug ] ) ) {
3718
+ $all_themes_installs[ $slug ] = array();
3719
+ }
3720
+
3721
+ $install->blog_id = $blog_id;
3722
+
3723
+ $all_themes_installs[ $slug ][] = $install;
3724
+ }
3725
+ }
3726
+ }
3727
+
3728
+ $licenses_by_module_type = self::get_all_licenses_by_module_type();
3729
+
3730
+ $vars = array(
3731
+ 'plugin_sites' => $all_plugins_installs,
3732
+ 'theme_sites' => $all_themes_installs,
3733
+ 'users' => self::get_all_users(),
3734
+ 'addons' => self::get_all_addons(),
3735
+ 'account_addons' => self::get_all_account_addons(),
3736
+ 'plugin_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_PLUGIN ],
3737
+ 'theme_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_THEME ]
3738
+ );
3739
+
3740
+ fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
3741
+ fs_require_once_template( 'debug.php', $vars );
3742
+ }
3743
+
3744
+ #endregion
3745
+
3746
+ #----------------------------------------------------------------------------------
3747
+ #region Connectivity Issues
3748
+ #----------------------------------------------------------------------------------
3749
+
3750
+ /**
3751
+ * Check if Freemius should be turned on for the current plugin install.
3752
+ *
3753
+ * Note:
3754
+ * $this->_is_on is updated in has_api_connectivity()
3755
+ *
3756
+ * @author Vova Feldman (@svovaf)
3757
+ * @since 1.0.9
3758
+ *
3759
+ * @return bool
3760
+ */
3761
+ function is_on() {
3762
+ self::$_static_logger->entrance();
3763
+
3764
+ if ( isset( $this->_is_on ) ) {
3765
+ return $this->_is_on;
3766
+ }
3767
+
3768
+ // If already installed or pending then sure it's on :)
3769
+ if ( $this->is_registered() || $this->is_pending_activation() ) {
3770
+ $this->_is_on = true;
3771
+
3772
+ return true;
3773
+ }
3774
+
3775
+ return false;
3776
+ }
3777
+
3778
+ /**
3779
+ * @author Vova Feldman (@svovaf)
3780
+ * @since 1.1.7.3
3781
+ *
3782
+ * @param bool $flush_if_no_connectivity
3783
+ *
3784
+ * @return bool
3785
+ */
3786
+ private function should_run_connectivity_test( $flush_if_no_connectivity = false ) {
3787
+ if ( ! isset( $this->_storage->connectivity_test ) ) {
3788
+ // Connectivity test was never executed, or cache was cleared.
3789
+ return true;
3790
+ }
3791
+
3792
+ if ( WP_FS__PING_API_ON_IP_OR_HOST_CHANGES ) {
3793
+ if ( WP_FS__IS_HTTP_REQUEST ) {
3794
+ if ( $_SERVER['HTTP_HOST'] != $this->_storage->connectivity_test['host'] ) {
3795
+ // Domain changed.
3796
+ return true;
3797
+ }
3798
+
3799
+ if ( WP_FS__REMOTE_ADDR != $this->_storage->connectivity_test['server_ip'] ) {
3800
+ // Server IP changed.
3801
+ return true;
3802
+ }
3803
+ }
3804
+ }
3805
+
3806
+ if ( $this->_storage->connectivity_test['is_connected'] &&
3807
+ $this->_storage->connectivity_test['is_active']
3808
+ ) {
3809
+ // API connected and Freemius is active - no need to run connectivity check.
3810
+ return false;
3811
+ }
3812
+
3813
+ if ( $flush_if_no_connectivity ) {
3814
+ /**
3815
+ * If explicitly asked to flush when no connectivity - do it only
3816
+ * if at least 10 sec passed from the last API connectivity test.
3817
+ */
3818
+ return ( isset( $this->_storage->connectivity_test['timestamp'] ) &&
3819
+ ( WP_FS__SCRIPT_START_TIME - $this->_storage->connectivity_test['timestamp'] ) > 10 );
3820
+ }
3821
+
3822
+ /**
3823
+ * @since 1.1.7 Don't check for connectivity on plugin downgrade.
3824
+ */
3825
+ $version = $this->get_plugin_version();
3826
+ if ( version_compare( $version, $this->_storage->connectivity_test['version'], '>' ) ) {
3827
+ // If it's a plugin version upgrade and Freemius is off or no connectivity, run connectivity test.
3828
+ return true;
3829
+ }
3830
+
3831
+ return false;
3832
+ }
3833
+
3834
+ /**
3835
+ * @author Vova Feldman (@svovaf)
3836
+ * @since 1.1.7.4
3837
+ *
3838
+ * @param int|null $blog_id Since 2.0.0.
3839
+ * @param bool $is_gdpr_test Since 2.0.2. Perform only the GDPR test.
3840
+ *
3841
+ * @return object|false
3842
+ */
3843
+ private function ping( $blog_id = null, $is_gdpr_test = false ) {
3844
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
3845
+ return false;
3846
+ }
3847
+
3848
+ $version = $this->get_plugin_version();
3849
+
3850
+ $is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
3851
+
3852
+ return $this->get_api_plugin_scope()->ping(
3853
+ $this->get_anonymous_id( $blog_id ),
3854
+ array(
3855
+ 'is_update' => json_encode( $is_update ),
3856
+ 'version' => $version,
3857
+ 'sdk' => $this->version,
3858
+ 'is_admin' => json_encode( is_admin() ),
3859
+ 'is_ajax' => json_encode( self::is_ajax() ),
3860
+ 'is_cron' => json_encode( self::is_cron() ),
3861
+ 'is_gdpr_test' => $is_gdpr_test,
3862
+ 'is_http' => json_encode( WP_FS__IS_HTTP_REQUEST ),
3863
+ )
3864
+ );
3865
+ }
3866
+
3867
+ /**
3868
+ * Check if there's any connectivity issue to Freemius API.
3869
+ *
3870
+ * @author Vova Feldman (@svovaf)
3871
+ * @since 1.0.9
3872
+ *
3873
+ * @param bool $flush_if_no_connectivity
3874
+ *
3875
+ * @return bool
3876
+ */
3877
+ function has_api_connectivity( $flush_if_no_connectivity = false ) {
3878
+ $this->_logger->entrance();
3879
+
3880
+ if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) {
3881
+ return $this->_has_api_connection;
3882
+ }
3883
+
3884
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
3885
+ isset( $this->_storage->connectivity_test ) &&
3886
+ true === $this->_storage->connectivity_test['is_connected']
3887
+ ) {
3888
+ unset( $this->_storage->connectivity_test );
3889
+ }
3890
+
3891
+ if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) {
3892
+ $this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
3893
+ /**
3894
+ * @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration.
3895
+ *
3896
+ * @since 1.2.1.5 If the user running the premium version then ignore the 'is_active' flag and turn Freemius on to enable license key activation.
3897
+ */
3898
+ $this->_is_on = $this->_storage->connectivity_test['is_active'] ||
3899
+ $this->is_premium() ||
3900
+ ( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF );
3901
+
3902
+ return $this->_has_api_connection;
3903
+ }
3904
+
3905
+ $pong = $this->ping();
3906
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
3907
+
3908
+ if ( ! $is_connected ) {
3909
+ // API failure.
3910
+ $this->_add_connectivity_issue_message( $pong );
3911
+ }
3912
+
3913
+ if ( $is_connected ) {
3914
+ FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
3915
+ }
3916
+
3917
+ $this->store_connectivity_info( $pong, $is_connected );
3918
+
3919
+ return $this->_has_api_connection;
3920
+ }
3921
+
3922
+ /**
3923
+ * @author Vova Feldman (@svovaf)
3924
+ * @since 1.1.7.4
3925
+ *
3926
+ * @param object $pong
3927
+ * @param bool $is_connected
3928
+ */
3929
+ private function store_connectivity_info( $pong, $is_connected ) {
3930
+ $this->_logger->entrance();
3931
+
3932
+ $version = $this->get_plugin_version();
3933
+
3934
+ if ( ! $is_connected || WP_FS__SIMULATE_FREEMIUS_OFF ) {
3935
+ $is_active = false;
3936
+ } else {
3937
+ $is_active = ( isset( $pong->is_active ) && true == $pong->is_active );
3938
+ }
3939
+
3940
+ $is_active = $this->apply_filters(
3941
+ 'is_on',
3942
+ $is_active,
3943
+ $this->is_plugin_update(),
3944
+ $version
3945
+ );
3946
+
3947
+ $this->_storage->connectivity_test = array(
3948
+ 'is_connected' => $is_connected,
3949
+ 'host' => $_SERVER['HTTP_HOST'],
3950
+ 'server_ip' => WP_FS__REMOTE_ADDR,
3951
+ 'is_active' => $is_active,
3952
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
3953
+ // Last version with connectivity attempt.
3954
+ 'version' => $version,
3955
+ );
3956
+
3957
+ $this->_has_api_connection = $is_connected;
3958
+ $this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected && ! WP_FS__SIMULATE_FREEMIUS_OFF );
3959
+ }
3960
+
3961
+ /**
3962
+ * Force turning Freemius on.
3963
+ *
3964
+ * @author Vova Feldman (@svovaf)
3965
+ * @since 1.1.8.1
3966
+ *
3967
+ * @return bool TRUE if successfully turned on.
3968
+ */
3969
+ private function turn_on() {
3970
+ $this->_logger->entrance();
3971
+
3972
+ if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) {
3973
+ return false;
3974
+ }
3975
+
3976
+ $updated_connectivity = $this->_storage->connectivity_test;
3977
+ $updated_connectivity['is_active'] = true;
3978
+ $updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME;
3979
+ $this->_storage->connectivity_test = $updated_connectivity;
3980
+
3981
+ $this->_is_on = true;
3982
+
3983
+ return true;
3984
+ }
3985
+
3986
+ /**
3987
+ * Anonymous and unique site identifier (Hash).
3988
+ *
3989
+ * @author Vova Feldman (@svovaf)
3990
+ * @since 1.1.0
3991
+ *
3992
+ * @param null|int $blog_id Since 2.0.0
3993
+ *
3994
+ * @return string
3995
+ */
3996
+ function get_anonymous_id( $blog_id = null ) {
3997
+ $unique_id = self::$_accounts->get_option( 'unique_id', null, $blog_id );
3998
+
3999
+ if ( empty( $unique_id ) || ! is_string( $unique_id ) ) {
4000
+ $key = fs_strip_url_protocol( get_site_url( $blog_id ) );
4001
+
4002
+ $secure_auth = SECURE_AUTH_KEY;
4003
+ if ( empty( $secure_auth ) ||
4004
+ false !== strpos( $secure_auth, ' ' ) ||
4005
+ 'put your unique phrase here' === $secure_auth
4006
+ ) {
4007
+ // Protect against default auth key.
4008
+ $secure_auth = md5( microtime() );
4009
+ }
4010
+
4011
+ /**
4012
+ * Base the unique identifier on the WP secure authentication key. Which
4013
+ * turns the key into a secret anonymous identifier. This will help us
4014
+ * to avoid duplicate installs generation on the backend upon opt-in.
4015
+ *
4016
+ * @author Vova Feldman (@svovaf)
4017
+ * @since 1.2.3
4018
+ */
4019
+ $unique_id = md5( $key . $secure_auth );
4020
+
4021
+ self::$_accounts->set_option( 'unique_id', $unique_id, true, $blog_id );
4022
+ }
4023
+
4024
+ $this->_logger->departure( $unique_id );
4025
+
4026
+ return $unique_id;
4027
+ }
4028
+
4029
+ /**
4030
+ * @author Vova Feldman (@svovaf)
4031
+ * @since 1.1.7.4
4032
+ *
4033
+ * @return \WP_User
4034
+ */
4035
+ static function _get_current_wp_user() {
4036
+ self::require_pluggable_essentials();
4037
+ self::wp_cookie_constants();
4038
+
4039
+ return wp_get_current_user();
4040
+ }
4041
+
4042
+ /**
4043
+ * Define cookie constants which are required by Freemius::_get_current_wp_user() since
4044
+ * it uses wp_get_current_user() which needs the cookie constants set. When a plugin
4045
+ * is network activated the cookie constants are only configured after the network
4046
+ * plugins activation, therefore, if we don't define those constants WP will throw
4047
+ * PHP warnings/notices.
4048
+ *
4049
+ * @author Vova Feldman (@svovaf)
4050
+ * @since 2.1.1
4051
+ */
4052
+ private static function wp_cookie_constants() {
4053
+ if ( defined( 'LOGGED_IN_COOKIE' ) &&
4054
+ ( defined( 'AUTH_COOKIE' ) || defined( 'SECURE_AUTH_COOKIE' ) )
4055
+ ) {
4056
+ return;
4057
+ }
4058
+
4059
+ /**
4060
+ * Used to guarantee unique hash cookies
4061
+ *
4062
+ * @since 1.5.0
4063
+ */
4064
+ if ( ! defined( 'COOKIEHASH' ) ) {
4065
+ $siteurl = get_site_option( 'siteurl' );
4066
+ if ( $siteurl ) {
4067
+ define( 'COOKIEHASH', md5( $siteurl ) );
4068
+ } else {
4069
+ define( 'COOKIEHASH', '' );
4070
+ }
4071
+ }
4072
+
4073
+ if ( ! defined( 'LOGGED_IN_COOKIE' ) ) {
4074
+ define( 'LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH );
4075
+ }
4076
+
4077
+ /**
4078
+ * @since 2.5.0
4079
+ */
4080
+ if ( ! defined( 'AUTH_COOKIE' ) ) {
4081
+ define( 'AUTH_COOKIE', 'wordpress_' . COOKIEHASH );
4082
+ }
4083
+
4084
+ /**
4085
+ * @since 2.6.0
4086
+ */
4087
+ if ( ! defined( 'SECURE_AUTH_COOKIE' ) ) {
4088
+ define( 'SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH );
4089
+ }
4090
+ }
4091
+
4092
+ /**
4093
+ * @author Vova Feldman (@svovaf)
4094
+ * @since 2.1.0
4095
+ *
4096
+ * @return int
4097
+ */
4098
+ static function get_current_wp_user_id() {
4099
+ $wp_user = self::_get_current_wp_user();
4100
+
4101
+ return $wp_user->ID;
4102
+ }
4103
+
4104
+ /**
4105
+ * @author Vova Feldman (@svovaf)
4106
+ * @since 1.2.1.7
4107
+ *
4108
+ * @param string $email
4109
+ *
4110
+ * @return bool
4111
+ */
4112
+ static function is_valid_email( $email ) {
4113
+ if ( false === filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
4114
+ return false;
4115
+ }
4116
+
4117
+ $parts = explode( '@', $email );
4118
+
4119
+ if ( 2 !== count( $parts ) || empty( $parts[1] ) ) {
4120
+ return false;
4121
+ }
4122
+
4123
+ $blacklist = array(
4124
+ 'admin.',
4125
+ 'webmaster.',
4126
+ 'localhost.',
4127
+ 'dev.',
4128
+ 'development.',
4129
+ 'test.',
4130
+ 'stage.',
4131
+ 'staging.',
4132
+ );
4133
+
4134
+ // Make sure domain is not one of the blacklisted.
4135
+ foreach ( $blacklist as $invalid ) {
4136
+ if ( 0 === strpos( $parts[1], $invalid ) ) {
4137
+ return false;
4138
+ }
4139
+ }
4140
+
4141
+ // Get the UTF encoded domain name.
4142
+ $domain = idn_to_ascii( $parts[1] ) . '.';
4143
+
4144
+ return ( checkdnsrr( $domain, 'MX' ) || checkdnsrr( $domain, 'A' ) );
4145
+ }
4146
+
4147
+ /**
4148
+ * Generate API connectivity issue message.
4149
+ *
4150
+ * @author Vova Feldman (@svovaf)
4151
+ * @since 1.0.9
4152
+ *
4153
+ * @param mixed $api_result
4154
+ * @param bool $is_first_failure
4155
+ */
4156
+ function _add_connectivity_issue_message( $api_result, $is_first_failure = true ) {
4157
+ if ( ! $this->is_premium() && $this->_enable_anonymous ) {
4158
+ // Don't add message if it's the free version and can run anonymously.
4159
+ return;
4160
+ }
4161
+
4162
+ if ( ! function_exists( 'wp_nonce_url' ) ) {
4163
+ require_once ABSPATH . 'wp-includes/functions.php';
4164
+ }
4165
+
4166
+ $current_user = self::_get_current_wp_user();
4167
+ // $admin_email = get_option( 'admin_email' );
4168
+ $admin_email = $current_user->user_email;
4169
+
4170
+ // Aliases.
4171
+ $deactivate_plugin_title = $this->esc_html_inline( 'That\'s exhausting, please deactivate', 'deactivate-plugin-title' );
4172
+ $deactivate_plugin_desc = $this->esc_html_inline( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.', 'deactivate-plugin-desc' );
4173
+ $install_previous_title = $this->esc_html_inline( 'Let\'s try your previous version', 'install-previous-title' );
4174
+ $install_previous_desc = $this->esc_html_inline( 'Uninstall this version and install the previous one.', 'install-previous-desc' );
4175
+ $fix_issue_title = $this->esc_html_inline( 'Yes - I\'m giving you a chance to fix it', 'fix-issue-title' );
4176
+ $fix_issue_desc = $this->esc_html_inline( 'We will do our best to whitelist your server and resolve this issue ASAP. You will get a follow-up email to %s once we have an update.', 'fix-issue-desc' );
4177
+ /* translators: %s: product title (e.g. "Awesome Plugin" requires an access to...) */
4178
+ $x_requires_access_to_api = $this->esc_html_inline( '%s requires an access to our API.', 'x-requires-access-to-api' );
4179
+ $sysadmin_title = $this->esc_html_inline( 'I\'m a system administrator', 'sysadmin-title' );
4180
+ $happy_to_resolve_issue_asap = $this->esc_html_inline( 'We are sure it\'s an issue on our side and more than happy to resolve it for you ASAP if you give us a chance.', 'happy-to-resolve-issue-asap' );
4181
+
4182
+ $message = false;
4183
+ if ( is_object( $api_result ) &&
4184
+ isset( $api_result->error ) &&
4185
+ isset( $api_result->error->code )
4186
+ ) {
4187
+ switch ( $api_result->error->code ) {
4188
+ case 'curl_missing':
4189
+ $missing_methods = '';
4190
+ if ( is_array( $api_result->missing_methods ) &&
4191
+ ! empty( $api_result->missing_methods )
4192
+ ) {
4193
+ foreach ( $api_result->missing_methods as $m ) {
4194
+ if ( 'curl_version' === $m ) {
4195
+ continue;
4196
+ }
4197
+
4198
+ if ( ! empty( $missing_methods ) ) {
4199
+ $missing_methods .= ', ';
4200
+ }
4201
+
4202
+ $missing_methods .= sprintf( '<code>%s</code>', $m );
4203
+ }
4204
+
4205
+ if ( ! empty( $missing_methods ) ) {
4206
+ $missing_methods = sprintf(
4207
+ '<br><br><b>%s</b> %s',
4208
+ $this->esc_html_inline( 'Disabled method(s):', 'curl-disabled-methods' ),
4209
+ $missing_methods
4210
+ );
4211
+ }
4212
+ }
4213
+
4214
+ $message = sprintf(
4215
+ $x_requires_access_to_api . ' ' .
4216
+ $this->esc_html_inline( 'We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server.', 'curl-missing-message' ) . ' ' .
4217
+ $missing_methods .
4218
+ ' %s',
4219
+ '<b>' . $this->get_plugin_name() . '</b>',
4220
+ sprintf(
4221
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
4222
+ sprintf(
4223
+ '<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
4224
+ $this->get_text_inline( 'I don\'t know what is cURL or how to install it, help me!', 'curl-missing-no-clue-title' ),
4225
+ ' - ' . sprintf(
4226
+ $this->get_text_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'curl-missing-no-clue-desc' ),
4227
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4228
+ )
4229
+ ),
4230
+ sprintf(
4231
+ '<b>%s</b> - %s',
4232
+ $sysadmin_title,
4233
+ esc_html( sprintf( $this->get_text_inline( 'Great, please install cURL and enable it in your php.ini file. In addition, search for the \'disable_functions\' directive in your php.ini file and remove any disabled methods starting with \'curl_\'. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the %s and reactivate it back again.', 'curl-missing-sysadmin-desc' ), $this->get_module_label( true ) ) )
4234
+ ),
4235
+ sprintf(
4236
+ '<a href="%s"><b>%s</b></a> - %s',
4237
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
4238
+ $deactivate_plugin_title,
4239
+ $deactivate_plugin_desc
4240
+ )
4241
+ )
4242
+ );
4243
+ break;
4244
+ case 'cloudflare_ddos_protection':
4245
+ $message = sprintf(
4246
+ $x_requires_access_to_api . ' ' .
4247
+ $this->esc_html_inline( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'cloudflare-blocks-connection-message' ) . ' ' .
4248
+ $happy_to_resolve_issue_asap .
4249
+ ' %s',
4250
+ '<b>' . $this->get_plugin_name() . '</b>',
4251
+ sprintf(
4252
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
4253
+ sprintf(
4254
+ '<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
4255
+ $fix_issue_title,
4256
+ ' - ' . sprintf(
4257
+ $fix_issue_desc,
4258
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4259
+ )
4260
+ ),
4261
+ sprintf(
4262
+ '<a href="%s" target="_blank"><b>%s</b></a> - %s',
4263
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
4264
+ $install_previous_title,
4265
+ $install_previous_desc
4266
+ ),
4267
+ sprintf(
4268
+ '<a href="%s"><b>%s</b></a> - %s',
4269
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
4270
+ $deactivate_plugin_title,
4271
+ $deactivate_plugin_desc
4272
+ )
4273
+ )
4274
+ );
4275
+ break;
4276
+ case 'squid_cache_block':
4277
+ $message = sprintf(
4278
+ $x_requires_access_to_api . ' ' .
4279
+ $this->esc_html_inline( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'squid-blocks-connection-message' ) .
4280
+ ' %s',
4281
+ '<b>' . $this->get_plugin_name() . '</b>',
4282
+ sprintf(
4283
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
4284
+ sprintf(
4285
+ '<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a> - %s',
4286
+ $this->esc_html_inline( 'I don\'t know what is Squid or ACL, help me!', 'squid-no-clue-title' ),
4287
+ sprintf(
4288
+ $this->esc_html_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'squid-no-clue-desc' ),
4289
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4290
+ )
4291
+ ),
4292
+ sprintf(
4293
+ '<b>%s</b> - %s',
4294
+ $sysadmin_title,
4295
+ sprintf(
4296
+ $this->esc_html_inline( 'Great, please whitelist the following domains: %s. Once you are done, deactivate the %s and activate it again.', 'squid-sysadmin-desc' ),
4297
+ // We use a filter since the plugin might require additional API connectivity.
4298
+ '<b>' . implode( ', ', $this->apply_filters( 'api_domains', array(
4299
+ 'api.freemius.com',
4300
+ 'wp.freemius.com'
4301
+ ) ) ) . '</b>',
4302
+ $this->_module_type
4303
+ )
4304
+ ),
4305
+ sprintf(
4306
+ '<a href="%s"><b>%s</b></a> - %s',
4307
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
4308
+ $deactivate_plugin_title,
4309
+ $deactivate_plugin_desc
4310
+ )
4311
+ )
4312
+ );
4313
+ break;
4314
+ // default:
4315
+ // $message = $this->get_text_inline( 'connectivity-test-fails-message' );
4316
+ // break;
4317
+ }
4318
+ }
4319
+
4320
+ $message_id = 'failed_connect_api';
4321
+ $type = 'error';
4322
+
4323
+ $connectivity_test_fails_message = $this->esc_html_inline( 'From unknown reason, the API connectivity test failed.', 'connectivity-test-fails-message' );
4324
+
4325
+ if ( false === $message ) {
4326
+ if ( $is_first_failure ) {
4327
+ // First attempt failed.
4328
+ $message = sprintf(
4329
+ $x_requires_access_to_api . ' ' .
4330
+ $connectivity_test_fails_message . ' ' .
4331
+ $this->esc_html_inline( 'It\'s probably a temporary issue on our end. Just to be sure, with your permission, would it be o.k to run another connectivity test?', 'connectivity-test-maybe-temporary' ) . '<br><br>' .
4332
+ '%s',
4333
+ '<b>' . $this->get_plugin_name() . '</b>',
4334
+ sprintf(
4335
+ '<div id="fs_firewall_issue_options">%s %s</div>',
4336
+ sprintf(
4337
+ '<a class="button button-primary fs-resolve" data-type="retry_ping" href="#">%s</a>',
4338
+ $this->get_text_inline( 'Yes - do your thing', 'yes-do-your-thing' )
4339
+ ),
4340
+ sprintf(
4341
+ '<a href="%s" class="button">%s</a>',
4342
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
4343
+ $this->get_text_inline( 'No - just deactivate', 'no-deactivate' )
4344
+ )
4345
+ )
4346
+ );
4347
+
4348
+ $message_id = 'failed_connect_api_first';
4349
+ $type = 'promotion';
4350
+ } else {
4351
+ // Second connectivity attempt failed.
4352
+ $message = sprintf(
4353
+ $x_requires_access_to_api . ' ' .
4354
+ $connectivity_test_fails_message . ' ' .
4355
+ $happy_to_resolve_issue_asap .
4356
+ ' %s',
4357
+ '<b>' . $this->get_plugin_name() . '</b>',
4358
+ sprintf(
4359
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
4360
+ sprintf(
4361
+ '<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
4362
+ $fix_issue_title,
4363
+ ' - ' . sprintf(
4364
+ $fix_issue_desc,
4365
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4366
+ )
4367
+ ),
4368
+ sprintf(
4369
+ '<a href="%s" target="_blank"><b>%s</b></a> - %s',
4370
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
4371
+ $install_previous_title,
4372
+ $install_previous_desc
4373
+ ),
4374
+ sprintf(
4375
+ '<a href="%s"><b>%s</b></a> - %s',
4376
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
4377
+ $deactivate_plugin_title,
4378
+ $deactivate_plugin_desc
4379
+ )
4380
+ )
4381
+ );
4382
+ }
4383
+ }
4384
+
4385
+ $this->_admin_notices->add_sticky(
4386
+ $message,
4387
+ $message_id,
4388
+ $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
4389
+ $type
4390
+ );
4391
+ }
4392
+
4393
+ /**
4394
+ * Handle user request to resolve connectivity issue.
4395
+ * This method will send an email to Freemius API technical staff for resolution.
4396
+ * The email will contain server's info and installed plugins (might be caching issue).
4397
+ *
4398
+ * @author Vova Feldman (@svovaf)
4399
+ * @since 1.0.9
4400
+ */
4401
+ function _email_about_firewall_issue() {
4402
+ $this->_admin_notices->remove_sticky( 'failed_connect_api' );
4403
+
4404
+ $pong = $this->ping();
4405
+
4406
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
4407
+
4408
+ if ( $is_connected ) {
4409
+ FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
4410
+
4411
+ $this->store_connectivity_info( $pong, $is_connected );
4412
+
4413
+ echo $this->get_after_plugin_activation_redirect_url();
4414
+ exit;
4415
+ }
4416
+
4417
+ $current_user = self::_get_current_wp_user();
4418
+ $admin_email = $current_user->user_email;
4419
+
4420
+ $error_type = fs_request_get( 'error_type', 'general' );
4421
+
4422
+ switch ( $error_type ) {
4423
+ case 'squid':
4424
+ $title = 'Squid ACL Blocking Issue';
4425
+ break;
4426
+ case 'cloudflare':
4427
+ $title = 'CloudFlare Blocking Issue';
4428
+ break;
4429
+ default:
4430
+ $title = 'API Connectivity Issue';
4431
+ break;
4432
+ }
4433
+
4434
+ $custom_email_sections = array();
4435
+
4436
+ // Add 'API Error' custom email section.
4437
+ $custom_email_sections['api_error'] = array(
4438
+ 'title' => 'API Error',
4439
+ 'rows' => array(
4440
+ 'ping' => array(
4441
+ 'API Error',
4442
+ is_string( $pong ) ? htmlentities( $pong ) : json_encode( $pong )
4443
+ ),
4444
+ )
4445
+ );
4446
+
4447
+ // Send email with technical details to resolve API connectivity issues.
4448
+ $this->send_email(
4449
+ 'api@freemius.com', // recipient
4450
+ $title . ' [' . $this->get_plugin_name() . ']', // subject
4451
+ $custom_email_sections,
4452
+ array( "Reply-To: $admin_email <$admin_email>" ) // headers
4453
+ );
4454
+
4455
+ $this->_admin_notices->add_sticky(
4456
+ sprintf(
4457
+ $this->get_text_inline( 'Thank for giving us the chance to fix it! A message was just sent to our technical staff. We will get back to you as soon as we have an update to %s. Appreciate your patience.', 'fix-request-sent-message' ),
4458
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4459
+ ),
4460
+ 'server_details_sent'
4461
+ );
4462
+
4463
+ // Action was taken, tell that API connectivity troubleshooting should be off now.
4464
+
4465
+ echo "1";
4466
+ exit;
4467
+ }
4468
+
4469
+ /**
4470
+ * Handle connectivity test retry approved by the user.
4471
+ *
4472
+ * @author Vova Feldman (@svovaf)
4473
+ * @since 1.1.7.4
4474
+ */
4475
+ function _retry_connectivity_test() {
4476
+ $this->_admin_notices->remove_sticky( 'failed_connect_api_first' );
4477
+
4478
+ $pong = $this->ping();
4479
+
4480
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
4481
+
4482
+ if ( $is_connected ) {
4483
+ FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
4484
+
4485
+ $this->store_connectivity_info( $pong, $is_connected );
4486
+
4487
+ echo $this->get_after_plugin_activation_redirect_url();
4488
+ } else {
4489
+ // Add connectivity issue message after 2nd failed attempt.
4490
+ $this->_add_connectivity_issue_message( $pong, false );
4491
+
4492
+ echo "1";
4493
+ }
4494
+
4495
+ exit;
4496
+ }
4497
+
4498
+ static function _add_firewall_issues_javascript() {
4499
+ $params = array();
4500
+ fs_require_once_template( 'firewall-issues-js.php', $params );
4501
+ }
4502
+
4503
+ #endregion
4504
+
4505
+ #----------------------------------------------------------------------------------
4506
+ #region Email
4507
+ #----------------------------------------------------------------------------------
4508
+
4509
+ /**
4510
+ * Generates and sends an HTML email with customizable sections.
4511
+ *
4512
+ * @author Leo Fajardo (@leorw)
4513
+ * @since 1.1.2
4514
+ *
4515
+ * @param string $to_address
4516
+ * @param string $subject
4517
+ * @param array $sections
4518
+ * @param array $headers
4519
+ *
4520
+ * @return bool Whether the email contents were sent successfully.
4521
+ */
4522
+ private function send_email(
4523
+ $to_address,
4524
+ $subject,
4525
+ $sections = array(),
4526
+ $headers = array()
4527
+ ) {
4528
+ $default_sections = $this->get_email_sections();
4529
+
4530
+ // Insert new sections or replace the default email sections.
4531
+ if ( is_array( $sections ) && ! empty( $sections ) ) {
4532
+ foreach ( $sections as $section_id => $custom_section ) {
4533
+ if ( ! isset( $default_sections[ $section_id ] ) ) {
4534
+ // If the section does not exist, add it.
4535
+ $default_sections[ $section_id ] = $custom_section;
4536
+ } else {
4537
+ // If the section already exists, override it.
4538
+ $current_section = $default_sections[ $section_id ];
4539
+
4540
+ // Replace the current section's title if a custom section title exists.
4541
+ if ( isset( $custom_section['title'] ) ) {
4542
+ $current_section['title'] = $custom_section['title'];
4543
+ }
4544
+
4545
+ // Insert new rows under the current section or replace the default rows.
4546
+ if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
4547
+ foreach ( $custom_section['rows'] as $row_id => $row ) {
4548
+ $current_section['rows'][ $row_id ] = $row;
4549
+ }
4550
+ }
4551
+
4552
+ $default_sections[ $section_id ] = $current_section;
4553
+ }
4554
+ }
4555
+ }
4556
+
4557
+ $vars = array( 'sections' => $default_sections );
4558
+ $message = fs_get_template( 'email.php', $vars );
4559
+
4560
+ // Set the type of email to HTML.
4561
+ $headers[] = 'Content-type: text/html; charset=UTF-8';
4562
+
4563
+ $header_string = implode( "\r\n", $headers );
4564
+
4565
+ return wp_mail(
4566
+ $to_address,
4567
+ $subject,
4568
+ $message,
4569
+ $header_string
4570
+ );
4571
+ }
4572
+
4573
+ /**
4574
+ * Generates the data for the sections of the email content.
4575
+ *
4576
+ * @author Leo Fajardo (@leorw)
4577
+ * @since 1.1.2
4578
+ *
4579
+ * @return array
4580
+ */
4581
+ private function get_email_sections() {
4582
+ // Retrieve the current user's information so that we can get the user's email, first name, and last name below.
4583
+ $current_user = self::_get_current_wp_user();
4584
+
4585
+ // Retrieve the cURL version information so that we can get the version number below.
4586
+ $curl_version_information = curl_version();
4587
+
4588
+ $active_plugin = self::get_active_plugins();
4589
+
4590
+ // Generate the list of active plugins separated by new line.
4591
+ $active_plugin_string = '';
4592
+ foreach ( $active_plugin as $plugin ) {
4593
+ $active_plugin_string .= sprintf(
4594
+ '<a href="%s">%s</a> [v%s]<br>',
4595
+ $plugin['PluginURI'],
4596
+ $plugin['Name'],
4597
+ $plugin['Version']
4598
+ );
4599
+ }
4600
+
4601
+ $server_ip = WP_FS__REMOTE_ADDR;
4602
+
4603
+ // Add PHP info for deeper investigation.
4604
+ ob_start();
4605
+ phpinfo();
4606
+ $php_info = ob_get_clean();
4607
+
4608
+ $api_domain = substr( FS_API__ADDRESS, strpos( FS_API__ADDRESS, ':' ) + 3 );
4609
+
4610
+ // Generate the default email sections.
4611
+ $sections = array(
4612
+ 'sdk' => array(
4613
+ 'title' => 'SDK',
4614
+ 'rows' => array(
4615
+ 'fs_version' => array( 'FS Version', $this->version ),
4616
+ 'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
4617
+ )
4618
+ ),
4619
+ 'plugin' => array(
4620
+ 'title' => ucfirst( $this->get_module_type() ),
4621
+ 'rows' => array(
4622
+ 'name' => array( 'Name', $this->get_plugin_name() ),
4623
+ 'version' => array( 'Version', $this->get_plugin_version() )
4624
+ )
4625
+ ),
4626
+ 'api' => array(
4627
+ 'title' => 'API Subdomain',
4628
+ 'rows' => array(
4629
+ 'dns' => array(
4630
+ 'DNS_CNAME',
4631
+ function_exists( 'dns_get_record' ) ?
4632
+ var_export( dns_get_record( $api_domain, DNS_CNAME ), true ) :
4633
+ 'dns_get_record() disabled/blocked'
4634
+ ),
4635
+ 'ip' => array(
4636
+ 'IP',
4637
+ function_exists( 'gethostbyname' ) ?
4638
+ gethostbyname( $api_domain ) :
4639
+ 'gethostbyname() disabled/blocked'
4640
+ ),
4641
+ ),
4642
+ ),
4643
+ 'site' => array(
4644
+ 'title' => 'Site',
4645
+ 'rows' => array(
4646
+ 'unique_id' => array( 'Unique ID', $this->get_anonymous_id() ),
4647
+ 'address' => array( 'Address', site_url() ),
4648
+ 'host' => array(
4649
+ 'HTTP_HOST',
4650
+ ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
4651
+ ),
4652
+ 'hosting' => array(
4653
+ 'Hosting Company' => fs_request_has( 'hosting_company' ) ?
4654
+ fs_request_get( 'hosting_company' ) :
4655
+ 'Unknown',
4656
+ ),
4657
+ 'server_addr' => array(
4658
+ 'SERVER_ADDR',
4659
+ '<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>'
4660
+ )
4661
+ )
4662
+ ),
4663
+ 'user' => array(
4664
+ 'title' => 'User',
4665
+ 'rows' => array(
4666
+ 'email' => array( 'Email', $current_user->user_email ),
4667
+ 'first' => array( 'First', $current_user->user_firstname ),
4668
+ 'last' => array( 'Last', $current_user->user_lastname )
4669
+ )
4670
+ ),
4671
+ 'plugins' => array(
4672
+ 'title' => 'Plugins',
4673
+ 'rows' => array(
4674
+ 'active_plugins' => array( 'Active Plugins', $active_plugin_string )
4675
+ )
4676
+ ),
4677
+ 'php_info' => array(
4678
+ 'title' => 'PHP Info',
4679
+ 'rows' => array(
4680
+ 'info' => array( $php_info )
4681
+ ),
4682
+ )
4683
+ );
4684
+
4685
+ // Allow the sections to be modified by other code.
4686
+ $sections = $this->apply_filters( 'email_template_sections', $sections );
4687
+
4688
+ return $sections;
4689
+ }
4690
+
4691
+ #endregion
4692
+
4693
+ #----------------------------------------------------------------------------------
4694
+ #region Initialization
4695
+ #----------------------------------------------------------------------------------
4696
+
4697
+ /**
4698
+ * Init plugin's Freemius instance.
4699
+ *
4700
+ * @author Vova Feldman (@svovaf)
4701
+ * @since 1.0.1
4702
+ *
4703
+ * @param number $id
4704
+ * @param string $public_key
4705
+ * @param bool $is_live
4706
+ * @param bool $is_premium
4707
+ */
4708
+ function init( $id, $public_key, $is_live = true, $is_premium = true ) {
4709
+ $this->_logger->entrance();
4710
+
4711
+ $this->dynamic_init( array(
4712
+ 'id' => $id,
4713
+ 'public_key' => $public_key,
4714
+ 'is_live' => $is_live,
4715
+ 'is_premium' => $is_premium,
4716
+ ) );
4717
+ }
4718
+
4719
+ /**
4720
+ * Dynamic initiator, originally created to support initiation
4721
+ * with parent_id for add-ons.
4722
+ *
4723
+ * @author Vova Feldman (@svovaf)
4724
+ * @since 1.0.6
4725
+ *
4726
+ * @param array $plugin_info
4727
+ *
4728
+ * @throws Freemius_Exception
4729
+ */
4730
+ function dynamic_init( array $plugin_info ) {
4731
+ $this->_logger->entrance();
4732
+
4733
+ $this->parse_settings( $plugin_info );
4734
+
4735
+ $this->register_after_settings_parse_hooks();
4736
+
4737
+ if ( $this->should_stop_execution() ) {
4738
+ return;
4739
+ }
4740
+
4741
+ if ( ! $this->is_registered() ) {
4742
+ if ( $this->is_anonymous() ) {
4743
+ // If user skipped, no need to test connectivity.
4744
+ $this->_has_api_connection = true;
4745
+ $this->_is_on = true;
4746
+ } else {
4747
+ if ( ! $this->has_api_connectivity() ) {
4748
+ if ( $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) ||
4749
+ $this->_admin_notices->has_sticky( 'failed_connect_api' )
4750
+ ) {
4751
+ if ( ! $this->_enable_anonymous || $this->is_premium() ) {
4752
+ // If anonymous mode is disabled, add firewall admin-notice message.
4753
+ add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
4754
+
4755
+ $ajax_action_suffix = $this->_slug . ( $this->is_theme() ? ':theme' : '' );
4756
+ add_action( "wp_ajax_fs_resolve_firewall_issues_{$ajax_action_suffix}", array(
4757
+ &$this,
4758
+ '_email_about_firewall_issue'
4759
+ ) );
4760
+
4761
+ add_action( "wp_ajax_fs_retry_connectivity_test_{$ajax_action_suffix}", array(
4762
+ &$this,
4763
+ '_retry_connectivity_test'
4764
+ ) );
4765
+
4766
+ /**
4767
+ * Currently the admin notice manager relies on the module's type and slug. The new AJAX actions manager uses module IDs, hence, consider to replace the if block above with the commented code below after adjusting the admin notices manager to work with module IDs.
4768
+ *
4769
+ * @author Vova Feldman (@svovaf)
4770
+ * @since 2.0.0
4771
+ */
4772
+ /*$this->add_ajax_action( 'resolve_firewall_issues', array(
4773
+ &$this,
4774
+ '_email_about_firewall_issue'
4775
+ ) );
4776
+
4777
+ $this->add_ajax_action( 'retry_connectivity_test', array(
4778
+ &$this,
4779
+ '_retry_connectivity_test'
4780
+ ) );*/
4781
+ }
4782
+ }
4783
+
4784
+ return;
4785
+ } else {
4786
+ $this->_admin_notices->remove_sticky( array(
4787
+ 'failed_connect_api_first',
4788
+ 'failed_connect_api',
4789
+ ) );
4790
+
4791
+ if ( $this->_anonymous_mode ) {
4792
+ // Simulate anonymous mode.
4793
+ $this->_is_anonymous = true;
4794
+ }
4795
+ }
4796
+ }
4797
+ }
4798
+
4799
+ /**
4800
+ * This should be executed even if Freemius is off for the core module,
4801
+ * otherwise, the add-ons dialogbox won't work properly. This is esepcially
4802
+ * relevant when the developer decided to turn FS off for existing users.
4803
+ *
4804
+ * @author Vova Feldman (@svovaf)
4805
+ */
4806
+ if ( $this->is_user_in_admin() &&
4807
+ 'plugin-information' === fs_request_get( 'tab', false ) &&
4808
+ $this->should_use_freemius_updater_and_dialog() &&
4809
+ (
4810
+ ( $this->is_addon() && $this->get_slug() == fs_request_get( 'plugin', false ) ) ||
4811
+ ( $this->has_addons() && $this->get_id() == fs_request_get( 'parent_plugin_id', false ) )
4812
+ )
4813
+ ) {
4814
+ require_once WP_FS__DIR_INCLUDES . '/fs-plugin-info-dialog.php';
4815
+
4816
+ new FS_Plugin_Info_Dialog( $this->is_addon() ? $this->get_parent_instance() : $this );
4817
+ }
4818
+
4819
+ // Check if Freemius is on for the current plugin.
4820
+ // This MUST be executed after all the plugin variables has been loaded.
4821
+ if ( ! $this->is_registered() && ! $this->is_on() ) {
4822
+ return;
4823
+ }
4824
+
4825
+ if ( $this->has_api_connectivity() ) {
4826
+ if ( self::is_cron() ) {
4827
+ $this->hook_callback_to_sync_cron();
4828
+ } else if ( $this->is_user_in_admin() ) {
4829
+ /**
4830
+ * Schedule daily data sync cron if:
4831
+ *
4832
+ * 1. User opted-in (for tracking).
4833
+ * 2. If skipped, but later upgraded (opted-in via upgrade).
4834
+ *
4835
+ * @author Vova Feldman (@svovaf)
4836
+ * @since 1.1.7.3
4837
+ *
4838
+ */
4839
+ if ( $this->is_registered() ) {
4840
+ if ( ! $this->is_sync_cron_on() && $this->is_tracking_allowed() ) {
4841
+ $this->schedule_sync_cron();
4842
+ }
4843
+ }
4844
+
4845
+ /**
4846
+ * Check if requested for manual blocking background sync.
4847
+ */
4848
+ if ( fs_request_has( 'background_sync' ) ) {
4849
+ $this->run_manual_sync();
4850
+ }
4851
+ }
4852
+ }
4853
+
4854
+ if ( $this->is_registered() ) {
4855
+ $this->hook_callback_to_install_sync();
4856
+ }
4857
+
4858
+ if ( $this->is_addon() ) {
4859
+ if ( $this->is_parent_plugin_installed() ) {
4860
+ // Link to parent FS.
4861
+ $this->_parent = self::get_instance_by_id( $this->_plugin->parent_plugin_id );
4862
+
4863
+ // Get parent plugin reference.
4864
+ $this->_parent_plugin = $this->_parent->get_plugin();
4865
+ }
4866
+ }
4867
+
4868
+ if ( $this->is_user_in_admin() ) {
4869
+ if ( $this->is_addon() ) {
4870
+ if ( ! $this->is_parent_plugin_installed() ) {
4871
+ $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
4872
+
4873
+ if ( isset( $plugin_info['parent'] ) ) {
4874
+ $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
4875
+ }
4876
+
4877
+ $this->_admin_notices->add(
4878
+ ( ! empty( $parent_name ) ?
4879
+ sprintf( $this->get_text_x_inline( '%s cannot run without %s.', 'addonX cannot run without pluginY', 'addon-x-cannot-run-without-y' ), $this->get_plugin_name(), $parent_name ) :
4880
+ sprintf( $this->get_text_x_inline( '%s cannot run without the plugin.', 'addonX cannot run...', 'addon-x-cannot-run-without-parent' ), $this->get_plugin_name() )
4881
+ ),
4882
+ $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
4883
+ 'error'
4884
+ );
4885
+
4886
+ return;
4887
+ } else {
4888
+ $is_network_admin = fs_is_network_admin();
4889
+
4890
+ if (
4891
+ $this->_parent->is_registered() &&
4892
+ ! $this->is_registered() &&
4893
+ $this->has_free_plan() &&
4894
+ /**
4895
+ * If not registered for add-on and the following conditions for the add-on are met, activate add-on account.
4896
+ * * Network active and in network admin - network activate add-on account.
4897
+ * * Network active and not in network admin - activate add-on account for the current blog.
4898
+ * * Not network active and not in network admin - activate add-on account for the current blog.
4899
+ *
4900
+ * If not registered for add-on, not network active, and in network admin, do not handle the add-on activation.
4901
+ *
4902
+ * @author Leo Fajardo (@leorw)
4903
+ * @since 2.3.0
4904
+ */
4905
+ ( $this->is_network_active() || ! $is_network_admin )
4906
+ ) {
4907
+ // If parent plugin activated, automatically install add-on for the user.
4908
+ $this->_activate_addon_account(
4909
+ $this->_parent,
4910
+ ( $this->is_network_active() && $is_network_admin ) ?
4911
+ true :
4912
+ get_current_blog_id()
4913
+ );
4914
+ } else if ( ! $this->_parent->is_registered() && $this->is_registered() ) {
4915
+ // If add-on activated and parent not, automatically install parent for the user.
4916
+ $this->activate_parent_account( $this->_parent );
4917
+ }
4918
+
4919
+ // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
4920
+ if ( $this->is_premium() ) {
4921
+ // Remove add-on download admin-notice.
4922
+ $this->_parent->_admin_notices->remove_sticky( array(
4923
+ 'addon_plan_upgraded_' . $this->_slug,
4924
+ 'no_addon_license_' . $this->_slug,
4925
+ ) );
4926
+ }
4927
+
4928
+ // $this->deactivate_premium_only_addon_without_license();
4929
+ }
4930
+ }
4931
+
4932
+ add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
4933
+
4934
+ // if ( $this->is_registered() ||
4935
+ // $this->is_anonymous() ||
4936
+ // $this->is_pending_activation()
4937
+ // ) {
4938
+ // $this->_init_admin();
4939
+ // }
4940
+ }
4941
+
4942
+ /**
4943
+ * Should be called outside `$this->is_user_in_admin()` scope
4944
+ * because the updater has some logic that needs to be executed
4945
+ * during AJAX calls.
4946
+ *
4947
+ * Currently we need to hook to the `http_request_host_is_external` filter.
4948
+ * In the future, there might be additional logic added.
4949
+ *
4950
+ * @author Vova Feldman
4951
+ * @since 1.2.1.6
4952
+ */
4953
+ if (
4954
+ $this->should_use_freemius_updater_and_dialog() &&
4955
+ (
4956
+ $this->is_premium() ||
4957
+ /**
4958
+ * If not premium but the premium version is installed, also instantiate the updater so that the
4959
+ * plugin information dialog of the premium version will have the information from the server.
4960
+ *
4961
+ * @author Leo Fajardo (@leorw)
4962
+ * @since 2.2.3
4963
+ */
4964
+ ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->premium_plugin_basename() ) ) )
4965
+ ) &&
4966
+ $this->has_release_on_freemius()
4967
+ ) {
4968
+ FS_Plugin_Updater::instance( $this );
4969
+ }
4970
+
4971
+ $this->do_action( 'initiated' );
4972
+
4973
+ if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
4974
+ if ( isset( $this->_storage->prev_is_premium ) ) {
4975
+ $this->apply_filters(
4976
+ 'after_code_type_change',
4977
+ // New code type.
4978
+ $this->_plugin->is_premium
4979
+ );
4980
+ } else {
4981
+ // Set for code type for the first time.
4982
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
4983
+ }
4984
+ }
4985
+
4986
+ if ( ! $this->is_addon() ) {
4987
+ if ( $this->is_registered() ) {
4988
+ // Fix for upgrade from versions < 1.0.9.
4989
+ if ( ! isset( $this->_storage->activation_timestamp ) ) {
4990
+ $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
4991
+ }
4992
+
4993
+ $this->do_action( 'after_init_plugin_registered' );
4994
+ } else if ( $this->is_anonymous() ) {
4995
+ $this->do_action( 'after_init_plugin_anonymous' );
4996
+ } else if ( $this->is_pending_activation() ) {
4997
+ $this->do_action( 'after_init_plugin_pending_activations' );
4998
+ }
4999
+ } else {
5000
+ if ( $this->is_registered() ) {
5001
+ $this->do_action( 'after_init_addon_registered' );
5002
+ } else if ( $this->is_anonymous() ) {
5003
+ $this->do_action( 'after_init_addon_anonymous' );
5004
+ } else if ( $this->is_pending_activation() ) {
5005
+ $this->do_action( 'after_init_addon_pending_activations' );
5006
+ }
5007
+ }
5008
+ }
5009
+
5010
+ /**
5011
+ * @author Leo Fajardo (@leorw)
5012
+ * @since 2.2.3
5013
+ *
5014
+ * @return bool
5015
+ */
5016
+ private function should_use_freemius_updater_and_dialog() {
5017
+ return (
5018
+ /**
5019
+ * Allow updater and dialog when the `fs_allow_updater_and_dialog` URL query param exists and has `true`
5020
+ * value, or when the current page is not the "Add Plugins" page (/plugin-install.php) and the `action`
5021
+ * URL query param doesn't exist or its value is not `install-plugin` so that there will be no conflicts
5022
+ * with the .org plugins' functionalities (e.g. installation from the "Add Plugins" page and viewing
5023
+ * plugin details from .org).
5024
+ */
5025
+ ( true === fs_request_get_bool( 'fs_allow_updater_and_dialog' ) ) ||
5026
+ (
5027
+ ! self::is_plugin_install_page() &&
5028
+ // Disallow updater and dialog when installing a plugin, otherwise .org "add-on" plugins will be affected.
5029
+ ( 'install-plugin' !== fs_request_get( 'action' ) )
5030
+ )
5031
+ );
5032
+ }
5033
+
5034
+ /**
5035
+ * @author Leo Fajardo (@leorw)
5036
+ *
5037
+ * @since 1.2.1.5
5038
+ */
5039
+ function _stop_tracking_callback() {
5040
+ $this->_logger->entrance();
5041
+
5042
+ $this->check_ajax_referer( 'stop_tracking' );
5043
+
5044
+ $result = $this->stop_tracking( fs_is_network_admin() );
5045
+
5046
+ if ( true === $result ) {
5047
+ self::shoot_ajax_success();
5048
+ }
5049
+
5050
+ $this->_logger->api_error( $result );
5051
+
5052
+ self::shoot_ajax_failure(
5053
+ sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
5054
+ ( $this->is_api_error( $result ) && isset( $result->error ) ?
5055
+ $result->error->message :
5056
+ var_export( $result, true ) )
5057
+ );
5058
+ }
5059
+
5060
+ /**
5061
+ * @author Leo Fajardo (@leorw)
5062
+ * @since 1.2.1.5
5063
+ */
5064
+ function _allow_tracking_callback() {
5065
+ $this->_logger->entrance();
5066
+
5067
+ $this->check_ajax_referer( 'allow_tracking' );
5068
+
5069
+ $result = $this->allow_tracking( fs_is_network_admin() );
5070
+
5071
+ if ( true === $result ) {
5072
+ self::shoot_ajax_success();
5073
+ }
5074
+
5075
+ $this->_logger->api_error( $result );
5076
+
5077
+ self::shoot_ajax_failure(
5078
+ sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
5079
+ ( $this->is_api_error( $result ) && isset( $result->error ) ?
5080
+ $result->error->message :
5081
+ var_export( $result, true ) )
5082
+ );
5083
+ }
5084
+
5085
+ /**
5086
+ * Opt-out from usage tracking.
5087
+ *
5088
+ * Note: This will not delete the account information but will stop all tracking.
5089
+ *
5090
+ * Returns:
5091
+ * 1. FALSE - If the user never opted-in.
5092
+ * 2. TRUE - If successfully opted-out.
5093
+ * 3. object - API result on failure.
5094
+ *
5095
+ * @author Leo Fajardo (@leorw)
5096
+ * @since 1.2.1.5
5097
+ *
5098
+ * @return bool|object
5099
+ */
5100
+ function stop_site_tracking() {
5101
+ $this->_logger->entrance();
5102
+
5103
+ if ( ! $this->is_registered() ) {
5104
+ // User never opted-in.
5105
+ return false;
5106
+ }
5107
+
5108
+ if ( $this->is_tracking_prohibited() ) {
5109
+ // Already disconnected.
5110
+ return true;
5111
+ }
5112
+
5113
+ // Send update to FS.
5114
+ $result = $this->get_api_site_scope()->call( '/?fields=is_disconnected', 'put', array(
5115
+ 'is_disconnected' => true
5116
+ ) );
5117
+
5118
+ if ( ! $this->is_api_result_entity( $result ) ||
5119
+ ! isset( $result->is_disconnected ) ||
5120
+ ! $result->is_disconnected
5121
+ ) {
5122
+ $this->_logger->api_error( $result );
5123
+
5124
+ return $result;
5125
+ }
5126
+
5127
+ $this->_site->is_disconnected = $result->is_disconnected;
5128
+ $this->_store_site();
5129
+
5130
+ $this->clear_sync_cron();
5131
+
5132
+ // Successfully disconnected.
5133
+ return true;
5134
+ }
5135
+
5136
+ /**
5137
+ * Opt-out network from usage tracking.
5138
+ *
5139
+ * Note: This will not delete the account information but will stop all tracking.
5140
+ *
5141
+ * Returns:
5142
+ * 1. FALSE - If the user never opted-in.
5143
+ * 2. TRUE - If successfully opted-out.
5144
+ * 3. object - API result on failure.
5145
+ *
5146
+ * @author Leo Fajardo (@leorw)
5147
+ * @since 1.2.1.5
5148
+ *
5149
+ * @return bool|object
5150
+ */
5151
+ function stop_network_tracking() {
5152
+ $this->_logger->entrance();
5153
+
5154
+ if ( ! $this->is_registered() ) {
5155
+ // User never opted-in.
5156
+ return false;
5157
+ }
5158
+
5159
+ $install_id_2_blog_id = array();
5160
+ $installs_map = $this->get_blog_install_map();
5161
+
5162
+ $opt_out_all = true;
5163
+
5164
+ $params = array();
5165
+ foreach ( $installs_map as $blog_id => $install ) {
5166
+ if ( $install->is_tracking_prohibited() ) {
5167
+ // Already opted-out.
5168
+ continue;
5169
+ }
5170
+
5171
+ if ( $this->is_site_delegated_connection( $blog_id ) ) {
5172
+ // Opt-out only from non-delegated installs.
5173
+ $opt_out_all = false;
5174
+ continue;
5175
+ }
5176
+
5177
+ $params[] = array( 'id' => $install->id );
5178
+
5179
+ $install_id_2_blog_id[ $install->id ] = $blog_id;
5180
+ }
5181
+
5182
+ if ( empty( $install_id_2_blog_id ) ) {
5183
+ return true;
5184
+ }
5185
+
5186
+ $params[] = array( 'is_disconnected' => true );
5187
+
5188
+ // Send update to FS.
5189
+ $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params );
5190
+
5191
+ if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
5192
+ $this->_logger->api_error( $result );
5193
+
5194
+ return $result;
5195
+ }
5196
+
5197
+ foreach ( $result->installs as $r_install ) {
5198
+ $blog_id = $install_id_2_blog_id[ $r_install->id ];
5199
+ $install = $installs_map[ $blog_id ];
5200
+ $install->is_disconnected = $r_install->is_disconnected;
5201
+ $this->_store_site( true, $blog_id, $install );
5202
+ }
5203
+
5204
+ $this->clear_sync_cron( $opt_out_all );
5205
+
5206
+ // Successfully disconnected.
5207
+ return true;
5208
+ }
5209
+
5210
+ /**
5211
+ * Opt-out from usage tracking.
5212
+ *
5213
+ * Note: This will not delete the account information but will stop all tracking.
5214
+ *
5215
+ * Returns:
5216
+ * 1. FALSE - If the user never opted-in.
5217
+ * 2. TRUE - If successfully opted-out.
5218
+ * 3. object - API result on failure.
5219
+ *
5220
+ * @author Leo Fajardo (@leorw)
5221
+ * @since 1.2.1.5
5222
+ *
5223
+ * @param bool $is_network_action
5224
+ *
5225
+ * @return bool|object
5226
+ */
5227
+ function stop_tracking( $is_network_action = false ) {
5228
+ $this->_logger->entrance();
5229
+
5230
+ return $is_network_action ?
5231
+ $this->stop_network_tracking() :
5232
+ $this->stop_site_tracking();
5233
+ }
5234
+
5235
+ /**
5236
+ * Opt-in back into usage tracking.
5237
+ *
5238
+ * Note: This will only work if the user opted-in previously.
5239
+ *
5240
+ * Returns:
5241
+ * 1. FALSE - If the user never opted-in.
5242
+ * 2. TRUE - If successfully opted-in back to usage tracking.
5243
+ * 3. object - API result on failure.
5244
+ *
5245
+ * @author Leo Fajardo (@leorw)
5246
+ * @since 1.2.1.5
5247
+ *
5248
+ * @return bool|object
5249
+ */
5250
+ function allow_site_tracking() {
5251
+ $this->_logger->entrance();
5252
+
5253
+ if ( ! $this->is_registered() ) {
5254
+ // User never opted-in.
5255
+ return false;
5256
+ }
5257
+
5258
+ if ( $this->is_tracking_allowed() ) {
5259
+ // Tracking already allowed.
5260
+ return true;
5261
+ }
5262
+
5263
+ $result = $this->get_api_site_scope()->call( '/?is_disconnected', 'put', array(
5264
+ 'is_disconnected' => false
5265
+ ) );
5266
+
5267
+ if ( ! $this->is_api_result_entity( $result ) ||
5268
+ ! isset( $result->is_disconnected ) ||
5269
+ $result->is_disconnected
5270
+ ) {
5271
+ $this->_logger->api_error( $result );
5272
+
5273
+ return $result;
5274
+ }
5275
+
5276
+ $this->_site->is_disconnected = $result->is_disconnected;
5277
+ $this->_store_site();
5278
+
5279
+ $this->schedule_sync_cron();
5280
+
5281
+ // Successfully reconnected.
5282
+ return true;
5283
+ }
5284
+
5285
+ /**
5286
+ * Opt-in network back into usage tracking.
5287
+ *
5288
+ * Note: This will only work if the user opted-in previously.
5289
+ *
5290
+ * Returns:
5291
+ * 1. FALSE - If the user never opted-in.
5292
+ * 2. TRUE - If successfully opted-in back to usage tracking.
5293
+ * 3. object - API result on failure.
5294
+ *
5295
+ * @author Leo Fajardo (@leorw)
5296
+ * @since 1.2.1.5
5297
+ *
5298
+ * @return bool|object
5299
+ */
5300
+ function allow_network_tracking() {
5301
+ $this->_logger->entrance();
5302
+
5303
+ if ( ! $this->is_registered() ) {
5304
+ // User never opted-in.
5305
+ return false;
5306
+ }
5307
+
5308
+ $install_id_2_blog_id = array();
5309
+ $installs_map = $this->get_blog_install_map();
5310
+
5311
+ $params = array();
5312
+ foreach ( $installs_map as $blog_id => $install ) {
5313
+ if ( $install->is_tracking_allowed() ) {
5314
+ continue;
5315
+ }
5316
+
5317
+ $params[] = array( 'id' => $install->id );
5318
+
5319
+ $install_id_2_blog_id[ $install->id ] = $blog_id;
5320
+ }
5321
+
5322
+ if ( empty( $install_id_2_blog_id ) ) {
5323
+ return true;
5324
+ }
5325
+
5326
+ $params[] = array( 'is_disconnected' => false );
5327
+
5328
+ // Send update to FS.
5329
+ $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params );
5330
+
5331
+
5332
+ if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
5333
+ $this->_logger->api_error( $result );
5334
+
5335
+ return $result;
5336
+ }
5337
+
5338
+ foreach ( $result->installs as $r_install ) {
5339
+ $blog_id = $install_id_2_blog_id[ $r_install->id ];
5340
+ $install = $installs_map[ $blog_id ];
5341
+ $install->is_disconnected = $r_install->is_disconnected;
5342
+ $this->_store_site( true, $blog_id, $install );
5343
+ }
5344
+
5345
+ $this->schedule_sync_cron();
5346
+
5347
+ // Successfully reconnected.
5348
+ return true;
5349
+ }
5350
+
5351
+ /**
5352
+ * Opt-in back into usage tracking.
5353
+ *
5354
+ * Note: This will only work if the user opted-in previously.
5355
+ *
5356
+ * Returns:
5357
+ * 1. FALSE - If the user never opted-in.
5358
+ * 2. TRUE - If successfully opted-in back to usage tracking.
5359
+ * 3. object - API result on failure.
5360
+ *
5361
+ * @author Leo Fajardo (@leorw)
5362
+ * @since 1.2.1.5
5363
+ *
5364
+ * @param bool $is_network_action
5365
+ *
5366
+ * @return bool|object
5367
+ */
5368
+ function allow_tracking( $is_network_action = false ) {
5369
+ $this->_logger->entrance();
5370
+
5371
+ return $is_network_action ?
5372
+ $this->allow_network_tracking() :
5373
+ $this->allow_site_tracking();
5374
+ }
5375
+
5376
+ /**
5377
+ * If user opted-in and later disabled usage-tracking,
5378
+ * re-allow tracking for licensing and updates.
5379
+ *
5380
+ * @author Leo Fajardo (@leorw)
5381
+ * @since 1.2.1.5
5382
+ *
5383
+ * @param bool $is_context_single_site
5384
+ */
5385
+ private function reconnect_locally( $is_context_single_site = false ) {
5386
+ $this->_logger->entrance();
5387
+
5388
+ if ( ! $this->is_registered() ) {
5389
+ return;
5390
+ }
5391
+
5392
+ if ( ! fs_is_network_admin() || $is_context_single_site ) {
5393
+ if ( $this->is_tracking_prohibited() ) {
5394
+ $this->_site->is_disconnected = false;
5395
+ $this->_store_site();
5396
+ }
5397
+ } else {
5398
+ $installs_map = $this->get_blog_install_map();
5399
+ foreach ( $installs_map as $blog_id => $install ) {
5400
+ /**
5401
+ * @var FS_Site $install
5402
+ */
5403
+ if ( $install->is_tracking_prohibited() ) {
5404
+ $install->is_disconnected = false;
5405
+ $this->_store_site( true, $blog_id, $install );
5406
+ }
5407
+ }
5408
+ }
5409
+ }
5410
+
5411
+ /**
5412
+ * @author Vova Feldman (@svovaf)
5413
+ * @since 2.3.2
5414
+ *
5415
+ * @return bool
5416
+ */
5417
+ function is_extensions_tracking_allowed() {
5418
+ return (true === $this->_storage->get( 'is_extensions_tracking_allowed', true ) );
5419
+ }
5420
+
5421
+ /**
5422
+ * @author Vova Feldman (@svovaf)
5423
+ * @since 2.3.2
5424
+ */
5425
+ function _update_tracking_permission_callback() {
5426
+ $this->_logger->entrance();
5427
+
5428
+ $this->check_ajax_referer( 'update_tracking_permission' );
5429
+
5430
+ $is_enabled = fs_request_get_bool( 'is_enabled', null );
5431
+
5432
+ if ( ! is_bool( $is_enabled ) ) {
5433
+ self::shoot_ajax_failure();
5434
+ }
5435
+
5436
+ $permission = fs_request_get( 'permission' );
5437
+
5438
+ switch ( $permission ) {
5439
+ case 'extensions':
5440
+ $this->update_extensions_tracking_flag( $is_enabled );
5441
+ break;
5442
+ default:
5443
+ $permission = 'no_match';
5444
+ }
5445
+
5446
+ if ( 'no_match' === $permission ) {
5447
+ self::shoot_ajax_failure();
5448
+ }
5449
+
5450
+ self::shoot_ajax_success( array(
5451
+ 'permissions' => array(
5452
+ $permission => $is_enabled,
5453
+ )
5454
+ ) );
5455
+ }
5456
+
5457
+ /**
5458
+ * @author Leo Fajardo (@leorw)
5459
+ * @since 2.3.2
5460
+ *
5461
+ * @param bool $is_enabled
5462
+ */
5463
+ private function update_extensions_tracking_flag( $is_enabled ) {
5464
+ $this->_storage->store( 'is_extensions_tracking_allowed', $is_enabled );
5465
+ }
5466
+
5467
+ /**
5468
+ * Parse plugin's settings (as defined by the plugin dev).
5469
+ *
5470
+ * @author Vova Feldman (@svovaf)
5471
+ * @since 1.1.7.3
5472
+ *
5473
+ * @param array $plugin_info
5474
+ *
5475
+ * @throws \Freemius_Exception
5476
+ */
5477
+ private function parse_settings( &$plugin_info ) {
5478
+ $this->_logger->entrance();
5479
+
5480
+ $id = $this->get_numeric_option( $plugin_info, 'id', false );
5481
+ $public_key = $this->get_option( $plugin_info, 'public_key', false );
5482
+ $secret_key = $this->get_option( $plugin_info, 'secret_key', null );
5483
+ $parent_id = $this->get_numeric_option( $plugin_info, 'parent_id', null );
5484
+ $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
5485
+
5486
+ /**
5487
+ * @author Vova Feldman (@svovaf)
5488
+ * @since 1.1.9 Try to pull secret key from external config.
5489
+ */
5490
+ if ( is_null( $secret_key ) && defined( "WP_FS__{$this->_slug}_SECRET_KEY" ) ) {
5491
+ $secret_key = constant( "WP_FS__{$this->_slug}_SECRET_KEY" );
5492
+ }
5493
+
5494
+ if ( isset( $plugin_info['parent'] ) ) {
5495
+ $parent_id = $this->get_numeric_option( $plugin_info['parent'], 'id', null );
5496
+ // $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
5497
+ // $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
5498
+ // $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
5499
+ }
5500
+
5501
+ if ( false === $id ) {
5502
+ throw new Freemius_Exception( array(
5503
+ 'error' => array(
5504
+ 'type' => 'ParameterNotSet',
5505
+ 'message' => 'Plugin id parameter is not set.',
5506
+ 'code' => 'plugin_id_not_set',
5507
+ 'http' => 500,
5508
+ )
5509
+ ) );
5510
+ }
5511
+ if ( false === $public_key ) {
5512
+ throw new Freemius_Exception( array(
5513
+ 'error' => array(
5514
+ 'type' => 'ParameterNotSet',
5515
+ 'message' => 'Plugin public_key parameter is not set.',
5516
+ 'code' => 'plugin_public_key_not_set',
5517
+ 'http' => 500,
5518
+ )
5519
+ ) );
5520
+ }
5521
+
5522
+ $plugin = ( $this->_plugin instanceof FS_Plugin ) ?
5523
+ $this->_plugin :
5524
+ new FS_Plugin();
5525
+
5526
+ $premium_suffix = $this->get_option( $plugin_info, 'premium_suffix', '(Premium)' );
5527
+
5528
+ $plugin->update( array(
5529
+ 'id' => $id,
5530
+ 'type' => $this->get_option( $plugin_info, 'type', $this->_module_type ),
5531
+ 'public_key' => $public_key,
5532
+ 'slug' => $this->_slug,
5533
+ 'premium_slug' => $this->get_option( $plugin_info, 'premium_slug', "{$this->_slug}-premium" ),
5534
+ 'parent_plugin_id' => $parent_id,
5535
+ 'version' => $this->get_plugin_version(),
5536
+ 'title' => $this->get_plugin_name( $premium_suffix ),
5537
+ 'file' => $this->_plugin_basename,
5538
+ 'is_premium' => $this->get_bool_option( $plugin_info, 'is_premium', true ),
5539
+ 'premium_suffix' => $premium_suffix,
5540
+ 'is_live' => $this->get_bool_option( $plugin_info, 'is_live', true ),
5541
+ 'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ),
5542
+ 'bundle_id' => $this->get_option( $plugin_info, 'bundle_id', null ),
5543
+ 'bundle_public_key' => $this->get_option( $plugin_info, 'bundle_public_key', null ),
5544
+ ) );
5545
+
5546
+ if ( $plugin->is_updated() ) {
5547
+ // Update plugin details.
5548
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->store( $plugin );
5549
+ }
5550
+ // Set the secret key after storing the plugin, we don't want to store the key in the storage.
5551
+ $this->_plugin->secret_key = $secret_key;
5552
+
5553
+ /**
5554
+ * If the product is network integrated and activated and the current view is in the network level Admin dashboard, if the product's network-level menu located differently from the sub-site level, then use the network menu details (when set).
5555
+ *
5556
+ * @author Vova Feldman
5557
+ * @since 2.4.5
5558
+ */
5559
+ if ( $this->is_network_active() && fs_is_network_admin() ) {
5560
+ if ( isset( $plugin_info['menu_network'] ) &&
5561
+ is_array( $plugin_info['menu_network'] ) &&
5562
+ ! empty( $plugin_info['menu_network'] )
5563
+ ) {
5564
+ $plugin_info['menu'] = $plugin_info['menu_network'];
5565
+ }
5566
+ }
5567
+
5568
+ if ( ! isset( $plugin_info['menu'] ) ) {
5569
+ $plugin_info['menu'] = array();
5570
+
5571
+ if ( ! empty( $this->_storage->sdk_last_version ) &&
5572
+ version_compare( $this->_storage->sdk_last_version, '1.1.2', '<=' )
5573
+ ) {
5574
+ // Backward compatibility to 1.1.2
5575
+ $plugin_info['menu']['slug'] = isset( $plugin_info['menu_slug'] ) ?
5576
+ $plugin_info['menu_slug'] :
5577
+ $this->_slug;
5578
+ }
5579
+ }
5580
+
5581
+ $this->_menu = FS_Admin_Menu_Manager::instance(
5582
+ $this->_module_id,
5583
+ $this->_module_type,
5584
+ $this->get_unique_affix()
5585
+ );
5586
+
5587
+ $this->_menu->init( $plugin_info['menu'], $this->is_addon() );
5588
+
5589
+ $this->_has_addons = $this->get_bool_option( $plugin_info, 'has_addons', false );
5590
+ $this->_has_paid_plans = $this->get_bool_option( $plugin_info, 'has_paid_plans', true );
5591
+ $this->_has_premium_version = $this->get_bool_option( $plugin_info, 'has_premium_version', $this->_has_paid_plans );
5592
+ $this->_ignore_pending_mode = $this->get_bool_option( $plugin_info, 'ignore_pending_mode', false );
5593
+ $this->_is_org_compliant = $this->get_bool_option( $plugin_info, 'is_org_compliant', true );
5594
+ $this->_is_premium_only = $this->get_bool_option( $plugin_info, 'is_premium_only', false );
5595
+ if ( $this->_is_premium_only ) {
5596
+ // If premium only plugin, disable anonymous mode.
5597
+ $this->_enable_anonymous = false;
5598
+ $this->_anonymous_mode = false;
5599
+ } else {
5600
+ $this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
5601
+ $this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
5602
+ }
5603
+ $this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
5604
+
5605
+ if ( ! empty( $plugin_info['trial'] ) ) {
5606
+ $this->_trial_days = $this->get_numeric_option(
5607
+ $plugin_info['trial'],
5608
+ 'days',
5609
+ // Default to 0 - trial without days specification.
5610
+ 0
5611
+ );
5612
+
5613
+ $this->_is_trial_require_payment = $this->get_bool_option( $plugin_info['trial'], 'is_require_payment', false );
5614
+ }
5615
+
5616
+ $this->_navigation = $this->get_option(
5617
+ $plugin_info,
5618
+ 'navigation',
5619
+ $this->is_free_wp_org_theme() ?
5620
+ self::NAVIGATION_TABS :
5621
+ self::NAVIGATION_MENU
5622
+ );
5623
+ }
5624
+
5625
+ /**
5626
+ * @param string[] $options
5627
+ * @param string $key
5628
+ * @param mixed $default
5629
+ *
5630
+ * @return bool
5631
+ */
5632
+ private function get_option( &$options, $key, $default = false ) {
5633
+ return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
5634
+ }
5635
+
5636
+ private function get_bool_option( &$options, $key, $default = false ) {
5637
+ return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
5638
+ }
5639
+
5640
+ private function get_numeric_option( &$options, $key, $default = false ) {
5641
+ return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
5642
+ }
5643
+
5644
+ /**
5645
+ * Gate keeper.
5646
+ *
5647
+ * @author Vova Feldman (@svovaf)
5648
+ * @since 1.1.7.3
5649
+ *
5650
+ * @return bool
5651
+ */
5652
+ private function should_stop_execution() {
5653
+ if ( empty( $this->_storage->was_plugin_loaded ) ) {
5654
+ /**
5655
+ * Don't execute Freemius until plugin was fully loaded at least once,
5656
+ * to give the opportunity for the activation hook to run before pinging
5657
+ * the API for connectivity test. This logic is relevant for the
5658
+ * identification of new plugin install vs. plugin update.
5659
+ *
5660
+ * @author Vova Feldman (@svovaf)
5661
+ * @since 1.1.9
5662
+ */
5663
+ return true;
5664
+ }
5665
+
5666
+ if ( $this->is_activation_mode() ) {
5667
+ if ( ! is_admin() ) {
5668
+ /**
5669
+ * If in activation mode, don't execute Freemius outside of the
5670
+ * admin dashboard.
5671
+ *
5672
+ * @author Vova Feldman (@svovaf)
5673
+ * @since 1.1.7.3
5674
+ */
5675
+ return true;
5676
+ }
5677
+
5678
+ if ( ! WP_FS__IS_HTTP_REQUEST ) {
5679
+ /**
5680
+ * If in activation and executed without HTTP context (e.g. CLI, Cronjob),
5681
+ * then don't start Freemius.
5682
+ *
5683
+ * @author Vova Feldman (@svovaf)
5684
+ * @since 1.1.6.3
5685
+ *
5686
+ * @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli
5687
+ */
5688
+ return true;
5689
+ }
5690
+
5691
+ if ( self::is_cron() ) {
5692
+ /**
5693
+ * If in activation mode, don't execute Freemius during wp crons
5694
+ * (wp crons have HTTP context - called as HTTP request).
5695
+ *
5696
+ * @author Vova Feldman (@svovaf)
5697
+ * @since 1.1.7.3
5698
+ */
5699
+ return true;
5700
+ }
5701
+
5702
+ if ( self::is_ajax() &&
5703
+ ! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) &&
5704
+ ! $this->_admin_notices->has_sticky( 'failed_connect_api' )
5705
+ ) {
5706
+ /**
5707
+ * During activation, if running in AJAX mode, unless there's a sticky
5708
+ * connectivity issue notice, don't run Freemius.
5709
+ *
5710
+ * @author Vova Feldman (@svovaf)
5711
+ * @since 1.1.7.3
5712
+ */
5713
+ return true;
5714
+ }
5715
+ }
5716
+
5717
+ return false;
5718
+ }
5719
+
5720
+ /**
5721
+ * Triggered after code type has changed.
5722
+ *
5723
+ * @author Vova Feldman (@svovaf)
5724
+ * @since 1.1.9.1
5725
+ */
5726
+ function _after_code_type_change() {
5727
+ $this->_logger->entrance();
5728
+
5729
+ if ( $this->is_theme() ) {
5730
+ // Expire the cache of the previous tabs since the theme may
5731
+ // have setting updates after code type has changed.
5732
+ $this->_cache->expire( 'tabs' );
5733
+ $this->_cache->expire( 'tabs_stylesheets' );
5734
+ }
5735
+
5736
+ if ( $this->is_registered() ) {
5737
+ if ( ! $this->is_addon() ) {
5738
+ add_action(
5739
+ is_admin() ? 'admin_init' : 'init',
5740
+ array( &$this, '_plugin_code_type_changed' )
5741
+ );
5742
+ }
5743
+
5744
+ if ( $this->is_premium() ) {
5745
+ // Purge cached payments after switching to the premium version.
5746
+ // @todo This logic doesn't handle purging the cache for serviceware module upgrade.
5747
+ $this->get_api_user_scope()->purge_cache( "/plugins/{$this->_module_id}/payments.json?include_addons=true" );
5748
+ }
5749
+ }
5750
+ }
5751
+
5752
+ /**
5753
+ * Handles plugin's code type change (free <--> premium).
5754
+ *
5755
+ * @author Vova Feldman (@svovaf)
5756
+ * @since 1.0.9
5757
+ */
5758
+ function _plugin_code_type_changed() {
5759
+ $this->_logger->entrance();
5760
+
5761
+ if ( $this->is_premium() ) {
5762
+ $this->reconnect_locally();
5763
+
5764
+ // Activated premium code.
5765
+ $this->do_action( 'after_premium_version_activation' );
5766
+
5767
+ // Remove all sticky messages related to download of the premium version.
5768
+ $this->_admin_notices->remove_sticky( array(
5769
+ 'trial_started',
5770
+ 'plan_upgraded',
5771
+ 'plan_changed',
5772
+ 'license_activated',
5773
+ ) );
5774
+
5775
+ $notice = '';
5776
+ if ( ! $this->is_only_premium() ) {
5777
+ $notice = sprintf( $this->get_text_inline( 'Premium %s version was successfully activated.', 'premium-activated-message' ), $this->_module_type );
5778
+ }
5779
+
5780
+ $license_notice = $this->get_license_network_activation_notice();
5781
+ if ( ! empty( $license_notice ) ) {
5782
+ $notice .= ' ' . $license_notice;
5783
+ }
5784
+
5785
+ if ( ! empty( $notice ) ) {
5786
+ $this->_admin_notices->add_sticky(
5787
+ trim( $notice ),
5788
+ 'premium_activated',
5789
+ $this->get_text_x_inline( 'W00t',
5790
+ 'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
5791
+ );
5792
+ }
5793
+ } else {
5794
+ // Remove sticky message related to premium code activation.
5795
+ $this->_admin_notices->remove_sticky( 'premium_activated' );
5796
+
5797
+ // Activated free code (after had the premium before).
5798
+ $this->do_action( 'after_free_version_reactivation' );
5799
+
5800
+ if ( $this->is_paying() && ! $this->is_premium() ) {
5801
+ $this->_admin_notices->add_sticky(
5802
+ sprintf(
5803
+ /* translators: %s: License type (e.g. you have a professional license) */
5804
+ $this->get_text_inline( 'You have a %s license.', 'you-have-x-license' ),
5805
+ $this->get_plan_title()
5806
+ ) . $this->get_complete_upgrade_instructions(),
5807
+ 'plan_upgraded',
5808
+ $this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
5809
+ );
5810
+ }
5811
+ }
5812
+
5813
+ // Schedule code type changes event.
5814
+ $this->schedule_install_sync();
5815
+
5816
+ /**
5817
+ * Unregister the uninstall hook for the other version of the plugin (with different code type) to avoid
5818
+ * triggering a fatal error when uninstalling that plugin. For example, after deactivating the "free" version
5819
+ * of a specific plugin, its uninstall hook should be unregistered after the "premium" version has been
5820
+ * activated. If we don't do that, a fatal error will occur when we try to uninstall the "free" version since
5821
+ * the main file of the "free" version will be loaded first before calling the hooked callback. Since the
5822
+ * free and premium versions are almost identical (same class or have same functions), a fatal error like
5823
+ * "Cannot redeclare class MyClass" or "Cannot redeclare my_function()" will occur.
5824
+ */
5825
+ $this->unregister_uninstall_hook();
5826
+
5827
+ $this->clear_module_main_file_cache();
5828
+
5829
+ // Update is_premium of latest version.
5830
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
5831
+ }
5832
+
5833
+ #endregion
5834
+
5835
+ #----------------------------------------------------------------------------------
5836
+ #region Add-ons
5837
+ #----------------------------------------------------------------------------------
5838
+
5839
+ /**
5840
+ * Check if add-on installed and activated on site.
5841
+ *
5842
+ * @author Vova Feldman (@svovaf)
5843
+ * @since 1.0.6
5844
+ *
5845
+ * @param string|number $id_or_slug
5846
+ * @param bool|null $is_premium Since 1.2.1.7 can check for specified add-on version.
5847
+ *
5848
+ * @return bool
5849
+ */
5850
+ function is_addon_activated( $id_or_slug, $is_premium = null ) {
5851
+ $this->_logger->entrance();
5852
+
5853
+ $addon_id = self::get_module_id( $id_or_slug );
5854
+ $is_activated = self::has_instance( $addon_id );
5855
+
5856
+ if ( ! $is_activated ) {
5857
+ return false;
5858
+ }
5859
+
5860
+ if ( is_bool( $is_premium ) ) {
5861
+ // Check if the specified code version is activate.
5862
+ $addon = $this->get_addon_instance( $addon_id );
5863
+ $is_activated = ( $is_premium === $addon->is_premium() );
5864
+ }
5865
+
5866
+ return $is_activated;
5867
+ }
5868
+
5869
+ /**
5870
+ * Check if add-on was connected to install
5871
+ *
5872
+ * @author Vova Feldman (@svovaf)
5873
+ * @since 1.1.7
5874
+ *
5875
+ * @param string|number $id_or_slug
5876
+ *
5877
+ * @return bool
5878
+ */
5879
+ function is_addon_connected( $id_or_slug ) {
5880
+ $this->_logger->entrance();
5881
+
5882
+ $sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );
5883
+
5884
+ $addon_id = self::get_module_id( $id_or_slug );
5885
+ $addon = $this->get_addon( $addon_id );
5886
+ $slug = $addon->slug;
5887
+ if ( ! isset( $sites[ $slug ] ) ) {
5888
+ return false;
5889
+ }
5890
+
5891
+ $site = $sites[ $slug ];
5892
+
5893
+ $plugin = FS_Plugin_Manager::instance( $addon_id )->get();
5894
+
5895
+ if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
5896
+ // The given slug do NOT belong to any of the plugin's add-ons.
5897
+ return false;
5898
+ }
5899
+
5900
+ return ( is_object( $site ) &&
5901
+ is_numeric( $site->id ) &&
5902
+ is_numeric( $site->user_id ) &&
5903
+ FS_Plugin_Plan::is_valid_id( $site->plan_id )
5904
+ );
5905
+ }
5906
+
5907
+ /**
5908
+ * Determines if add-on installed.
5909
+ *
5910
+ * NOTE: This is a heuristic and only works if the folder/file named as the slug.
5911
+ *
5912
+ * @author Vova Feldman (@svovaf)
5913
+ * @since 1.0.6
5914
+ *
5915
+ * @param string|number $id_or_slug
5916
+ *
5917
+ * @return bool
5918
+ */
5919
+ function is_addon_installed( $id_or_slug ) {
5920
+ $this->_logger->entrance();
5921
+
5922
+ $addon_id = self::get_module_id( $id_or_slug );
5923
+
5924
+ return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $addon_id ) ) );
5925
+ }
5926
+
5927
+ /**
5928
+ * Get add-on basename.
5929
+ *
5930
+ * @author Vova Feldman (@svovaf)
5931
+ * @since 1.0.6
5932
+ *
5933
+ * @param string|number $id_or_slug
5934
+ *
5935
+ * @return string
5936
+ */
5937
+ function get_addon_basename( $id_or_slug ) {
5938
+ $addon_id = self::get_module_id( $id_or_slug );
5939
+
5940
+ if ( $this->is_addon_activated( $addon_id ) ) {
5941
+ return self::instance( $addon_id )->get_plugin_basename();
5942
+ }
5943
+
5944
+ $addon = $this->get_addon( $addon_id );
5945
+ $premium_basename = "{$addon->premium_slug}/{$addon->slug}.php";
5946
+
5947
+ if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) {
5948
+ return $premium_basename;
5949
+ }
5950
+
5951
+ $all_plugins = $this->get_all_plugins();
5952
+
5953
+ foreach ( $all_plugins as $basename => $data ) {
5954
+ if ( $addon->slug === $data['slug'] ||
5955
+ $addon->premium_slug === $data['slug']
5956
+ ) {
5957
+ return $basename;
5958
+ }
5959
+ }
5960
+
5961
+ $free_basename = "{$addon->slug}/{$addon->slug}.php";
5962
+
5963
+ return $free_basename;
5964
+ }
5965
+
5966
+ /**
5967
+ * Get installed add-ons instances.
5968
+ *
5969
+ * @author Vova Feldman (@svovaf)
5970
+ * @since 1.0.6
5971
+ *
5972
+ * @return Freemius[]
5973
+ */
5974
+ function get_installed_addons() {
5975
+ if ( $this->is_addon() ) {
5976
+ // Add-on cannot have add-ons.
5977
+ return array();
5978
+ }
5979
+
5980
+ $installed_addons = array();
5981
+
5982
+ foreach ( self::$_instances as $instance ) {
5983
+ if ( $instance->is_addon_of( $this->_plugin->id ) ) {
5984
+ $installed_addons[] = $instance;
5985
+ }
5986
+ }
5987
+
5988
+ return $installed_addons;
5989
+ }
5990
+
5991
+ /**
5992
+ * Check if any add-ons of the plugin are installed.
5993
+ *
5994
+ * @author Leo Fajardo (@leorw)
5995
+ * @since 1.1.1
5996
+ *
5997
+ * @return bool
5998
+ */
5999
+ function has_installed_addons() {
6000
+ if ( ! $this->has_addons() ) {
6001
+ return false;
6002
+ }
6003
+
6004
+ foreach ( self::$_instances as $instance ) {
6005
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
6006
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
6007
+ return true;
6008
+ }
6009
+ }
6010
+ }
6011
+
6012
+ return false;
6013
+ }
6014
+
6015
+ /**
6016
+ * Tell Freemius that the current plugin is an add-on.
6017
+ *
6018
+ * @author Vova Feldman (@svovaf)
6019
+ * @since 1.0.6
6020
+ *
6021
+ * @param number $parent_plugin_id The parent plugin ID
6022
+ */
6023
+ function init_addon( $parent_plugin_id ) {
6024
+ $this->_plugin->parent_plugin_id = $parent_plugin_id;
6025
+ }
6026
+
6027
+ /**
6028
+ * @author Vova Feldman (@svovaf)
6029
+ * @since 1.0.6
6030
+ *
6031
+ * @return bool
6032
+ */
6033
+ function is_addon() {
6034
+ return (
6035
+ isset( $this->_plugin->parent_plugin_id ) &&
6036
+ is_numeric( $this->_plugin->parent_plugin_id )
6037
+ );
6038
+ }
6039
+
6040
+ /**
6041
+ * @author Vova Feldman (@svovaf)
6042
+ * @since 2.3.2
6043
+ *
6044
+ * @param number $parent_product_id
6045
+ *
6046
+ * @return bool
6047
+ */
6048
+ function is_addon_of( $parent_product_id ) {
6049
+ return (
6050
+ $this->is_addon() &&
6051
+ $parent_product_id == $this->_plugin->parent_plugin_id
6052
+ );
6053
+ }
6054
+
6055
+ /**
6056
+ * Deactivate add-on if it's premium only and the user does't have a valid license.
6057
+ *
6058
+ * @param bool $is_after_trial_cancel
6059
+ *
6060
+ * @return bool If add-on was deactivated.
6061
+ */
6062
+ private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) {
6063
+ if ( ! $this->has_free_plan() &&
6064
+ ! $this->has_features_enabled_license() &&
6065
+ ! $this->_has_premium_license()
6066
+ ) {
6067
+ if ( $this->is_registered() ) {
6068
+ // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons).
6069
+ // if (empty($this->_storage->activation_timestamp) ||
6070
+ // (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30
6071
+ // ) {
6072
+ /**
6073
+ * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation.
6074
+ *
6075
+ * Retry syncing the user add-on licenses.
6076
+ */
6077
+ // Sync licenses.
6078
+ $this->_sync_licenses();
6079
+ // }
6080
+
6081
+ // Try to activate premium license.
6082
+ $this->_activate_license( true );
6083
+ }
6084
+
6085
+ if ( ! $this->has_free_plan() &&
6086
+ ! $this->has_features_enabled_license() &&
6087
+ ! $this->_has_premium_license()
6088
+ ) {
6089
+ // @todo Check if deactivate plugins also call the deactivation hook.
6090
+
6091
+ $this->_parent->_admin_notices->add_sticky(
6092
+ sprintf(
6093
+ ( $is_after_trial_cancel ?
6094
+ $this->_parent->get_text_inline(
6095
+ '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.',
6096
+ 'addon-trial-cancelled-message'
6097
+ ) :
6098
+ $this->_parent->get_text_inline(
6099
+ '%s is a premium only add-on. You have to purchase a license first before activating the plugin.',
6100
+ 'addon-no-license-message'
6101
+ )
6102
+ ),
6103
+ '<b>' . $this->_plugin->title . '</b>'
6104
+ ) . ' ' . sprintf(
6105
+ '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>',
6106
+ $this->_parent->addon_url( $this->_slug ),
6107
+ esc_attr( sprintf( $this->_parent->get_text_inline( 'More information about %s', 'more-information-about-x' ), $this->_plugin->title ) ),
6108
+ $this->_parent->get_text_inline( 'Purchase License', 'purchase-license' )
6109
+ ),
6110
+ 'no_addon_license_' . $this->_slug,
6111
+ ( $is_after_trial_cancel ? '' : $this->_parent->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' ),
6112
+ ( $is_after_trial_cancel ? 'success' : 'error' )
6113
+ );
6114
+
6115
+ deactivate_plugins( array( $this->_plugin_basename ), true );
6116
+
6117
+ return true;
6118
+ }
6119
+ }
6120
+
6121
+ return false;
6122
+ }
6123
+
6124
+ #endregion
6125
+
6126
+ #----------------------------------------------------------------------------------
6127
+ #region Sandbox
6128
+ #----------------------------------------------------------------------------------
6129
+
6130
+ /**
6131
+ * Set Freemius into sandbox mode for debugging.
6132
+ *
6133
+ * @author Vova Feldman (@svovaf)
6134
+ * @since 1.0.4
6135
+ *
6136
+ * @param string $secret_key
6137
+ */
6138
+ function init_sandbox( $secret_key ) {
6139
+ $this->_plugin->secret_key = $secret_key;
6140
+
6141
+ // Update plugin details.
6142
+ FS_Plugin_Manager::instance( $this->_module_id )->update( $this->_plugin, true );
6143
+ }
6144
+
6145
+ /**
6146
+ * Check if running payments in sandbox mode.
6147
+ *
6148
+ * @author Vova Feldman (@svovaf)
6149
+ * @since 1.0.4
6150
+ *
6151
+ * @return bool
6152
+ */
6153
+ function is_payments_sandbox() {
6154
+ return ( ! $this->is_live() ) || isset( $this->_plugin->secret_key );
6155
+ }
6156
+
6157
+ #endregion
6158
+
6159
+ /**
6160
+ * Check if running test vs. live plugin.
6161
+ *
6162
+ * @author Vova Feldman (@svovaf)
6163
+ * @since 1.0.5
6164
+ *
6165
+ * @return bool
6166
+ */
6167
+ function is_live() {
6168
+ return $this->_plugin->is_live;
6169
+ }
6170
+
6171
+ /**
6172
+ * Check if super-admin skipped connection for all sites in the network.
6173
+ *
6174
+ * @author Vova Feldman (@svovaf)
6175
+ * @since 2.0.0
6176
+ */
6177
+ function is_network_anonymous() {
6178
+ if ( ! $this->_is_network_active ) {
6179
+ return false;
6180
+ }
6181
+
6182
+ $is_anonymous_ms = $this->_storage->get( 'is_anonymous_ms' );
6183
+
6184
+ if ( empty( $is_anonymous_ms ) ) {
6185
+ return false;
6186
+ }
6187
+
6188
+ return $is_anonymous_ms['is'];
6189
+ }
6190
+
6191
+ /**
6192
+ * Check if super-admin opted-in for all sites in the network.
6193
+ *
6194
+ * @author Vova Feldman (@svovaf)
6195
+ * @since 2.0.0
6196
+ */
6197
+ function is_network_connected() {
6198
+ if ( ! $this->_is_network_active ) {
6199
+ return false;
6200
+ }
6201
+
6202
+ return $this->_storage->get( 'is_network_connected' );
6203
+ }
6204
+
6205
+ /**
6206
+ * Check if the user skipped connecting the account with Freemius.
6207
+ *
6208
+ * @author Vova Feldman (@svovaf)
6209
+ * @since 1.0.7
6210
+ *
6211
+ * @return bool
6212
+ */
6213
+ function is_anonymous() {
6214
+ if ( ! isset( $this->_is_anonymous ) ) {
6215
+ if ( $this->is_network_anonymous() ) {
6216
+ $this->_is_anonymous = true;
6217
+ } else if ( ! fs_is_network_admin() ) {
6218
+ if ( ! isset( $this->_storage->is_anonymous ) ) {
6219
+ // Not skipped.
6220
+ $this->_is_anonymous = false;
6221
+ } else if ( is_bool( $this->_storage->is_anonymous ) ) {
6222
+ // For back compatibility, since the variable was boolean before.
6223
+ $this->_is_anonymous = $this->_storage->is_anonymous;
6224
+
6225
+ // Upgrade stored data format to 1.1.3 format.
6226
+ $this->set_anonymous_mode( $this->_storage->is_anonymous );
6227
+ } else {
6228
+ // Version 1.1.3 and later.
6229
+ $this->_is_anonymous = $this->_storage->is_anonymous['is'];
6230
+ }
6231
+ }
6232
+ }
6233
+
6234
+ return $this->_is_anonymous;
6235
+ }
6236
+
6237
+ /**
6238
+ * Check if the user skipped the connection of a specified site.
6239
+ *
6240
+ * @author Vova Feldman (@svovaf)
6241
+ * @since 2.0.0
6242
+ *
6243
+ * @param int $blog_id
6244
+ *
6245
+ * @return bool
6246
+ */
6247
+ function is_anonymous_site( $blog_id = 0 ) {
6248
+ if ( $this->is_network_anonymous() ) {
6249
+ return true;
6250
+ }
6251
+
6252
+ $is_anonymous = $this->_storage->get( 'is_anonymous', false, $blog_id );
6253
+
6254
+ if ( empty( $is_anonymous ) ) {
6255
+ return false;
6256
+ }
6257
+
6258
+ return $is_anonymous['is'];
6259
+ }
6260
+
6261
+ /**
6262
+ * Check if user connected his account and install pending email activation.
6263
+ *
6264
+ * @author Vova Feldman (@svovaf)
6265
+ * @since 1.0.7
6266
+ *
6267
+ * @return bool
6268
+ */
6269
+ function is_pending_activation() {
6270
+ return $this->_storage->get( 'is_pending_activation', false );
6271
+ }
6272
+
6273
+ /**
6274
+ * Check if plugin must be WordPress.org compliant.
6275
+ *
6276
+ * @since 1.0.7
6277
+ *
6278
+ * @return bool
6279
+ */
6280
+ function is_org_repo_compliant() {
6281
+ return $this->_is_org_compliant;
6282
+ }
6283
+
6284
+ #--------------------------------------------------------------------------------
6285
+ #region WP Cron Common
6286
+ #--------------------------------------------------------------------------------
6287
+
6288
+ /**
6289
+ * @author Vova Feldman (@svovaf)
6290
+ * @since 2.0.0
6291
+ *
6292
+ * @param string $name Cron name.
6293
+ *
6294
+ * @return object
6295
+ */
6296
+ private function get_cron_data( $name ) {
6297
+ $this->_logger->entrance( $name );
6298
+
6299
+ /**
6300
+ * @var object $cron_data
6301
+ */
6302
+ return $this->_storage->get( "{$name}_cron", null );
6303
+ }
6304
+
6305
+ /**
6306
+ * @author Vova Feldman (@svovaf)
6307
+ * @since 2.0.0
6308
+ *
6309
+ * @param string $name Cron name.
6310
+ */
6311
+ private function clear_cron_data( $name ) {
6312
+ $this->_logger->entrance( $name );
6313
+
6314
+ $this->_storage->remove( "{$name}_cron" );
6315
+ }
6316
+
6317
+ /**
6318
+ * @author Vova Feldman (@svovaf)
6319
+ * @since 2.0.0
6320
+ *
6321
+ * @param string $name Cron name.
6322
+ * @param int $cron_blog_id The cron executing blog ID.
6323
+ */
6324
+ private function set_cron_data( $name, $cron_blog_id = 0 ) {
6325
+ $this->_logger->entrance( $name );
6326
+
6327
+ $this->_storage->store( "{$name}_cron", (object) array(
6328
+ 'version' => $this->get_plugin_version(),
6329
+ 'blog_id' => $cron_blog_id,
6330
+ 'sdk_version' => $this->version,
6331
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
6332
+ 'on' => true,
6333
+ ) );
6334
+ }
6335
+
6336
+ /**
6337
+ * Get the cron's executing blog ID.
6338
+ *
6339
+ * @author Vova Feldman (@svovaf)
6340
+ * @since 2.0.0
6341
+ *
6342
+ * @param string $name Cron name.
6343
+ *
6344
+ * @return int
6345
+ */
6346
+ private function get_cron_blog_id( $name ) {
6347
+ $this->_logger->entrance( $name );
6348
+
6349
+ /**
6350
+ * @var object $cron_data
6351
+ */
6352
+ $cron_data = $this->get_cron_data( $name );
6353
+
6354
+ return ( is_object( $cron_data ) && is_numeric( $cron_data->blog_id ) ) ?
6355
+ $cron_data->blog_id :
6356
+ 0;
6357
+ }
6358
+
6359
+ /**
6360
+ * @author Vova Feldman (@svovaf)
6361
+ * @since 2.0.0
6362
+ *
6363
+ * @param string $name Cron name.
6364
+ *
6365
+ * @return bool
6366
+ */
6367
+ private function is_cron_on( $name ) {
6368
+ $this->_logger->entrance( $name );
6369
+
6370
+ /**
6371
+ * @var object $cron_data
6372
+ */
6373
+ $cron_data = $this->get_cron_data( $name );
6374
+
6375
+ return ( ! is_null( $cron_data ) && true === $cron_data->on );
6376
+ }
6377
+
6378
+ /**
6379
+ * Unix timestamp for previous cron execution or false if never executed.
6380
+ *
6381
+ * @author Vova Feldman (@svovaf)
6382
+ * @since 2.0.0
6383
+ *
6384
+ * @param string $name Cron name.
6385
+ *
6386
+ * @return int|false
6387
+ */
6388
+ private function cron_last_execution( $name ) {
6389
+ $this->_logger->entrance( $name );
6390
+
6391
+ return $this->_storage->get( "{$name}_timestamp" );
6392
+ }
6393
+
6394
+ /**
6395
+ * Set cron execution time to now.
6396
+ *
6397
+ * @author Vova Feldman (@svovaf)
6398
+ * @since 2.0.0
6399
+ *
6400
+ * @param string $name Cron name.
6401
+ */
6402
+ private function set_cron_execution_timestamp( $name ) {
6403
+ $this->_logger->entrance( $name );
6404
+
6405
+ $this->_storage->store( "{$name}_timestamp", time() );
6406
+ }
6407
+
6408
+ /**
6409
+ * Sets the keepalive time to now.
6410
+ *
6411
+ * @author Leo Fajardo (@leorw)
6412
+ * @since 2.2.3
6413
+ *
6414
+ * @param bool|null $use_network_level_storage
6415
+ */
6416
+ private function set_keepalive_timestamp( $use_network_level_storage = null ) {
6417
+ $this->_logger->entrance();
6418
+
6419
+ $this->_storage->store( 'keepalive_timestamp', time(), $use_network_level_storage );
6420
+ }
6421
+
6422
+ /**
6423
+ * Check if cron was executed in the last $period of seconds.
6424
+ *
6425
+ * @author Vova Feldman (@svovaf)
6426
+ * @since 2.0.0
6427
+ *
6428
+ * @param string $name Cron name.
6429
+ * @param int $period In seconds
6430
+ *
6431
+ * @return bool
6432
+ */
6433
+ private function is_cron_executed( $name, $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
6434
+ $this->_logger->entrance( $name );
6435
+
6436
+ $last_execution = $this->cron_last_execution( $name );
6437
+
6438
+ if ( ! is_numeric( $last_execution ) ) {
6439
+ return false;
6440
+ }
6441
+
6442
+ return ( $last_execution > ( WP_FS__SCRIPT_START_TIME - $period ) );
6443
+ }
6444
+
6445
+ /**
6446
+ * WP Cron is executed on a site level. When running in a multisite network environment
6447
+ * with the network integration activated, for optimization reasons, we are consolidating
6448
+ * the installs data sync cron to be executed only from a single site.
6449
+ *
6450
+ * @author Vova Feldman (@svovaf)
6451
+ * @since 2.0.0
6452
+ *
6453
+ * @param int $except_blog_id Target any except the excluded blog ID.
6454
+ *
6455
+ * @return int
6456
+ */
6457
+ private function get_cron_target_blog_id( $except_blog_id = 0 ) {
6458
+ if ( ! is_multisite() ) {
6459
+ return 0;
6460
+ }
6461
+
6462
+ if ( $this->_is_network_active &&
6463
+ is_numeric( $this->_storage->network_install_blog_id ) &&
6464
+ $except_blog_id != $this->_storage->network_install_blog_id &&
6465
+ self::is_site_active( $this->_storage->network_install_blog_id )
6466
+ ) {
6467
+ // Try to run cron from the main network blog.
6468
+ $install = $this->get_install_by_blog_id( $this->_storage->network_install_blog_id );
6469
+
6470
+ if ( is_object( $install ) &&
6471
+ ( $this->is_premium() || $install->is_tracking_allowed() )
6472
+ ) {
6473
+ return $this->_storage->network_install_blog_id;
6474
+ }
6475
+ }
6476
+
6477
+ // Get first opted-in blog ID with active tracking.
6478
+ $installs = $this->get_blog_install_map();
6479
+ foreach ( $installs as $blog_id => $install ) {
6480
+ if ( $except_blog_id != $blog_id &&
6481
+ self::is_site_active( $blog_id ) &&
6482
+ ( $this->is_premium() || $install->is_tracking_allowed() )
6483
+ ) {
6484
+ return $blog_id;
6485
+ }
6486
+ }
6487
+
6488
+ return 0;
6489
+ }
6490
+
6491
+ /**
6492
+ * @author Vova Feldman (@svovaf)
6493
+ * @since 2.0.0
6494
+ *
6495
+ * @param string $name Cron name.
6496
+ * @param string $action_tag Callback action tag.
6497
+ * @param bool $is_network_clear If set to TRUE, clear sync cron even if there are installs that are still connected.
6498
+ */
6499
+ private function clear_cron( $name, $action_tag = '', $is_network_clear = false ) {
6500
+ $this->_logger->entrance( $name );
6501
+
6502
+ if ( ! $this->is_cron_on( $name ) ) {
6503
+ return;
6504
+ }
6505
+
6506
+ $clear_cron = true;
6507
+ if ( ! $is_network_clear && $this->_is_network_active ) {
6508
+ $installs = $this->get_blog_install_map();
6509
+
6510
+ foreach ( $installs as $blog_id => $install ) {
6511
+ /**
6512
+ * @var FS_Site $install
6513
+ */
6514
+ if ( $install->is_tracking_allowed() ) {
6515
+ $clear_cron = false;
6516
+ break;
6517
+ }
6518
+ }
6519
+ }
6520
+
6521
+ if ( ! $clear_cron ) {
6522
+ return;
6523
+ }
6524
+
6525
+ /**
6526
+ * @var object $cron_data
6527
+ */
6528
+ $cron_data = $this->get_cron_data( $name );
6529
+
6530
+ $cron_blog_id = is_object( $cron_data ) && isset( $cron_data->blog_id ) ?
6531
+ $cron_data->blog_id :
6532
+ 0;
6533
+
6534
+ $this->clear_cron_data( $name );
6535
+
6536
+ if ( 0 < $cron_blog_id ) {
6537
+ switch_to_blog( $cron_blog_id );
6538
+ }
6539
+
6540
+ if ( empty( $action_tag ) ) {
6541
+ $action_tag = $name;
6542
+ }
6543
+
6544
+ wp_clear_scheduled_hook( $this->get_action_tag( $action_tag ) );
6545
+
6546
+ if ( 0 < $cron_blog_id ) {
6547
+ restore_current_blog();
6548
+ }
6549
+ }
6550
+
6551
+ /**
6552
+ * Unix timestamp for next cron execution or false if not scheduled.
6553
+ *
6554
+ * @author Vova Feldman (@svovaf)
6555
+ * @since 2.0.0
6556
+ *
6557
+ * @param string $name Cron name.
6558
+ * @param string $action_tag Callback action tag.
6559
+ *
6560
+ * @return int|false
6561
+ */
6562
+ private function get_next_scheduled_cron( $name, $action_tag = '' ) {
6563
+ $this->_logger->entrance( $name );
6564
+
6565
+ if ( ! $this->is_cron_on( $name ) ) {
6566
+ return false;
6567
+ }
6568
+
6569
+ /**
6570
+ * @var object $cron_data
6571
+ */
6572
+ $cron_data = $this->get_cron_data( $name );
6573
+
6574
+ $cron_blog_id = is_object( $cron_data ) && isset( $cron_data->blog_id ) ?
6575
+ $cron_data->blog_id :
6576
+ 0;
6577
+
6578
+ if ( 0 < $cron_blog_id ) {
6579
+ switch_to_blog( $cron_blog_id );
6580
+ }
6581
+
6582
+ if ( empty( $action_tag ) ) {
6583
+ $action_tag = $name;
6584
+ }
6585
+
6586
+ $next_scheduled = wp_next_scheduled( $this->get_action_tag( $action_tag ) );
6587
+
6588
+ if ( 0 < $cron_blog_id ) {
6589
+ restore_current_blog();
6590
+ }
6591
+
6592
+ return $next_scheduled;
6593
+ }
6594
+
6595
+ /**
6596
+ * @author Vova Feldman (@svovaf)
6597
+ * @since 2.0.0
6598
+ *
6599
+ * @param string $name Cron name.
6600
+ * @param string $action_tag Callback action tag.
6601
+ * @param string $recurrence 'single' or 'daily'.
6602
+ * @param int $start_at Defaults to now.
6603
+ * @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise, schedule job to start right away.
6604
+ * @param int $except_blog_id Target any except the excluded blog ID.
6605
+ */
6606
+ private function schedule_cron(
6607
+ $name,
6608
+ $action_tag = '',
6609
+ $recurrence = 'single',
6610
+ $start_at = WP_FS__SCRIPT_START_TIME,
6611
+ $randomize_start = true,
6612
+ $except_blog_id = 0
6613
+ ) {
6614
+ $this->_logger->entrance( $name );
6615
+
6616
+ $this->clear_cron( $name, $action_tag, true );
6617
+
6618
+ $cron_blog_id = $this->get_cron_target_blog_id( $except_blog_id );
6619
+
6620
+ if ( is_multisite() && 0 == $cron_blog_id ) {
6621
+ // Don't schedule cron since couldn't find a target blog.
6622
+ return;
6623
+ }
6624
+
6625
+ if ( 0 < $cron_blog_id ) {
6626
+ switch_to_blog( $cron_blog_id );
6627
+ }
6628
+
6629
+ if ( 'daily' === $recurrence ) {
6630
+ if ( $randomize_start ) {
6631
+ // Schedule first sync with a random 12 hour time range from now.
6632
+ $start_at += rand( 0, ( WP_FS__TIME_24_HOURS_IN_SEC / 2 ) );
6633
+ }
6634
+
6635
+ // Schedule daily WP cron.
6636
+ wp_schedule_event(
6637
+ $start_at,
6638
+ 'daily',
6639
+ $this->get_action_tag( $action_tag )
6640
+ );
6641
+ } else if ( 'single' === $recurrence ) {
6642
+ // Schedule single cron.
6643
+ wp_schedule_single_event(
6644
+ $start_at,
6645
+ $this->get_action_tag( $action_tag )
6646
+ );
6647
+ }
6648
+
6649
+ $this->set_cron_data( $name, $cron_blog_id );
6650
+
6651
+ if ( 0 < $cron_blog_id ) {
6652
+ restore_current_blog();
6653
+ }
6654
+ }
6655
+
6656
+ /**
6657
+ * Consolidated cron execution for performance optimization. The max number of API requests is based on the number of unique opted-in users.
6658
+ * that doesn't halt page loading.
6659
+ *
6660
+ * @author Vova Feldman (@svovaf)
6661
+ * @since 2.0.0
6662
+ *
6663
+ * @param string $name Cron name.
6664
+ * @param callable $callable The function that should be executed.
6665
+ */
6666
+ private function execute_cron( $name, $callable ) {
6667
+ $this->_logger->entrance( $name );
6668
+
6669
+ // Store the last time data sync was executed.
6670
+ $this->set_cron_execution_timestamp( $name );
6671
+
6672
+ // Check if API is temporary down.
6673
+ if ( FS_Api::is_temporary_down() ) {
6674
+ return;
6675
+ }
6676
+
6677
+ // @todo Add logic that identifies API latency, and reschedule the next background sync randomly between 8-16 hours.
6678
+
6679
+ $users_2_blog_ids = array();
6680
+
6681
+ if ( ! is_multisite() ) {
6682
+ // Add dummy blog.
6683
+ $users_2_blog_ids[0] = array( 0 );
6684
+ } else {
6685
+ $installs = $this->get_blog_install_map();
6686
+ foreach ( $installs as $blog_id => $install ) {
6687
+ if ( $this->is_premium() || $install->is_tracking_allowed() ) {
6688
+ if ( ! isset( $users_2_blog_ids[ $install->user_id ] ) ) {
6689
+ $users_2_blog_ids[ $install->user_id ] = array();
6690
+ }
6691
+
6692
+ $users_2_blog_ids[ $install->user_id ][] = $blog_id;
6693
+ }
6694
+ }
6695
+ }
6696
+
6697
+ $current_blog_id = get_current_blog_id();
6698
+
6699
+ foreach ( $users_2_blog_ids as $user_id => $blog_ids ) {
6700
+ if ( 0 < $blog_ids[0] ) {
6701
+ $this->switch_to_blog( $blog_ids[0] );
6702
+ }
6703
+
6704
+ call_user_func_array( $callable, array( $blog_ids, ( is_multisite() ? $current_blog_id : null ) ) );
6705
+
6706
+ foreach ( $blog_ids as $blog_id ) {
6707
+ $this->do_action( "after_{$name}_cron", $blog_id );
6708
+ }
6709
+ }
6710
+
6711
+ if ( is_multisite() ) {
6712
+ $this->switch_to_blog( $current_blog_id, fs_is_network_admin() ? $this->get_network_install() : null );
6713
+
6714
+ $this->do_action( "after_{$name}_cron_multisite" );
6715
+ }
6716
+ }
6717
+
6718
+ #endregion
6719
+
6720
+ #----------------------------------------------------------------------------------
6721
+ #region Daily Sync Cron
6722
+ #----------------------------------------------------------------------------------
6723
+
6724
+
6725
+ /**
6726
+ * @author Vova Feldman (@svovaf)
6727
+ * @since 2.0.0
6728
+ *
6729
+ * @return bool
6730
+ */
6731
+ private function is_sync_cron_scheduled() {
6732
+ return $this->is_cron_on( 'sync' );
6733
+ }
6734
+
6735
+ /**
6736
+ * Get the sync cron's executing blog ID.
6737
+ *
6738
+ * @author Vova Feldman (@svovaf)
6739
+ * @since 2.0.0
6740
+ *
6741
+ * @return int
6742
+ */
6743
+ private function get_sync_cron_blog_id() {
6744
+ return $this->get_cron_blog_id( 'sync' );
6745
+ }
6746
+
6747
+ /**
6748
+ * @author Vova Feldman (@svovaf)
6749
+ * @since 1.1.7.3
6750
+ */
6751
+ private function run_manual_sync() {
6752
+ self::require_pluggable_essentials();
6753
+
6754
+ if ( ! $this->is_user_admin() ) {
6755
+ return;
6756
+ }
6757
+
6758
+ // Run manual sync.
6759
+ $this->_sync_cron();
6760
+
6761
+ // Reschedule next cron to run 24 hours from now (performance optimization).
6762
+ $this->schedule_sync_cron( time() + WP_FS__TIME_24_HOURS_IN_SEC, false );
6763
+ }
6764
+
6765
+ /**
6766
+ * Data sync cron job. Replaces the background sync non blocking HTTP request
6767
+ * that doesn't halt page loading.
6768
+ *
6769
+ * @author Vova Feldman (@svovaf)
6770
+ * @since 1.1.7.3
6771
+ * @since 2.0.0 Consolidate all the data sync into the same cron for performance optimization. The max number of API requests is based on the number of unique opted-in users.
6772
+ */
6773
+ function _sync_cron() {
6774
+ $this->_logger->entrance();
6775
+
6776
+ $this->execute_cron( 'sync', array( &$this, '_sync_cron_method' ) );
6777
+ }
6778
+
6779
+ /**
6780
+ * The actual data sync cron logic.
6781
+ *
6782
+ * @author Vova Feldman (@svovaf)
6783
+ * @since 2.0.0
6784
+ *
6785
+ * @param int[] $blog_ids
6786
+ * @param int|null $current_blog_id @since 2.2.3. This is passed from the `execute_cron` method and used by the
6787
+ * `_sync_plugin_license` method in order to switch to the previous blog when sending
6788
+ * updates for a single site in case `execute_cron` has switched to a different blog.
6789
+ */
6790
+ function _sync_cron_method( array $blog_ids, $current_blog_id = null ) {
6791
+ if ( $this->is_registered() ) {
6792
+ $this->sync_user_beta_mode();
6793
+
6794
+ if ( $this->has_paid_plan() ) {
6795
+ // Initiate background plan sync.
6796
+ $this->_sync_license( true, false, $current_blog_id );
6797
+
6798
+ if ( $this->is_paying() ) {
6799
+ // Check for premium plugin updates.
6800
+ $this->check_updates( true );
6801
+ }
6802
+ } else {
6803
+ // Sync install(s) (only if something changed locally).
6804
+ if ( 1 < count( $blog_ids ) ) {
6805
+ $this->sync_installs();
6806
+ } else {
6807
+ $this->sync_install();
6808
+ }
6809
+
6810
+ $this->maybe_sync_install_user();
6811
+ }
6812
+ }
6813
+ }
6814
+
6815
+ /**
6816
+ * Check if sync was executed in the last $period of seconds.
6817
+ *
6818
+ * @author Vova Feldman (@svovaf)
6819
+ * @since 1.1.7.3
6820
+ *
6821
+ * @param int $period In seconds
6822
+ *
6823
+ * @return bool
6824
+ */
6825
+ private function is_sync_executed( $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
6826
+ return $this->is_cron_executed( 'sync', $period );
6827
+ }
6828
+
6829
+ /**
6830
+ * @author Vova Feldman (@svovaf)
6831
+ * @since 1.1.7.3
6832
+ *
6833
+ * @return bool
6834
+ */
6835
+ private function is_sync_cron_on() {
6836
+ return $this->is_cron_on( 'sync' );
6837
+ }
6838
+
6839
+ /**
6840
+ * @author Vova Feldman (@svovaf)
6841
+ * @since 1.1.7.3
6842
+ *
6843
+ * @param int $start_at Defaults to now.
6844
+ * @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise, schedule job to start right away.
6845
+ * @param int $except_blog_id Since 2.0.0 when running in a multisite network environment, the cron execution is consolidated. This param allows excluding excluded specified blog ID from being the cron executor.
6846
+ */
6847
+ private function schedule_sync_cron(
6848
+ $start_at = WP_FS__SCRIPT_START_TIME,
6849
+ $randomize_start = true,
6850
+ $except_blog_id = 0
6851
+ ) {
6852
+ $this->schedule_cron(
6853
+ 'sync',
6854
+ 'data_sync',
6855
+ 'daily',
6856
+ $start_at,
6857
+ $randomize_start,
6858
+ $except_blog_id
6859
+ );
6860
+ }
6861
+
6862
+ /**
6863
+ * Add the actual sync function to the cron job hook.
6864
+ *
6865
+ * @author Vova Feldman (@svovaf)
6866
+ * @since 1.1.7.3
6867
+ */
6868
+ private function hook_callback_to_sync_cron() {
6869
+ $this->add_action( 'data_sync', array( &$this, '_sync_cron' ) );
6870
+ }
6871
+
6872
+ /**
6873
+ * @author Vova Feldman (@svovaf)
6874
+ * @since 1.1.7.3
6875
+ *
6876
+ * @param bool $is_network_clear Since 2.0.0 If set to TRUE, clear sync cron even if there are installs that are still connected.
6877
+ */
6878
+ private function clear_sync_cron( $is_network_clear = false ) {
6879
+ $this->_logger->entrance();
6880
+
6881
+ $this->clear_cron( 'sync', 'data_sync', $is_network_clear );
6882
+ }
6883
+
6884
+ /**
6885
+ * Unix timestamp for next sync cron execution or false if not scheduled.
6886
+ *
6887
+ * @author Vova Feldman (@svovaf)
6888
+ * @since 1.1.7.3
6889
+ *
6890
+ * @return int|false
6891
+ */
6892
+ function next_sync_cron() {
6893
+ return $this->get_next_scheduled_cron( 'sync', 'data_sync' );
6894
+ }
6895
+
6896
+ /**
6897
+ * Unix timestamp for previous sync cron execution or false if never executed.
6898
+ *
6899
+ * @author Vova Feldman (@svovaf)
6900
+ * @since 1.1.7.3
6901
+ *
6902
+ * @return int|false
6903
+ */
6904
+ function last_sync_cron() {
6905
+ return $this->cron_last_execution( 'sync' );
6906
+ }
6907
+
6908
+ #endregion Daily Sync Cron ------------------------------------------------------------------
6909
+
6910
+ #----------------------------------------------------------------------------------
6911
+ #region Async Install Sync
6912
+ #----------------------------------------------------------------------------------
6913
+
6914
+ /**
6915
+ * @author Vova Feldman (@svovaf)
6916
+ * @since 1.1.7.3
6917
+ *
6918
+ * @return bool
6919
+ */
6920
+ private function is_install_sync_scheduled() {
6921
+ return $this->is_cron_on( 'install_sync' );
6922
+ }
6923
+
6924
+ /**
6925
+ * Get the sync cron's executing blog ID.
6926
+ *
6927
+ * @author Vova Feldman (@svovaf)
6928
+ * @since 2.0.0
6929
+ *
6930
+ * @return int
6931
+ */
6932
+ private function get_install_sync_cron_blog_id() {
6933
+ return $this->get_cron_blog_id( 'install_sync' );
6934
+ }
6935
+
6936
+ /**
6937
+ * Instead of running blocking install sync event, execute non blocking scheduled wp-cron.
6938
+ *
6939
+ * @author Vova Feldman (@svovaf)
6940
+ * @since 1.1.7.3
6941
+ *
6942
+ * @param int $except_blog_id Since 2.0.0 when running in a multisite network environment, the cron execution is consolidated. This param allows excluding excluded specified blog ID from being the cron executor.
6943
+ */
6944
+ private function schedule_install_sync( $except_blog_id = 0 ) {
6945
+ $this->schedule_cron( 'install_sync', 'install_sync', 'single', WP_FS__SCRIPT_START_TIME, false, $except_blog_id );
6946
+ }
6947
+
6948
+ /**
6949
+ * Unix timestamp for previous install sync cron execution or false if never executed.
6950
+ *
6951
+ * @todo There's some very strange bug that $this->_storage->install_sync_timestamp value is not being updated. But for sure the sync event is working.
6952
+ *
6953
+ * @author Vova Feldman (@svovaf)
6954
+ * @since 1.1.7.3
6955
+ *
6956
+ * @return int|false
6957
+ */
6958
+ function last_install_sync() {
6959
+ return $this->cron_last_execution( 'install_sync' );
6960
+ }
6961
+
6962
+ /**
6963
+ * Unix timestamp for next install sync cron execution or false if not scheduled.
6964
+ *
6965
+ * @author Vova Feldman (@svovaf)
6966
+ * @since 1.1.7.3
6967
+ *
6968
+ * @return int|false
6969
+ */
6970
+ function next_install_sync() {
6971
+ return $this->get_next_scheduled_cron( 'install_sync', 'install_sync' );
6972
+ }
6973
+
6974
+ /**
6975
+ * Add the actual install sync function to the cron job hook.
6976
+ *
6977
+ * @author Vova Feldman (@svovaf)
6978
+ * @since 1.1.7.3
6979
+ */
6980
+ private function hook_callback_to_install_sync() {
6981
+ $this->add_action( 'install_sync', array( &$this, '_run_sync_install' ) );
6982
+ }
6983
+
6984
+ /**
6985
+ * @author Vova Feldman (@svovaf)
6986
+ * @since 1.1.7.3
6987
+ *
6988
+ * @param bool $is_network_clear Since 2.0.0 If set to TRUE, clear sync cron even if there are installs that are still connected.
6989
+ */
6990
+ private function clear_install_sync_cron( $is_network_clear = false ) {
6991
+ $this->_logger->entrance();
6992
+
6993
+ $this->clear_cron( 'install_sync', 'install_sync', $is_network_clear );
6994
+ }
6995
+
6996
+ /**
6997
+ * @author Vova Feldman (@svovaf)
6998
+ * @since 1.1.7.3
6999
+ * @since 2.0.0 Consolidate all the data sync into the same cron for performance optimization. The max number of API requests is based on the number of unique opted-in users.
7000
+ */
7001
+ public function _run_sync_install() {
7002
+ $this->_logger->entrance();
7003
+
7004
+ $this->execute_cron( 'sync', array( &$this, '_sync_install_cron_method' ) );
7005
+ }
7006
+
7007
+ /**
7008
+ * The actual install(s) sync cron logic.
7009
+ *
7010
+ * @author Vova Feldman (@svovaf)
7011
+ * @since 2.0.0
7012
+ *
7013
+ * @param int[] $blog_ids
7014
+ * @param int|null $current_blog_id
7015
+ */
7016
+ function _sync_install_cron_method( array $blog_ids, $current_blog_id = null ) {
7017
+ if ( $this->is_registered() ) {
7018
+ if ( 1 < count( $blog_ids ) ) {
7019
+ $this->sync_installs( array(), true );
7020
+ } else {
7021
+ $this->sync_install( array(), true );
7022
+ }
7023
+
7024
+ $this->maybe_sync_install_user();
7025
+ }
7026
+ }
7027
+
7028
+ #endregion Async Install Sync ------------------------------------------------------------------
7029
+
7030
+ /**
7031
+ * Show a notice that activation is currently pending.
7032
+ *
7033
+ * @author Vova Feldman (@svovaf)
7034
+ * @since 1.0.7
7035
+ *
7036
+ * @param bool|string $email
7037
+ * @param bool $is_pending_trial Since 1.2.1.5
7038
+ */
7039
+ function _add_pending_activation_notice( $email = false, $is_pending_trial = false ) {
7040
+ if ( ! is_string( $email ) ) {
7041
+ $current_user = self::_get_current_wp_user();
7042
+ $email = $current_user->user_email;
7043
+ }
7044
+
7045
+ $this->_admin_notices->add_sticky(
7046
+ sprintf(
7047
+ $this->get_text_inline( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to %s.', 'pending-activation-message' ),
7048
+ '<b>' . $this->get_plugin_name() . '</b>',
7049
+ '<b>' . $email . '</b>',
7050
+ ( $is_pending_trial ?
7051
+ $this->get_text_inline( 'start the trial', 'start-the-trial' ) :
7052
+ $this->get_text_inline( 'complete the install', 'complete-the-install' ) )
7053
+ ),
7054
+ 'activation_pending',
7055
+ 'Thanks!'
7056
+ );
7057
+ }
7058
+
7059
+ /**
7060
+ * Check if currently in plugin activation.
7061
+ *
7062
+ * @author Vova Feldman (@svovaf)
7063
+ * @since 1.1.4
7064
+ *
7065
+ * @return bool
7066
+ */
7067
+ function is_plugin_activation() {
7068
+ $result = get_transient( "fs_{$this->_module_type}_{$this->_slug}_activated" );
7069
+
7070
+ return !empty($result);
7071
+ }
7072
+
7073
+ /**
7074
+ *
7075
+ * NOTE: admin_menu action executed before admin_init.
7076
+ *
7077
+ * @author Vova Feldman (@svovaf)
7078
+ * @since 1.0.7
7079
+ */
7080
+ function _admin_init_action() {
7081
+ /**
7082
+ * Automatically redirect to connect/activation page after plugin activation.
7083
+ *
7084
+ * @since 1.1.7 Do NOT redirect to opt-in when running in network admin mode.
7085
+ */
7086
+ if ( $this->is_plugin_activation() ) {
7087
+ delete_transient( "fs_{$this->_module_type}_{$this->_slug}_activated" );
7088
+
7089
+ if ( isset( $_GET['activate-multi'] ) ) {
7090
+ /**
7091
+ * Don't redirect if activating multiple plugins at once (bulk activation).
7092
+ */
7093
+ } else {
7094
+ $this->_redirect_on_activation_hook();
7095
+ return;
7096
+ }
7097
+ }
7098
+
7099
+ if ( fs_request_is_action( $this->get_unique_affix() . '_skip_activation' ) ) {
7100
+ check_admin_referer( $this->get_unique_affix() . '_skip_activation' );
7101
+
7102
+ $this->skip_connection( null, fs_is_network_admin() );
7103
+
7104
+ fs_redirect( $this->get_after_activation_url( 'after_skip_url' ) );
7105
+ }
7106
+
7107
+ if ( $this->is_network_activation_mode() &&
7108
+ fs_request_is_action( $this->get_unique_affix() . '_delegate_activation' )
7109
+ ) {
7110
+ check_admin_referer( $this->get_unique_affix() . '_delegate_activation' );
7111
+
7112
+ $this->delegate_connection();
7113
+
7114
+ fs_redirect( $this->get_after_activation_url( 'after_delegation_url' ) );
7115
+ }
7116
+
7117
+ $this->_add_upgrade_action_link();
7118
+
7119
+ if ( ! ( ! $this->_is_network_active && fs_is_network_admin() ) &&
7120
+ (
7121
+ ( true === $this->_storage->require_license_activation ) ||
7122
+ // Not registered nor anonymous.
7123
+ ( ! $this->is_registered() && ! $this->is_anonymous() ) ||
7124
+ // OR, network level and in network upgrade mode.
7125
+ ( fs_is_network_admin() && $this->_is_network_active && $this->is_network_upgrade_mode() )
7126
+ )
7127
+ ) {
7128
+ if ( ! $this->is_pending_activation() ) {
7129
+ if ( ! $this->_menu->is_activation_page( $this->show_opt_in_on_themes_page() ) ) {
7130
+ /**
7131
+ * If a user visits any other admin page before activating the premium-only theme with a valid
7132
+ * license, reactivate the previous theme.
7133
+ *
7134
+ * @author Leo Fajardo (@leorw)
7135
+ * @since 1.2.2
7136
+ */
7137
+ if ( $this->is_theme() &&
7138
+ ! $this->has_settings_menu() &&
7139
+ ! isset( $_REQUEST['fs_action'] ) &&
7140
+ $this->can_activate_previous_theme()
7141
+ ) {
7142
+ if ( $this->is_only_premium() ) {
7143
+ $this->activate_previous_theme();
7144
+ return;
7145
+ }
7146
+
7147
+ if ( true === $this->_storage->require_license_activation ) {
7148
+ $this->_storage->require_license_activation = false;
7149
+ }
7150
+ }
7151
+
7152
+ if ( ! fs_is_network_admin() &&
7153
+ $this->is_network_activation_mode() &&
7154
+ ! $this->is_delegated_connection()
7155
+ ) {
7156
+ return;
7157
+ }
7158
+
7159
+ if ( $this->is_plugin_new_install() || $this->is_only_premium() ) {
7160
+ if ( ! $this->_anonymous_mode ) {
7161
+ // Show notice for new plugin installations.
7162
+ $this->_admin_notices->add(
7163
+ sprintf(
7164
+ $this->get_text_inline( 'You are just one step away - %s', 'you-are-step-away' ),
7165
+ sprintf( '<b><a href="%s">%s</a></b>',
7166
+ $this->get_activation_url( array(), ! $this->is_delegated_connection() ),
7167
+ sprintf( $this->get_text_x_inline( 'Complete "%s" Activation Now',
7168
+ '%s - plugin name. As complete "PluginX" activation now', 'activate-x-now' ), $this->get_plugin_name() )
7169
+ )
7170
+ ),
7171
+ '',
7172
+ 'update-nag'
7173
+ );
7174
+ }
7175
+ } else {
7176
+ if ( $this->should_add_sticky_optin_notice() ) {
7177
+ $this->add_sticky_optin_admin_notice();
7178
+ }
7179
+
7180
+ if ( $this->has_filter( 'optin_pointer_element' ) ) {
7181
+ // Don't show admin nag if plugin update.
7182
+ wp_enqueue_script( 'wp-pointer' );
7183
+ wp_enqueue_style( 'wp-pointer' );
7184
+
7185
+ $this->_enqueue_connect_essentials();
7186
+
7187
+ add_action( 'admin_print_footer_scripts', array(
7188
+ $this,
7189
+ '_add_connect_pointer_script'
7190
+ ) );
7191
+ }
7192
+ }
7193
+ }
7194
+ }
7195
+
7196
+ if ( $this->show_opt_in_on_themes_page() &&
7197
+ $this->is_activation_page()
7198
+ ) {
7199
+ $this->_show_theme_activation_optin_dialog();
7200
+ }
7201
+ }
7202
+ }
7203
+
7204
+ /**
7205
+ * @author Vova Feldman (@svovaf)
7206
+ * @since 2.0.0
7207
+ *
7208
+ * @return bool
7209
+ */
7210
+ private function should_add_sticky_optin_notice() {
7211
+ if ( fs_is_network_admin() ) {
7212
+ if ( ! $this->_is_network_active ) {
7213
+ return false;
7214
+ }
7215
+
7216
+ if ( ! $this->is_network_activation_mode() ) {
7217
+ return false;
7218
+ }
7219
+
7220
+ return ! isset( $this->_storage->sticky_optin_added_ms );
7221
+ }
7222
+
7223
+ if ( ! $this->is_activation_mode() ) {
7224
+ return false;
7225
+ }
7226
+
7227
+ // If running from a blog admin and delegated the connection.
7228
+ return ! isset( $this->_storage->sticky_optin_added );
7229
+ }
7230
+
7231
+ /**
7232
+ * @author Leo Fajardo (@leorw)
7233
+ * @since 2.0.0
7234
+ */
7235
+ private function add_sticky_optin_admin_notice() {
7236
+ if ( ! $this->_is_network_active || ! fs_is_network_admin() ) {
7237
+ $this->_storage->sticky_optin_added = true;
7238
+ } else {
7239
+ $this->_storage->sticky_optin_added_ms = true;
7240
+ }
7241
+
7242
+ // Show notice for new plugin installations.
7243
+ $this->_admin_notices->add_sticky(
7244
+ sprintf(
7245
+ $this->get_text_inline( 'We made a few tweaks to the %s, %s', 'few-plugin-tweaks' ),
7246
+ $this->_module_type,
7247
+ sprintf( '<b><a href="%s">%s</a></b>',
7248
+ $this->get_activation_url(),
7249
+ sprintf( $this->get_text_inline( 'Opt in to make "%s" better!', 'optin-x-now' ), $this->get_plugin_name() )
7250
+ )
7251
+ ),
7252
+ 'connect_account',
7253
+ '',
7254
+ 'update-nag'
7255
+ );
7256
+ }
7257
+
7258
+ /**
7259
+ * Enqueue connect requires scripts and styles.
7260
+ *
7261
+ * @author Vova Feldman (@svovaf)
7262
+ * @since 1.1.4
7263
+ */
7264
+ function _enqueue_connect_essentials() {
7265
+ wp_enqueue_script( 'jquery' );
7266
+ wp_enqueue_script( 'json2' );
7267
+
7268
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
7269
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
7270
+
7271
+ fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
7272
+ }
7273
+
7274
+ /**
7275
+ * Add connect / opt-in pointer.
7276
+ *
7277
+ * @author Vova Feldman (@svovaf)
7278
+ * @since 1.1.4
7279
+ */
7280
+ function _add_connect_pointer_script() {
7281
+ $vars = array( 'id' => $this->_module_id );
7282
+ $pointer_content = fs_get_template( 'connect.php', $vars );
7283
+ ?>
7284
+ <script type="text/javascript">// <![CDATA[
7285
+ jQuery(document).ready(function ($) {
7286
+ if ('undefined' !== typeof(jQuery().pointer)) {
7287
+
7288
+ var element = <?php echo $this->apply_filters( 'optin_pointer_element', '$("#non_existing_element");' ) ?>;
7289
+
7290
+ if (element.length > 0) {
7291
+ var optin = $(element).pointer($.extend(true, {}, {
7292
+ content : <?php echo json_encode( $pointer_content ) ?>,
7293
+ position : {
7294
+ edge : 'left',
7295
+ align: 'center'
7296
+ },
7297
+ buttons : function () {
7298
+ // Don't show pointer buttons.
7299
+ return '';
7300
+ },
7301
+ pointerWidth: 482
7302
+ }, <?php echo $this->apply_filters( 'optin_pointer_options_json', '{}' ) ?>));
7303
+
7304
+ <?php
7305
+ echo $this->apply_filters( 'optin_pointer_execute', "
7306
+
7307
+ optin.pointer('open');
7308
+
7309
+ // Tag the opt-in pointer with custom class.
7310
+ $('.wp-pointer #fs_connect')
7311
+ .parents('.wp-pointer.wp-pointer-top')
7312
+ .addClass('fs-opt-in-pointer');
7313
+
7314
+ ", 'element', 'optin' ) ?>
7315
+ }
7316
+ }
7317
+ });
7318
+ // ]]></script>
7319
+ <?php
7320
+ }
7321
+
7322
+ /**
7323
+ * Return current page's URL.
7324
+ *
7325
+ * @author Vova Feldman (@svovaf)
7326
+ * @since 1.0.7
7327
+ *
7328
+ * @return string
7329
+ */
7330
+ function current_page_url() {
7331
+ $url = 'http';
7332
+
7333
+ if ( isset( $_SERVER["HTTPS"] ) ) {
7334
+ if ( $_SERVER["HTTPS"] == "on" ) {
7335
+ $url .= "s";
7336
+ }
7337
+ }
7338
+ $url .= "://";
7339
+ if ( $_SERVER["SERVER_PORT"] != "80" ) {
7340
+ $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
7341
+ } else {
7342
+ $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
7343
+ }
7344
+
7345
+ return esc_url( $url );
7346
+ }
7347
+
7348
+ /**
7349
+ * Check if the current page is the plugin's main admin settings page.
7350
+ *
7351
+ * @author Vova Feldman (@svovaf)
7352
+ * @since 1.0.7
7353
+ *
7354
+ * @return bool
7355
+ */
7356
+ function _is_plugin_page() {
7357
+ return fs_is_plugin_page( $this->_menu->get_raw_slug() ) ||
7358
+ fs_is_plugin_page( $this->_slug );
7359
+ }
7360
+
7361
+ /* Events
7362
+ ------------------------------------------------------------------------------------------------------------------*/
7363
+ /**
7364
+ * Delete site install from Database.
7365
+ *
7366
+ * @author Vova Feldman (@svovaf)
7367
+ * @since 1.0.1
7368
+ *
7369
+ * @param bool $store
7370
+ * @param int|null $blog_id Since 2.0.0
7371
+ *
7372
+ * @return false|int The install ID if deleted. Otherwise, FALSE (when install not exist).
7373
+ */
7374
+ function _delete_site( $store = true, $blog_id = null ) {
7375
+ return self::_delete_site_by_slug( $this->_slug, $this->_module_type, $store, $blog_id );
7376
+ }
7377
+
7378
+ /**
7379
+ * Delete site install from Database.
7380
+ *
7381
+ * @author Vova Feldman (@svovaf)
7382
+ * @since 1.2.2.7
7383
+ *
7384
+ * @param string $slug
7385
+ * @param string $module_type
7386
+ * @param bool $store
7387
+ * @param int|null $blog_id Since 2.0.0
7388
+ *
7389
+ * @return false|int The install ID if deleted. Otherwise, FALSE (when install not exist).
7390
+ */
7391
+ static function _delete_site_by_slug( $slug, $module_type, $store = true, $blog_id = null ) {
7392
+ $sites = self::get_all_sites( $module_type, $blog_id );
7393
+
7394
+ $install_id = false;
7395
+
7396
+ if ( isset( $sites[ $slug ] ) ) {
7397
+ if ( is_object( $sites[ $slug ] ) ) {
7398
+ $install_id = $sites[ $slug ]->id;
7399
+ }
7400
+
7401
+ unset( $sites[ $slug ] );
7402
+
7403
+ self::set_account_option_by_module( $module_type, 'sites', $sites, $store, $blog_id );
7404
+ }
7405
+
7406
+ return $install_id;
7407
+ }
7408
+
7409
+ /**
7410
+ * Delete user.
7411
+ *
7412
+ * @author Vova Feldman (@svovaf)
7413
+ * @since 2.0.0
7414
+ *
7415
+ * @param number $user_id
7416
+ * @param bool $store
7417
+ *
7418
+ * @return false|int The user ID if deleted. Otherwise, FALSE (when install not exist).
7419
+ */
7420
+ private static function delete_user( $user_id, $store = true ) {
7421
+ $users = self::get_all_users();
7422
+
7423
+ if ( ! is_array( $users ) || ! isset( $users[ $user_id ] ) ) {
7424
+ return false;
7425
+ }
7426
+
7427
+ unset( $users[ $user_id ] );
7428
+
7429
+ self::$_accounts->set_option( 'users', $users, $store );
7430
+
7431
+ return $user_id;
7432
+ }
7433
+
7434
+ /**
7435
+ * Delete plugin's plans information.
7436
+ *
7437
+ * @param bool $store Flush to Database if true.
7438
+ * @param bool $keep_associated_plans If set to false, delete all plans, even if a plan is associated with an install.
7439
+ *
7440
+ * @author Vova Feldman (@svovaf)
7441
+ * @since 1.0.9
7442
+ */
7443
+ private function _delete_plans( $store = true, $keep_associated_plans = true ) {
7444
+ $this->_logger->entrance();
7445
+
7446
+ $plans = self::get_all_plans( $this->_module_type );
7447
+
7448
+ $plans_to_keep = array();
7449
+
7450
+ if ( $keep_associated_plans ) {
7451
+ $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs();
7452
+ foreach ( $plans_ids_to_keep as $plan_id ) {
7453
+ $plan = self::_get_plan_by_id( $plan_id );
7454
+ if ( is_object( $plan ) ) {
7455
+ $plans_to_keep[] = self::_encrypt_entity( $plan );
7456
+ }
7457
+ }
7458
+ }
7459
+
7460
+ if ( ! empty( $plans_to_keep ) ) {
7461
+ $plans[ $this->_slug ] = $plans_to_keep;
7462
+ } else {
7463
+ unset( $plans[ $this->_slug ] );
7464
+ }
7465
+
7466
+ $this->set_account_option( 'plans', $plans, $store );
7467
+ }
7468
+
7469
+ /**
7470
+ * Delete all plugin licenses.
7471
+ *
7472
+ * @author Vova Feldman (@svovaf)
7473
+ * @since 1.0.9
7474
+ *
7475
+ * @param bool $store
7476
+ */
7477
+ private function _delete_licenses( $store = true ) {
7478
+ $this->_logger->entrance();
7479
+
7480
+ $all_licenses = self::get_all_licenses();
7481
+
7482
+ unset( $all_licenses[ $this->_module_id ] );
7483
+
7484
+ self::$_accounts->set_option( 'all_licenses', $all_licenses, $store );
7485
+ }
7486
+
7487
+ /**
7488
+ * Check if Freemius was added on new plugin installation.
7489
+ *
7490
+ * @author Vova Feldman (@svovaf)
7491
+ * @since 1.1.5
7492
+ *
7493
+ * @return bool
7494
+ */
7495
+ function is_plugin_new_install() {
7496
+ return isset( $this->_storage->is_plugin_new_install ) &&
7497
+ $this->_storage->is_plugin_new_install;
7498
+ }
7499
+
7500
+ /**
7501
+ * Check if it's the first plugin release that is running Freemius.
7502
+ *
7503
+ * @author Vova Feldman (@svovaf)
7504
+ * @since 1.2.1.5
7505
+ *
7506
+ * @return bool
7507
+ */
7508
+ function is_first_freemius_powered_version() {
7509
+ return empty( $this->_storage->plugin_last_version );
7510
+ }
7511
+
7512
+ /**
7513
+ * @author Leo Fajardo (@leorw)
7514
+ * @since 1.2.2
7515
+ *
7516
+ * @return bool|string
7517
+ */
7518
+ private function get_previous_theme_slug() {
7519
+ return isset( $this->_storage->previous_theme ) ?
7520
+ $this->_storage->previous_theme :
7521
+ false;
7522
+ }
7523
+
7524
+ /**
7525
+ * @author Leo Fajardo (@leorw)
7526
+ * @since 1.2.2
7527
+ *
7528
+ * @return string
7529
+ */
7530
+ private function can_activate_previous_theme() {
7531
+ $slug = $this->get_previous_theme_slug();
7532
+ if ( false !== $slug && current_user_can( 'switch_themes' ) ) {
7533
+ $theme_instance = wp_get_theme( $slug );
7534
+
7535
+ return $theme_instance->exists();
7536
+ }
7537
+
7538
+ return false;
7539
+ }
7540
+
7541
+ /**
7542
+ * @author Leo Fajardo (@leorw)
7543
+ * @since 1.2.2
7544
+ */
7545
+ private function activate_previous_theme() {
7546
+ switch_theme( $this->get_previous_theme_slug() );
7547
+ unset( $this->_storage->previous_theme );
7548
+
7549
+ global $pagenow;
7550
+ if ( 'themes.php' === $pagenow ) {
7551
+ /**
7552
+ * Refresh the active theme information.
7553
+ *
7554
+ * @author Leo Fajardo (@leorw)
7555
+ * @since 1.2.2
7556
+ */
7557
+ fs_redirect( $this->admin_url( $pagenow ) );
7558
+ }
7559
+ }
7560
+
7561
+ /**
7562
+ * @author Leo Fajardo (@leorw)
7563
+ * @since 1.2.2
7564
+ *
7565
+ * @return string
7566
+ */
7567
+ function get_previous_theme_activation_url() {
7568
+ if ( ! $this->can_activate_previous_theme() ) {
7569
+ return '';
7570
+ }
7571
+
7572
+ /**
7573
+ * Activation URL
7574
+ *
7575
+ * @author Leo Fajardo (@leorw)
7576
+ * @since 1.2.2
7577
+ */
7578
+ return wp_nonce_url(
7579
+ $this->admin_url( 'themes.php?action=activate&stylesheet=' . urlencode( $this->get_previous_theme_slug() ) ),
7580
+ 'switch-theme_' . $this->get_previous_theme_slug()
7581
+ );
7582
+ }
7583
+
7584
+ /**
7585
+ * Saves the slug of the previous theme if it still exists so that it can be used by the logic in the opt-in
7586
+ * form that decides whether to add a close button to the opt-in dialog or not. So after a premium-only theme is
7587
+ * activated, the close button will appear and will reactivate the previous theme if clicked. If the previous
7588
+ * theme doesn't exist, then there will be no close button.
7589
+ *
7590
+ * @author Leo Fajardo (@leorw)
7591
+ * @since 1.2.2
7592
+ *
7593
+ * @param string $slug_or_name Old theme's slug or name.
7594
+ * @param bool|WP_Theme $old_theme WP_Theme instance of the old theme if it still exists.
7595
+ */
7596
+ function _activate_theme_event_hook( $slug_or_name, $old_theme = false ) {
7597
+ $this->_storage->previous_theme = ( false !== $old_theme ) ?
7598
+ $old_theme->get_stylesheet() :
7599
+ $slug_or_name;
7600
+
7601
+ $this->_activate_plugin_event_hook();
7602
+ }
7603
+
7604
+ /**
7605
+ * Plugin activated hook.
7606
+ *
7607
+ * @author Vova Feldman (@svovaf)
7608
+ * @since 1.0.1
7609
+ *
7610
+ * @uses FS_Api
7611
+ */
7612
+ function _activate_plugin_event_hook() {
7613
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
7614
+
7615
+ if ( ! $this->is_user_admin() ) {
7616
+ return;
7617
+ }
7618
+
7619
+ $this->unregister_uninstall_hook();
7620
+
7621
+ // Clear API cache on activation.
7622
+ FS_Api::clear_cache();
7623
+
7624
+ $is_premium_version_activation = $this->is_plugin() ?
7625
+ ( current_filter() !== ( 'activate_' . $this->_free_plugin_basename ) ) :
7626
+ $this->is_premium();
7627
+
7628
+ $this->_logger->info( 'Activating ' . ( $is_premium_version_activation ? 'premium' : 'free' ) . ' plugin version.' );
7629
+
7630
+ if ( $this->is_plugin() ) {
7631
+ // This logic is relevant only to plugins since both the free and premium versions of a plugin can be active at the same time.
7632
+ // 1. If running in the activation of the FREE module, get the basename of the PREMIUM.
7633
+ // 2. If running in the activation of the PREMIUM module, get the basename of the FREE.
7634
+ $other_version_basename = $is_premium_version_activation ?
7635
+ $this->_free_plugin_basename :
7636
+ $this->premium_plugin_basename();
7637
+
7638
+ if ( ! $this->_is_network_active ) {
7639
+ /**
7640
+ * Themes are always network activated, but the ACTUAL activation is per site.
7641
+ *
7642
+ * During the activation, the plugin isn't yet active, therefore,
7643
+ * _is_network_active will be set to false even if it's a network level
7644
+ * activation. So we need to fix that by looking at the is_network_admin() value.
7645
+ *
7646
+ * @author Vova Feldman
7647
+ */
7648
+ $this->_is_network_active = (
7649
+ $this->_is_multisite_integrated &&
7650
+ fs_is_network_admin()
7651
+ );
7652
+ }
7653
+
7654
+ /**
7655
+ * If the other module version is active, deactivate it.
7656
+ *
7657
+ * is_plugin_active() checks if the plugin is active on the site or the network level and
7658
+ * deactivate_plugins() deactivates the plugin whether it's activated on the site or network level.
7659
+ *
7660
+ * @author Leo Fajardo (@leorw)
7661
+ * @since 1.2.2
7662
+ */
7663
+ if ( is_plugin_active( $other_version_basename ) ) {
7664
+ deactivate_plugins( $other_version_basename );
7665
+ }
7666
+ }
7667
+
7668
+ if ( $this->is_registered() ) {
7669
+ if ( $is_premium_version_activation ) {
7670
+ $this->reconnect_locally();
7671
+ }
7672
+
7673
+
7674
+ // Schedule re-activation event and sync.
7675
+ // $this->sync_install( array(), true );
7676
+ $this->schedule_install_sync();
7677
+
7678
+ // If activating the premium module version, add an admin notice to congratulate for an upgrade completion.
7679
+ if ( $is_premium_version_activation ) {
7680
+ $this->_admin_notices->add(
7681
+ sprintf( $this->get_text_inline( 'The upgrade of %s was successfully completed.', 'successful-version-upgrade-message' ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
7682
+ $this->get_text_x_inline( 'W00t',
7683
+ 'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
7684
+ );
7685
+ }
7686
+ } else if ( $this->is_anonymous() ) {
7687
+ if ( isset( $this->_storage->is_anonymous_ms ) && $this->_storage->is_anonymous_ms['is'] ) {
7688
+ $plugin_version = $this->_storage->is_anonymous_ms['version'];
7689
+ $network = true;
7690
+ } else {
7691
+ $plugin_version = $this->_storage->is_anonymous['version'];
7692
+ $network = false;
7693
+ }
7694
+
7695
+ /**
7696
+ * Reset "skipped" click cache on the following:
7697
+ * 1. Freemius DEV mode.
7698
+ * 2. WordPress DEBUG mode.
7699
+ * 3. If a plugin and the user skipped the exact same version before.
7700
+ *
7701
+ * @since 1.2.2.7 Ulrich Pogson (@grapplerulrich) asked to not reset the SKIPPED flag if the exact same THEME version was activated before unless the developer is running with WP_DEBUG on, or Freemius debug mode on (WP_FS__DEV_MODE).
7702
+ *
7703
+ * @todo 4. If explicitly asked to retry after every activation.
7704
+ */
7705
+ if ( WP_FS__DEV_MODE ||
7706
+ (
7707
+ ( $this->is_plugin() || ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) &&
7708
+ $this->get_plugin_version() == $plugin_version
7709
+ )
7710
+ ) {
7711
+ $this->reset_anonymous_mode( $network );
7712
+ }
7713
+ }
7714
+
7715
+ $is_trial_or_has_features_enabled_license = ( $this->is_trial() || $this->has_features_enabled_license() );
7716
+
7717
+ if ( $this->is_addon() && ! $is_trial_or_has_features_enabled_license ) {
7718
+ /**
7719
+ * When activating an add-on, try to also activate a license.
7720
+ *
7721
+ * @author Leo Fajardo (@leorw)
7722
+ * @since 2.3.0
7723
+ */
7724
+ if ( ! $this->_is_network_active ) {
7725
+ $this->maybe_activate_addon_license();
7726
+ } else {
7727
+ $this->maybe_network_activate_addon_license();
7728
+ }
7729
+
7730
+ /**
7731
+ * Avoid redirecting to the license activation screen after automatically activating an add-on license.
7732
+ *
7733
+ * @author Leo Fajardo (@leorw)
7734
+ * @since 2.3.0
7735
+ */
7736
+ $is_trial_or_has_features_enabled_license = ( $this->is_trial() || $this->has_features_enabled_license() );
7737
+
7738
+ if ( $is_trial_or_has_features_enabled_license && true === $this->_storage->require_license_activation ) {
7739
+ $this->_storage->require_license_activation = false;
7740
+ }
7741
+ }
7742
+
7743
+ if (
7744
+ $is_premium_version_activation &&
7745
+ (
7746
+ ( ! $this->is_registered() && $this->is_anonymous() ) ||
7747
+ (
7748
+ $this->is_registered() &&
7749
+ ! $is_trial_or_has_features_enabled_license
7750
+ )
7751
+ )
7752
+ ) {
7753
+ $this->_storage->require_license_activation = true;
7754
+ }
7755
+
7756
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
7757
+ /**
7758
+ * If no previous version of plugin's version exist, it means that it's either
7759
+ * the first time that the plugin installed on the site, or the plugin was installed
7760
+ * before but didn't have Freemius integrated.
7761
+ *
7762
+ * Since register_activation_hook() do NOT fires on updates since 3.1, and only fires
7763
+ * on manual activation via the dashboard, is_plugin_activation() is TRUE
7764
+ * only after immediate activation.
7765
+ *
7766
+ * @since 1.1.4
7767
+ * @link https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
7768
+ */
7769
+ $this->_storage->is_plugin_new_install = empty( $this->_storage->plugin_last_version );
7770
+ }
7771
+
7772
+ if ( ! $this->_anonymous_mode &&
7773
+ $this->has_api_connectivity( WP_FS__DEV_MODE ) &&
7774
+ ! $this->_isAutoInstall
7775
+ ) {
7776
+ // Store hint that the plugin was just activated to enable auto-redirection to settings.
7777
+ set_transient( "fs_{$this->_module_type}_{$this->_slug}_activated", true, 60 );
7778
+ }
7779
+
7780
+ /**
7781
+ * Activation hook is executed after the plugin's main file is loaded, therefore,
7782
+ * after the plugin was loaded. The logic is located at activate_plugin()
7783
+ * ./wp-admin/includes/plugin.php.
7784
+ *
7785
+ * @author Vova Feldman (@svovaf)
7786
+ * @since 1.1.9
7787
+ */
7788
+ $this->_storage->was_plugin_loaded = true;
7789
+ }
7790
+
7791
+ /**
7792
+ * @author Leo Fajardo (@leorw)
7793
+ * @since 2.3.0
7794
+ */
7795
+ private function maybe_activate_addon_license() {
7796
+ $parent_fs = $this->get_parent_instance();
7797
+
7798
+ if (
7799
+ ! is_object( $parent_fs ) ||
7800
+ ( ! $parent_fs->is_registered() && ! $parent_fs->is_network_registered() )
7801
+ ) {
7802
+ // Try to activate a license only if the parent plugin is active and has a valid `install`.
7803
+ return;
7804
+ }
7805
+
7806
+ $license = $this->get_addon_active_parent_license();
7807
+ if ( ! is_object( $license ) ) {
7808
+ return;
7809
+ }
7810
+
7811
+ if ( ! $this->is_registered() ) {
7812
+ // Opt in with a license key.
7813
+ $this->opt_in(
7814
+ $parent_fs->get_current_or_network_user()->email,
7815
+ false,
7816
+ false,
7817
+ $license->secret_key
7818
+ );
7819
+ } else {
7820
+ // Activate the license.
7821
+ $install = $this->get_api_site_scope()->call(
7822
+ '/',
7823
+ 'put',
7824
+ array( 'license_key' => $this->apply_filters( 'license_key', $license->secret_key ) )
7825
+ );
7826
+
7827
+ if ( ! FS_Api::is_api_error( $install ) ) {
7828
+ $this->_sync_addon_license( $this->get_id(), true );
7829
+ }
7830
+ }
7831
+ }
7832
+
7833
+
7834
+ /**
7835
+ * @author Leo Fajardo (@leorw)
7836
+ * @since 2.3.0
7837
+ *
7838
+ * @param FS_Plugin_License $license
7839
+ */
7840
+ private function maybe_network_activate_addon_license( $license = null ) {
7841
+ $parent_fs = $this->get_parent_instance();
7842
+ if ( ! is_object( $parent_fs ) || ( ! $parent_fs->is_registered() && ! $parent_fs->is_network_registered() ) ) {
7843
+ // Try to activate a license only if the parent plugin is active and has a valid `install`.
7844
+ return;
7845
+ }
7846
+
7847
+ $license = ( ! is_null( $license ) ) ?
7848
+ $license :
7849
+ $this->get_addon_active_parent_license();
7850
+
7851
+ if ( ! is_object( $license ) ) {
7852
+ return;
7853
+ }
7854
+
7855
+ if ( ! $this->is_network_registered() ) {
7856
+ $sites = $this->get_sites_for_network_level_optin();
7857
+
7858
+ if ( count( $sites ) > $license->left() ) {
7859
+ // If the add-on is network active, try to activate the license only if it can be activated on all sites.
7860
+ return;
7861
+ }
7862
+
7863
+ // Opt in with a license key.
7864
+ $this->opt_in(
7865
+ $parent_fs->get_user()->email,
7866
+ false,
7867
+ false,
7868
+ $license->secret_key,
7869
+ false,
7870
+ false,
7871
+ false,
7872
+ null,
7873
+ $sites
7874
+ );
7875
+ } else {
7876
+ $blog_2_install_map = array();
7877
+ $site_ids = array();
7878
+
7879
+ $all_sites = Freemius::get_sites();
7880
+
7881
+ foreach ( $all_sites as $site ) {
7882
+ $blog_id = Freemius::get_site_blog_id( $site );
7883
+ $install = $this->get_install_by_blog_id( $blog_id );
7884
+
7885
+ if ( is_object( $install ) && FS_Plugin_License::is_valid_id( $install->license_id ) ) {
7886
+ // Skip license activation for installs that are already associated with a license.
7887
+ continue;
7888
+ }
7889
+
7890
+ if ( is_object( $install ) ) {
7891
+ $blog_2_install_map[ $blog_id ] = $install;
7892
+ } else {
7893
+ $site_ids[] = $blog_id;
7894
+ }
7895
+ }
7896
+
7897
+ if ( ( count( $blog_2_install_map ) + count( $site_ids ) ) > $license->left() ) {
7898
+ return;
7899
+ }
7900
+
7901
+ $user = $this->get_current_or_network_user();
7902
+
7903
+ if ( ! empty( $blog_2_install_map ) ) {
7904
+ $result = $this->activate_license_on_many_installs( $user, $license->secret_key, $blog_2_install_map );
7905
+
7906
+ if ( true !== $result ) {
7907
+ return;
7908
+ }
7909
+ }
7910
+
7911
+ if ( ! empty( $site_ids ) ) {
7912
+ $this->activate_license_on_many_sites( $user, $license->secret_key, $site_ids );
7913
+ }
7914
+ }
7915
+ }
7916
+
7917
+ /**
7918
+ * @author Leo Fajardo (@leorw)
7919
+ * @since 2.3.0
7920
+ *
7921
+ * @return FS_Plugin_License
7922
+ */
7923
+ private function get_addon_active_parent_license() {
7924
+ $parent_licenses_endpoint = "/plugins/{$this->get_id()}/parent_licenses.json?filter=activatable";
7925
+ $parent_instance = $this->get_parent_instance();
7926
+
7927
+ $foreign_licenses = $parent_instance->get_foreign_licenses_info(
7928
+ self::get_all_licenses( $this->get_parent_id() )
7929
+ );
7930
+
7931
+ if ( ! empty ( $foreign_licenses ) ) {
7932
+ $foreign_licenses = array(
7933
+ // Prefix with `+` to tell the server to include foreign licenses in the licenses collection.
7934
+ 'ids' => ( urlencode( '+' ) . implode( ',', $foreign_licenses['ids'] ) ),
7935
+ 'license_keys' => implode( ',', array_map( 'urlencode', $foreign_licenses['license_keys'] ) )
7936
+ );
7937
+
7938
+ $parent_licenses_endpoint = add_query_arg( $foreign_licenses, $parent_licenses_endpoint );
7939
+ }
7940
+
7941
+ $result = $parent_instance->get_current_or_network_user_api_scope()->get( $parent_licenses_endpoint, true );
7942
+
7943
+ if (
7944
+ ! $this->is_api_result_object( $result, 'licenses' ) ||
7945
+ ! is_array( $result->licenses ) ||
7946
+ empty( $result->licenses )
7947
+ ) {
7948
+ return null;
7949
+ }
7950
+
7951
+ $license = new FS_Plugin_License( $result->licenses[ 0 ] );
7952
+
7953
+ return $license;
7954
+ }
7955
+
7956
+ /**
7957
+ * @author Leo Fajardo (@leorw)
7958
+ * @since 2.3.0
7959
+ *
7960
+ * @return array
7961
+ */
7962
+ function get_sites_for_network_level_optin() {
7963
+ $sites = array();
7964
+ $all_sites = self::get_sites();
7965
+
7966
+ foreach ( $all_sites as $site ) {
7967
+ $blog_id = self::get_site_blog_id( $site );
7968
+
7969
+ if ( ! $this->is_site_delegated_connection( $blog_id ) &&
7970
+ ! $this->is_installed_on_site( $blog_id )
7971
+ ) {
7972
+ $sites[] = $this->get_site_info( $site );
7973
+ }
7974
+ }
7975
+
7976
+ return $sites;
7977
+ }
7978
+
7979
+ /**
7980
+ * Delete account.
7981
+ *
7982
+ * @author Vova Feldman (@svovaf)
7983
+ * @since 1.0.3
7984
+ *
7985
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
7986
+ */
7987
+ function delete_account_event( $check_user = true ) {
7988
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
7989
+
7990
+ if ( $check_user && ! $this->is_user_admin() ) {
7991
+ return;
7992
+ }
7993
+
7994
+ $this->do_action( 'before_account_delete' );
7995
+
7996
+ // Clear all admin notices.
7997
+ $this->_admin_notices->clear_all_sticky( false );
7998
+
7999
+ $this->_delete_site( false );
8000
+
8001
+ $delete_network_common_data = true;
8002
+
8003
+ if ( $this->_is_network_active ) {
8004
+ $installs = $this->get_blog_install_map();
8005
+
8006
+ // Don't delete common network data unless no other installs left.
8007
+ $delete_network_common_data = empty( $installs );
8008
+ }
8009
+
8010
+ if ( $delete_network_common_data ) {
8011
+ $this->_delete_plans( false );
8012
+
8013
+ $this->_delete_licenses( false );
8014
+
8015
+ // Delete add-ons related to plugin's account.
8016
+ $this->_delete_account_addons( false );
8017
+ }
8018
+
8019
+ // @todo Delete plans and licenses of add-ons.
8020
+
8021
+ self::$_accounts->store();
8022
+
8023
+ /**
8024
+ * IMPORTANT:
8025
+ * Clear crons must be executed before clearing all storage.
8026
+ * Otherwise, the cron will not be cleared.
8027
+ */
8028
+ if ( $delete_network_common_data ) {
8029
+ $this->clear_sync_cron();
8030
+ }
8031
+
8032
+ $this->clear_install_sync_cron();
8033
+
8034
+ // Clear all storage data.
8035
+ $this->_storage->clear_all( true, array(
8036
+ 'is_delegated_connection',
8037
+ 'connectivity_test',
8038
+ 'is_on',
8039
+ ), false );
8040
+
8041
+ // Send delete event.
8042
+ $this->get_api_site_scope()->call( '/', 'delete' );
8043
+
8044
+ $this->do_action( 'after_account_delete' );
8045
+ }
8046
+
8047
+ /**
8048
+ * Delete network level account.
8049
+ *
8050
+ * @author Vova Feldman (@svovaf)
8051
+ * @since 2.0.0
8052
+ *
8053
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
8054
+ */
8055
+ function delete_network_account_event( $check_user = true ) {
8056
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
8057
+
8058
+ if ( $check_user && ! $this->is_user_admin() ) {
8059
+ return;
8060
+ }
8061
+
8062
+ $this->do_action( 'before_network_account_delete' );
8063
+
8064
+ // Clear all admin notices.
8065
+ $this->_admin_notices->clear_all_sticky();
8066
+
8067
+ $this->_delete_plans( false, false );
8068
+
8069
+ $this->_delete_licenses( false );
8070
+
8071
+ // Delete add-ons related to plugin's account.
8072
+ $this->_delete_account_addons( false );
8073
+
8074
+ // @todo Delete plans and licenses of add-ons.
8075
+
8076
+ self::$_accounts->store( true );
8077
+
8078
+ /**
8079
+ * IMPORTANT:
8080
+ * Clear crons must be executed before clearing all storage.
8081
+ * Otherwise, the cron will not be cleared.
8082
+ */
8083
+ $this->clear_sync_cron( true );
8084
+ $this->clear_install_sync_cron( true );
8085
+
8086
+ $sites = self::get_sites();
8087
+
8088
+ $install_ids = array();
8089
+ foreach ( $sites as $site ) {
8090
+ $blog_id = self::get_site_blog_id( $site );
8091
+
8092
+ if ( $this->is_site_delegated_connection( $blog_id ) ) {
8093
+ continue;
8094
+ }
8095
+
8096
+ $install_id = $this->_delete_site( true, $blog_id );
8097
+
8098
+ // Clear all storage data.
8099
+ $this->_storage->clear_all( true, array( 'connectivity_test' ), $blog_id );
8100
+
8101
+ if ( FS_Site::is_valid_id( $install_id ) ) {
8102
+ $install_ids[] = $install_id;
8103
+ }
8104
+
8105
+ switch_to_blog( $blog_id );
8106
+
8107
+ $this->do_action( 'after_account_delete' );
8108
+
8109
+ restore_current_blog();
8110
+ }
8111
+
8112
+ $this->_storage->clear_all( true, array(
8113
+ 'connectivity_test',
8114
+ 'is_on',
8115
+ ), true );
8116
+
8117
+ // Send delete event.
8118
+ if ( ! empty( $install_ids ) ) {
8119
+ $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json?ids=" . implode( ',', $install_ids ), 'delete' );
8120
+ }
8121
+
8122
+ $this->do_action( 'after_network_account_delete' );
8123
+ }
8124
+
8125
+ /**
8126
+ * Plugin deactivation hook.
8127
+ *
8128
+ * @author Vova Feldman (@svovaf)
8129
+ * @since 1.0.1
8130
+ */
8131
+ function _deactivate_plugin_hook() {
8132
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
8133
+
8134
+ if ( ! $this->is_user_admin() ) {
8135
+ return;
8136
+ }
8137
+
8138
+ $is_network_deactivation = fs_is_network_admin();
8139
+ $storage_keys_for_removal = array();
8140
+
8141
+ $this->_admin_notices->clear_all_sticky();
8142
+
8143
+ $storage_keys_for_removal[] = 'sticky_optin_added';
8144
+ if ( isset( $this->_storage->sticky_optin_added ) ) {
8145
+ unset( $this->_storage->sticky_optin_added );
8146
+ }
8147
+
8148
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
8149
+ // Remember that plugin was already installed.
8150
+ $this->_storage->is_plugin_new_install = false;
8151
+ }
8152
+
8153
+ // Hook to plugin uninstall.
8154
+ register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );
8155
+
8156
+ $this->clear_module_main_file_cache();
8157
+ $this->clear_sync_cron( $this->_is_network_active );
8158
+ $this->clear_install_sync_cron();
8159
+
8160
+ if ( $this->is_registered() ) {
8161
+ if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
8162
+ FS_Plugin_Updater::instance( $this )->delete_update_data();
8163
+ }
8164
+
8165
+ if ( $is_network_deactivation ) {
8166
+ // Send deactivation event.
8167
+ $this->sync_installs( array(
8168
+ 'is_active' => false,
8169
+ ) );
8170
+ } else {
8171
+ // Send deactivation event.
8172
+ $this->sync_install( array(
8173
+ 'is_active' => false,
8174
+ ) );
8175
+ }
8176
+ } else {
8177
+ if ( ! $this->has_api_connectivity() ) {
8178
+ // Reset connectivity test cache.
8179
+ unset( $this->_storage->connectivity_test );
8180
+
8181
+ $storage_keys_for_removal[] = 'connectivity_test';
8182
+ }
8183
+ }
8184
+
8185
+ if ( $is_network_deactivation ) {
8186
+ if ( isset( $this->_storage->sticky_optin_added_ms ) ) {
8187
+ unset( $this->_storage->sticky_optin_added_ms );
8188
+ }
8189
+
8190
+ if ( ! empty( $storage_keys_for_removal ) ) {
8191
+ $sites = self::get_sites();
8192
+
8193
+ foreach ( $sites as $site ) {
8194
+ $blog_id = self::get_site_blog_id( $site );
8195
+
8196
+ foreach ( $storage_keys_for_removal as $key ) {
8197
+ $this->_storage->remove( $key, false, $blog_id );
8198
+ }
8199
+
8200
+ $this->_storage->save( $blog_id );
8201
+ }
8202
+ }
8203
+ }
8204
+
8205
+ // Clear API cache on deactivation.
8206
+ FS_Api::clear_cache();
8207
+
8208
+ $this->remove_sdk_reference();
8209
+ }
8210
+
8211
+ /**
8212
+ * @author Vova Feldman (@svovaf)
8213
+ * @since 1.1.6
8214
+ */
8215
+ private function remove_sdk_reference() {
8216
+ global $fs_active_plugins;
8217
+
8218
+ foreach ( $fs_active_plugins->plugins as $sdk_path => $data ) {
8219
+ if ( $this->_plugin_basename == $data->plugin_path ) {
8220
+ unset( $fs_active_plugins->plugins[ $sdk_path ] );
8221
+ break;
8222
+ }
8223
+ }
8224
+
8225
+ fs_fallback_to_newest_active_sdk();
8226
+ }
8227
+
8228
+ /**
8229
+ * @author Vova Feldman (@svovaf)
8230
+ * @since 1.1.3
8231
+ *
8232
+ * @param bool $is_anonymous
8233
+ * @param bool|int $network_or_blog_id Since 2.0.0
8234
+ */
8235
+ private function set_anonymous_mode( $is_anonymous = true, $network_or_blog_id = 0 ) {
8236
+ // Store information regarding skip to try and opt-in the user
8237
+ // again in the future.
8238
+ $skip_info = array(
8239
+ 'is' => $is_anonymous,
8240
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
8241
+ 'version' => $this->get_plugin_version(),
8242
+ );
8243
+
8244
+ if ( true === $network_or_blog_id ) {
8245
+ $this->_storage->is_anonymous_ms = $skip_info;
8246
+ } else {
8247
+ $this->_storage->store( 'is_anonymous', $skip_info, $network_or_blog_id );
8248
+ }
8249
+
8250
+ $this->network_upgrade_mode_completed();
8251
+
8252
+ // Update anonymous mode cache.
8253
+ $this->_is_anonymous = $is_anonymous;
8254
+ }
8255
+
8256
+ /**
8257
+ * @author Vova Feldman (@svovaf)
8258
+ * @since 2.0.0
8259
+ *
8260
+ * @param int $blog_id Site ID.
8261
+ * @param int $user_id User ID.
8262
+ * @param string $domain Site domain.
8263
+ * @param string $path Site path.
8264
+ * @param int $network_id Network ID. Only relevant on multi-network installations.
8265
+ * @param array $meta Metadata. Used to set initial site options.
8266
+ *
8267
+ * @uses Freemius::is_license_network_active() to check if the context license was network activated by the super-admin.
8268
+ * @uses Freemius::is_network_connected() to check if the super-admin network opted-in.
8269
+ * @uses Freemius::is_network_anonymous() to check if the super-admin network skipped.
8270
+ * @uses Freemius::is_network_delegated_connection() to check if the super-admin network delegated the connection to the site admins.
8271
+ */
8272
+ function _after_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) {
8273
+ $this->_logger->entrance();
8274
+
8275
+ if ( $this->is_premium() &&
8276
+ $this->is_network_connected() &&
8277
+ is_object( $this->_license ) &&
8278
+ $this->_license->can_activate( FS_Site::is_localhost_by_address( $domain ) ) &&
8279
+ $this->is_license_network_active( $blog_id )
8280
+ ) {
8281
+ /**
8282
+ * Running the premium version, the license was network activated, and the license can also be activated on the current site -> so try to opt-in with the license key.
8283
+ */
8284
+ $current_blog_id = get_current_blog_id();
8285
+ $license = clone $this->_license;
8286
+
8287
+ $this->switch_to_blog( $blog_id );
8288
+
8289
+ // Opt-in with network user.
8290
+ $this->install_with_user(
8291
+ $this->get_network_user(),
8292
+ $license->secret_key,
8293
+ false,
8294
+ false,
8295
+ false
8296
+ );
8297
+
8298
+ if ( is_object( $this->_site ) ) {
8299
+ if ( $this->_site->license_id == $license->id ) {
8300
+ /**
8301
+ * If the license was activated successfully, sync the license data from the remote server.
8302
+ */
8303
+ $this->_license = $license;
8304
+ $this->sync_site_license();
8305
+ }
8306
+ }
8307
+
8308
+ $this->switch_to_blog( $current_blog_id );
8309
+
8310
+ if ( is_object( $this->_site ) ) {
8311
+ // Already connected (with or without a license), so no need to continue.
8312
+ return;
8313
+ }
8314
+ }
8315
+
8316
+ if ( $this->is_network_anonymous() ) {
8317
+ /**
8318
+ * Opt-in was network skipped so automatically skip the opt-in for the new site.
8319
+ */
8320
+ $this->skip_site_connection( $blog_id );
8321
+ } else if ( $this->is_network_delegated_connection() ) {
8322
+ /**
8323
+ * Opt-in was network delegated so automatically delegate the opt-in for the new site's admin.
8324
+ */
8325
+ $this->delegate_site_connection( $blog_id );
8326
+ } else if ( $this->is_network_connected() ) {
8327
+ /**
8328
+ * Opt-in was network activated so automatically opt-in with the network user and new site admin.
8329
+ */
8330
+ $current_blog_id = get_current_blog_id();
8331
+
8332
+ $this->switch_to_blog( $blog_id );
8333
+
8334
+ // Opt-in with network user.
8335
+ $this->install_with_user(
8336
+ $this->get_network_user(),
8337
+ false,
8338
+ false,
8339
+ false,
8340
+ false
8341
+ );
8342
+
8343
+ $this->switch_to_blog( $current_blog_id );
8344
+ } else {
8345
+ /**
8346
+ * If the super-admin mixed different options (connect, skip, delegated):
8347
+ * a) If at least one site connection was delegated, then automatically delegate connection.
8348
+ * b) Otherwise, it means that at least one site was skipped and at least one site was connected. For a simplified UX in the initial release of the multisite network integration, skip the connection for the newly created site. If the super-admin will want to opt-in they can still do that from the network level Account page.
8349
+ */
8350
+ $has_delegated_site = false;
8351
+
8352
+ $sites = self::get_sites();
8353
+ foreach ( $sites as $site ) {
8354
+ $blog_id = self::get_site_blog_id( $site );
8355
+
8356
+ if ( $this->is_site_delegated_connection( $blog_id ) ) {
8357
+ $has_delegated_site = true;
8358
+ break;
8359
+ }
8360
+ }
8361
+
8362
+ if ( $has_delegated_site ) {
8363
+ $this->delegate_site_connection( $blog_id );
8364
+ } else {
8365
+ $this->skip_site_connection( $blog_id );
8366
+ }
8367
+ }
8368
+ }
8369
+
8370
+ /**
8371
+ * @author Vova Feldman (@svovaf)
8372
+ * @since 1.1.3
8373
+ *
8374
+ * @param bool|int $network_or_blog_id Since 2.0.0.
8375
+ */
8376
+ private function reset_anonymous_mode( $network_or_blog_id = 0 ) {
8377
+ if ( true === $network_or_blog_id ) {
8378
+ unset( $this->_storage->is_anonymous_ms );
8379
+ } else {
8380
+ $this->_storage->remove( 'is_anonymous', true, $network_or_blog_id );
8381
+ }
8382
+
8383
+ /**
8384
+ * Ensure that this field is also "false", otherwise, if the current module's type is "theme" and the module
8385
+ * has no menus, the opt-in popup will not be shown immediately (in this case, the user will have to click
8386
+ * on the admin notice that contains the opt-in link in order to trigger the opt-in popup).
8387
+ *
8388
+ * @author Leo Fajardo (@leorw)
8389
+ * @since 1.2.2
8390
+ */
8391
+ if ( ! $this->_is_network_active ||
8392
+ 0 === $network_or_blog_id ||
8393
+ get_current_blog_id() == $network_or_blog_id ||
8394
+ ( true === $network_or_blog_id && fs_is_network_admin() )
8395
+ ) {
8396
+ $this->_is_anonymous = null;
8397
+ }
8398
+ }
8399
+
8400
+ /**
8401
+ * This is used to ensure that before redirecting to the opt-in page after resetting the anonymous mode or
8402
+ * deleting the account in the network level, the URL of the page to redirect to is correct.
8403
+ *
8404
+ * @author Leo Fajardo (@leorw)
8405
+ *
8406
+ * @since 2.1.3
8407
+ */
8408
+ private function maybe_set_slug_and_network_menu_exists_flag() {
8409
+ if ( ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) {
8410
+ $this->_menu->set_slug_and_network_menu_exists_flag( $this->_menu->has_menu() ?
8411
+ $this->_menu->get_slug() :
8412
+ $this->_slug
8413
+ );
8414
+ }
8415
+ }
8416
+
8417
+ /**
8418
+ * Clears the anonymous mode and redirects to the opt-in screen.
8419
+ *
8420
+ * @author Vova Feldman (@svovaf)
8421
+ * @since 1.1.7
8422
+ */
8423
+ function connect_again() {
8424
+ if ( ! $this->is_anonymous() ) {
8425
+ return;
8426
+ }
8427
+
8428
+ $this->reset_anonymous_mode( fs_is_network_admin() );
8429
+
8430
+ $this->maybe_set_slug_and_network_menu_exists_flag();
8431
+
8432
+ fs_redirect( $this->get_activation_url() );
8433
+ }
8434
+
8435
+ /**
8436
+ * Skip account connect, and set anonymous mode.
8437
+ *
8438
+ * @author Vova Feldman (@svovaf)
8439
+ * @since 1.1.1
8440
+ *
8441
+ * @param array|null $sites Since 2.0.0. Specific sites.
8442
+ * @param bool $skip_all_network Since 2.0.0. If true, skip connection for all sites.
8443
+ */
8444
+ function skip_connection( $sites = null, $skip_all_network = false ) {
8445
+ $this->_logger->entrance();
8446
+
8447
+ $this->_admin_notices->remove_sticky( 'connect_account' );
8448
+
8449
+ if ( $skip_all_network ) {
8450
+ $this->set_anonymous_mode( true, true );
8451
+ }
8452
+
8453
+ if ( ! $skip_all_network && empty( $sites ) ) {
8454
+ $this->skip_site_connection();
8455
+ } else {
8456
+ $uids = array();
8457
+
8458
+ if ( $skip_all_network ) {
8459
+ $this->set_anonymous_mode( true, true );
8460
+
8461
+ $sites = self::get_sites();
8462
+ foreach ( $sites as $site ) {
8463
+ $blog_id = self::get_site_blog_id( $site );
8464
+ $this->skip_site_connection( $blog_id, false );
8465
+ $uids[] = $this->get_anonymous_id( $blog_id );
8466
+ }
8467
+ } else if ( ! empty( $sites ) ) {
8468
+ foreach ( $sites as $site ) {
8469
+ $uids[] = $site['uid'];
8470
+ $this->skip_site_connection( $site['blog_id'], false );
8471
+ }
8472
+ }
8473
+
8474
+ // Send anonymous skip event.
8475
+ // No user identified info nor any tracking will be sent after the user skips the opt-in.
8476
+ $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
8477
+ 'uids' => $uids,
8478
+ ) );
8479
+ }
8480
+
8481
+ $this->network_upgrade_mode_completed();
8482
+ }
8483
+
8484
+ /**
8485
+ * Skip connection for specific site in the network.
8486
+ *
8487
+ * @author Vova Feldman (@svovaf)
8488
+ * @since 2.0.0
8489
+ *
8490
+ * @param int|null $blog_id
8491
+ * @param bool $send_skip
8492
+ */
8493
+ private function skip_site_connection( $blog_id = null, $send_skip = true ) {
8494
+ $this->_logger->entrance();
8495
+
8496
+ $this->_admin_notices->remove_sticky( 'connect_account', $blog_id );
8497
+
8498
+ $this->set_anonymous_mode( true, $blog_id );
8499
+
8500
+ if ( $send_skip ) {
8501
+ $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
8502
+ 'uids' => array( $this->get_anonymous_id( $blog_id ) ),
8503
+ ) );
8504
+ }
8505
+ }
8506
+
8507
+ /**
8508
+ * Plugin version update hook.
8509
+ *
8510
+ * @author Vova Feldman (@svovaf)
8511
+ * @since 1.0.4
8512
+ */
8513
+ private function update_plugin_version_event() {
8514
+ $this->_logger->entrance();
8515
+
8516
+ if ( ! $this->is_registered() ) {
8517
+ return;
8518
+ }
8519
+
8520
+ $this->schedule_install_sync();
8521
+ // $this->sync_install( array(), true );
8522
+ }
8523
+
8524
+ /**
8525
+ * Generate an MD5 signature of a plugins collection.
8526
+ * This helper methods used to identify changes in a plugins collection.
8527
+ *
8528
+ * @author Vova Feldman (@svovaf)
8529
+ * @since 2.0.0
8530
+ *
8531
+ * @param array [string]array $plugins
8532
+ *
8533
+ * @return string
8534
+ */
8535
+ private function get_plugins_thumbprint( $plugins ) {
8536
+ ksort( $plugins );
8537
+
8538
+ $thumbprint = '';
8539
+ foreach ( $plugins as $basename => $data ) {
8540
+ $thumbprint .= $data['slug'] . ',' .
8541
+ $data['Version'] . ',' .
8542
+ ( $data['is_active'] ? '1' : '0' ) . ';';
8543
+ }
8544
+
8545
+ return md5( $thumbprint );
8546
+ }
8547
+
8548
+ /**
8549
+ * Return a list of modified plugins since the last sync.
8550
+ *
8551
+ * Note:
8552
+ * There's no point to store a plugins counter since even if the number of
8553
+ * plugins didn't change, we still need to check if the versions are all the
8554
+ * same and the activity state is similar.
8555
+ *
8556
+ * @author Vova Feldman (@svovaf)
8557
+ * @since 1.1.8
8558
+ *
8559
+ * @return array|false
8560
+ */
8561
+ private function get_plugins_data_for_api() {
8562
+ // Alias.
8563
+ $site_active_plugins_option_name = 'active_plugins';
8564
+ $network_plugins_option_name = 'all_plugins';
8565
+
8566
+ /**
8567
+ * Collection of all site level active plugins.
8568
+ */
8569
+ $site_active_plugins_cache = self::$_accounts->get_option( $site_active_plugins_option_name );
8570
+
8571
+ if ( ! is_object( $site_active_plugins_cache ) ) {
8572
+ $site_active_plugins_cache = (object) array(
8573
+ 'timestamp' => '',
8574
+ 'md5' => '',
8575
+ 'plugins' => array(),
8576
+ );
8577
+ }
8578
+
8579
+ $time = time();
8580
+
8581
+ if ( ! empty( $site_active_plugins_cache->timestamp ) &&
8582
+ ( $time - $site_active_plugins_cache->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
8583
+ ) {
8584
+ // Don't send plugin updates if last update was in the past 5 min.
8585
+ return false;
8586
+ }
8587
+
8588
+ // Write timestamp to lock the logic.
8589
+ $site_active_plugins_cache->timestamp = $time;
8590
+ self::$_accounts->set_option( $site_active_plugins_option_name, $site_active_plugins_cache, true );
8591
+
8592
+ // Reload options from DB.
8593
+ self::$_accounts->load( true );
8594
+ $site_active_plugins_cache = self::$_accounts->get_option( $site_active_plugins_option_name );
8595
+
8596
+ if ( $time != $site_active_plugins_cache->timestamp ) {
8597
+ // If timestamp is different, then another thread captured the lock.
8598
+ return false;
8599
+ }
8600
+
8601
+ /**
8602
+ * Collection of all plugins (network level).
8603
+ */
8604
+ $network_plugins_cache = self::$_accounts->get_option( $network_plugins_option_name );
8605
+
8606
+ if ( ! is_object( $network_plugins_cache ) ) {
8607
+ $network_plugins_cache = (object) array(
8608
+ 'timestamp' => '',
8609
+ 'md5' => '',
8610
+ 'plugins' => array(),
8611
+ );
8612
+ }
8613
+
8614
+ // Check if there's a change in plugins.
8615
+ $network_plugins = self::get_network_plugins();
8616
+ $site_active_plugins = self::get_site_active_plugins();
8617
+
8618
+ $network_plugins_thumbprint = $this->get_plugins_thumbprint( $network_plugins );
8619
+ $site_active_plugins_thumbprint = $this->get_plugins_thumbprint( $site_active_plugins );
8620
+
8621
+ // Check if plugins status changed (version or active/inactive).
8622
+ $network_plugins_changed = ( $network_plugins_cache->md5 !== $network_plugins_thumbprint );
8623
+ $site_active_plugins_changed = ( $site_active_plugins_cache->md5 !== $site_active_plugins_thumbprint );
8624
+
8625
+ if ( ! $network_plugins_changed &&
8626
+ ! $site_active_plugins_changed
8627
+ ) {
8628
+ // No changes.
8629
+ return array();
8630
+ }
8631
+
8632
+ $plugins_update_data = array();
8633
+
8634
+ foreach ( $network_plugins_cache->plugins as $basename => $data ) {
8635
+ if ( ! isset( $network_plugins[ $basename ] ) ) {
8636
+ // Plugin uninstalled.
8637
+ $uninstalled_plugin_data = $data;
8638
+ $uninstalled_plugin_data['is_active'] = false;
8639
+ $uninstalled_plugin_data['is_uninstalled'] = true;
8640
+ $plugins_update_data[] = $uninstalled_plugin_data;
8641
+
8642
+ unset( $network_plugins[ $basename ] );
8643
+
8644
+ unset( $network_plugins_cache->plugins[ $basename ] );
8645
+ unset( $site_active_plugins_cache->plugins[ $basename ] );
8646
+
8647
+ continue;
8648
+ }
8649
+
8650
+ $was_active = $data['is_active'] ||
8651
+ ( isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
8652
+ true === $site_active_plugins_cache->plugins[ $basename ]['is_active'] );
8653
+ $is_active = $network_plugins[ $basename ]['is_active'] ||
8654
+ ( isset( $site_active_plugins[ $basename ] ) &&
8655
+ $site_active_plugins[ $basename ]['is_active'] );
8656
+
8657
+ if ( ! isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
8658
+ isset( $site_active_plugins[ $basename ] )
8659
+ ) {
8660
+ // Plugin was site level activated.
8661
+ $site_active_plugins_cache->plugins[ $basename ] = $network_plugins[ $basename ];
8662
+ $site_active_plugins_cache->plugins[ $basename ]['is_active'] = true;
8663
+ } else if ( isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
8664
+ ! isset( $site_active_plugins[ $basename ] )
8665
+ ) {
8666
+ // Plugin was site level deactivated.
8667
+ unset( $site_active_plugins_cache->plugins[ $basename ] );
8668
+ }
8669
+
8670
+ $prev_version = $data['version'];
8671
+ $current_version = $network_plugins[ $basename ]['Version'];
8672
+
8673
+ if ( $was_active !== $is_active || $prev_version !== $current_version ) {
8674
+ // Plugin activated or deactivated, or version changed.
8675
+
8676
+ if ( $was_active !== $is_active ) {
8677
+ if ( $data['is_active'] != $network_plugins[ $basename ]['is_active'] ) {
8678
+ $network_plugins_cache->plugins[ $basename ]['is_active'] = $data['is_active'];
8679
+ }
8680
+ }
8681
+
8682
+ if ( $prev_version !== $current_version ) {
8683
+ $network_plugins_cache->plugins[ $basename ]['Version'] = $current_version;
8684
+ }
8685
+
8686
+ $updated_plugin_data = $data;
8687
+ $updated_plugin_data['is_active'] = $is_active;
8688
+ $updated_plugin_data['version'] = $current_version;
8689
+ $updated_plugin_data['title'] = $network_plugins[ $basename ]['Name'];
8690
+ $plugins_update_data[] = $updated_plugin_data;
8691
+ }
8692
+ }
8693
+
8694
+ // Find new plugins that weren't yet seen before.
8695
+ foreach ( $network_plugins as $basename => $data ) {
8696
+ if ( ! isset( $network_plugins_cache->plugins[ $basename ] ) ) {
8697
+ // New plugin.
8698
+ $new_plugin = array(
8699
+ 'slug' => $data['slug'],
8700
+ 'version' => $data['Version'],
8701
+ 'title' => $data['Name'],
8702
+ 'is_active' => $data['is_active'],
8703
+ 'is_uninstalled' => false,
8704
+ );
8705
+
8706
+ $plugins_update_data[] = $new_plugin;
8707
+ $network_plugins_cache->plugins[ $basename ] = $new_plugin;
8708
+
8709
+ if ( isset( $site_active_plugins[ $basename ] ) ) {
8710
+ $site_active_plugins_cache->plugins[ $basename ] = $new_plugin;
8711
+ $site_active_plugins_cache->plugins[ $basename ]['is_active'] = true;
8712
+ }
8713
+ }
8714
+ }
8715
+
8716
+ $site_active_plugins_cache->md5 = $site_active_plugins_thumbprint;
8717
+ $site_active_plugins_cache->timestamp = $time;
8718
+ self::$_accounts->set_option( $site_active_plugins_option_name, $site_active_plugins_cache, true );
8719
+
8720
+ $network_plugins_cache->md5 = $network_plugins_thumbprint;
8721
+ $network_plugins_cache->timestamp = $time;
8722
+ self::$_accounts->set_option( $network_plugins_option_name, $network_plugins_cache, true );
8723
+
8724
+ return $plugins_update_data;
8725
+ }
8726
+
8727
+ /**
8728
+ * Return a list of modified themes since the last sync.
8729
+ *
8730
+ * Note:
8731
+ * There's no point to store a themes counter since even if the number of
8732
+ * themes didn't change, we still need to check if the versions are all the
8733
+ * same and the activity state is similar.
8734
+ *
8735
+ * @author Vova Feldman (@svovaf)
8736
+ * @since 1.1.8
8737
+ *
8738
+ * @return array|false
8739
+ */
8740
+ private function get_themes_data_for_api() {
8741
+ // Alias.
8742
+ $option_name = 'all_themes';
8743
+
8744
+ $all_cached_themes = self::$_accounts->get_option( $option_name );
8745
+
8746
+ if ( ! is_object( $all_cached_themes ) ) {
8747
+ $all_cached_themes = (object) array(
8748
+ 'timestamp' => '',
8749
+ 'md5' => '',
8750
+ 'themes' => array(),
8751
+ );
8752
+ }
8753
+
8754
+ $time = time();
8755
+
8756
+ if ( ! empty( $all_cached_themes->timestamp ) &&
8757
+ ( $time - $all_cached_themes->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
8758
+ ) {
8759
+ // Don't send theme updates if last update was in the past 5 min.
8760
+ return false;
8761
+ }
8762
+
8763
+ // Write timestamp to lock the logic.
8764
+ $all_cached_themes->timestamp = $time;
8765
+ self::$_accounts->set_option( $option_name, $all_cached_themes, true );
8766
+
8767
+ // Reload options from DB.
8768
+ self::$_accounts->load( true );
8769
+ $all_cached_themes = self::$_accounts->get_option( $option_name );
8770
+
8771
+ if ( $time != $all_cached_themes->timestamp ) {
8772
+ // If timestamp is different, then another thread captured the lock.
8773
+ return false;
8774
+ }
8775
+
8776
+ // Get active theme.
8777
+ $active_theme = wp_get_theme();
8778
+ $active_theme_stylesheet = $active_theme->get_stylesheet();
8779
+
8780
+ // Check if there's a change in themes.
8781
+ $all_themes = wp_get_themes();
8782
+
8783
+ // Check if themes changed.
8784
+ ksort( $all_themes );
8785
+
8786
+ $themes_signature = '';
8787
+ foreach ( $all_themes as $slug => $data ) {
8788
+ $is_active = ( $slug === $active_theme_stylesheet );
8789
+ $themes_signature .= $slug . ',' .
8790
+ $data->version . ',' .
8791
+ ( $is_active ? '1' : '0' ) . ';';
8792
+ }
8793
+
8794
+ // Check if themes status changed (version or active/inactive).
8795
+ $themes_changed = ( $all_cached_themes->md5 !== md5( $themes_signature ) );
8796
+
8797
+ $themes_update_data = array();
8798
+
8799
+ if ( $themes_changed ) {
8800
+ // Change in themes, report changes.
8801
+
8802
+ // Update existing themes info.
8803
+ foreach ( $all_cached_themes->themes as $slug => $data ) {
8804
+ $is_active = ( $slug === $active_theme_stylesheet );
8805
+
8806
+ if ( ! isset( $all_themes[ $slug ] ) ) {
8807
+ // Plugin uninstalled.
8808
+ $uninstalled_theme_data = $data;
8809
+ $uninstalled_theme_data['is_active'] = false;
8810
+ $uninstalled_theme_data['is_uninstalled'] = true;
8811
+ $themes_update_data[] = $uninstalled_theme_data;
8812
+
8813
+ unset( $all_themes[ $slug ] );
8814
+ unset( $all_cached_themes->themes[ $slug ] );
8815
+ } else if ( $data['is_active'] !== $is_active ||
8816
+ $data['version'] !== $all_themes[ $slug ]->version
8817
+ ) {
8818
+ // Plugin activated or deactivated, or version changed.
8819
+
8820
+ $all_cached_themes->themes[ $slug ]['is_active'] = $is_active;
8821
+ $all_cached_themes->themes[ $slug ]['version'] = $all_themes[ $slug ]->version;
8822
+
8823
+ $themes_update_data[] = $all_cached_themes->themes[ $slug ];
8824
+ }
8825
+ }
8826
+
8827
+ // Find new themes that weren't yet seen before.
8828
+ foreach ( $all_themes as $slug => $data ) {
8829
+ if ( ! isset( $all_cached_themes->themes[ $slug ] ) ) {
8830
+ $is_active = ( $slug === $active_theme_stylesheet );
8831
+
8832
+ // New plugin.
8833
+ $new_plugin = array(
8834
+ 'slug' => $slug,
8835
+ 'version' => $data->version,
8836
+ 'title' => $data->name,
8837
+ 'is_active' => $is_active,
8838
+ 'is_uninstalled' => false,
8839
+ );
8840
+
8841
+ $themes_update_data[] = $new_plugin;
8842
+ $all_cached_themes->themes[ $slug ] = $new_plugin;
8843
+ }
8844
+ }
8845
+
8846
+ $all_cached_themes->md5 = md5( $themes_signature );
8847
+ $all_cached_themes->timestamp = time();
8848
+ self::$_accounts->set_option( $option_name, $all_cached_themes, true );
8849
+ }
8850
+
8851
+ return $themes_update_data;
8852
+ }
8853
+
8854
+ /**
8855
+ * Get site data for API install request.
8856
+ *
8857
+ * @author Vova Feldman (@svovaf)
8858
+ * @since 1.1.2
8859
+ *
8860
+ * @param string[] $override
8861
+ * @param bool $include_plugins Since 1.1.8 by default include plugin changes.
8862
+ * @param bool $include_themes Since 1.1.8 by default include plugin changes.
8863
+ * @param bool $include_blog_data Since 2.3.0 by default include the current blog's data (language, charset, title, and URL).
8864
+ *
8865
+ * @return array
8866
+ */
8867
+ private function get_install_data_for_api(
8868
+ array $override,
8869
+ $include_plugins = true,
8870
+ $include_themes = true,
8871
+ $include_blog_data = true
8872
+ ) {
8873
+ if ( $this->is_extensions_tracking_allowed() ) {
8874
+ if ( ! defined( 'WP_FS__TRACK_PLUGINS' ) || false !== WP_FS__TRACK_PLUGINS ) {
8875
+ /**
8876
+ * @since 1.1.8 Also send plugin updates.
8877
+ */
8878
+ if ( $include_plugins && ! isset( $override['plugins'] ) ) {
8879
+ $plugins = $this->get_plugins_data_for_api();
8880
+ if ( ! empty( $plugins ) ) {
8881
+ $override['plugins'] = $plugins;
8882
+ }
8883
+ }
8884
+ }
8885
+
8886
+ if ( ! defined( 'WP_FS__TRACK_THEMES' ) || false !== WP_FS__TRACK_THEMES ) {
8887
+ /**
8888
+ * @since 1.1.8 Also send themes updates.
8889
+ */
8890
+ if ( $include_themes && ! isset( $override['themes'] ) ) {
8891
+ $themes = $this->get_themes_data_for_api();
8892
+ if ( ! empty( $themes ) ) {
8893
+ $override['themes'] = $themes;
8894
+ }
8895
+ }
8896
+ }
8897
+ }
8898
+
8899
+ $versions = $this->get_versions();
8900
+
8901
+ $blog_data = $include_blog_data ?
8902
+ array(
8903
+ 'language' => get_bloginfo( 'language' ),
8904
+ 'charset' => get_bloginfo( 'charset' ),
8905
+ 'title' => get_bloginfo( 'name' ),
8906
+ 'url' => get_site_url(),
8907
+ ) :
8908
+ array();
8909
+
8910
+ return array_merge( $versions, $blog_data, array(
8911
+ 'version' => $this->get_plugin_version(),
8912
+ 'is_premium' => $this->is_premium(),
8913
+ // Special params.
8914
+ 'is_active' => true,
8915
+ 'is_disconnected' => $this->is_tracking_prohibited(),
8916
+ 'is_uninstalled' => false,
8917
+ ), $override );
8918
+ }
8919
+
8920
+ /**
8921
+ * Update installs details.
8922
+ *
8923
+ * @todo V1 of multiste network support doesn't support plugin and theme data sending.
8924
+ *
8925
+ * @author Vova Feldman (@svovaf)
8926
+ * @since 2.0.0
8927
+ *
8928
+ * @param string[] string $override
8929
+ * @param bool $only_diff
8930
+ * @param bool $include_plugins Since 1.1.8 by default include plugin changes.
8931
+ * @param bool $include_themes Since 1.1.8 by default include plugin changes.
8932
+ *
8933
+ * @return array
8934
+ */
8935
+ private function get_installs_data_for_api(
8936
+ array $override,
8937
+ $only_diff = false,
8938
+ $include_plugins = true,
8939
+ $include_themes = true
8940
+ ) {
8941
+ /**
8942
+ * @since 1.1.8 Also send plugin updates.
8943
+ */
8944
+ // if ( $include_plugins && ! isset( $override['plugins'] ) ) {
8945
+ // $plugins = $this->get_plugins_data_for_api();
8946
+ // if ( ! empty( $plugins ) ) {
8947
+ // $override['plugins'] = $plugins;
8948
+ // }
8949
+ // }
8950
+ /**
8951
+ * @since 1.1.8 Also send themes updates.
8952
+ */
8953
+ // if ( $include_themes && ! isset( $override['themes'] ) ) {
8954
+ // $themes = $this->get_themes_data_for_api();
8955
+ // if ( ! empty( $themes ) ) {
8956
+ // $override['themes'] = $themes;
8957
+ // }
8958
+ // }
8959
+
8960
+ // Common properties.
8961
+ $versions = $this->get_versions();
8962
+ $common = array_merge( $versions, array(
8963
+ 'version' => $this->get_plugin_version(),
8964
+ 'is_premium' => $this->is_premium(),
8965
+ ), $override );
8966
+
8967
+
8968
+ $is_common_diff_for_any_site = false;
8969
+ $common_diff_union = array();
8970
+
8971
+ $installs_data = array();
8972
+
8973
+ $sites = self::get_sites();
8974
+
8975
+ foreach ( $sites as $site ) {
8976
+ $blog_id = self::get_site_blog_id( $site );
8977
+
8978
+ $install = $this->get_install_by_blog_id( $blog_id );
8979
+
8980
+ if ( is_object( $install ) ) {
8981
+ if ( $install->user_id != $this->_user->id ) {
8982
+ // Install belongs to a different owner.
8983
+ continue;
8984
+ }
8985
+
8986
+ if ( ! $this->is_premium() && $install->is_tracking_prohibited() ) {
8987
+ // Don't send updates regarding opted-out installs.
8988
+ continue;
8989
+ }
8990
+
8991
+ $install_data = $this->get_site_info( $site );
8992
+
8993
+ $uid = $install_data['uid'];
8994
+
8995
+ unset( $install_data['blog_id'] );
8996
+ unset( $install_data['uid'] );
8997
+
8998
+ $install_data['is_disconnected'] = $install->is_disconnected;
8999
+ $install_data['is_active'] = $this->is_active_for_site( $blog_id );
9000
+ $install_data['is_uninstalled'] = $install->is_uninstalled;
9001
+
9002
+ $common_diff = null;
9003
+ $is_common_diff = false;
9004
+ if ( $only_diff ) {
9005
+ $install_data = $this->get_install_diff_for_api( $install_data, $install, $override );
9006
+ $common_diff = $this->get_install_diff_for_api( $common, $install, $override );
9007
+
9008
+ $is_common_diff = ! empty( $common_diff );
9009
+
9010
+ if ( $is_common_diff ) {
9011
+ foreach ( $common_diff as $k => $v ) {
9012
+ if ( ! isset( $common_diff_union[ $k ] ) ) {
9013
+ $common_diff_union[ $k ] = $v;
9014
+ }
9015
+ }
9016
+ }
9017
+
9018
+ $is_common_diff_for_any_site = $is_common_diff_for_any_site || $is_common_diff;
9019
+ }
9020
+
9021
+ if ( ! empty( $install_data ) || $is_common_diff ) {
9022
+ // Add install ID and site unique ID.
9023
+ $install_data['id'] = $install->id;
9024
+ $install_data['uid'] = $uid;
9025
+
9026
+ $installs_data[] = $install_data;
9027
+ }
9028
+ }
9029
+ }
9030
+
9031
+ restore_current_blog();
9032
+
9033
+ if ( 0 < count( $installs_data ) && ( $is_common_diff_for_any_site || ! $only_diff ) ) {
9034
+ if ( ! $only_diff ) {
9035
+ $installs_data[] = $common;
9036
+ } else if ( ! empty( $common_diff_union ) ) {
9037
+ $installs_data[] = $common_diff_union;
9038
+ }
9039
+ }
9040
+
9041
+ foreach ( $installs_data as &$data ) {
9042
+ $data = (object) $data;
9043
+ }
9044
+
9045
+ return $installs_data;
9046
+ }
9047
+
9048
+ /**
9049
+ * Compare site actual data to the stored install data and return the differences for an API data sync.
9050
+ *
9051
+ * @author Vova Feldman (@svovaf)
9052
+ * @since 2.0.0
9053
+ *
9054
+ * @param array $site
9055
+ * @param FS_Site $install
9056
+ * @param string[] string $override
9057
+ *
9058
+ * @return array
9059
+ */
9060
+ private function get_install_diff_for_api( $site, $install, $override = array() ) {
9061
+ $diff = array();
9062
+ $special = array();
9063
+ $special_override = false;
9064
+
9065
+ foreach ( $site as $p => $v ) {
9066
+ if ( property_exists( $install, $p ) ) {
9067
+ if ( ( is_bool( $install->{$p} ) || ! empty( $install->{$p} ) ) &&
9068
+ $install->{$p} != $v
9069
+ ) {
9070
+ $install->{$p} = $v;
9071
+ $diff[ $p ] = $v;
9072
+ }
9073
+ } else {
9074
+ $special[ $p ] = $v;
9075
+
9076
+ if ( isset( $override[ $p ] ) ||
9077
+ 'plugins' === $p ||
9078
+ 'themes' === $p
9079
+ ) {
9080
+ $special_override = true;
9081
+ }
9082
+ }
9083
+ }
9084
+
9085
+ if ( $special_override || 0 < count( $diff ) ) {
9086
+ // Add special params only if has at least one
9087
+ // standard param, or if explicitly requested to
9088
+ // override a special param or a param which is not exist
9089
+ // in the install object.
9090
+ $diff = array_merge( $diff, $special );
9091
+ }
9092
+
9093
+ return $diff;
9094
+ }
9095
+
9096
+ /**
9097
+ * Update install only if changed.
9098
+ *
9099
+ * @author Vova Feldman (@svovaf)
9100
+ * @since 1.0.9
9101
+ *
9102
+ * @param string[] string $override
9103
+ * @param bool $flush
9104
+ *
9105
+ * @return false|object|string
9106
+ */
9107
+ private function send_install_update( $override = array(), $flush = false ) {
9108
+ $this->_logger->entrance();
9109
+
9110
+ $check_properties = $this->get_install_data_for_api( $override );
9111
+
9112
+ if ( $flush ) {
9113
+ $params = $check_properties;
9114
+ } else {
9115
+ $params = $this->get_install_diff_for_api( $check_properties, $this->_site, $override );
9116
+ }
9117
+
9118
+ $keepalive_only_update = false;
9119
+ if ( empty( $params ) ) {
9120
+ $keepalive_only_update = $this->should_send_keepalive_update();
9121
+
9122
+ if ( ! $keepalive_only_update ) {
9123
+ /**
9124
+ * There are no updates to send including keepalive.
9125
+ *
9126
+ * @author Leo Fajardo (@leorw)
9127
+ * @since 2.2.3
9128
+ */
9129
+ return false;
9130
+ }
9131
+ }
9132
+
9133
+ if ( ! $keepalive_only_update ) {
9134
+ /**
9135
+ * Do not update the last install sync timestamp after a keepalive-only call since there were no actual
9136
+ * updates sent.
9137
+ *
9138
+ * @author Leo Fajardo (@leorw)
9139
+ * @since 2.2.3
9140
+ */
9141
+ if ( ! is_multisite() ) {
9142
+ // Update last install sync timestamp.
9143
+ $this->set_cron_execution_timestamp( 'install_sync' );
9144
+ }
9145
+
9146
+ $params['uid'] = $this->get_anonymous_id();
9147
+ }
9148
+
9149
+ $this->set_keepalive_timestamp();
9150
+
9151
+ // Send updated values to FS.
9152
+ $site = $this->get_api_site_scope()->call( '/', 'put', $params );
9153
+
9154
+ if ( ! $keepalive_only_update && $this->is_api_result_entity( $site ) ) {
9155
+ /**
9156
+ * Do not clear scheduled sync after a keepalive-only call since there were no actual updates sent.
9157
+ *
9158
+ * @author Leo Fajardo (@leorw)
9159
+ * @since 2.2.3
9160
+ */
9161
+ if ( ! is_multisite() ) {
9162
+ // I successfully sent install update, clear scheduled sync if exist.
9163
+ $this->clear_install_sync_cron();
9164
+ }
9165
+ }
9166
+
9167
+ return $site;
9168
+ }
9169
+
9170
+ /**
9171
+ * Update installs only if changed.
9172
+ *
9173
+ * @author Vova Feldman (@svovaf)
9174
+ * @since 2.0.0
9175
+ *
9176
+ * @param string[] string $override
9177
+ * @param bool $flush
9178
+ *
9179
+ * @return false|object|string
9180
+ */
9181
+ private function send_installs_update( $override = array(), $flush = false ) {
9182
+ $this->_logger->entrance();
9183
+
9184
+ $installs_data = $this->get_installs_data_for_api( $override, ! $flush );
9185
+
9186
+ $keepalive_only_update = false;
9187
+ if ( empty( $installs_data ) ) {
9188
+ /**
9189
+ * Pass `true` to use the network level storage since the update is for many installs.
9190
+ *
9191
+ * @author Leo Fajardo (@leorw)
9192
+ * @since 2.2.3
9193
+ */
9194
+ $keepalive_only_update = $this->should_send_keepalive_update( true );
9195
+
9196
+ if ( ! $keepalive_only_update ) {
9197
+ /**
9198
+ * There are no updates to send including keepalive.
9199
+ *
9200
+ * @author Leo Fajardo (@leorw)
9201
+ * @since 2.2.3
9202
+ */
9203
+ return false;
9204
+ }
9205
+ }
9206
+
9207
+ if ( ! $keepalive_only_update ) {
9208
+ // Update last install sync timestamp if there were actual updates sent (i.e., not a keepalive-only call).
9209
+ $this->set_cron_execution_timestamp( 'install_sync' );
9210
+ }
9211
+
9212
+ /**
9213
+ * Pass `true` to use the network level storage since the update is for many installs.
9214
+ *
9215
+ * @author Leo Fajardo (@leorw)
9216
+ * @since 2.2.3
9217
+ */
9218
+ $this->set_keepalive_timestamp( true );
9219
+
9220
+ // Send updated values to FS.
9221
+ $result = $this->get_api_user_scope()->call( "/plugins/{$this->_plugin->id}/installs.json", 'put', $installs_data );
9222
+
9223
+ if ( ! $keepalive_only_update && $this->is_api_result_object( $result, 'installs' ) ) {
9224
+ // I successfully sent installs update (there was an actual update sent and it's not just a keepalive-only call), clear scheduled sync if exist.
9225
+ $this->clear_install_sync_cron();
9226
+ }
9227
+
9228
+ return $result;
9229
+ }
9230
+
9231
+ /**
9232
+ * @author Leo Fajardo (@leorw)
9233
+ *
9234
+ * @param bool|null $use_network_level_storage
9235
+ *
9236
+ * @return bool
9237
+ */
9238
+ private function should_send_keepalive_update( $use_network_level_storage = null ) {
9239
+ $keepalive_timestamp = $this->_storage->get( 'keepalive_timestamp', 0, $use_network_level_storage );
9240
+
9241
+ if ( $keepalive_timestamp < ( time() - WP_FS__TIME_WEEK_IN_SEC ) ) {
9242
+ // If updated more than 7 days ago, trigger a keepalive and update the time it was triggered.
9243
+ return true;
9244
+ } else {
9245
+ // If updated 7 days ago or less, "flip a coin", if the value is 7 trigger a keepalive and update the last time it was triggered.
9246
+ return ( 7 == rand( 1, 7 ) );
9247
+ }
9248
+ }
9249
+
9250
+ /**
9251
+ * Syncs the install owner's data if needed (i.e., if the install owner is different from the loaded user).
9252
+ *
9253
+ * @author Leo Fajardo (@leorw)
9254
+ * @since 2.3.2
9255
+ */
9256
+ private function maybe_sync_install_user() {
9257
+ if ( $this->_user->id == $this->_site->user_id ) {
9258
+ return;
9259
+ }
9260
+
9261
+ // Fetch user data and store if found.
9262
+ $this->sync_user_by_current_install();
9263
+ }
9264
+
9265
+ /**
9266
+ * Update install only if changed.
9267
+ *
9268
+ * @author Vova Feldman (@svovaf)
9269
+ * @since 1.0.9
9270
+ *
9271
+ * @param string[] string $override
9272
+ * @param bool $flush
9273
+ */
9274
+ private function sync_install( $override = array(), $flush = false ) {
9275
+ $this->_logger->entrance();
9276
+
9277
+ $site = $this->send_install_update( $override, $flush );
9278
+
9279
+ if ( false === $site ) {
9280
+ // No sync required.
9281
+ return;
9282
+ }
9283
+
9284
+ if ( ! $this->is_api_result_entity( $site ) ) {
9285
+ // Failed to sync, don't update locally.
9286
+ return;
9287
+ }
9288
+
9289
+ $this->_site = new FS_Site( $site );
9290
+
9291
+ $this->_store_site( true );
9292
+ }
9293
+
9294
+ /**
9295
+ * Update install only if changed.
9296
+ *
9297
+ * @author Vova Feldman (@svovaf)
9298
+ * @since 1.0.9
9299
+ *
9300
+ * @param string[] string $override
9301
+ * @param bool $flush
9302
+ */
9303
+ private function sync_installs( $override = array(), $flush = false ) {
9304
+ $this->_logger->entrance();
9305
+
9306
+ $result = $this->send_installs_update( $override, $flush );
9307
+
9308
+ if ( false === $result ) {
9309
+ // No sync required.
9310
+ return;
9311
+ }
9312
+
9313
+ if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
9314
+ // Failed to sync, don't update locally.
9315
+ return;
9316
+ }
9317
+
9318
+ $address_to_blog_map = $this->get_address_to_blog_map();
9319
+
9320
+ foreach ( $result->installs as $install ) {
9321
+ $this->_site = new FS_Site( $install );
9322
+
9323
+ $address = trailingslashit( fs_strip_url_protocol( $install->url ) );
9324
+ $blog_id = $address_to_blog_map[ $address ];
9325
+
9326
+ $this->_store_site( true, $blog_id );
9327
+ }
9328
+ }
9329
+
9330
+ /**
9331
+ * Track install's custom event.
9332
+ *
9333
+ * IMPORTANT:
9334
+ * Custom event tracking is currently only supported for specific clients.
9335
+ * If you are not one of them, please don't use this method. If you will,
9336
+ * the API will simply ignore your request based on the plugin ID.
9337
+ *
9338
+ * Need custom tracking for your plugin or theme?
9339
+ * If you are interested in custom event tracking please contact yo@freemius.com
9340
+ * for further details.
9341
+ *
9342
+ * @author Vova Feldman (@svovaf)
9343
+ * @since 1.2.1
9344
+ *
9345
+ * @param string $name Event name.
9346
+ * @param array $properties Associative key/value array with primitive values only
9347
+ * @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s.
9348
+ * @param bool $once If true, event will be tracked only once. IMPORTANT: Still trigger the API call.
9349
+ *
9350
+ * @return object|false Event data or FALSE on failure.
9351
+ *
9352
+ * @throws \Freemius_InvalidArgumentException
9353
+ */
9354
+ public function track_event( $name, $properties = array(), $process_at = false, $once = false ) {
9355
+ $this->_logger->entrance( http_build_query( array( 'name' => $name, 'once' => $once ) ) );
9356
+
9357
+ if ( ! $this->is_registered() ) {
9358
+ return false;
9359
+ }
9360
+
9361
+ $event = array( 'type' => $name );
9362
+
9363
+ if ( is_numeric( $process_at ) && $process_at > time() ) {
9364
+ $event['process_at'] = $process_at;
9365
+ }
9366
+
9367
+ if ( $once ) {
9368
+ $event['once'] = true;
9369
+ }
9370
+
9371
+ if ( ! empty( $properties ) ) {
9372
+ // Verify associative array values are primitive.
9373
+ foreach ( $properties as $k => $v ) {
9374
+ if ( ! is_scalar( $v ) ) {
9375
+ throw new Freemius_InvalidArgumentException( 'The $properties argument must be an associative key/value array with primitive values only.' );
9376
+ }
9377
+ }
9378
+
9379
+ $event['properties'] = $properties;
9380
+ }
9381
+
9382
+ $result = $this->get_api_site_scope()->call( 'events.json', 'post', $event );
9383
+
9384
+ return $this->is_api_error( $result ) ?
9385
+ false :
9386
+ $result;
9387
+ }
9388
+
9389
+ /**
9390
+ * Track install's custom event only once, but it still triggers the API call.
9391
+ *
9392
+ * IMPORTANT:
9393
+ * Custom event tracking is currently only supported for specific clients.
9394
+ * If you are not one of them, please don't use this method. If you will,
9395
+ * the API will simply ignore your request based on the plugin ID.
9396
+ *
9397
+ * Need custom tracking for your plugin or theme?
9398
+ * If you are interested in custom event tracking please contact yo@freemius.com
9399
+ * for further details.
9400
+ *
9401
+ * @author Vova Feldman (@svovaf)
9402
+ * @since 1.2.1
9403
+ *
9404
+ * @param string $name Event name.
9405
+ * @param array $properties Associative key/value array with primitive values only
9406
+ * @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s.
9407
+ *
9408
+ * @return object|false Event data or FALSE on failure.
9409
+ *
9410
+ * @throws \Freemius_InvalidArgumentException
9411
+ *
9412
+ * @user Freemius::track_event()
9413
+ */
9414
+ public function track_event_once( $name, $properties = array(), $process_at = false ) {
9415
+ return $this->track_event( $name, $properties, $process_at, true );
9416
+ }
9417
+
9418
+ /**
9419
+ * Plugin uninstall hook.
9420
+ *
9421
+ * @author Vova Feldman (@svovaf)
9422
+ * @since 1.0.1
9423
+ *
9424
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
9425
+ */
9426
+ function _uninstall_plugin_event( $check_user = true ) {
9427
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
9428
+
9429
+ if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
9430
+ return;
9431
+ }
9432
+
9433
+ $params = array();
9434
+ $uninstall_reason = null;
9435
+ if ( isset( $this->_storage->uninstall_reason ) ) {
9436
+ $uninstall_reason = $this->_storage->uninstall_reason;
9437
+ $params['reason_id'] = $uninstall_reason->id;
9438
+ $params['reason_info'] = $uninstall_reason->info;
9439
+ }
9440
+
9441
+ if ( ! $this->is_registered() ) {
9442
+ // Send anonymous uninstall event only if user submitted a feedback.
9443
+ if ( isset( $uninstall_reason ) ) {
9444
+ if ( isset( $uninstall_reason->is_anonymous ) && ! $uninstall_reason->is_anonymous ) {
9445
+ $this->opt_in( false, false, false, false, true );
9446
+ } else {
9447
+ $params['uid'] = $this->get_anonymous_id();
9448
+ $this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params );
9449
+ }
9450
+ }
9451
+ } else {
9452
+ $params = array_merge( $params, array(
9453
+ 'is_active' => false,
9454
+ 'is_uninstalled' => true,
9455
+ ) );
9456
+
9457
+ if ( $this->_is_network_active ) {
9458
+ // Send uninstall event.
9459
+ $this->send_installs_update( $params );
9460
+ } else {
9461
+ // Send uninstall event.
9462
+ $this->send_install_update( $params );
9463
+ }
9464
+ }
9465
+
9466
+ // @todo Decide if we want to delete plugin information from db.
9467
+ }
9468
+
9469
+ /**
9470
+ * Set the basename of the current product and hook _activate_plugin_event_hook() to the activation action.
9471
+ *
9472
+ * @author Vova Feldman (@svovaf)
9473
+ * @since 2.2.1
9474
+ *
9475
+ * @param string $is_premium
9476
+ * @param string $caller
9477
+ *
9478
+ * @return string
9479
+ */
9480
+ function set_basename( $is_premium, $caller ) {
9481
+ $basename = plugin_basename( $caller );
9482
+
9483
+ $current_basename = $is_premium ?
9484
+ $this->_premium_plugin_basename :
9485
+ $this->_free_plugin_basename;
9486
+
9487
+ if ( $current_basename == $basename ) {
9488
+ // Basename value set correctly.
9489
+ return;
9490
+ }
9491
+
9492
+ if ( $is_premium ) {
9493
+ $this->_premium_plugin_basename = $basename;
9494
+ } else {
9495
+ $this->_free_plugin_basename = $basename;
9496
+ }
9497
+
9498
+ $plugin_dir = dirname( $this->_plugin_dir_path ) . '/';
9499
+
9500
+ register_activation_hook(
9501
+ $plugin_dir . $basename,
9502
+ array( &$this, '_activate_plugin_event_hook' )
9503
+ );
9504
+ }
9505
+
9506
+ /**
9507
+ * @author Vova Feldman (@svovaf)
9508
+ * @since 1.1.1
9509
+ * @since 2.2.1 If the context product is in its premium version, use the current module's basename, even if it was renamed.
9510
+ *
9511
+ * @return string
9512
+ */
9513
+ function premium_plugin_basename() {
9514
+ if ( ! isset( $this->_premium_plugin_basename ) ) {
9515
+ $this->_premium_plugin_basename = $this->is_premium() ?
9516
+ // The product is premium, so use the current basename.
9517
+ $this->_plugin_basename :
9518
+ $this->get_premium_slug() . '/' . basename( $this->_free_plugin_basename );
9519
+ }
9520
+
9521
+ return $this->_premium_plugin_basename;
9522
+ }
9523
+
9524
+ /**
9525
+ * Uninstall plugin hook. Called only when connected his account with Freemius for active sites tracking.
9526
+ *
9527
+ * @author Vova Feldman (@svovaf)
9528
+ * @since 1.0.2
9529
+ */
9530
+ public static function _uninstall_plugin_hook() {
9531
+ self::_load_required_static();
9532
+
9533
+ self::$_static_logger->entrance();
9534
+
9535
+ if ( ! current_user_can( 'activate_plugins' ) ) {
9536
+ return;
9537
+ }
9538
+
9539
+ $plugin_file = substr( current_filter(), strlen( 'uninstall_' ) );
9540
+
9541
+ self::$_static_logger->info( 'plugin = ' . $plugin_file );
9542
+
9543
+ define( 'WP_FS__UNINSTALL_MODE', true );
9544
+
9545
+ $fs = self::get_instance_by_file( $plugin_file );
9546
+
9547
+ if ( is_object( $fs ) ) {
9548
+ $fs->remove_sdk_reference();
9549
+
9550
+ self::require_plugin_essentials();
9551
+
9552
+ if ( is_plugin_active( $fs->_free_plugin_basename ) ||
9553
+ is_plugin_active( $fs->premium_plugin_basename() )
9554
+ ) {
9555
+ // Deleting Free or Premium plugin version while the other version still installed.
9556
+ return;
9557
+ }
9558
+
9559
+ $fs->_uninstall_plugin_event();
9560
+
9561
+ $fs->do_action( 'after_uninstall' );
9562
+ }
9563
+ }
9564
+
9565
+ #----------------------------------------------------------------------------------
9566
+ #region Plugin Information
9567
+ #----------------------------------------------------------------------------------
9568
+
9569
+ /**
9570
+ * Load WordPress core plugin.php essential module.
9571
+ *
9572
+ * @author Vova Feldman (@svovaf)
9573
+ * @since 1.1.1
9574
+ */
9575
+ private static function require_plugin_essentials() {
9576
+ if ( ! function_exists( 'get_plugins' ) ) {
9577
+ self::$_static_logger->log( 'Including wp-admin/includes/plugin.php...' );
9578
+
9579
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
9580
+ }
9581
+ }
9582
+
9583
+ /**
9584
+ * Load WordPress core pluggable.php module.
9585
+ *
9586
+ * @author Vova Feldman (@svovaf)
9587
+ * @since 1.1.2
9588
+ */
9589
+ private static function require_pluggable_essentials() {
9590
+ if ( ! function_exists( 'wp_get_current_user' ) ) {
9591
+ require_once ABSPATH . 'wp-includes/pluggable.php';
9592
+ }
9593
+ }
9594
+
9595
+ /**
9596
+ * Return plugin data.
9597
+ *
9598
+ * @author Vova Feldman (@svovaf)
9599
+ * @since 1.0.1
9600
+ *
9601
+ * @param bool $reparse_plugin_metadata
9602
+ *
9603
+ * @return array
9604
+ */
9605
+ function get_plugin_data( $reparse_plugin_metadata = false ) {
9606
+ if ( ! isset( $this->_plugin_data ) || $reparse_plugin_metadata ) {
9607
+ self::require_plugin_essentials();
9608
+
9609
+ if ( $this->is_plugin() ) {
9610
+ /**
9611
+ * @author Vova Feldman (@svovaf)
9612
+ * @since 1.2.0 When using get_plugin_data() do NOT translate plugin data.
9613
+ *
9614
+ * @link https://github.com/Freemius/wordpress-sdk/issues/77
9615
+ */
9616
+ $plugin_data = get_plugin_data(
9617
+ $this->_plugin_main_file_path,
9618
+ false,
9619
+ false
9620
+ );
9621
+ } else {
9622
+ $theme_data = wp_get_theme();
9623
+
9624
+ if ( $this->_plugin_basename !== $theme_data->get_stylesheet() && is_child_theme() ) {
9625
+ $parent_theme = $theme_data->parent();
9626
+
9627
+ if ( ( $parent_theme instanceof WP_Theme ) && $this->_plugin_basename === $parent_theme->get_stylesheet() ) {
9628
+ $theme_data = $parent_theme;
9629
+ }
9630
+ }
9631
+
9632
+ $plugin_data = array(
9633
+ 'Name' => $theme_data->get( 'Name' ),
9634
+ 'Version' => $theme_data->get( 'Version' ),
9635
+ 'Author' => $theme_data->get( 'Author' ),
9636
+ 'Description' => $theme_data->get( 'Description' ),
9637
+ 'PluginURI' => $theme_data->get( 'ThemeURI' ),
9638
+ );
9639
+ }
9640
+
9641
+ $this->_plugin_data = $plugin_data;
9642
+ }
9643
+
9644
+ return $this->_plugin_data;
9645
+ }
9646
+
9647
+ /**
9648
+ * @author Vova Feldman (@svovaf)
9649
+ * @since 1.0.1
9650
+ * @since 1.2.2.5 If slug not set load slug by module ID.
9651
+ *
9652
+ * @return string Plugin slug.
9653
+ */
9654
+ function get_slug() {
9655
+ if ( ! isset( $this->_slug ) ) {
9656
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
9657
+ $this->_slug = $id_slug_type_path_map[ $this->_module_id ]['slug'];
9658
+ }
9659
+
9660
+ return $this->_slug;
9661
+ }
9662
+
9663
+ /**
9664
+ * @author Leo Fajardo (@leorw)
9665
+ * @since 2.2.1
9666
+ *
9667
+ * @return string
9668
+ */
9669
+ function get_premium_slug() {
9670
+ return is_object( $this->_plugin ) ?
9671
+ $this->_plugin->premium_slug :
9672
+ "{$this->_slug}-premium";
9673
+ }
9674
+
9675
+ /**
9676
+ * Retrieve the desired folder name for the product.
9677
+ *
9678
+ * @author Vova Feldman (@svovaf)
9679
+ * @since 1.2.1.7
9680
+ *
9681
+ * @return string Plugin slug.
9682
+ */
9683
+ function get_target_folder_name() {
9684
+ return $this->can_use_premium_code() ?
9685
+ $this->_plugin->premium_slug :
9686
+ $this->_slug;
9687
+ }
9688
+
9689
+ /**
9690
+ * @author Vova Feldman (@svovaf)
9691
+ * @since 1.0.1
9692
+ *
9693
+ * @return number Plugin ID.
9694
+ */
9695
+ function get_id() {
9696
+ return $this->_plugin->id;
9697
+ }
9698
+
9699
+ /**
9700
+ * @author Leo Fajardo (@leorw)
9701
+ * @since 2.2.4
9702
+ *
9703
+ * @return number|null Bundle ID.
9704
+ */
9705
+ function get_bundle_id() {
9706
+ return ( isset( $this->_plugin->bundle_id ) && FS_Plugin::is_valid_id( $this->_plugin->bundle_id ) ) ?
9707
+ $this->_plugin->bundle_id :
9708
+ null;
9709
+ }
9710
+
9711
+ /**
9712
+ * @author Vova Feldman (@svovaf)
9713
+ * @since 2.3.1
9714
+ *
9715
+ * @return string|null Bundle public key.
9716
+ */
9717
+ function get_bundle_public_key() {
9718
+ return isset( $this->_plugin->bundle_public_key ) ?
9719
+ $this->_plugin->bundle_public_key :
9720
+ null;
9721
+ }
9722
+
9723
+ /**
9724
+ * @author Vova Feldman (@svovaf)
9725
+ * @since 1.2.1.5
9726
+ *
9727
+ * @return string Freemius SDK version
9728
+ */
9729
+ function get_sdk_version() {
9730
+ return $this->version;
9731
+ }
9732
+
9733
+ /**
9734
+ * @author Vova Feldman (@svovaf)
9735
+ * @since 1.2.1.5
9736
+ *
9737
+ * @return number Parent plugin ID (if parent exist).
9738
+ */
9739
+ function get_parent_id() {
9740
+ return $this->is_addon() ?
9741
+ $this->get_parent_instance()->get_id() :
9742
+ $this->_plugin->id;
9743
+ }
9744
+
9745
+ /**
9746
+ * @author Vova Feldman (@svovaf)
9747
+ * @since 2.3.1
9748
+ *
9749
+ * @return string
9750
+ */
9751
+ function get_usage_tracking_terms_url() {
9752
+ return $this->apply_filters(
9753
+ 'usage_tracking_terms_url',
9754
+ "https://freemius.com/wordpress/usage-tracking/{$this->_plugin->id}/{$this->_slug}/"
9755
+ );
9756
+ }
9757
+
9758
+ /**
9759
+ * @author Vova Feldman (@svovaf)
9760
+ * @since 2.3.1
9761
+ *
9762
+ * @return string
9763
+ */
9764
+ function get_eula_url() {
9765
+ return $this->apply_filters(
9766
+ 'eula_url',
9767
+ "https://freemius.com/terms/{$this->_plugin->id}/{$this->_slug}/"
9768
+ );
9769
+ }
9770
+
9771
+ /**
9772
+ * @author Vova Feldman (@svovaf)
9773
+ * @since 1.0.1
9774
+ *
9775
+ * @return string Plugin public key.
9776
+ */
9777
+ function get_public_key() {
9778
+ return $this->_plugin->public_key;
9779
+ }
9780
+
9781
+ /**
9782
+ * Will be available only on sandbox mode.
9783
+ *
9784
+ * @author Vova Feldman (@svovaf)
9785
+ * @since 1.0.4
9786
+ *
9787
+ * @return mixed Plugin secret key.
9788
+ */
9789
+ function get_secret_key() {
9790
+ return $this->_plugin->secret_key;
9791
+ }
9792
+
9793
+ /**
9794
+ * @author Vova Feldman (@svovaf)
9795
+ * @since 1.1.1
9796
+ *
9797
+ * @return bool
9798
+ */
9799
+ function has_secret_key() {
9800
+ return ! empty( $this->_plugin->secret_key );
9801
+ }
9802
+
9803
+ /**
9804
+ * @author Vova Feldman (@svovaf)
9805
+ * @since 1.0.9
9806
+ *
9807
+ * @param string|bool $premium_suffix
9808
+ *
9809
+ * @return string
9810
+ */
9811
+ function get_plugin_name( $premium_suffix = false ) {
9812
+ $this->_logger->entrance();
9813
+
9814
+ /**
9815
+ * This `if-else` can be squeezed into a single `if` but I intentionally split it for code readability.
9816
+ *
9817
+ * @author Vova Feldman
9818
+ */
9819
+ if ( ! isset( $this->_plugin_name ) ) {
9820
+ // Name is not yet set.
9821
+ $this->set_name( $premium_suffix );
9822
+ } else if (
9823
+ ! empty( $premium_suffix ) &&
9824
+ ( ! is_object( $this->_plugin ) || $this->_plugin->premium_suffix !== $premium_suffix )
9825
+ ) {
9826
+ // Name is already set, but there's a change in the premium suffix.
9827
+ $this->set_name( $premium_suffix );
9828
+ }
9829
+
9830
+ return $this->_plugin_name;
9831
+ }
9832
+
9833
+ /**
9834
+ * Calculates and stores the product's name. This helper function was created specifically for get_plugin_name() just to make the code clearer.
9835
+ *
9836
+ * @author Vova Feldman (@svovaf)
9837
+ * @since 2.2.1
9838
+ *
9839
+ * @param string $premium_suffix
9840
+ */
9841
+ private function set_name( $premium_suffix = '' ) {
9842
+ $plugin_data = $this->get_plugin_data();
9843
+
9844
+ // Get name.
9845
+ $this->_plugin_name = $plugin_data['Name'];
9846
+
9847
+ if ( is_string( $premium_suffix ) ) {
9848
+ $premium_suffix = trim( $premium_suffix );
9849
+
9850
+ if ( ! empty( $premium_suffix ) ) {
9851
+ // Check if plugin name contains " (premium)" or a custom suffix and remove it.
9852
+ $suffix = ( ' ' . strtolower( $premium_suffix ) );
9853
+ $suffix_len = strlen( $suffix );
9854
+
9855
+ if ( strlen( $plugin_data['Name'] ) > $suffix_len &&
9856
+ $suffix === substr( strtolower( $plugin_data['Name'] ), - $suffix_len )
9857
+ ) {
9858
+ $this->_plugin_name = substr( $plugin_data['Name'], 0, - $suffix_len );
9859
+ }
9860
+ }
9861
+ }
9862
+
9863
+ $this->_logger->departure( 'Name = ' . $this->_plugin_name );
9864
+ }
9865
+
9866
+ /**
9867
+ * @author Vova Feldman (@svovaf)
9868
+ * @since 1.0.0
9869
+ *
9870
+ * @param bool $reparse_plugin_metadata
9871
+ *
9872
+ * @return string
9873
+ */
9874
+ function get_plugin_version( $reparse_plugin_metadata = false ) {
9875
+ $this->_logger->entrance();
9876
+
9877
+ $plugin_data = $this->get_plugin_data( $reparse_plugin_metadata );
9878
+
9879
+ $this->_logger->departure( 'Version = ' . $plugin_data['Version'] );
9880
+
9881
+ return $this->apply_filters( 'plugin_version', $plugin_data['Version'] );
9882
+ }
9883
+
9884
+ /**
9885
+ * @author Vova Feldman (@svovaf)
9886
+ * @since 1.2.1.7
9887
+ *
9888
+ * @return string
9889
+ */
9890
+ function get_plugin_title() {
9891
+ $this->_logger->entrance();
9892
+
9893
+ $title = $this->_plugin->title;
9894
+
9895
+ return $this->apply_filters( 'plugin_title', $title );
9896
+ }
9897
+
9898
+ /**
9899
+ * @author Vova Feldman (@svovaf)
9900
+ * @since 1.2.2.7
9901
+ *
9902
+ * @param bool $lowercase
9903
+ *
9904
+ * @return string
9905
+ */
9906
+ function get_module_label( $lowercase = false ) {
9907
+ $label = $this->is_addon() ?
9908
+ $this->get_text_inline( 'Add-On', 'addon' ) :
9909
+ ( $this->is_plugin() ?
9910
+ $this->get_text_inline( 'Plugin', 'plugin' ) :
9911
+ $this->get_text_inline( 'Theme', 'theme' ) );
9912
+
9913
+ if ( $lowercase ) {
9914
+ $label = strtolower( $label );
9915
+ }
9916
+
9917
+ return $label;
9918
+ }
9919
+
9920
+ /**
9921
+ * @author Vova Feldman (@svovaf)
9922
+ * @since 1.0.4
9923
+ *
9924
+ * @return string
9925
+ */
9926
+ function get_plugin_basename() {
9927
+ if ( ! isset( $this->_plugin_basename ) ) {
9928
+ if ( $this->is_plugin() ) {
9929
+ $this->_plugin_basename = plugin_basename( $this->_plugin_main_file_path );
9930
+ } else {
9931
+ $this->_plugin_basename = basename( dirname( $this->_plugin_main_file_path ) );
9932
+ }
9933
+ }
9934
+
9935
+ return $this->_plugin_basename;
9936
+ }
9937
+
9938
+ function get_plugin_folder_name() {
9939
+ $this->_logger->entrance();
9940
+
9941
+ $plugin_folder = $this->_plugin_basename;
9942
+
9943
+ while ( '.' !== dirname( $plugin_folder ) ) {
9944
+ $plugin_folder = dirname( $plugin_folder );
9945
+ }
9946
+
9947
+ $this->_logger->departure( 'Folder Name = ' . $plugin_folder );
9948
+
9949
+ return $plugin_folder;
9950
+ }
9951
+
9952
+ #endregion ------------------------------------------------------------------
9953
+
9954
+ /* Account
9955
+ ------------------------------------------------------------------------------------------------------------------*/
9956
+
9957
+ /**
9958
+ * Find plugin's slug by plugin's basename.
9959
+ *
9960
+ * @author Vova Feldman (@svovaf)
9961
+ * @since 1.0.9
9962
+ *
9963
+ * @param string $plugin_base_name
9964
+ *
9965
+ * @return false|string
9966
+ */
9967
+ private static function find_slug_by_basename( $plugin_base_name ) {
9968
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
9969
+
9970
+ if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) {
9971
+ return false;
9972
+ }
9973
+
9974
+ return $file_slug_map[ $plugin_base_name ];
9975
+ }
9976
+
9977
+ /**
9978
+ * Store the map between the plugin's basename to the slug.
9979
+ *
9980
+ * @author Vova Feldman (@svovaf)
9981
+ * @since 1.0.9
9982
+ */
9983
+ private function store_file_slug_map() {
9984
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
9985
+
9986
+ if ( ! array( $file_slug_map ) ) {
9987
+ $file_slug_map = array();
9988
+ }
9989
+
9990
+ if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) ||
9991
+ $file_slug_map[ $this->_plugin_basename ] !== $this->_slug
9992
+ ) {
9993
+ $file_slug_map[ $this->_plugin_basename ] = $this->_slug;
9994
+ self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
9995
+ }
9996
+ }
9997
+
9998
+ /**
9999
+ * @return array[number]FS_User
10000
+ */
10001
+ static function get_all_users() {
10002
+ $users = self::maybe_get_entities_account_option( 'users', array() );
10003
+
10004
+ if ( ! is_array( $users ) ) {
10005
+ $users = array();
10006
+ }
10007
+
10008
+ return $users;
10009
+ }
10010
+
10011
+ /**
10012
+ * @param string $module_type
10013
+ * @param null|int $blog_id Since 2.0.0
10014
+ *
10015
+ * @return array[string]FS_Site
10016
+ */
10017
+ private static function get_all_sites(
10018
+ $module_type = WP_FS__MODULE_TYPE_PLUGIN,
10019
+ $blog_id = null
10020
+ ) {
10021
+ $sites = self::get_account_option( 'sites', $module_type, $blog_id );
10022
+
10023
+ if ( ! is_array( $sites ) ) {
10024
+ $sites = array();
10025
+ }
10026
+
10027
+ return $sites;
10028
+ }
10029
+
10030
+ /**
10031
+ * @author Leo Fajardo (@leorw)
10032
+ *
10033
+ * @since 1.2.2
10034
+ *
10035
+ * @param string $option_name
10036
+ * @param string $module_type
10037
+ * @param null|int $network_level_or_blog_id Since 2.0.0
10038
+ *
10039
+ * @return mixed
10040
+ */
10041
+ private static function get_account_option( $option_name, $module_type = null, $network_level_or_blog_id = null ) {
10042
+ if ( ! is_null( $module_type ) && WP_FS__MODULE_TYPE_PLUGIN !== $module_type ) {
10043
+ $option_name = $module_type . '_' . $option_name;
10044
+ }
10045
+
10046
+ return self::maybe_get_entities_account_option( $option_name, array(), $network_level_or_blog_id );
10047
+ }
10048
+
10049
+ /**
10050
+ * @author Leo Fajardo (@leorw)
10051
+ *
10052
+ * @since 1.2.2
10053
+ *
10054
+ * @param string $option_name
10055
+ * @param mixed $option_value
10056
+ * @param bool $store
10057
+ * @param null|int $network_level_or_blog_id Since 2.0.0
10058
+ */
10059
+ private function set_account_option( $option_name, $option_value, $store, $network_level_or_blog_id = null ) {
10060
+ self::set_account_option_by_module(
10061
+ $this->_module_type,
10062
+ $option_name,
10063
+ $option_value,
10064
+ $store,
10065
+ $network_level_or_blog_id
10066
+ );
10067
+ }
10068
+
10069
+ /**
10070
+ * @author Vova Feldman (@svovaf)
10071
+ *
10072
+ * @since 1.2.2.7
10073
+ *
10074
+ * @param string $module_type
10075
+ * @param string $option_name
10076
+ * @param mixed $option_value
10077
+ * @param bool $store
10078
+ * @param null|int $network_level_or_blog_id Since 2.0.0
10079
+ */
10080
+ private static function set_account_option_by_module(
10081
+ $module_type,
10082
+ $option_name,
10083
+ $option_value,
10084
+ $store,
10085
+ $network_level_or_blog_id = null
10086
+ ) {
10087
+ if ( WP_FS__MODULE_TYPE_PLUGIN != $module_type ) {
10088
+ $option_name = $module_type . '_' . $option_name;
10089
+ }
10090
+
10091
+ self::$_accounts->set_option( $option_name, $option_value, $store, $network_level_or_blog_id );
10092
+ }
10093
+
10094
+ /**
10095
+ * This method can also return non-entity or non-entities collection option like the `user_id_license_ids_map` option.
10096
+ *
10097
+ * @author Leo Fajardo (@leorw)
10098
+ * @since 2.3.1
10099
+ *
10100
+ * @param string $option_name
10101
+ * @param mixed $default
10102
+ * @param null|bool|int $network_level_or_blog_id When an integer, use the given blog storage. When `true` use the multisite storage (if there's a network). When `false`, use the current context blog storage. When `null`, the decision which storage to use (MS vs. Current S) will be handled internally and determined based on the $option (based on self::$_SITE_LEVEL_PARAMS).
10103
+ *
10104
+ * @return mixed|FS_Plugin[]|FS_User[]|FS_Site[]|FS_Plugin_License[]|FS_Plugin_Plan[]|FS_Plugin_Tag[]
10105
+ */
10106
+ private static function maybe_get_entities_account_option( $option_name, $default = null, $network_level_or_blog_id = null ) {
10107
+ $option = self::$_accounts->get_option( $option_name, $default, $network_level_or_blog_id );
10108
+
10109
+ $class_name = '';
10110
+
10111
+ switch ( $option_name ) {
10112
+ case 'plugins':
10113
+ case 'themes':
10114
+ case 'addons':
10115
+ $class_name = FS_Plugin::get_class_name();
10116
+ break;
10117
+ case 'users':
10118
+ $class_name = FS_User::get_class_name();
10119
+ break;
10120
+ case 'sites':
10121
+ $class_name = FS_Site::get_class_name();
10122
+ break;
10123
+ case 'licenses':
10124
+ case 'all_licenses':
10125
+ $class_name = FS_Plugin_License::get_class_name();
10126
+ break;
10127
+ case 'plans':
10128
+ $class_name = FS_Plugin_Plan::get_class_name();
10129
+ break;
10130
+ case 'updates':
10131
+ $class_name = FS_Plugin_Tag::get_class_name();
10132
+ break;
10133
+ }
10134
+
10135
+ if ( empty( $class_name ) ) {
10136
+ return $option;
10137
+ }
10138
+
10139
+ return fs_get_entities( $option, $class_name );
10140
+ }
10141
+
10142
+ /**
10143
+ * @author Vova Feldman (@svovaf)
10144
+ * @since 1.0.6
10145
+ *
10146
+ * @param number|null $module_id
10147
+ *
10148
+ * @return FS_Plugin_License[]
10149
+ */
10150
+ private static function get_all_licenses( $module_id = null ) {
10151
+ $licenses = self::get_account_option( 'all_licenses' );
10152
+
10153
+ if ( ! is_array( $licenses ) ) {
10154
+ $licenses = array();
10155
+ }
10156
+
10157
+ if ( is_null( $module_id ) ) {
10158
+ return $licenses;
10159
+ }
10160
+
10161
+ $licenses = isset( $licenses[ $module_id ] ) ?
10162
+ $licenses[ $module_id ] :
10163
+ array();
10164
+
10165
+ return $licenses;
10166
+ }
10167
+
10168
+ /**
10169
+ * @author Leo Fajardo (@leorw)
10170
+ * @since 2.0.0
10171
+ *
10172
+ * @return array
10173
+ */
10174
+ private static function get_all_licenses_by_module_type() {
10175
+ $licenses = self::get_account_option( 'all_licenses' );
10176
+
10177
+ $licenses_by_module_type = array(
10178
+ WP_FS__MODULE_TYPE_PLUGIN => array(),
10179
+ WP_FS__MODULE_TYPE_THEME => array()
10180
+ );
10181
+
10182
+ if ( ! is_array( $licenses ) ) {
10183
+ return $licenses_by_module_type;
10184
+ }
10185
+
10186
+ foreach ( $licenses as $module_id => $module_licenses ) {
10187
+ $fs = self::get_instance_by_id( $module_id );
10188
+ if ( false === $fs ) {
10189
+ continue;
10190
+ }
10191
+
10192
+ $licenses_by_module_type[ $fs->_module_type ] = array_merge( $licenses_by_module_type[ $fs->_module_type ], $module_licenses );
10193
+ }
10194
+
10195
+ return $licenses_by_module_type;
10196
+ }
10197
+
10198
+ /**
10199
+ * @author Leo Fajardo (@leorw)
10200
+ * @since 2.0.0
10201
+ *
10202
+ * @param number $module_id
10203
+ * @param number|null $user_id
10204
+ *
10205
+ * @return array
10206
+ */
10207
+ private static function get_user_id_license_ids_map( $module_id, $user_id = null ) {
10208
+ $all_modules_user_id_license_ids_map = self::get_account_option( 'user_id_license_ids_map' );
10209
+
10210
+ if ( ! is_array( $all_modules_user_id_license_ids_map ) ) {
10211
+ $all_modules_user_id_license_ids_map = array();
10212
+ }
10213
+
10214
+ $user_id_license_ids_map = isset( $all_modules_user_id_license_ids_map[ $module_id ] ) ?
10215
+ $all_modules_user_id_license_ids_map[ $module_id ] :
10216
+ array();
10217
+
10218
+ if ( FS_User::is_valid_id( $user_id ) ) {
10219
+ $user_id_license_ids_map = isset( $user_id_license_ids_map[ $user_id ] ) ?
10220
+ $user_id_license_ids_map[ $user_id ] :
10221
+ array();
10222
+ }
10223
+
10224
+ return $user_id_license_ids_map;
10225
+ }
10226
+
10227
+ /**
10228
+ * @author Leo Fajardo (@leorw)
10229
+ * @since 2.0.0
10230
+ *
10231
+ * @param array $new_user_id_license_ids_map
10232
+ * @param number $module_id
10233
+ * @param number|null $user_id
10234
+ */
10235
+ private static function store_user_id_license_ids_map( $new_user_id_license_ids_map, $module_id, $user_id = null ) {
10236
+ $all_modules_user_id_license_ids_map = self::get_account_option( 'user_id_license_ids_map' );
10237
+ if ( ! is_array( $all_modules_user_id_license_ids_map ) ) {
10238
+ $all_modules_user_id_license_ids_map = array();
10239
+ }
10240
+
10241
+ if ( ! isset( $all_modules_user_id_license_ids_map[ $module_id ] ) ) {
10242
+ $all_modules_user_id_license_ids_map[ $module_id ] = array();
10243
+ }
10244
+
10245
+ if ( FS_User::is_valid_id( $user_id ) ) {
10246
+ $all_modules_user_id_license_ids_map[ $module_id ][ $user_id ] = $new_user_id_license_ids_map;
10247
+ } else {
10248
+ $all_modules_user_id_license_ids_map[ $module_id ] = $new_user_id_license_ids_map;
10249
+ }
10250
+
10251
+ self::$_accounts->set_option( 'user_id_license_ids_map', $all_modules_user_id_license_ids_map, true );
10252
+ }
10253
+
10254
+ /**
10255
+ * Get a collection of the user's linked license IDs.
10256
+ *
10257
+ * @author Vova Feldman (@svovaf)
10258
+ * @since 2.0.0
10259
+ *
10260
+ * @param number $user_id
10261
+ *
10262
+ * @return number[]
10263
+ */
10264
+ private function get_user_linked_license_ids( $user_id ) {
10265
+ return self::get_user_id_license_ids_map( $this->_module_id, $user_id );
10266
+ }
10267
+
10268
+ /**
10269
+ * Override the user's linked license IDs with a new IDs collection.
10270
+ *
10271
+ * @author Vova Feldman (@svovaf)
10272
+ * @since 2.0.0
10273
+ *
10274
+ * @param number $user_id
10275
+ * @param number[] $license_ids
10276
+ */
10277
+ private function set_user_linked_license_ids( $user_id, array $license_ids ) {
10278
+ self::store_user_id_license_ids_map( $license_ids, $this->_module_id, $user_id );
10279
+ }
10280
+
10281
+ /**
10282
+ * Link a specified license ID to a given user.
10283
+ *
10284
+ * @author Vova Feldman (@svovaf)
10285
+ * @since 2.0.0
10286
+ *
10287
+ * @param number $license_id
10288
+ * @param number $user_id
10289
+ */
10290
+ private function link_license_2_user( $license_id, $user_id ) {
10291
+ $license_ids = $this->get_user_linked_license_ids( $user_id );
10292
+
10293
+ if ( in_array( $license_id, $license_ids ) ) {
10294
+ // License already linked.
10295
+ return;
10296
+ }
10297
+
10298
+ $license_ids[] = $license_id;
10299
+
10300
+ $this->set_user_linked_license_ids( $user_id, $license_ids );
10301
+ }
10302
+
10303
+ /**
10304
+ * @param string|bool $module_type
10305
+ *
10306
+ * @return FS_Plugin_Plan[]
10307
+ */
10308
+ private static function get_all_plans( $module_type = false ) {
10309
+ $plans = self::get_account_option( 'plans', $module_type );
10310
+
10311
+ if ( ! is_array( $plans ) ) {
10312
+ $plans = array();
10313
+ }
10314
+
10315
+ return $plans;
10316
+ }
10317
+
10318
+ /**
10319
+ * @author Vova Feldman (@svovaf)
10320
+ * @since 1.0.4
10321
+ *
10322
+ * @return FS_Plugin_Tag[]
10323
+ */
10324
+ private static function get_all_updates() {
10325
+ $updates = self::maybe_get_entities_account_option( 'updates', array() );
10326
+
10327
+ if ( ! is_array( $updates ) ) {
10328
+ $updates = array();
10329
+ }
10330
+
10331
+ return $updates;
10332
+ }
10333
+
10334
+ /**
10335
+ * @author Vova Feldman (@svovaf)
10336
+ * @since 1.0.6
10337
+ *
10338
+ * @return array<number,FS_Plugin[]>|false
10339
+ */
10340
+ private static function get_all_addons() {
10341
+ $addons = self::maybe_get_entities_account_option( 'addons', array() );
10342
+
10343
+ if ( ! is_array( $addons ) ) {
10344
+ $addons = array();
10345
+ }
10346
+
10347
+ return $addons;
10348
+ }
10349
+
10350
+ /**
10351
+ * @author Vova Feldman (@svovaf)
10352
+ * @since 1.0.6
10353
+ *
10354
+ * @return number[]|false
10355
+ */
10356
+ private static function get_all_account_addons() {
10357
+ $addons = self::$_accounts->get_option( 'account_addons', array() );
10358
+
10359
+ if ( ! is_array( $addons ) ) {
10360
+ $addons = array();
10361
+ }
10362
+
10363
+ return $addons;
10364
+ }
10365
+
10366
+ /**
10367
+ * Check if user has connected his account (opted-in).
10368
+ *
10369
+ * Note:
10370
+ * If the user opted-in and opted-out on a later stage,
10371
+ * this will still return true. If you want to check if the
10372
+ * user is currently opted-in, use:
10373
+ * `$fs->is_registered() && $fs->is_tracking_allowed()`
10374
+ *
10375
+ * @author Vova Feldman (@svovaf)
10376
+ * @since 1.0.1
10377
+ * @return bool
10378
+ */
10379
+ function is_registered() {
10380
+ return is_object( $this->_user );
10381
+ }
10382
+
10383
+ /**
10384
+ * Returns TRUE if the user opted-in and didn't disconnect (opt-out).
10385
+ *
10386
+ * @author Leo Fajardo (@leorw)
10387
+ * @since 1.2.1.5
10388
+ *
10389
+ * @return bool
10390
+ */
10391
+ function is_tracking_allowed() {
10392
+ return ( is_object( $this->_site ) && $this->_site->is_tracking_allowed() );
10393
+ }
10394
+
10395
+ /**
10396
+ * @author Vova Feldman (@svovaf)
10397
+ * @since 1.0.4
10398
+ *
10399
+ * @return FS_Plugin
10400
+ */
10401
+ function get_plugin() {
10402
+ return $this->_plugin;
10403
+ }
10404
+
10405
+ /**
10406
+ * @author Vova Feldman (@svovaf)
10407
+ * @since 1.0.3
10408
+ *
10409
+ * @return FS_User
10410
+ */
10411
+ function get_user() {
10412
+ return $this->_user;
10413
+ }
10414
+
10415
+ /**
10416
+ * @author Vova Feldman (@svovaf)
10417
+ * @since 1.0.3
10418
+ *
10419
+ * @return FS_Site
10420
+ */
10421
+ function get_site() {
10422
+ return $this->_site;
10423
+ }
10424
+
10425
+ /**
10426
+ * Get plugin add-ons.
10427
+ *
10428
+ * @author Vova Feldman (@svovaf)
10429
+ * @since 1.0.6
10430
+ *
10431
+ * @since 1.1.7.3 If not yet loaded, fetch data from the API.
10432
+ *
10433
+ * @param bool $flush
10434
+ *
10435
+ * @return FS_Plugin[]|false
10436
+ */
10437
+ function get_addons( $flush = false ) {
10438
+ $this->_logger->entrance();
10439
+
10440
+ if ( ! $this->_has_addons ) {
10441
+ return false;
10442
+ }
10443
+
10444
+ $addons = $this->sync_addons( $flush );
10445
+
10446
+ return ( ! is_array( $addons ) || empty( $addons ) ) ?
10447
+ false :
10448
+ $addons;
10449
+ }
10450
+
10451
+ /**
10452
+ * @author Vova Feldman (@svovaf)
10453
+ * @since 1.0.6
10454
+ *
10455
+ * @return number[]|false
10456
+ */
10457
+ function get_account_addons() {
10458
+ $this->_logger->entrance();
10459
+
10460
+ $addons = self::get_all_account_addons();
10461
+
10462
+ if ( ! is_array( $addons ) ||
10463
+ ! isset( $addons[ $this->_plugin->id ] ) ||
10464
+ ! is_array( $addons[ $this->_plugin->id ] ) ||
10465
+ 0 === count( $addons[ $this->_plugin->id ] )
10466
+ ) {
10467
+ return false;
10468
+ }
10469
+
10470
+ return $addons[ $this->_plugin->id ];
10471
+ }
10472
+
10473
+ /**
10474
+ * Check if user has any
10475
+ *
10476
+ * @author Vova Feldman (@svovaf)
10477
+ * @since 1.1.6
10478
+ *
10479
+ * @return bool
10480
+ */
10481
+ function has_account_addons() {
10482
+ $addons = $this->get_account_addons();
10483
+
10484
+ return is_array( $addons ) && ( 0 < count( $addons ) );
10485
+ }
10486
+
10487
+
10488
+ /**
10489
+ * Get add-on by ID (from local data).
10490
+ *
10491
+ * @author Vova Feldman (@svovaf)
10492
+ * @since 1.0.6
10493
+ *
10494
+ * @param number $id
10495
+ *
10496
+ * @return FS_Plugin|false
10497
+ */
10498
+ function get_addon( $id ) {
10499
+ $this->_logger->entrance();
10500
+
10501
+ $addons = $this->get_addons();
10502
+
10503
+ if ( is_array( $addons ) ) {
10504
+ foreach ( $addons as $addon ) {
10505
+ if ( $id == $addon->id ) {
10506
+ return $addon;
10507
+ }
10508
+ }
10509
+ }
10510
+
10511
+ return false;
10512
+ }
10513
+
10514
+ /**
10515
+ * Get add-on by slug (from local data).
10516
+ *
10517
+ * @author Vova Feldman (@svovaf)
10518
+ * @since 1.0.6
10519
+ *
10520
+ * @param string $slug
10521
+ *
10522
+ * @param bool $flush
10523
+ *
10524
+ * @return FS_Plugin|false
10525
+ */
10526
+ function get_addon_by_slug( $slug, $flush = false ) {
10527
+ $this->_logger->entrance();
10528
+
10529
+ $addons = $this->get_addons( $flush );
10530
+
10531
+ if ( is_array( $addons ) ) {
10532
+ foreach ( $addons as $addon ) {
10533
+ if ( $slug === $addon->slug ) {
10534
+ return $addon;
10535
+ }
10536
+ }
10537
+ }
10538
+
10539
+ return false;
10540
+ }
10541
+
10542
+ /**
10543
+ * @var array<number,object[]> {
10544
+ * @key number Add-on ID.
10545
+ * @val object[] The add-on's plans and prices object.
10546
+ * }
10547
+ */
10548
+ private $plans_and_pricing_by_addon_id;
10549
+
10550
+ /**
10551
+ * @author Leo Fajardo (@leorw)
10552
+ * @since 2.3.0
10553
+ *
10554
+ * @return array<number,object[]> {
10555
+ * @key number Add-on ID.
10556
+ * @val object[] The add-on's plans and prices object.
10557
+ * }
10558
+ */
10559
+ function _get_addons_plans_and_pricing_map_by_id() {
10560
+ if ( ! isset( $this->plans_and_pricing_by_addon_id ) ) {
10561
+ $result = $this->get_api_plugin_scope()->get( $this->add_show_pending( "/addons/pricing.json?type=visible" ) );
10562
+
10563
+ $plans_and_pricing_by_addon_id = array();
10564
+ if ( $this->is_api_result_object( $result, 'addons' ) ) {
10565
+ foreach ( $result->addons as $addon ) {
10566
+ $plans_and_pricing_by_addon_id[ $addon->id ] = $addon->plans;
10567
+ }
10568
+ }
10569
+
10570
+ $this->plans_and_pricing_by_addon_id = $plans_and_pricing_by_addon_id;
10571
+ }
10572
+
10573
+ return $this->plans_and_pricing_by_addon_id;
10574
+ }
10575
+
10576
+ /**
10577
+ * @author Leo Fajardo (@leorw)
10578
+ * @since 2.3.0
10579
+ *
10580
+ * @param number $addon_id
10581
+ * @param bool $is_installed
10582
+ *
10583
+ * @return array
10584
+ */
10585
+ function _get_addon_info( $addon_id, $is_installed ) {
10586
+ $addon = $this->get_addon( $addon_id );
10587
+
10588
+ if ( ! is_object( $addon ) ) {
10589
+ // Unexpected call.
10590
+ return array();
10591
+ }
10592
+
10593
+ $slug = $addon->slug;
10594
+
10595
+ $addon_storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
10596
+
10597
+ if ( ! fs_is_network_admin() ) {
10598
+ // Get blog-level activated installations.
10599
+ $sites = self::maybe_get_entities_account_option( 'sites', array() );
10600
+ } else {
10601
+ $sites = null;
10602
+
10603
+ if ( $this->is_addon_activated( $addon_id ) &&
10604
+ $this->get_addon_instance( $addon_id )->is_network_active()
10605
+ ) {
10606
+ if ( FS_Site::is_valid_id( $addon_storage->network_install_blog_id ) ) {
10607
+ // Get network-level activated installations.
10608
+ $sites = self::maybe_get_entities_account_option(
10609
+ 'sites',
10610
+ array(),
10611
+ $addon_storage->network_install_blog_id
10612
+ );
10613
+ }
10614
+ }
10615
+ }
10616
+
10617
+ $addon_info = array(
10618
+ 'is_connected' => false,
10619
+ 'slug' => $slug,
10620
+ 'title' => $addon->title,
10621
+ 'is_whitelabeled' => $addon_storage->is_whitelabeled
10622
+ );
10623
+
10624
+ if ( ! $is_installed ) {
10625
+ $plans_and_pricing_by_addon_id = $this->_get_addons_plans_and_pricing_map_by_id();
10626
+
10627
+ if ( isset( $plans_and_pricing_by_addon_id[ $addon_id ] ) ) {
10628
+ $has_paid_plan = false;
10629
+ $plans = $plans_and_pricing_by_addon_id[ $addon_id ];
10630
+
10631
+ if ( is_array( $plans ) && count( $plans ) > 0 ) {
10632
+ foreach ( $plans as $plan ) {
10633
+ if ( isset( $plan->pricing ) &&
10634
+ is_array( $plan->pricing ) &&
10635
+ count( $plan->pricing ) > 0
10636
+ ) {
10637
+ $has_paid_plan = true;
10638
+ break;
10639
+ }
10640
+ }
10641
+ }
10642
+
10643
+ $addon_info['has_paid_plan'] = $has_paid_plan;
10644
+ }
10645
+ }
10646
+
10647
+ if ( ! is_array( $sites ) || ! isset( $sites[ $slug ] ) ) {
10648
+ return $addon_info;
10649
+ }
10650
+
10651
+ $site = $sites[ $slug ];
10652
+
10653
+ $addon_info['is_connected'] = (
10654
+ ( $addon->parent_plugin_id == $this->get_id() ) &&
10655
+ is_object( $site ) &&
10656
+ FS_Site::is_valid_id( $site->id ) &&
10657
+ FS_User::is_valid_id( $site->user_id ) &&
10658
+ FS_Plugin_Plan::is_valid_id( $site->plan_id )
10659
+ );
10660
+
10661
+ if ( $addon_info['is_connected'] && $is_installed ) {
10662
+ return $addon_info;
10663
+ }
10664
+
10665
+ $addon_info['site'] = $site;
10666
+
10667
+ $plugins_data = self::maybe_get_entities_account_option( WP_FS__MODULE_TYPE_PLUGIN . 's', array() );
10668
+ if ( isset( $plugins_data[ $slug ] ) ) {
10669
+ $plugin_data = $plugins_data[ $slug ];
10670
+
10671
+ $addon_info['version'] = $plugin_data->version;
10672
+ }
10673
+
10674
+ $all_plans = self::maybe_get_entities_account_option( 'plans', array() );
10675
+ if ( isset( $all_plans[ $slug ] ) ) {
10676
+ $plans = $all_plans[ $slug ];
10677
+
10678
+ foreach ( $plans as $plan ) {
10679
+ if ( $site->plan_id == Freemius::_decrypt( $plan->id ) ) {
10680
+ $addon_info['plan_name'] = Freemius::_decrypt( $plan->name );
10681
+ $addon_info['plan_title'] = Freemius::_decrypt( $plan->title );
10682
+ break;
10683
+ }
10684
+ }
10685
+ }
10686
+
10687
+ $licenses = self::maybe_get_entities_account_option( 'all_licenses', array() );
10688
+ if ( is_array( $licenses ) && isset( $licenses[ $addon_id ] ) ) {
10689
+ foreach ( $licenses[ $addon_id ] as $license ) {
10690
+ if ( $license->id == $site->license_id ) {
10691
+ $addon_info['license'] = $license;
10692
+ break;
10693
+ }
10694
+ }
10695
+ }
10696
+
10697
+ if ( isset( $addon_info['license'] ) ) {
10698
+ if ( isset( $addon_storage->subscriptions ) &&
10699
+ ! empty( $addon_storage->subscriptions )
10700
+ ) {
10701
+ $addon_subscriptions = fs_get_entities( $addon_storage->subscriptions, FS_Subscription::get_class_name() );
10702
+
10703
+ foreach ( $addon_subscriptions as $subscription ) {
10704
+ if ( $subscription->license_id == $site->license_id ) {
10705
+ $addon_info['subscription'] = $subscription;
10706
+ break;
10707
+ }
10708
+ }
10709
+ }
10710
+ }
10711
+
10712
+ return $addon_info;
10713
+ }
10714
+
10715
+ /**
10716
+ * @author Vova Feldman (@svovaf)
10717
+ * @since 2.0.0
10718
+ *
10719
+ * @param number $user_id
10720
+ *
10721
+ * @return FS_User
10722
+ */
10723
+ static function _get_user_by_id( $user_id ) {
10724
+ self::$_static_logger->entrance( "user_id = {$user_id}" );
10725
+
10726
+ $users = self::get_all_users();
10727
+
10728
+ if ( is_array( $users ) ) {
10729
+ if ( isset( $users[ $user_id ] ) &&
10730
+ $users[ $user_id ] instanceof FS_User &&
10731
+ $user_id == $users[ $user_id ]->id
10732
+ ) {
10733
+ return $users[ $user_id ];
10734
+ }
10735
+
10736
+ // If user wasn't found by the key, iterate over all the users collection.
10737
+ foreach ( $users as $user ) {
10738
+ /**
10739
+ * @var FS_User $user
10740
+ */
10741
+ if ( $user_id == $user->id ) {
10742
+ return $user;
10743
+ }
10744
+ }
10745
+ }
10746
+
10747
+ return null;
10748
+ }
10749
+
10750
+ /**
10751
+ * Checks if a Freemius user_id is associated with a super-admin.
10752
+ *
10753
+ * @author Vova Feldman (@svovaf)
10754
+ * @since 2.0.0
10755
+ *
10756
+ * @param number $user_id
10757
+ *
10758
+ * @return bool
10759
+ */
10760
+ private static function is_super_admin( $user_id ) {
10761
+ $is_super_admin = false;
10762
+
10763
+ $user = self::_get_user_by_id( $user_id );
10764
+
10765
+ if ( $user instanceof FS_User && ! empty( $user->email ) ) {
10766
+ self::require_pluggable_essentials();
10767
+
10768
+ $wp_user = get_user_by( 'email', $user->email );
10769
+
10770
+ if ( $wp_user instanceof WP_User ) {
10771
+ $super_admins = get_super_admins();
10772
+ $is_super_admin = ( is_array( $super_admins ) && in_array( $wp_user->user_login, $super_admins ) );
10773
+ }
10774
+ }
10775
+
10776
+ return $is_super_admin;
10777
+ }
10778
+
10779
+ #----------------------------------------------------------------------------------
10780
+ #region Plans & Licensing
10781
+ #----------------------------------------------------------------------------------
10782
+
10783
+ /**
10784
+ * Check if running premium plugin code.
10785
+ *
10786
+ * @author Vova Feldman (@svovaf)
10787
+ * @since 1.0.5
10788
+ *
10789
+ * @return bool
10790
+ */
10791
+ function is_premium() {
10792
+ /**
10793
+ * `$this->_plugin` will be `false` when `is_activation_mode` calls this method directly from the
10794
+ * `register_constructor_hooks` method.
10795
+ *
10796
+ * @author Leo Fajardo (@leorw)
10797
+ * @since 2.2.3
10798
+ */
10799
+ return is_object( $this->_plugin ) ?
10800
+ $this->_plugin->is_premium :
10801
+ false;
10802
+ }
10803
+
10804
+ /**
10805
+ * Get site's plan ID.
10806
+ *
10807
+ * @author Vova Feldman (@svovaf)
10808
+ * @since 1.0.2
10809
+ *
10810
+ * @return number
10811
+ */
10812
+ function get_plan_id() {
10813
+ return $this->_site->plan_id;
10814
+ }
10815
+
10816
+ /**
10817
+ * Get site's plan title.
10818
+ *
10819
+ * @author Vova Feldman (@svovaf)
10820
+ * @since 1.0.2
10821
+ *
10822
+ * @return string
10823
+ */
10824
+ function get_plan_title() {
10825
+ $plan = $this->get_plan();
10826
+
10827
+ return is_object( $plan ) ? $plan->title : 'PLAN_TITLE';
10828
+ }
10829
+
10830
+ /**
10831
+ * Get site's plan name.
10832
+ *
10833
+ * @author Vova Feldman (@svovaf)
10834
+ * @since 2.0.0
10835
+ *
10836
+ * @return string
10837
+ */
10838
+ function get_plan_name() {
10839
+ $plan = $this->get_plan();
10840
+
10841
+ return is_object( $plan ) ? $plan->name : 'PLAN_NAME';
10842
+ }
10843
+
10844
+ /**
10845
+ * @author Vova Feldman (@svovaf)
10846
+ * @since 1.0.9
10847
+ *
10848
+ * @return FS_Plugin_Plan|false
10849
+ */
10850
+ function get_plan() {
10851
+ if ( ! is_object( $this->_site ) ) {
10852
+ return false;
10853
+ }
10854
+
10855
+ return FS_Plugin_Plan::is_valid_id( $this->_site->plan_id ) ?
10856
+ $this->_get_plan_by_id( $this->_site->plan_id ) :
10857
+ false;
10858
+ }
10859
+
10860
+ /**
10861
+ * @author Vova Feldman (@svovaf)
10862
+ * @since 1.0.3
10863
+ *
10864
+ * @return bool
10865
+ */
10866
+ function is_trial() {
10867
+ $this->_logger->entrance();
10868
+
10869
+ if ( ! $this->is_registered() || ! is_object( $this->_site ) ) {
10870
+ return false;
10871
+ }
10872
+
10873
+ return $this->_site->is_trial();
10874
+ }
10875
+
10876
+ /**
10877
+ * Check if currently in a trial with payment method (credit card or paypal).
10878
+ *
10879
+ * @author Vova Feldman (@svovaf)
10880
+ * @since 1.1.7
10881
+ *
10882
+ * @return bool
10883
+ */
10884
+ function is_paid_trial() {
10885
+ $this->_logger->entrance();
10886
+
10887
+ if ( ! $this->is_trial() ) {
10888
+ return false;
10889
+ }
10890
+
10891
+ if ( ! $this->has_active_valid_license() ) {
10892
+ return false;
10893
+ }
10894
+
10895
+ if ( $this->_site->trial_plan_id != $this->_license->plan_id ) {
10896
+ return false;
10897
+ }
10898
+
10899
+ /**
10900
+ * @var FS_Subscription $subscription
10901
+ */
10902
+ $subscription = $this->_get_subscription( $this->_license->id );
10903
+
10904
+ return ( is_object( $subscription ) && $subscription->is_active() );
10905
+ }
10906
+
10907
+ /**
10908
+ * Check if trial already utilized.
10909
+ *
10910
+ * @since 1.0.9
10911
+ *
10912
+ * @return bool
10913
+ */
10914
+ function is_trial_utilized() {
10915
+ $this->_logger->entrance();
10916
+
10917
+ if ( ! $this->is_registered() ) {
10918
+ return false;
10919
+ }
10920
+
10921
+ return $this->_site->is_trial_utilized();
10922
+ }
10923
+
10924
+ /**
10925
+ * Get trial plan information (if in trial).
10926
+ *
10927
+ * @author Vova Feldman (@svovaf)
10928
+ * @since 1.0.9
10929
+ *
10930
+ * @return bool|FS_Plugin_Plan
10931
+ */
10932
+ function get_trial_plan() {
10933
+ $this->_logger->entrance();
10934
+
10935
+ if ( ! $this->is_trial() ) {
10936
+ return false;
10937
+ }
10938
+
10939
+ // Try to load plan from local cache.
10940
+ $trial_plan = $this->_get_plan_by_id( $this->_site->trial_plan_id );
10941
+
10942
+ if ( ! is_object( $trial_plan ) ) {
10943
+ $trial_plan = $this->_fetch_site_plan( $this->_site->trial_plan_id );
10944
+
10945
+ /**
10946
+ * If managed to fetch the plan, add it to the plans collection.
10947
+ */
10948
+ if ( $trial_plan instanceof FS_Plugin_Plan ) {
10949
+ if ( ! is_array( $this->_plans ) ) {
10950
+ $this->_plans = array();
10951
+ }
10952
+
10953
+ $this->_plans[] = $trial_plan;
10954
+ $this->_store_plans();
10955
+ }
10956
+ }
10957
+
10958
+ if ( $trial_plan instanceof FS_Plugin_Plan ) {
10959
+ return $trial_plan;
10960
+ }
10961
+
10962
+ /**
10963
+ * If for some reason failed to get the trial plan, fallback to a dummy name and title.
10964
+ */
10965
+ $trial_plan = new FS_Plugin_Plan();
10966
+ $trial_plan->id = $this->_site->trial_plan_id;
10967
+ $trial_plan->name = 'pro';
10968
+ $trial_plan->title = 'Pro';
10969
+
10970
+ return $trial_plan;
10971
+ }
10972
+
10973
+ /**
10974
+ * Check if the user has an activate, non-expired license on current plugin's install.
10975
+ *
10976
+ * @since 1.0.9
10977
+ *
10978
+ * @return bool
10979
+ */
10980
+ function is_paying() {
10981
+ $this->_logger->entrance();
10982
+
10983
+ if ( ! $this->is_registered() ) {
10984
+ return false;
10985
+ }
10986
+
10987
+ if ( ! $this->has_paid_plan() ) {
10988
+ return false;
10989
+ }
10990
+
10991
+ return (
10992
+ ! $this->is_trial() &&
10993
+ 'free' !== $this->get_plan_name() &&
10994
+ $this->has_active_valid_license()
10995
+ );
10996
+ }
10997
+
10998
+ /**
10999
+ * @author Vova Feldman (@svovaf)
11000
+ * @since 1.0.4
11001
+ *
11002
+ * @return bool
11003
+ */
11004
+ function is_free_plan() {
11005
+ if ( ! $this->is_registered() ) {
11006
+ return true;
11007
+ }
11008
+
11009
+ if ( ! $this->has_paid_plan() ) {
11010
+ return true;
11011
+ }
11012
+
11013
+ return (
11014
+ 'free' === $this->get_plan_name() ||
11015
+ ! $this->has_features_enabled_license()
11016
+ );
11017
+ }
11018
+
11019
+ /**
11020
+ * @author Vova Feldman (@svovaf)
11021
+ * @since 1.0.5
11022
+ *
11023
+ * @return bool
11024
+ */
11025
+ function _has_premium_license() {
11026
+ $this->_logger->entrance();
11027
+
11028
+ $premium_license = $this->_get_available_premium_license();
11029
+
11030
+ return ( false !== $premium_license );
11031
+ }
11032
+
11033
+ /**
11034
+ * Check if user has any licenses associated with the plugin (including expired or blocking).
11035
+ *
11036
+ * @author Vova Feldman (@svovaf)
11037
+ * @since 1.1.7.3
11038
+ *
11039
+ * @param bool $including_foreign
11040
+ *
11041
+ * @return bool
11042
+ */
11043
+ function has_any_license( $including_foreign = true ) {
11044
+ if ( ! is_array( $this->_licenses ) || 0 === count( $this->_licenses ) ) {
11045
+ return false;
11046
+ }
11047
+
11048
+ if ( $including_foreign ) {
11049
+ return true;
11050
+ }
11051
+
11052
+ foreach ( $this->_licenses as $license ) {
11053
+ if ( $this->_user->id == $license->user_id ) {
11054
+ return true;
11055
+ }
11056
+ }
11057
+
11058
+ return false;
11059
+ }
11060
+
11061
+ /**
11062
+ * @author Vova Feldman (@svovaf)
11063
+ * @since 1.0.5
11064
+ *
11065
+ * @param bool|null $is_localhost
11066
+ *
11067
+ * @return FS_Plugin_License|false
11068
+ */
11069
+ function _get_available_premium_license( $is_localhost = null ) {
11070
+ $this->_logger->entrance();
11071
+
11072
+ $licenses = $this->get_available_premium_licenses( $is_localhost );
11073
+ if ( ! empty( $licenses ) ) {
11074
+ return $licenses[0];
11075
+ }
11076
+
11077
+ return false;
11078
+ }
11079
+
11080
+ /**
11081
+ * @author Vova Feldman (@svovaf)
11082
+ * @since 1.0.5
11083
+ *
11084
+ * @param bool|null $is_localhost
11085
+ *
11086
+ * @return FS_Plugin_License[]
11087
+ */
11088
+ function get_available_premium_licenses( $is_localhost = null ) {
11089
+ $this->_logger->entrance();
11090
+
11091
+ $licenses = array();
11092
+ if ( ! $this->has_paid_plan() ) {
11093
+ return $licenses;
11094
+ }
11095
+
11096
+ if ( is_array( $this->_licenses ) ) {
11097
+ foreach ( $this->_licenses as $license ) {
11098
+ if ( ! $license->can_activate( $is_localhost ) ) {
11099
+ continue;
11100
+ }
11101
+
11102
+ $licenses[] = $license;
11103
+ }
11104
+ }
11105
+
11106
+ return $licenses;
11107
+ }
11108
+
11109
+ /**
11110
+ * Sync local plugin plans with remote server.
11111
+ *
11112
+ * IMPORTANT: If for some reason a site is associated with deleted plan, we'll preserve the plan's information and append it as the last plan. This means that if plan is deleted, the is_plan() method will ALWAYS return true for any given argument (it becomes the most inclusive plan).
11113
+ *
11114
+ * @author Vova Feldman (@svovaf)
11115
+ * @since 1.0.5
11116
+ *
11117
+ * @return FS_Plugin_Plan[]|object
11118
+ */
11119
+ function _sync_plans() {
11120
+ $plans = $this->_fetch_plugin_plans();
11121
+
11122
+ if ( $this->is_array_instanceof( $plans, 'FS_Plugin_Plan' ) ) {
11123
+ $plans_map = array();
11124
+ foreach ( $plans as $plan ) {
11125
+ $plans_map[ $plan->id ] = true;
11126
+ }
11127
+
11128
+ $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs();
11129
+
11130
+ foreach ( $plans_ids_to_keep as $plan_id ) {
11131
+ if ( isset( $plans_map[ $plan_id ] ) ) {
11132
+ continue;
11133
+ }
11134
+
11135
+ $missing_plan = self::_get_plan_by_id( $plan_id );
11136
+
11137
+ if ( is_object( $missing_plan ) ) {
11138
+ $plans[] = $missing_plan;
11139
+ }
11140
+ }
11141
+
11142
+ $this->_plans = $plans;
11143
+ $this->_store_plans();
11144
+ }
11145
+
11146
+ $this->do_action( 'after_plans_sync', $plans );
11147
+
11148
+ return $this->_plans;
11149
+ }
11150
+
11151
+ /**
11152
+ * Check if specified plan exists locally. If not, fetch it and store it.
11153
+ *
11154
+ * @author Vova Feldman (@svovaf)
11155
+ * @since 2.0.0
11156
+ *
11157
+ * @param number $plan_id
11158
+ *
11159
+ * @return \FS_Plugin_Plan|object The plan entity or the API error object on failure.
11160
+ */
11161
+ private function sync_plan_if_not_exist( $plan_id ) {
11162
+ $plan = self::_get_plan_by_id( $plan_id );
11163
+
11164
+ if ( is_object( $plan ) ) {
11165
+ // Plan already exists.
11166
+ return $plan;
11167
+ }
11168
+
11169
+ $plan = $this->fetch_plan_by_id( $plan_id );
11170
+
11171
+ if ( $plan instanceof FS_Plugin_Plan ) {
11172
+ $this->_plans[] = $plan;
11173
+ $this->_store_plans();
11174
+
11175
+ return $plan;
11176
+ }
11177
+
11178
+ return $plan;
11179
+ }
11180
+
11181
+ /**
11182
+ * Check if specified license exists locally. If not, fetch it and store it.
11183
+ *
11184
+ * @author Vova Feldman (@svovaf)
11185
+ * @since 2.0.0
11186
+ *
11187
+ * @param number $license_id
11188
+ * @param string $license_key
11189
+ *
11190
+ * @return \FS_Plugin_Plan|object The plan entity or the API error object on failure.
11191
+ */
11192
+ private function sync_license_if_not_exist( $license_id, $license_key ) {
11193
+ $license = $this->_get_license_by_id( $license_id );
11194
+
11195
+ if ( is_object( $license ) ) {
11196
+ // License already exists.
11197
+ return $license;
11198
+ }
11199
+
11200
+ $license = $this->fetch_license_by_key( $license_id, $license_key );
11201
+
11202
+ if ( $license instanceof FS_Plugin_License ) {
11203
+ $this->_licenses[] = $license;
11204
+
11205
+ $this->set_license( $license );
11206
+
11207
+ $this->_store_licenses();
11208
+
11209
+ return $license;
11210
+ }
11211
+
11212
+ return $license;
11213
+ }
11214
+
11215
+ /**
11216
+ * Get a collection of unique plan IDs that are associated with any installs in the network.
11217
+ *
11218
+ * @author Leo Fajardo (@leorw)
11219
+ * @since 2.0.0
11220
+ *
11221
+ * @return number[]
11222
+ */
11223
+ private function get_plans_ids_associated_with_installs() {
11224
+ if ( ! is_multisite() ) {
11225
+ if ( ! is_object( $this->_site ) ||
11226
+ ! FS_Plugin_Plan::is_valid_id( $this->_site->plan_id )
11227
+ ) {
11228
+ return array();
11229
+ }
11230
+
11231
+ return array( $this->_site->plan_id );
11232
+ }
11233
+
11234
+ $plan_ids = array();
11235
+ $sites = self::get_sites();
11236
+ foreach ( $sites as $site ) {
11237
+ $blog_id = self::get_site_blog_id( $site );
11238
+ $install = $this->get_install_by_blog_id( $blog_id );
11239
+
11240
+ if ( ! is_object( $install ) ||
11241
+ ! FS_Plugin_Plan::is_valid_id( $install->plan_id )
11242
+ ) {
11243
+ continue;
11244
+ }
11245
+
11246
+ $plan_ids[ $install->plan_id ] = true;
11247
+ }
11248
+
11249
+ return array_keys( $plan_ids );
11250
+ }
11251
+
11252
+ /**
11253
+ * Get a collection of unique license IDs that are associated with any installs in the network.
11254
+ *
11255
+ * @author Leo Fajardo (@leorw)
11256
+ * @since 2.0.0
11257
+ *
11258
+ * @return number[]
11259
+ */
11260
+ private function get_license_ids_associated_with_installs() {
11261
+ if ( ! $this->_is_network_active ) {
11262
+ if ( ! is_object( $this->_site ) ||
11263
+ ! FS_Plugin_License::is_valid_id( $this->_site->license_id )
11264
+ ) {
11265
+ return array();
11266
+ }
11267
+
11268
+ return array( $this->_site->license_id );
11269
+ }
11270
+
11271
+ $license_ids = array();
11272
+ $sites = self::get_sites();
11273
+ foreach ( $sites as $site ) {
11274
+ $blog_id = self::get_site_blog_id( $site );
11275
+ $install = $this->get_install_by_blog_id( $blog_id );
11276
+
11277
+ if ( ! is_object( $install ) ||
11278
+ ! FS_Plugin_License::is_valid_id( $install->license_id )
11279
+ ) {
11280
+ continue;
11281
+ }
11282
+
11283
+ $license_ids[ $install->license_id ] = true;
11284
+ }
11285
+
11286
+ return array_keys( $license_ids );
11287
+ }
11288
+
11289
+ /**
11290
+ * @author Vova Feldman (@svovaf)
11291
+ * @since 1.0.5
11292
+ *
11293
+ * @param number $id
11294
+ *
11295
+ * @return FS_Plugin_Plan|false
11296
+ */
11297
+ function _get_plan_by_id( $id ) {
11298
+ $this->_logger->entrance();
11299
+
11300
+ if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
11301
+ $this->_sync_plans();
11302
+ }
11303
+
11304
+ foreach ( $this->_plans as $plan ) {
11305
+ if ( $id == $plan->id ) {
11306
+ return $plan;
11307
+ }
11308
+ }
11309
+
11310
+ return false;
11311
+ }
11312
+
11313
+ /**
11314
+ * @author Vova Feldman (@svovaf)
11315
+ * @since 1.1.8.1
11316
+ *
11317
+ * @param string $name
11318
+ *
11319
+ * @return FS_Plugin_Plan|false
11320
+ */
11321
+ private function get_plan_by_name( $name ) {
11322
+ $this->_logger->entrance();
11323
+
11324
+ if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
11325
+ $this->_sync_plans();
11326
+ }
11327
+
11328
+ foreach ( $this->_plans as $plan ) {
11329
+ if ( $name == $plan->name ) {
11330
+ return $plan;
11331
+ }
11332
+ }
11333
+
11334
+ return false;
11335
+ }
11336
+
11337
+ /**
11338
+ * Sync local licenses with remote server.
11339
+ *
11340
+ * @author Vova Feldman (@svovaf)
11341
+ * @since 1.0.6
11342
+ *
11343
+ * @param number|bool $site_license_id
11344
+ * @param number|null $blog_id
11345
+ *
11346
+ * @return FS_Plugin_License[]|object
11347
+ */
11348
+ function _sync_licenses( $site_license_id = false, $blog_id = null ) {
11349
+ $this->_logger->entrance();
11350
+
11351
+ $is_network_admin = fs_is_network_admin();
11352
+
11353
+ if ( $is_network_admin && is_null( $blog_id ) ) {
11354
+ $all_licenses = self::get_all_licenses( $this->_module_id );
11355
+ } else {
11356
+ $all_licenses = $this->get_user_licenses( $this->_user->id );
11357
+ }
11358
+
11359
+ $foreign_licenses = $this->get_foreign_licenses_info( $all_licenses, $site_license_id );
11360
+
11361
+ $all_licenses_map = array();
11362
+ foreach ( $all_licenses as $license ) {
11363
+ $all_licenses_map[ $license->id ] = true;
11364
+ }
11365
+
11366
+ $licenses = $this->_fetch_licenses( false, $site_license_id, $foreign_licenses, $blog_id );
11367
+
11368
+ if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
11369
+ $licenses_map = array();
11370
+ foreach ( $licenses as $license ) {
11371
+ $licenses_map[ $license->id ] = true;
11372
+ }
11373
+
11374
+ // $license_ids_to_keep = $this->get_license_ids_associated_with_installs();
11375
+ // foreach ( $license_ids_to_keep as $license_id ) {
11376
+ // if ( isset( $licenses_map[ $license_id ] ) ) {
11377
+ // continue;
11378
+ // }
11379
+ //
11380
+ // $missing_license = self::_get_license_by_id( $license_id, false );
11381
+ // if ( is_object( $missing_license ) ) {
11382
+ // $licenses[] = $missing_license;
11383
+ // $licenses_map[ $missing_license->id ] = true;
11384
+ // }
11385
+ // }
11386
+
11387
+ $user_license_ids = $this->get_user_linked_license_ids( $this->_user->id );
11388
+
11389
+ foreach ( $user_license_ids as $key => $license_id ) {
11390
+ if ( ! isset( $licenses_map[ $license_id ] ) ) {
11391
+ // Remove access to licenses that no longer exist.
11392
+ unset( $user_license_ids[ $key ] );
11393
+ }
11394
+ }
11395
+
11396
+ if ( ! empty( $user_license_ids ) ) {
11397
+ foreach ( $licenses_map as $license_id => $value ) {
11398
+ if ( ! isset( $all_licenses_map[ $license_id ] ) ) {
11399
+ // Associate new licenses with the user who triggered the license syncing.
11400
+ $user_license_ids[] = $license_id;
11401
+ }
11402
+ }
11403
+
11404
+ $user_license_ids = array_unique( $user_license_ids );
11405
+ } else {
11406
+ $user_license_ids = array_keys( $licenses_map );
11407
+ }
11408
+
11409
+ if ( ! $is_network_admin || ! is_null( $blog_id ) ) {
11410
+ $user_licenses = array();
11411
+ foreach ( $licenses as $license ) {
11412
+ if ( ! in_array( $license->id, $user_license_ids ) ) {
11413
+ continue;
11414
+ }
11415
+
11416
+ $user_licenses[] = $license;
11417
+ }
11418
+
11419
+ $this->_licenses = $user_licenses;
11420
+ } else {
11421
+ $this->_licenses = $licenses;
11422
+ }
11423
+
11424
+ $this->set_user_linked_license_ids( $this->_user->id, $user_license_ids );
11425
+
11426
+ $this->_store_licenses( true, $this->_module_id, $licenses );
11427
+ }
11428
+
11429
+ // Update current license.
11430
+ if ( is_object( $this->_license ) ) {
11431
+ $license = $this->_get_license_by_id( $this->_license->id );
11432
+
11433
+ if ( is_object( $license ) ) {
11434
+ /**
11435
+ * `$license` can be `false` in case a user change action has just been completed and this method
11436
+ * has synced the `$this->_licenses` collection for the new user. In this case, the
11437
+ * `$this->_licenses` collection may have only the newly activated license that is associated with
11438
+ * the new user. `set_license` will eventually be called in the same request by the logic that
11439
+ * follows outside this method which will detect that the install's license has been updated, and
11440
+ * then `_update_site_license` will be called which in turn will call `set_license`.
11441
+ *
11442
+ * @author Leo Fajardo (@leorw)
11443
+ * @since 2.3.2
11444
+ */
11445
+ $this->set_license( $license );
11446
+ }
11447
+ }
11448
+
11449
+ return $this->_licenses;
11450
+ }
11451
+
11452
+ /**
11453
+ * @author Vova Feldman (@svovaf)
11454
+ * @since 1.0.5
11455
+ *
11456
+ * @param number $id
11457
+ * @param bool $sync_licenses
11458
+ *
11459
+ * @return FS_Plugin_License|false
11460
+ */
11461
+ function _get_license_by_id( $id, $sync_licenses = true ) {
11462
+ $this->_logger->entrance();
11463
+
11464
+ if ( ! FS_Plugin_License::is_valid_id( $id ) ) {
11465
+ return false;
11466
+ }
11467
+
11468
+ /**
11469
+ * When running from the network level admin and opted-in from the network,
11470
+ * check if the license exists in the network user licenses collection.
11471
+ *
11472
+ * @author Vova Feldman (@svovaf)
11473
+ * @since 2.0.0
11474
+ */
11475
+ if ( fs_is_network_admin() &&
11476
+ $this->is_network_registered() &&
11477
+ ( ! is_object( $this->_user ) || $this->_storage->network_user_id != $this->_user->id )
11478
+ ) {
11479
+ $licenses = $this->get_user_licenses( $this->_storage->network_user_id );
11480
+
11481
+ foreach ( $licenses as $license ) {
11482
+ if ( $id == $license->id ) {
11483
+ return $license;
11484
+ }
11485
+ }
11486
+ }
11487
+
11488
+ if ( ! $this->has_any_license() && $sync_licenses ) {
11489
+ $this->_sync_licenses( $id );
11490
+ }
11491
+
11492
+ if ( is_array( $this->_licenses ) ) {
11493
+ foreach ( $this->_licenses as $license ) {
11494
+ if ( $id == $license->id ) {
11495
+ return $license;
11496
+ }
11497
+ }
11498
+ }
11499
+
11500
+ return false;
11501
+ }
11502
+
11503
+ /**
11504
+ * Get license by ID. Unlike _get_license_by_id(), this method only checks the local storage and return any license, whether it's associated with the current context user/install or not.
11505
+ *
11506
+ * @author Vova Feldman (@svovaf)
11507
+ * @since 2.0.0
11508
+ *
11509
+ * @param number $id
11510
+ *
11511
+ * @return FS_Plugin_License
11512
+ */
11513
+ private function get_license_by_id( $id ) {
11514
+ $licenses = self::get_all_licenses( $this->_module_id );
11515
+
11516
+ if ( is_array( $licenses ) && ! empty( $licenses ) ) {
11517
+ foreach ( $licenses as $license ) {
11518
+ if ( $id == $license->id ) {
11519
+ return $license;
11520
+ }
11521
+ }
11522
+ }
11523
+
11524
+ return null;
11525
+ }
11526
+
11527
+ /**
11528
+ * Synchronize the site's context license by fetching the license form the API and updating the local data with it.
11529
+ *
11530
+ * @author Vova Feldman (@svovaf)
11531
+ * @since 2.0.0
11532
+ *
11533
+ * @return \FS_Plugin_License|mixed
11534
+ */
11535
+ private function sync_site_license() {
11536
+ $api = $this->get_api_user_scope();
11537
+
11538
+ $result = $api->get( "/licenses/{$this->_license->id}.json?license_key=" . urlencode( $this->_license->secret_key ), true );
11539
+
11540
+ if ( ! $this->is_api_result_entity( $result ) ) {
11541
+ return $result;
11542
+ }
11543
+
11544
+ $license = $this->_update_site_license( new FS_Plugin_License( $result ) );
11545
+ $this->_store_licenses();
11546
+
11547
+ return $license;
11548
+ }
11549
+
11550
+ /**
11551
+ * Get all user's available licenses for the current module.
11552
+ *
11553
+ * @author Vova Feldman (@svovaf)
11554
+ * @since 2.0.0
11555
+ *
11556
+ * @param number $user_id
11557
+ *
11558
+ * @return FS_Plugin_License[]
11559
+ */
11560
+ private function get_user_licenses( $user_id ) {
11561
+ $all_licenses = self::get_all_licenses( $this->_module_id );
11562
+ if ( empty( $all_licenses ) ) {
11563
+ return array();
11564
+ }
11565
+
11566
+ $user_license_ids = $this->get_user_linked_license_ids( $user_id );
11567
+ if ( empty( $user_license_ids ) ) {
11568
+ return array();
11569
+ }
11570
+
11571
+ $licenses = array();
11572
+ foreach ( $all_licenses as $license ) {
11573
+ if ( in_array( $license->id, $user_license_ids ) ) {
11574
+ $licenses[] = $license;
11575
+ }
11576
+ }
11577
+
11578
+ return $licenses;
11579
+ }
11580
+
11581
+ /**
11582
+ * Checks if the context license is network activated except on the given blog ID.
11583
+ *
11584
+ * @author Vova Feldman (@svovaf)
11585
+ * @since 2.0.0
11586
+ *
11587
+ * @param int $except_blog_id
11588
+ *
11589
+ * @return bool
11590
+ */
11591
+ private function is_license_network_active( $except_blog_id = 0 ) {
11592
+ $this->_logger->entrance();
11593
+
11594
+ if ( ! is_object( $this->_license ) ) {
11595
+ return false;
11596
+ }
11597
+
11598
+ $sites = self::get_sites();
11599
+
11600
+ if ( $this->_license->total_activations() < ( count( $sites ) - 1 ) ) {
11601
+ // There are more sites than the number of activations, so license cannot be network activated.
11602
+ return false;
11603
+ }
11604
+
11605
+ foreach ( $sites as $site ) {
11606
+ $blog_id = self::get_site_blog_id( $site );
11607
+
11608
+ if ( $except_blog_id == $blog_id ) {
11609
+ // Skip excluded blog.
11610
+ continue;
11611
+ }
11612
+
11613
+ $install = $this->get_install_by_blog_id( $blog_id );
11614
+
11615
+ if ( is_object( $install ) && $install->license_id != $this->_license->id ) {
11616
+ return false;
11617
+ }
11618
+ }
11619
+
11620
+ return true;
11621
+ }
11622
+
11623
+ /**
11624
+ * Checks if license can be activated on all the network sites (opted-in or skipped) that are not yet associated with a license. If possible, try to make the activation, if not return false.
11625
+ *
11626
+ * Notice: On success, this method will also update the license activations counters (without updating the license in the storage).
11627
+ *
11628
+ * @author Vova Feldman (@svovaf)
11629
+ * @since 2.0.0
11630
+ *
11631
+ * @param \FS_User $user
11632
+ * @param \FS_Plugin_License $license
11633
+ *
11634
+ * @return bool
11635
+ */
11636
+ private function try_activate_license_on_network( FS_User $user, FS_Plugin_License $license ) {
11637
+ $this->_logger->entrance();
11638
+
11639
+ $result = $this->can_activate_license_on_network( $license );
11640
+
11641
+ if ( false === $result ) {
11642
+ return false;
11643
+ }
11644
+
11645
+ $installs_without_license = $result['installs'];
11646
+ if ( ! empty( $installs_without_license ) ) {
11647
+ $this->activate_license_on_many_installs( $user, $license->secret_key, $installs_without_license );
11648
+ }
11649
+
11650
+ $disconnected_site_ids = $result['sites'];
11651
+ if ( ! empty( $disconnected_site_ids ) ) {
11652
+ $this->activate_license_on_many_sites( $user, $license->secret_key, $disconnected_site_ids );
11653
+ }
11654
+
11655
+ $this->link_license_2_user( $license->id, $user->id );
11656
+
11657
+ // Sync license after activations.
11658
+ $license->activated += $result['production_count'];
11659
+ $license->activated_local += $result['localhost_count'];
11660
+
11661
+ // $this->_store_licenses()
11662
+
11663
+ return true;
11664
+ }
11665
+
11666
+ /**
11667
+ * Checks if the given license can be activated on the whole network.
11668
+ *
11669
+ * @author Vova Feldman (@svovaf)
11670
+ * @since 2.0.0
11671
+ *
11672
+ * @param \FS_Plugin_License $license
11673
+ *
11674
+ * @return false|array {
11675
+ * @type array[int]FS_Site $installs Blog ID to install map.
11676
+ * @type int[] $sites Non-connected blog IDs.
11677
+ * @type int $production_count Production sites count.
11678
+ * @type int $localhost_count Production sites count.
11679
+ * }
11680
+ */
11681
+ private function can_activate_license_on_network( FS_Plugin_License $license ) {
11682
+ $sites = self::get_sites();
11683
+
11684
+ $production_count = 0;
11685
+ $localhost_count = 0;
11686
+
11687
+ $installs_without_license = array();
11688
+ $disconnected_site_ids = array();
11689
+
11690
+ foreach ( $sites as $site ) {
11691
+ $blog_id = self::get_site_blog_id( $site );
11692
+ $install = $this->get_install_by_blog_id( $blog_id );
11693
+
11694
+ if ( is_object( $install ) ) {
11695
+ if ( FS_Plugin_License::is_valid_id( $install->license_id ) ) {
11696
+ // License already activated on the install.
11697
+ continue;
11698
+ }
11699
+
11700
+ $url = $install->url;
11701
+
11702
+ $installs_without_license[ $blog_id ] = $install;
11703
+ } else {
11704
+ $url = is_object( $site ) ?
11705
+ $site->siteurl :
11706
+ get_site_url( $blog_id );
11707
+
11708
+ $disconnected_site_ids[] = $blog_id;
11709
+ }
11710
+
11711
+ if ( FS_Site::is_localhost_by_address( $url ) ) {
11712
+ $localhost_count ++;
11713
+ } else {
11714
+ $production_count ++;
11715
+ }
11716
+ }
11717
+
11718
+ if ( ! $license->can_activate_bulk( $production_count, $localhost_count ) ) {
11719
+ return false;
11720
+ }
11721
+
11722
+ return array(
11723
+ 'installs' => $installs_without_license,
11724
+ 'sites' => $disconnected_site_ids,
11725
+ 'production_count' => $production_count,
11726
+ 'localhost_count' => $localhost_count,
11727
+ );
11728
+ }
11729
+
11730
+ /**
11731
+ * Activate a given license on a collection of installs.
11732
+ *
11733
+ * @author Vova Feldman (@svovaf)
11734
+ * @since 2.0.0
11735
+ *
11736
+ * @param \FS_User $user
11737
+ * @param string $license_key
11738
+ * @param array $blog_2_install_map {
11739
+ * @key int Blog ID.
11740
+ * @value FS_Site Blog's associated install.
11741
+ * }
11742
+ *
11743
+ * @return mixed|true
11744
+ */
11745
+ private function activate_license_on_many_installs(
11746
+ FS_User $user,
11747
+ $license_key,
11748
+ array $blog_2_install_map
11749
+ ) {
11750
+ $params = array(
11751
+ array( 'license_key' => $this->apply_filters( 'license_key', $license_key ) )
11752
+ );
11753
+
11754
+ $install_2_blog_map = array();
11755
+ foreach ( $blog_2_install_map as $blog_id => $install ) {
11756
+ $params[] = array( 'id' => $install->id );
11757
+
11758
+ $install_2_blog_map[ $install->id ] = $blog_id;
11759
+ }
11760
+
11761
+ $result = $this->get_api_user_scope_by_user( $user )->call(
11762
+ "plugins/{$this->_plugin->id}/installs.json",
11763
+ 'PUT',
11764
+ $params
11765
+ );
11766
+
11767
+ if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
11768
+ return $result;
11769
+ }
11770
+
11771
+ foreach ( $result->installs as $r_install ) {
11772
+ $install = new FS_Site( $r_install );
11773
+ $install->is_disconnected = false;
11774
+
11775
+ // Update install.
11776
+ $this->_store_site(
11777
+ true,
11778
+ $install_2_blog_map[ $r_install->id ],
11779
+ $install
11780
+ );
11781
+ }
11782
+
11783
+ return true;
11784
+ }
11785
+
11786
+ /**
11787
+ * Activate a given license on a collection of blogs/sites that are not yet opted-in.
11788
+ *
11789
+ * @author Vova Feldman (@svovaf)
11790
+ * @since 2.3.1
11791
+ *
11792
+ * @param \FS_User $user
11793
+ * @param string $license_key
11794
+ *
11795
+ * @return true|mixed True if successful, otherwise, the API result.
11796
+ */
11797
+ private function activate_license_on_site( FS_User $user, $license_key ) {
11798
+ return $this->activate_license_on_many_sites( $user, $license_key );
11799
+ }
11800
+
11801
+ /**
11802
+ * Activate a given license on a collection of blogs/sites that are not yet opted-in.
11803
+ *
11804
+ * @author Vova Feldman (@svovaf)
11805
+ * @since 2.0.0
11806
+ *
11807
+ * @param \FS_User $user
11808
+ * @param string $license_key
11809
+ * @param int[] $site_ids
11810
+ *
11811
+ * @return true|mixed True if successful, otherwise, the API result.
11812
+ */
11813
+ private function activate_license_on_many_sites(
11814
+ FS_User $user,
11815
+ $license_key,
11816
+ array $site_ids = array()
11817
+ ) {
11818
+ $sites = array();
11819
+ foreach ( $site_ids as $site_id ) {
11820
+ $sites[] = $this->get_site_info( array( 'blog_id' => $site_id ) );
11821
+ }
11822
+
11823
+ // Install the plugin.
11824
+ $result = $this->create_installs_with_user(
11825
+ $user,
11826
+ $license_key,
11827
+ false,
11828
+ $sites,
11829
+ false,
11830
+ true
11831
+ );
11832
+
11833
+ if ( ! $this->is_api_result_entity( $result ) &&
11834
+ ! $this->is_api_result_object( $result, 'installs' )
11835
+ ) {
11836
+ return $result;
11837
+ }
11838
+
11839
+ $installs = array();
11840
+
11841
+ if ( $this->is_api_result_entity( $result ) ) {
11842
+ $install = new FS_Site( $result );
11843
+
11844
+ $this->_user = $user;
11845
+
11846
+ $this->_store_site( true, null, $install );
11847
+
11848
+ $this->_site = $install;
11849
+
11850
+ $this->reset_anonymous_mode();
11851
+ } else {
11852
+ foreach ( $result->installs as $install ) {
11853
+ $installs[] = new FS_Site( $install );
11854
+ }
11855
+
11856
+ // Map site addresses to their blog IDs.
11857
+ $address_to_blog_map = $this->get_address_to_blog_map();
11858
+
11859
+ $first_blog_id = null;
11860
+
11861
+ foreach ( $installs as $install ) {
11862
+ $address = trailingslashit( fs_strip_url_protocol( $install->url ) );
11863
+ $blog_id = $address_to_blog_map[ $address ];
11864
+
11865
+ $this->_store_site( true, $blog_id, $install );
11866
+
11867
+ $this->reset_anonymous_mode( $blog_id );
11868
+
11869
+ if ( is_null( $first_blog_id ) ) {
11870
+ $first_blog_id = $blog_id;
11871
+ }
11872
+ }
11873
+
11874
+ if ( ! FS_Site::is_valid_id( $this->_storage->network_install_blog_id ) ) {
11875
+ $this->_storage->network_install_blog_id = $first_blog_id;
11876
+ }
11877
+ }
11878
+
11879
+ return true;
11880
+ }
11881
+
11882
+ /**
11883
+ * Sync site's license with user licenses.
11884
+ *
11885
+ * @author Vova Feldman (@svovaf)
11886
+ * @since 1.0.6
11887
+ *
11888
+ * @param FS_Plugin_License|null $new_license
11889
+ *
11890
+ * @return FS_Plugin_License|null
11891
+ */
11892
+ function _update_site_license( $new_license ) {
11893
+ $this->_logger->entrance();
11894
+
11895
+ /**
11896
+ * In case this call will be removed in the future, the `_sync_licenses()` method needs to be updated
11897
+ * accordingly so that it will also handle the case when an ownership change is done via license
11898
+ * activation.
11899
+ *
11900
+ * @author Leo Fajardo (@leorw)
11901
+ * @since 2.3.2
11902
+ */
11903
+ $this->set_license( $new_license );
11904
+
11905
+ if ( ! is_object( $new_license ) ) {
11906
+ $this->_site->license_id = null;
11907
+ $this->_sync_site_subscription( null );
11908
+
11909
+ return $this->_license;
11910
+ }
11911
+
11912
+ $this->_site->license_id = $this->_license->id;
11913
+
11914
+ if ( ! is_array( $this->_licenses ) ) {
11915
+ $this->_licenses = array();
11916
+ }
11917
+
11918
+ $is_license_found = false;
11919
+ for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
11920
+ if ( $new_license->id == $this->_licenses[ $i ]->id ) {
11921
+ $this->_licenses[ $i ] = $new_license;
11922
+
11923
+ $is_license_found = true;
11924
+ break;
11925
+ }
11926
+ }
11927
+
11928
+ // If new license just append.
11929
+ if ( ! $is_license_found ) {
11930
+ $this->_licenses[] = $new_license;
11931
+ }
11932
+
11933
+ $this->_sync_site_subscription( $new_license );
11934
+
11935
+ return $this->_license;
11936
+ }
11937
+
11938
+ /**
11939
+ * @author Vova Feldman (@svovaf)
11940
+ * @since 2.3.1
11941
+ *
11942
+ * @param \FS_Plugin_License $license
11943
+ */
11944
+ private function set_license( FS_Plugin_License $license = null ) {
11945
+ $this->_license = $license;
11946
+
11947
+ $this->maybe_update_whitelabel_flag( $license );
11948
+ }
11949
+
11950
+ /**
11951
+ * @author Leo Fajardo (@leorw)
11952
+ * @since 2.3.1
11953
+ *
11954
+ * @param FS_Plugin_License $license
11955
+ */
11956
+ private function maybe_update_whitelabel_flag( $license ) {
11957
+ $is_whitelabeled = isset( $this->_storage->is_whitelabeled ) ?
11958
+ $this->_storage->is_whitelabeled :
11959
+ false;
11960
+
11961
+ if ( is_object( $license ) ) {
11962
+ $license_user = self::_get_user_by_id( $license->user_id );
11963
+
11964
+ if ( ! is_object( $license_user ) ) {
11965
+ // If foreign license, do not update the `is_whitelabeled` flag.
11966
+ return;
11967
+ }
11968
+
11969
+ if ( $this->is_addon() ) {
11970
+ /**
11971
+ * Store the last license data to the parent's storage since it's needed only when showing the
11972
+ * "Start Debug" dialog which is triggered from the "Account" page. This way, there's no need to
11973
+ * iterate over the add-ons just to get the last license data.
11974
+ */
11975
+ $this->get_parent_instance()->store_last_activated_license_data( $license, $license_user );
11976
+ } else {
11977
+ $this->store_last_activated_license_data( $license );
11978
+ }
11979
+
11980
+ if ( $license->is_whitelabeled ) {
11981
+ // Activated a developer license, data should be hidden.
11982
+ $is_whitelabeled = true;
11983
+ } else if ( $this->is_registered() && $this->_user->id == $license->user_id ) {
11984
+ // The account owner activated a regular license key, no need to hide the data.
11985
+ $is_whitelabeled = false;
11986
+ }
11987
+ }
11988
+
11989
+ $this->_storage->is_whitelabeled = $is_whitelabeled;
11990
+
11991
+ // Reset the whitelabeled status after update.
11992
+ $this->is_whitelabeled = null;
11993
+ if ( $this->is_addon() ) {
11994
+ $parent_fs = $this->get_parent_instance();
11995
+
11996
+ if ( is_object( $parent_fs ) ) {
11997
+ $parent_fs->is_whitelabeled = null;
11998
+ }
11999
+ }
12000
+ }
12001
+
12002
+ /**
12003
+ * @author Leo Fajardo (@leorw)
12004
+ * @since 2.3.1
12005
+ *
12006
+ * @param FS_Plugin_License $license
12007
+ * @param FS_User $license_user
12008
+ */
12009
+ private function store_last_activated_license_data( FS_Plugin_License $license, $license_user = null ) {
12010
+ if ( ! is_object( $license_user ) ) {
12011
+ $this->_storage->last_license_key = md5( $license->secret_key );
12012
+ $this->_storage->last_license_user_id = null;
12013
+ } else {
12014
+ $this->_storage->last_license_user_key = md5( $license_user->secret_key );
12015
+ $this->_storage->last_license_user_id = $license_user->id;
12016
+ }
12017
+ }
12018
+
12019
+ /**
12020
+ * @author Leo Fajardo (@leorw)
12021
+ * @since 2.3.1
12022
+ *
12023
+ * @param bool $ignore_data_debug_mode
12024
+ *
12025
+ * @return bool
12026
+ */
12027
+ function is_whitelabeled_by_flag( $ignore_data_debug_mode = false ) {
12028
+ if ( true !== $this->_storage->is_whitelabeled ) {
12029
+ return false;
12030
+ } else if ( $ignore_data_debug_mode ) {
12031
+ return true;
12032
+ }
12033
+
12034
+ $fs = $this->is_addon() ?
12035
+ $this->get_parent_instance() :
12036
+ $this;
12037
+
12038
+ return ! $fs->is_data_debug_mode();
12039
+ }
12040
+
12041
+ /**
12042
+ * @author Leo Fajardo (@leorw)
12043
+ * @since 2.3.1
12044
+ *
12045
+ * @return number
12046
+ */
12047
+ function get_last_license_user_id() {
12048
+ return ( FS_User::is_valid_id( $this->_storage->last_license_user_id ) ) ?
12049
+ $this->_storage->last_license_user_id :
12050
+ null;
12051
+ }
12052
+
12053
+ /**
12054
+ * @author Leo Fajardo (@leorw)
12055
+ * @since 2.3.1
12056
+ *
12057
+ * @param int $blog_id
12058
+ * @param bool $ignore_data_debug_mode
12059
+ *
12060
+ * @return bool
12061
+ */
12062
+ function is_whitelabeled( $ignore_data_debug_mode = false, $blog_id = null ) {
12063
+ if ( ! is_null( $blog_id ) ) {
12064
+ $this->switch_to_blog( $blog_id );
12065
+ }
12066
+
12067
+ if ( ! is_null( $this->is_whitelabeled ) ) {
12068
+ $is_whitelabeled = $this->is_whitelabeled;
12069
+ } else {
12070
+ $is_whitelabeled = false;
12071
+
12072
+ $is_whitelabeled_flag = $this->is_whitelabeled_by_flag( true );
12073
+
12074
+ if ( ! $this->has_addons() ) {
12075
+ $is_whitelabeled = $is_whitelabeled_flag;
12076
+ } else if ( $is_whitelabeled_flag ) {
12077
+ $is_whitelabeled = true;
12078
+ } else {
12079
+ $addon_ids = $this->get_updated_account_addons();
12080
+ $installed_addons = $this->get_installed_addons();
12081
+ foreach ( $installed_addons as $fs_addon ) {
12082
+ $addon_ids[] = $fs_addon->get_id();
12083
+ }
12084
+
12085
+ if ( ! empty( $addon_ids ) ) {
12086
+ $addon_ids = array_unique( $addon_ids );
12087
+
12088
+ $is_network_level = (
12089
+ fs_is_network_admin() &&
12090
+ $this->is_network_active()
12091
+ );
12092
+
12093
+ foreach ( $addon_ids as $addon_id ) {
12094
+ $addon = $this->get_addon( $addon_id );
12095
+
12096
+ if ( ! is_object( $addon ) ) {
12097
+ continue;
12098
+ }
12099
+
12100
+ $addon_storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $addon->slug );
12101
+ $fs_addon = $this->is_addon_activated( $addon_id ) ?
12102
+ self::get_addon_instance( $addon_id ) :
12103
+ null;
12104
+
12105
+ $was_addon_network_activated = false;
12106
+
12107
+ if ( is_object( $fs_addon ) ) {
12108
+ $was_addon_network_activated = $fs_addon->is_network_active();
12109
+ } else if ( $is_network_level ) {
12110
+ $was_addon_network_activated = $addon_storage->get( 'was_plugin_loaded', false, true );
12111
+ }
12112
+
12113
+ $network_delegated_connection = (
12114
+ $was_addon_network_activated &&
12115
+ $addon_storage->get( 'is_delegated_connection', false, true )
12116
+ );
12117
+
12118
+ if (
12119
+ $is_network_level &&
12120
+ ( ! $was_addon_network_activated || $network_delegated_connection )
12121
+ ) {
12122
+ $sites = self::get_sites();
12123
+
12124
+ /**
12125
+ * If in network admin area and the add-on was not network-activated or network-activated
12126
+ * and network-delegated, find any add-on whose is_whitelabeled flag is true.
12127
+ */
12128
+ foreach ( $sites as $site ) {
12129
+ $site_info = $this->get_site_info( $site );
12130
+
12131
+ if ( $addon_storage->get( 'is_whitelabeled', false, $site_info['blog_id'] ) ) {
12132
+ $is_whitelabeled = true;
12133
+ break;
12134
+ }
12135
+ }
12136
+
12137
+ if ( $is_whitelabeled ) {
12138
+ break;
12139
+ }
12140
+ } else {
12141
+ /**
12142
+ * This will be executed when any of the following is met:
12143
+ * 1. Add-on was network-activated, not network-delegated, and in network admin area.
12144
+ * 2. Add-on was network-activated, network-delegated, and in site admin area.
12145
+ * 3. Add-on was not network-activated and in site admin area.
12146
+ */
12147
+ if ( true === $addon_storage->is_whitelabeled ) {
12148
+ $is_whitelabeled = true;
12149
+ break;
12150
+ }
12151
+ }
12152
+ }
12153
+ }
12154
+ }
12155
+
12156
+ $this->is_whitelabeled = $is_whitelabeled;
12157
+
12158
+ if ( ! $is_whitelabeled || ! $this->is_data_debug_mode() ) {
12159
+ $this->_admin_notices->remove_sticky( 'data_debug_mode_enabled' );
12160
+ }
12161
+
12162
+ if ( ! is_null( $blog_id ) ) {
12163
+ $this->restore_current_blog();
12164
+ }
12165
+ }
12166
+
12167
+ return (
12168
+ $is_whitelabeled &&
12169
+ ( $ignore_data_debug_mode || ! $this->is_data_debug_mode() )
12170
+ );
12171
+ }
12172
+
12173
+ /**
12174
+ * Sync site's subscription.
12175
+ *
12176
+ * @author Vova Feldman (@svovaf)
12177
+ * @since 1.0.9
12178
+ *
12179
+ * @param FS_Plugin_License|null $license
12180
+ *
12181
+ * @return bool|\FS_Subscription
12182
+ */
12183
+ private function _sync_site_subscription( $license ) {
12184
+ if ( ! is_object( $license ) ) {
12185
+ $this->delete_unused_subscriptions();
12186
+
12187
+ return false;
12188
+ }
12189
+
12190
+ // Load subscription details if not lifetime.
12191
+ $subscription = $license->is_lifetime() ?
12192
+ false :
12193
+ $this->_fetch_site_license_subscription();
12194
+
12195
+ if ( is_object( $subscription ) && ! isset( $subscription->error ) ) {
12196
+ $this->store_subscription( $subscription );
12197
+ } else {
12198
+ $this->delete_unused_subscriptions();
12199
+ }
12200
+
12201
+ return $subscription;
12202
+ }
12203
+
12204
+ /**
12205
+ * @author Vova Feldman (@svovaf)
12206
+ * @since 1.0.6
12207
+ *
12208
+ * @return bool|\FS_Plugin_License
12209
+ */
12210
+ function _get_license() {
12211
+ if ( ! fs_is_network_admin() || is_object( $this->_license ) ) {
12212
+ return $this->_license;
12213
+ }
12214
+
12215
+ return $this->_get_available_premium_license();
12216
+ }
12217
+
12218
+ /**
12219
+ * @param number $license_id
12220
+ *
12221
+ * @return null|\FS_Subscription
12222
+ */
12223
+ function _get_subscription( $license_id ) {
12224
+ if ( ! isset( $this->_storage->subscriptions ) ||
12225
+ empty( $this->_storage->subscriptions )
12226
+ ) {
12227
+ return null;
12228
+ }
12229
+
12230
+ foreach ( fs_get_entities( $this->_storage->subscriptions, FS_Subscription::get_class_name() ) as $subscription ) {
12231
+ if ( $subscription->license_id == $license_id ) {
12232
+ return $subscription;
12233
+ }
12234
+ }
12235
+
12236
+ return null;
12237
+ }
12238
+
12239
+ /**
12240
+ * @author Leo Fajardo (@leorw)
12241
+ * @since 2.0.0
12242
+ *
12243
+ * @param FS_Subscription $subscription
12244
+ */
12245
+ function store_subscription( FS_Subscription $subscription ) {
12246
+ if ( ! isset( $this->_storage->subscriptions ) ) {
12247
+ $this->_storage->subscriptions = array();
12248
+ }
12249
+
12250
+ if ( empty( $this->_storage->subscriptions ) || ! is_multisite() ) {
12251
+ $this->_storage->subscriptions = array( $subscription );
12252
+
12253
+ return;
12254
+ }
12255
+
12256
+ $subscriptions = fs_get_entities( $this->_storage->subscriptions, FS_Subscription::get_class_name() );
12257
+
12258
+ $updated_subscription = false;
12259
+ foreach ( $subscriptions as $key => $existing_subscription ) {
12260
+ if ( $existing_subscription->id == $subscription->id ) {
12261
+ $subscriptions[ $key ] = $subscription;
12262
+ $updated_subscription = true;
12263
+ break;
12264
+ }
12265
+ }
12266
+
12267
+ if ( ! $updated_subscription ) {
12268
+ $subscriptions[] = $subscription;
12269
+ }
12270
+
12271
+ $this->_storage->subscriptions = $subscriptions;
12272
+ }
12273
+
12274
+ /**
12275
+ * @author Leo Fajardo (@leorw)
12276
+ * @since 2.0.0
12277
+ */
12278
+ function delete_unused_subscriptions() {
12279
+ if ( ! isset( $this->_storage->subscriptions ) ||
12280
+ empty( $this->_storage->subscriptions ) ||
12281
+ // Clean up only if there are already at least 3 subscriptions.
12282
+ ( count( $this->_storage->subscriptions ) < 3 )
12283
+ ) {
12284
+ return;
12285
+ }
12286
+
12287
+ if ( ! is_multisite() ) {
12288
+ // If not multisite, there should only be 1 subscription, so just clear the array.
12289
+ $this->_storage->subscriptions = array();
12290
+
12291
+ return;
12292
+ }
12293
+
12294
+ $subscriptions_to_keep_by_license_id_map = array();
12295
+ $sites = self::get_sites();
12296
+ foreach ( $sites as $site ) {
12297
+ $blog_id = self::get_site_blog_id( $site );
12298
+ $install = $this->get_install_by_blog_id( $blog_id );
12299
+
12300
+ if ( ! is_object( $install ) ||
12301
+ ! FS_Plugin_License::is_valid_id( $install->license_id )
12302
+ ) {
12303
+ continue;
12304
+ }
12305
+
12306
+ $subscriptions_to_keep_by_license_id_map[ $install->license_id ] = true;
12307
+ }
12308
+
12309
+ if ( empty( $subscriptions_to_keep_by_license_id_map ) ) {
12310
+ $this->_storage->subscriptions = array();
12311
+
12312
+ return;
12313
+ }
12314
+
12315
+ foreach ( $this->_storage->subscriptions as $key => $subscription ) {
12316
+ if ( ! isset( $subscriptions_to_keep_by_license_id_map[ $subscription->license_id ] ) ) {
12317
+ unset( $this->_storage->subscriptions[ $key ] );
12318
+ }
12319
+ }
12320
+ }
12321
+
12322
+ /**
12323
+ * @author Vova Feldman (@svovaf)
12324
+ * @since 1.0.2
12325
+ *
12326
+ * @param string $plan Plan name
12327
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
12328
+ *
12329
+ * @return bool
12330
+ */
12331
+ function is_plan( $plan, $exact = false ) {
12332
+ $this->_logger->entrance();
12333
+
12334
+ if ( ! $this->is_registered() ) {
12335
+ return false;
12336
+ }
12337
+
12338
+ $plan = strtolower( $plan );
12339
+
12340
+ $current_plan_name = $this->get_plan_name();
12341
+
12342
+ if ( $current_plan_name === $plan ) {
12343
+ // Exact plan.
12344
+ return true;
12345
+ } else if ( $exact ) {
12346
+ // Required exact, but plans are different.
12347
+ return false;
12348
+ }
12349
+
12350
+ $current_plan_order = - 1;
12351
+ $required_plan_order = PHP_INT_MAX;
12352
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
12353
+ if ( $plan === $this->_plans[ $i ]->name ) {
12354
+ $required_plan_order = $i;
12355
+ } else if ( $current_plan_name === $this->_plans[ $i ]->name ) {
12356
+ $current_plan_order = $i;
12357
+ }
12358
+ }
12359
+
12360
+ return ( $current_plan_order > $required_plan_order );
12361
+ }
12362
+
12363
+ /**
12364
+ * Check if module has only one plan.
12365
+ *
12366
+ * @author Vova Feldman (@svovaf)
12367
+ * @since 1.2.1.7
12368
+ *
12369
+ * @param bool $double_check In some cases developers prefer to release their paid offering as premium-only, even though there is a free version. For those cases, looking at the 'is_premium_only' value isn't enough because the result will return false even when the product has only signle paid plan.
12370
+ *
12371
+ * @return bool
12372
+ */
12373
+ function is_single_plan( $double_check = false ) {
12374
+ $this->_logger->entrance();
12375
+
12376
+ if ( ! $this->is_registered() ||
12377
+ ! is_array( $this->_plans ) ||
12378
+ 0 === count( $this->_plans )
12379
+ ) {
12380
+ return true;
12381
+ }
12382
+
12383
+ $has_free_plan = $this->has_free_plan();
12384
+
12385
+ if ( ! $has_free_plan && $double_check ) {
12386
+ foreach ( $this->_plans as $plan ) {
12387
+ if ( $plan->is_free() ) {
12388
+ $has_free_plan = true;
12389
+ break;
12390
+ }
12391
+ }
12392
+ }
12393
+
12394
+ return ( 1 === ( count( $this->_plans ) - ( $has_free_plan ? 1 : 0 ) ) );
12395
+ }
12396
+
12397
+ /**
12398
+ * Check if plan based on trial. If not in trial mode, should return false.
12399
+ *
12400
+ * @since 1.0.9
12401
+ *
12402
+ * @param string $plan Plan name
12403
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
12404
+ *
12405
+ * @return bool
12406
+ */
12407
+ function is_trial_plan( $plan, $exact = false ) {
12408
+ $this->_logger->entrance();
12409
+
12410
+ if ( ! $this->is_registered() ) {
12411
+ return false;
12412
+ }
12413
+
12414
+ if ( ! $this->is_trial() ) {
12415
+ return false;
12416
+ }
12417
+
12418
+ $trial_plan = $this->get_trial_plan();
12419
+
12420
+ if ( $trial_plan->name === $plan ) {
12421
+ // Exact plan.
12422
+ return true;
12423
+ } else if ( $exact ) {
12424
+ // Required exact, but plans are different.
12425
+ return false;
12426
+ }
12427
+
12428
+ $current_plan_order = - 1;
12429
+ $required_plan_order = - 1;
12430
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
12431
+ if ( $plan === $this->_plans[ $i ]->name ) {
12432
+ $required_plan_order = $i;
12433
+ } else if ( $trial_plan->name === $this->_plans[ $i ]->name ) {
12434
+ $current_plan_order = $i;
12435
+ }
12436
+ }
12437
+
12438
+ return ( $current_plan_order > $required_plan_order );
12439
+ }
12440
+
12441
+ /**
12442
+ * Check if plugin has any paid plans.
12443
+ *
12444
+ * @author Vova Feldman (@svovaf)
12445
+ * @since 1.0.7
12446
+ *
12447
+ * @return bool
12448
+ */
12449
+ function has_paid_plan() {
12450
+ return $this->_has_paid_plans ||
12451
+ FS_Plan_Manager::instance()->has_paid_plan( $this->_plans );
12452
+ }
12453
+
12454
+ /**
12455
+ * Check if plugin has any plan with a trail.
12456
+ *
12457
+ * @author Vova Feldman (@svovaf)
12458
+ * @since 1.0.9
12459
+ *
12460
+ * @return bool
12461
+ */
12462
+ function has_trial_plan() {
12463
+ /**
12464
+ * @author Vova Feldman(@svovaf)
12465
+ * @since 1.2.1.5
12466
+ *
12467
+ * Allow setting a trial from the SDK without calling the API.
12468
+ * But, if the user did opt-in, continue using the real data from the API.
12469
+ */
12470
+ if ( $this->_trial_days >= 0 ) {
12471
+ return true;
12472
+ }
12473
+
12474
+ return $this->_storage->get( 'has_trial_plan', false );
12475
+ }
12476
+
12477
+ /**
12478
+ * Check if plugin has any free plan, or is it premium only.
12479
+ *
12480
+ * Note: If no plans configured, assume plugin is free.
12481
+ *
12482
+ * @author Vova Feldman (@svovaf)
12483
+ * @since 1.0.7
12484
+ *
12485
+ * @return bool
12486
+ */
12487
+ function has_free_plan() {
12488
+ return ! $this->is_only_premium();
12489
+ }
12490
+
12491
+ /**
12492
+ * Displays a license activation dialog box when the user clicks on the "Activate License"
12493
+ * or "Change License" link on the plugins
12494
+ * page.
12495
+ *
12496
+ * @author Leo Fajardo (@leorw)
12497
+ * @since 1.1.9
12498
+ */
12499
+ function _add_license_activation_dialog_box() {
12500
+ $vars = array(
12501
+ 'id' => $this->_module_id,
12502
+ );
12503
+
12504
+ fs_require_template( 'forms/license-activation.php', $vars );
12505
+ fs_require_template( 'forms/resend-key.php', $vars );
12506
+ }
12507
+
12508
+ /**
12509
+ * Returns a collection of IDs of installs that are associated with the context product and its add-ons, and activated with foreign licenses.
12510
+ *
12511
+ * @author Leo Fajardo (@leorw)
12512
+ * @since 2.3.2
12513
+ *
12514
+ * @return number[]
12515
+ */
12516
+ function get_installs_ids_with_foreign_licenses() {
12517
+ $installs = array();
12518
+
12519
+ if (
12520
+ is_object( $this->_license ) &&
12521
+ $this->_site->user_id != $this->_license->user_id
12522
+ ) {
12523
+ $installs[] = $this->_site->id;
12524
+ }
12525
+
12526
+ /**
12527
+ * Also try to get foreign licenses for the context product's add-ons.
12528
+ */
12529
+ $installs_by_slug_map = $this->get_parent_and_addons_installs_info();
12530
+
12531
+ foreach ( $installs_by_slug_map as $slug => $install_info ) {
12532
+ if ( $slug == $this->get_slug() ) {
12533
+ continue;
12534
+ }
12535
+
12536
+ $install = $install_info['install'];
12537
+ $license = $install_info['license'];
12538
+
12539
+ if (
12540
+ is_object( $license ) &&
12541
+ $install->user_id != $license->user_id
12542
+ ) {
12543
+ $installs[] = $install->id;
12544
+ }
12545
+ }
12546
+
12547
+ return $installs;
12548
+ }
12549
+
12550
+ /**
12551
+ * Displays the "Change User" dialog box when the user clicks on the "Change User" button on the "Account" page.
12552
+ *
12553
+ * @author Leo Fajardo (@leorw)
12554
+ * @since 2.3.2
12555
+ *
12556
+ * @param number[] $install_ids
12557
+ */
12558
+ function _add_user_change_dialog_box( $install_ids ) {
12559
+ $vars = array(
12560
+ 'id' => $this->_module_id,
12561
+ 'license_owners' => $this->fetch_installs_licenses_owners_data( $install_ids )
12562
+ );
12563
+
12564
+ fs_require_template( 'forms/user-change.php', $vars );
12565
+ }
12566
+
12567
+ /**
12568
+ * @author Leo Fajardo (@leorw)
12569
+ * @since 2.3.1
12570
+ */
12571
+ function _add_data_debug_mode_dialog_box() {
12572
+ $vars = array(
12573
+ 'id' => $this->_module_id,
12574
+ );
12575
+
12576
+ fs_require_template( 'forms/data-debug-mode.php', $vars );
12577
+ }
12578
+
12579
+ /**
12580
+ * Displays a subscription cancellation dialog box when the user clicks on the "Deactivate License"
12581
+ * link on the "Account" page or deactivates a plugin and there's an active subscription that is
12582
+ * either associated with a non-lifetime single-site license or non-lifetime multisite license that
12583
+ * is only activated on a single production site.
12584
+ *
12585
+ * @author Leo Fajardo (@leorw)
12586
+ * @since 2.2.1
12587
+ *
12588
+ * @param bool $is_license_deactivation
12589
+ *
12590
+ * @return array
12591
+ */
12592
+ function _get_subscription_cancellation_dialog_box_template_params( $is_license_deactivation = false ) {
12593
+ if ( fs_is_network_admin() ) {
12594
+ // Subscription cancellation dialog box is currently not supported for multisite networks.
12595
+ return array();
12596
+ }
12597
+
12598
+ if ( $this->is_whitelabeled() ) {
12599
+ return array();
12600
+ }
12601
+
12602
+ $license = $this->_get_license();
12603
+
12604
+ /**
12605
+ * If the installation is associated with a non-lifetime license, which is either a single-site or only activated on a single production site (or zero), and connected to an active subscription, suggest the customer to cancel the subscription upon deactivation.
12606
+ *
12607
+ * @author Leo Fajardo (@leorw) (Comment added by Vova Feldman @svovaf)
12608
+ * @since 2.2.1
12609
+ */
12610
+ if ( ! is_object( $license ) ||
12611
+ $license->is_lifetime() ||
12612
+ ( ! $license->is_single_site() && $license->activated > 1 )
12613
+ ) {
12614
+ return array();
12615
+ }
12616
+
12617
+ /**
12618
+ * @var FS_Subscription $subscription
12619
+ */
12620
+ $subscription = $this->_get_subscription( $license->id );
12621
+ if ( ! is_object( $subscription ) || ! $subscription->is_active() ) {
12622
+ return array();
12623
+ }
12624
+
12625
+ return array(
12626
+ 'id' => $this->_module_id,
12627
+ 'license' => $license,
12628
+ 'has_trial' => $this->is_paid_trial(),
12629
+ 'is_license_deactivation' => $is_license_deactivation,
12630
+ );
12631
+ }
12632
+
12633
+ /**
12634
+ * @author Leo Fajardo (@leorw)
12635
+ * @since 2.0.2
12636
+ */
12637
+ function _add_premium_version_upgrade_selection_dialog_box() {
12638
+ $modules_update = get_site_transient( $this->is_theme() ? 'update_themes' : 'update_plugins' );
12639
+ if ( ! isset( $modules_update->response[ $this->_plugin_basename ] ) ) {
12640
+ return;
12641
+ }
12642
+
12643
+ $vars = array(
12644
+ 'id' => $this->_module_id,
12645
+ 'new_version' => is_object( $modules_update->response[ $this->_plugin_basename ] ) ?
12646
+ $modules_update->response[ $this->_plugin_basename ]->new_version :
12647
+ $modules_update->response[ $this->_plugin_basename ]['new_version']
12648
+ );
12649
+
12650
+ fs_require_template( 'forms/premium-versions-upgrade-metadata.php', $vars );
12651
+ fs_require_once_template( 'forms/premium-versions-upgrade-handler.php', $vars );
12652
+ }
12653
+
12654
+ /**
12655
+ * Displays the opt-out dialog box when the user clicks on the "Opt Out" link on the "Plugins"
12656
+ * page.
12657
+ *
12658
+ * @author Leo Fajardo (@leorw)
12659
+ * @since 1.2.1.5
12660
+ */
12661
+ function _add_optout_dialog() {
12662
+ if ( $this->is_theme() ) {
12663
+ $vars = null;
12664
+ fs_require_once_template( '/js/jquery.content-change.php', $vars );
12665
+ }
12666
+
12667
+ $vars = array( 'id' => $this->_module_id );
12668
+ fs_require_template( 'forms/optout.php', $vars );
12669
+ }
12670
+
12671
+ /**
12672
+ * Prepare page to include all required UI and logic for the license activation dialog.
12673
+ *
12674
+ * @author Vova Feldman (@svovaf)
12675
+ * @since 1.2.0
12676
+ */
12677
+ function _add_license_activation() {
12678
+ if ( ! $this->is_user_admin() ) {
12679
+ // Only admins can activate a license.
12680
+ return;
12681
+ }
12682
+
12683
+ if ( ! $this->has_paid_plan() ) {
12684
+ // Module doesn't have any paid plans.
12685
+ return;
12686
+ }
12687
+
12688
+ if (
12689
+ $this->has_premium_version() &&
12690
+ ! $this->is_premium() &&
12691
+ /**
12692
+ * Also handle the case when an upgrade was made using the free version.
12693
+ *
12694
+ * @author Leo Fajardo (@leorw)
12695
+ * @since 2.3.2
12696
+ */
12697
+ ! is_object( $this->_get_license() )
12698
+ ) {
12699
+ // Only add license activation logic to the premium version, or in case of a serviceware plugin, also in the free version.
12700
+ return;
12701
+ }
12702
+
12703
+ // Add license activation link and AJAX request handler.
12704
+ if ( self::is_plugins_page() ) {
12705
+ $is_network_admin = fs_is_network_admin();
12706
+
12707
+ if (
12708
+ ( $is_network_admin && $this->is_network_active() && ! $this->is_network_delegated_connection() ) ||
12709
+ ( ! $is_network_admin && ( ! $this->is_network_active() || $this->is_delegated_connection() ) )
12710
+ ) {
12711
+ /**
12712
+ * @since 1.2.0 Add license action link only on plugins page.
12713
+ */
12714
+ $this->_add_license_action_link();
12715
+ }
12716
+ }
12717
+
12718
+ // Add license activation AJAX callback.
12719
+ $this->add_ajax_action( 'activate_license', array( &$this, '_activate_license_ajax_action' ) );
12720
+
12721
+ // Add resend license AJAX callback.
12722
+ $this->add_ajax_action( 'resend_license_key', array( &$this, '_resend_license_key_ajax_action' ) );
12723
+ }
12724
+
12725
+ /**
12726
+ * Prepares page to include all required UI and logic for the "Change User" dialog.
12727
+ *
12728
+ * @author Leo Fajardo (@leorw)
12729
+ * @since 2.3.2
12730
+ */
12731
+ function _add_user_change_option() {
12732
+ if ( ! $this->should_handle_user_change() ) {
12733
+ return;
12734
+ }
12735
+
12736
+ if ( empty( $this->get_installs_ids_with_foreign_licenses() ) ) {
12737
+ // Handle user change only when the parent product or one of its add-ons is activated with a foreign license.
12738
+ return;
12739
+ }
12740
+
12741
+ // Add user change AJAX handler.
12742
+ $this->add_ajax_action( 'change_user', array( &$this, '_user_change_ajax_action' ) );
12743
+ }
12744
+
12745
+ /**
12746
+ * @author Leo Fajardo (@leorw)
12747
+ * @since 2.3.2
12748
+ */
12749
+ function should_handle_user_change() {
12750
+ if ( ! $this->is_user_admin() ) {
12751
+ // Only admins can change user.
12752
+ return false;
12753
+ }
12754
+
12755
+ if ( $this->is_addon() ) {
12756
+ return false;
12757
+ }
12758
+
12759
+ if ( ! $this->is_registered() ) {
12760
+ return false;
12761
+ }
12762
+
12763
+ if (
12764
+ $this->is_network_active() &&
12765
+ ( fs_is_network_admin() || ! $this->is_site_delegated_connection() )
12766
+ ) {
12767
+ // Handle only on site-level "Account" section for now.
12768
+ return false;
12769
+ }
12770
+
12771
+ return true;
12772
+ }
12773
+
12774
+ /**
12775
+ * @author Leo Fajardo (@leorw)
12776
+ * @since 2.0.2
12777
+ */
12778
+ function _add_premium_version_upgrade_selection() {
12779
+ if ( ! $this->is_user_admin() ) {
12780
+ return;
12781
+ }
12782
+
12783
+ if ( ! $this->is_premium() || $this->has_any_active_valid_license() ) {
12784
+ // This is relevant only to the free versions and premium versions without an active license.
12785
+ return;
12786
+ }
12787
+
12788
+ if ( self::is_updates_page() || ( $this->is_plugin() && self::is_plugins_page() ) ) {
12789
+ $this->_add_premium_version_upgrade_selection_action();
12790
+ }
12791
+ }
12792
+
12793
+ /**
12794
+ * @author Leo Fajardo (@leorw)
12795
+ * @since 2.3.0
12796
+ */
12797
+ function _add_beta_mode_update_handler() {
12798
+ if ( ! $this->is_user_admin() ) {
12799
+ return;
12800
+ }
12801
+
12802
+ if ( ! $this->is_premium() ) {
12803
+ return;
12804
+ }
12805
+
12806
+ $this->add_ajax_action( 'set_beta_mode', array( &$this, '_set_beta_mode_ajax_handler' ) );
12807
+ }
12808
+
12809
+ /**
12810
+ * @author Leo Fajardo (@leorw)
12811
+ * @since 2.3.0
12812
+ */
12813
+ function _set_beta_mode_ajax_handler() {
12814
+ $this->_logger->entrance();
12815
+
12816
+ $this->check_ajax_referer( 'set_beta_mode' );
12817
+
12818
+ if ( ! $this->is_user_admin() ) {
12819
+ // Only for admins.
12820
+ self::shoot_ajax_failure();
12821
+ }
12822
+
12823
+ $is_beta = trim( fs_request_get( 'is_beta', '', 'post' ) );
12824
+
12825
+ if ( empty( $is_beta ) || ! in_array( $is_beta, array( 'true', 'false' ) ) ) {
12826
+ self::shoot_ajax_failure();
12827
+ }
12828
+
12829
+ $user = $this->get_api_user_scope()->call(
12830
+ '',
12831
+ 'put',
12832
+ array(
12833
+ 'plugin_id' => $this->get_id(),
12834
+ 'is_beta' => ( 'true' == $is_beta ),
12835
+ 'fields' => 'is_beta'
12836
+ )
12837
+ );
12838
+
12839
+ if ( ! $this->is_api_result_entity( $user ) ) {
12840
+ self::shoot_ajax_failure(
12841
+ FS_Api::is_api_error_object( $user ) ?
12842
+ $user->error->message :
12843
+ fs_text_inline( "An unknown error has occurred while trying to set the user's beta mode.", 'unknown-error-occurred', $this->get_slug() )
12844
+ );
12845
+ }
12846
+
12847
+ $this->_user->is_beta = $user->is_beta;
12848
+ $this->_store_user();
12849
+
12850
+ self::shoot_ajax_response( array( 'success' => true ) );
12851
+ }
12852
+
12853
+ /**
12854
+ * License activation WP AJAX handler.
12855
+ *
12856
+ * @author Leo Fajardo (@leorw)
12857
+ * @since 1.1.9
12858
+ *
12859
+ * @uses Freemius::activate_license()
12860
+ */
12861
+ function _activate_license_ajax_action() {
12862
+ $this->_logger->entrance();
12863
+
12864
+ $this->check_ajax_referer( 'activate_license' );
12865
+
12866
+ $license_key = trim( fs_request_get( 'license_key' ) );
12867
+
12868
+ if ( empty( $license_key ) ) {
12869
+ exit;
12870
+ }
12871
+
12872
+ $result = $this->activate_license(
12873
+ $license_key,
12874
+ fs_is_network_admin() ?
12875
+ fs_request_get( 'sites', array(), 'post' ) :
12876
+ array(),
12877
+ fs_request_get_bool( 'is_marketing_allowed', null ),
12878
+ fs_request_get( 'blog_id', null ),
12879
+ fs_request_get( 'module_id', null, 'post' ),
12880
+ fs_request_get( 'user_id', null ),
12881
+ fs_request_get_bool( 'is_extensions_tracking_allowed', true )
12882
+ );
12883
+
12884
+ echo json_encode( $result );
12885
+
12886
+ exit;
12887
+ }
12888
+
12889
+ /**
12890
+ * User change WP AJAX handler.
12891
+ *
12892
+ * @author Leo Fajardo (@leorw)
12893
+ * @since 2.3.2
12894
+ */
12895
+ function _user_change_ajax_action() {
12896
+ $this->_logger->entrance();
12897
+
12898
+ $this->check_ajax_referer( 'change_user' );
12899
+
12900
+ $new_email_address = trim( fs_request_get( 'email_address', '' ) );
12901
+ $new_user_id = fs_request_get( 'user_id' );
12902
+
12903
+ if ( empty( $new_email_address ) && ! FS_User::is_valid_id( $new_user_id ) ) {
12904
+ self::shoot_ajax_failure( fs_text_inline( 'Invalid new user ID or email address.', 'invalid-new-user-id-or-email', $this->get_slug() ) );
12905
+ }
12906
+
12907
+ $params = array();
12908
+
12909
+ if ( ! empty( $new_email_address ) ) {
12910
+ $params['user_email'] = $new_email_address;
12911
+ } else {
12912
+ $params['user_id'] = $new_user_id;
12913
+ }
12914
+
12915
+ $installs_info_by_slug_map = $this->get_parent_and_addons_installs_info();
12916
+ $install_ids = array();
12917
+
12918
+ foreach ( $installs_info_by_slug_map as $slug => $install_info ) {
12919
+ $install_ids[ $slug ] = $install_info['install']->id;
12920
+ }
12921
+
12922
+ $params['install_ids'] = implode( ',', array_values( $install_ids ) );
12923
+
12924
+ $install = $this->get_api_site_scope()->call( $this->add_show_pending( '/' ), 'put', $params );
12925
+
12926
+ if ( FS_Api::is_api_error( $install ) ) {
12927
+ $error = '';
12928
+
12929
+ if ( is_object( $install ) ) {
12930
+ switch ( $install->error->code ) {
12931
+ case 'user_exist':
12932
+ $error = (
12933
+ $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' .
12934
+ $this->get_text_inline( 'Sorry, we could not complete the email update. Another user with the same email is already registered.', 'user-exist-message' ) . ' ' .
12935
+ sprintf( $this->get_text_inline( 'If you would like to give up the ownership of the %s\'s account to %s click the Change Ownership button.', 'user-exist-message_ownership' ), $this->_module_type, '<b>' . $new_email_address . '</b>' ) .
12936
+ sprintf(
12937
+ '<a style="line-height: 40px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
12938
+ $this->get_account_url( 'change_owner', array(
12939
+ 'state' => 'init',
12940
+ 'candidate_email' => $new_email_address
12941
+ ) ),
12942
+ $this->get_text_inline( 'Change Ownership', 'change-ownership' )
12943
+ )
12944
+ );
12945
+ break;
12946
+ }
12947
+ }
12948
+
12949
+ if ( empty( $error ) ) {
12950
+ $error = FS_Api::is_api_error_object( $install ) ?
12951
+ $install->error->message :
12952
+ var_export( $install->error, true );
12953
+ }
12954
+
12955
+ self::shoot_ajax_failure( $error );
12956
+ } else {
12957
+ if (
12958
+ // If successful ownership change.
12959
+ $this->get_user()->id != $install->user_id ||
12960
+ ! empty( $new_email_address )
12961
+ ) {
12962
+ $this->complete_ownership_change_by_license( $install->user_id, $install_ids );
12963
+ }
12964
+ }
12965
+
12966
+ self::shoot_ajax_success();
12967
+ }
12968
+
12969
+ /**
12970
+ * A helper method to activate migrated licenses. If the product is network activated and integrated, the method will network activate the license.
12971
+ *
12972
+ * @author Vova Feldman (@svovaf)
12973
+ * @since 2.3.0
12974
+ *
12975
+ * @param string $license_key
12976
+ * @param null|bool $is_marketing_allowed
12977
+ * @param null|number $plugin_id
12978
+ *
12979
+ * @return array {
12980
+ * @var bool $success
12981
+ * @var string $error
12982
+ * @var string $next_page
12983
+ * }
12984
+ *
12985
+ * @uses Freemius::activate_license()
12986
+ */
12987
+ function activate_migrated_license(
12988
+ $license_key,
12989
+ $is_marketing_allowed = null,
12990
+ $plugin_id = null
12991
+ ) {
12992
+ $this->_logger->entrance();
12993
+
12994
+ $result = $this->activate_license(
12995
+ $license_key,
12996
+ $this->is_network_active() ?
12997
+ $this->get_sites_for_network_level_optin() :
12998
+ array(),
12999
+ $is_marketing_allowed,
13000
+ null,
13001
+ $plugin_id
13002
+ );
13003
+
13004
+ // No need to show the sticky after license activation notice after migrating a license.
13005
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
13006
+
13007
+ return $result;
13008
+ }
13009
+
13010
+ /**
13011
+ * The implementation of this method was previously in `_activate_license_ajax_action()`.
13012
+ *
13013
+ * @author Vova Feldman (@svovaf)
13014
+ * @since 2.2.4
13015
+ * @since 2.0.0 When a super-admin that hasn't connected before is network activating a license and excluding some of the sites for the license activation, go over the unselected sites in the network and if a site is not connected, skipped, nor delegated, if it's a freemium product then just skip the connection for the site, if it's a premium only product, delegate the connection and license activation to the site admin (Vova Feldman @svovaf).
13016
+ * @param string $license_key
13017
+ * @param array $sites
13018
+ * @param null|bool $is_marketing_allowed
13019
+ * @param null|int $blog_id
13020
+ * @param null|number $plugin_id
13021
+ * @param null|number $license_owner_id
13022
+ *
13023
+ * @return array {
13024
+ * @var bool $success
13025
+ * @var string $error
13026
+ * @var string $next_page
13027
+ * }
13028
+ */
13029
+ private function activate_license(
13030
+ $license_key,
13031
+ $sites = array(),
13032
+ $is_marketing_allowed = null,
13033
+ $blog_id = null,
13034
+ $plugin_id = null,
13035
+ $license_owner_id = null,
13036
+ $is_extensions_tracking_allowed = true
13037
+ ) {
13038
+ $this->_logger->entrance();
13039
+
13040
+ $license_key = trim( $license_key );
13041
+
13042
+ if ( ! fs_is_network_admin() ) {
13043
+ // If the license activation is executed outside the context of a network admin, ignore the sites collection.
13044
+ $sites = array();
13045
+ }
13046
+
13047
+ $fs = ( empty($plugin_id) || $plugin_id == $this->_module_id ) ?
13048
+ $this :
13049
+ $this->get_addon_instance( $plugin_id );
13050
+
13051
+ $this->update_extensions_tracking_flag( $is_extensions_tracking_allowed );
13052
+
13053
+ $error = false;
13054
+ $next_page = false;
13055
+
13056
+ $has_valid_blog_id = is_numeric( $blog_id );
13057
+
13058
+ $user = null;
13059
+
13060
+ if ( $fs->is_addon() && $fs->get_parent_instance()->is_registered() ) {
13061
+ /**
13062
+ * When activating an add-on's license and the parent is opted-in, activate the license with the parent's opted-in user context.
13063
+ *
13064
+ * @author Vova Feldman (@svovaf)
13065
+ */
13066
+ $user = $fs->get_parent_instance()->get_current_or_network_user();
13067
+ } else if ( $fs->is_registered() ) {
13068
+ $user = $fs->get_current_or_network_user();
13069
+ }
13070
+
13071
+ if ( is_object( $user ) ) {
13072
+ if ( fs_is_network_admin() && ! $has_valid_blog_id ) {
13073
+ // If no specific blog ID was provided, activate the license for all sites in the network.
13074
+ $blog_2_install_map = array();
13075
+ $site_ids = array();
13076
+
13077
+ foreach ( $sites as $site ) {
13078
+ if ( ! isset( $site['blog_id'] ) || ! is_numeric( $site['blog_id'] ) ) {
13079
+ continue;
13080
+ }
13081
+
13082
+ $install = $fs->get_install_by_blog_id( $site['blog_id'] );
13083
+
13084
+ if ( is_object( $install ) ) {
13085
+ $blog_2_install_map[ $site['blog_id'] ] = $install;
13086
+ } else {
13087
+ $site_ids[] = $site['blog_id'];
13088
+ }
13089
+ }
13090
+
13091
+ if ( ! empty( $blog_2_install_map ) ) {
13092
+ $result = $fs->activate_license_on_many_installs( $user, $license_key, $blog_2_install_map );
13093
+
13094
+ if ( true !== $result ) {
13095
+ $error = FS_Api::is_api_error_object( $result ) ?
13096
+ $result->error->message :
13097
+ var_export( $result, true );
13098
+ }
13099
+ }
13100
+
13101
+ if ( empty( $error ) && ! empty( $site_ids ) ) {
13102
+ $result = $fs->activate_license_on_many_sites( $user, $license_key, $site_ids );
13103
+
13104
+ if ( true !== $result ) {
13105
+ $error = FS_Api::is_api_error_object( $result ) ?
13106
+ $result->error->message :
13107
+ var_export( $result, true );
13108
+ }
13109
+ }
13110
+ } else {
13111
+ if ( $has_valid_blog_id ) {
13112
+ /**
13113
+ * If a specific blog ID was provided, activate the license only for the install that is
13114
+ * associated with the given blog ID.
13115
+ *
13116
+ * @author Leo Fajardo (@leorw)
13117
+ */
13118
+ $fs->switch_to_blog( $blog_id );
13119
+ }
13120
+
13121
+ if ( $fs->is_registered() ) {
13122
+ $params = array(
13123
+ 'license_key' => $fs->apply_filters( 'license_key', $license_key )
13124
+ );
13125
+
13126
+ $install_ids = array();
13127
+
13128
+ $change_owner = FS_User::is_valid_id( $license_owner_id );
13129
+
13130
+ if ( $change_owner ) {
13131
+ $params['user_id'] = $license_owner_id;
13132
+
13133
+ $installs_info_by_slug_map = $fs->get_parent_and_addons_installs_info();
13134
+
13135
+ foreach ( $installs_info_by_slug_map as $slug => $install_info ) {
13136
+ $install_ids[ $slug ] = $install_info['install']->id;
13137
+ }
13138
+
13139
+ $params['install_ids'] = implode( ',', array_values( $install_ids ) );
13140
+ }
13141
+
13142
+ $api = $fs->get_api_site_scope();
13143
+
13144
+ $install = $api->call( $fs->add_show_pending( '/' ), 'put', $params );
13145
+
13146
+ if ( FS_Api::is_api_error( $install ) ) {
13147
+ $error = FS_Api::is_api_error_object( $install ) ?
13148
+ $install->error->message :
13149
+ var_export( $install->error, true );
13150
+ } else {
13151
+ $fs->reconnect_locally( $has_valid_blog_id );
13152
+
13153
+ if (
13154
+ $change_owner &&
13155
+ // If successful ownership change.
13156
+ $fs->get_user()->id != $install->user_id
13157
+ ) {
13158
+ $fs->complete_ownership_change_by_license( $install->user_id, $install_ids );
13159
+ }
13160
+ }
13161
+ } else /* ( $fs->is_addon() && $fs->get_parent_instance()->is_registered() ) */ {
13162
+ $result = $fs->activate_license_on_site( $user, $license_key );
13163
+
13164
+ if ( true !== $result ) {
13165
+ $error = FS_Api::is_api_error_object( $result ) ?
13166
+ $result->error->message :
13167
+ var_export( $result, true );
13168
+ }
13169
+ }
13170
+ }
13171
+
13172
+ if ( empty( $error ) ) {
13173
+ $fs->network_upgrade_mode_completed();
13174
+
13175
+ $fs->_sync_license( true, $has_valid_blog_id );
13176
+
13177
+ $this->maybe_sync_install_user();
13178
+
13179
+ $next_page = $fs->is_addon() ?
13180
+ $fs->get_parent_instance()->get_account_url() :
13181
+ $fs->get_account_url();
13182
+ }
13183
+ } else {
13184
+ $next_page = $fs->opt_in(
13185
+ false,
13186
+ false,
13187
+ false,
13188
+ $license_key,
13189
+ false,
13190
+ false,
13191
+ false,
13192
+ $is_marketing_allowed,
13193
+ $sites
13194
+ );
13195
+
13196
+ if ( isset( $next_page->error ) ) {
13197
+ $error = $next_page->error;
13198
+ } else {
13199
+ if ( fs_is_network_admin() ) {
13200
+ /**
13201
+ * Get the list of sites that were just opted-in (and license activated).
13202
+ * This is an optimization for the next part below saving some DB queries.
13203
+ */
13204
+ $connected_sites = array();
13205
+ foreach ( $sites as $site ) {
13206
+ if ( isset( $site['blog_id'] ) && is_numeric( $site['blog_id'] ) ) {
13207
+ $connected_sites[ $site['blog_id'] ] = true;
13208
+ }
13209
+ }
13210
+
13211
+ $all_sites = self::get_sites();
13212
+ $pending_sites = array();
13213
+
13214
+ /**
13215
+ * Check if there are any sites that are not connected, skipped, nor delegated. For every site that falls into that category, if the product is freemium, skip the connection. If the product is premium only, delegate the connection to the site administrator.
13216
+ *
13217
+ * @author Vova Feldman (@svovaf)
13218
+ */
13219
+ foreach ( $all_sites as $site ) {
13220
+ $blog_id = self::get_site_blog_id( $site );
13221
+
13222
+ if ( isset( $connected_sites[ $blog_id ] ) ) {
13223
+ // Site was just connected.
13224
+ continue;
13225
+ }
13226
+
13227
+ if ( $fs->is_installed_on_site( $blog_id ) ) {
13228
+ // Site was already connected before.
13229
+ continue;
13230
+ }
13231
+
13232
+ if ( $fs->is_site_delegated_connection( $blog_id ) ) {
13233
+ // Site's connection was delegated.
13234
+ continue;
13235
+ }
13236
+
13237
+ if ( $fs->is_anonymous_site( $blog_id ) ) {
13238
+ // Site connection was already skipped.
13239
+ continue;
13240
+ }
13241
+
13242
+ $pending_sites[] = self::get_site_info( $site );
13243
+ }
13244
+
13245
+ if ( ! empty( $pending_sites ) ) {
13246
+ if ( $fs->is_freemium() && $fs->is_enable_anonymous() ) {
13247
+ $fs->skip_connection( $pending_sites );
13248
+ } else {
13249
+ $fs->delegate_connection( $pending_sites );
13250
+ }
13251
+ }
13252
+ }
13253
+ }
13254
+ }
13255
+
13256
+ if ( false === $error && true === $fs->_storage->require_license_activation ) {
13257
+ $fs->_storage->require_license_activation = false;
13258
+ }
13259
+
13260
+ $result = array(
13261
+ 'success' => ( false === $error )
13262
+ );
13263
+
13264
+ if ( false !== $error ) {
13265
+ $result['error'] = $fs->apply_filters( 'opt_in_error_message', $error );
13266
+ } else {
13267
+ if ( $fs->is_addon() || $fs->has_addons() ) {
13268
+ /**
13269
+ * Purge the valid user licenses cache so that when the "Account" or the "Add-Ons" page is loaded,
13270
+ * an updated valid user licenses collection will be fetched from the server which is used to also
13271
+ * update the account add-ons (add-ons the user has licenses for).
13272
+ *
13273
+ * @author Leo Fajardo (@leorw)
13274
+ * @since 2.2.4
13275
+ */
13276
+ $fs->purge_valid_user_licenses_cache();
13277
+ }
13278
+
13279
+ $result['next_page'] = $next_page;
13280
+ }
13281
+
13282
+ return $result;
13283
+ }
13284
+
13285
+ /**
13286
+ * @author Leo Fajardo (@leorw)
13287
+ * @since 2.3.2
13288
+ *
13289
+ * @return array {
13290
+ * @key string Product slug.
13291
+ * @value array {
13292
+ * @property FS_Site $site
13293
+ * @property FS_Plugin_License $license
13294
+ * }
13295
+ * }
13296
+ */
13297
+ private function get_parent_and_addons_installs_info() {
13298
+ $fs = $this->is_addon() ?
13299
+ $this->get_parent_instance() :
13300
+ $this;
13301
+
13302
+ $installed_addons_ids = array();
13303
+
13304
+ $installed_addons_instances = $fs->get_installed_addons();
13305
+ foreach ( $installed_addons_instances as $instance ) {
13306
+ $installed_addons_ids[] = $instance->get_id();
13307
+ }
13308
+
13309
+ $addons_ids = array_unique( array_merge(
13310
+ $installed_addons_ids,
13311
+ $fs->get_updated_account_addons()
13312
+ ) );
13313
+
13314
+ // Add parent product info.
13315
+ $installs_info_by_slug_map = array(
13316
+ $fs->get_slug() => array(
13317
+ 'install' => $fs->get_site(),
13318
+ 'license' => $fs->_get_license()
13319
+ )
13320
+ );
13321
+
13322
+ foreach ( $addons_ids as $addon_id ) {
13323
+ $is_installed = isset( $installed_addons_ids_map[ $addon_id ] );
13324
+
13325
+ $addon_info = $fs->_get_addon_info( $addon_id, $is_installed );
13326
+
13327
+ if ( ! $addon_info['is_connected'] ) {
13328
+ // Add-on is not associated with an install entity.
13329
+ continue;
13330
+ }
13331
+
13332
+ $installs_info_by_slug_map[ $addon_info['slug'] ] = array(
13333
+ 'install' => $addon_info['site'],
13334
+ 'license' => isset( $addon_info['license'] ) ?
13335
+ $addon_info['license'] :
13336
+ null
13337
+ );
13338
+ }
13339
+
13340
+ return $installs_info_by_slug_map;
13341
+ }
13342
+
13343
+ /**
13344
+ * @author Leo Fajardo (@leorw)
13345
+ * @since 1.2.3.1
13346
+ */
13347
+ function _network_activate_ajax_action() {
13348
+ $this->_logger->entrance();
13349
+
13350
+ $this->check_ajax_referer( 'network_activate' );
13351
+
13352
+ $plugin_id = fs_request_get( 'module_id', '', 'post' );
13353
+ $fs = ( $plugin_id == $this->_module_id ) ?
13354
+ $this :
13355
+ $this->get_addon_instance( $plugin_id );
13356
+
13357
+ $error = false;
13358
+
13359
+ $sites = fs_request_get( 'sites', array(), 'post' );
13360
+ if ( is_array( $sites ) && ! empty( $sites ) ) {
13361
+ $sites_by_action = array(
13362
+ 'allow' => array(),
13363
+ 'delegate' => array(),
13364
+ 'skip' => array()
13365
+ );
13366
+
13367
+ foreach ( $sites as $site ) {
13368
+ $sites_by_action[ $site['action'] ][] = $site;
13369
+ }
13370
+
13371
+ $total_sites = count( $sites );
13372
+ $total_sites_to_delegate = count( $sites_by_action['delegate'] );
13373
+
13374
+ $next_page = '';
13375
+
13376
+ $has_any_install = fs_request_get_bool( 'has_any_install' );
13377
+
13378
+ if ( $total_sites === $total_sites_to_delegate &&
13379
+ ! $this->is_network_upgrade_mode() &&
13380
+ ! $has_any_install
13381
+ ) {
13382
+ $this->delegate_connection();
13383
+ } else {
13384
+ if ( ! empty( $sites_by_action['delegate'] ) ) {
13385
+ $this->delegate_connection( $sites_by_action['delegate'] );
13386
+ }
13387
+
13388
+ if ( ! empty( $sites_by_action['skip'] ) ) {
13389
+ $this->skip_connection( $sites_by_action['skip'] );
13390
+ }
13391
+
13392
+ if ( empty( $sites_by_action['allow'] ) ) {
13393
+ if ( $has_any_install ) {
13394
+ $first_install = $fs->find_first_install();
13395
+
13396
+ if ( ! is_null( $first_install ) ) {
13397
+ $fs->_site = $first_install['install'];
13398
+ $fs->_storage->network_install_blog_id = $first_install['blog_id'];
13399
+
13400
+ $fs->_user = self::_get_user_by_id( $fs->_site->user_id );
13401
+ $fs->_storage->network_user_id = $fs->_user->id;
13402
+ }
13403
+ }
13404
+ } else {
13405
+ if ( ! $fs->is_registered() || ! $this->_is_network_active ) {
13406
+ $next_page = $fs->opt_in(
13407
+ false,
13408
+ false,
13409
+ false,
13410
+ false,
13411
+ false,
13412
+ false,
13413
+ false,
13414
+ fs_request_get_bool( 'is_marketing_allowed', null ),
13415
+ $sites_by_action['allow']
13416
+ );
13417
+ } else {
13418
+ $next_page = $fs->install_with_user(
13419
+ $this->get_network_user(),
13420
+ false,
13421
+ false,
13422
+ false,
13423
+ true,
13424
+ $sites_by_action['allow']
13425
+ );
13426
+ }
13427
+
13428
+ if ( is_object( $next_page ) && isset( $next_page->error ) ) {
13429
+ $error = $next_page->error;
13430
+ }
13431
+ }
13432
+ }
13433
+
13434
+ if ( empty( $next_page ) ) {
13435
+ $next_page = $this->get_after_activation_url( 'after_network_activation_url' );
13436
+ }
13437
+ } else {
13438
+ $error = $this->get_text_inline( 'Invalid site details collection.', 'invalid_site_details_collection' );
13439
+ }
13440
+
13441
+ $result = array(
13442
+ 'success' => ( false === $error )
13443
+ );
13444
+
13445
+ if ( false !== $error ) {
13446
+ $result['error'] = $error;
13447
+ } else {
13448
+ $result['next_page'] = $next_page;
13449
+ }
13450
+
13451
+ echo json_encode( $result );
13452
+
13453
+ exit;
13454
+ }
13455
+
13456
+ /**
13457
+ * Billing update AJAX callback.
13458
+ *
13459
+ * @author Vova Feldman (@svovaf)
13460
+ * @since 1.2.1.5
13461
+ */
13462
+ function _update_billing_ajax_action() {
13463
+ $this->_logger->entrance();
13464
+
13465
+ $this->check_ajax_referer( 'update_billing' );
13466
+
13467
+ if ( ! $this->is_user_admin() ) {
13468
+ // Only for admins.
13469
+ self::shoot_ajax_failure();
13470
+ }
13471
+
13472
+ $billing = fs_request_get( 'billing' );
13473
+
13474
+ $api = $this->get_api_user_scope();
13475
+ $result = $api->call( '/billing.json', 'put', array_merge( $billing, array(
13476
+ 'plugin_id' => $this->get_parent_id(),
13477
+ ) ) );
13478
+
13479
+ if ( ! $this->is_api_result_entity( $result ) ) {
13480
+ self::shoot_ajax_failure();
13481
+ }
13482
+
13483
+ // Purge cached billing.
13484
+ $this->get_api_user_scope()->purge_cache( 'billing.json' );
13485
+
13486
+ self::shoot_ajax_success();
13487
+ }
13488
+
13489
+ /**
13490
+ * Trial start for anonymous users (AJAX callback).
13491
+ *
13492
+ * @author Vova Feldman (@svovaf)
13493
+ * @since 1.2.1.5
13494
+ */
13495
+ function _start_trial_ajax_action() {
13496
+ $this->_logger->entrance();
13497
+
13498
+ $this->check_ajax_referer( 'start_trial' );
13499
+
13500
+ if ( ! $this->is_user_admin() ) {
13501
+ // Only for admins.
13502
+ self::shoot_ajax_failure();
13503
+ }
13504
+
13505
+ $trial_data = fs_request_get( 'trial' );
13506
+
13507
+ $next_page = $this->opt_in(
13508
+ false,
13509
+ false,
13510
+ false,
13511
+ false,
13512
+ false,
13513
+ $trial_data['plan_id']
13514
+ );
13515
+
13516
+ if ( is_object( $next_page ) && $this->is_api_error( $next_page ) ) {
13517
+ self::shoot_ajax_failure(
13518
+ isset( $next_page->error ) ?
13519
+ $next_page->error->message :
13520
+ var_export( $next_page, true )
13521
+ );
13522
+ }
13523
+
13524
+ $this->shoot_ajax_success( array(
13525
+ 'next_page' => $next_page,
13526
+ ) );
13527
+ }
13528
+
13529
+ /**
13530
+ * @author Leo Fajardo (@leorw)
13531
+ * @since 1.2.0
13532
+ */
13533
+ function _resend_license_key_ajax_action() {
13534
+ $this->_logger->entrance();
13535
+
13536
+ $this->check_ajax_referer( 'resend_license_key' );
13537
+
13538
+ $email_address = sanitize_email( trim( fs_request_get( 'email', '', 'post' ) ) );
13539
+
13540
+ if ( empty( $email_address ) ) {
13541
+ exit;
13542
+ }
13543
+
13544
+ $error = false;
13545
+
13546
+ $api = $this->get_api_plugin_scope();
13547
+ $result = $api->call( '/licenses/resend.json', 'post',
13548
+ array(
13549
+ 'email' => $email_address,
13550
+ 'url' => home_url(),
13551
+ )
13552
+ );
13553
+
13554
+ if ( is_object( $result ) && isset( $result->error ) ) {
13555
+ $error = $result->error;
13556
+
13557
+ if ( in_array( $error->code, array( 'invalid_email', 'no_user' ) ) ) {
13558
+ $error = $this->get_text_inline( "We couldn't find your email address in the system, are you sure it's the right address?", 'email-not-found' );
13559
+ } else if ( 'no_license' === $error->code ) {
13560
+ $error = $this->get_text_inline( "We can't see any active licenses associated with that email address, are you sure it's the right address?", 'no-active-licenses' );
13561
+ } else {
13562
+ $error = $error->message;
13563
+ }
13564
+ }
13565
+
13566
+ $licenses = array(
13567
+ 'success' => ( false === $error )
13568
+ );
13569
+
13570
+ if ( false !== $error ) {
13571
+ $licenses['error'] = sprintf( '%s... %s', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ), strtolower( $error ) );
13572
+ }
13573
+
13574
+ echo json_encode( $licenses );
13575
+
13576
+ exit;
13577
+ }
13578
+
13579
+ /**
13580
+ * @author Vova Feldman (@svovaf)
13581
+ * @since 1.2.1.8
13582
+ *
13583
+ * @var string
13584
+ */
13585
+ private static $_pagenow;
13586
+
13587
+ /**
13588
+ * Get current page or the referer if executing a WP AJAX request.
13589
+ *
13590
+ * @author Vova Feldman (@svovaf)
13591
+ * @since 1.2.1.8
13592
+ *
13593
+ * @return string
13594
+ */
13595
+ static function get_current_page() {
13596
+ if ( ! isset( self::$_pagenow ) ) {
13597
+ global $pagenow;
13598
+ if ( empty( $pagenow ) && is_admin() && is_multisite() ) {
13599
+ /**
13600
+ * It appears that `$pagenow` is not yet initialized in some network admin pages when this method
13601
+ * is called, so initialize it here using some pieces of code from `wp-includes/vars.php`.
13602
+ *
13603
+ * @author Leo Fajardo (@leorw)
13604
+ * @since 2.2.3
13605
+ */
13606
+ if ( is_network_admin() ) {
13607
+ preg_match( '#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches );
13608
+ } else if ( is_user_admin() ) {
13609
+ preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches );
13610
+ } else {
13611
+ preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches );
13612
+ }
13613
+
13614
+ $pagenow = $self_matches[1];
13615
+ $pagenow = trim( $pagenow, '/' );
13616
+ $pagenow = preg_replace( '#\?.*?$#', '', $pagenow );
13617
+ if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
13618
+ $pagenow = 'index.php';
13619
+ } else {
13620
+ preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches );
13621
+ $pagenow = strtolower( $self_matches[1] );
13622
+ if ( '.php' !== substr($pagenow, -4, 4) )
13623
+ $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried)
13624
+ }
13625
+ }
13626
+
13627
+ self::$_pagenow = $pagenow;
13628
+
13629
+ if ( self::is_ajax() &&
13630
+ 'admin-ajax.php' === $pagenow
13631
+ ) {
13632
+ $referer = fs_get_raw_referer();
13633
+
13634
+ if ( is_string( $referer ) ) {
13635
+ $parts = explode( '?', $referer );
13636
+
13637
+ self::$_pagenow = basename( $parts[0] );
13638
+ }
13639
+ }
13640
+ }
13641
+
13642
+ return self::$_pagenow;
13643
+ }
13644
+
13645
+ /**
13646
+ * Helper method to check if user in the plugins page.
13647
+ *
13648
+ * @author Vova Feldman (@svovaf)
13649
+ * @since 1.2.1.5
13650
+ *
13651
+ * @return bool
13652
+ */
13653
+ static function is_plugins_page() {
13654
+ return ( 'plugins.php' === self::get_current_page() );
13655
+ }
13656
+
13657
+ /**
13658
+ * @author Leo Fajardo (@leorw)
13659
+ * @since 2.2.3
13660
+ *
13661
+ * @return bool
13662
+ */
13663
+ static function is_plugin_install_page() {
13664
+ return ( 'plugin-install.php' === self::get_current_page() );
13665
+ }
13666
+
13667
+ /**
13668
+ * @author Leo Fajardo (@leorw)
13669
+ * @since 2.0.2
13670
+ *
13671
+ * @return bool
13672
+ */
13673
+ static function is_updates_page() {
13674
+ return ( 'update-core.php' === self::get_current_page() );
13675
+ }
13676
+
13677
+ /**
13678
+ * Helper method to check if user in the themes page.
13679
+ *
13680
+ * @author Vova Feldman (@svovaf)
13681
+ * @since 1.2.2.6
13682
+ *
13683
+ * @return bool
13684
+ */
13685
+ static function is_themes_page() {
13686
+ return ( 'themes.php' === self::get_current_page() );
13687
+ }
13688
+
13689
+ #----------------------------------------------------------------------------------
13690
+ #region Affiliation
13691
+ #----------------------------------------------------------------------------------
13692
+
13693
+ /**
13694
+ * @author Leo Fajardo (@leorw)
13695
+ * @since 1.2.3
13696
+ *
13697
+ * @return bool
13698
+ */
13699
+ function has_affiliate_program() {
13700
+ if ( ! is_object( $this->_plugin ) ) {
13701
+ return false;
13702
+ }
13703
+
13704
+ return $this->_plugin->has_affiliate_program();
13705
+ }
13706
+
13707
+ /**
13708
+ * @author Leo Fajardo (@leorw)
13709
+ * @since 1.2.4
13710
+ */
13711
+ private function fetch_affiliate_terms() {
13712
+ if ( ! is_object( $this->plugin_affiliate_terms ) ) {
13713
+ $plugins_api = $this->get_api_plugin_scope();
13714
+ $affiliate_terms = $plugins_api->get( '/aff.json?type=affiliation', false );
13715
+
13716
+ if ( ! $this->is_api_result_entity( $affiliate_terms ) ) {
13717
+ return;
13718
+ }
13719
+
13720
+ $this->plugin_affiliate_terms = new FS_AffiliateTerms( $affiliate_terms );
13721
+ }
13722
+ }
13723
+
13724
+ /**
13725
+ * @author Leo Fajardo (@leorw)
13726
+ * @since 1.2.4
13727
+ */
13728
+ private function fetch_affiliate_and_custom_terms() {
13729
+ if ( ! empty( $this->_storage->affiliate_application_data ) ) {
13730
+ $application_data = $this->_storage->affiliate_application_data;
13731
+ $flush = ( ! isset( $application_data['status'] ) || 'pending' === $application_data['status'] );
13732
+
13733
+ $users_api = $this->get_api_user_scope();
13734
+ $result = $users_api->get( "/plugins/{$this->_plugin->id}/aff/{$this->plugin_affiliate_terms->id}/affiliates.json", $flush );
13735
+ if ( $this->is_api_result_object( $result, 'affiliates' ) ) {
13736
+ if ( ! empty( $result->affiliates ) ) {
13737
+ $affiliate = new FS_Affiliate( $result->affiliates[0] );
13738
+
13739
+ if ( ! isset( $application_data['status'] ) || $application_data['status'] !== $affiliate->status ) {
13740
+ $application_data['status'] = $affiliate->status;
13741
+ $this->_storage->affiliate_application_data = $application_data;
13742
+ }
13743
+
13744
+ if ( $affiliate->is_using_custom_terms ) {
13745
+ $affiliate_terms = $users_api->get( "/plugins/{$this->_plugin->id}/affiliates/{$affiliate->id}/aff/{$affiliate->custom_affiliate_terms_id}.json", $flush );
13746
+ if ( $this->is_api_result_entity( $affiliate_terms ) ) {
13747
+ $this->custom_affiliate_terms = new FS_AffiliateTerms( $affiliate_terms );
13748
+ }
13749
+ }
13750
+
13751
+ $this->affiliate = $affiliate;
13752
+ }
13753
+ }
13754
+ }
13755
+ }
13756
+
13757
+ /**
13758
+ * @author Leo Fajardo (@leorw)
13759
+ * @since 1.2.3
13760
+ */
13761
+ private function fetch_affiliate_and_terms() {
13762
+ $this->_logger->entrance();
13763
+
13764
+ $this->fetch_affiliate_terms();
13765
+ $this->fetch_affiliate_and_custom_terms();
13766
+ }
13767
+
13768
+ /**
13769
+ * @author Leo Fajardo (@leorw)
13770
+ * @since 1.2.3
13771
+ *
13772
+ * @return FS_Affiliate
13773
+ */
13774
+ function get_affiliate() {
13775
+ return $this->affiliate;
13776
+ }
13777
+
13778
+
13779
+ /**
13780
+ * @author Leo Fajardo (@leorw)
13781
+ * @since 1.2.3
13782
+ *
13783
+ * @return FS_AffiliateTerms
13784
+ */
13785
+ function get_affiliate_terms() {
13786
+ return is_object( $this->custom_affiliate_terms ) ?
13787
+ $this->custom_affiliate_terms :
13788
+ $this->plugin_affiliate_terms;
13789
+ }
13790
+
13791
+ /**
13792
+ * @author Leo Fajardo (@leorw)
13793
+ * @since 1.2.3
13794
+ */
13795
+ function _submit_affiliate_application() {
13796
+ $this->_logger->entrance();
13797
+
13798
+ $this->check_ajax_referer( 'submit_affiliate_application' );
13799
+
13800
+ if ( ! $this->is_user_admin() ) {
13801
+ // Only for admins.
13802
+ self::shoot_ajax_failure();
13803
+ }
13804
+
13805
+ $affiliate = fs_request_get( 'affiliate' );
13806
+
13807
+ if ( empty( $affiliate['promotion_methods'] ) ) {
13808
+ unset( $affiliate['promotion_methods'] );
13809
+ }
13810
+
13811
+ if ( ! empty( $affiliate['additional_domains'] ) ) {
13812
+ $affiliate['additional_domains'] = array_unique( $affiliate['additional_domains'] );
13813
+ }
13814
+
13815
+ if ( ! $this->is_registered() ) {
13816
+ // Opt in but don't track usage.
13817
+ $next_page = $this->opt_in(
13818
+ false,
13819
+ false,
13820
+ false,
13821
+ false,
13822
+ false,
13823
+ false,
13824
+ true
13825
+ );
13826
+
13827
+ if ( is_object( $next_page ) && $this->is_api_error( $next_page ) ) {
13828
+ self::shoot_ajax_failure(
13829
+ isset( $next_page->error ) ?
13830
+ $next_page->error->message :
13831
+ var_export( $next_page, true )
13832
+ );
13833
+ } else if ( $this->is_pending_activation() ) {
13834
+ self::shoot_ajax_failure( $this->get_text_inline( 'Account is pending activation.', 'account-is-pending-activation' ) );
13835
+ }
13836
+ }
13837
+
13838
+ $this->fetch_affiliate_terms();
13839
+
13840
+ $api = $this->get_api_user_scope();
13841
+ $result = $api->call(
13842
+ ( "/plugins/{$this->_plugin->id}/aff/{$this->plugin_affiliate_terms->id}/affiliates.json" ),
13843
+ 'post',
13844
+ $affiliate
13845
+ );
13846
+
13847
+ if ( $this->is_api_error( $result ) ) {
13848
+ self::shoot_ajax_failure(
13849
+ isset( $result->error ) ?
13850
+ $result->error->message :
13851
+ var_export( $result, true )
13852
+ );
13853
+ } else {
13854
+ if ( $this->_admin_notices->has_sticky( 'affiliate_program' ) ) {
13855
+ $this->_admin_notices->remove_sticky( 'affiliate_program' );
13856
+ }
13857
+
13858
+ $affiliate_application_data = array(
13859
+ 'status' => 'pending',
13860
+ 'stats_description' => $affiliate['stats_description'],
13861
+ 'promotion_method_description' => $affiliate['promotion_method_description'],
13862
+ );
13863
+
13864
+ if ( ! empty( $affiliate['promotion_methods'] ) ) {
13865
+ $affiliate_application_data['promotion_methods'] = $affiliate['promotion_methods'];
13866
+ }
13867
+
13868
+ if ( ! empty( $affiliate['domain'] ) ) {
13869
+ $affiliate_application_data['domain'] = $affiliate['domain'];
13870
+ }
13871
+
13872
+ if ( ! empty( $affiliate['additional_domains'] ) ) {
13873
+ $affiliate_application_data['additional_domains'] = $affiliate['additional_domains'];
13874
+ }
13875
+
13876
+ $this->_storage->affiliate_application_data = $affiliate_application_data;
13877
+ }
13878
+
13879
+ // Purge cached affiliate.
13880
+ $api->purge_cache( 'affiliate.json' );
13881
+
13882
+ self::shoot_ajax_success( $result );
13883
+ }
13884
+
13885
+ /**
13886
+ * @author Leo Fajardo (@leorw)
13887
+ * @since 1.2.3
13888
+ *
13889
+ * @return array|null
13890
+ */
13891
+ function get_affiliate_application_data() {
13892
+ if ( empty( $this->_storage->affiliate_application_data ) ) {
13893
+ return null;
13894
+ }
13895
+
13896
+ return $this->_storage->affiliate_application_data;
13897
+ }
13898
+
13899
+ #endregion Affiliation ------------------------------------------------------------
13900
+
13901
+ #----------------------------------------------------------------------------------
13902
+ #region URL Generators
13903
+ #----------------------------------------------------------------------------------
13904
+
13905
+ /**
13906
+ * Alias to pricing_url().
13907
+ *
13908
+ * @author Vova Feldman (@svovaf)
13909
+ * @since 1.0.2
13910
+ *
13911
+ * @uses pricing_url()
13912
+ *
13913
+ * @param string $period Billing cycle
13914
+ * @param bool $is_trial
13915
+ *
13916
+ * @return string
13917
+ */
13918
+ function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
13919
+ return $this->pricing_url( $period, $is_trial );
13920
+ }
13921
+
13922
+ /**
13923
+ * @author Vova Feldman (@svovaf)
13924
+ * @since 1.0.9
13925
+ *
13926
+ * @uses get_upgrade_url()
13927
+ *
13928
+ * @return string
13929
+ */
13930
+ function get_trial_url() {
13931
+ return $this->get_upgrade_url( WP_FS__PERIOD_ANNUALLY, true );
13932
+ }
13933
+
13934
+ /**
13935
+ * @author Leo Fajardo (@leorw)
13936
+ * @since 2.1.4
13937
+ *
13938
+ * @param string $new_version
13939
+ *
13940
+ * @return string
13941
+ */
13942
+ function version_upgrade_checkout_link( $new_version ) {
13943
+ if ( ! is_object( $this->_license ) ) {
13944
+ $url = $this->pricing_url();
13945
+
13946
+ $purchase_license_text = $this->get_text_inline( 'Buy a license now', 'buy-license-now' );
13947
+ } else {
13948
+ $subscription = $this->_get_subscription( $this->_license->id );
13949
+
13950
+ $url = $this->checkout_url(
13951
+ is_object( $subscription ) ?
13952
+ ( 1 == $subscription->billing_cycle ? WP_FS__PERIOD_MONTHLY : WP_FS__PERIOD_ANNUALLY ) :
13953
+ WP_FS__PERIOD_LIFETIME,
13954
+ false,
13955
+ array( 'licenses' => $this->_license->quota )
13956
+ );
13957
+
13958
+ $purchase_license_text = $this->get_text_inline( 'Renew your license now', 'renew-license-now' );
13959
+ }
13960
+
13961
+ return sprintf(
13962
+ $this->get_text_inline( '%s to access version %s security & feature updates, and support.', 'x-for-updates-and-support' ),
13963
+ sprintf( '<a href="%s">%s</a>', $url, $purchase_license_text ),
13964
+ $new_version
13965
+ );
13966
+ }
13967
+
13968
+ /**
13969
+ * Plugin's pricing URL.
13970
+ *
13971
+ * @author Vova Feldman (@svovaf)
13972
+ * @since 1.0.4
13973
+ *
13974
+ * @param string $billing_cycle Billing cycle
13975
+ *
13976
+ * @param bool $is_trial
13977
+ *
13978
+ * @return string
13979
+ */
13980
+ function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
13981
+ $this->_logger->entrance();
13982
+
13983
+ $params = array(
13984
+ 'billing_cycle' => $billing_cycle
13985
+ );
13986
+
13987
+ if ( $is_trial ) {
13988
+ $params['trial'] = 'true';
13989
+ }
13990
+
13991
+ $url = $this->is_addon() ?
13992
+ $this->_parent->addon_url( $this->_slug ) :
13993
+ $this->_get_admin_page_url( 'pricing', $params );
13994
+
13995
+ return $this->apply_filters( 'pricing_url', $url );
13996
+ }
13997
+
13998
+ /**
13999
+ * Checkout page URL.
14000
+ *
14001
+ * @author Vova Feldman (@svovaf)
14002
+ * @since 1.0.6
14003
+ *
14004
+ * @param string $billing_cycle Billing cycle
14005
+ * @param bool $is_trial
14006
+ * @param array $extra (optional) Extra parameters, override other query params.
14007
+ * @param bool|null $network
14008
+ *
14009
+ * @return string
14010
+ */
14011
+ function checkout_url(
14012
+ $billing_cycle = WP_FS__PERIOD_ANNUALLY,
14013
+ $is_trial = false,
14014
+ $extra = array(),
14015
+ $network = null
14016
+ ) {
14017
+ $this->_logger->entrance();
14018
+
14019
+ $params = array(
14020
+ 'checkout' => 'true',
14021
+ 'billing_cycle' => $billing_cycle,
14022
+ );
14023
+
14024
+ if ( $is_trial ) {
14025
+ $params['trial'] = 'true';
14026
+ }
14027
+
14028
+ /**
14029
+ * Params in extra override other params.
14030
+ */
14031
+ $params = array_merge( $params, $extra );
14032
+
14033
+ return $this->_get_admin_page_url( 'pricing', $params, $network );
14034
+ }
14035
+
14036
+ /**
14037
+ * Add-on checkout URL.
14038
+ *
14039
+ * @author Vova Feldman (@svovaf)
14040
+ * @since 1.1.7
14041
+ *
14042
+ * @param number $addon_id
14043
+ * @param number $pricing_id
14044
+ * @param string $billing_cycle
14045
+ * @param bool $is_trial
14046
+ * @param bool|null $network
14047
+ *
14048
+ * @return string
14049
+ */
14050
+ function addon_checkout_url(
14051
+ $addon_id,
14052
+ $pricing_id,
14053
+ $billing_cycle = WP_FS__PERIOD_ANNUALLY,
14054
+ $is_trial = false,
14055
+ $network = null
14056
+ ) {
14057
+ return $this->checkout_url( $billing_cycle, $is_trial, array(
14058
+ 'plugin_id' => $addon_id,
14059
+ 'pricing_id' => $pricing_id,
14060
+ ), $network );
14061
+ }
14062
+
14063
+ #endregion
14064
+
14065
+ #endregion ------------------------------------------------------------------
14066
+
14067
+ /**
14068
+ * Check if plugin has any add-ons.
14069
+ *
14070
+ * @author Vova Feldman (@svovaf)
14071
+ * @since 1.0.5
14072
+ *
14073
+ * @since 1.1.7.3 Base logic only on the parameter provided by the developer in the init function.
14074
+ *
14075
+ * @return bool
14076
+ */
14077
+ function has_addons() {
14078
+ $this->_logger->entrance();
14079
+
14080
+ return $this->_has_addons;
14081
+ }
14082
+
14083
+ /**
14084
+ * Check if plugin can work in anonymous mode.
14085
+ *
14086
+ * @author Vova Feldman (@svovaf)
14087
+ * @since 1.0.9
14088
+ *
14089
+ * @return bool
14090
+ *
14091
+ * @deprecated Please use is_enable_anonymous() instead.
14092
+ */
14093
+ function enable_anonymous() {
14094
+ return $this->_enable_anonymous;
14095
+ }
14096
+
14097
+ /**
14098
+ * Check if plugin can work in anonymous mode.
14099
+ *
14100
+ * @author Vova Feldman (@svovaf)
14101
+ * @since 1.1.9
14102
+ *
14103
+ * @return bool
14104
+ */
14105
+ function is_enable_anonymous() {
14106
+ return $this->_enable_anonymous;
14107
+ }
14108
+
14109
+ /**
14110
+ * Check if plugin is premium only (no free plans).
14111
+ *
14112
+ * @author Vova Feldman (@svovaf)
14113
+ * @since 1.1.9
14114
+ *
14115
+ * @return bool
14116
+ */
14117
+ function is_only_premium() {
14118
+ return $this->_is_premium_only;
14119
+ }
14120
+
14121
+ /**
14122
+ * Checks if the plugin's type is "plugin". The other type is "theme".
14123
+ *
14124
+ * @author Leo Fajardo (@leorw)
14125
+ * @since 1.2.2
14126
+ *
14127
+ * @return bool
14128
+ */
14129
+ function is_plugin() {
14130
+ return ( WP_FS__MODULE_TYPE_PLUGIN === $this->_module_type );
14131
+ }
14132
+
14133
+ /**
14134
+ * @author Leo Fajardo (@leorw)
14135
+ * @since 1.2.2
14136
+ *
14137
+ * @return string
14138
+ */
14139
+ function get_module_type() {
14140
+ if ( ! isset( $this->_module_type ) ) {
14141
+ $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
14142
+ $this->_module_type = $id_slug_type_path_map[ $this->_module_id ]['type'];
14143
+ }
14144
+
14145
+ return $this->_module_type;
14146
+ }
14147
+
14148
+ /**
14149
+ * @author Leo Fajardo (@leorw)
14150
+ * @since 1.2.2
14151
+ *
14152
+ * @return string
14153
+ */
14154
+ function get_plugin_main_file_path() {
14155
+ return $this->_plugin_main_file_path;
14156
+ }
14157
+
14158
+ /**
14159
+ * Check if module has a premium code version.
14160
+ *
14161
+ * Serviceware module might be freemium without any
14162
+ * premium code version, where the paid features
14163
+ * are all part of the service.
14164
+ *
14165
+ * @author Vova Feldman (@svovaf)
14166
+ * @since 1.2.1.6
14167
+ *
14168
+ * @return bool
14169
+ */
14170
+ function has_premium_version() {
14171
+ return $this->_has_premium_version;
14172
+ }
14173
+
14174
+ /**
14175
+ * Check if feature supported with current site's plan.
14176
+ *
14177
+ * @author Vova Feldman (@svovaf)
14178
+ * @since 1.0.1
14179
+ *
14180
+ * @todo IMPLEMENT
14181
+ *
14182
+ * @param number $feature_id
14183
+ *
14184
+ * @throws Exception
14185
+ */
14186
+ function is_feature_supported( $feature_id ) {
14187
+ throw new Exception( 'not implemented' );
14188
+ }
14189
+
14190
+ /**
14191
+ * @author Vova Feldman (@svovaf)
14192
+ * @since 1.0.1
14193
+ *
14194
+ * @return bool Is running in SSL/HTTPS
14195
+ */
14196
+ function is_ssl() {
14197
+ return WP_FS__IS_HTTPS;
14198
+ }
14199
+
14200
+ /**
14201
+ * @author Vova Feldman (@svovaf)
14202
+ * @since 1.0.9
14203
+ *
14204
+ * @return bool Is running in AJAX call.
14205
+ *
14206
+ * @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
14207
+ */
14208
+ static function is_ajax() {
14209
+ return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
14210
+ }
14211
+
14212
+ /**
14213
+ * Check if it's an AJAX call targeted for the current module.
14214
+ *
14215
+ * @author Vova Feldman (@svovaf)
14216
+ * @since 1.2.0
14217
+ *
14218
+ * @param array|string $actions Collection of AJAX actions.
14219
+ *
14220
+ * @return bool
14221
+ */
14222
+ function is_ajax_action( $actions ) {
14223
+ // Verify it's an ajax call.
14224
+ if ( ! self::is_ajax() ) {
14225
+ return false;
14226
+ }
14227
+
14228
+ // Verify the call is relevant for the plugin.
14229
+ if ( $this->_module_id != fs_request_get( 'module_id' ) ) {
14230
+ return false;
14231
+ }
14232
+
14233
+ // Verify it's one of the specified actions.
14234
+ if ( is_string( $actions ) ) {
14235
+ $actions = explode( ',', $actions );
14236
+ }
14237
+
14238
+ if ( is_array( $actions ) && 0 < count( $actions ) ) {
14239
+ $ajax_action = fs_request_get( 'action' );
14240
+
14241
+ foreach ( $actions as $action ) {
14242
+ if ( $ajax_action === $this->get_action_tag( $action ) ) {
14243
+ return true;
14244
+ }
14245
+ }
14246
+ }
14247
+
14248
+ return false;
14249
+ }
14250
+
14251
+ /**
14252
+ * Check if it's an AJAX call targeted for current request.
14253
+ *
14254
+ * @author Vova Feldman (@svovaf)
14255
+ * @since 1.2.0
14256
+ *
14257
+ * @param array|string $actions Collection of AJAX actions.
14258
+ * @param number|null $module_id
14259
+ *
14260
+ * @return bool
14261
+ */
14262
+ static function is_ajax_action_static( $actions, $module_id = null ) {
14263
+ // Verify it's an ajax call.
14264
+ if ( ! self::is_ajax() ) {
14265
+ return false;
14266
+ }
14267
+
14268
+
14269
+ if ( ! empty( $module_id ) ) {
14270
+ // Verify the call is relevant for the plugin.
14271
+ if ( $module_id != fs_request_get( 'module_id' ) ) {
14272
+ return false;
14273
+ }
14274
+