Activity Log - Version 2.2.7

Version Description

  • Added! - Freemius Insights platform to improve plugin UX
  • Tweak! Update translate: Russian (ru_RU) - Thanks to Oleg Reznikov
  • Tested up to WordPress v4.4
Download this release

Release Info

Developer KingYes
Plugin Icon 128x128 Activity Log
Version 2.2.7
Comparing to
See all releases

Code changes from version 2.2.6 to 2.2.7

Files changed (118) hide show
  1. aryo-activity-log.php +53 -10
  2. classes/class-aal-activity-log-list-table.php +29 -29
  3. classes/class-aal-admin-ui.php +2 -2
  4. classes/class-aal-help.php +3 -3
  5. classes/class-aal-notifications.php +2 -2
  6. classes/class-aal-settings.php +31 -31
  7. classes/freemius/LICENSE.txt +340 -0
  8. classes/freemius/assets/css/admin/account.css +1 -0
  9. classes/freemius/assets/css/admin/add-ons.css +2 -0
  10. classes/freemius/assets/css/admin/common.css +1 -0
  11. classes/freemius/assets/css/admin/connect.css +1 -0
  12. classes/freemius/assets/css/admin/deactivation-feedback.css +1 -0
  13. classes/freemius/assets/css/common.css +1 -0
  14. classes/freemius/assets/img/icon.svg +78 -0
  15. classes/freemius/assets/img/plugin-icon.png +0 -0
  16. classes/freemius/assets/js/jquery.ba-postmessage.js +222 -0
  17. classes/freemius/assets/js/jquery.ba-postmessage.min.js +9 -0
  18. classes/freemius/assets/js/nojquery.ba-postmessage.js +140 -0
  19. classes/freemius/assets/js/nojquery.ba-postmessage.min.js +12 -0
  20. classes/freemius/assets/js/postmessage.js +110 -0
  21. classes/freemius/assets/scss/_colors.scss +58 -0
  22. classes/freemius/assets/scss/_functions.scss +0 -0
  23. classes/freemius/assets/scss/_load.scss +4 -0
  24. classes/freemius/assets/scss/_mixins.scss +224 -0
  25. classes/freemius/assets/scss/_start.scss +4 -0
  26. classes/freemius/assets/scss/_vars.scss +5 -0
  27. classes/freemius/assets/scss/admin/account.scss +122 -0
  28. classes/freemius/assets/scss/admin/add-ons.scss +319 -0
  29. classes/freemius/assets/scss/admin/common.scss +109 -0
  30. classes/freemius/assets/scss/admin/connect.scss +405 -0
  31. classes/freemius/assets/scss/admin/deactivation-feedback.scss +120 -0
  32. classes/freemius/config.php +161 -0
  33. classes/freemius/includes/class-freemius-abstract.php +392 -0
  34. classes/freemius/includes/class-freemius.php +7648 -0
  35. classes/freemius/includes/class-fs-api.php +354 -0
  36. classes/freemius/includes/class-fs-logger.php +168 -0
  37. classes/freemius/includes/class-fs-plugin-updater.php +253 -0
  38. classes/freemius/includes/class-fs-security.php +61 -0
  39. classes/freemius/includes/entities/class-fs-entity.php +149 -0
  40. classes/freemius/includes/entities/class-fs-plugin-info.php +34 -0
  41. classes/freemius/includes/entities/class-fs-plugin-license.php +160 -0
  42. classes/freemius/includes/entities/class-fs-plugin-plan.php +71 -0
  43. classes/freemius/includes/entities/class-fs-plugin-tag.php +24 -0
  44. classes/freemius/includes/entities/class-fs-plugin.php +90 -0
  45. classes/freemius/includes/entities/class-fs-scope-entity.php +29 -0
  46. classes/freemius/includes/entities/class-fs-site.php +119 -0
  47. classes/freemius/includes/entities/class-fs-subscription.php +117 -0
  48. classes/freemius/includes/entities/class-fs-user.php +62 -0
  49. classes/freemius/includes/fs-core-functions.php +461 -0
  50. classes/freemius/includes/fs-plugin-functions.php +411 -0
  51. classes/freemius/includes/i18n.php +247 -0
  52. classes/freemius/includes/managers/class-fs-admin-menu-manager.php +544 -0
  53. classes/freemius/includes/managers/class-fs-admin-notice-manager.php +303 -0
  54. classes/freemius/includes/managers/class-fs-key-value-storage.php +291 -0
  55. classes/freemius/includes/managers/class-fs-license-manager.php +101 -0
  56. classes/freemius/includes/managers/class-fs-option-manager.php +297 -0
  57. classes/freemius/includes/managers/class-fs-plan-manager.php +147 -0
  58. classes/freemius/includes/managers/class-fs-plugin-manager.php +154 -0
  59. classes/freemius/includes/sdk/Exceptions/ArgumentNotExistException.php +2 -0
  60. classes/freemius/includes/sdk/Exceptions/EmptyArgumentException.php +2 -0
  61. classes/freemius/includes/sdk/Exceptions/Exception.php +75 -0
  62. classes/freemius/includes/sdk/Exceptions/InvalidArgumentException.php +2 -0
  63. classes/freemius/includes/sdk/Exceptions/OAuthException.php +8 -0
  64. classes/freemius/includes/sdk/Freemius.php +403 -0
  65. classes/freemius/includes/sdk/FreemiusBase.php +217 -0
  66. classes/freemius/includes/sdk/LICENSE.txt +340 -0
  67. classes/freemius/start.php +95 -0
  68. classes/freemius/templates/account.php +442 -0
  69. classes/freemius/templates/add-ons.php +113 -0
  70. classes/freemius/templates/admin-notice.php +34 -0
  71. classes/freemius/templates/all-admin-notice.php +31 -0
  72. classes/freemius/templates/checkout.php +242 -0
  73. classes/freemius/templates/connect.php +182 -0
  74. classes/freemius/templates/contact.php +72 -0
  75. classes/freemius/templates/deactivation-feedback-modal.php +196 -0
  76. classes/freemius/templates/debug.php +103 -0
  77. classes/freemius/templates/email.php +42 -0
  78. classes/freemius/templates/firewall-issues-js.php +49 -0
  79. classes/freemius/templates/pending-activation.php +146 -0
  80. classes/freemius/templates/plugin-icon.php +58 -0
  81. classes/freemius/templates/plugin-info/description.php +63 -0
  82. classes/freemius/templates/plugin-info/features.php +81 -0
  83. classes/freemius/templates/plugin-info/screenshots.php +19 -0
  84. classes/freemius/templates/powered-by.php +37 -0
  85. classes/freemius/templates/pricing.php +96 -0
  86. classes/freemius/templates/sticky-admin-notice-js.php +36 -0
  87. hooks/class-aal-hook-posts.php +2 -2
  88. language/aryo-aal-ru_RU.mo +0 -0
  89. language/aryo-aal.pot +0 -716
  90. language/{aryo-aal-cs_CZ.mo → aryo-activity-log-cs_CZ.mo} +0 -0
  91. language/{aryo-aal-cs_CZ.po → aryo-activity-log-cs_CZ.po} +0 -0
  92. language/{aryo-aal-da_DK.mo → aryo-activity-log-da_DK.mo} +0 -0
  93. language/{aryo-aal-da_DK.po → aryo-activity-log-da_DK.po} +0 -0
  94. language/{aryo-aal-de_DE.mo → aryo-activity-log-de_DE.mo} +0 -0
  95. language/{aryo-aal-de_DE.po → aryo-activity-log-de_DE.po} +0 -0
  96. language/{aryo-aal-fi.mo → aryo-activity-log-fi.mo} +0 -0
  97. language/{aryo-aal-fi.po → aryo-activity-log-fi.po} +0 -0
  98. language/{aryo-aal-he_IL.mo → aryo-activity-log-he_IL.mo} +0 -0
  99. language/{aryo-aal-he_IL.po → aryo-activity-log-he_IL.po} +0 -0
  100. language/{aryo-aal-hy_AM.mo → aryo-activity-log-hy_AM.mo} +0 -0
  101. language/{aryo-aal-hy_AM.po → aryo-activity-log-hy_AM.po} +0 -0
  102. language/{aryo-aal-nl_NL.mo → aryo-activity-log-nl_NL.mo} +0 -0
  103. language/{aryo-aal-nl_NL.po → aryo-activity-log-nl_NL.po} +0 -0
  104. language/{aryo-aal-pl_PL.mo → aryo-activity-log-pl_PL.mo} +0 -0
  105. language/{aryo-aal-pl_PL.po → aryo-activity-log-pl_PL.po} +0 -0
  106. language/{aryo-aal-pt_BR.mo → aryo-activity-log-pt_BR.mo} +0 -0
  107. language/{aryo-aal-pt_BR.po → aryo-activity-log-pt_BR.po} +0 -0
  108. language/aryo-activity-log-ru_RU.mo +0 -0
  109. language/{aryo-aal-ru_RU.po → aryo-activity-log-ru_RU.po} +151 -134
  110. language/{aryo-aal-sr_RS.mo → aryo-activity-log-sr_RS.mo} +0 -0
  111. language/{aryo-aal-sr_RS.po → aryo-activity-log-sr_RS.po} +0 -0
  112. language/{aryo-aal-tr_TR.mo → aryo-activity-log-tr_TR.mo} +0 -0
  113. language/{aryo-aal-tr_TR.po → aryo-activity-log-tr_TR.po} +0 -0
  114. language/aryo-activity-log.pot +1927 -0
  115. language/strings.php +99 -99
  116. notifications/abstract-class-aal-notification-base.php +6 -6
  117. notifications/class-aal-notification-email.php +8 -8
  118. readme.txt +9 -4
aryo-activity-log.php CHANGED
@@ -5,8 +5,8 @@ Plugin URI: http://wordpress.org/plugins/aryo-activity-log/
5
  Description: Get aware of any activities that are taking place on your dashboard! Imagine it like a black-box for your WordPress site. e.g. post was deleted, plugin was activated, user logged in or logged out - it's all these for you to see.
6
  Author: Yakir Sitbon, Maor Chasen, Ariel Klikstein
7
  Author URI: http://pojo.me/
8
- Version: 2.2.6
9
- Text Domain: aryo-aal
10
  Domain Path: /language/
11
  License: GPLv2 or later
12
 
@@ -76,11 +76,16 @@ final class AAL_Main {
76
  */
77
  public $api;
78
 
 
 
 
 
 
79
  /**
80
  * Load text domain
81
  */
82
  public function load_textdomain() {
83
- load_plugin_textdomain( 'aryo-aal', false, basename( dirname( __FILE__ ) ) . '/language' );
84
  }
85
 
86
  /**
@@ -88,7 +93,9 @@ final class AAL_Main {
88
  */
89
  protected function __construct() {
90
  global $wpdb;
91
-
 
 
92
  $this->ui = new AAL_Admin_Ui();
93
  $this->hooks = new AAL_Hooks();
94
  $this->settings = new AAL_Settings();
@@ -113,7 +120,7 @@ final class AAL_Main {
113
  */
114
  public function __clone() {
115
  // Cloning instances of the class is forbidden
116
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'aryo-aal' ), '2.0.7' );
117
  }
118
 
119
  /**
@@ -124,7 +131,7 @@ final class AAL_Main {
124
  */
125
  public function __wakeup() {
126
  // Unserializing instances of the class is forbidden
127
- _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'aryo-aal' ), '2.0.7' );
128
  }
129
 
130
  /**
@@ -135,8 +142,44 @@ final class AAL_Main {
135
  self::$_instance = new AAL_Main();
136
  return self::$_instance;
137
  }
138
-
139
- }
140
- AAL_Main::instance();
141
 
142
- // EOF
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  Description: Get aware of any activities that are taking place on your dashboard! Imagine it like a black-box for your WordPress site. e.g. post was deleted, plugin was activated, user logged in or logged out - it's all these for you to see.
6
  Author: Yakir Sitbon, Maor Chasen, Ariel Klikstein
7
  Author URI: http://pojo.me/
8
+ Version: 2.2.7
9
+ Text Domain: aryo-activity-log
10
  Domain Path: /language/
11
  License: GPLv2 or later
12
 
76
  */
77
  public $api;
78
 
79
+ /**
80
+ * @var Freemius
81
+ */
82
+ public $freemius;
83
+
84
  /**
85
  * Load text domain
86
  */
87
  public function load_textdomain() {
88
+ load_plugin_textdomain( 'aryo-activity-log', false, basename( dirname( __FILE__ ) ) . '/language' );
89
  }
90
 
91
  /**
93
  */
94
  protected function __construct() {
95
  global $wpdb;
96
+
97
+ $this->_setup_freemius();
98
+
99
  $this->ui = new AAL_Admin_Ui();
100
  $this->hooks = new AAL_Hooks();
101
  $this->settings = new AAL_Settings();
120
  */
121
  public function __clone() {
122
  // Cloning instances of the class is forbidden
123
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'aryo-activity-log' ), '2.0.7' );
124
  }
125
 
126
  /**
131
  */
132
  public function __wakeup() {
133
  // Unserializing instances of the class is forbidden
134
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'aryo-activity-log' ), '2.0.7' );
135
  }
136
 
137
  /**
142
  self::$_instance = new AAL_Main();
143
  return self::$_instance;
144
  }
 
 
 
145
 
146
+ private function _setup_freemius() {
147
+ // Include Freemius SDK.
148
+ require_once 'classes/freemius/start.php';
149
+
150
+ $this->freemius = fs_dynamic_init(
151
+ array(
152
+ 'id' => '111',
153
+ 'slug' => 'aryo-activity-log',
154
+ 'public_key' => 'pk_939ce05ca99db10045c0094c6e953',
155
+ 'is_premium' => false,
156
+ 'has_paid_plans' => false,
157
+ 'menu' => array(
158
+ 'slug' => 'activity_log_page',
159
+ 'account' => false,
160
+ 'contact' => false,
161
+ 'support' => false,
162
+ ),
163
+ )
164
+ );
165
+
166
+ if ( $this->freemius->is_plugin_update() ) {
167
+ $this->freemius->add_filter( 'connect_message', array( &$this, '_freemius_custom_connect_message' ), WP_FS__DEFAULT_PRIORITY, 6 );
168
+ }
169
+ }
170
+
171
+ public function _freemius_custom_connect_message( $message, $user_first_name, $plugin_title, $user_login, $site_link, $freemius_link ) {
172
+ return sprintf(
173
+ __(
174
+ '<b>Please help us improve %1$s!</b><br>
175
+ If you opt-in, some data about your usage of <b>%1$s</b> will be sent to %2$s.
176
+ If you skip this, that\'s okay! <b>%1$s</b> will still work just fine.',
177
+ 'aryo-activity-log'
178
+ ),
179
+ $this->freemius->get_plugin_name(),
180
+ $freemius_link
181
+ );
182
+ }
183
+
184
+ }
185
+ AAL_Main::instance();
classes/class-aal-activity-log-list-table.php CHANGED
@@ -67,7 +67,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
67
  }
68
 
69
  protected function _get_action_label( $action ) {
70
- return ucwords( str_replace( '_', ' ', __( $action, 'aryo-aal' ) ) );
71
  }
72
 
73
  public function __construct( $args = array() ) {
@@ -101,7 +101,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
101
  'per_page',
102
  array(
103
  'default' => 50,
104
- 'label' => __( 'Activities', 'aryo-aal' ),
105
  'option' => 'edit_aal_logs_per_page',
106
  )
107
  );
@@ -112,13 +112,13 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
112
 
113
  public function get_columns() {
114
  $columns = array(
115
- 'date' => __( 'Date', 'aryo-aal' ),
116
- 'author' => __( 'Author', 'aryo-aal' ),
117
- 'ip' => __( 'IP', 'aryo-aal' ),
118
- 'type' => __( 'Type', 'aryo-aal' ),
119
- 'label' => __( 'Label', 'aryo-aal' ),
120
- 'action' => __( 'Action', 'aryo-aal' ),
121
- 'description' => __( 'Description', 'aryo-aal' ),
122
  );
123
 
124
  return $columns;
@@ -139,7 +139,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
139
  $return = $this->_get_action_label( $item->action );
140
  break;
141
  case 'date' :
142
- $return = sprintf( '<strong>' . __( '%s ago', 'aryo-aal' ) . '</strong>', human_time_diff( $item->hist_time, current_time( 'timestamp' ) ) );
143
  $return .= '<br />' . date( 'd/m/Y', $item->hist_time );
144
  $return .= '<br />' . date( 'H:i', $item->hist_time );
145
  break;
@@ -168,18 +168,18 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
168
  get_edit_user_link( $user->ID ),
169
  get_avatar( $user->ID, 40 ),
170
  $user->display_name,
171
- isset( $user->roles[0] ) && isset( $wp_roles->role_names[ $user->roles[0] ] ) ? $wp_roles->role_names[ $user->roles[0] ] : __( 'Unknown', 'aryo-aal' )
172
  );
173
  }
174
  }
175
  return sprintf(
176
  '<span class="aal-author-name">%s</span>',
177
- __( 'Guest', 'aryo-aal' )
178
  );
179
  }
180
 
181
  public function column_type( $item ) {
182
- $return = __( $item->object_type, 'aryo-aal' );
183
 
184
  $return = apply_filters( 'aal_table_list_column_type', $return, $item );
185
  return $return;
@@ -217,7 +217,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
217
 
218
  case 'Export' :
219
  if ( 'all' === $item->object_name ) {
220
- $return = __( 'All', 'aryo-aal' );
221
  } else {
222
  $pt = get_post_type_object( $item->object_name );
223
  $return = ! empty( $pt->label ) ? $pt->label : $item->object_name;
@@ -226,7 +226,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
226
 
227
  case 'Options' :
228
  case 'Core' :
229
- $return = __( $item->object_name, 'aryo-aal' );
230
  break;
231
  }
232
 
@@ -237,7 +237,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
237
 
238
  public function display_tablenav( $which ) {
239
  if ( 'top' == $which )
240
- $this->search_box( __( 'Search', 'aryo-aal' ), 'aal-search' );
241
  wp_nonce_field( 'bulk-' . $this->_args['plural'] );
242
  ?>
243
  <div class="tablenav <?php echo esc_attr( $which ); ?>">
@@ -275,12 +275,12 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
275
 
276
  $output = array();
277
  foreach ( $this->_get_allow_caps() as $cap ) {
278
- $output[ $cap ] = __( ucwords( $cap ), 'aryo-aal' );
279
  }
280
 
281
  if ( ! empty( $output ) ) {
282
  echo '<select name="capshow" id="hs-filter-capshow">';
283
- printf( '<option value="">%s</option>', __( 'All Roles', 'aryo-aal' ) );
284
  foreach ( $output as $key => $value ) {
285
  printf( '<option value="%s"%s>%s</option>', $key, selected( $_REQUEST['capshow'], $key, false ), $value );
286
  }
@@ -293,7 +293,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
293
  $output = array();
294
  foreach ( $users as $_user ) {
295
  if ( 0 === (int) $_user->user_id ) {
296
- $output[0] = __( 'Guest', 'aryo-aal' );
297
  continue;
298
  }
299
 
@@ -304,7 +304,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
304
 
305
  if ( ! empty( $output ) ) {
306
  echo '<select name="usershow" id="hs-filter-usershow">';
307
- printf( '<option value="">%s</option>', __( 'All Users', 'aryo-aal' ) );
308
  foreach ( $output as $key => $value ) {
309
  printf( '<option value="%s"%s>%s</option>', $key, selected( $_REQUEST['usershow'], $key, false ), $value );
310
  }
@@ -329,10 +329,10 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
329
 
330
  $output = array();
331
  foreach ( $types as $type )
332
- $output[] = sprintf( '<option value="%1$s"%2$s>%3$s</option>', $type->object_type, selected( $_REQUEST['typeshow'], $type->object_type, false ), __( $type->object_type, 'aryo-aal' ) );
333
 
334
  echo '<select name="typeshow" id="hs-filter-typeshow">';
335
- printf( '<option value="">%s</option>', __( 'All Types', 'aryo-aal' ) );
336
  echo implode( '', $output );
337
  echo '</select>';
338
  }
@@ -358,7 +358,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
358
  $output[] = sprintf( '<option value="%s"%s>%s</option>', $type->action, selected( $_REQUEST['showaction'], $type->action, false ), $this->_get_action_label( $type->action ) );
359
 
360
  echo '<select name="showaction" id="hs-filter-showaction">';
361
- printf( '<option value="">%s</option>', __( 'All Actions', 'aryo-aal' ) );
362
  echo implode( '', $output );
363
  echo '</select>';
364
  }
@@ -369,18 +369,18 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
369
  $_REQUEST['dateshow'] = '';
370
 
371
  $date_options = array(
372
- '' => __( 'All Time', 'aryo-aal' ),
373
- 'today' => __( 'Today', 'aryo-aal' ),
374
- 'yesterday' => __( 'Yesterday', 'aryo-aal' ),
375
- 'week' => __( 'Week', 'aryo-aal' ),
376
- 'month' => __( 'Month', 'aryo-aal' ),
377
  );
378
  echo '<select name="dateshow" id="hs-filter-date">';
379
  foreach ( $date_options as $key => $value )
380
  printf( '<option value="%1$s"%2$s>%3$s</option>', $key, selected( $_REQUEST['dateshow'], $key, false ), $value );
381
  echo '</select>';
382
 
383
- submit_button( __( 'Filter', 'aryo-aal' ), 'button', false, false, array( 'id' => 'activity-query-submit' ) );
384
  }
385
 
386
  echo '</div>';
67
  }
68
 
69
  protected function _get_action_label( $action ) {
70
+ return ucwords( str_replace( '_', ' ', __( $action, 'aryo-activity-log' ) ) );
71
  }
72
 
73
  public function __construct( $args = array() ) {
101
  'per_page',
102
  array(
103
  'default' => 50,
104
+ 'label' => __( 'Activities', 'aryo-activity-log' ),
105
  'option' => 'edit_aal_logs_per_page',
106
  )
107
  );
112
 
113
  public function get_columns() {
114
  $columns = array(
115
+ 'date' => __( 'Date', 'aryo-activity-log' ),
116
+ 'author' => __( 'Author', 'aryo-activity-log' ),
117
+ 'ip' => __( 'IP', 'aryo-activity-log' ),
118
+ 'type' => __( 'Type', 'aryo-activity-log' ),
119
+ 'label' => __( 'Label', 'aryo-activity-log' ),
120
+ 'action' => __( 'Action', 'aryo-activity-log' ),
121
+ 'description' => __( 'Description', 'aryo-activity-log' ),
122
  );
123
 
124
  return $columns;
139
  $return = $this->_get_action_label( $item->action );
140
  break;
141
  case 'date' :
142
+ $return = sprintf( '<strong>' . __( '%s ago', 'aryo-activity-log' ) . '</strong>', human_time_diff( $item->hist_time, current_time( 'timestamp' ) ) );
143
  $return .= '<br />' . date( 'd/m/Y', $item->hist_time );
144
  $return .= '<br />' . date( 'H:i', $item->hist_time );
145
  break;
168
  get_edit_user_link( $user->ID ),
169
  get_avatar( $user->ID, 40 ),
170
  $user->display_name,
171
+ isset( $user->roles[0] ) && isset( $wp_roles->role_names[ $user->roles[0] ] ) ? $wp_roles->role_names[ $user->roles[0] ] : __( 'Unknown', 'aryo-activity-log' )
172
  );
173
  }
174
  }
175
  return sprintf(
176
  '<span class="aal-author-name">%s</span>',
177
+ __( 'Guest', 'aryo-activity-log' )
178
  );
179
  }
180
 
181
  public function column_type( $item ) {
182
+ $return = __( $item->object_type, 'aryo-activity-log' );
183
 
184
  $return = apply_filters( 'aal_table_list_column_type', $return, $item );
185
  return $return;
217
 
218
  case 'Export' :
219
  if ( 'all' === $item->object_name ) {
220
+ $return = __( 'All', 'aryo-activity-log' );
221
  } else {
222
  $pt = get_post_type_object( $item->object_name );
223
  $return = ! empty( $pt->label ) ? $pt->label : $item->object_name;
226
 
227
  case 'Options' :
228
  case 'Core' :
229
+ $return = __( $item->object_name, 'aryo-activity-log' );
230
  break;
231
  }
232
 
237
 
238
  public function display_tablenav( $which ) {
239
  if ( 'top' == $which )
240
+ $this->search_box( __( 'Search', 'aryo-activity-log' ), 'aal-search' );
241
  wp_nonce_field( 'bulk-' . $this->_args['plural'] );
242
  ?>
243
  <div class="tablenav <?php echo esc_attr( $which ); ?>">
275
 
276
  $output = array();
277
  foreach ( $this->_get_allow_caps() as $cap ) {
278
+ $output[ $cap ] = __( ucwords( $cap ), 'aryo-activity-log' );
279
  }
280
 
281
  if ( ! empty( $output ) ) {
282
  echo '<select name="capshow" id="hs-filter-capshow">';
283
+ printf( '<option value="">%s</option>', __( 'All Roles', 'aryo-activity-log' ) );
284
  foreach ( $output as $key => $value ) {
285
  printf( '<option value="%s"%s>%s</option>', $key, selected( $_REQUEST['capshow'], $key, false ), $value );
286
  }
293
  $output = array();
294
  foreach ( $users as $_user ) {
295
  if ( 0 === (int) $_user->user_id ) {
296
+ $output[0] = __( 'Guest', 'aryo-activity-log' );
297
  continue;
298
  }
299
 
304
 
305
  if ( ! empty( $output ) ) {
306
  echo '<select name="usershow" id="hs-filter-usershow">';
307
+ printf( '<option value="">%s</option>', __( 'All Users', 'aryo-activity-log' ) );
308
  foreach ( $output as $key => $value ) {
309
  printf( '<option value="%s"%s>%s</option>', $key, selected( $_REQUEST['usershow'], $key, false ), $value );
310
  }
329
 
330
  $output = array();
331
  foreach ( $types as $type )
332
+ $output[] = sprintf( '<option value="%1$s"%2$s>%3$s</option>', $type->object_type, selected( $_REQUEST['typeshow'], $type->object_type, false ), __( $type->object_type, 'aryo-activity-log' ) );
333
 
334
  echo '<select name="typeshow" id="hs-filter-typeshow">';
335
+ printf( '<option value="">%s</option>', __( 'All Types', 'aryo-activity-log' ) );
336
  echo implode( '', $output );
337
  echo '</select>';
338
  }
358
  $output[] = sprintf( '<option value="%s"%s>%s</option>', $type->action, selected( $_REQUEST['showaction'], $type->action, false ), $this->_get_action_label( $type->action ) );
359
 
360
  echo '<select name="showaction" id="hs-filter-showaction">';
361
+ printf( '<option value="">%s</option>', __( 'All Actions', 'aryo-activity-log' ) );
362
  echo implode( '', $output );
363
  echo '</select>';
364
  }
369
  $_REQUEST['dateshow'] = '';
370
 
371
  $date_options = array(
372
+ '' => __( 'All Time', 'aryo-activity-log' ),
373
+ 'today' => __( 'Today', 'aryo-activity-log' ),
374
+ 'yesterday' => __( 'Yesterday', 'aryo-activity-log' ),
375
+ 'week' => __( 'Week', 'aryo-activity-log' ),
376
+ 'month' => __( 'Month', 'aryo-activity-log' ),
377
  );
378
  echo '<select name="dateshow" id="hs-filter-date">';
379
  foreach ( $date_options as $key => $value )
380
  printf( '<option value="%1$s"%2$s>%3$s</option>', $key, selected( $_REQUEST['dateshow'], $key, false ), $value );
381
  echo '</select>';
382
 
383
+ submit_button( __( 'Filter', 'aryo-activity-log' ), 'button', false, false, array( 'id' => 'activity-query-submit' ) );
384
  }
385
 
386
  echo '</div>';
classes/class-aal-admin-ui.php CHANGED
@@ -13,7 +13,7 @@ class AAL_Admin_Ui {
13
  public function create_admin_menu() {
14
  $menu_capability = current_user_can( 'view_all_aryo_activity_log' ) ? 'view_all_aryo_activity_log' : 'edit_pages';
15
 
16
- $this->_screens['main'] = add_menu_page( __( 'Activity Log', 'aryo-aal' ), __( 'Activity Log', 'aryo-aal' ), $menu_capability, 'activity_log_page', array( &$this, 'activity_log_page_func' ), '', '2.1' );
17
 
18
  // Just make sure we are create instance.
19
  add_action( 'load-' . $this->_screens['main'], array( &$this, 'get_list_table' ) );
@@ -23,7 +23,7 @@ class AAL_Admin_Ui {
23
  $this->get_list_table()->prepare_items();
24
  ?>
25
  <div class="wrap">
26
- <h2 class="aal-page-title"><?php _e( 'Activity Log', 'aryo-aal' ); ?></h2>
27
 
28
  <form id="activity-filter" method="get">
29
  <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
13
  public function create_admin_menu() {
14
  $menu_capability = current_user_can( 'view_all_aryo_activity_log' ) ? 'view_all_aryo_activity_log' : 'edit_pages';
15
 
16
+ $this->_screens['main'] = add_menu_page( __( 'Activity Log', 'aryo-activity-log' ), __( 'Activity Log', 'aryo-activity-log' ), $menu_capability, 'activity_log_page', array( &$this, 'activity_log_page_func' ), '', '2.1' );
17
 
18
  // Just make sure we are create instance.
19
  add_action( 'load-' . $this->_screens['main'], array( &$this, 'get_list_table' ) );
23
  $this->get_list_table()->prepare_items();
24
  ?>
25
  <div class="wrap">
26
+ <h2 class="aal-page-title"><?php _e( 'Activity Log', 'aryo-activity-log' ); ?></h2>
27
 
28
  <form id="activity-filter" method="get">
29
  <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
classes/class-aal-help.php CHANGED
@@ -17,12 +17,12 @@ class AAL_Help {
17
  switch ( $screen->id ) {
18
  case 'activity-log_page_activity-log-settings':
19
  $screen->add_help_tab( array(
20
- 'title' => __( 'Overview', 'aryo-aal' ),
21
  'id' => 'aal-overview',
22
  'content' => '
23
- <h3>' . __( 'Notifications', 'aryo-aal' ) . '</h3>
24
  <p>' . __( 'This screen lets you control what will happen once a user on your site does something you define. For instance, let us assume that you have created a user on your site
25
- for your content editor. Now, let\'s say that every time that user updates a post, you want to know about it. You can easily do it from this page.', 'aryo-aal' ) . '</p>',
26
  ) );
27
  break;
28
  }
17
  switch ( $screen->id ) {
18
  case 'activity-log_page_activity-log-settings':
19
  $screen->add_help_tab( array(
20
+ 'title' => __( 'Overview', 'aryo-activity-log' ),
21
  'id' => 'aal-overview',
22
  'content' => '
23
+ <h3>' . __( 'Notifications', 'aryo-activity-log' ) . '</h3>
24
  <p>' . __( 'This screen lets you control what will happen once a user on your site does something you define. For instance, let us assume that you have created a user on your site
25
+ for your content editor. Now, let\'s say that every time that user updates a post, you want to know about it. You can easily do it from this page.', 'aryo-activity-log' ) . '</p>',
26
  ) );
27
  break;
28
  }
classes/class-aal-notifications.php CHANGED
@@ -109,7 +109,7 @@ class AAL_Notifications {
109
 
110
  // make key => value pairs (where slug in key)
111
  foreach ( $opts as $opt ) {
112
- $ready[ $opt ] = ucwords( str_replace( '_', ' ', __( $opt, 'aryo-aal' ) ) );
113
  }
114
 
115
  return $ready;
@@ -287,7 +287,7 @@ class AAL_Notifications {
287
  */
288
  public function register_handler( $classname ) {
289
  if ( ! class_exists( $classname ) ) {
290
- trigger_error( __( 'The AAL notification handler you are trying to register does not exist.', 'aryo-aal' ) );
291
  return false;
292
  }
293
 
109
 
110
  // make key => value pairs (where slug in key)
111
  foreach ( $opts as $opt ) {
112
+ $ready[ $opt ] = ucwords( str_replace( '_', ' ', __( $opt, 'aryo-activity-log' ) ) );
113
  }
114
 
115
  return $ready;
287
  */
288
  public function register_handler( $classname ) {
289
  if ( ! class_exists( $classname ) ) {
290
+ trigger_error( __( 'The AAL notification handler you are trying to register does not exist.', 'aryo-activity-log' ) );
291
  return false;
292
  }
293
 
classes/class-aal-settings.php CHANGED
@@ -23,10 +23,10 @@ class AAL_Settings {
23
  }
24
 
25
  public function plugin_action_links( $links ) {
26
- $settings_link = sprintf( '<a href="%s" target="_blank">%s</a>', 'https://github.com/KingYes/wordpress-aryo-activity-log', __( 'GitHub', 'aryo-aal' ) );
27
  array_unshift( $links, $settings_link );
28
 
29
- $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=activity-log-settings' ), __( 'Settings', 'aryo-aal' ) );
30
  array_unshift( $links, $settings_link );
31
 
32
  return $links;
@@ -40,8 +40,8 @@ class AAL_Settings {
40
  public function action_admin_menu() {
41
  $this->hook = add_submenu_page(
42
  'activity_log_page',
43
- __( 'Activity Log Settings', 'aryo-aal' ), // <title> tag
44
- __( 'Settings', 'aryo-aal' ), // menu label
45
  'manage_options', // required cap to view this page
46
  $this->slug, // page slug
47
  array( &$this, 'display_settings_page' ) // callback
@@ -79,14 +79,14 @@ class AAL_Settings {
79
  // First, we register a section. This is necessary since all future options must belong to a
80
  add_settings_section(
81
  'general_settings_section', // ID used to identify this section and with which to register options
82
- __( 'Display Options', 'aryo-aal' ), // Title to be displayed on the administration page
83
  array( 'AAL_Settings_Fields', 'general_settings_section_header' ), // Callback used to render the description of the section
84
  $this->slug // Page on which to add this section of options
85
  );
86
 
87
  add_settings_field(
88
  'logs_lifespan',
89
- __( 'Keep logs for', 'aryo-aal' ),
90
  array( 'AAL_Settings_Fields', 'number_field' ),
91
  $this->slug,
92
  'general_settings_section',
@@ -95,24 +95,24 @@ class AAL_Settings {
95
  'page' => $this->slug,
96
  'classes' => array( 'small-text' ),
97
  'type' => 'number',
98
- 'sub_desc' => __( 'days.', 'aryo-aal' ),
99
- 'desc' => __( 'Maximum number of days to keep activity log. Leave blank to keep activity log forever (not recommended).', 'aryo-aal' ),
100
  )
101
  );
102
 
103
  if ( apply_filters( 'aal_allow_option_erase_logs', true ) ) {
104
  add_settings_field(
105
  'raw_delete_log_activities',
106
- __( 'Delete Log Activities', 'aryo-aal' ),
107
  array( 'AAL_Settings_Fields', 'raw_html' ),
108
  $this->slug,
109
  'general_settings_section',
110
  array(
111
- 'html' => sprintf( __( '<a href="%s" id="%s">Reset Database</a>', 'aryo-aal' ), add_query_arg( array(
112
  'action' => 'aal_reset_items',
113
  '_nonce' => wp_create_nonce( 'aal_reset_items' ),
114
  ), admin_url( 'admin-ajax.php' ) ), 'aal-delete-log-activities' ),
115
- 'desc' => __( 'Warning: Clicking this will delete all activities from the database.', 'aryo-aal' ),
116
  )
117
  );
118
  }
@@ -122,21 +122,21 @@ class AAL_Settings {
122
  // Email Notifications Settings
123
  add_settings_section(
124
  'email_notifications', // ID used to identify this section and with which to register options
125
- __( 'Notifications', 'aryo-aal' ), // Title to be displayed on the administration page
126
  array( 'AAL_Settings_Fields', 'email_notifications_section_header' ), // Callback used to render the description of the section
127
  $this->slug // Page on which to add this section of options
128
  );
129
 
130
  add_settings_field(
131
  'notification_rules',
132
- __( 'Notification Events', 'aryo-aal' ),
133
  array( 'AAL_Settings_Fields', 'email_notification_buffer_field' ),
134
  $this->slug,
135
  'email_notifications',
136
  array(
137
  'id' => 'notification_rules',
138
  'page' => $this->slug,
139
- 'desc' => __( 'Maximum number of days to keep activity log. Leave blank to keep activity log forever (not recommended).', 'aryo-aal' ),
140
  )
141
  );
142
 
@@ -157,7 +157,7 @@ class AAL_Settings {
157
 
158
  add_settings_field(
159
  "notification_handler_{$handler_id}_enabled",
160
- __( 'Enable?', 'aryo-aal' ),
161
  array( $handler_obj, '_settings_enabled_field_callback' ),
162
  $this->slug,
163
  "notification_$handler_id",
@@ -193,8 +193,8 @@ class AAL_Settings {
193
  private function menu_print_tabs() {
194
  $current_section = $this->get_setup_section();
195
  $sections = array(
196
- 'general' => __( 'General', 'aryo-aal' ),
197
- 'notifications' => __( 'Notifications', 'aryo-aal' ),
198
  );
199
 
200
  $sections = apply_filters( 'aal_setup_sections', $sections );
@@ -224,7 +224,7 @@ class AAL_Settings {
224
  <div class="wrap">
225
 
226
  <div id="icon-themes" class="icon32"></div>
227
- <h2 class="aal-page-title"><?php _e( 'Activity Log Settings', 'aryo-aal' ); ?></h2>
228
  <?php settings_errors(); ?>
229
  <h2 class="nav-tab-wrapper"><?php $this->menu_print_tabs(); ?></h2>
230
 
@@ -243,7 +243,7 @@ class AAL_Settings {
243
  public function admin_notices() {
244
  switch ( filter_input( INPUT_GET, 'message' ) ) {
245
  case 'data_erased':
246
- printf( '<div class="updated"><p>%s</p></div>', __( 'All activities have been successfully deleted.', 'aryo-aal' ) );
247
  break;
248
  }
249
  }
@@ -254,7 +254,7 @@ class AAL_Settings {
254
  <script type="text/javascript">
255
  jQuery( document ).ready( function( $ ) {
256
  $( '#aal-delete-log-activities' ).on( 'click', function( e ) {
257
- if ( ! confirm( '<?php echo __( 'Are you sure you want to do this action?', 'aryo-aal' ); ?>' ) ) {
258
  e.preventDefault();
259
  }
260
  } );
@@ -265,7 +265,7 @@ class AAL_Settings {
265
 
266
  public function ajax_aal_reset_items() {
267
  if ( ! check_ajax_referer( 'aal_reset_items', '_nonce', false ) || ! current_user_can( 'manage_options' ) ) {
268
- wp_die( __( 'You do not have sufficient permissions to access this page.', 'aryo-aal' ) );
269
  }
270
 
271
  AAL_Main::instance()->api->erase_all_items();
@@ -318,13 +318,13 @@ final class AAL_Settings_Fields {
318
 
319
  public static function general_settings_section_header() {
320
  ?>
321
- <p><?php _e( 'These are some basic settings for Activity Log.', 'aryo-aal' ); ?></p>
322
  <?php
323
  }
324
 
325
  public static function email_notifications_section_header() {
326
  ?>
327
- <p><?php _e( 'Serve yourself with custom-tailored notifications. First, define your conditions. Then, choose how the notifications will be sent.', 'aryo-aal' ); ?></p>
328
  <?php
329
  }
330
 
@@ -423,8 +423,8 @@ final class AAL_Settings_Fields {
423
  extract( $args, EXTR_SKIP );
424
 
425
  ?>
426
- <label class="tix-yes-no description"><input type="radio" name="<?php echo esc_attr( $name ); ?>" value="1" <?php checked( $value, true ); ?>> <?php _e( 'Yes', 'aryo-aal' ); ?></label>
427
- <label class="tix-yes-no description"><input type="radio" name="<?php echo esc_attr( $name ); ?>" value="0" <?php checked( $value, false ); ?>> <?php _e( 'No', 'aryo-aal' ); ?></label>
428
 
429
  <?php if ( isset( $args['description'] ) ) : ?>
430
  <p class="description"><?php echo $args['description']; ?></p>
@@ -441,14 +441,14 @@ final class AAL_Settings_Fields {
441
 
442
  // available action categories
443
  $keys = array(
444
- 'user' => __( 'User', 'aryo-aal' ),
445
- 'action-type' => __( 'Action Type', 'aryo-aal' ),
446
- 'action-value' => __( 'Action Performed', 'aryo-aal' ),
447
  );
448
  // available condition types
449
  $conditions = array(
450
- 'equals' => __( 'equals to', 'aryo-aal' ),
451
- 'not_equals' => __( 'not equals to', 'aryo-aal' ),
452
  );
453
 
454
  $common_name = sprintf( '%s[%s]', esc_attr( $args['page'] ), esc_attr( $args['id'] ) );
@@ -458,7 +458,7 @@ final class AAL_Settings_Fields {
458
  // if empty, reset to one element with the key of 1
459
  $rows = empty( $rows ) ? array( array( 'key' => 1 ) ) : $rows;
460
  ?>
461
- <p class="description"><?php _e( 'A notification will be sent upon a successful match with the following conditions:', 'aryo-aal' ); ?></p>
462
  <div class="aal-notifier-settings">
463
  <ul>
464
  <?php foreach ( $rows as $rid => $row ) :
23
  }
24
 
25
  public function plugin_action_links( $links ) {
26
+ $settings_link = sprintf( '<a href="%s" target="_blank">%s</a>', 'https://github.com/KingYes/wordpress-aryo-activity-log', __( 'GitHub', 'aryo-activity-log' ) );
27
  array_unshift( $links, $settings_link );
28
 
29
+ $settings_link = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=activity-log-settings' ), __( 'Settings', 'aryo-activity-log' ) );
30
  array_unshift( $links, $settings_link );
31
 
32
  return $links;
40
  public function action_admin_menu() {
41
  $this->hook = add_submenu_page(
42
  'activity_log_page',
43
+ __( 'Activity Log Settings', 'aryo-activity-log' ), // <title> tag
44
+ __( 'Settings', 'aryo-activity-log' ), // menu label
45
  'manage_options', // required cap to view this page
46
  $this->slug, // page slug
47
  array( &$this, 'display_settings_page' ) // callback
79
  // First, we register a section. This is necessary since all future options must belong to a
80
  add_settings_section(
81
  'general_settings_section', // ID used to identify this section and with which to register options
82
+ __( 'Display Options', 'aryo-activity-log' ), // Title to be displayed on the administration page
83
  array( 'AAL_Settings_Fields', 'general_settings_section_header' ), // Callback used to render the description of the section
84
  $this->slug // Page on which to add this section of options
85
  );
86
 
87
  add_settings_field(
88
  'logs_lifespan',
89
+ __( 'Keep logs for', 'aryo-activity-log' ),
90
  array( 'AAL_Settings_Fields', 'number_field' ),
91
  $this->slug,
92
  'general_settings_section',
95
  'page' => $this->slug,
96
  'classes' => array( 'small-text' ),
97
  'type' => 'number',
98
+ 'sub_desc' => __( 'days.', 'aryo-activity-log' ),
99
+ 'desc' => __( 'Maximum number of days to keep activity log. Leave blank to keep activity log forever (not recommended).', 'aryo-activity-log' ),
100
  )
101
  );
102
 
103
  if ( apply_filters( 'aal_allow_option_erase_logs', true ) ) {
104
  add_settings_field(
105
  'raw_delete_log_activities',
106
+ __( 'Delete Log Activities', 'aryo-activity-log' ),
107
  array( 'AAL_Settings_Fields', 'raw_html' ),
108
  $this->slug,
109
  'general_settings_section',
110
  array(
111
+ 'html' => sprintf( __( '<a href="%s" id="%s">Reset Database</a>', 'aryo-activity-log' ), add_query_arg( array(
112
  'action' => 'aal_reset_items',
113
  '_nonce' => wp_create_nonce( 'aal_reset_items' ),
114
  ), admin_url( 'admin-ajax.php' ) ), 'aal-delete-log-activities' ),
115
+ 'desc' => __( 'Warning: Clicking this will delete all activities from the database.', 'aryo-activity-log' ),
116
  )
117
  );
118
  }
122
  // Email Notifications Settings
123
  add_settings_section(
124
  'email_notifications', // ID used to identify this section and with which to register options
125
+ __( 'Notifications', 'aryo-activity-log' ), // Title to be displayed on the administration page
126
  array( 'AAL_Settings_Fields', 'email_notifications_section_header' ), // Callback used to render the description of the section
127
  $this->slug // Page on which to add this section of options
128
  );
129
 
130
  add_settings_field(
131
  'notification_rules',
132
+ __( 'Notification Events', 'aryo-activity-log' ),
133
  array( 'AAL_Settings_Fields', 'email_notification_buffer_field' ),
134
  $this->slug,
135
  'email_notifications',
136
  array(
137
  'id' => 'notification_rules',
138
  'page' => $this->slug,
139
+ 'desc' => __( 'Maximum number of days to keep activity log. Leave blank to keep activity log forever (not recommended).', 'aryo-activity-log' ),
140
  )
141
  );
142
 
157
 
158
  add_settings_field(
159
  "notification_handler_{$handler_id}_enabled",
160
+ __( 'Enable?', 'aryo-activity-log' ),
161
  array( $handler_obj, '_settings_enabled_field_callback' ),
162
  $this->slug,
163
  "notification_$handler_id",
193
  private function menu_print_tabs() {
194
  $current_section = $this->get_setup_section();
195
  $sections = array(
196
+ 'general' => __( 'General', 'aryo-activity-log' ),
197
+ 'notifications' => __( 'Notifications', 'aryo-activity-log' ),
198
  );
199
 
200
  $sections = apply_filters( 'aal_setup_sections', $sections );
224
  <div class="wrap">
225
 
226
  <div id="icon-themes" class="icon32"></div>
227
+ <h2 class="aal-page-title"><?php _e( 'Activity Log Settings', 'aryo-activity-log' ); ?></h2>
228
  <?php settings_errors(); ?>
229
  <h2 class="nav-tab-wrapper"><?php $this->menu_print_tabs(); ?></h2>
230
 
243
  public function admin_notices() {
244
  switch ( filter_input( INPUT_GET, 'message' ) ) {
245
  case 'data_erased':
246
+ printf( '<div class="updated"><p>%s</p></div>', __( 'All activities have been successfully deleted.', 'aryo-activity-log' ) );
247
  break;
248
  }
249
  }
254
  <script type="text/javascript">
255
  jQuery( document ).ready( function( $ ) {
256
  $( '#aal-delete-log-activities' ).on( 'click', function( e ) {
257
+ if ( ! confirm( '<?php echo __( 'Are you sure you want to do this action?', 'aryo-activity-log' ); ?>' ) ) {
258
  e.preventDefault();
259
  }
260
  } );
265
 
266
  public function ajax_aal_reset_items() {
267
  if ( ! check_ajax_referer( 'aal_reset_items', '_nonce', false ) || ! current_user_can( 'manage_options' ) ) {
268
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'aryo-activity-log' ) );
269
  }
270
 
271
  AAL_Main::instance()->api->erase_all_items();
318
 
319
  public static function general_settings_section_header() {
320
  ?>
321
+ <p><?php _e( 'These are some basic settings for Activity Log.', 'aryo-activity-log' ); ?></p>
322
  <?php
323
  }
324
 
325
  public static function email_notifications_section_header() {
326
  ?>
327
+ <p><?php _e( 'Serve yourself with custom-tailored notifications. First, define your conditions. Then, choose how the notifications will be sent.', 'aryo-activity-log' ); ?></p>
328
  <?php
329
  }
330
 
423
  extract( $args, EXTR_SKIP );
424
 
425
  ?>
426
+ <label class="tix-yes-no description"><input type="radio" name="<?php echo esc_attr( $name ); ?>" value="1" <?php checked( $value, true ); ?>> <?php _e( 'Yes', 'aryo-activity-log' ); ?></label>
427
+ <label class="tix-yes-no description"><input type="radio" name="<?php echo esc_attr( $name ); ?>" value="0" <?php checked( $value, false ); ?>> <?php _e( 'No', 'aryo-activity-log' ); ?></label>
428
 
429
  <?php if ( isset( $args['description'] ) ) : ?>
430
  <p class="description"><?php echo $args['description']; ?></p>
441
 
442
  // available action categories
443
  $keys = array(
444
+ 'user' => __( 'User', 'aryo-activity-log' ),
445
+ 'action-type' => __( 'Action Type', 'aryo-activity-log' ),
446
+ 'action-value' => __( 'Action Performed', 'aryo-activity-log' ),
447
  );
448
  // available condition types
449
  $conditions = array(
450
+ 'equals' => __( 'equals to', 'aryo-activity-log' ),
451
+ 'not_equals' => __( 'not equals to', 'aryo-activity-log' ),
452
  );
453
 
454
  $common_name = sprintf( '%s[%s]', esc_attr( $args['page'] ), esc_attr( $args['id'] ) );
458
  // if empty, reset to one element with the key of 1
459
  $rows = empty( $rows ) ? array( array( 'key' => 1 ) ) : $rows;
460
  ?>
461
+ <p class="description"><?php _e( 'A notification will be sent upon a successful match with the following conditions:', 'aryo-activity-log' ); ?></p>
462
  <div class="aal-notifier-settings">
463
  <ul>
464
  <?php foreach ( $rows as $rid => $row ) :
classes/freemius/LICENSE.txt ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
340
+
classes/freemius/assets/css/admin/account.css ADDED
@@ -0,0 +1 @@
 
1
+ #fs_account .postbox,#fs_account .widefat{max-width:700px}#fs_account .fs-header-actions{position:absolute;top:10px;right:10px;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}.rtl #fs_account .fs-header-actions{left:10px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table td label{background:orange;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}.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 var,.fs-key-value-table code{color:#0073AA;font-size:16px;background:none}#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}
classes/freemius/assets/css/admin/add-ons.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ #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 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;-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-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}@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:772px !important}#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-left:30px}#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{background:#FFFEEC;margin:-16px;padding:20px 20px 50px 20px;border-bottom:1px solid #DDD}#plugin-information .plugin-information-pricing h3{margin-top:0}#plugin-information .plugin-information-pricing .button{width:100%;text-align:center;font-weight:bold;text-transform:uppercase;font-size:1.1em}#plugin-information .plugin-information-pricing label{white-space:nowrap}#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}@media screen and (max-width: 961px){#fs_addons .fs-cards-list .fs-card{height:265px}}
classes/freemius/assets/css/admin/common.css ADDED
@@ -0,0 +1 @@
 
1
+ .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-close{position:absolute;top:10px;right:10px;cursor:pointer;color:#ccc}.fs-notice .fs-close:hover{color:#aaa}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;bottom:-22px;top: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}.rtl .fs-notice .fs-close{left:10px;right:auto}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;box-shadow:0px 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)}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@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'}
classes/freemius/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 p{margin:0;padding:0;font-size:1.2em}#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-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-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 div{margin-left:55px}#fs_connect .fs-permissions ul li div span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li div 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-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}.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-secondary{float:left}.rtl #fs_connect .fs-permissions ul li div{margin-right:55px;margin-left:0}.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}.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}
classes/freemius/assets/css/admin/deactivation-feedback.css ADDED
@@ -0,0 +1 @@
 
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 .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 .fs-modal-dialog li.reason{margin-bottom:10px}.fs-modal .fs-modal-dialog li.reason .reason-input{margin-left:29px}.fs-modal .fs-modal-dialog li.reason label{display:table}.fs-modal .fs-modal-dialog li.reason label>span{display:table-cell;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-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body h2{font-size:20px}.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:not(.active){display:none}.fs-modal .reason-input{margin:3px 0 3px 22px}.fs-modal .reason-input input,.fs-modal .reason-input textarea{width:100%}body.has-fs-modal{overflow:hidden}#the-list .deactivate>.fs-slug{display:none}
classes/freemius/assets/css/common.css ADDED
@@ -0,0 +1 @@
 
1
+ .fs-notice.success{color:green;font-weight:700}
classes/freemius/assets/img/icon.svg ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="256px"
5
+ height="256px" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
6
+ <g id="Layer_2">
7
+ <rect fill="#C91E60" width="256" height="256"/>
8
+ </g>
9
+ <g id="Layer_5">
10
+ <text transform="matrix(1 0 0 1 64.1411 78.187)"><tspan x="0" y="0" fill="#FFFFFF" font-family="'Helvetica-Light'" font-size="39.6274">Activity</tspan><tspan x="29.72" y="47.553" fill="#FFFFFF" font-family="'Helvetica-Light'" font-size="39.6274">Log</tspan></text>
11
+ </g>
12
+ <g id="Layer_4">
13
+ <g>
14
+ <path fill="none" d="M153.006,225.923c-13.807,0-25-11.193-25-25s11.193-25,25-25H256V0H0v256h256v-30.077H153.006z"/>
15
+ <path fill="#FFFFFF" d="M128.006,200.923c0,13.807,11.193,25,25,25H256v-50H153.006
16
+ C139.199,175.923,128.006,187.116,128.006,200.923z"/>
17
+ </g>
18
+ </g>
19
+ <g id="Layer_6">
20
+ <g>
21
+ <path fill="#C91E60" d="M166.129,200.071c0,1.251-0.235,2.424-0.707,3.52c-0.472,1.099-1.121,2.059-1.946,2.885
22
+ c-0.826,0.825-1.786,1.473-2.883,1.945c-1.098,0.471-2.27,0.707-3.521,0.707c-1.085,0-2.104-0.178-3.06-0.53
23
+ c-0.956-0.354-1.821-0.837-2.601-1.45v7.075c0,0.472-0.165,0.871-0.495,1.202c-0.33,0.33-0.73,0.496-1.202,0.496
24
+ c-0.473,0-0.873-0.166-1.203-0.496c-0.331-0.331-0.493-0.73-0.493-1.202v-14.151c0-1.251,0.234-2.424,0.705-3.52
25
+ c0.472-1.097,1.118-2.058,1.946-2.884c0.826-0.826,1.786-1.474,2.884-1.946c1.096-0.471,2.269-0.706,3.519-0.706
26
+ c1.251,0,2.423,0.235,3.521,0.706c1.097,0.473,2.057,1.12,2.883,1.946c0.825,0.826,1.475,1.787,1.946,2.884
27
+ C165.894,197.647,166.129,198.82,166.129,200.071 M162.733,200.071c0-0.779-0.148-1.51-0.442-2.192
28
+ c-0.297-0.685-0.702-1.286-1.221-1.805c-0.519-0.52-1.12-0.926-1.805-1.22c-0.685-0.296-1.416-0.443-2.193-0.443
29
+ c-0.778,0-1.509,0.147-2.193,0.443c-0.685,0.294-1.285,0.7-1.805,1.22c-0.519,0.519-0.926,1.12-1.22,1.805
30
+ c-0.295,0.683-0.442,1.413-0.442,2.192c0,0.778,0.147,1.51,0.442,2.193c0.294,0.684,0.701,1.286,1.22,1.805
31
+ c0.52,0.519,1.12,0.926,1.805,1.22c0.685,0.298,1.415,0.442,2.193,0.442c0.777,0,1.509-0.145,2.193-0.442
32
+ c0.685-0.294,1.286-0.701,1.805-1.22s0.924-1.121,1.221-1.805C162.585,201.581,162.733,200.85,162.733,200.071"/>
33
+ <path fill="#C91E60" d="M167.827,200.071c0-1.251,0.236-2.424,0.707-3.52c0.472-1.097,1.121-2.058,1.947-2.884
34
+ c0.824-0.826,1.785-1.474,2.882-1.946c1.098-0.471,2.271-0.706,3.521-0.706c1.249,0,2.424,0.235,3.519,0.706
35
+ c1.097,0.473,2.058,1.12,2.884,1.946c0.825,0.826,1.474,1.787,1.946,2.884c0.471,1.096,0.707,2.269,0.707,3.52
36
+ s-0.236,2.424-0.707,3.52c-0.473,1.099-1.121,2.059-1.946,2.885c-0.826,0.825-1.787,1.473-2.884,1.945
37
+ c-1.095,0.471-2.27,0.707-3.519,0.707c-1.251,0-2.424-0.236-3.521-0.707c-1.097-0.473-2.058-1.12-2.882-1.945
38
+ c-0.826-0.826-1.476-1.786-1.947-2.885C168.063,202.495,167.827,201.322,167.827,200.071 M171.224,200.071
39
+ c0,0.778,0.146,1.51,0.441,2.193c0.297,0.684,0.702,1.286,1.221,1.805s1.121,0.926,1.805,1.22
40
+ c0.684,0.298,1.415,0.442,2.194,0.442c0.776,0,1.508-0.145,2.191-0.442c0.686-0.294,1.286-0.701,1.806-1.22
41
+ c0.518-0.519,0.925-1.121,1.22-1.805c0.296-0.684,0.443-1.415,0.443-2.193c0-0.779-0.147-1.51-0.443-2.192
42
+ c-0.295-0.685-0.702-1.286-1.22-1.805c-0.52-0.52-1.12-0.926-1.806-1.22c-0.684-0.296-1.415-0.443-2.191-0.443
43
+ c-0.779,0-1.511,0.147-2.194,0.443c-0.684,0.294-1.286,0.7-1.805,1.22c-0.519,0.519-0.924,1.12-1.221,1.805
44
+ C171.37,198.562,171.224,199.292,171.224,200.071"/>
45
+ <path fill="#C91E60" d="M185.092,215.921c-0.472,0-0.873-0.166-1.204-0.496c-0.328-0.331-0.494-0.73-0.494-1.202
46
+ s0.166-0.873,0.494-1.203c0.331-0.331,0.732-0.495,1.204-0.495c0.944,0,1.746-0.33,2.405-0.99c0.66-0.662,0.991-1.463,0.991-2.406
47
+ v-16.415c0-0.471,0.164-0.871,0.496-1.202c0.327-0.33,0.729-0.495,1.201-0.495s0.875,0.165,1.204,0.495
48
+ c0.33,0.331,0.494,0.731,0.494,1.202v16.415c0,0.943-0.177,1.827-0.529,2.653c-0.354,0.825-0.838,1.545-1.452,2.157
49
+ c-0.613,0.613-1.332,1.099-2.157,1.451C186.919,215.743,186.036,215.921,185.092,215.921 M188.205,187.901
50
+ c0-0.542,0.195-1.008,0.583-1.396c0.389-0.39,0.854-0.584,1.397-0.584s1.008,0.194,1.397,0.584
51
+ c0.388,0.389,0.584,0.854,0.584,1.396c0,0.543-0.196,1.01-0.584,1.398c-0.39,0.388-0.854,0.583-1.397,0.583
52
+ s-1.009-0.195-1.397-0.583C188.4,188.911,188.205,188.444,188.205,187.901"/>
53
+ <path fill="#C91E60" d="M194.431,200.071c0-1.251,0.235-2.424,0.707-3.52c0.473-1.097,1.119-2.058,1.947-2.884
54
+ c0.824-0.826,1.783-1.474,2.883-1.946c1.097-0.471,2.27-0.706,3.519-0.706c1.25,0,2.425,0.235,3.522,0.706
55
+ c1.096,0.473,2.056,1.12,2.883,1.946c0.825,0.826,1.473,1.787,1.944,2.884c0.472,1.096,0.708,2.269,0.708,3.52
56
+ s-0.236,2.424-0.708,3.52c-0.472,1.099-1.119,2.059-1.944,2.885c-0.827,0.825-1.787,1.473-2.883,1.945
57
+ c-1.098,0.471-2.272,0.707-3.522,0.707c-1.249,0-2.422-0.236-3.519-0.707c-1.1-0.473-2.059-1.12-2.883-1.945
58
+ c-0.828-0.826-1.475-1.786-1.947-2.885C194.666,202.495,194.431,201.322,194.431,200.071 M197.827,200.071
59
+ c0,0.778,0.146,1.51,0.442,2.193c0.295,0.684,0.701,1.286,1.22,1.805c0.52,0.519,1.12,0.926,1.805,1.22
60
+ c0.684,0.298,1.415,0.442,2.192,0.442c0.779,0,1.511-0.145,2.194-0.442c0.684-0.294,1.284-0.701,1.803-1.22
61
+ s0.926-1.121,1.224-1.805c0.294-0.684,0.439-1.415,0.439-2.193c0-0.779-0.146-1.51-0.439-2.192
62
+ c-0.298-0.685-0.705-1.286-1.224-1.805c-0.519-0.52-1.119-0.926-1.803-1.22c-0.684-0.296-1.415-0.443-2.194-0.443
63
+ c-0.777,0-1.509,0.147-2.192,0.443c-0.685,0.294-1.285,0.7-1.805,1.22c-0.519,0.519-0.925,1.12-1.22,1.805
64
+ C197.974,198.562,197.827,199.292,197.827,200.071"/>
65
+ <path fill="#353E44" d="M213.941,207.714c0.389,0,0.706,0.317,0.706,0.707s-0.317,0.707-0.706,0.707
66
+ c-0.39,0-0.709-0.317-0.709-0.707S213.552,207.714,213.941,207.714"/>
67
+ <path fill="#353E44" d="M223.845,208.562c0,0.318-0.246,0.565-0.564,0.565c-0.319,0-0.568-0.247-0.568-0.565v-4.528
68
+ c0-1.556-1.272-2.83-2.828-2.83c-1.559,0-2.83,1.274-2.83,2.83v4.528c0,0.318-0.247,0.565-0.565,0.565
69
+ c-0.319,0-0.566-0.247-0.566-0.565v-4.528c0-2.192,1.77-3.962,3.962-3.962c1.433,0,2.705,0.778,3.396,1.929
70
+ c0.688-1.15,1.944-1.929,3.396-1.929c2.192,0,3.963,1.77,3.963,3.962v4.528c0,0.318-0.25,0.565-0.567,0.565
71
+ c-0.318,0-0.565-0.247-0.565-0.565v-4.528c0-1.556-1.274-2.83-2.83-2.83c-1.558,0-2.831,1.274-2.831,2.83V208.562z"/>
72
+ <path fill="#353E44" d="M236.441,209.128c-2.494,0-4.528-2.034-4.528-4.527s2.034-4.528,4.528-4.528
73
+ c2.492,0,4.525,2.035,4.525,4.528c0,0.318-0.248,0.565-0.563,0.565h-7.325c0.285,1.609,1.682,2.83,3.363,2.83h1.131
74
+ c0.317,0,0.567,0.248,0.567,0.566s-0.25,0.565-0.567,0.565H236.441z M233.078,204.034h6.705c-0.266-1.592-1.663-2.83-3.342-2.83
75
+ C234.76,201.204,233.363,202.442,233.078,204.034"/>
76
+ </g>
77
+ </g>
78
+ </svg>
classes/freemius/assets/img/plugin-icon.png ADDED
Binary file
classes/freemius/assets/js/jquery.ba-postmessage.js ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
10
+ // Script: jQuery postMessage: Cross-domain scripting goodness
11
+ //
12
+ // *Version: 0.5, Last updated: 9/11/2009*
13
+ //
14
+ // Project Home - http://benalman.com/projects/jquery-postmessage-plugin/
15
+ // GitHub - http://github.com/cowboy/jquery-postmessage/
16
+ // Source - http://github.com/cowboy/jquery-postmessage/raw/master/jquery.ba-postmessage.js
17
+ // (Minified) - http://github.com/cowboy/jquery-postmessage/raw/master/jquery.ba-postmessage.min.js (0.9kb)
18
+ //
19
+ // About: License
20
+ //
21
+ // Copyright (c) 2009 "Cowboy" Ben Alman,
22
+ // Dual licensed under the MIT and GPL licenses.
23
+ // http://benalman.com/about/license/
24
+ //
25
+ // About: Examples
26
+ //
27
+ // This working example, complete with fully commented code, illustrates one
28
+ // way in which this plugin can be used.
29
+ //
30
+ // Iframe resizing - http://benalman.com/code/projects/jquery-postmessage/examples/iframe/
31
+ //
32
+ // About: Support and Testing
33
+ //
34
+ // Information about what version or versions of jQuery this plugin has been
35
+ // tested with and what browsers it has been tested in.
36
+ //
37
+ // jQuery Versions - 1.3.2
38
+ // Browsers Tested - Internet Explorer 6-8, Firefox 3, Safari 3-4, Chrome, Opera 9.
39
+ //
40
+ // About: Release History
41
+ //
42
+ // 0.5 - (9/11/2009) Improved cache-busting
43
+ // 0.4 - (8/25/2009) Initial release
44
+
45
+ (function($){
46
+ '$:nomunge'; // Used by YUI compressor.
47
+
48
+ // A few vars used in non-awesome browsers.
49
+ var interval_id,
50
+ last_hash,
51
+ cache_bust = 1,
52
+
53
+ // A var used in awesome browsers.
54
+ rm_callback,
55
+
56
+ // A few convenient shortcuts.
57
+ window = this,
58
+ FALSE = !1,
59
+
60
+ // Reused internal strings.
61
+ postMessage = 'postMessage',
62
+ addEventListener = 'addEventListener',
63
+
64
+ p_receiveMessage,
65
+
66
+ // I couldn't get window.postMessage to actually work in Opera 9.64!
67
+ has_postMessage = window[postMessage] && !$.browser.opera;
68
+
69
+ // Method: jQuery.postMessage
70
+ //
71
+ // This method will call window.postMessage if available, setting the
72
+ // targetOrigin parameter to the base of the target_url parameter for maximum
73
+ // security in browsers that support it. If window.postMessage is not available,
74
+ // the target window's location.hash will be used to pass the message. If an
75
+ // object is passed as the message param, it will be serialized into a string
76
+ // using the jQuery.param method.
77
+ //
78
+ // Usage:
79
+ //
80
+ // > jQuery.postMessage( message, target_url [, target ] );
81
+ //
82
+ // Arguments:
83
+ //
84
+ // message - (String) A message to be passed to the other frame.
85
+ // message - (Object) An object to be serialized into a params string, using
86
+ // the jQuery.param method.
87
+ // target_url - (String) The URL of the other frame this window is
88
+ // attempting to communicate with. This must be the exact URL (including
89
+ // any query string) of the other window for this script to work in
90
+ // browsers that don't support window.postMessage.
91
+ // target - (Object) A reference to the other frame this window is
92
+ // attempting to communicate with. If omitted, defaults to `parent`.
93
+ //
94
+ // Returns:
95
+ //
96
+ // Nothing.
97
+
98
+ $[postMessage] = function( message, target_url, target ) {
99
+ if ( !target_url ) { return; }
100
+
101
+ // Serialize the message if not a string. Note that this is the only real
102
+ // jQuery dependency for this script. If removed, this script could be
103
+ // written as very basic JavaScript.
104
+ message = typeof message === 'string' ? message : $.param( message );
105
+
106
+ // Default to parent if unspecified.
107
+ target = target || parent;
108
+
109
+ if ( has_postMessage ) {
110
+ // The browser supports window.postMessage, so call it with a targetOrigin
111
+ // set appropriately, based on the target_url parameter.
112
+ target[postMessage]( message, target_url.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
113
+
114
+ } else if ( target_url ) {
115
+ // The browser does not support window.postMessage, so set the location
116
+ // of the target to target_url#message. A bit ugly, but it works! A cache
117
+ // bust parameter is added to ensure that repeat messages trigger the
118
+ // callback.
119
+ target.location = target_url.replace( /#.*$/, '' ) + '#' + (+new Date) + (cache_bust++) + '&' + message;
120
+ }
121
+ };
122
+
123
+ // Method: jQuery.receiveMessage
124
+ //
125
+ // Register a single callback for either a window.postMessage call, if
126
+ // supported, or if unsupported, for any change in the current window
127
+ // location.hash. If window.postMessage is supported and source_origin is
128
+ // specified, the source window will be checked against this for maximum
129
+ // security. If window.postMessage is unsupported, a polling loop will be
130
+ // started to watch for changes to the location.hash.
131
+ //
132
+ // Note that for simplicity's sake, only a single callback can be registered
133
+ // at one time. Passing no params will unbind this event (or stop the polling
134
+ // loop), and calling this method a second time with another callback will
135
+ // unbind the event (or stop the polling loop) first, before binding the new
136
+ // callback.
137
+ //
138
+ // Also note that if window.postMessage is available, the optional
139
+ // source_origin param will be used to test the event.origin property. From
140
+ // the MDC window.postMessage docs: This string is the concatenation of the
141
+ // protocol and "://", the host name if one exists, and ":" followed by a port
142
+ // number if a port is present and differs from the default port for the given
143
+ // protocol. Examples of typical origins are https://example.org (implying
144
+ // port 443), http://example.net (implying port 80), and http://example.com:8080.
145
+ //
146
+ // Usage:
147
+ //
148
+ // > jQuery.receiveMessage( callback [, source_origin ] [, delay ] );
149
+ //
150
+ // Arguments:
151
+ //
152
+ // callback - (Function) This callback will execute whenever a <jQuery.postMessage>
153
+ // message is received, provided the source_origin matches. If callback is
154
+ // omitted, any existing receiveMessage event bind or polling loop will be
155
+ // canceled.
156
+ // source_origin - (String) If window.postMessage is available and this value
157
+ // is not equal to the event.origin property, the callback will not be
158
+ // called.
159
+ // source_origin - (Function) If window.postMessage is available and this
160
+ // function returns false when passed the event.origin property, the
161
+ // callback will not be called.
162
+ // delay - (Number) An optional zero-or-greater delay in milliseconds at
163
+ // which the polling loop will execute (for browser that don't support
164
+ // window.postMessage). If omitted, defaults to 100.
165
+ //
166
+ // Returns:
167
+ //
168
+ // Nothing!
169
+
170
+ $.receiveMessage = p_receiveMessage = function( callback, source_origin, delay ) {
171
+ if ( has_postMessage ) {
172
+ // Since the browser supports window.postMessage, the callback will be
173
+ // bound to the actual event associated with window.postMessage.
174
+
175
+ if ( callback ) {
176
+ // Unbind an existing callback if it exists.
177
+ rm_callback && p_receiveMessage();
178
+
179
+ // Bind the callback. A reference to the callback is stored for ease of
180
+ // unbinding.
181
+ rm_callback = function(e) {
182
+ if ( ( typeof source_origin === 'string' && e.origin !== source_origin )
183
+ || ( $.isFunction( source_origin ) && source_origin( e.origin ) === FALSE ) ) {
184
+ return FALSE;
185
+ }
186
+ callback( e );
187
+ };
188
+ }
189
+
190
+ if ( window[addEventListener] ) {
191
+ window[ callback ? addEventListener : 'removeEventListener' ]( 'message', rm_callback, FALSE );
192
+ } else {
193
+ window[ callback ? 'attachEvent' : 'detachEvent' ]( 'onmessage', rm_callback );
194
+ }
195
+
196
+ } else {
197
+ // Since the browser sucks, a polling loop will be started, and the
198
+ // callback will be called whenever the location.hash changes.
199
+
200
+ interval_id && clearInterval( interval_id );
201
+ interval_id = null;
202
+
203
+ if ( callback ) {
204
+ delay = typeof source_origin === 'number'
205
+ ? source_origin
206
+ : typeof delay === 'number'
207
+ ? delay
208
+ : 100;
209
+
210
+ interval_id = setInterval(function(){
211
+ var hash = document.location.hash,
212
+ re = /^#?\d+&/;
213
+ if ( hash !== last_hash && re.test( hash ) ) {
214
+ last_hash = hash;
215
+ callback({ data: hash.replace( re, '' ) });
216
+ }
217
+ }, delay );
218
+ }
219
+ }
220
+ };
221
+
222
+ })(jQuery);
classes/freemius/assets/js/jquery.ba-postmessage.min.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
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
+ (function($){var g,d,j=1,a,b=this,f=!1,h="postMessage",e="addEventListener",c,i=b[h]&&!$.browser.opera;$[h]=function(k,l,m){if(!l){return}k=typeof k==="string"?k:$.param(k);m=m||parent;if(i){m[h](k,l.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))}else{if(l){m.location=l.replace(/#.*$/,"")+"#"+(+new Date)+(j++)+"&"+k}}};$.receiveMessage=c=function(l,m,k){if(i){if(l){a&&c();a=function(n){if((typeof m==="string"&&n.origin!==m)||($.isFunction(m)&&m(n.origin)===f)){return f}l(n)}}if(b[e]){b[l?e:"removeEventListener"]("message",a,f)}else{b[l?"attachEvent":"detachEvent"]("onmessage",a)}}else{g&&clearInterval(g);g=null;if(l){k=typeof m==="number"?m:typeof k==="number"?k:100;g=setInterval(function(){var o=document.location.hash,n=/^#?\d+&/;if(o!==d&&n.test(o)){d=o;l({data:o.replace(n,"")})}},k)}}}})(jQuery);
classes/freemius/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
+ }
classes/freemius/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};
classes/freemius/assets/js/postmessage.js ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
29
+ return {
30
+ init : function (url)
31
+ {
32
+ _base_url = url;
33
+ _init();
34
+
35
+ // Automatically receive forward messages.
36
+ FS.PostMessage.receiveOnce('forward', function (data){
37
+ window.location = data.url;
38
+ });
39
+ },
40
+ init_child : function ()
41
+ {
42
+ this.init(_parent_subdomain);
43
+
44
+ _is_child = true;
45
+
46
+ // Post height of a child right after window is loaded.
47
+ $(window).bind('load', function () {
48
+ FS.PostMessage.postHeight();
49
+ });
50
+
51
+ },
52
+ postHeight : function (diff, wrapper) {
53
+ diff = diff || 0;
54
+ wrapper = wrapper || '#wrap_section';
55
+ this.post('height', {
56
+ height: diff + $(wrapper).outerHeight(true)
57
+ });
58
+ },
59
+ post : function (type, data, iframe)
60
+ {
61
+ console.debug('PostMessage.post', type);
62
+
63
+ if (iframe)
64
+ {
65
+ // Post to iframe.
66
+ _postman.postMessage(JSON.stringify({
67
+ type: type,
68
+ data: data
69
+ }), iframe.src, iframe.contentWindow);
70
+ }
71
+ else {
72
+ // Post to parent.
73
+ _postman.postMessage(JSON.stringify({
74
+ type: type,
75
+ data: data
76
+ }), _parent_url, window.parent);
77
+ }
78
+ },
79
+ receive: function (type, callback)
80
+ {
81
+ console.debug('PostMessage.receive', type);
82
+
83
+ if (undef === _callbacks[type])
84
+ _callbacks[type] = [];
85
+
86
+ _callbacks[type].push(callback);
87
+ },
88
+ receiveOnce: function (type, callback)
89
+ {
90
+ if (this.is_set(type))
91
+ return;
92
+
93
+ this.receive(type, callback);
94
+ },
95
+ // Check if any callbacks assigned to a specified message type.
96
+ is_set: function (type)
97
+ {
98
+ return (undef != _callbacks[type]);
99
+ },
100
+ parent_url: function ()
101
+ {
102
+ return _parent_url;
103
+ },
104
+ parent_subdomain: function ()
105
+ {
106
+ return _parent_subdomain;
107
+ }
108
+ };
109
+ }();
110
+ })(jQuery);
classes/freemius/assets/scss/_colors.scss ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $menu-hover-color: #333;
2
+ $darkest-color: #000;
3
+ $fms-live-color: #71ae00;
4
+ $fms-test-color: #f7941d;
5
+ $fms-link-color: #29abe1;
6
+ $fms-link-hover-color: darken(#29abe1, 10%);
7
+ $body-bkg: #111;
8
+ $special-color: #d3135a;
9
+ $body-color: #f1f1f1;
10
+ $fms-white: #f1f1f1;
11
+ $container-bkg: #222;
12
+ $container-bkg-odd: #262626;
13
+ $container-border-color: #333;
14
+ $table-head-bkg: #333;
15
+ $table-head-color: #999;
16
+ $info-color: #999;
17
+ $error-color: #ff0000;
18
+
19
+ $fs-logo-blue-color: #29abe1;
20
+ $fs-logo-green-color: #71ae00;
21
+ $fs-logo-magenta-color: #d3135a;
22
+
23
+ $fs-notice-promotion-border-color: #00a0d2;
24
+ $fs-notice-promotion-bkg: #f2fcff;
25
+
26
+ // WordPress colors.
27
+ $page-header-bkg: #333;
28
+ $page-header-color: $fms-white;
29
+ $text-dark-color: #333;
30
+ $text-light-color: #666;
31
+ $text-lightest-color: #999;
32
+
33
+ // WP Buttons.
34
+ $button-primary-bkg: #6bc406;
35
+ $button-primary-color: $fms-white;
36
+ $button-secondary-bkg: #333;
37
+ $button-secondary-color: $fms-white;
38
+ $featured-color: #6bc406;
39
+ $wp-selected-color: #0074a3;
40
+
41
+ $wordpress_color: #01749A;
42
+ $blogger_color: #ff8100;
43
+ $wix_color: #fac102;
44
+ $shopify_color: #80d100;
45
+ $addthis_color: #fe6d4e;
46
+ $tumblr_color: #34506b;
47
+ $zepo_color: #00baf2;
48
+ $jquery_color: #000919;
49
+ $javascript_color: #00baf2;
50
+ $squarespace_color: #000;
51
+
52
+ $blog_color: #ff6600;
53
+ $facebook_color: #3b5998;
54
+ $twitter_color: #4099ff;
55
+ $linkedin_color: #4875b4;
56
+ $youtube_color: #ff3333;
57
+ $gplus_color: #c63d2d;
58
+
classes/freemius/assets/scss/_functions.scss ADDED
File without changes
classes/freemius/assets/scss/_load.scss ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ @import 'mixins';
2
+ @import "vars";
3
+ @import "functions";
4
+ @import "colors";
classes/freemius/assets/scss/_mixins.scss ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ---- CSS3 SASS MIXINS ----
2
+ // https://github.com/madr/css3-sass-mixins
3
+ //
4
+ // Copyright (C) 2011 by Anders Ytterström
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to deal
8
+ // in the Software without restriction, including without limitation the rights
9
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ // copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ // THE SOFTWARE.
23
+ //
24
+
25
+ // ---- LEGACY IE SUPPORT USING FILTERS ----
26
+ // Should IE filters be used or not?
27
+ // PROS: gradients, drop shadows etc will be handled by css.
28
+ // CONS: will harm the site performance badly,
29
+ // especially on sites with heavy rendering and scripting.
30
+ $useIEFilters: 0;
31
+ // might be 0 or 1. disabled by default.
32
+ // ---- /LEGACY IE SUPPORT USING FILTERS ----
33
+
34
+
35
+ @mixin background-size ($value) {
36
+ -webkit-background-size: $value;
37
+ background-size: $value;
38
+ }
39
+
40
+ @mixin border-image ($path, $offsets, $repeats) {
41
+ -moz-border-image: $path $offsets $repeats;
42
+ -o-border-image: $path $offsets $repeats;
43
+ -webkit-border-image: $path $offsets $repeats;
44
+ border-image: $path $offsets $repeats;
45
+ }
46
+
47
+ @mixin border-radius ($values...) {
48
+ -moz-border-radius: $values;
49
+ -webkit-border-radius: $values;
50
+ border-radius: $values;
51
+ /*-moz-background-clip: padding;
52
+ -webkit-background-clip: padding-box;
53
+ background-clip: padding-box;*/
54
+ }
55
+
56
+ @mixin box-shadow ($values...) {
57
+ -moz-box-shadow: $values;
58
+ -webkit-box-shadow: $values;
59
+ box-shadow: $values;
60
+ }
61
+
62
+ //@mixin box-shadow ($x, $y, $offset, $hex, $ie: $useIEFilters, $inset: null, $spread:null) {
63
+ // -moz-box-shadow: $x $y $offset $spread $hex $inset;
64
+ // -webkit-box-shadow: $x $y $offset $spread $hex $inset;
65
+ // box-shadow: $x $y $offset $spread $hex $inset;
66
+ //
67
+ // @if $ie == 1 {
68
+ // $iecolor: '#' + red($hex) + green($hex) + blue($hex);
69
+ // filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}');
70
+ // -ms-filter: quote(progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}'));
71
+ // }
72
+ //}
73
+
74
+ @mixin box-sizing($value) {
75
+ -moz-box-sizing: $value;
76
+ -webkit-box-sizing: $value;
77
+ box-sizing: $value;
78
+ }
79
+
80
+ // requires sass 3.2
81
+ //@mixin keyframes {
82
+ // @-moz-keyframes { @content; }
83
+ // @-ms-keyframes { @content; }
84
+ // @-o-keyframes { @content; }
85
+ // @-webkit-keyframes { @content; }
86
+ // @keyframes { @content; }
87
+ //}
88
+
89
+ @mixin linear-gradient($from, $to, $ie: $useIEFilters) {
90
+ @if $ie != 1 { background-color: $to; }
91
+
92
+ background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, $from),color-stop(1, $to));
93
+ background-image: -webkit-linear-gradient(top, $from, $to);
94
+ background-image: -moz-linear-gradient(top, $from, $to);
95
+ background-image: -ms-linear-gradient(top, $from, $to);
96
+ background-image: -o-linear-gradient(top, $from, $to);
97
+ background-image: linear-gradient(top, bottom, $from, $to);
98
+
99
+ @if $ie == 1 {
100
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}');
101
+ }
102
+ }
103
+
104
+ @mixin horizontal-gradient($startColor: #555, $endColor: #333, $ie: $useIEFilters) {
105
+ @if $ie != 1 { background-color: $endColor; }
106
+
107
+ background-color: $endColor;
108
+ background-image: -webkit-gradient(linear, 0 0, 100% 0, from($startColor), to($endColor)); // Safari 4+, Chrome 2+
109
+ background-image: -webkit-linear-gradient(left, $startColor, $endColor); // Safari 5.1+, Chrome 10+
110
+ background-image: -moz-linear-gradient(left, $startColor, $endColor); // FF 3.6+
111
+ background-image: -o-linear-gradient(left, $startColor, $endColor); // Opera 11.10
112
+ background-image: linear-gradient(to right, $startColor, $endColor); // Standard, IE10
113
+ background-repeat: repeat-x;
114
+ @if $ie == 1 {
115
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=1);
116
+ }
117
+ }
118
+
119
+ @mixin radial-gradient($from, $to, $ie: $useIEFilters) {
120
+ @if $ie != 1 { background-color: $to; }
121
+
122
+ background: -moz-radial-gradient(center, circle cover, $from 0%, $to 100%);
123
+ background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, $from), color-stop(100%, $to));
124
+ background: -webkit-radial-gradient(center, circle cover, $from 0%, $to 100%);
125
+ background: -o-radial-gradient(center, circle cover, $from 0%, $to 100%);
126
+ background: -ms-radial-gradient(center, circle cover, $from 0%, $to 100%);
127
+ background: radial-gradient(center, circle cover, $from 0%, $to 100%);
128
+ background-color: $from;
129
+
130
+ @if $ie == 1 {
131
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}', GradientType=1); /* IE6-9 fallback on horizontal gradient */
132
+ }
133
+ }
134
+
135
+ /*@mixin rgba-bg ($hex, $alpha, $ie: $useIEFilters) {
136
+ @if $ie == 1 {
137
+ background-color: none;
138
+ $hexopac: ie-hex-str(rgba($hex, $alpha));
139
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}}');
140
+ -ms-filter: quote(progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}'));
141
+ }
142
+ @else {
143
+ background-color: $hex;
144
+ background-color: rgba($hex, $alpha);
145
+ }
146
+ }*/
147
+
148
+ @mixin perspective($perspective) {
149
+ -moz-perspective: $perspective;
150
+ -ms-perspective: $perspective;
151
+ -webkit-perspective: $perspective;
152
+ perspective: $perspective;
153
+ -moz-transform-style: preserve-3d;
154
+ -ms-transform-style: preserve-3d;
155
+ -webkit-transform-style: preserve-3d;
156
+ transform-style: preserve-3d;
157
+ }
158
+
159
+ @mixin transform ($transforms) {
160
+ -moz-transform: $transforms;
161
+ -o-transform: $transforms;
162
+ -ms-transform: $transforms;
163
+ -webkit-transform: $transforms;
164
+ transform: $transforms;
165
+ }
166
+
167
+ @mixin matrix ($a, $b, $c, $d, $e, $f) {
168
+ -moz-transform: matrix($a, $b, $c, $d, #{$e}px, #{$f}px);
169
+ -o-transform: matrix($a, $b, $c, $d, $e, $f);
170
+ -ms-transform: matrix($a, $b, $c, $d, $e, $f);
171
+ -webkit-transform: matrix($a, $b, $c, $d, $e, $f);
172
+ transform: matrix($a, $b, $c, $d, $e, $f);
173
+ }
174
+
175
+ @mixin rotate ($deg) {
176
+ @include transform(rotate(#{$deg}deg));
177
+ }
178
+
179
+ @mixin scale ($size) {
180
+ @include transform(scale(#{$size}));
181
+ }
182
+
183
+ @mixin translate ($x, $y) {
184
+ @include transform(translate($x, $y));
185
+ }
186
+
187
+ @mixin transition ($value...) {
188
+ -moz-transition: $value;
189
+ -o-transition: $value;
190
+ -ms-transition: $value;
191
+ -webkit-transition: $value;
192
+ transition: $value;
193
+ }
194
+
195
+ // ==== /CSS3 SASS MIXINS ====
196
+
197
+ @mixin opacity($opacity) {
198
+ opacity: $opacity;
199
+ $opacity-ie: $opacity * 100;
200
+ filter: alpha(opacity=$opacity-ie); //IE8
201
+ }
202
+
203
+ @mixin sprite($img, $width, $height: $width, $display: block)
204
+ {
205
+ display: $display;
206
+ background-image: url('#{$img}');
207
+
208
+ @include size($width, $height);
209
+ }
210
+
211
+ @mixin size($width, $height: $width)
212
+ {
213
+ width: $width;
214
+ height: $height;
215
+ }
216
+
217
+ @mixin clearfix
218
+ {
219
+ &:after {
220
+ content: "";
221
+ display: table;
222
+ clear: both;
223
+ }
224
+ }
classes/freemius/assets/scss/_start.scss ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ @import "vars";
2
+ @import "colors";
3
+ @import "mixins";
4
+ @import "functions";
classes/freemius/assets/scss/_vars.scss ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ $is_production: true;
2
+
3
+ $img_common: if($is_production == true, '//img.freemius.com', 'http://img.freemius:8080');
4
+
5
+ $layout_width: 960px;
classes/freemius/assets/scss/admin/account.scss ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #fs_account
2
+ {
3
+ .postbox,
4
+ .widefat
5
+ {
6
+ max-width: 700px;
7
+ }
8
+
9
+ .fs-header-actions
10
+ {
11
+ position: absolute;
12
+ top: 10px;
13
+ right: 10px;
14
+ font-size: 0.9em;
15
+
16
+ ul
17
+ {
18
+ margin: 0;
19
+ }
20
+
21
+ li
22
+ {
23
+ form
24
+ {
25
+ display: inline-block;
26
+ }
27
+
28
+ float: left;
29
+ a
30
+ {
31
+ text-decoration: none;
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ .rtl #fs_account .fs-header-actions
38
+ {
39
+ left: 10px;
40
+ right: auto;
41
+ }
42
+
43
+ .fs-key-value-table
44
+ {
45
+ width: 100%;
46
+
47
+ form
48
+ {
49
+ display: inline-block;
50
+ }
51
+
52
+ td label
53
+ {
54
+ background: orange;
55
+ color: #fff;
56
+ display: inline-block;
57
+ border-radius: 3px;
58
+ padding: 5px;
59
+ font-size: 11px;
60
+ line-height: 11px;
61
+ vertical-align: baseline;
62
+ }
63
+
64
+ tr
65
+ {
66
+ td:first-child
67
+ {
68
+ nobr
69
+ {
70
+ font-weight: bold;
71
+ }
72
+
73
+ text-align: right;
74
+
75
+ form
76
+ {
77
+ display: block;
78
+ }
79
+ }
80
+
81
+ td.fs-right
82
+ {
83
+ text-align: right;
84
+ }
85
+
86
+ &.fs-odd
87
+ {
88
+ background: #ebebeb;
89
+ }
90
+ }
91
+
92
+ td, th
93
+ {
94
+ padding: 10px;
95
+ }
96
+
97
+ var, code
98
+ {
99
+ color: #0073AA;
100
+ font-size: 16px;
101
+ background: none;
102
+ }
103
+ }
104
+
105
+ #fs_addons
106
+ {
107
+ td:first-child,
108
+ th:first-child
109
+ {
110
+ text-align: left;
111
+ font-weight: bold;
112
+ }
113
+ td:last-child,
114
+ th:last-child
115
+ {
116
+ text-align: right;
117
+ }
118
+ th
119
+ {
120
+ font-weight: bold;
121
+ }
122
+ }
classes/freemius/assets/scss/admin/add-ons.scss ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ #fs_addons
4
+ {
5
+ .fs-cards-list
6
+ {
7
+ list-style: none;
8
+
9
+ .fs-card
10
+ {
11
+ float: left;
12
+ // height: 185px; // With reviews/ratings
13
+ height: 152px;
14
+ width: 310px;
15
+ padding: 0;
16
+ margin: 0 0 30px 30px;
17
+ font-size: 14px;
18
+ list-style: none;
19
+ border: 1px solid #ddd;
20
+ cursor: pointer;
21
+ position: relative;
22
+
23
+ .fs-overlay
24
+ {
25
+ position: absolute;
26
+ left: 0;
27
+ right: 0;
28
+ bottom: 0;
29
+ top: 0;
30
+ z-index: 9;
31
+ }
32
+
33
+ .fs-inner
34
+ {
35
+ background-color: #fff;
36
+ overflow: hidden;
37
+ height: 100%;
38
+ position: relative;
39
+
40
+ ul
41
+ {
42
+ @include transition(all, 0.15s);
43
+ left: 0;
44
+ right: 0;
45
+ top: 0;
46
+ position: absolute;
47
+
48
+ }
49
+
50
+ li
51
+ {
52
+ list-style: none;
53
+ line-height: 18px;
54
+ padding: 0 15px;
55
+ width: 100%;
56
+ display: block;
57
+ @include box-sizing(border-box);
58
+ }
59
+
60
+ .fs-card-banner
61
+ {
62
+ padding: 0;
63
+ margin: 0;
64
+ line-height: 0;
65
+ display: block;
66
+ height: 100px;
67
+ background-repeat: repeat-x;
68
+ background-size: 100% 100%;
69
+ @include transition(all, 0.15s);
70
+ }
71
+
72
+ .fs-title
73
+ {
74
+ margin: 10px 0 0 0;
75
+ height: 18px;
76
+ overflow: hidden;
77
+ color: #000;
78
+ white-space: nowrap;
79
+ text-overflow: ellipsis;
80
+ font-weight: bold;
81
+ }
82
+
83
+ .fs-offer
84
+ {
85
+ font-size: 0.9em;
86
+ }
87
+
88
+ .fs-description
89
+ {
90
+ background-color: #f9f9f9;
91
+ padding: 10px 15px 100px 15px;
92
+ border-top: 1px solid #eee;
93
+ margin: 0 0 10px 0;
94
+ color: #777;
95
+ }
96
+ }
97
+
98
+ @media screen and (min-width: 960px) {
99
+ &:hover
100
+ {
101
+ .fs-overlay
102
+ {
103
+ border: 2px solid $fms-link-color;
104
+ margin-left: -1px;
105
+ margin-top: -1px;
106
+ }
107
+
108
+ .fs-inner
109
+ {
110
+ ul
111
+ {
112
+ top: -100px;
113
+ }
114
+
115
+ .fs-card-banner
116
+ {
117
+ // background-position: 50% -100px;
118
+ }
119
+
120
+ .fs-title,
121
+ .fs-offer
122
+ {
123
+ color: $fms-link-color;
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ #TB_window
133
+ {
134
+ &, iframe
135
+ {
136
+ width: 772px !important;
137
+ }
138
+ }
139
+
140
+ #plugin-information
141
+ {
142
+ #section-description
143
+ {
144
+ h2, h3, p, b, i, blockquote, li, ul, ol
145
+ {
146
+ clear: none;
147
+ }
148
+
149
+ .fs-selling-points
150
+ {
151
+ padding-bottom: 10px;
152
+ border-bottom: 1px solid #ddd;
153
+
154
+ ul
155
+ {
156
+ margin: 0;
157
+
158
+ li
159
+ {
160
+ padding: 0;
161
+ list-style: none outside none;
162
+
163
+ i.dashicons
164
+ {
165
+ color: $fs-logo-green-color;
166
+ font-size: 3em;
167
+ vertical-align: middle;
168
+ line-height: 30px;
169
+ float: left;
170
+ margin: 0 0 0 -15px;
171
+ }
172
+
173
+ h3
174
+ {
175
+ margin-left: 30px;
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ .fs-screenshots
182
+ {
183
+ @include clearfix();
184
+ ul
185
+ {
186
+ list-style: none;
187
+ margin: 0;
188
+
189
+ li
190
+ {
191
+ width: 225px;
192
+ height: 225px;
193
+ float: left;
194
+ margin-bottom: 20px;
195
+ @include box-sizing(content-box);
196
+
197
+ a
198
+ {
199
+ display: block;
200
+ width: 100%;
201
+ height: 100%;
202
+ border: 1px solid;
203
+ @include box-shadow(1px 1px 1px rgba(0,0,0,0.2));
204
+ background-size: cover;
205
+ }
206
+
207
+ &.odd
208
+ {
209
+ margin-right: 20px;
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+
216
+ .plugin-information-pricing
217
+ {
218
+ background: #FFFEEC;
219
+ margin: -16px;
220
+ padding: 20px 20px 50px 20px;
221
+ border-bottom: 1px solid #DDD;
222
+
223
+ h3
224
+ {
225
+ margin-top: 0;
226
+ }
227
+
228
+ .button
229
+ {
230
+ width: 100%;
231
+ text-align: center;
232
+ font-weight: bold;
233
+ text-transform: uppercase;
234
+ font-size: 1.1em;
235
+ }
236
+
237
+ label
238
+ {
239
+ white-space: nowrap;
240
+ }
241
+ }
242
+
243
+ #section-features
244
+ {
245
+ .fs-features
246
+ {
247
+ margin: -20px -26px;
248
+ }
249
+
250
+ table {
251
+ width: 100%;
252
+ border-spacing: 0;
253
+ border-collapse: separate;
254
+
255
+ thead {
256
+ th
257
+ {
258
+ padding: 10px 0;
259
+ }
260
+
261
+ .fs-price
262
+ {
263
+ color: $fs-logo-green-color;
264
+ font-weight: normal;
265
+ display: block;
266
+ text-align: center;
267
+ }
268
+ }
269
+
270
+ tbody
271
+ {
272
+ td
273
+ {
274
+ border-top: 1px solid #ccc;
275
+ padding: 10px 0;
276
+ text-align: center;
277
+ width: 100px;
278
+ color: $fs-logo-green-color;
279
+
280
+ &:first-child
281
+ {
282
+ text-align: left;
283
+ width: auto;
284
+ color: inherit;
285
+ padding-left: 26px;
286
+ }
287
+ }
288
+ tr.fs-odd
289
+ {
290
+ td
291
+ {
292
+ background: #fefefe;
293
+ }
294
+ }
295
+ }
296
+ }
297
+
298
+ .dashicons-yes
299
+ {
300
+ width: 30px;
301
+ height: 30px;
302
+ font-size: 30px;
303
+ }
304
+ }
305
+ }
306
+
307
+ @media screen and (max-width: 961px)
308
+ {
309
+ #fs_addons
310
+ {
311
+ .fs-cards-list
312
+ {
313
+ .fs-card
314
+ {
315
+ height: 265px;
316
+ }
317
+ }
318
+ }
319
+ }
classes/freemius/assets/scss/admin/common.scss ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ .fs-notice
4
+ {
5
+ position: relative;
6
+
7
+ &.fs-has-title
8
+ {
9
+ margin-bottom: 30px !important;
10
+ }
11
+
12
+ &.success
13
+ {
14
+ color: green;
15
+ // font-weight: normal;
16
+ }
17
+
18
+ &.promotion
19
+ {
20
+ border-color: $fs-notice-promotion-border-color !important;
21
+ background-color: $fs-notice-promotion-bkg !important;
22
+ }
23
+
24
+ .fs-close
25
+ {
26
+ position: absolute;
27
+ top: 10px;
28
+ right: 10px;
29
+ cursor: pointer;
30
+ color: #ccc;
31
+
32
+ &:hover
33
+ {
34
+ color: #aaa;
35
+ }
36
+ }
37
+
38
+ label.fs-plugin-title
39
+ {
40
+ background: rgba(0, 0, 0, 0.3);
41
+ color: #fff;
42
+ padding: 2px 10px;
43
+ position: absolute;
44
+ bottom: -22px;
45
+ top: auto;
46
+ right: auto;
47
+ @include border-radius(0 0 3px 3px);
48
+ left: 10px;
49
+ font-size: 12px;
50
+ font-weight: bold;
51
+ cursor: auto;
52
+ }
53
+ }
54
+
55
+ .rtl .fs-notice .fs-close
56
+ {
57
+ left: 10px;
58
+ right: auto;
59
+ }
60
+
61
+ .fs-secure-notice
62
+ {
63
+ position: fixed;
64
+ top: 32px;
65
+ left: 160px;
66
+ right: 0;
67
+ background: rgb(235, 253, 235);
68
+ padding: 10px 20px;
69
+ color: green;
70
+ z-index: 9999;
71
+ box-shadow: 0px 2px 2px rgba(6, 113, 6, 0.3);
72
+ @include opacity(0.95);
73
+
74
+ &:hover
75
+ {
76
+ @include opacity(1);
77
+ }
78
+ }
79
+
80
+ @media screen and (max-width: 960px)
81
+ {
82
+ .fs-secure-notice
83
+ {
84
+ left: 36px;
85
+ }
86
+ }
87
+
88
+ @media screen and (max-width: 782px)
89
+ {
90
+ .fs-secure-notice
91
+ {
92
+ left: 0;
93
+ top: 46px;
94
+ text-align: center;
95
+ }
96
+ }
97
+
98
+ span.fs-submenu-item.fs-sub:before {
99
+ // Add small arrow.
100
+ content: '\21B3';
101
+ padding: 0 5px;
102
+ }
103
+
104
+ .rtl {
105
+ span.fs-submenu-item.fs-sub:before {
106
+ // Add small RTL arrow.
107
+ content: '\21B2';
108
+ }
109
+ }
classes/freemius/assets/scss/admin/connect.scss ADDED
@@ -0,0 +1,405 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ $form_width: 480px;
4
+
5
+ #fs_connect
6
+ {
7
+ width: $form_width;
8
+ @include box-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));
9
+ margin: 20px 0;
10
+
11
+ @media screen and (max-width: ($form_width - 1)) {
12
+ @include box-shadow(none);
13
+ width: auto;
14
+ margin: 0 0 0 -10px;
15
+ }
16
+
17
+ .fs-content
18
+ {
19
+ background: #fff;
20
+ padding: 15px 20px;
21
+
22
+ p
23
+ {
24
+ margin: 0;
25
+ padding: 0;
26
+ font-size: 1.2em;
27
+ }
28
+ }
29
+
30
+ .fs-actions
31
+ {
32
+ padding: 10px 20px;
33
+ background: #C0C7CA;
34
+
35
+ .button
36
+ {
37
+ padding: 0 10px 1px;
38
+ line-height: 35px;
39
+ height: 37px;
40
+ font-size: 16px;
41
+ margin-bottom: 0;
42
+
43
+ .dashicons
44
+ {
45
+ font-size: 37px;
46
+ margin-left: -8px;
47
+ margin-right: 12px;
48
+ }
49
+
50
+ &.button-primary
51
+ {
52
+ padding-right: 15px;
53
+ padding-left: 15px;
54
+
55
+ &:after
56
+ {
57
+ content: ' \279C';
58
+ }
59
+ }
60
+
61
+ &.button-secondary
62
+ {
63
+ float: right;
64
+ }
65
+ }
66
+
67
+ // .fs-skip
68
+ // {
69
+ // line-height: 38px;
70
+ // vertical-align: middle;
71
+ // text-decoration: none;
72
+ // margin-left: 10px;
73
+ // }
74
+ }
75
+
76
+ &.fs-anonymous-disabled
77
+ {
78
+ .fs-actions
79
+ {
80
+ .button.button-primary
81
+ {
82
+ width: 100%;
83
+ }
84
+ }
85
+ }
86
+
87
+ .fs-permissions
88
+ {
89
+ padding: 10px 20px;
90
+ background: #FEFEFE;
91
+ // background: #F1F1F1;
92
+ @include transition(background 0.5s ease);
93
+
94
+ .fs-trigger
95
+ {
96
+ font-size: 0.9em;
97
+ text-decoration: none;
98
+ text-align: center;
99
+ display: block;
100
+ }
101
+
102
+ ul
103
+ {
104
+ height: 0;
105
+ overflow: hidden;
106
+ margin: 0;
107
+
108
+ li
109
+ {
110
+ margin-bottom: 12px;
111
+
112
+ &:last-child
113
+ {
114
+ margin-bottom: 0;
115
+ }
116
+
117
+ i.dashicons
118
+ {
119
+ float: left;
120
+ font-size: 40px;
121
+ width: 40px;
122
+ height: 40px;
123
+ }
124
+
125
+ div
126
+ {
127
+ margin-left: 55px;
128
+
129
+ span
130
+ {
131
+ font-weight: bold;
132
+ text-transform: uppercase;
133
+ color: #23282d;
134
+ }
135
+
136
+ p
137
+ {
138
+ margin: 2px 0 0 0;
139
+ }
140
+ }
141
+ }
142
+ }
143
+
144
+ &.fs-open
145
+ {
146
+ background: #fff;
147
+
148
+ ul
149
+ {
150
+ height: auto;
151
+ margin: 20px 20px 10px 20px;
152
+ }
153
+ }
154
+
155
+ @media screen and (max-width: ($form_width - 1)) {
156
+ background: #fff;
157
+
158
+ .fs-trigger
159
+ {
160
+ display: none;
161
+ }
162
+
163
+ ul
164
+ {
165
+ height: auto;
166
+ margin: 20px;
167
+ }
168
+ }
169
+ }
170
+
171
+ $icon_size: 80px;
172
+ $wp_logo_padding: $icon_size / 10;
173
+ $icons_top: 10px;
174
+
175
+ .fs-visual
176
+ {
177
+ padding: 12px;
178
+ line-height: 0;
179
+ background: #fafafa;
180
+ height: $icon_size;
181
+ position: relative;
182
+
183
+ .fs-site-icon
184
+ {
185
+ position: absolute;
186
+ left: 20px;
187
+ top: $icons_top;
188
+ }
189
+
190
+ .fs-connect-logo
191
+ {
192
+ position: absolute;
193
+ right: 20px;
194
+ top: $icons_top;
195
+ }
196
+
197
+ .fs-plugin-icon
198
+ {
199
+ position: absolute;
200
+ top: $icons_top;
201
+ left: 50%;
202
+ margin-left: - ($icon_size / 2);
203
+ }
204
+
205
+ .fs-plugin-icon,
206
+ .fs-site-icon,
207
+ img,
208
+ object
209
+ {
210
+ width: $icon_size;
211
+ height: $icon_size;
212
+ }
213
+
214
+ .dashicons-wordpress
215
+ {
216
+ font-size: $icon_size - ($wp_logo_padding * 2);
217
+ background: $wordpress_color;
218
+ color: #fff;
219
+ width: $icon_size - ($wp_logo_padding * 2);
220
+ height: $icon_size - ($wp_logo_padding * 2);
221
+ padding: $wp_logo_padding;
222
+ }
223
+
224
+ .dashicons-plus
225
+ {
226
+ position: absolute;
227
+ top: 50%;
228
+ font-size: 30px;
229
+ margin-top: -10px;
230
+ color: #bbb;
231
+
232
+ &.fs-first
233
+ {
234
+ left: 28%;
235
+ }
236
+ &.fs-second
237
+ {
238
+ left: 65%;
239
+ }
240
+ }
241
+
242
+ .fs-plugin-icon,
243
+ .fs-connect-logo,
244
+ .fs-site-icon
245
+ {
246
+ border: 1px solid #ccc;
247
+ padding: 1px;
248
+ background: #fff;
249
+ }
250
+ }
251
+
252
+ .fs-terms
253
+ {
254
+ text-align: center;
255
+ font-size: 0.85em;
256
+ padding: 5px;
257
+ background: rgba(0, 0, 0, 0.05);
258
+
259
+ &, a
260
+ {
261
+ color: #999;
262
+ }
263
+
264
+ a
265
+ {
266
+ text-decoration: none;
267
+ }
268
+ }
269
+ }
270
+
271
+ .rtl
272
+ {
273
+ #fs_connect
274
+ {
275
+ .fs-actions
276
+ {
277
+ padding: 10px 20px;
278
+ background: #C0C7CA;
279
+
280
+ .button
281
+ {
282
+ .dashicons
283
+ {
284
+ font-size: 37px;
285
+ margin-left: -8px;
286
+ margin-right: 12px;
287
+ }
288
+
289
+ &.button-primary
290
+ {
291
+ &:after
292
+ {
293
+ content: ' \000bb';
294
+ }
295
+ }
296
+
297
+ &.button-secondary
298
+ {
299
+ float: left;
300
+ }
301
+ }
302
+ }
303
+
304
+ .fs-permissions
305
+ {
306
+ ul
307
+ {
308
+ li
309
+ {
310
+ div
311
+ {
312
+ margin-right: 55px;
313
+ margin-left: 0;
314
+ }
315
+
316
+ i.dashicons
317
+ {
318
+ float: right;
319
+ }
320
+
321
+ }
322
+ }
323
+ }
324
+
325
+ .fs-visual
326
+ {
327
+ .fs-site-icon
328
+ {
329
+ right: 20px;
330
+ left: auto;
331
+ }
332
+
333
+ .fs-connect-logo
334
+ {
335
+ right: auto;
336
+ left: 20px;
337
+ }
338
+ }
339
+ }
340
+ }
341
+
342
+ .wp-pointer-content
343
+ {
344
+ #fs_connect
345
+ {
346
+ margin: 0;
347
+ @include box-shadow(none);
348
+ }
349
+ }
350
+
351
+ .fs-opt-in-pointer
352
+ {
353
+ .wp-pointer-content
354
+ {
355
+ padding: 0;
356
+ }
357
+
358
+ &.wp-pointer-top
359
+ {
360
+ .wp-pointer-arrow
361
+ {
362
+ border-bottom-color: #dfdfdf;
363
+ }
364
+ .wp-pointer-arrow-inner
365
+ {
366
+ border-bottom-color: #fafafa;
367
+ }
368
+ }
369
+
370
+ &.wp-pointer-bottom
371
+ {
372
+ .wp-pointer-arrow
373
+ {
374
+ border-top-color: #dfdfdf;
375
+ }
376
+ .wp-pointer-arrow-inner
377
+ {
378
+ border-top-color: #fafafa;
379
+ }
380
+ }
381
+
382
+ &.wp-pointer-left
383
+ {
384
+ .wp-pointer-arrow
385
+ {
386
+ border-right-color: #dfdfdf;
387
+ }
388
+ .wp-pointer-arrow-inner
389
+ {
390
+ border-right-color: #fafafa;
391
+ }
392
+ }
393
+
394
+ &.wp-pointer-right
395
+ {
396
+ .wp-pointer-arrow
397
+ {
398
+ border-left-color: #dfdfdf;
399
+ }
400
+ .wp-pointer-arrow-inner
401
+ {
402
+ border-left-color: #fafafa;
403
+ }
404
+ }
405
+ }
classes/freemius/assets/scss/admin/deactivation-feedback.scss ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .fs-modal {
2
+ position: fixed;
3
+ overflow: auto;
4
+ height: 100%;
5
+ width: 100%;
6
+ top: 0;
7
+ z-index: 100000;
8
+ display: none;
9
+ background: rgba(0, 0, 0, 0.6);
10
+
11
+ .fs-modal-dialog {
12
+ background: transparent;
13
+ position: absolute;
14
+ left: 50%;
15
+ margin-left: -298px;
16
+ padding-bottom: 30px;
17
+ top: -100%;
18
+ z-index: 100001;
19
+ width: 596px;
20
+
21
+ @media (max-width: 650px) {
22
+ margin-left: -50%;
23
+ box-sizing: border-box;
24
+ padding-left: 10px;
25
+ padding-right: 10px;
26
+ width: 100%;
27
+
28
+ .fs-modal-panel > h3 > strong {
29
+ font-size: 1.3em;
30
+ }
31
+
32
+ li.reason {
33
+ margin-bottom: 10px;
34
+
35
+ .reason-input {
36
+ margin-left: 29px;
37
+ }
38
+
39
+ label {
40
+ display: table;
41
+
42
+ > span {
43
+ display: table-cell;
44
+ font-size: 1.3em;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ &.active {
52
+ display: block;
53
+
54
+ &:before {
55
+ display: block;
56
+ }
57
+
58
+ .fs-modal-dialog {
59
+ top: 10%;
60
+ }
61
+ }
62
+
63
+ .fs-modal-body,
64
+ .fs-modal-footer {
65
+ border: 0;
66
+ background: #fefefe;
67
+ padding: 20px;
68
+ }
69
+
70
+ .fs-modal-body {
71
+ border-bottom: 0;
72
+
73
+ h2 {
74
+ font-size: 20px;
75
+ }
76
+
77
+ > div {
78
+ margin-top: 10px;
79
+
80
+ h2 {
81
+ font-weight: bold;
82
+ font-size: 20px;
83
+ margin-top: 0;
84
+ }
85
+ }
86
+ }
87
+
88
+ .fs-modal-footer {
89
+ border-top: #eeeeee solid 1px;
90
+ text-align: right;
91
+
92
+ > .button {
93
+ margin: 0 7px;
94
+
95
+ &:first-child {
96
+ margin: 0;
97
+ }
98
+ }
99
+ }
100
+
101
+ .fs-modal-panel:not(.active) {
102
+ display: none;
103
+ }
104
+
105
+ .reason-input {
106
+ margin: 3px 0 3px 22px;
107
+
108
+ input, textarea {
109
+ width: 100%;
110
+ }
111
+ }
112
+ }
113
+
114
+ body.has-fs-modal {
115
+ overflow: hidden;
116
+ }
117
+
118
+ #the-list .deactivate > .fs-slug {
119
+ display: none;
120
+ }
classes/freemius/config.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ define( 'WP_FS__SLUG', 'freemius' );
14
+ if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
15
+ define( 'WP_FS__DEV_MODE', false );
16
+ }
17
+
18
+ /**
19
+ * API Connectivity Simulation
20
+ */
21
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false && WP_FS__DEV_MODE );
22
+ define( 'WP_FS__SIMULATE_NO_CURL', false && WP_FS__DEV_MODE );
23
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false && WP_FS__DEV_MODE );
24
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false && WP_FS__DEV_MODE );
25
+ if ( WP_FS__SIMULATE_NO_CURL ) {
26
+ define( 'FS_SDK__SIMULATE_NO_CURL', true );
27
+ }
28
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
29
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
30
+ }
31
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
32
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
33
+ }
34
+
35
+ /**
36
+ * If your dev environment supports custom public network IP setup
37
+ * like VVV, please update WP_FS__LOCALHOST_IP with your public IP
38
+ * and uncomment it during dev.
39
+ */
40
+ if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
41
+ // VVV default public network IP.
42
+ define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.1' );
43
+
44
+ // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
45
+ }
46
+
47
+ /**
48
+ * If true and running with secret key, the opt-in process
49
+ * will skip the email activation process which is invoked
50
+ * when the email of the context user already exist in Freemius
51
+ * database (as a security precaution, to prevent sharing user
52
+ * secret with unauthorized entity).
53
+ *
54
+ * IMPORTANT:
55
+ * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
56
+ * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
57
+ * CLOCK IS SYNCED.
58
+ */
59
+ define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
60
+
61
+
62
+ /**
63
+ * Directories
64
+ */
65
+ define( 'WP_FS__DIR', dirname( __FILE__ ) );
66
+ define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
67
+ define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
68
+ define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
69
+ define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
70
+ define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
71
+ define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
72
+ define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
73
+
74
+
75
+ /**
76
+ * Domain / URL / Address
77
+ */
78
+ define( 'WP_FS__TESTING_DOMAIN', 'fswp:8080' );
79
+ define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
80
+ define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
81
+ define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
82
+ define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
83
+
84
+ define( 'WP_FS__IS_PRODUCTION_MODE', ! defined( 'WP_FS__DEV_MODE' ) || ! WP_FS__DEV_MODE || ( WP_FS__TESTING_DOMAIN !== $_SERVER['HTTP_HOST'] ) );
85
+
86
+ define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
87
+
88
+ if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
89
+ define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP == $_SERVER['REMOTE_ADDR'] ) );
90
+ } else {
91
+ define( 'WP_FS__IS_LOCALHOST', ( substr( $_SERVER['REMOTE_ADDR'], 0, 4 ) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1' ) );
92
+ }
93
+
94
+ define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
95
+
96
+ // Set API address for local testing.
97
+ if ( ! WP_FS__IS_PRODUCTION_MODE ) {
98
+ define( 'FS_API__ADDRESS', 'http://api.freemius:8080' );
99
+ define( 'FS_API__SANDBOX_ADDRESS', 'http://sandbox-api.freemius:8080' );
100
+ }
101
+
102
+ define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
103
+
104
+ if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
105
+ define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
106
+ }
107
+ if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
108
+ define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
109
+ }
110
+ define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
111
+
112
+ define( 'WP_FS__IS_HTTPS', (
113
+ // Checks if CloudFlare's HTTPS (Flexible SSL support)
114
+ isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) ||
115
+ // Check if HTTPS request.
116
+ ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
117
+ ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
118
+ );
119
+
120
+ define( 'WP_FS__IS_POST_REQUEST', ( strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
121
+
122
+ /**
123
+ * Billing Frequencies
124
+ */
125
+ define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
126
+ define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
127
+ define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
128
+
129
+ /**
130
+ * Plans
131
+ */
132
+ define( 'WP_FS__PLAN_DEFAULT_PAID', false );
133
+ define( 'WP_FS__PLAN_FREE', 'free' );
134
+ define( 'WP_FS__PLAN_TRIAL', 'trial' );
135
+
136
+ /**
137
+ * Times in seconds
138
+ */
139
+ // define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
140
+ define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
141
+ // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
142
+ define( 'WP_FS__TIME_24_HOURS_IN_SEC', 86400 );
143
+
144
+ /**
145
+ * Debugging
146
+ */
147
+ define( 'WP_FS__DEBUG_SDK', ! empty( $_GET['fs_dbg'] ) );
148
+ define( 'WP_FS__ECHO_DEBUG_SDK', ! empty( $_GET['fs_dbg_echo'] ) );
149
+ define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-n-d H:i:s' );
150
+
151
+ if ( WP_FS__ECHO_DEBUG_SDK ) {
152
+ error_reporting( E_ALL );
153
+ ini_set( 'error_reporting', E_ALL );
154
+ ini_set( 'display_errors', true );
155
+ ini_set( 'html_errors', true );
156
+ }
157
+
158
+
159
+ define( 'WP_FS__SCRIPT_START_TIME', time() );
160
+ define( 'WP_FS__DEFAULT_PRIORITY', 10 );
161
+ define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
classes/freemius/includes/class-freemius-abstract.php ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.7
7
+ */
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+
13
+ /**
14
+ * - Each instance of Freemius class represents a single plugin
15
+ * install by a single user (the installer of the plugin).
16
+ *
17
+ * - Each website can only have one install of the same plugin.
18
+ *
19
+ * - Install entity is only created after a user connects his account with Freemius.
20
+ *
21
+ * Class Freemius_Abstract
22
+ */
23
+ abstract class Freemius_Abstract {
24
+
25
+ #region Identity ------------------------------------------------------------------
26
+
27
+ /**
28
+ * Check if user registered with Freemius by connecting his account.
29
+ *
30
+ * @since 1.0.1
31
+ * @return bool
32
+ */
33
+ abstract function is_registered();
34
+
35
+ /**
36
+ * Check if the user skipped connecting the account with Freemius.
37
+ *
38
+ * @since 1.0.7
39
+ *
40
+ * @return bool
41
+ */
42
+ abstract function is_anonymous();
43
+
44
+ /**
45
+ * Check if the user currently in activation mode.
46
+ *
47
+ * @since 1.0.7
48
+ *
49
+ * @return bool
50
+ */
51
+ abstract function is_activation_mode();
52
+
53
+ #endregion Identity ------------------------------------------------------------------
54
+
55
+ #region Permissions ------------------------------------------------------------------
56
+
57
+ /**
58
+ * Check if plugin must be WordPress.org compliant.
59
+ *
60
+ * @since 1.0.7
61
+ *
62
+ * @return bool
63
+ */
64
+ abstract function is_org_repo_compliant();
65
+
66
+ /**
67
+ * Check if plugin is allowed to install executable files.
68
+ *
69
+ * @author Vova Feldman (@svovaf)
70
+ * @since 1.0.5
71
+ *
72
+ * @return bool
73
+ */
74
+ function is_allowed_to_install() {
75
+ return ( $this->is_premium() || ! $this->is_org_repo_compliant() );
76
+ }
77
+
78
+ #endregion Permissions ------------------------------------------------------------------
79
+
80
+ /**
81
+ * Check if user in trial or in free plan (not paying).
82
+ *
83
+ * @author Vova Feldman (@svovaf)
84
+ * @since 1.0.4
85
+ *
86
+ * @return bool
87
+ */
88
+ function is_not_paying() {
89
+ return ( $this->is_trial() || $this->is_free_plan() );
90
+ }
91
+
92
+ /**
93
+ * Check if the user has an activated and valid paid license on current plugin's install.
94
+ *
95
+ * @since 1.0.9
96
+ *
97
+ * @return bool
98
+ */
99
+ abstract function is_paying();
100
+
101
+ /**
102
+ * Check if the user is paying or in trial.
103
+ *
104
+ * @since 1.0.9
105
+ *
106
+ * @return bool
107
+ */
108
+ function is_paying_or_trial() {
109
+ return ( $this->is_paying() || $this->is_trial() );
110
+ }
111
+
112
+ #region Premium Only ------------------------------------------------------------------
113
+
114
+ /**
115
+ * All logic wrapped in methods with "__premium_only()" suffix will be only
116
+ * included in the premium code.
117
+ *
118
+ * Example:
119
+ * if ( freemius()->is__premium_only() ) {
120
+ * ...
121
+ * }
122
+ */
123
+
124
+ /**
125
+ * Returns true when running premium plugin code.
126
+ *
127
+ * @since 1.0.9
128
+ *
129
+ * @return bool
130
+ */
131
+ function is__premium_only() {
132
+ return $this->is_premium();
133
+ }
134
+
135
+ /**
136
+ * Check if the user has an activated and valid paid license on current plugin's install.
137
+ *
138
+ * @since 1.0.9
139
+ *
140
+ * @return bool
141
+ *
142
+ */
143
+ function is_paying__premium_only() {
144
+ return ( $this->is__premium_only() && $this->is_paying() );
145
+ }
146
+
147
+ /**
148
+ * All code wrapped in this statement will be only included in the premium code.
149
+ *
150
+ * @since 1.0.9
151
+ *
152
+ * @param string $plan Plan name
153
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
154
+ *
155
+ * @return bool
156
+ */
157
+ function is_plan__premium_only( $plan, $exact = false ) {
158
+ return ( $this->is_premium() && $this->is_plan( $plan, $exact ) );
159
+ }
160
+
161
+ /**
162
+ * Check if plan matches active license' plan or active trial license' plan.
163
+ *
164
+ * All code wrapped in this statement will be only included in the premium code.
165
+ *
166
+ * @since 1.0.9
167
+ *
168
+ * @param string $plan Plan name
169
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
170
+ *
171
+ * @return bool
172
+ */
173
+ function is_plan_or_trial__premium_only( $plan, $exact = false ) {
174
+ return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) );
175
+ }
176
+
177
+ /**
178
+ * Check if the user is paying or in trial.
179
+ *
180
+ * All code wrapped in this statement will be only included in the premium code.
181
+ *
182
+ * @since 1.0.9
183
+ *
184
+ * @return bool
185
+ */
186
+ function is_paying_or_trial__premium_only() {
187
+ return $this->is_premium() && $this->is_paying_or_trial();
188
+ }
189
+
190
+ /**
191
+ * Check if the user has an activated and valid paid license on current plugin's install.
192
+ *
193
+ * @since 1.0.4
194
+ *
195
+ * @return bool
196
+ *
197
+ * @deprecated Method name is confusing since it's not clear from the name the code will be removed.
198
+ * @using Alias to is_paying__premium_only()
199
+ */
200
+ function is_paying__fs__() {
201
+ return $this->is_paying__premium_only();
202
+ }
203
+
204
+ #endregion Premium Only ------------------------------------------------------------------
205
+
206
+ #region Trial ------------------------------------------------------------------
207
+
208
+ /**
209
+ * Check if the user in a trial.
210
+ *
211
+ * @since 1.0.3
212
+ *
213
+ * @return bool
214
+ */
215
+ abstract function is_trial();
216
+
217
+ /**
218
+ * Check if trial already utilized.
219
+ *
220
+ * @since 1.0.9
221
+ *
222
+ * @return bool
223
+ */
224
+ abstract function is_trial_utilized();
225
+
226
+ #endregion Trial ------------------------------------------------------------------
227
+
228
+ #region Plans ------------------------------------------------------------------
229
+
230
+ /**
231
+ * Check if plugin using the free plan.
232
+ *
233
+ * @since 1.0.4
234
+ *
235
+ * @return bool
236
+ */
237
+ abstract function is_free_plan();
238
+
239
+ /**
240
+ * @since 1.0.2
241
+ *
242
+ * @param string $plan Plan name
243
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
244
+ *
245
+ * @return bool
246
+ */
247
+ abstract function is_plan( $plan, $exact = false );
248
+
249
+ /**
250
+ * Check if plan based on trial. If not in trial mode, should return false.
251
+ *
252
+ * @since 1.0.9
253
+ *
254
+ * @param string $plan Plan name
255
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
256
+ *
257
+ * @return bool
258
+ */
259
+ abstract function is_trial_plan( $plan, $exact = false );
260
+
261
+ /**
262
+ * Check if plan matches active license' plan or active trial license' plan.
263
+ *
264
+ * @since 1.0.9
265
+ *
266
+ * @param string $plan Plan name
267
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
268
+ *
269
+ * @return bool
270
+ */
271
+ function is_plan_or_trial( $plan, $exact = false ) {
272
+ return $this->is_plan( $plan, $exact ) ||
273
+ $this->is_trial_plan( $plan, $exact );
274
+ }
275
+
276
+ /**
277
+ * Check if plugin has any paid plans.
278
+ *
279
+ * @author Vova Feldman (@svovaf)
280
+ * @since 1.0.7
281
+ *
282
+ * @return bool
283
+ */
284
+ abstract function has_paid_plan();
285
+
286
+ /**
287
+ * Check if plugin has any free plan, or is it premium only.
288
+ *
289
+ * Note: If no plans configured, assume plugin is free.
290
+ *
291
+ * @author Vova Feldman (@svovaf)
292
+ * @since 1.0.7
293
+ *
294
+ * @return bool
295
+ */
296
+ abstract function has_free_plan();
297
+
298
+ #endregion Plans ------------------------------------------------------------------
299
+
300
+ /**
301
+ * Check if running payments in sandbox mode.
302
+ *
303
+ * @since 1.0.4
304
+ *
305
+ * @return bool
306
+ */
307
+ abstract function is_payments_sandbox();
308
+
309
+ /**
310
+ * Check if running test vs. live plugin.
311
+ *
312
+ * @since 1.0.5
313
+ *
314
+ * @return bool
315
+ */
316
+ abstract function is_live();
317
+
318
+ /**
319
+ * Check if running premium plugin code.
320
+ *
321
+ * @since 1.0.5
322
+ *
323
+ * @return bool
324
+ */
325
+ abstract function is_premium();
326
+
327
+ /**
328
+ * Get upgrade URL.
329
+ *
330
+ * @author Vova Feldman (@svovaf)
331
+ * @since 1.0.2
332
+ *
333
+ * @param string $period Billing cycle
334
+ *
335
+ * @return string
336
+ */
337
+ abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
338
+
339
+ /**
340
+ * Check if Freemius was first added in a plugin update.
341
+ *
342
+ * @author Vova Feldman (@svovaf)
343
+ * @since 1.1.5
344
+ *
345
+ * @return bool
346
+ */
347
+ abstract function is_plugin_update();
348
+
349
+ #region Marketing ------------------------------------------------------------------
350
+
351
+ /**
352
+ * Check if current user purchased any other plugins before.
353
+ *
354
+ * @author Vova Feldman (@svovaf)
355
+ * @since 1.0.9
356
+ *
357
+ * @return bool
358
+ */
359
+ abstract function has_purchased_before();
360
+
361
+ /**
362
+ * Check if current user classified as an agency.
363
+ *
364
+ * @author Vova Feldman (@svovaf)
365
+ * @since 1.0.9
366
+ *
367
+ * @return bool
368
+ */
369
+ abstract function is_agency();
370
+
371
+ /**
372
+ * Check if current user classified as a developer.
373
+ *
374
+ * @author Vova Feldman (@svovaf)
375
+ * @since 1.0.9
376
+ *
377
+ * @return bool
378
+ */
379
+ abstract function is_developer();
380
+
381
+ /**
382
+ * Check if current user classified as a business.
383
+ *
384
+ * @author Vova Feldman (@svovaf)
385
+ * @since 1.0.9
386
+ *
387
+ * @return bool
388
+ */
389
+ abstract function is_business();
390
+
391
+ #endregion ------------------------------------------------------------------
392
+ }
classes/freemius/includes/class-freemius.php ADDED
@@ -0,0 +1,7648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
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 = '1.1.5';
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 1.0.0
38
+ *
39
+ * @var string
40
+ */
41
+ private $_free_plugin_basename;
42
+ /**
43
+ * @since 1.0.0
44
+ *
45
+ * @var string
46
+ */
47
+ private $_plugin_dir_path;
48
+ /**
49
+ * @since 1.0.0
50
+ *
51
+ * @var string
52
+ */
53
+ private $_plugin_dir_name;
54
+ /**
55
+ * @since 1.0.0
56
+ *
57
+ * @var string
58
+ */
59
+ private $_plugin_main_file_path;
60
+ /**
61
+ * @var string[]
62
+ */
63
+ private $_plugin_data;
64
+ /**
65
+ * @since 1.0.9
66
+ *
67
+ * @var string
68
+ */
69
+ private $_plugin_name;
70
+
71
+ #endregion Plugin Info
72
+
73
+ /**
74
+ * @since 1.0.9
75
+ *
76
+ * @var bool If false, don't turn Freemius on.
77
+ */
78
+ private $_is_on;
79
+
80
+ /**
81
+ * @since 1.1.3
82
+ *
83
+ * @var bool If false, don't turn Freemius on.
84
+ */
85
+ private $_is_anonymous;
86
+
87
+ /**
88
+ * @since 1.0.9
89
+ * @var bool If false, issues with connectivity to Freemius API.
90
+ */
91
+ private $_has_api_connection;
92
+
93
+ /**
94
+ * @since 1.0.9
95
+ * @var bool Hints the SDK if plugin can support anonymous mode (if skip connect is visible).
96
+ */
97
+ private $_enable_anonymous;
98
+
99
+ /**
100
+ * @since 1.0.8
101
+ * @var bool Hints the SDK if the plugin has any paid plans.
102
+ */
103
+ private $_has_paid_plans;
104
+
105
+ /**
106
+ * @since 1.0.7
107
+ * @var bool Hints the SDK if the plugin is WordPress.org compliant.
108
+ */
109
+ private $_is_org_compliant;
110
+
111
+ /**
112
+ * @since 1.0.7
113
+ * @var bool Hints the SDK if the plugin is has add-ons.
114
+ */
115
+ private $_has_addons;
116
+
117
+ /**
118
+ * @var FS_Key_Value_Storage
119
+ */
120
+ private $_storage;
121
+
122
+ /**
123
+ * @since 1.0.0
124
+ *
125
+ * @var FS_Logger
126
+ */
127
+ private $_logger;
128
+ /**
129
+ * @since 1.0.4
130
+ *
131
+ * @var FS_Plugin
132
+ */
133
+ private $_plugin = false;
134
+ /**
135
+ * @since 1.0.4
136
+ *
137
+ * @var FS_Plugin
138
+ */
139
+ private $_parent_plugin = false;
140
+ /**
141
+ * @since 1.1.1
142
+ *
143
+ * @var Freemius
144
+ */
145
+ private $_parent = false;
146
+ /**
147
+ * @since 1.0.1
148
+ *
149
+ * @var FS_User
150
+ */
151
+ private $_user = false;
152
+ /**
153
+ * @since 1.0.1
154
+ *
155
+ * @var FS_Site
156
+ */
157
+ private $_site = false;
158
+ /**
159
+ * @since 1.0.1
160
+ *
161
+ * @var FS_Plugin_License
162
+ */
163
+ private $_license;
164
+ /**
165
+ * @since 1.0.2
166
+ *
167
+ * @var FS_Plugin_Plan[]
168
+ */
169
+ private $_plans = false;
170
+ /**
171
+ * @var FS_Plugin_License[]
172
+ * @since 1.0.5
173
+ */
174
+ private $_licenses = false;
175
+
176
+ /**
177
+ * @since 1.0.1
178
+ *
179
+ * @var FS_Admin_Menu_Manager
180
+ */
181
+ private $_menu;
182
+
183
+ /**
184
+ * @var FS_Admin_Notice_Manager
185
+ */
186
+ private $_admin_notices;
187
+
188
+ /**
189
+ * @var FS_Logger
190
+ * @since 1.0.0
191
+ */
192
+ private static $_static_logger;
193
+
194
+ /**
195
+ * @var FS_Option_Manager
196
+ * @since 1.0.2
197
+ */
198
+ private static $_accounts;
199
+
200
+ /**
201
+ * @var Freemius[]
202
+ */
203
+ private static $_instances = array();
204
+
205
+
206
+ /* Ctor
207
+ ------------------------------------------------------------------------------------------------------------------*/
208
+
209
+ private function __construct( $slug ) {
210
+ $this->_slug = $slug;
211
+
212
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
213
+
214
+ $this->_storage = FS_Key_Value_Storage::instance( 'plugin_data', $this->_slug );
215
+
216
+ $this->_plugin_main_file_path = $this->_find_caller_plugin_file();
217
+ $this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
218
+ $this->_plugin_basename = plugin_basename( $this->_plugin_main_file_path );
219
+ $this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
220
+
221
+ $base_name_split = explode( '/', $this->_plugin_basename );
222
+ $this->_plugin_dir_name = $base_name_split[0];
223
+
224
+ if ( $this->_logger->is_on() ) {
225
+ $this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
226
+ $this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
227
+ $this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
228
+ $this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
229
+ $this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
230
+ }
231
+
232
+ // Remember link between file to slug.
233
+ $this->store_file_slug_map();
234
+
235
+ // Store plugin's initial install timestamp.
236
+ if ( ! isset( $this->_storage->install_timestamp ) ) {
237
+ $this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
238
+ }
239
+
240
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_slug )->get();
241
+
242
+ $this->_admin_notices = FS_Admin_Notice_Manager::instance(
243
+ $slug,
244
+ is_object( $this->_plugin ) ? $this->_plugin->title : ''
245
+ );
246
+
247
+ if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ) {
248
+ FS_Api::clear_cache();
249
+ }
250
+
251
+ $this->_register_hooks();
252
+
253
+ $this->_load_account();
254
+
255
+ $this->_version_updates_handler();
256
+ }
257
+
258
+ /**
259
+ * @author Vova Feldman (@svovaf)
260
+ * @since 1.0.9
261
+ */
262
+ private function _version_updates_handler() {
263
+ if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
264
+ // Freemius version upgrade mode.
265
+ $this->_storage->sdk_last_version = $this->_storage->sdk_version;
266
+ $this->_storage->sdk_version = $this->version;
267
+
268
+ if ( empty( $this->_storage->sdk_last_version ) ||
269
+ version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
270
+ ) {
271
+ $this->_storage->sdk_upgrade_mode = true;
272
+ $this->_storage->sdk_downgrade_mode = false;
273
+ } else {
274
+ $this->_storage->sdk_downgrade_mode = true;
275
+ $this->_storage->sdk_upgrade_mode = false;
276
+
277
+ }
278
+
279
+ $this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
280
+ }
281
+
282
+ $plugin_version = $this->get_plugin_version();
283
+ if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
284
+ // Plugin version upgrade mode.
285
+ $this->_storage->plugin_last_version = $this->_storage->plugin_version;
286
+ $this->_storage->plugin_version = $plugin_version;
287
+
288
+ if ( empty( $this->_storage->plugin_last_version ) ||
289
+ version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
290
+ ) {
291
+ $this->_storage->plugin_upgrade_mode = true;
292
+ $this->_storage->plugin_downgrade_mode = false;
293
+ } else {
294
+ $this->_storage->plugin_downgrade_mode = true;
295
+ $this->_storage->plugin_upgrade_mode = false;
296
+ }
297
+
298
+ if ( ! empty( $this->_storage->plugin_last_version ) ) {
299
+ // Different version of the plugin was installed before, therefore it's an update.
300
+ $this->_storage->is_plugin_new_install = false;
301
+ }
302
+
303
+ $this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
304
+ }
305
+ }
306
+
307
+ /**
308
+ * @author Vova Feldman (@svovaf)
309
+ * @since 1.1.5
310
+ *
311
+ * @param string $sdk_prev_version
312
+ * @param string $sdk_version
313
+ */
314
+ function _data_migration($sdk_prev_version, $sdk_version) {
315
+ if ( version_compare($sdk_prev_version, '1.1.5', '<' ) &&
316
+ version_compare($sdk_version, '1.1.5', '>=')
317
+ ) {
318
+ // On version 1.1.5 merged connectivity and is_on data.
319
+ if ( isset( $this->_storage->connectivity_test ) ) {
320
+ if ( ! isset( $this->_storage->is_on ) ) {
321
+ unset( $this->_storage->connectivity_test );
322
+ } else {
323
+ $connectivity_data = $this->_storage->connectivity_test;
324
+ $connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
325
+ $connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
326
+
327
+ // Override.
328
+ $this->_storage->connectivity_test = $connectivity_data;
329
+
330
+ // Remove previous structure.
331
+ unset( $this->_storage->is_on );
332
+ }
333
+
334
+ }
335
+ }
336
+ }
337
+
338
+ /**
339
+ * @author Vova Feldman (@svovaf)
340
+ * @since 1.0.9
341
+ */
342
+ private function _register_hooks() {
343
+ if ( is_admin() ) {
344
+ // Hook to plugin activation
345
+ register_activation_hook( $this->_plugin_main_file_path, array(
346
+ &$this,
347
+ '_activate_plugin_event_hook'
348
+ ) );
349
+
350
+ // Hook to plugin uninstall.
351
+ register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );
352
+
353
+ if ( ! $this->is_ajax() ) {
354
+ if ( ! $this->is_addon() ) {
355
+ add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
356
+ add_action( 'admin_menu', array( &$this, '_prepare_admin_menu' ), WP_FS__LOWEST_PRIORITY );
357
+ }
358
+ }
359
+ }
360
+
361
+ register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
362
+
363
+ add_action( 'init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
364
+
365
+ $this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
366
+
367
+ $this->add_action('sdk_version_update', array(&$this, '_data_migration'), WP_FS__DEFAULT_PRIORITY, 2);
368
+ }
369
+
370
+ /**
371
+ * @author Vova Feldman (@svovaf)
372
+ * @since 1.0.9
373
+ */
374
+ private function _register_account_hooks() {
375
+ if ( is_admin() ) {
376
+ if ( ! $this->is_ajax() ) {
377
+ if ( $this->has_trial_plan() ) {
378
+ $last_time_trial_promotion_shown = $this->_storage->get( 'trial_promotion_shown', false );
379
+ if ( ! $this->_site->is_trial_utilized() &&
380
+ (
381
+ // Show promotion if never shown it yet and 24 hours after initial activation.
382
+ ( false === $last_time_trial_promotion_shown && $this->_storage->activation_timestamp < ( time() - WP_FS__TIME_24_HOURS_IN_SEC ) ) ||
383
+ // Show promotion in every 30 days.
384
+ ( is_numeric( $last_time_trial_promotion_shown ) && 30 * WP_FS__TIME_24_HOURS_IN_SEC < time() - $last_time_trial_promotion_shown ) )
385
+ ) {
386
+ $this->add_action( 'after_init_plugin_registered', array( &$this, '_add_trial_notice' ) );
387
+ }
388
+ }
389
+ }
390
+
391
+ // If user is paying or in trial and have the free version installed,
392
+ // assume that the deactivation is for the upgrade process.
393
+ if ( ! $this->is_paying_or_trial() || $this->is_premium() ) {
394
+ add_action( 'wp_ajax_submit-uninstall-reason', array( &$this, '_submit_uninstall_reason_action' ) );
395
+
396
+ global $pagenow;
397
+ if ( 'plugins.php' === $pagenow ) {
398
+ add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
399
+ }
400
+ }
401
+ }
402
+ }
403
+
404
+ /**
405
+ * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
406
+ * page.
407
+ *
408
+ * @author Vova Feldman (@svovaf)
409
+ * @author Leo Fajardo (@leorw)
410
+ * @since 1.1.2
411
+ */
412
+ function _add_deactivation_feedback_dialog_box() {
413
+ fs_enqueue_local_style( 'fs_deactivation_feedback', '/admin/deactivation-feedback.css' );
414
+
415
+ /* Check the type of user:
416
+ * 1. Long-term (long-term)
417
+ * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
418
+ * 3. Short-term (short-term)
419
+ */
420
+ $is_long_term_user = true;
421
+
422
+ // Check if the site is at least 2 days old.
423
+ $time_installed = $this->_storage->install_timestamp;
424
+
425
+ // Difference in seconds.
426
+ $date_diff = time() - $time_installed;
427
+
428
+ // Convert seconds to days.
429
+ $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
430
+
431
+ if ( $date_diff_days < 2 ) {
432
+ $is_long_term_user = false;
433
+ }
434
+
435
+ $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
436
+
437
+ if ( $is_long_term_user ) {
438
+ $user_type = 'long-term';
439
+ } else {
440
+ if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
441
+ $user_type = 'non-registered-and-non-anonymous-short-term';
442
+ } else {
443
+ $user_type = 'short-term';
444
+ }
445
+ }
446
+
447
+ $uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
448
+
449
+ // Load the HTML template for the deactivation feedback dialog box.
450
+ $vars = array(
451
+ 'reasons' => $uninstall_reasons,
452
+ 'slug' => $this->_slug
453
+ );
454
+
455
+ fs_require_once_template( 'deactivation-feedback-modal.php', $vars );
456
+ }
457
+
458
+ /**
459
+ * @author Leo Fajardo (leorw)
460
+ * @since 1.1.2
461
+ *
462
+ * @param string $user_type
463
+ *
464
+ * @return array The uninstall reasons for the specified user type.
465
+ */
466
+ function _get_uninstall_reasons( $user_type = 'long-term' ) {
467
+ $reason_found_better_plugin = array(
468
+ 'id' => 2,
469
+ 'text' => __fs( 'reason-found-a-better-plugin' ),
470
+ 'input_type' => 'textfield',
471
+ 'input_placeholder' => __fs( 'placeholder-plugin-name' )
472
+ );
473
+
474
+ $reason_other = array(
475
+ 'id' => 7,
476
+ 'text' => __fs( 'reason-other' ),
477
+ 'input_type' => 'textfield',
478
+ 'input_placeholder' => ''
479
+ );
480
+
481
+ $long_term_user_reasons = array(
482
+ array(
483
+ 'id' => 1,
484
+ 'text' => __fs( 'reason-no-longer-needed' ),
485
+ 'input_type' => '',
486
+ 'input_placeholder' => ''
487
+ ),
488
+ $reason_found_better_plugin,
489
+ array(
490
+ 'id' => 3,
491
+ 'text' => __fs( 'reason-needed-for-a-short-period' ),
492
+ 'input_type' => '',
493
+ 'input_placeholder' => ''
494
+ ),
495
+ array(
496
+ 'id' => 4,
497
+ 'text' => __fs( 'reason-broke-my-site' ),
498
+ 'input_type' => '',
499
+ 'input_placeholder' => ''
500
+ ),
501
+ array(
502
+ 'id' => 5,
503
+ 'text' => __fs( 'reason-suddenly-stopped-working' ),
504
+ 'input_type' => '',
505
+ 'input_placeholder' => ''
506
+ )
507
+ );
508
+
509
+ if ( $this->is_paying() ) {
510
+ $long_term_user_reasons[] = array(
511
+ 'id' => 6,
512
+ 'text' => __fs( 'reason-cant-pay-anymore' ),
513
+ 'input_type' => 'textfield',
514
+ 'input_placeholder' => __fs( 'placeholder-comfortable-price' )
515
+ );
516
+ }
517
+
518
+ $long_term_user_reasons[] = $reason_other;
519
+
520
+ $uninstall_reasons = array(
521
+ 'long-term' => $long_term_user_reasons,
522
+ 'non-registered-and-non-anonymous-short-term' => array(
523
+ array(
524
+ 'id' => 8,
525
+ 'text' => __fs( 'reason-didnt-work' ),
526
+ 'input_type' => '',
527
+ 'input_placeholder' => ''
528
+ ),
529
+ array(
530
+ 'id' => 9,
531
+ 'text' => __fs( 'reason-dont-like-to-share-my-information' ),
532
+ 'input_type' => '',
533
+ 'input_placeholder' => ''
534
+ ),
535
+ $reason_found_better_plugin,
536
+ $reason_other
537
+ ),
538
+ 'short-term' => array(
539
+ array(
540
+ 'id' => 10,
541
+ 'text' => __fs( 'reason-couldnt-make-it-work' ),
542
+ 'input_type' => '',
543
+ 'input_placeholder' => ''
544
+ ),
545
+ $reason_found_better_plugin,
546
+ array(
547
+ 'id' => 11,
548
+ 'text' => __fs( 'reason-great-but-need-specific-feature' ),
549
+ 'input_type' => 'textarea',
550
+ 'input_placeholder' => __fs( 'placeholder-feature' )
551
+ ),
552
+ array(
553
+ 'id' => 12,
554
+ 'text' => __fs( 'reason-not-working' ),
555
+ 'input_type' => 'textarea',
556
+ 'input_placeholder' => __fs( 'placeholder-share-what-didnt-work' )
557
+ ),
558
+ array(
559
+ 'id' => 13,
560
+ 'text' => __fs( 'reason-not-what-i-was-looking-for' ),
561
+ 'input_type' => 'textarea',
562
+ 'input_placeholder' => __fs( 'placeholder-what-youve-been-looking-for' )
563
+ ),
564
+ array(
565
+ 'id' => 14,
566
+ 'text' => __fs( 'reason-didnt-work-as-expected' ),
567
+ 'input_type' => 'textarea',
568
+ 'input_placeholder' => __fs( 'placeholder-what-did-you-expect' )
569
+ ),
570
+ $reason_other
571
+ )
572
+ );
573
+
574
+ $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
575
+
576
+ return $uninstall_reasons[ $user_type ];
577
+ }
578
+
579
+ /**
580
+ * Called after the user has submitted his reason for deactivating the plugin.
581
+ *
582
+ * @author Leo Fajardo (@leorw)
583
+ * @since 1.1.2
584
+ */
585
+ function _submit_uninstall_reason_action() {
586
+ if ( ! isset( $_POST['reason_id'] ) ) {
587
+ exit;
588
+ }
589
+
590
+ $reason_info = isset( $_REQUEST['reason_info'] ) ? trim( stripslashes( $_REQUEST['reason_info'] ) ) : '';
591
+
592
+ $reason = (object) array(
593
+ 'id' => $_POST['reason_id'],
594
+ 'info' => substr( $reason_info, 0, 128 )
595
+ );
596
+
597
+ $this->_storage->store( 'uninstall_reason', $reason );
598
+
599
+ // Print '1' for successful operation.
600
+ echo 1;
601
+ exit;
602
+ }
603
+
604
+ /**
605
+ * Leverage backtrace to find caller plugin file path.
606
+ *
607
+ * @author Vova Feldman (@svovaf)
608
+ * @since 1.0.6
609
+ *
610
+ * @return string
611
+ */
612
+ private function _find_caller_plugin_file() {
613
+ $bt = debug_backtrace();
614
+ $backtrace_entries_count = count( $bt );
615
+
616
+ // Try to load the cached value of the file path.
617
+ if ( isset( $this->_storage->plugin_main_file ) ) {
618
+ if ( file_exists( $this->_storage->plugin_main_file->path ) ) {
619
+ return $this->_storage->plugin_main_file->path;
620
+ }
621
+ }
622
+
623
+ /**
624
+ * All the code below will be executed once on activation.
625
+ * If the user changes the main plugin's file name, the file_exists()
626
+ * will catch it.
627
+ */
628
+ self::require_plugin_essentials();
629
+
630
+ $all_plugins = get_plugins();
631
+ $all_plugins_paths = array();
632
+
633
+ // Get active plugin's main files real full names (might be symlinks).
634
+ foreach ( $all_plugins as $relative_path => &$data ) {
635
+ $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
636
+ }
637
+
638
+ $plugin_file = null;
639
+ for ( $i = 1; $i < $backtrace_entries_count; $i ++ ) {
640
+ if ( in_array( fs_normalize_path( $bt[ $i ]['file'] ), $all_plugins_paths ) ) {
641
+ $plugin_file = $bt[ $i ]['file'];
642
+ break;
643
+ }
644
+ }
645
+
646
+ if ( is_null( $plugin_file ) ) {
647
+ // Throw an error to the developer in case of some edge case dev environment.
648
+ wp_die( __fs( 'failed-finding-main-path' ), __fs( 'error' ), array( 'back_link' => true ) );
649
+ }
650
+
651
+ $this->_storage->plugin_main_file = (object) array(
652
+ 'path' => fs_normalize_path( $plugin_file ),
653
+ );
654
+
655
+ return $plugin_file;
656
+ }
657
+
658
+ #region Instance ------------------------------------------------------------------
659
+
660
+ /**
661
+ * Main singleton instance.
662
+ *
663
+ * @author Vova Feldman (@svovaf)
664
+ * @since 1.0.0
665
+ *
666
+ * @param $slug
667
+ *
668
+ * @return Freemius
669
+ */
670
+ static function instance( $slug ) {
671
+ $slug = strtolower( $slug );
672
+
673
+ if ( ! isset( self::$_instances[ $slug ] ) ) {
674
+ if ( 0 === count( self::$_instances ) ) {
675
+ self::_load_required_static();
676
+ }
677
+
678
+ self::$_instances[ $slug ] = new Freemius( $slug );
679
+ }
680
+
681
+ return self::$_instances[ $slug ];
682
+ }
683
+
684
+ /**
685
+ * @author Vova Feldman (@svovaf)
686
+ * @since 1.0.6
687
+ *
688
+ * @param string|number $slug_or_id
689
+ *
690
+ * @return bool
691
+ */
692
+ private static function has_instance( $slug_or_id ) {
693
+ return ! is_numeric( $slug_or_id ) ?
694
+ isset( self::$_instances[ strtolower( $slug_or_id ) ] ) :
695
+ ( false !== self::get_instance_by_id( $slug_or_id ) );
696
+ }
697
+
698
+ /**
699
+ * @author Vova Feldman (@svovaf)
700
+ * @since 1.0.6
701
+ *
702
+ * @param $id
703
+ *
704
+ * @return false|Freemius
705
+ */
706
+ static function get_instance_by_id( $id ) {
707
+ foreach ( self::$_instances as $slug => $instance ) {
708
+ if ( $id == $instance->get_id() ) {
709
+ return $instance;
710
+ }
711
+ }
712
+
713
+ return false;
714
+ }
715
+
716
+ /**
717
+ *
718
+ * @author Vova Feldman (@svovaf)
719
+ * @since 1.0.1
720
+ *
721
+ * @param $plugin_file
722
+ *
723
+ * @return false|Freemius
724
+ */
725
+ static function get_instance_by_file( $plugin_file ) {
726
+ $slug = self::find_slug_by_basename( $plugin_file );
727
+
728
+ return ( false !== $slug ) ?
729
+ self::instance( $slug ) :
730
+ false;
731
+ }
732
+
733
+ /**
734
+ * @author Vova Feldman (@svovaf)
735
+ * @since 1.0.6
736
+ *
737
+ * @return false|Freemius
738
+ */
739
+ function get_parent_instance() {
740
+ return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
741
+ }
742
+
743
+ /**
744
+ * @author Vova Feldman (@svovaf)
745
+ * @since 1.0.6
746
+ *
747
+ * @param $slug_or_id
748
+ *
749
+ * @return bool|Freemius
750
+ */
751
+ function get_addon_instance( $slug_or_id ) {
752
+ return ! is_numeric( $slug_or_id ) ?
753
+ self::instance( strtolower( $slug_or_id ) ) :
754
+ self::get_instance_by_id( $slug_or_id );
755
+ }
756
+
757
+ #endregion ------------------------------------------------------------------
758
+
759
+ /**
760
+ * @author Vova Feldman (@svovaf)
761
+ * @since 1.0.6
762
+ *
763
+ * @return bool
764
+ */
765
+ function is_parent_plugin_installed() {
766
+ return self::has_instance( $this->_plugin->parent_plugin_id );
767
+ }
768
+
769
+ /**
770
+ * Check if add-on parent plugin in activation mode.
771
+ *
772
+ * @author Vova Feldman (@svovaf)
773
+ * @since 1.0.7
774
+ *
775
+ * @return bool
776
+ */
777
+ function is_parent_in_activation() {
778
+ $parent_fs = $this->get_parent_instance();
779
+ if ( ! is_object( $parent_fs ) ) {
780
+ return false;
781
+ }
782
+
783
+ return ( $parent_fs->is_activation_mode() );
784
+ }
785
+
786
+ /**
787
+ * Is plugin in activation mode.
788
+ *
789
+ * @author Vova Feldman (@svovaf)
790
+ * @since 1.0.7
791
+ *
792
+ * @return bool
793
+ */
794
+ function is_activation_mode() {
795
+ return (
796
+ ! $this->is_registered() &&
797
+ ( ! $this->enable_anonymous() ||
798
+ ( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
799
+ );
800
+ }
801
+
802
+ private static $_statics_loaded = false;
803
+
804
+ /**
805
+ * Load static resources.
806
+ *
807
+ * @author Vova Feldman (@svovaf)
808
+ * @since 1.0.1
809
+ */
810
+ private static function _load_required_static() {
811
+ if ( self::$_statics_loaded ) {
812
+ return;
813
+ }
814
+
815
+ self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
816
+
817
+ self::$_static_logger->entrance();
818
+
819
+ self::$_accounts = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
820
+
821
+ // Configure which Freemius powered plugins should be auto updated.
822
+ // add_filter( 'auto_update_plugin', '_include_plugins_in_auto_update', 10, 2 );
823
+
824
+ if ( WP_FS__DEV_MODE ) {
825
+ add_action( 'admin_menu', array( 'Freemius', 'add_debug_page' ) );
826
+ }
827
+
828
+ self::$_statics_loaded = true;
829
+ }
830
+
831
+ #region Debugging ------------------------------------------------------------------
832
+
833
+ /**
834
+ * @author Vova Feldman (@svovaf)
835
+ * @since 1.0.8
836
+ */
837
+ static function add_debug_page() {
838
+ self::$_static_logger->entrance();
839
+
840
+ $hook = add_object_page(
841
+ __fs( 'freemius-debug' ),
842
+ __fs( 'freemius-debug' ),
843
+ 'manage_options',
844
+ 'freemius',
845
+ array( 'Freemius', '_debug_page_render' )
846
+ );
847
+
848
+ add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
849
+ }
850
+
851
+ /**
852
+ * @author Vova Feldman (@svovaf)
853
+ * @since 1.0.8
854
+ */
855
+ static function _debug_page_actions() {
856
+ if ( fs_request_is_action( 'delete_all_accounts' ) ) {
857
+ check_admin_referer( 'delete_all_accounts' );
858
+
859
+ self::$_accounts->clear( true );
860
+
861
+ return;
862
+ }
863
+ }
864
+
865
+ /**
866
+ * @author Vova Feldman (@svovaf)
867
+ * @since 1.0.8
868
+ */
869
+ static function _debug_page_render() {
870
+ self::$_static_logger->entrance();
871
+
872
+ $sites = self::get_all_sites();
873
+ $users = self::get_all_users();
874
+ $addons = self::get_all_addons();
875
+ $account_addons = self::get_all_account_addons();
876
+
877
+ // $plans = self::get_all_plans();
878
+ // $licenses = self::get_all_licenses();
879
+
880
+ $vars = array(
881
+ 'sites' => $sites,
882
+ 'users' => $users,
883
+ 'addons' => $addons,
884
+ 'account_addons' => $account_addons,
885
+ );
886
+ fs_require_once_template( 'debug.php', $vars );
887
+ }
888
+
889
+ #endregion ------------------------------------------------------------------
890
+
891
+ #region Connectivity Issues ------------------------------------------------------------------
892
+
893
+ /**
894
+ * Check if Freemius should be turned on for the current plugin install.
895
+ *
896
+ * @author Vova Feldman (@svovaf)
897
+ * @since 1.0.9
898
+ *
899
+ * @return bool
900
+ */
901
+ private function is_on() {
902
+ self::$_static_logger->entrance();
903
+
904
+ if ( isset( $this->_is_on ) ) {
905
+ return $this->_is_on;
906
+ }
907
+
908
+ // If already installed or pending then sure it's on :)
909
+ if ( $this->is_registered() || $this->is_pending_activation() ) {
910
+ $this->_is_on = true;
911
+
912
+ return $this->_is_on;
913
+ }
914
+ }
915
+
916
+ /**
917
+ * Check if there's any connectivity issue to Freemius API.
918
+ *
919
+ * @author Vova Feldman (@svovaf)
920
+ * @since 1.0.9
921
+ *
922
+ * @param bool $flush
923
+ *
924
+ * @return bool
925
+ */
926
+ private function has_api_connectivity($flush = false) {
927
+ if (!$flush && isset( $this->_has_api_connection ) ) {
928
+ return $this->_has_api_connection;
929
+ }
930
+
931
+ $version = $this->get_plugin_version();
932
+
933
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
934
+ isset( $this->_storage->connectivity_test ) &&
935
+ true === $this->_storage->connectivity_test['is_connected']
936
+ ) {
937
+ unset( $this->_storage->connectivity_test );
938
+ }
939
+
940
+ if (isset( $this->_storage->connectivity_test ) ) {
941
+ if ( $_SERVER['HTTP_HOST'] == $this->_storage->connectivity_test['host'] &&
942
+ fs_get_ip() == $this->_storage->connectivity_test['server_ip']
943
+ ) {
944
+ if ( ( $this->_storage->connectivity_test['is_connected'] &&
945
+ $this->_storage->connectivity_test['is_active'] ) ||
946
+ (!$flush &&
947
+ $version == $this->_storage->connectivity_test['version'])
948
+ ) {
949
+ $this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
950
+ $this->_is_on = $this->_storage->connectivity_test['is_active'];
951
+
952
+ return $this->_has_api_connection;
953
+ }
954
+ }
955
+ }
956
+
957
+ $is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
958
+
959
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
960
+ $is_connected = false;
961
+ } else {
962
+ $pong = $this->get_api_plugin_scope()->ping( $this->get_anonymous_id(), $is_update );
963
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
964
+ }
965
+
966
+ if ( ! $is_connected ) {
967
+ // 2nd try of connectivity.
968
+ $pong = $this->get_api_plugin_scope()->ping( $this->get_anonymous_id(), $is_update );
969
+
970
+ if ( $this->get_api_plugin_scope()->is_valid_ping( $pong ) ) {
971
+ $is_connected = true;
972
+ } else {
973
+ // Another API failure.
974
+ $this->_add_connectivity_issue_message( $pong );
975
+ }
976
+ }
977
+
978
+ $is_active = ( ! $is_connected ) ?
979
+ false :
980
+ ( isset( $pong->is_active ) && true == $pong->is_active );
981
+
982
+ $this->_storage->connectivity_test = array(
983
+ 'is_connected' => $is_connected,
984
+ 'host' => $_SERVER['HTTP_HOST'],
985
+ 'server_ip' => fs_get_ip(),
986
+ 'is_active' => $is_active,
987
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
988
+ // Last version with connectivity attempt.
989
+ 'version' => $version,
990
+ );
991
+
992
+ $this->_has_api_connection = $is_connected;
993
+ $this->_is_on = $is_active;
994
+
995
+ return $this->_has_api_connection;
996
+ }
997
+
998
+ /**
999
+ * Anonymous and unique site identifier (Hash).
1000
+ *
1001
+ * @author Vova Feldman (@svovaf)
1002
+ * @since 1.1.0
1003
+ *
1004
+ * @return string
1005
+ */
1006
+ function get_anonymous_id() {
1007
+ if ( ! self::$_accounts->has_option( 'unique_id' ) ) {
1008
+ $key = get_site_url();
1009
+
1010
+ // If localhost, assign microtime instead of domain.
1011
+ if ( WP_FS__IS_LOCALHOST || false !== strpos( $key, 'localhost' ) ) {
1012
+ $key = microtime();
1013
+ }
1014
+
1015
+ self::$_accounts->set_option( 'unique_id', md5( $key ), true );
1016
+ }
1017
+
1018
+ return self::$_accounts->get_option( 'unique_id' );
1019
+ }
1020
+
1021
+ /**
1022
+ * Generate API connectivity issue message.
1023
+ *
1024
+ * @author Vova Feldman (@svovaf)
1025
+ * @since 1.0.9
1026
+ *
1027
+ * @param mixed $api_result
1028
+ */
1029
+ function _add_connectivity_issue_message( $api_result ) {
1030
+ if ( $this->_enable_anonymous ) {
1031
+ // Don't add message if can run anonymously.
1032
+ return;
1033
+ }
1034
+
1035
+ if ( ! function_exists( 'wp_nonce_url' ) ) {
1036
+ require_once( ABSPATH . 'wp-includes/functions.php' );
1037
+ }
1038
+
1039
+ self::require_pluggable_essentials();
1040
+
1041
+ $current_user = wp_get_current_user();
1042
+ // $admin_email = get_option( 'admin_email' );
1043
+ $admin_email = $current_user->user_email;
1044
+
1045
+ $message = false;
1046
+ if ( is_object( $api_result ) &&
1047
+ isset( $api_result->error )
1048
+ ) {
1049
+ switch ( $api_result->error->code ) {
1050
+ case 'curl_missing':
1051
+ $message = sprintf(
1052
+ __fs( 'x-requires-access-to-api', 'freemius' ) . ' ' .
1053
+ __fs( 'curl-missing-message' ) . ' ' .
1054
+ ' %s',
1055
+ '<b>' . $this->get_plugin_name() . '</b>',
1056
+ sprintf(
1057
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1058
+ sprintf(
1059
+ '<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
1060
+ __fs( 'curl-missing-no-clue-title' ),
1061
+ ' - ' . sprintf(
1062
+ __fs( 'curl-missing-no-clue-desc' ),
1063
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1064
+ )
1065
+ ),
1066
+ sprintf(
1067
+ '<b>%s</b> - %s',
1068
+ __fs( 'sysadmin-title' ),
1069
+ __fs( 'curl-missing-sysadmin-desc' )
1070
+ ),
1071
+ sprintf(
1072
+ '<a href="%s"><b>%s</b></a>%s',
1073
+ 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 ),
1074
+ __fs( 'deactivate-plugin-title' ),
1075
+ ' - ' . __fs( 'deactivate-plugin-desc', 'freemius' )
1076
+ )
1077
+ )
1078
+ );
1079
+ break;
1080
+ case 'cloudflare_ddos_protection':
1081
+ $message = sprintf(
1082
+ __fs( 'x-requires-access-to-api', 'freemius' ) . ' ' .
1083
+ __fs( 'cloudflare-blocks-connection-message' ) . ' ' .
1084
+ __fs( 'happy-to-resolve-issue-asap' ) .
1085
+ ' %s',
1086
+ '<b>' . $this->get_plugin_name() . '</b>',
1087
+ sprintf(
1088
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1089
+ sprintf(
1090
+ '<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
1091
+ __fs( 'fix-issue-title' ),
1092
+ ' - ' . sprintf(
1093
+ __fs( 'fix-issue-desc' ),
1094
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1095
+ )
1096
+ ),
1097
+ sprintf(
1098
+ '<a href="%s" target="_blank"><b>%s</b></a>%s',
1099
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
1100
+ __fs( 'install-previous-title' ),
1101
+ ' - ' . __fs( 'install-previous-desc' )
1102
+ ),
1103
+ sprintf(
1104
+ '<a href="%s"><b>%s</b></a>%s',
1105
+ 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 ),
1106
+ __fs( 'deactivate-plugin-title' ),
1107
+ ' - ' . __fs( 'deactivate-plugin-desc', 'freemius' )
1108
+ )
1109
+ )
1110
+ );
1111
+ break;
1112
+ case 'squid_cache_block':
1113
+ $message = sprintf(
1114
+ __fs( 'x-requires-access-to-api', 'freemius' ) . ' ' .
1115
+ __fs( 'squid-blocks-connection-message' ) .
1116
+ ' %s',
1117
+ '<b>' . $this->get_plugin_name() . '</b>',
1118
+ sprintf(
1119
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1120
+ sprintf(
1121
+ '<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a>%s',
1122
+ __fs( 'squid-no-clue-title' ),
1123
+ ' - ' . sprintf(
1124
+ __fs( 'squid-no-clue-desc' ),
1125
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1126
+ )
1127
+ ),
1128
+ sprintf(
1129
+ '<b>%s</b> - %s',
1130
+ __fs( 'sysadmin-title' ),
1131
+ sprintf(
1132
+ __fs( 'squid-sysadmin-desc' ),
1133
+ // We use a filter since the plugin might require additional API connectivity.
1134
+ '<b>' . implode( ', ', $this->apply_filters( 'api_domains', array( 'api.freemius.com' ) ) ) . '</b>' )
1135
+ ),
1136
+ sprintf(
1137
+ '<a href="%s"><b>%s</b></a>%s',
1138
+ 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 ),
1139
+ __fs( 'deactivate-plugin-title' ),
1140
+ ' - ' . __fs( 'deactivate-plugin-desc', 'freemius' )
1141
+ )
1142
+ )
1143
+ );
1144
+ break;
1145
+ default:
1146
+ $message = __fs( 'connectivity-test-fails-message' );
1147
+ break;
1148
+ }
1149
+ }
1150
+
1151
+ if ( false === $message ) {
1152
+ $message = sprintf(
1153
+ __fs( 'x-requires-access-to-api', 'freemius' ) . ' ' .
1154
+ __fs( 'connectivity-test-fails-message' ) . ' ' .
1155
+ __fs( 'happy-to-resolve-issue-asap' ) .
1156
+ ' %s',
1157
+ '<b>' . $this->get_plugin_name() . '</b>',
1158
+ sprintf(
1159
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1160
+ sprintf(
1161
+ '<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
1162
+ __fs( 'fix-issue-title' ),
1163
+ ' - ' . sprintf(
1164
+ __fs( 'fix-issue-desc' ),
1165
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1166
+ )
1167
+ ),
1168
+ sprintf(
1169
+ '<a href="%s" target="_blank"><b>%s</b></a>%s',
1170
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
1171
+ __fs( 'install-previous-title' ),
1172
+ ' - ' . __fs( 'install-previous-desc' )
1173
+ ),
1174
+ sprintf(
1175
+ '<a href="%s"><b>%s</b></a>%s',
1176
+ 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 ),
1177
+ __fs( 'deactivate-plugin-title' ),
1178
+ ' - ' . __fs( 'deactivate-plugin-desc', 'freemius' )
1179
+ )
1180
+ )
1181
+ );
1182
+ }
1183
+
1184
+ $this->_admin_notices->add_sticky(
1185
+ $message,
1186
+ 'failed_connect_api',
1187
+ __fs( 'oops' ) . '...',
1188
+ 'error'
1189
+ );
1190
+ }
1191
+
1192
+ /**
1193
+ * Get collection of all active plugins.
1194
+ *
1195
+ * @author Vova Feldman (@svovaf)
1196
+ * @since 1.0.9
1197
+ *
1198
+ * @return array[string]array
1199
+ */
1200
+ private function get_active_plugins() {
1201
+ self::require_plugin_essentials();
1202
+
1203
+ $active_plugin = array();
1204
+ $all_plugins = get_plugins();
1205
+ $active_plugins_basenames = get_option( 'active_plugins' );
1206
+
1207
+ foreach ( $active_plugins_basenames as $plugin_basename ) {
1208
+ $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
1209
+ }
1210
+
1211
+ return $active_plugin;
1212
+ }
1213
+
1214
+ /**
1215
+ * Handle user request to resolve connectivity issue.
1216
+ * This method will send an email to Freemius API technical staff for resolution.
1217
+ * The email will contain server's info and installed plugins (might be caching issue).
1218
+ *
1219
+ * @author Vova Feldman (@svovaf)
1220
+ * @since 1.0.9
1221
+ */
1222
+ function _email_about_firewall_issue() {
1223
+ $this->_admin_notices->remove_sticky( 'failed_connect_api' );
1224
+
1225
+ self::require_pluggable_essentials();
1226
+
1227
+ $current_user = wp_get_current_user();
1228
+ $admin_email = $current_user->user_email;
1229
+
1230
+ $ping = $this->get_api_plugin_scope()->ping();
1231
+
1232
+ $error_type = fs_request_get( 'error_type', 'general' );
1233
+
1234
+ switch ( $error_type ) {
1235
+ case 'squid':
1236
+ $title = 'Squid ACL Blocking Issue';
1237
+ break;
1238
+ case 'cloudflare':
1239
+ $title = 'CloudFlare Blocking Issue';
1240
+ break;
1241
+ default:
1242
+ $title = 'API Connectivity Issue';
1243
+ break;
1244
+ }
1245
+
1246
+ $custom_email_sections = array();
1247
+
1248
+ if ( 'squid' === $error_type ) {
1249
+ // Override the 'Site' email section.
1250
+ $custom_email_sections['site'] = array(
1251
+ 'rows' => array(
1252
+ 'hosting_company' => array( 'Hosting Company', fs_request_get( 'hosting_company' ) )
1253
+ )
1254
+ );
1255
+ }
1256
+
1257
+ // Add 'API Error' custom email section.
1258
+ $custom_email_sections['api_error'] = array(
1259
+ 'title' => 'API Error',
1260
+ 'rows' => array(
1261
+ 'ping' => array( is_string( $ping ) ? htmlentities( $ping ) : json_encode( $ping ) )
1262
+ )
1263
+ );
1264
+
1265
+ // Send email with technical details to resolve CloudFlare's firewall unnecessary protection.
1266
+ $this->send_email(
1267
+ 'api@freemius.com', // recipient
1268
+ $title . ' [' . $this->get_plugin_name() . ']', // subject
1269
+ $custom_email_sections,
1270
+ array( "Reply-To: $admin_email <$admin_email>" ) // headers
1271
+ );
1272
+
1273
+ $this->_admin_notices->add_sticky(
1274
+ sprintf(
1275
+ __fs( 'fix-request-sent-message' ),
1276
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1277
+ ),
1278
+ 'server_details_sent'
1279
+ );
1280
+
1281
+ // Action was taken, tell that API connectivity troubleshooting should be off now.
1282
+
1283
+ echo "1";
1284
+ exit;
1285
+ }
1286
+
1287
+ static function _add_firewall_issues_javascript() {
1288
+ $params = array();
1289
+ fs_require_once_template( 'firewall-issues-js.php', $params );
1290
+ }
1291
+
1292
+ #endregion Connectivity Issues ------------------------------------------------------------------
1293
+
1294
+ #region Email ------------------------------------------------------------------
1295
+
1296
+ /**
1297
+ * Generates and sends an HTML email with customizable sections.
1298
+ *
1299
+ * @author Leo Fajardo (@leorw)
1300
+ * @since 1.1.2
1301
+ *
1302
+ * @param string $to_address
1303
+ * @param string $subject
1304
+ * @param array $sections
1305
+ * @param array $headers
1306
+ *
1307
+ * @return bool Whether the email contents were sent successfully.
1308
+ */
1309
+ private function send_email(
1310
+ $to_address,
1311
+ $subject,
1312
+ $sections = array(),
1313
+ $headers = array()
1314
+ ) {
1315
+ $default_sections = $this->get_email_sections();
1316
+
1317
+ // Insert new sections or replace the default email sections.
1318
+ if ( is_array( $sections ) && ! empty( $sections ) ) {
1319
+ foreach ( $sections as $section_id => $custom_section ) {
1320
+ if ( ! isset( $default_sections[ $section_id ] ) ) {
1321
+ // If the section does not exist, add it.
1322
+ $default_sections[ $section_id ] = $custom_section;
1323
+ } else {
1324
+ // If the section already exists, override it.
1325
+ $current_section = $default_sections[ $section_id ];
1326
+
1327
+ // Replace the current section's title if a custom section title exists.
1328
+ if ( isset( $custom_section['title'] ) ) {
1329
+ $current_section['title'] = $custom_section['title'];
1330
+ }
1331
+
1332
+ // Insert new rows under the current section or replace the default rows.
1333
+ if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
1334
+ foreach ( $custom_section['rows'] as $row_id => $row ) {
1335
+ $current_section['rows'][ $row_id ] = $row;
1336
+ }
1337
+ }
1338
+
1339
+ $default_sections[ $section_id ] = $current_section;
1340
+ }
1341
+ }
1342
+ }
1343
+
1344
+ $vars = array( 'sections' => $default_sections );
1345
+ $message = fs_get_template( 'email.php', $vars );
1346
+
1347
+ // Set the type of email to HTML.
1348
+ $headers[] = 'Content-type: text/html';
1349
+
1350
+ $header_string = implode( "\r\n", $headers );
1351
+
1352
+ return wp_mail(
1353
+ $to_address,
1354
+ $subject,
1355
+ $message,
1356
+ $header_string
1357
+ );
1358
+ }
1359
+
1360
+ /**
1361
+ * Generates the data for the sections of the email content.
1362
+ *
1363
+ * @author Leo Fajardo (@leorw)
1364
+ * @since 1.1.2
1365
+ *
1366
+ * @return array
1367
+ */
1368
+ private function get_email_sections() {
1369
+ self::require_pluggable_essentials();
1370
+
1371
+ // Retrieve the current user's information so that we can get the user's email, first name, and last name below.
1372
+ $current_user = wp_get_current_user();
1373
+
1374
+ // Retrieve the cURL version information so that we can get the version number below.
1375
+ $curl_version_information = curl_version();
1376
+
1377
+ $active_plugin = $this->get_active_plugins();
1378
+
1379
+ // Generate the list of active plugins separated by new line.
1380
+ $active_plugin_string = '';
1381
+ foreach ( $active_plugin as $plugin ) {
1382
+ $active_plugin_string .= sprintf(
1383
+ '<a href="%s">%s</a> [v%s]<br>',
1384
+ $plugin['PluginURI'],
1385
+ $plugin['Name'],
1386
+ $plugin['Version']
1387
+ );
1388
+ }
1389
+
1390
+ $server_ip = fs_get_ip();
1391
+
1392
+ // Generate the default email sections.
1393
+ $sections = array(
1394
+ 'sdk' => array(
1395
+ 'title' => 'SDK',
1396
+ 'rows' => array(
1397
+ 'fs_version' => array( 'FS Version', $this->version ),
1398
+ 'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
1399
+ )
1400
+ ),
1401
+ 'plugin' => array(
1402
+ 'title' => 'Plugin',
1403
+ 'rows' => array(
1404
+ 'name' => array( 'Name', $this->get_plugin_name() ),
1405
+ 'version' => array( 'Version', $this->get_plugin_version() )
1406
+ )
1407
+ ),
1408
+ 'site' => array(
1409
+ 'title' => 'Site',
1410
+ 'rows' => array(
1411
+ 'address' => array( 'Address', site_url() ),
1412
+ 'host' => array(
1413
+ 'HTTP_HOST',
1414
+ ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
1415
+ ),
1416
+ 'server_addr' => array(
1417
+ 'SERVER_ADDR',
1418
+ '<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>'
1419
+ )
1420
+ )
1421
+ ),
1422
+ 'user' => array(
1423
+ 'title' => 'User',
1424
+ 'rows' => array(
1425
+ 'email' => array( 'Email', $current_user->user_email ),
1426
+ 'first' => array( 'First', $current_user->user_firstname ),
1427
+ 'last' => array( 'Last', $current_user->user_lastname )
1428
+ )
1429
+ ),
1430
+ 'plugins' => array(
1431
+ 'title' => 'Plugins',
1432
+ 'rows' => array(
1433
+ 'active_plugins' => array( 'Active Plugins', $active_plugin_string )
1434
+ )
1435
+ ),
1436
+ );
1437
+
1438
+ // Allow the sections to be modified by other code.
1439
+ $sections = $this->apply_filters( 'email_template_sections', $sections );
1440
+
1441
+ return $sections;
1442
+ }
1443
+
1444
+ #endregion Email ------------------------------------------------------------------
1445
+
1446
+ #region Initialization ------------------------------------------------------------------
1447
+
1448
+ /**
1449
+ * Init plugin's Freemius instance.
1450
+ *
1451
+ * @author Vova Feldman (@svovaf)
1452
+ * @since 1.0.1
1453
+ *
1454
+ * @param number $id
1455
+ * @param string $public_key
1456
+ * @param bool $is_live
1457
+ * @param bool $is_premium
1458
+ */
1459
+ function init( $id, $public_key, $is_live = true, $is_premium = true ) {
1460
+ $this->_logger->entrance();
1461
+
1462
+ $this->dynamic_init( array(
1463
+ 'id' => $id,
1464
+ 'public_key' => $public_key,
1465
+ 'is_live' => $is_live,
1466
+ 'is_premium' => $is_premium,
1467
+ ) );
1468
+ }
1469
+
1470
+ private function _get_option( &$options, $key, $default = false ) {
1471
+ return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
1472
+ }
1473
+
1474
+ private function _get_bool_option( &$options, $key, $default = false ) {
1475
+ return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
1476
+ }
1477
+
1478
+ private function _get_numeric_option( &$options, $key, $default = false ) {
1479
+ return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
1480
+ }
1481
+
1482
+ /**
1483
+ * Dynamic initiator, originally created to support initiation
1484
+ * with parent_id for add-ons.
1485
+ *
1486
+ * @author Vova Feldman (@svovaf)
1487
+ * @since 1.0.6
1488
+ *
1489
+ * @param array $plugin_info
1490
+ *
1491
+ * @throws Freemius_Exception
1492
+ */
1493
+ function dynamic_init( array $plugin_info ) {
1494
+ $this->_logger->entrance();
1495
+
1496
+ $id = $this->_get_numeric_option( $plugin_info, 'id', false );
1497
+ $public_key = $this->_get_option( $plugin_info, 'public_key', false );
1498
+ $secret_key = $this->_get_option( $plugin_info, 'secret_key', null );
1499
+ $parent_id = $this->_get_numeric_option( $plugin_info, 'parent_id', null );
1500
+ $parent_name = $this->_get_option( $plugin_info, 'parent_name', null );
1501
+
1502
+ if ( isset( $plugin_info['parent'] ) ) {
1503
+ $parent_id = $this->_get_numeric_option( $plugin_info['parent'], 'id', null );
1504
+ // $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
1505
+ // $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
1506
+ $parent_name = $this->_get_option( $plugin_info['parent'], 'name', null );
1507
+ }
1508
+
1509
+ if ( false === $id ) {
1510
+ throw new Freemius_Exception( 'Plugin id parameter is not set.' );
1511
+ }
1512
+ if ( false === $public_key ) {
1513
+ throw new Freemius_Exception( 'Plugin public_key parameter is not set.' );
1514
+ }
1515
+
1516
+ $plugin = ( $this->_plugin instanceof FS_Plugin ) ?
1517
+ $this->_plugin :
1518
+ new FS_Plugin();
1519
+
1520
+ $plugin->update( array(
1521
+ 'id' => $id,
1522
+ 'public_key' => $public_key,
1523
+ 'slug' => $this->_slug,
1524
+ 'parent_plugin_id' => $parent_id,
1525
+ 'version' => $this->get_plugin_version(),
1526
+ 'title' => $this->get_plugin_name(),
1527
+ 'file' => $this->_free_plugin_basename,
1528
+ 'is_premium' => $this->_get_bool_option( $plugin_info, 'is_premium', true ),
1529
+ 'is_live' => $this->_get_bool_option( $plugin_info, 'is_live', true ),
1530
+ // 'secret_key' => $secret_key,
1531
+ ) );
1532
+
1533
+ if ( $plugin->is_updated() ) {
1534
+ // Update plugin details.
1535
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_slug )->store( $plugin );
1536
+ }
1537
+ $this->_plugin->secret_key = $secret_key;
1538
+
1539
+ if ( ! isset( $plugin_info['menu'] ) ) {
1540
+ // Back compatibility to 1.1.2
1541
+ $plugin_info['menu'] = array(
1542
+ 'slug' => isset( $plugin_info['menu_slug'] ) ?
1543
+ $plugin_info['menu_slug'] :
1544
+ $this->_slug
1545
+ );
1546
+ }
1547
+
1548
+ $this->_menu = FS_Admin_Menu_Manager::instance( $this->_slug );
1549
+ $this->_menu->init( $plugin_info['menu'], $this->is_addon() );
1550
+
1551
+ $this->_has_addons = $this->_get_bool_option( $plugin_info, 'has_addons', false );
1552
+ $this->_has_paid_plans = $this->_get_bool_option( $plugin_info, 'has_paid_plans', true );
1553
+ $this->_is_org_compliant = $this->_get_bool_option( $plugin_info, 'is_org_compliant', true );
1554
+ $this->_enable_anonymous = $this->_get_bool_option( $plugin_info, 'enable_anonymous', true );
1555
+
1556
+ if ( ! $this->is_registered() ) {
1557
+ if ( ! $this->has_api_connectivity() ) {
1558
+ if ( is_admin() && $this->_admin_notices->has_sticky( 'failed_connect_api' ) ) {
1559
+ if ( ! $this->_enable_anonymous ) {
1560
+ // If anonymous mode is disabled, add firewall admin-notice message.
1561
+ add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
1562
+
1563
+ add_action( "wp_ajax_{$this->_slug}_resolve_firewall_issues", array(
1564
+ &$this,
1565
+ '_email_about_firewall_issue'
1566
+ ) );
1567
+ }
1568
+ }
1569
+
1570
+ return;
1571
+ }
1572
+
1573
+ // Check if Freemius is on for the current plugin.
1574
+ // This MUST be executed after all the plugin variables has been loaded.
1575
+ if ( ! $this->is_on() ) {
1576
+ return;
1577
+ }
1578
+ }
1579
+
1580
+ if ( false === $this->_background_sync() ) {
1581
+ // If background sync wasn't executed,
1582
+ // and if the plugin declared it has add-ons but
1583
+ // no add-ons found in the local data, then try to sync add-ons.
1584
+ if ( $this->_has_addons &&
1585
+ ! $this->is_addon() &&
1586
+ ( false === $this->get_addons() )
1587
+ ) {
1588
+ $this->_sync_addons();
1589
+ }
1590
+ }
1591
+
1592
+ if ( $this->is_addon() ) {
1593
+ if ( $this->is_parent_plugin_installed() ) {
1594
+ // Link to parent FS.
1595
+ $this->_parent = self::get_instance_by_id( $parent_id );
1596
+
1597
+ // Get parent plugin reference.
1598
+ $this->_parent_plugin = $this->_parent->get_plugin();
1599
+ }
1600
+ }
1601
+
1602
+ if ( is_admin() ) {
1603
+ global $pagenow;
1604
+ if ( 'plugins.php' === $pagenow ) {
1605
+ $this->hook_plugin_action_links();
1606
+ }
1607
+
1608
+ if ( $this->is_addon() ) {
1609
+ if ( ! $this->is_parent_plugin_installed() ) {
1610
+ $this->_admin_notices->add(
1611
+ ( is_string( $parent_name ) ?
1612
+ sprintf( __fs( 'addon-cannot-run-without-x' ), $this->get_plugin_name(), $parent_name ) :
1613
+ sprintf( __fs( 'addon-x-cannot-run-without-parent' ), $this->get_plugin_name() )
1614
+ ),
1615
+ __fs( 'oops' ) . '...',
1616
+ 'error'
1617
+ );
1618
+
1619
+ return;
1620
+ } else {
1621
+ if ( $this->_parent->is_registered() && ! $this->is_registered() ) {
1622
+ // If parent plugin activated, automatically install add-on for the user.
1623
+ $this->_activate_addon_account( $this->_parent );
1624
+ }
1625
+
1626
+ // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
1627
+ if ( $this->is_premium() ) {
1628
+ // Remove add-on download admin-notice.
1629
+ $this->_parent->_admin_notices->remove_sticky( 'addon_plan_upgraded_' . $this->_slug );
1630
+ }
1631
+ }
1632
+ } else {
1633
+ add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
1634
+
1635
+ if ( $this->_has_addons() &&
1636
+ 'plugin-information' === fs_request_get( 'tab', false ) &&
1637
+ $this->get_id() == fs_request_get( 'parent_plugin_id', false )
1638
+ ) {
1639
+ // Remove default plugin information action.
1640
+ remove_all_actions( 'install_plugins_pre_plugin-information' );
1641
+
1642
+ require_once WP_FS__DIR_INCLUDES . '/fs-plugin-functions.php';
1643
+
1644
+ // Override action with custom plugins function for add-ons.
1645
+ add_action( 'install_plugins_pre_plugin-information', 'fs_install_plugin_information' );
1646
+
1647
+ // Override request for plugin information for Add-ons.
1648
+ add_filter( 'fs_plugins_api', array( &$this, '_get_addon_info_filter' ), WP_FS__DEFAULT_PRIORITY, 3 );
1649
+ } else {
1650
+ if ( $this->is_paying() || $this->_has_addons() ) {
1651
+ new FS_Plugin_Updater( $this );
1652
+ }
1653
+ }
1654
+ }
1655
+
1656
+ // if ( $this->is_registered() ||
1657
+ // $this->is_anonymous() ||
1658
+ // $this->is_pending_activation()
1659
+ // ) {
1660
+ // $this->_init_admin();
1661
+ // }
1662
+ }
1663
+
1664
+ $this->do_action( 'initiated' );
1665
+
1666
+ if ( ! $this->is_addon() ) {
1667
+ if ( $this->is_registered() ) {
1668
+ // Fix for upgrade from versions < 1.0.9.
1669
+ if ( ! isset( $this->_storage->activation_timestamp ) ) {
1670
+ $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
1671
+ }
1672
+ if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
1673
+ if ( isset( $this->_storage->prev_is_premium ) ) {
1674
+ add_action( is_admin() ? 'admin_init' : 'init', array(
1675
+ &$this,
1676
+ '_plugin_code_type_changed'
1677
+ ) );
1678
+ } else {
1679
+ // Set for code type for the first time.
1680
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
1681
+ }
1682
+ }
1683
+
1684
+ $this->do_action( 'after_init_plugin_registered' );
1685
+ } else if ( $this->is_anonymous() ) {
1686
+ $this->do_action( 'after_init_plugin_anonymous' );
1687
+ } else if ( $this->is_pending_activation() ) {
1688
+ $this->do_action( 'after_init_plugin_pending_activations' );
1689
+ }
1690
+ } else {
1691
+ if ( $this->is_registered() ) {
1692
+ $this->do_action( 'after_init_addon_registered' );
1693
+ } else if ( $this->is_anonymous() ) {
1694
+ $this->do_action( 'after_init_addon_anonymous' );
1695
+ } else if ( $this->is_pending_activation() ) {
1696
+ $this->do_action( 'after_init_addon_pending_activations' );
1697
+ }
1698
+ }
1699
+ }
1700
+
1701
+ /**
1702
+ * Handles plugin's code type change (free <--> premium).
1703
+ *
1704
+ * @author Vova Feldman (@svovaf)
1705
+ * @since 1.0.9
1706
+ */
1707
+ function _plugin_code_type_changed() {
1708
+ // Send code type changes event.
1709
+ $this->sync_install();
1710
+
1711
+ if ( $this->is_premium() ) {
1712
+ // Activated premium code.
1713
+ $this->do_action( 'after_premium_version_activation' );
1714
+
1715
+ // Remove all sticky messages related to download of the premium version.
1716
+ $this->_admin_notices->remove_sticky( array(
1717
+ 'trial_started',
1718
+ 'plan_upgraded',
1719
+ 'plan_changed',
1720
+ ) );
1721
+
1722
+ $this->_admin_notices->add_sticky(
1723
+ __fs( 'premium-activated-message' ),
1724
+ 'premium_activated',
1725
+ __fs( 'woot' ) . '!'
1726
+ );
1727
+ } else {
1728
+ // Activated free code (after had the premium before).
1729
+ $this->do_action( 'after_free_version_reactivation' );
1730
+
1731
+ if ( $this->is_paying() && ! $this->is_premium() ) {
1732
+ $this->_admin_notices->add_sticky(
1733
+ sprintf(
1734
+ __fs( 'you-have-x-license' ),
1735
+ $this->_site->plan->title
1736
+ ) . ' ' . $this->_get_latest_download_link( sprintf(
1737
+ __fs( 'download-x-version-now' ),
1738
+ $this->_site->plan->title
1739
+ ) ),
1740
+ 'plan_upgraded',
1741
+ __fs( 'yee-haw' ) . '!'
1742
+ );
1743
+ }
1744
+ }
1745
+
1746
+ // Update is_premium of latest version.
1747
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
1748
+ }
1749
+
1750
+ #endregion Initialization ------------------------------------------------------------------
1751
+
1752
+ #region Add-ons -------------------------------------------------------------------------
1753
+
1754
+ /**
1755
+ * Generate add-on plugin information.
1756
+ *
1757
+ * @author Vova Feldman (@svovaf)
1758
+ * @since 1.0.6
1759
+ *
1760
+ * @param array $data
1761
+ * @param string $action
1762
+ * @param object|null $args
1763
+ *
1764
+ * @return array|null
1765
+ */
1766
+ function _get_addon_info_filter( $data, $action = '', $args = null ) {
1767
+ $this->_logger->entrance();
1768
+
1769
+ $parent_plugin_id = fs_request_get( 'parent_plugin_id', false );
1770
+
1771
+ if ( $this->get_id() != $parent_plugin_id ||
1772
+ ( 'plugin_information' !== $action ) ||
1773
+ ! isset( $args->slug )
1774
+ ) {
1775
+ return $data;
1776
+ }
1777
+
1778
+ // Find add-on by slug.
1779
+ $addons = $this->get_addons();
1780
+ $selected_addon = false;
1781
+ foreach ( $addons as $addon ) {
1782
+ if ( $addon->slug == $args->slug ) {
1783
+ $selected_addon = $addon;
1784
+ break;
1785
+ }
1786
+ }
1787
+
1788
+ if ( false === $selected_addon ) {
1789
+ return $data;
1790
+ }
1791
+
1792
+ if ( ! isset( $selected_addon->info ) ) {
1793
+ // Setup some default info.
1794
+ $selected_addon->info = new stdClass();
1795
+ $selected_addon->info->selling_point_0 = 'Selling Point 1';
1796
+ $selected_addon->info->selling_point_1 = 'Selling Point 2';
1797
+ $selected_addon->info->selling_point_2 = 'Selling Point 3';
1798
+ $selected_addon->info->description = '<p>Tell your users all about your add-on</p>';
1799
+ }
1800
+
1801
+ fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
1802
+
1803
+ $data = $args;
1804
+
1805
+ // Fetch as much as possible info from local files.
1806
+ $plugin_local_data = $this->get_plugin_data();
1807
+ $data->name = $selected_addon->title;
1808
+ $data->author = $plugin_local_data['Author'];
1809
+ $view_vars = array( 'plugin' => $selected_addon );
1810
+ $data->sections = array(
1811
+ 'description' => fs_get_template( '/plugin-info/description.php', $view_vars ),
1812
+ );
1813
+
1814
+ if ( ! empty( $selected_addon->info->banner_url ) ) {
1815
+ $data->banners = array(
1816
+ 'low' => $selected_addon->info->banner_url,
1817
+ );
1818
+ }
1819
+
1820
+ if ( ! empty( $selected_addon->info->screenshots ) ) {
1821
+ $view_vars = array( 'screenshots' => $selected_addon->info->screenshots );
1822
+ $data->sections['screenshots'] = fs_get_template( '/plugin-info/screenshots.php', $view_vars );
1823
+ }
1824
+
1825
+ // Load add-on pricing.
1826
+ $has_pricing = false;
1827
+ $has_features = false;
1828
+ $plans = false;
1829
+ $plans_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans.json" );
1830
+ if ( ! isset( $plans_result->error ) ) {
1831
+ $plans = $plans_result->plans;
1832
+ if ( is_array( $plans ) ) {
1833
+ foreach ( $plans as &$plan ) {
1834
+ $pricing_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans/{$plan->id}/pricing.json" );
1835
+ if ( ! isset( $pricing_result->error ) ) {
1836
+ // Update plan's pricing.
1837
+ $plan->pricing = $pricing_result->pricing;
1838
+
1839
+ $has_pricing = true;
1840
+ }
1841
+
1842
+ $features_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans/{$plan->id}/features.json" );
1843
+ if ( ! isset( $features_result->error ) &&
1844
+ is_array( $features_result->features ) &&
1845
+ 0 < count( $features_result->features )
1846
+ ) {
1847
+ // Update plan's pricing.
1848
+ $plan->features = $features_result->features;
1849
+
1850
+ $has_features = true;
1851
+ }
1852
+ }
1853
+ }
1854
+ }
1855
+
1856
+ // Get latest add-on version.
1857
+ $latest = $this->_fetch_latest_version( $selected_addon->id );
1858
+
1859
+ if ( is_object( $latest ) ) {
1860
+ $data->version = $latest->version;
1861
+ $data->last_updated = ! is_null( $latest->updated ) ? $latest->updated : $latest->created;
1862
+ $data->requires = $latest->requires_platform_version;
1863
+ $data->tested = $latest->tested_up_to_version;
1864
+ } else {
1865
+ // Add dummy version.
1866
+ $data->version = '1.0.0';
1867
+
1868
+ // Add message to developer to deploy the plugin through Freemius.
1869
+ }
1870
+
1871
+ $data->checkout_link = $this->checkout_url();
1872
+ $data->download_link = 'https://dummy.com';
1873
+
1874
+ if ( $has_pricing ) {
1875
+ // Add plans to data.
1876
+ $data->plans = $plans;
1877
+
1878
+ if ( $has_features ) {
1879
+ $view_vars = array( 'plans' => $plans );
1880
+ $data->sections['features'] = fs_get_template( '/plugin-info/features.php', $view_vars );
1881
+ }
1882
+ }
1883
+
1884
+ return $data;
1885
+ }
1886
+
1887
+ /**
1888
+ * Check if add-on installed and activated on site.
1889
+ *
1890
+ * @author Vova Feldman (@svovaf)
1891
+ * @since 1.0.6
1892
+ *
1893
+ * @param string|number $slug_or_id
1894
+ *
1895
+ * @return bool
1896
+ */
1897
+ function is_addon_activated( $slug_or_id ) {
1898
+ return self::has_instance( $slug_or_id );
1899
+ }
1900
+
1901
+ /**
1902
+ * Determines if add-on installed.
1903
+ *
1904
+ * NOTE: This is a heuristic and only works if the folder/file named as the slug.
1905
+ *
1906
+ * @author Vova Feldman (@svovaf)
1907
+ * @since 1.0.6
1908
+ *
1909
+ * @param string $slug
1910
+ *
1911
+ * @return bool
1912
+ */
1913
+ function is_addon_installed( $slug ) {
1914
+ return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $slug ) ) );
1915
+ }
1916
+
1917
+ /**
1918
+ * Get add-on basename.
1919
+ *
1920
+ * @author Vova Feldman (@svovaf)
1921
+ * @since 1.0.6
1922
+ *
1923
+ * @param string $slug
1924
+ *
1925
+ * @return string
1926
+ */
1927
+ function get_addon_basename( $slug ) {
1928
+ if ( $this->is_addon_activated( $slug ) ) {
1929
+ self::instance( $slug )->get_plugin_basename();
1930
+ }
1931
+
1932
+ return $slug . '/' . $slug . '.php';
1933
+ }
1934
+
1935
+ /**
1936
+ * Get installed add-ons instances.
1937
+ *
1938
+ * @author Vova Feldman (@svovaf)
1939
+ * @since 1.0.6
1940
+ *
1941
+ * @return Freemius[]
1942
+ */
1943
+ function get_installed_addons() {
1944
+ $installed_addons = array();
1945
+ foreach ( self::$_instances as $slug => $instance ) {
1946
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
1947
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
1948
+ $installed_addons[] = $instance;
1949
+ }
1950
+ }
1951
+ }
1952
+
1953
+ return $installed_addons;
1954
+ }
1955
+
1956
+ /**
1957
+ * Check if any add-ons of the plugin are installed.
1958
+ *
1959
+ * @author Leo Fajardo (@leorw)
1960
+ * @since 1.1.1
1961
+ *
1962
+ * @return bool
1963
+ */
1964
+ function has_installed_addons() {
1965
+ if ( ! $this->_has_addons() ) {
1966
+ return false;
1967
+ }
1968
+
1969
+ foreach ( self::$_instances as $slug => $instance ) {
1970
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
1971
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
1972
+ return true;
1973
+ }
1974
+ }
1975
+ }
1976
+
1977
+ return false;
1978
+ }
1979
+
1980
+ /**
1981
+ * Tell Freemius that the current plugin is an add-on.
1982
+ *
1983
+ * @author Vova Feldman (@svovaf)
1984
+ * @since 1.0.6
1985
+ *
1986
+ * @param number $parent_plugin_id The parent plugin ID
1987
+ */
1988
+ function init_addon( $parent_plugin_id ) {
1989
+ $this->_plugin->parent_plugin_id = $parent_plugin_id;
1990
+ }
1991
+
1992
+ /**
1993
+ * @author Vova Feldman (@svovaf)
1994
+ * @since 1.0.6
1995
+ *
1996
+ * @return bool
1997
+ */
1998
+ function is_addon() {
1999
+ return isset( $this->_plugin->parent_plugin_id ) && is_numeric( $this->_plugin->parent_plugin_id );
2000
+ }
2001
+
2002
+ #endregion ------------------------------------------------------------------
2003
+
2004
+ #region Sandbox ------------------------------------------------------------------
2005
+
2006
+ /**
2007
+ * Set Freemius into sandbox mode for debugging.
2008
+ *
2009
+ * @author Vova Feldman (@svovaf)
2010
+ * @since 1.0.4
2011
+ *
2012
+ * @param string $secret_key
2013
+ */
2014
+ function init_sandbox( $secret_key ) {
2015
+ $this->_plugin->secret_key = $secret_key;
2016
+
2017
+ // Update plugin details.
2018
+ FS_Plugin_Manager::instance( $this->_slug )->update( $this->_plugin, true );
2019
+ }
2020
+
2021
+ /**
2022
+ * Check if running payments in sandbox mode.
2023
+ *
2024
+ * @author Vova Feldman (@svovaf)
2025
+ * @since 1.0.4
2026
+ *
2027
+ * @return bool
2028
+ */
2029
+ function is_payments_sandbox() {
2030
+ return ( ! $this->is_live() ) || isset( $this->_plugin->secret_key );
2031
+ }
2032
+
2033
+ #endregion Sandbox ------------------------------------------------------------------
2034
+
2035
+ /**
2036
+ * Check if running test vs. live plugin.
2037
+ *
2038
+ * @author Vova Feldman (@svovaf)
2039
+ * @since 1.0.5
2040
+ *
2041
+ * @return bool
2042
+ */
2043
+ function is_live() {
2044
+ return $this->_plugin->is_live;
2045
+ }
2046
+
2047
+ /**
2048
+ * Check if the user skipped connecting the account with Freemius.
2049
+ *
2050
+ * @author Vova Feldman (@svovaf)
2051
+ * @since 1.0.7
2052
+ *
2053
+ * @return bool
2054
+ */
2055
+ function is_anonymous() {
2056
+ if ( ! isset( $this->_is_anonymous ) ) {
2057
+ if ( ! isset( $this->_storage->is_anonymous ) ) {
2058
+ // Not skipped.
2059
+ $this->_is_anonymous = false;
2060
+ } else if ( is_bool( $this->_storage->is_anonymous ) ) {
2061
+ // For back compatibility, since the variable was boolean before.
2062
+ $this->_is_anonymous = $this->_storage->is_anonymous;
2063
+
2064
+ // Upgrade stored data format to 1.1.3 format.
2065
+ $this->set_anonymous_mode( $this->_storage->is_anonymous );
2066
+ } else {
2067
+ // Version 1.1.3 and higher.
2068
+ $this->_is_anonymous = $this->_storage->is_anonymous['is'];
2069
+ }
2070
+ }
2071
+
2072
+ return $this->_is_anonymous;
2073
+ }
2074
+
2075
+ /**
2076
+ * Check if user connected his account and install pending email activation.
2077
+ *
2078
+ * @author Vova Feldman (@svovaf)
2079
+ * @since 1.0.7
2080
+ *
2081
+ * @return bool
2082
+ */
2083
+ function is_pending_activation() {
2084
+ return $this->_storage->get( 'is_pending_activation', false );
2085
+ }
2086
+
2087
+ /**
2088
+ * Check if plugin must be WordPress.org compliant.
2089
+ *
2090
+ * @since 1.0.7
2091
+ *
2092
+ * @return bool
2093
+ */
2094
+ function is_org_repo_compliant() {
2095
+ return $this->_is_org_compliant;
2096
+ }
2097
+
2098
+ /**
2099
+ * Background sync every 24 hours.
2100
+ *
2101
+ * @author Vova Feldman (@svovaf)
2102
+ * @since 1.0.4
2103
+ *
2104
+ * @return bool If function actually executed the sync in this iteration.
2105
+ */
2106
+ private function _background_sync() {
2107
+ $this->_logger->entrance();
2108
+
2109
+ // Don't sync license on AJAX calls.
2110
+ if ( $this->is_ajax() ) {
2111
+ return false;
2112
+ }
2113
+
2114
+ // Asked to sync explicitly, no need for background sync.
2115
+ if ( fs_request_is_action( $this->_slug . '_sync_license' ) ) {
2116
+ return false;
2117
+ }
2118
+
2119
+ $sync_timestamp = $this->_storage->get( 'sync_timestamp' );
2120
+
2121
+ if ( ! is_numeric( $sync_timestamp ) || $sync_timestamp >= time() ) {
2122
+ // If updated not set or happens to be in the future, set as if was 24 hours earlier.
2123
+ $sync_timestamp = time() - WP_FS__TIME_24_HOURS_IN_SEC;
2124
+ $this->_storage->sync_timestamp = $sync_timestamp;
2125
+ }
2126
+
2127
+ if ( ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE && fs_request_has( 'background_sync' ) ) ||
2128
+ ( $sync_timestamp <= time() - WP_FS__TIME_24_HOURS_IN_SEC )
2129
+ ) {
2130
+
2131
+ if ( $this->is_registered() ) {
2132
+ // Initiate background plan sync.
2133
+ $this->_sync_license( true );
2134
+
2135
+ // Check for plugin updates.
2136
+ $this->_check_updates( true );
2137
+ }
2138
+
2139
+ if ( ! $this->is_addon() ) {
2140
+ if ( $this->is_registered() || $this->_has_addons ) {
2141
+ // Try to fetch add-ons if registered or if plugin
2142
+ // declared that it has add-ons.
2143
+ $this->_sync_addons();
2144
+ }
2145
+ }
2146
+
2147
+ // Update last sync timestamp.
2148
+ $this->_storage->sync_timestamp = time();
2149
+
2150
+ return true;
2151
+ }
2152
+
2153
+ return false;
2154
+ }
2155
+
2156
+ /**
2157
+ * Show a notice that activation is currently pending.
2158
+ *
2159
+ * @author Vova Feldman (@svovaf)
2160
+ * @since 1.0.7
2161
+ *
2162
+ * @param bool|string $email
2163
+ */
2164
+ function _add_pending_activation_notice( $email = false ) {
2165
+ if ( ! is_string( $email ) ) {
2166
+ $current_user = wp_get_current_user();
2167
+ $email = $current_user->user_email;
2168
+ }
2169
+
2170
+ $this->_admin_notices->add_sticky(
2171
+ sprintf(
2172
+ __fs( 'pending-activation-message' ),
2173
+ '<b>' . $this->get_plugin_name() . '</b>',
2174
+ '<b>' . $email . '</b>'
2175
+ ),
2176
+ 'activation_pending',
2177
+ 'Thanks!'
2178
+ );
2179
+ }
2180
+
2181
+ /**
2182
+ * Check if currently in plugin activation.
2183
+ *
2184
+ * @author Vova Feldman (@svovaf)
2185
+ * @since 1.1.4
2186
+ *
2187
+ * @return bool
2188
+ */
2189
+ function is_plugin_activation() {
2190
+ return get_option( "fs_{$this->_slug}_activated", false );
2191
+ }
2192
+
2193
+ /**
2194
+ *
2195
+ * NOTE: admin_menu action executed before admin_init.
2196
+ *
2197
+ * @author Vova Feldman (@svovaf)
2198
+ * @since 1.0.7
2199
+ */
2200
+ function _admin_init_action() {
2201
+ // Automatically redirect to connect/activation page after plugin activation.
2202
+ if ( $this->is_plugin_activation() ) {
2203
+ delete_option( "fs_{$this->_slug}_activated" );
2204
+ $this->_redirect_on_activation_hook();
2205
+
2206
+ return;
2207
+ }
2208
+
2209
+ if ( fs_request_is_action( $this->_slug . '_skip_activation' ) ) {
2210
+ check_admin_referer( $this->_slug . '_skip_activation' );
2211
+
2212
+ $this->skip_connection();
2213
+
2214
+ if ( fs_redirect( $this->get_after_activation_url( 'after_skip_url' ) ) ) {
2215
+ exit();
2216
+ }
2217
+ }
2218
+
2219
+ if ( ! $this->is_addon() && ! $this->is_registered() && ! $this->is_anonymous() ) {
2220
+ if ( ! $this->is_pending_activation() ) {
2221
+ if ( ! $this->_menu->is_activation_page() ) {
2222
+ if ( $this->is_plugin_new_install() ) {
2223
+ // Show notice for new plugin installations.
2224
+ $this->_admin_notices->add(
2225
+ sprintf(
2226
+ __fs( 'you-are-step-away' ),
2227
+ sprintf( '<b><a href="%s">%s</a></b>',
2228
+ $this->get_activation_url(),
2229
+ sprintf( __fs( 'activate-x-now' ), $this->get_plugin_name() )
2230
+ )
2231
+ ),
2232
+ '',
2233
+ 'update-nag'
2234
+ );
2235
+ } else {
2236
+ if ( ! isset( $this->_storage->sticky_optin_added ) ) {
2237
+ $this->_storage->sticky_optin_added = true;
2238
+
2239
+ // Show notice for new plugin installations.
2240
+ $this->_admin_notices->add_sticky(
2241
+ sprintf(
2242
+ __fs( 'few-plugin-tweaks' ),
2243
+ sprintf( '<b><a href="%s">%s</a></b>',
2244
+ $this->get_activation_url(),
2245
+ sprintf( __fs( 'optin-x-now' ), $this->get_plugin_name() )
2246
+ )
2247
+ ),
2248
+ 'connect_account',
2249
+ '',
2250
+ 'update-nag'
2251
+ );
2252
+ }
2253
+ }
2254
+ }
2255
+ }
2256
+ }
2257
+
2258
+ $this->_add_upgrade_action_link();
2259
+ }
2260
+
2261
+ /**
2262
+ * Enqueue connect requires scripts and styles.
2263
+ *
2264
+ * @author Vova Feldman (@svovaf)
2265
+ * @since 1.1.4
2266
+ */
2267
+ function _enqueue_connect_essentials() {
2268
+ wp_enqueue_script( 'jquery' );
2269
+ wp_enqueue_script( 'json2' );
2270
+
2271
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
2272
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
2273
+
2274
+ fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
2275
+ }
2276
+ /**
2277
+ * Return current page's URL.
2278
+ *
2279
+ * @author Vova Feldman (@svovaf)
2280
+ * @since 1.0.7
2281
+ *
2282
+ * @return string
2283
+ */
2284
+ function current_page_url() {
2285
+ $url = 'http';
2286
+
2287
+ if ( isset( $_SERVER["HTTPS"] ) ) {
2288
+ if ( $_SERVER["HTTPS"] == "on" ) {
2289
+ $url .= "s";
2290
+ }
2291
+ }
2292
+ $url .= "://";
2293
+ if ( $_SERVER["SERVER_PORT"] != "80" ) {
2294
+ $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
2295
+ } else {
2296
+ $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
2297
+ }
2298
+
2299
+ return esc_url( $url );
2300
+ }
2301
+
2302
+ /**
2303
+ * Check if the current page is the plugin's main admin settings page.
2304
+ *
2305
+ * @author Vova Feldman (@svovaf)
2306
+ * @since 1.0.7
2307
+ *
2308
+ * @return bool
2309
+ */
2310
+ function _is_plugin_page() {
2311
+ return fs_is_plugin_page( $this->_menu->get_raw_slug() ) ||
2312
+ fs_is_plugin_page( $this->_slug );
2313
+ }
2314
+
2315
+ /* Events
2316
+ ------------------------------------------------------------------------------------------------------------------*/
2317
+ /**
2318
+ * Delete site install from Database.
2319
+ *
2320
+ * @author Vova Feldman (@svovaf)
2321
+ * @since 1.0.1
2322
+ *
2323
+ * @param bool $store
2324
+ */
2325
+ function _delete_site( $store = true ) {
2326
+ $sites = self::get_all_sites();
2327
+
2328
+ if ( isset( $sites[ $this->_slug ] ) ) {
2329
+ unset( $sites[ $this->_slug ] );
2330
+ }
2331
+
2332
+ self::$_accounts->set_option( 'sites', $sites, $store );
2333
+ }
2334
+
2335
+ /**
2336
+ * Delete plugin's plans information.
2337
+ *
2338
+ * @param bool $store Flush to Database if true.
2339
+ *
2340
+ * @author Vova Feldman (@svovaf)
2341
+ * @since 1.0.9
2342
+ */
2343
+ private function _delete_plans( $store = true ) {
2344
+ $this->_logger->entrance();
2345
+
2346
+ $plans = self::get_all_plans();
2347
+
2348
+ unset( $plans[ $this->_slug ] );
2349
+
2350
+ self::$_accounts->set_option( 'plans', $plans, $store );
2351
+ }
2352
+
2353
+ /**
2354
+ * Delete all plugin licenses.
2355
+ *
2356
+ * @author Vova Feldman (@svovaf)
2357
+ * @since 1.0.9
2358
+ *
2359
+ * @param bool $store
2360
+ * @param string|bool $plugin_slug
2361
+ */
2362
+ private function _delete_licenses( $store = true, $plugin_slug = false ) {
2363
+ $this->_logger->entrance();
2364
+
2365
+ $all_licenses = self::get_all_licenses();
2366
+
2367
+ if ( ! is_string( $plugin_slug ) ) {
2368
+ $plugin_slug = $this->_slug;
2369
+ }
2370
+
2371
+ unset( $all_licenses[ $plugin_slug ] );
2372
+
2373
+ self::$_accounts->set_option( 'licenses', $all_licenses, $store );
2374
+ }
2375
+
2376
+ /**
2377
+ * @author Vova Feldman (@svovaf)
2378
+ * @since 1.1.5
2379
+ *
2380
+ * @return bool
2381
+ */
2382
+ private function is_plugin_new_install()
2383
+ {
2384
+ return isset($this->_storage->is_plugin_new_install) &&
2385
+ $this->_storage->is_plugin_new_install;
2386
+ }
2387
+
2388
+ /**
2389
+ * @author Vova Feldman (@svovaf)
2390
+ * @since 1.1.5
2391
+ *
2392
+ * @return bool
2393
+ */
2394
+ function is_plugin_update() {
2395
+ return ! $this->is_plugin_new_install();
2396
+ }
2397
+
2398
+ /**
2399
+ * Plugin activated hook.
2400
+ *
2401
+ * @author Vova Feldman (@svovaf)
2402
+ * @since 1.0.1
2403
+ *
2404
+ * @uses FS_Api
2405
+ */
2406
+ function _activate_plugin_event_hook() {
2407
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
2408
+
2409
+ if ( ! current_user_can( 'activate_plugins' ) ) {
2410
+ return;
2411
+ }
2412
+
2413
+ // Clear API cache on activation.
2414
+ FS_Api::clear_cache();
2415
+
2416
+ if ( $this->is_registered() ) {
2417
+ // Send re-activation event and sync.
2418
+ $this->sync_install( array(), true );
2419
+
2420
+ /**
2421
+ * @todo Work on automatic deactivation of the Free plugin version. It doesn't work since the slug of the free & premium versions is identical. Therefore, only one instance of Freemius is created and the activation hook of the premium version is not being added.
2422
+ */
2423
+ if ( $this->_plugin_basename !== $this->_free_plugin_basename ) {
2424
+ // Deactivate Free plugin version on premium plugin activation.
2425
+ deactivate_plugins( $this->_free_plugin_basename );
2426
+
2427
+ $this->_admin_notices->add(
2428
+ sprintf( __fs( 'successful-version-upgrade-message' ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
2429
+ __fs( 'woot' ) . '!'
2430
+ );
2431
+ }
2432
+ } else if ( $this->is_anonymous() ) {
2433
+ /**
2434
+ * Reset "skipped" click cache on the following:
2435
+ * 1. Development mode.
2436
+ * 2. If the user skipped the exact same version before.
2437
+ *
2438
+ * @todo 3. If explicitly asked to retry after every activation.
2439
+ */
2440
+ if ( WP_FS__DEV_MODE ||
2441
+ $this->get_plugin_version() == $this->_storage->is_anonymous['version']
2442
+ ) {
2443
+ $this->reset_anonymous_mode();
2444
+ }
2445
+ }
2446
+
2447
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
2448
+ /**
2449
+ * If no previous version of plugin's version exist, it means that it's either
2450
+ * the first time that the plugin installed on the site, or the plugin was installed
2451
+ * before but didn't have Freemius integrated.
2452
+ *
2453
+ * Since register_activation_hook() do NOT fires since 3.1, and only fires
2454
+ * on manual activation via the dashboard, is_plugin_activation() is TRUE
2455
+ * only after immediate activation.
2456
+ *
2457
+ * @since 1.1.4
2458
+ * @link https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
2459
+ */
2460
+ $this->_storage->is_plugin_new_install = empty( $this->_storage->plugin_last_version );
2461
+ }
2462
+
2463
+ if ( $this->has_api_connectivity(true) ) {
2464
+ // Store hint that the plugin was just activated to enable auto-redirection to settings.
2465
+ add_option( "fs_{$this->_slug}_activated", true );
2466
+ }
2467
+ }
2468
+
2469
+ /**
2470
+ * Delete account.
2471
+ *
2472
+ * @author Vova Feldman (@svovaf)
2473
+ * @since 1.0.3
2474
+ *
2475
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
2476
+ */
2477
+ function delete_account_event( $check_user = true ) {
2478
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
2479
+
2480
+ if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
2481
+ return;
2482
+ }
2483
+
2484
+ $this->do_action( 'before_account_delete' );
2485
+
2486
+ // Clear all admin notices.
2487
+ $this->_admin_notices->clear_all_sticky();
2488
+
2489
+ $this->_delete_site( false );
2490
+
2491
+ $this->_delete_plans( false );
2492
+
2493
+ $this->_delete_licenses( false );
2494
+
2495
+ // Delete add-ons related to plugin's account.
2496
+ $this->_delete_account_addons( false );
2497
+
2498
+ // @todo Delete plans and licenses of add-ons.
2499
+
2500
+ self::$_accounts->store();
2501
+
2502
+ // Clear all storage data.
2503
+ $this->_storage->clear_all( true, array(
2504
+ 'connectivity_test',
2505
+ 'is_on',
2506
+ ) );
2507
+
2508
+ // Send delete event.
2509
+ $this->get_api_site_scope()->call( '/', 'delete' );
2510
+
2511
+ $this->do_action( 'after_account_delete' );
2512
+ }
2513
+
2514
+ /**
2515
+ * Plugin deactivation hook.
2516
+ *
2517
+ * @author Vova Feldman (@svovaf)
2518
+ * @since 1.0.1
2519
+ */
2520
+ function _deactivate_plugin_hook() {
2521
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
2522
+
2523
+ if ( ! current_user_can( 'activate_plugins' ) ) {
2524
+ return;
2525
+ }
2526
+
2527
+ $this->_admin_notices->clear_all_sticky();
2528
+
2529
+ if ( ! $this->has_api_connectivity() ) {
2530
+ // Reset connectivity test cache.
2531
+ unset( $this->_storage->connectivity_test );
2532
+ }
2533
+
2534
+ if (!isset($this->_storage->is_plugin_new_install)) {
2535
+ // Remember that plugin was already installed.
2536
+ $this->_storage->is_plugin_new_install = false;
2537
+ }
2538
+
2539
+ if ( $this->is_registered() ) {
2540
+ // Send deactivation event.
2541
+ $this->sync_install( array(
2542
+ 'is_active' => false,
2543
+ ) );
2544
+ }
2545
+
2546
+ // Clear API cache on deactivation.
2547
+ FS_Api::clear_cache();
2548
+ }
2549
+
2550
+ /**
2551
+ * @author Vova Feldman (@svovaf)
2552
+ * @since 1.1.3
2553
+ *
2554
+ * @param bool $is_anonymous
2555
+ */
2556
+ private function set_anonymous_mode( $is_anonymous = true ) {
2557
+ // Store information regarding skip to try and opt-in the user
2558
+ // again in the future.
2559
+ $this->_storage->is_anonymous = array(
2560
+ 'is' => $is_anonymous,
2561
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
2562
+ 'version' => $this->get_plugin_version(),
2563
+ );
2564
+
2565
+ // Update anonymous mode cache.
2566
+ $this->_is_anonymous = $is_anonymous;
2567
+ }
2568
+
2569
+ /**
2570
+ * @author Vova Feldman (@svovaf)
2571
+ * @since 1.1.3
2572
+ */
2573
+ private function reset_anonymous_mode() {
2574
+ unset( $this->_storage->is_anonymous );
2575
+ }
2576
+
2577
+ /**
2578
+ * Skip account connect, and set anonymous mode.
2579
+ *
2580
+ * @author Vova Feldman (@svovaf)
2581
+ * @since 1.1.1
2582
+ */
2583
+ private function skip_connection() {
2584
+ $this->_logger->entrance();
2585
+
2586
+ $this->_admin_notices->remove_sticky( 'connect_account' );
2587
+
2588
+ $this->set_anonymous_mode();
2589
+
2590
+ // Send anonymous skip event.
2591
+ // No user identified info nor any tracking will be sent after the user skips the opt-in.
2592
+ $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
2593
+ 'uid' => $this->get_anonymous_id(),
2594
+ ) );
2595
+ }
2596
+
2597
+ /**
2598
+ * Plugin version update hook.
2599
+ *
2600
+ * @author Vova Feldman (@svovaf)
2601
+ * @since 1.0.4
2602
+ */
2603
+ private function update_plugin_version_event() {
2604
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
2605
+
2606
+ $this->_site->version = $this->get_plugin_version();
2607
+
2608
+ // Send update event.
2609
+ $site = $this->send_install_update( array(), true );
2610
+
2611
+ if ( false !== $site && ! $this->is_api_error( $site ) ) {
2612
+ $this->_site = new FS_Site( $site );
2613
+ $this->_site->plan = $this->_get_plan_by_id( $site->plan_id );
2614
+ $this->_store_site( true );
2615
+ }
2616
+ }
2617
+
2618
+ /**
2619
+ * Update install details.
2620
+ *
2621
+ * @author Vova Feldman (@svovaf)
2622
+ * @since 1.1.2
2623
+ *
2624
+ * @param string[] string $override
2625
+ *
2626
+ * @return array
2627
+ */
2628
+ private function get_install_data_for_api( $override = array() ) {
2629
+ return array_merge( array(
2630
+ 'version' => $this->get_plugin_version(),
2631
+ 'is_premium' => $this->is_premium(),
2632
+ 'language' => get_bloginfo( 'language' ),
2633
+ 'charset' => get_bloginfo( 'charset' ),
2634
+ 'platform_version' => get_bloginfo( 'version' ),
2635
+ 'programming_language_version' => phpversion(),
2636
+ 'title' => get_bloginfo( 'name' ),
2637
+ 'url' => get_site_url(),
2638
+ // Special params.
2639
+ 'is_active' => true,
2640
+ 'is_uninstalled' => false,
2641
+ ), $override );
2642
+ }
2643
+
2644
+ /**
2645
+ * Update install only if changed.
2646
+ *
2647
+ * @author Vova Feldman (@svovaf)
2648
+ * @since 1.0.9
2649
+ *
2650
+ * @param string[] string $override
2651
+ * @param bool $flush
2652
+ *
2653
+ * @return false|object|string
2654
+ */
2655
+ private function send_install_update( $override = array(), $flush = false ) {
2656
+ $this->_logger->entrance();
2657
+
2658
+ $check_properties = $this->get_install_data_for_api( $override );
2659
+
2660
+ if ( $flush ) {
2661
+ $params = $check_properties;
2662
+ } else {
2663
+ $params = array();
2664
+ $special = array();
2665
+ $special_override = false;
2666
+
2667
+ foreach ( $check_properties as $p => $v ) {
2668
+ if ( property_exists( $this->_site, $p ) ) {
2669
+ if ( ! empty( $this->_site->{$p} ) &&
2670
+ $this->_site->{$p} != $v
2671
+ ) {
2672
+ $this->_site->{$p} = $v;
2673
+ $params[ $p ] = $v;
2674
+ }
2675
+ } else {
2676
+ $special[ $p ] = $v;
2677
+
2678
+ if ( isset( $override[ $p ] ) ) {
2679
+ $special_override = true;
2680
+ }
2681
+ }
2682
+ }
2683
+
2684
+ if ( $special_override || 0 < count( $params ) ) {
2685
+ // Add special params only if has at least one
2686
+ // standard param, or if explicitly requested to
2687
+ // override a special param or a pram which is not exist
2688
+ // in the install object.
2689
+ $params = array_merge( $params, $special );
2690
+ }
2691
+ }
2692
+
2693
+ if ( 0 < count( $params ) ) {
2694
+ // Send updated values to FS.
2695
+ return $this->get_api_site_scope()->call( '/', 'put', $params );
2696
+ }
2697
+
2698
+ return false;
2699
+ }
2700
+
2701
+ /**
2702
+ * Update install only if changed.
2703
+ *
2704
+ * @author Vova Feldman (@svovaf)
2705
+ * @since 1.0.9
2706
+ *
2707
+ * @param string[] string $override
2708
+ * @param bool $flush
2709
+ *
2710
+ * @return false|object|string
2711
+ */
2712
+ private function sync_install( $override = array(), $flush = false ) {
2713
+ $this->_logger->entrance();
2714
+
2715
+ $site = $this->send_install_update( $override, $flush );
2716
+
2717
+ if ( false === $site ) {
2718
+ // No sync required.
2719
+ return;
2720
+ }
2721
+
2722
+ if ( $this->is_api_error( $site ) ) {
2723
+ // Failed to sync, don't update locally.
2724
+ return;
2725
+ }
2726
+
2727
+ $plan = $this->get_plan();
2728
+ $this->_site = new FS_Site( $site );
2729
+ $this->_site->plan = $plan;
2730
+
2731
+ $this->_store_site( true );
2732
+ }
2733
+
2734
+ /**
2735
+ * Plugin uninstall hook.
2736
+ *
2737
+ * @author Vova Feldman (@svovaf)
2738
+ * @since 1.0.1
2739
+ *
2740
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
2741
+ */
2742
+ function _uninstall_plugin_event( $check_user = true ) {
2743
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
2744
+
2745
+ if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
2746
+ return;
2747
+ }
2748
+
2749
+ $params = array();
2750
+ if ( isset( $this->_storage->uninstall_reason ) ) {
2751
+ $params['reason_id'] = $this->_storage->uninstall_reason->id;
2752
+ $params['reason_info'] = $this->_storage->uninstall_reason->info;
2753
+ }
2754
+
2755
+ if ( ! $this->is_registered() && isset( $this->_storage->uninstall_reason ) ) {
2756
+ // Send anonymous uninstall event only if user submitted a feedback.
2757
+ $params['uid'] = $this->get_anonymous_id();
2758
+ $this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params );
2759
+ } else {
2760
+ // Send uninstall event.
2761
+ $this->send_install_update( array_merge( $params, array(
2762
+ 'is_active' => false,
2763
+ 'is_uninstalled' => true,
2764
+ ) ) );
2765
+ }
2766
+
2767
+ // @todo Decide if we want to delete plugin information from db.
2768
+ }
2769
+
2770
+ /**
2771
+ * @author Vova Feldman (@svovaf)
2772
+ * @since 1.1.1
2773
+ *
2774
+ * @return string
2775
+ */
2776
+ private function premium_plugin_basename() {
2777
+ return preg_replace( '/\//', '-premium/', $this->_free_plugin_basename, 1 );
2778
+ }
2779
+
2780
+ /**
2781
+ * Uninstall plugin hook. Called only when connected his account with Freemius for active sites tracking.
2782
+ *
2783
+ * @author Vova Feldman (@svovaf)
2784
+ * @since 1.0.2
2785
+ */
2786
+ public static function _uninstall_plugin_hook() {
2787
+ self::_load_required_static();
2788
+
2789
+ self::$_static_logger->entrance();
2790
+
2791
+ if ( ! current_user_can( 'activate_plugins' ) ) {
2792
+ return;
2793
+ }
2794
+
2795
+ $plugin_file = substr( current_filter(), strlen( 'uninstall_' ) );
2796
+
2797
+ self::$_static_logger->info( 'plugin = ' . $plugin_file );
2798
+
2799
+ define( 'WP_FS__UNINSTALL_MODE', true );
2800
+
2801
+ $fs = self::get_instance_by_file( $plugin_file );
2802
+
2803
+ if ( is_object( $fs ) ) {
2804
+ self::require_plugin_essentials();
2805
+
2806
+ if ( is_plugin_active( $fs->_free_plugin_basename ) ||
2807
+ is_plugin_active( $fs->premium_plugin_basename() )
2808
+ ) {
2809
+ // Deleting Free or Premium plugin version while the other version still installed.
2810
+ return;
2811
+ }
2812
+
2813
+ $fs->_uninstall_plugin_event();
2814
+
2815
+ $fs->do_action( 'after_uninstall' );
2816
+ }
2817
+ }
2818
+
2819
+ #region Plugin Information ------------------------------------------------------------------
2820
+
2821
+ /**
2822
+ * Load WordPress core plugin.php essential module.
2823
+ *
2824
+ * @author Vova Feldman (@svovaf)
2825
+ * @since 1.1.1
2826
+ */
2827
+ private static function require_plugin_essentials() {
2828
+ if ( ! function_exists( 'get_plugins' ) ) {
2829
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
2830
+ }
2831
+ }
2832
+
2833
+ /**
2834
+ * Load WordPress core pluggable.php module.
2835
+ *
2836
+ * @author Vova Feldman (@svovaf)
2837
+ * @since 1.1.2
2838
+ */
2839
+ private static function require_pluggable_essentials() {
2840
+ if ( ! function_exists( 'wp_get_current_user' ) ) {
2841
+ require_once( ABSPATH . 'wp-includes/pluggable.php' );
2842
+ }
2843
+ }
2844
+
2845
+ /**
2846
+ * Return plugin data.
2847
+ *
2848
+ * @author Vova Feldman (@svovaf)
2849
+ * @since 1.0.1
2850
+ *
2851
+ * @return array
2852
+ */
2853
+ function get_plugin_data() {
2854
+ if ( ! isset( $this->_plugin_data ) ) {
2855
+ self::require_plugin_essentials();
2856
+
2857
+ $this->_plugin_data = get_plugin_data( $this->_plugin_main_file_path );
2858
+ }
2859
+
2860
+ return $this->_plugin_data;
2861
+ }
2862
+
2863
+ /**
2864
+ * @author Vova Feldman (@svovaf)
2865
+ * @since 1.0.1
2866
+ *
2867
+ * @return string Plugin slug.
2868
+ */
2869
+ function get_slug() {
2870
+ return $this->_slug;
2871
+ }
2872
+
2873
+ /**
2874
+ * @author Vova Feldman (@svovaf)
2875
+ * @since 1.0.1
2876
+ *
2877
+ * @return number Plugin ID.
2878
+ */
2879
+ function get_id() {
2880
+ return $this->_plugin->id;
2881
+ }
2882
+
2883
+ /**
2884
+ * @author Vova Feldman (@svovaf)
2885
+ * @since 1.0.1
2886
+ *
2887
+ * @return string Plugin public key.
2888
+ */
2889
+ function get_public_key() {
2890
+ return $this->_plugin->public_key;
2891
+ }
2892
+
2893
+ /**
2894
+ * Will be available only on sandbox mode.
2895
+ *
2896
+ * @author Vova Feldman (@svovaf)
2897
+ * @since 1.0.4
2898
+ *
2899
+ * @return mixed Plugin secret key.
2900
+ */
2901
+ function get_secret_key() {
2902
+ return $this->_plugin->secret_key;
2903
+ }
2904
+
2905
+ /**
2906
+ * @author Vova Feldman (@svovaf)
2907
+ * @since 1.1.1
2908
+ *
2909
+ * @return bool
2910
+ */
2911
+ function has_secret_key() {
2912
+ return ! empty( $this->_plugin->secret_key );
2913
+ }
2914
+
2915
+ /**
2916
+ * @author Vova Feldman (@svovaf)
2917
+ * @since 1.0.9
2918
+ *
2919
+ * @return string
2920
+ */
2921
+ function get_plugin_name() {
2922
+ $this->_logger->entrance();
2923
+
2924
+ if ( ! isset( $this->_plugin_name ) ) {
2925
+ $plugin_data = $this->get_plugin_data();
2926
+
2927
+ // Get name.
2928
+ $this->_plugin_name = $plugin_data['Name'];
2929
+
2930
+ // Check if plugin name contains [Premium] suffix and remove it.
2931
+ $suffix = '[premium]';
2932
+ $suffix_len = strlen( $suffix );
2933
+
2934
+ if ( strlen( $plugin_data['Name'] ) > $suffix_len &&
2935
+ $suffix === substr( strtolower( $plugin_data['Name'] ), - $suffix_len )
2936
+ ) {
2937
+ $this->_plugin_name = substr( $plugin_data['Name'], 0, - $suffix_len );
2938
+ }
2939
+
2940
+ $this->_logger->departure( 'Name = ' . $this->_plugin_name );
2941
+ }
2942
+
2943
+ return $this->_plugin_name;
2944
+ }
2945
+
2946
+ /**
2947
+ * @author Vova Feldman (@svovaf)
2948
+ * @since 1.0.0
2949
+ *
2950
+ * @return string
2951
+ */
2952
+ function get_plugin_version() {
2953
+ $this->_logger->entrance();
2954
+
2955
+ $plugin_data = $this->get_plugin_data();
2956
+
2957
+ $this->_logger->departure( 'Version = ' . $plugin_data['Version'] );
2958
+
2959
+ return $plugin_data['Version'];
2960
+ }
2961
+
2962
+ /**
2963
+ * @author Vova Feldman (@svovaf)
2964
+ * @since 1.0.4
2965
+ *
2966
+ * @return string
2967
+ */
2968
+ function get_plugin_basename() {
2969
+ return $this->_plugin_basename;
2970
+ }
2971
+
2972
+ function get_plugin_folder_name() {
2973
+ $this->_logger->entrance();
2974
+
2975
+ $plugin_folder = $this->_plugin_basename;
2976
+
2977
+ while ( '.' !== dirname( $plugin_folder ) ) {
2978
+ $plugin_folder = dirname( $plugin_folder );
2979
+ }
2980
+
2981
+ $this->_logger->departure( 'Folder Name = ' . $plugin_folder );
2982
+
2983
+ return $plugin_folder;
2984
+ }
2985
+
2986
+ #endregion ------------------------------------------------------------------
2987
+
2988
+ /* Account
2989
+ ------------------------------------------------------------------------------------------------------------------*/
2990
+
2991
+ /**
2992
+ * Find plugin's slug by plugin's basename.
2993
+ *
2994
+ * @author Vova Feldman (@svovaf)
2995
+ * @since 1.0.9
2996
+ *
2997
+ * @param string $plugin_base_name
2998
+ *
2999
+ * @return false|string
3000
+ */
3001
+ private static function find_slug_by_basename( $plugin_base_name ) {
3002
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
3003
+
3004
+ if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) {
3005
+ return false;
3006
+ }
3007
+
3008
+ return $file_slug_map[ $plugin_base_name ];
3009
+ }
3010
+
3011
+ /**
3012
+ * Store the map between the plugin's basename to the slug.
3013
+ *
3014
+ * @author Vova Feldman (@svovaf)
3015
+ * @since 1.0.9
3016
+ */
3017
+ private function store_file_slug_map() {
3018
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
3019
+
3020
+ if ( ! array( $file_slug_map ) ) {
3021
+ $file_slug_map = array();
3022
+ }
3023
+
3024
+ if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) ||
3025
+ $file_slug_map[ $this->_plugin_basename ] !== $this->_slug
3026
+ ) {
3027
+ $file_slug_map[ $this->_plugin_basename ] = $this->_slug;
3028
+ self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
3029
+ }
3030
+ }
3031
+
3032
+ /**
3033
+ * @return FS_User[]
3034
+ */
3035
+ static function get_all_users() {
3036
+ $users = self::$_accounts->get_option( 'users', array() );
3037
+
3038
+ if ( ! is_array( $users ) ) {
3039
+ $users = array();
3040
+ }
3041
+
3042
+ return $users;
3043
+ }
3044
+
3045
+ /**
3046
+ * @return FS_Site[]
3047
+ */
3048
+ private static function get_all_sites() {
3049
+ $sites = self::$_accounts->get_option( 'sites', array() );
3050
+
3051
+ if ( ! is_array( $sites ) ) {
3052
+ $sites = array();
3053
+ }
3054
+
3055
+ return $sites;
3056
+ }
3057
+
3058
+ /**
3059
+ * @author Vova Feldman (@svovaf)
3060
+ * @since 1.0.6
3061
+ *
3062
+ * @return FS_Plugin_License[]
3063
+ */
3064
+ private static function get_all_licenses() {
3065
+ $licenses = self::$_accounts->get_option( 'licenses', array() );
3066
+
3067
+ if ( ! is_array( $licenses ) ) {
3068
+ $licenses = array();
3069
+ }
3070
+
3071
+ return $licenses;
3072
+ }
3073
+
3074
+ /**
3075
+ * @return FS_Plugin_Plan[]
3076
+ */
3077
+ private static function get_all_plans() {
3078
+ $plans = self::$_accounts->get_option( 'plans', array() );
3079
+
3080
+ if ( ! is_array( $plans ) ) {
3081
+ $plans = array();
3082
+ }
3083
+
3084
+ return $plans;
3085
+ }
3086
+
3087
+ /**
3088
+ * @author Vova Feldman (@svovaf)
3089
+ * @since 1.0.4
3090
+ *
3091
+ * @return FS_Plugin_Tag[]
3092
+ */
3093
+ private static function get_all_updates() {
3094
+ $updates = self::$_accounts->get_option( 'updates', array() );
3095
+
3096
+ if ( ! is_array( $updates ) ) {
3097
+ $updates = array();
3098
+ }
3099
+
3100
+ return $updates;
3101
+ }
3102
+
3103
+ /**
3104
+ * @author Vova Feldman (@svovaf)
3105
+ * @since 1.0.6
3106
+ *
3107
+ * @return FS_Plugin[]|false
3108
+ */
3109
+ private static function get_all_addons() {
3110
+ $addons = self::$_accounts->get_option( 'addons', array() );
3111
+
3112
+ if ( ! is_array( $addons ) ) {
3113
+ $addons = array();
3114
+ }
3115
+
3116
+ return $addons;
3117
+ }
3118
+
3119
+ /**
3120
+ * @author Vova Feldman (@svovaf)
3121
+ * @since 1.0.6
3122
+ *
3123
+ * @return FS_Plugin[]|false
3124
+ */
3125
+ private static function get_all_account_addons() {
3126
+ $addons = self::$_accounts->get_option( 'account_addons', array() );
3127
+
3128
+ if ( ! is_array( $addons ) ) {
3129
+ $addons = array();
3130
+ }
3131
+
3132
+ return $addons;
3133
+ }
3134
+
3135
+ /**
3136
+ * Check if user is registered.
3137
+ *
3138
+ * @author Vova Feldman (@svovaf)
3139
+ * @since 1.0.1
3140
+ * @return bool
3141
+ */
3142
+ function is_registered() {
3143
+ return is_object( $this->_user );
3144
+ }
3145
+
3146
+ /**
3147
+ * @author Vova Feldman (@svovaf)
3148
+ * @since 1.0.4
3149
+ *
3150
+ * @return FS_Plugin
3151
+ */
3152
+ function get_plugin() {
3153
+ return $this->_plugin;
3154
+ }
3155
+
3156
+ /**
3157
+ * @author Vova Feldman (@svovaf)
3158
+ * @since 1.0.3
3159
+ *
3160
+ * @return FS_User
3161
+ */
3162
+ function get_user() {
3163
+ return $this->_user;
3164
+ }
3165
+
3166
+ /**
3167
+ * @author Vova Feldman (@svovaf)
3168
+ * @since 1.0.3
3169
+ *
3170
+ * @return FS_Site
3171
+ */
3172
+ function get_site() {
3173
+ return $this->_site;
3174
+ }
3175
+
3176
+ /**
3177
+ * @author Vova Feldman (@svovaf)
3178
+ * @since 1.0.6
3179
+ *
3180
+ * @return FS_Plugin[]|false
3181
+ */
3182
+ function get_addons() {
3183
+ $this->_logger->entrance();
3184
+
3185
+ $addons = self::get_all_addons();
3186
+
3187
+ if ( ! is_array( $addons ) ||
3188
+ ! isset( $addons[ $this->_plugin->id ] ) ||
3189
+ ! is_array( $addons[ $this->_plugin->id ] ) ||
3190
+ 0 === count( $addons[ $this->_plugin->id ] )
3191
+ ) {
3192
+ return false;
3193
+ }
3194
+
3195
+ return $addons[ $this->_plugin->id ];
3196
+ }
3197
+
3198
+ /**
3199
+ * @author Vova Feldman (@svovaf)
3200
+ * @since 1.0.6
3201
+ *
3202
+ * @return FS_Plugin[]|false
3203
+ */
3204
+ function get_account_addons() {
3205
+ $this->_logger->entrance();
3206
+
3207
+ $addons = self::get_all_account_addons();
3208
+
3209
+ if ( ! is_array( $addons ) ||
3210
+ ! isset( $addons[ $this->_plugin->id ] ) ||
3211
+ ! is_array( $addons[ $this->_plugin->id ] ) ||
3212
+ 0 === count( $addons[ $this->_plugin->id ] )
3213
+ ) {
3214
+ return false;
3215
+ }
3216
+
3217
+ return $addons[ $this->_plugin->id ];
3218
+ }
3219
+
3220
+ /**
3221
+ * Get add-on by ID (from local data).
3222
+ *
3223
+ * @author Vova Feldman (@svovaf)
3224
+ * @since 1.0.6
3225
+ *
3226
+ * @param number $id
3227
+ *
3228
+ * @return FS_Plugin|false
3229
+ */
3230
+ function get_addon( $id ) {
3231
+ $this->_logger->entrance();
3232
+
3233
+ $addons = $this->get_addons();
3234
+
3235
+ if ( is_array( $addons ) ) {
3236
+ foreach ( $addons as $addon ) {
3237
+ if ( $id == $addon->id ) {
3238
+ return $addon;
3239
+ }
3240
+ }
3241
+ }
3242
+
3243
+ return false;
3244
+ }
3245
+
3246
+ /**
3247
+ * Get add-on by slug (from local data).
3248
+ *
3249
+ * @author Vova Feldman (@svovaf)
3250
+ * @since 1.0.6
3251
+ *
3252
+ * @param string $slug
3253
+ *
3254
+ * @return FS_Plugin|false
3255
+ */
3256
+ function get_addon_by_slug( $slug ) {
3257
+ $this->_logger->entrance();
3258
+
3259
+ $addons = $this->get_addons();
3260
+
3261
+ if ( is_array( $addons ) ) {
3262
+ foreach ( $addons as $addon ) {
3263
+ if ( $slug == $addon->slug ) {
3264
+ return $addon;
3265
+ }
3266
+ }
3267
+ }
3268
+
3269
+ return false;
3270
+ }
3271
+
3272
+ #region Plans & Licensing ------------------------------------------------------------------
3273
+
3274
+ /**
3275
+ * Check if running premium plugin code.
3276
+ *
3277
+ * @author Vova Feldman (@svovaf)
3278
+ * @since 1.0.5
3279
+ *
3280
+ * @return bool
3281
+ */
3282
+ function is_premium() {
3283
+ return $this->_plugin->is_premium;
3284
+ }
3285
+
3286
+ /**
3287
+ * Get site's plan ID.
3288
+ *
3289
+ * @author Vova Feldman (@svovaf)
3290
+ * @since 1.0.2
3291
+ *
3292
+ * @return number
3293
+ */
3294
+ function get_plan_id() {
3295
+ return $this->_site->plan->id;
3296
+ }
3297
+
3298
+ /**
3299
+ * Get site's plan title.
3300
+ *
3301
+ * @author Vova Feldman (@svovaf)
3302
+ * @since 1.0.2
3303
+ *
3304
+ * @return string
3305
+ */
3306
+ function get_plan_title() {
3307
+ return $this->_site->plan->title;
3308
+ }
3309
+
3310
+ /**
3311
+ * @author Vova Feldman (@svovaf)
3312
+ * @since 1.0.9
3313
+ *
3314
+ * @return FS_Plugin_Plan
3315
+ */
3316
+ function get_plan() {
3317
+ return is_object( $this->_site->plan ) ? $this->_site->plan : false;
3318
+ }
3319
+
3320
+ /**
3321
+ * @author Vova Feldman (@svovaf)
3322
+ * @since 1.0.3
3323
+ *
3324
+ * @return bool
3325
+ */
3326
+ function is_trial() {
3327
+ $this->_logger->entrance();
3328
+
3329
+ if ( ! $this->is_registered() ) {
3330
+ return false;
3331
+ }
3332
+
3333
+ // Paid plan beats trial.
3334
+ return $this->is_free_plan() && $this->_site->is_trial();
3335
+ }
3336
+
3337
+ /**
3338
+ * Check if trial already utilized.
3339
+ *
3340
+ * @since 1.0.9
3341
+ *
3342
+ * @return bool
3343
+ */
3344
+ function is_trial_utilized() {
3345
+ $this->_logger->entrance();
3346
+
3347
+ if ( ! $this->is_registered() ) {
3348
+ return false;
3349
+ }
3350
+
3351
+ return $this->_site->is_trial_utilized();
3352
+ }
3353
+
3354
+ /**
3355
+ * Get trial plan information (if in trial).
3356
+ *
3357
+ * @author Vova Feldman (@svovaf)
3358
+ * @since 1.0.9
3359
+ *
3360
+ * @return bool|FS_Plugin_Plan
3361
+ */
3362
+ function get_trial_plan() {
3363
+ $this->_logger->entrance();
3364
+
3365
+ if ( ! $this->is_trial() ) {
3366
+ return false;
3367
+ }
3368
+
3369
+ return $this->_storage->trial_plan;
3370
+ }
3371
+
3372
+ /**
3373
+ * Check if the user has an activated and valid paid license on current plugin's install.
3374
+ *
3375
+ * @since 1.0.9
3376
+ *
3377
+ * @return bool
3378
+ */
3379
+ function is_paying() {
3380
+ $this->_logger->entrance();
3381
+
3382
+ if ( ! $this->is_registered() ) {
3383
+ return false;
3384
+ }
3385
+
3386
+ return (
3387
+ ! $this->is_trial() &&
3388
+ 'free' !== $this->_site->plan->name &&
3389
+ $this->has_features_enabled_license()
3390
+ );
3391
+ }
3392
+
3393
+ /**
3394
+ * @author Vova Feldman (@svovaf)
3395
+ * @since 1.0.4
3396
+ *
3397
+ * @return bool
3398
+ */
3399
+ function is_free_plan() {
3400
+ if ( ! $this->is_registered() ) {
3401
+ return true;
3402
+ }
3403
+
3404
+ return (
3405
+ 'free' === $this->_site->plan->name ||
3406
+ ! $this->has_features_enabled_license()
3407
+ );
3408
+ }
3409
+
3410
+ /**
3411
+ * @author Vova Feldman (@svovaf)
3412
+ * @since 1.0.5
3413
+ *
3414
+ * @return bool
3415
+ */
3416
+ function _has_premium_license() {
3417
+ $this->_logger->entrance();
3418
+
3419
+ $premium_license = $this->_get_available_premium_license();
3420
+
3421
+ return ( false !== $premium_license );
3422
+ }
3423
+
3424
+ /**
3425
+ * @author Vova Feldman (@svovaf)
3426
+ * @since 1.0.5
3427
+ *
3428
+ * @return FS_Plugin_License
3429
+ */
3430
+ function _get_available_premium_license() {
3431
+ $this->_logger->entrance();
3432
+
3433
+ if ( is_array( $this->_licenses ) ) {
3434
+ foreach ( $this->_licenses as $license ) {
3435
+ if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
3436
+ return $license;
3437
+ }
3438
+ }
3439
+ }
3440
+
3441
+ return false;
3442
+ }
3443
+
3444
+ /**
3445
+ * Sync local plugin plans with remote server.
3446
+ *
3447
+ * @author Vova Feldman (@svovaf)
3448
+ * @since 1.0.5
3449
+ *
3450
+ * @return FS_Plugin_Plan[]|object
3451
+ */
3452
+ function _sync_plans() {
3453
+ $plans = $this->_fetch_plugin_plans();
3454
+ if ( ! $this->is_api_error( $plans ) ) {
3455
+ $this->_plans = $plans;
3456
+ $this->_store_plans();
3457
+ }
3458
+
3459
+ $this->do_action( 'after_plans_sync', $plans );
3460
+
3461
+ return $this->_plans;
3462
+ }
3463
+
3464
+ /**
3465
+ * @author Vova Feldman (@svovaf)
3466
+ * @since 1.0.5
3467
+ *
3468
+ * @param number $id
3469
+ *
3470
+ * @return FS_Plugin_Plan
3471
+ */
3472
+ function _get_plan_by_id( $id ) {
3473
+ $this->_logger->entrance();
3474
+
3475
+ if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
3476
+ $this->_sync_plans();
3477
+ }
3478
+
3479
+ foreach ( $this->_plans as $plan ) {
3480
+ if ( $id == $plan->id ) {
3481
+ return $plan;
3482
+ }
3483
+ }
3484
+
3485
+ return false;
3486
+ }
3487
+
3488
+ /**
3489
+ * Sync local plugin plans with remote server.
3490
+ *
3491
+ * @author Vova Feldman (@svovaf)
3492
+ * @since 1.0.6
3493
+ *
3494
+ * @return FS_Plugin_License[]|object
3495
+ */
3496
+ function _sync_licenses() {
3497
+ $licenses = $this->_fetch_licenses();
3498
+ if ( ! isset( $licenses->error ) ) {
3499
+ $this->_licenses = $licenses;
3500
+ $this->_store_licenses();
3501
+ }
3502
+
3503
+ // Update current license.
3504
+ if ( is_object( $this->_license ) ) {
3505
+ $this->_license = $this->_get_license_by_id( $this->_license->id );
3506
+ }
3507
+
3508
+ return $this->_licenses;
3509
+ }
3510
+
3511
+ /**
3512
+ * @author Vova Feldman (@svovaf)
3513
+ * @since 1.0.5
3514
+ *
3515
+ * @param number $id
3516
+ *
3517
+ * @return FS_Plugin_License
3518
+ */
3519
+ function _get_license_by_id( $id ) {
3520
+ $this->_logger->entrance();
3521
+
3522
+ if ( ! is_numeric( $id ) ) {
3523
+ return false;
3524
+ }
3525
+
3526
+ if ( ! is_array( $this->_licenses ) || 0 === count( $this->_licenses ) ) {
3527
+ $this->_sync_licenses();
3528
+ }
3529
+
3530
+ foreach ( $this->_licenses as $license ) {
3531
+ if ( $id == $license->id ) {
3532
+ return $license;
3533
+ }
3534
+ }
3535
+
3536
+ return false;
3537
+ }
3538
+
3539
+ /**
3540
+ * Sync site's license with user licenses.
3541
+ *
3542
+ * @author Vova Feldman (@svovaf)
3543
+ * @since 1.0.6
3544
+ *
3545
+ * @param FS_Plugin_License|null $new_license
3546
+ */
3547
+ function _update_site_license( $new_license ) {
3548
+ $this->_logger->entrance();
3549
+
3550
+ $this->_license = $new_license;
3551
+
3552
+ if ( ! is_object( $new_license ) ) {
3553
+ $this->_site->license_id = null;
3554
+ $this->_sync_site_subscription( null );
3555
+
3556
+ return;
3557
+ }
3558
+
3559
+ $this->_site->license_id = $this->_license->id;
3560
+
3561
+ if ( ! is_array( $this->_licenses ) ) {
3562
+ $this->_licenses = array();
3563
+ }
3564
+
3565
+ $is_license_found = false;
3566
+ for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
3567
+ if ( $new_license->id == $this->_licenses[ $i ]->id ) {
3568
+ $this->_licenses[ $i ] = $new_license;
3569
+
3570
+ $is_license_found = true;
3571
+ break;
3572
+ }
3573
+ }
3574
+
3575
+ // If new license just append.
3576
+ if ( ! $is_license_found ) {
3577
+ $this->_licenses[] = $new_license;
3578
+ }
3579
+
3580
+ $this->_sync_site_subscription( $new_license );
3581
+ }
3582
+
3583
+ /**
3584
+ * Sync site's subscription.
3585
+ *
3586
+ * @author Vova Feldman (@svovaf)
3587
+ * @since 1.0.9
3588
+ *
3589
+ * @param FS_Plugin_License|null $license
3590
+ *
3591
+ * @return bool|\FS_Subscription
3592
+ */
3593
+ private function _sync_site_subscription( $license ) {
3594
+ if ( ! is_object( $license ) ) {
3595
+ unset( $this->_storage->subscription );
3596
+
3597
+ return false;
3598
+ }
3599
+
3600
+ // Load subscription details if not lifetime.
3601
+ $subscription = $license->is_lifetime() ?
3602
+ false :
3603
+ $this->_fetch_site_license_subscription();
3604
+
3605
+ if ( is_object( $subscription ) && ! isset( $subscription->error ) ) {
3606
+ $this->_storage->subscription = $subscription;
3607
+ } else {
3608
+ unset( $this->_storage->subscription );
3609
+ }
3610
+
3611
+ return $subscription;
3612
+ }
3613
+
3614
+ /**
3615
+ * @author Vova Feldman (@svovaf)
3616
+ * @since 1.0.6
3617
+ *
3618
+ * @return bool|\FS_Plugin_License
3619
+ */
3620
+ function _get_license() {
3621
+ return $this->_license;
3622
+ }
3623
+
3624
+ /**
3625
+ * @return bool|\FS_Subscription
3626
+ */
3627
+ function _get_subscription() {
3628
+ return isset( $this->_storage->subscription ) ?
3629
+ $this->_storage->subscription :
3630
+ false;
3631
+ }
3632
+
3633
+ /**
3634
+ * @author Vova Feldman (@svovaf)
3635
+ * @since 1.0.2
3636
+ *
3637
+ * @param string $plan Plan name
3638
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
3639
+ *
3640
+ * @return bool
3641
+ */
3642
+ function is_plan( $plan, $exact = false ) {
3643
+ $this->_logger->entrance();
3644
+
3645
+ if ( ! $this->is_registered() ) {
3646
+ return false;
3647
+ }
3648
+
3649
+ $plan = strtolower( $plan );
3650
+
3651
+ if ( $this->_site->plan->name === $plan ) // Exact plan.
3652
+ {
3653
+ return true;
3654
+ } else if ( $exact ) // Required exact, but plans are different.
3655
+ {
3656
+ return false;
3657
+ }
3658
+
3659
+ $current_plan_order = - 1;
3660
+ $required_plan_order = - 1;
3661
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
3662
+ if ( $plan === $this->_plans[ $i ]->name ) {
3663
+ $required_plan_order = $i;
3664
+ } else if ( $this->_site->plan->name === $this->_plans[ $i ]->name ) {
3665
+ $current_plan_order = $i;
3666
+ }
3667
+ }
3668
+
3669
+ return ( $current_plan_order > $required_plan_order );
3670
+ }
3671
+
3672
+ /**
3673
+ * Check if plan based on trial. If not in trial mode, should return false.
3674
+ *
3675
+ * @since 1.0.9
3676
+ *
3677
+ * @param string $plan Plan name
3678
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
3679
+ *
3680
+ * @return bool
3681
+ */
3682
+ function is_trial_plan( $plan, $exact = false ) {
3683
+ $this->_logger->entrance();
3684
+
3685
+ if ( ! $this->is_registered() ) {
3686
+ return false;
3687
+ }
3688
+
3689
+ if ( ! $this->is_trial() ) {
3690
+ return false;
3691
+ }
3692
+
3693
+ if ( ! isset( $this->_storage->trial_plan ) ) {
3694
+ // Store trial plan information.
3695
+ $this->_enrich_site_trial_plan( true );
3696
+ }
3697
+
3698
+ if ( $this->_storage->trial_plan->name === $plan ) // Exact plan.
3699
+ {
3700
+ return true;
3701
+ } else if ( $exact ) // Required exact, but plans are different.
3702
+ {
3703
+ return false;
3704
+ }
3705
+
3706
+ $current_plan_order = - 1;
3707
+ $required_plan_order = - 1;
3708
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
3709
+ if ( $plan === $this->_plans[ $i ]->name ) {
3710
+ $required_plan_order = $i;
3711
+ } else if ( $this->_storage->trial_plan->name === $this->_plans[ $i ]->name ) {
3712
+ $current_plan_order = $i;
3713
+ }
3714
+ }
3715
+
3716
+ return ( $current_plan_order > $required_plan_order );
3717
+ }
3718
+
3719
+ /**
3720
+ * Check if plugin has any paid plans.
3721
+ *
3722
+ * @author Vova Feldman (@svovaf)
3723
+ * @since 1.0.7
3724
+ *
3725
+ * @return bool
3726
+ */
3727
+ function has_paid_plan() {
3728
+ return $this->_has_paid_plans || FS_Plan_Manager::instance()->has_paid_plan( $this->_plans );
3729
+ }
3730
+
3731
+ /**
3732
+ * Check if plugin has any plan with a trail.
3733
+ *
3734
+ * @author Vova Feldman (@svovaf)
3735
+ * @since 1.0.9
3736
+ *
3737
+ * @return bool
3738
+ */
3739
+ function has_trial_plan() {
3740
+ if ( ! $this->is_registered() ) {
3741
+ return false;
3742
+ }
3743
+
3744
+ return $this->_storage->get( 'has_trial_plan', false );
3745
+ }
3746
+
3747
+ /**
3748
+ * Check if plugin has any free plan, or is it premium only.
3749
+ *
3750
+ * Note: If no plans configured, assume plugin is free.
3751
+ *
3752
+ * @author Vova Feldman (@svovaf)
3753
+ * @since 1.0.7
3754
+ *
3755
+ * @return bool
3756
+ */
3757
+ function has_free_plan() {
3758
+ return FS_Plan_Manager::instance()->has_free_plan( $this->_plans );
3759
+ }
3760
+
3761
+ #region URL Generators
3762
+
3763
+ /**
3764
+ * Alias to pricing_url().
3765
+ *
3766
+ * @author Vova Feldman (@svovaf)
3767
+ * @since 1.0.2
3768
+ *
3769
+ * @uses pricing_url
3770
+ *
3771
+ * @param string $period Billing cycle
3772
+ *
3773
+ * @return string
3774
+ */
3775
+ function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY ) {
3776
+ return $this->pricing_url( $period );
3777
+ }
3778
+
3779
+ /**
3780
+ * @author Vova Feldman (@svovaf)
3781
+ * @since 1.0.9
3782
+ *
3783
+ * @uses get_upgrade_url
3784
+ *
3785
+ * @return string
3786
+ */
3787
+ function get_trial_url() {
3788
+ return $this->get_upgrade_url( 'trial' );
3789
+ }
3790
+
3791
+ /**
3792
+ * Plugin's pricing URL.
3793
+ *
3794
+ * @author Vova Feldman (@svovaf)
3795
+ * @since 1.0.4
3796
+ *
3797
+ * @param string $period Billing cycle
3798
+ *
3799
+ * @return string
3800
+ */
3801
+ function pricing_url( $period = WP_FS__PERIOD_ANNUALLY ) {
3802
+ $this->_logger->entrance();
3803
+
3804
+ return $this->_get_admin_page_url( 'pricing', array( 'billing_cycle' => $period ) );
3805
+ }
3806
+
3807
+ /**
3808
+ * Checkout page URL.
3809
+ *
3810
+ * @author Vova Feldman (@svovaf)
3811
+ * @since 1.0.6
3812
+ *
3813
+ * @param string $period Billing cycle
3814
+ * @param bool|string $plan_name
3815
+ * @param bool|number $plan_id
3816
+ * @param bool|int $licenses
3817
+ *
3818
+ * @return string
3819
+ */
3820
+ function checkout_url(
3821
+ $period = WP_FS__PERIOD_ANNUALLY,
3822
+ $plan_name = false,
3823
+ $plan_id = false,
3824
+ $licenses = false
3825
+ ) {
3826
+ $this->_logger->entrance();
3827
+
3828
+ $params = array(
3829
+ 'checkout' => 'true',
3830
+ 'billing_cycle' => $period,
3831
+ );
3832
+
3833
+ if ( false !== $plan_name ) {
3834
+ $params['plan_name'] = $plan_name;
3835
+ }
3836
+ if ( false !== $plan_id ) {
3837
+ $params['plan_id'] = $plan_id;
3838
+ }
3839
+ if ( false !== $licenses ) {
3840
+ $params['licenses'] = $licenses;
3841
+ }
3842
+
3843
+ return $this->_get_admin_page_url( 'pricing', $params );
3844
+ }
3845
+
3846
+ #endregion
3847
+
3848
+ #endregion ------------------------------------------------------------------
3849
+
3850
+ /**
3851
+ * Check if plugin has any add-ons.
3852
+ *
3853
+ * @author Vova Feldman (@svovaf)
3854
+ * @since 1.0.5
3855
+ *
3856
+ * @return bool
3857
+ */
3858
+ function _has_addons() {
3859
+ $this->_logger->entrance();
3860
+
3861
+ return ( $this->_has_addons || false !== $this->get_addons() );
3862
+ }
3863
+
3864
+ /**
3865
+ * Check if plugin can work in anonymous mode.
3866
+ *
3867
+ * @author Vova Feldman (@svovaf)
3868
+ * @since 1.0.9
3869
+ *
3870
+ * @return bool
3871
+ */
3872
+ function enable_anonymous() {
3873
+ return $this->_enable_anonymous;
3874
+ }
3875
+
3876
+ /**
3877
+ * Check if feature supported with current site's plan.
3878
+ *
3879
+ * @author Vova Feldman (@svovaf)
3880
+ * @since 1.0.1
3881
+ *
3882
+ * @todo IMPLEMENT
3883
+ *
3884
+ * @param number $feature_id
3885
+ *
3886
+ * @throws Exception
3887
+ */
3888
+ function is_feature_supported( $feature_id ) {
3889
+ throw new Exception( 'not implemented' );
3890
+ }
3891
+
3892
+ /**
3893
+ * @author Vova Feldman (@svovaf)
3894
+ * @since 1.0.1
3895
+ *
3896
+ * @return bool Is running in SSL/HTTPS
3897
+ */
3898
+ function is_ssl() {
3899
+ return WP_FS__IS_HTTPS;
3900
+ }
3901
+
3902
+ /**
3903
+ * @author Vova Feldman (@svovaf)
3904
+ * @since 1.0.9
3905
+ *
3906
+ * @return bool Is running in AJAX call.
3907
+ *
3908
+ * @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
3909
+ */
3910
+ function is_ajax() {
3911
+ return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
3912
+ }
3913
+
3914
+ /**
3915
+ * Check if running in HTTPS and if site's plan matching the specified plan.
3916
+ *
3917
+ * @param string $plan
3918
+ * @param bool $exact
3919
+ *
3920
+ * @return bool
3921
+ */
3922
+ function is_ssl_and_plan( $plan, $exact = false ) {
3923
+ return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) );
3924
+ }
3925
+
3926
+ /**
3927
+ * Construct plugin's settings page URL.
3928
+ *
3929
+ * @author Vova Feldman (@svovaf)
3930
+ * @since 1.0.4
3931
+ *
3932
+ * @param string $page
3933
+ * @param array $params
3934
+ *
3935
+ * @return string
3936
+ */
3937
+ function _get_admin_page_url( $page = '', $params = array() ) {
3938
+ if ( ! $this->_menu->is_top_level() ) {
3939
+ $parent_slug = $this->_menu->get_parent_slug();
3940
+ $menu_file = ( false !== strpos( $parent_slug, '.php' ) ) ?
3941
+ $parent_slug :
3942
+ 'admin.php';
3943
+
3944
+ return add_query_arg( array_merge( $params, array(
3945
+ 'page' => $this->_menu->get_slug( $page ),
3946
+ ) ), admin_url( $menu_file, 'admin' ) );
3947
+ }
3948
+
3949
+ if ( $this->_menu->is_cpt() ) {
3950
+ if ( empty( $page ) && $this->is_activation_mode() ) {
3951
+ return add_query_arg( array_merge( $params, array(
3952
+ 'page' => $this->_menu->get_slug()
3953
+ ) ), admin_url( 'admin.php', 'admin' ) );
3954
+ } else {
3955
+ if ( ! empty( $page ) ) {
3956
+ $params['page'] = $this->_menu->get_slug( $page );
3957
+ }
3958
+
3959
+ return add_query_arg( $params, admin_url( $this->_menu->get_raw_slug(), 'admin' ) );
3960
+ }
3961
+ } else {
3962
+ return add_query_arg( array_merge( $params, array(
3963
+ 'page' => $this->_menu->get_slug( $page ),
3964
+ ) ), admin_url( 'admin.php', 'admin' ) );
3965
+ }
3966
+ }
3967
+
3968
+
3969
+ /**
3970
+ * Plugin's account URL.
3971
+ *
3972
+ * @author Vova Feldman (@svovaf)
3973
+ * @since 1.0.4
3974
+ *
3975
+ * @param bool|string $action
3976
+ * @param array $params
3977
+ *
3978
+ * @param bool $add_action_nonce
3979
+ *
3980
+ * @return string
3981
+ */
3982
+ function get_account_url( $action = false, $params = array(), $add_action_nonce = true ) {
3983
+ if ( is_string( $action ) ) {
3984
+ $params['fs_action'] = $action;
3985
+ }
3986
+
3987
+ self::require_pluggable_essentials();
3988
+
3989
+ return ( $add_action_nonce && is_string( $action ) ) ?
3990
+ wp_nonce_url( $this->_get_admin_page_url( 'account', $params ), $action ) :
3991
+ $this->_get_admin_page_url( 'account', $params );
3992
+ }
3993
+
3994
+ /**
3995
+ * Plugin's account URL.
3996
+ *
3997
+ * @author Vova Feldman (@svovaf)
3998
+ * @since 1.0.4
3999
+ *
4000
+ * @param bool|string $topic
4001
+ * @param bool|string $message
4002
+ *
4003
+ * @return string
4004
+ */
4005
+ function contact_url( $topic = false, $message = false ) {
4006
+ $params = array();
4007
+ if ( is_string( $topic ) ) {
4008
+ $params['topic'] = $topic;
4009
+ }
4010
+ if ( is_string( $message ) ) {
4011
+ $params['message'] = $message;
4012
+ }
4013
+
4014
+ if ( $this->is_addon() ) {
4015
+ $params['addon_id'] = $this->get_id();
4016
+
4017
+ return $this->get_parent_instance()->_get_admin_page_url( 'contact', $params );
4018
+ } else {
4019
+ return $this->_get_admin_page_url( 'contact', $params );
4020
+ }
4021
+ }
4022
+
4023
+ /**
4024
+ * Add-on direct info URL.
4025
+ *
4026
+ * @author Vova Feldman (@svovaf)
4027
+ * @since 1.1.0
4028
+ *
4029
+ * @param string $slug
4030
+ *
4031
+ * @return string
4032
+ */
4033
+ function addon_url( $slug ) {
4034
+ return $this->_get_admin_page_url( 'addons', array(
4035
+ 'slug' => $slug
4036
+ ) );
4037
+ }
4038
+
4039
+ /* Logger
4040
+ ------------------------------------------------------------------------------------------------------------------*/
4041
+ /**
4042
+ * @param string $id
4043
+ * @param bool $prefix_slug
4044
+ *
4045
+ * @return FS_Logger
4046
+ */
4047
+ function get_logger( $id = '', $prefix_slug = true ) {
4048
+ return FS_Logger::get_logger( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id );
4049
+ }
4050
+
4051
+ /**
4052
+ * @param $id
4053
+ * @param bool $load_options
4054
+ * @param bool $prefix_slug
4055
+ *
4056
+ * @return FS_Option_Manager
4057
+ */
4058
+ function get_options_manager( $id, $load_options = false, $prefix_slug = true ) {
4059
+ return FS_Option_Manager::get_manager( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id, $load_options );
4060
+ }
4061
+
4062
+ /* Security
4063
+ ------------------------------------------------------------------------------------------------------------------*/
4064
+ private function _encrypt( $str ) {
4065
+ if ( is_null( $str ) ) {
4066
+ return null;
4067
+ }
4068
+
4069
+ return base64_encode( $str );
4070
+ }
4071
+
4072
+ private function _decrypt( $str ) {
4073
+ if ( is_null( $str ) ) {
4074
+ return null;
4075
+ }
4076
+
4077
+ return base64_decode( $str );
4078
+ }
4079
+
4080
+ /**
4081
+ * @author Vova Feldman (@svovaf)
4082
+ * @since 1.0.5
4083
+ *
4084
+ * @param FS_Entity $entity
4085
+ *
4086
+ * @return FS_Entity Return an encrypted clone entity.
4087
+ */
4088
+ private function _encrypt_entity( FS_Entity $entity ) {
4089
+ $clone = clone $entity;
4090
+ $props = get_object_vars( $entity );
4091
+
4092
+ foreach ( $props as $key => $val ) {
4093
+ $clone->{$key} = $this->_encrypt( $val );
4094
+ }
4095
+
4096
+ return $clone;
4097
+ }
4098
+
4099
+ /**
4100
+ * @author Vova Feldman (@svovaf)
4101
+ * @since 1.0.5
4102
+ *
4103
+ * @param FS_Entity $entity
4104
+ *
4105
+ * @return FS_Entity Return an decrypted clone entity.
4106
+ */
4107
+ private function _decrypt_entity( FS_Entity $entity ) {
4108
+ $clone = clone $entity;
4109
+ $props = get_object_vars( $entity );
4110
+
4111
+ foreach ( $props as $key => $val ) {
4112
+ $clone->{$key} = $this->_decrypt( $val );
4113
+ }
4114
+
4115
+ return $clone;
4116
+ }
4117
+
4118
+ /**
4119
+ * Tries to activate account based on POST params.
4120
+ *
4121
+ * @author Vova Feldman (@svovaf)
4122
+ * @since 1.0.2
4123
+ */
4124
+ function _activate_account() {
4125
+ if ( $this->is_registered() ) {
4126
+ // Already activated.
4127
+ return;
4128
+ }
4129
+
4130
+ $this->_clean_admin_content_section();
4131
+
4132
+ if ( fs_request_is_action( 'activate' ) && fs_request_is_post() ) {
4133
+ // check_admin_referer( 'activate_' . $this->_plugin->public_key );
4134
+
4135
+ // Verify matching plugin details.
4136
+ if ( $this->_plugin->id != fs_request_get( 'plugin_id' ) || $this->_slug != fs_request_get( 'plugin_slug' ) ) {
4137
+ return;
4138
+ }
4139
+
4140
+ $user = new FS_User();
4141
+ $user->id = fs_request_get( 'user_id' );
4142
+ $user->public_key = fs_request_get( 'user_public_key' );
4143
+ $user->secret_key = fs_request_get( 'user_secret_key' );
4144
+ $user->email = fs_request_get( 'user_email' );
4145
+ $user->first = fs_request_get( 'user_first' );
4146
+ $user->last = fs_request_get( 'user_last' );
4147
+ $user->is_verified = fs_request_get_bool( 'user_is_verified' );
4148
+
4149
+ $site = new FS_Site();
4150
+ $site->id = fs_request_get( 'install_id' );
4151
+ $site->public_key = fs_request_get( 'install_public_key' );
4152
+ $site->secret_key = fs_request_get( 'install_secret_key' );
4153
+ $site->plan->id = fs_request_get( 'plan_id' );
4154
+ $site->plan->title = fs_request_get( 'plan_title' );
4155
+ $site->plan->name = fs_request_get( 'plan_name' );
4156
+
4157
+ $plans = array();
4158
+ $plans_data = json_decode( urldecode( fs_request_get( 'plans' ) ) );
4159
+ foreach ( $plans_data as $p ) {
4160
+ $plans[] = new FS_Plugin_Plan( $p );
4161
+ }
4162
+
4163
+ $this->_set_account( $user, $site, $plans );
4164
+
4165
+ // Reload the page with the keys.
4166
+ if ( fs_redirect( $this->_get_admin_page_url() ) ) {
4167
+ exit();
4168
+ }
4169
+ }
4170
+ }
4171
+
4172
+ /**
4173
+ * @author Vova Feldman (@svovaf)
4174
+ * @since 1.0.7
4175
+ *
4176
+ * @param string $email
4177
+ *
4178
+ * @return FS_User|bool
4179
+ */
4180
+ static function _get_user_by_email( $email ) {
4181
+ self::$_static_logger->entrance();
4182
+
4183
+ $email = trim( strtolower( $email ) );
4184
+ $users = self::get_all_users();
4185
+ if ( is_array( $users ) ) {
4186
+ foreach ( $users as $u ) {
4187
+ if ( $email === trim( strtolower( $u->email ) ) ) {
4188
+ return $u;
4189
+ }
4190
+ }
4191
+ }
4192
+
4193
+ return false;
4194
+ }
4195
+
4196
+ #region Account (Loading, Updates & Activation) ------------------------------------------------------------------
4197
+
4198
+ /***
4199
+ * Load account information (user + site).
4200
+ *
4201
+ * @author Vova Feldman (@svovaf)
4202
+ * @since 1.0.1
4203
+ */
4204
+ private function _load_account() {
4205
+ $this->_logger->entrance();
4206
+
4207
+ $this->do_action( 'before_account_load' );
4208
+
4209
+ $sites = self::get_all_sites();
4210
+ $users = self::get_all_users();
4211
+ $plans = self::get_all_plans();
4212
+ $licenses = self::get_all_licenses();
4213
+
4214
+ if ( $this->_logger->is_on() && is_admin() ) {
4215
+ $this->_logger->log( 'sites = ' . var_export( $sites, true ) );
4216
+ $this->_logger->log( 'users = ' . var_export( $users, true ) );
4217
+ $this->_logger->log( 'plans = ' . var_export( $plans, true ) );
4218
+ $this->_logger->log( 'licenses = ' . var_export( $licenses, true ) );
4219
+ }
4220
+
4221
+ $site = isset( $sites[ $this->_slug ] ) ? $sites[ $this->_slug ] : false;
4222
+
4223
+ if ( is_object( $site ) &&
4224
+ is_numeric( $site->id ) &&
4225
+ is_numeric( $site->user_id ) &&
4226
+ is_object( $site->plan )
4227
+ ) {
4228
+ // Load site.
4229
+ $this->_site = clone $site;
4230
+ $this->_site->plan = $this->_decrypt_entity( $this->_site->plan );
4231
+
4232
+ // Load relevant user.
4233
+ $this->_user = clone $users[ $this->_site->user_id ];
4234
+
4235
+ // Load plans.
4236
+ $this->_plans = $plans[ $this->_slug ];
4237
+ if ( ! is_array( $this->_plans ) || empty( $this->_plans ) ) {
4238
+ $this->_sync_plans( true );
4239
+ } else {
4240
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
4241
+ if ( $this->_plans[ $i ] instanceof FS_Plugin_Plan ) {
4242
+ $this->_plans[ $i ] = $this->_decrypt_entity( $this->_plans[ $i ] );
4243
+ } else {
4244
+ unset( $this->_plans[ $i ] );
4245
+ }
4246
+ }
4247
+ }
4248
+
4249
+ // Load licenses.
4250
+ $this->_licenses = array();
4251
+ if ( is_array( $licenses ) &&
4252
+ isset( $licenses[ $this->_slug ] ) &&
4253
+ isset( $licenses[ $this->_slug ][ $this->_user->id ] )
4254
+ ) {
4255
+ $this->_licenses = $licenses[ $this->_slug ][ $this->_user->id ];
4256
+ }
4257
+
4258
+ $this->_license = $this->_get_license_by_id( $this->_site->license_id );
4259
+
4260
+ if ( $this->_site->version != $this->get_plugin_version() ) {
4261
+ // If stored install version is different than current installed plugin version,
4262
+ // then update plugin version event.
4263
+ $this->update_plugin_version_event();
4264
+ }
4265
+ }
4266
+
4267
+ $this->_register_account_hooks();
4268
+ }
4269
+
4270
+ /**
4271
+ * @author Vova Feldman (@svovaf)
4272
+ * @since 1.0.1
4273
+ *
4274
+ * @param FS_User $user
4275
+ * @param FS_Site $site
4276
+ * @param bool|array $plans
4277
+ */
4278
+ private function _set_account( FS_User $user, FS_Site $site, $plans = false ) {
4279
+ $site->slug = $this->_slug;
4280
+ $site->user_id = $user->id;
4281
+
4282
+ $this->_site = $site;
4283
+ $this->_user = $user;
4284
+ if ( false !== $plans ) {
4285
+ $this->_plans = $plans;
4286
+ }
4287
+
4288
+ $this->send_install_update( array(), true );
4289
+
4290
+ $this->_store_account();
4291
+
4292
+ }
4293
+
4294
+ /**
4295
+ * Set user and site identities.
4296
+ *
4297
+ * @author Vova Feldman (@svovaf)
4298
+ * @since 1.0.9
4299
+ *
4300
+ * @param FS_User $user
4301
+ * @param FS_Site $site
4302
+ * @param bool $redirect
4303
+ *
4304
+ * @return bool False if account already set.
4305
+ */
4306
+ function setup_account( FS_User $user, FS_Site $site, $redirect = true ) {
4307
+ $this->_user = $user;
4308
+ $this->_site = $site;
4309
+ $this->_enrich_site_plan( false );
4310
+
4311
+ $this->_set_account( $user, $site );
4312
+ $this->_sync_plans();
4313
+
4314
+ if ( $this->is_trial() ) {
4315
+ // Store trial plan information.
4316
+ $this->_enrich_site_trial_plan( true );
4317
+ }
4318
+
4319
+ $this->do_action( 'after_account_connection', $user, $site );
4320
+
4321
+ if ( is_numeric( $site->license_id ) ) {
4322
+ $this->_license = $this->_get_license_by_id( $site->license_id );
4323
+ }
4324
+
4325
+ if ( $this->is_pending_activation() ) {
4326
+ // Remove pending activation sticky notice (if still exist).
4327
+ $this->_admin_notices->remove_sticky( 'activation_pending' );
4328
+
4329
+ // Remove plugin from pending activation mode.
4330
+ unset( $this->_storage->is_pending_activation );
4331
+
4332
+ if ( ! $this->is_paying() ) {
4333
+ $this->_admin_notices->add_sticky(
4334
+ sprintf( __fs( 'plugin-x-activation-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
4335
+ 'activation_complete'
4336
+ );
4337
+ }
4338
+ }
4339
+
4340
+ if ( $this->is_paying() && ! $this->is_premium() ) {
4341
+ $this->_admin_notices->add_sticky(
4342
+ sprintf(
4343
+ __fs( 'activation-with-plan-x-message' ),
4344
+ $this->_site->plan->title
4345
+ ) . ' ' . $this->_get_latest_download_link( sprintf(
4346
+ __fs( 'download-latest-x-version' ),
4347
+ $this->_site->plan->title
4348
+ ) ),
4349
+ 'plan_upgraded',
4350
+ __fs( 'yee-haw' ) . '!'
4351
+ );
4352
+ }
4353
+
4354
+ $plugin_id = fs_request_get( 'plugin_id', false );
4355
+
4356
+ // Store activation time ONLY for plugins (not add-ons).
4357
+ if ( ! is_numeric( $plugin_id ) || ( $plugin_id == $this->_plugin->id ) ) {
4358
+ $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
4359
+ }
4360
+
4361
+ if ( is_numeric( $plugin_id ) ) {
4362
+ if ( $plugin_id != $this->_plugin->id ) {
4363
+ // Add-on was installed - sync license right after install.
4364
+ if ( $redirect && fs_redirect( fs_nonce_url( $this->_get_admin_page_url(
4365
+ 'account',
4366
+ array(
4367
+ 'fs_action' => $this->_slug . '_sync_license',
4368
+ 'plugin_id' => $plugin_id
4369
+ )
4370
+ ), $this->_slug . '_sync_license' ) )
4371
+ ) {
4372
+ exit();
4373
+ }
4374
+
4375
+ }
4376
+ } else {
4377
+ // Reload the page with the keys.
4378
+ if ( $redirect && fs_redirect( $this->get_after_activation_url( 'after_connect_url' ) ) ) {
4379
+ exit();
4380
+ }
4381
+ }
4382
+ }
4383
+
4384
+ /**
4385
+ * Install plugin with new user information after approval.
4386
+ *
4387
+ * @author Vova Feldman (@svovaf)
4388
+ * @since 1.0.7
4389
+ */
4390
+ function _install_with_new_user() {
4391
+ if ( $this->is_registered() ) {
4392
+ return;
4393
+ }
4394
+
4395
+ if ( fs_request_is_action( $this->_slug . '_activate_new' ) ) {
4396
+ // check_admin_referer( $this->_slug . '_activate_new' );
4397
+
4398
+ $this->_admin_notices->remove_sticky( 'connect_account' );
4399
+
4400
+ if ( fs_request_has( 'user_secret_key' ) ) {
4401
+ $user = new FS_User();
4402
+ $user->id = fs_request_get( 'user_id' );
4403
+ $user->public_key = fs_request_get( 'user_public_key' );
4404
+ $user->secret_key = fs_request_get( 'user_secret_key' );
4405
+
4406
+ $this->_user = $user;
4407
+ $user_result = $this->get_api_user_scope()->get();
4408
+ $user = new FS_User( $user_result );
4409
+ $this->_user = $user;
4410
+
4411
+ $site = new FS_Site();
4412
+ $site->id = fs_request_get( 'install_id' );
4413
+ $site->public_key = fs_request_get( 'install_public_key' );
4414
+ $site->secret_key = fs_request_get( 'install_secret_key' );
4415
+
4416
+ $this->_site = $site;
4417
+ $site_result = $this->get_api_site_scope()->get();
4418
+ $site = new FS_Site( $site_result );
4419
+ $this->_site = $site;
4420
+
4421
+ $this->setup_account( $this->_user, $this->_site );
4422
+ } else if ( fs_request_has( 'pending_activation' ) ) {
4423
+ // Install must be activated via email since
4424
+ // user with the same email already exist.
4425
+ $this->_storage->is_pending_activation = true;
4426
+ $this->_add_pending_activation_notice( fs_request_get( 'user_email' ) );
4427
+
4428
+ // Reload the page with with pending activation message.
4429
+ if ( fs_redirect( $this->get_after_activation_url( 'after_pending_connect_url' ) ) ) {
4430
+ exit();
4431
+ }
4432
+ }
4433
+ }
4434
+ }
4435
+
4436
+ /**
4437
+ * Install plugin with current logged WP user info.
4438
+ *
4439
+ * @author Vova Feldman (@svovaf)
4440
+ * @since 1.0.7
4441
+ */
4442
+ function _install_with_current_user() {
4443
+ if ( $this->is_registered() ) {
4444
+ return;
4445
+ }
4446
+
4447
+ if ( fs_request_is_action( $this->_slug . '_activate_existing' ) && fs_request_is_post() ) {
4448
+ // check_admin_referer( 'activate_existing_' . $this->_plugin->public_key );
4449
+
4450
+ $this->_admin_notices->remove_sticky( 'connect_account' );
4451
+
4452
+ // Get current logged WP user.
4453
+ $current_user = wp_get_current_user();
4454
+
4455
+ // Find the relevant FS user by the email.
4456
+ $user = self::_get_user_by_email( $current_user->user_email );
4457
+
4458
+ // We have to set the user before getting user scope API handler.
4459
+ $this->_user = $user;
4460
+
4461
+ // Install the plugin.
4462
+ $install = $this->get_api_user_scope()->call(
4463
+ "/plugins/{$this->get_id()}/installs.json",
4464
+ 'post',
4465
+ $this->get_install_data_for_api( array(
4466
+ 'uid' => $this->get_anonymous_id(),
4467
+ ) )
4468
+ );
4469
+
4470
+ if ( isset( $install->error ) ) {
4471
+ $this->_admin_notices->add(
4472
+ sprintf( __fs( 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
4473
+ __fs( 'contact-us-with-error-message' ) . ' ' . '<b>' . $install->error->message . '</b>',
4474
+ __fs( 'oops' ) . '...',
4475
+ 'error'
4476
+ );
4477
+
4478
+ return;
4479
+ }
4480
+
4481
+ $site = new FS_Site( $install );
4482
+ $this->_site = $site;
4483
+ // $this->_enrich_site_plan( false );
4484
+
4485
+ // $this->_set_account( $user, $site );
4486
+ // $this->_sync_plans();
4487
+
4488
+ $this->setup_account( $this->_user, $this->_site );
4489
+ }
4490
+ }
4491
+
4492
+ /**
4493
+ * Tries to activate add-on account based on parent plugin info.
4494
+ *
4495
+ * @author Vova Feldman (@svovaf)
4496
+ * @since 1.0.6
4497
+ *
4498
+ * @param Freemius $parent_fs
4499
+ */
4500
+ private function _activate_addon_account( Freemius $parent_fs ) {
4501
+ if ( $this->is_registered() ) {
4502
+ // Already activated.
4503
+ return;
4504
+ }
4505
+
4506
+ // Activate add-on with parent plugin credentials.
4507
+ $addon_install = $parent_fs->get_api_site_scope()->call(
4508
+ "/addons/{$this->_plugin->id}/installs.json",
4509
+ 'post',
4510
+ $this->get_install_data_for_api( array(
4511
+ 'uid' => $this->get_anonymous_id(),
4512
+ ) )
4513
+ );
4514
+
4515
+ if ( isset( $addon_install->error ) ) {
4516
+ $this->_admin_notices->add(
4517
+ sprintf( __fs( 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
4518
+ __fs( 'contact-us-with-error-message' ) . ' ' . '<b>' . $addon_install->error->message . '</b>',
4519
+ __fs( 'oops' ) . '...',
4520
+ 'error'
4521
+ );
4522
+
4523
+ return;
4524
+ }
4525
+
4526
+ // First of all, set site info - otherwise we won't
4527
+ // be able to invoke API calls.
4528
+ $this->_site = new FS_Site( $addon_install );
4529
+
4530
+ // Sync add-on plans.
4531
+ $this->_sync_plans();
4532
+
4533
+ // Get site's current plan.
4534
+ $this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id );
4535
+
4536
+ // Get user information based on parent's plugin.
4537
+ $user = $parent_fs->get_user();
4538
+
4539
+ $this->_set_account( $user, $this->_site );
4540
+
4541
+ // Sync licenses.
4542
+ $this->_sync_licenses();
4543
+
4544
+ // Try to activate premium license.
4545
+ $this->_activate_license( true );
4546
+ }
4547
+
4548
+ #endregion ------------------------------------------------------------------
4549
+
4550
+ #region Admin Menu Items ------------------------------------------------------------------
4551
+
4552
+ private $_menu_items = array();
4553
+
4554
+ /**
4555
+ * @author Vova Feldman (@svovaf)
4556
+ * @since 1.0.7
4557
+ *
4558
+ * @return string
4559
+ */
4560
+ function get_menu_slug() {
4561
+ return $this->_menu->get_slug();
4562
+ }
4563
+
4564
+ /**
4565
+ * @author Vova Feldman (@svovaf)
4566
+ * @since 1.0.9
4567
+ */
4568
+ function _prepare_admin_menu() {
4569
+ if ( ! $this->is_on() ) {
4570
+ return;
4571
+ }
4572
+
4573
+ if ( ! $this->has_api_connectivity() && ! $this->enable_anonymous() ) {
4574
+ $this->_menu->remove_menu_item();
4575
+ } else {
4576
+ $this->add_submenu_items();
4577
+ $this->add_menu_action();
4578
+ }
4579
+ }
4580
+
4581
+ /**
4582
+ * Admin dashboard menu items modifications.
4583
+ *
4584
+ * NOTE: admin_menu action executed before admin_init.
4585
+ *
4586
+ * @author Vova Feldman (@svovaf)
4587
+ * @since 1.0.7
4588
+ *
4589
+ */
4590
+ private function add_menu_action() {
4591
+ if ( $this->is_activation_mode() ) {
4592
+ $this->override_plugin_menu_with_activation();
4593
+ } else {
4594
+ // If not registered try to install user.
4595
+ if ( ! $this->is_registered() &&
4596
+ fs_request_is_action( $this->_slug . '_activate_new' )
4597
+ ) {
4598
+ $this->_install_with_new_user();
4599
+ }
4600
+ }
4601
+ }
4602
+
4603
+ /**
4604
+ * @author Vova Feldman (@svovaf)
4605
+ * @since 1.0.1
4606
+ *
4607
+ * @return string
4608
+ */
4609
+ function _redirect_on_clicked_menu_link() {
4610
+ $this->_logger->entrance();
4611
+
4612
+ $page = strtolower( isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '' );
4613
+
4614
+ $this->_logger->log( 'page = ' . $page );
4615
+
4616
+ foreach ( $this->_menu_items as $priority => $items ) {
4617
+ foreach ( $items as $item ) {
4618
+ if ( isset( $item['url'] ) ) {
4619
+ if ( $page === $item['menu_slug'] ) {
4620
+ $this->_logger->log( 'Redirecting to ' . $item['url'] );
4621
+
4622
+ fs_redirect( $item['url'] );
4623
+ }
4624
+ }
4625
+ }
4626
+ }
4627
+ }
4628
+
4629
+ /**
4630
+ * Remove plugin's all admin menu items & pages, and replace with activation page.
4631
+ *
4632
+ * @author Vova Feldman (@svovaf)
4633
+ * @since 1.0.1
4634
+ */
4635
+ private function override_plugin_menu_with_activation() {
4636
+ $this->_logger->entrance();
4637
+
4638
+ $hook = false;
4639
+
4640
+ if ( $this->_menu->is_top_level() ) {
4641
+ $hook = $this->_menu->override_menu_item( array( &$this, '_connect_page_render' ) );
4642
+
4643
+ if ( false === $hook ) {
4644
+ // Create new menu item just for the opt-in.
4645
+ $hook = add_menu_page(
4646
+ $this->get_plugin_name(),
4647
+ $this->get_plugin_name(),
4648
+ 'manage_options',
4649
+ $this->_menu->get_slug(),
4650
+ array( &$this, '_connect_page_render' )
4651
+ );
4652
+ }
4653
+ } else {
4654
+ $menus = array( $this->_menu->get_parent_slug() );
4655
+
4656
+ if ( $this->_menu->is_override_exact() ) {
4657
+ // Make sure the current page is matching the activation page.
4658
+ $activation_url = strtolower( $this->get_activation_url() );
4659
+ $request_url = strtolower( $_SERVER['REQUEST_URI'] );
4660
+
4661
+ if ( parse_url( $activation_url, PHP_URL_PATH ) !== parse_url( $request_url, PHP_URL_PATH ) ) {
4662
+ // Different path - DO NOT OVERRIDE PAGE.
4663
+ return;
4664
+ }
4665
+
4666
+ $activation_url_params = array();
4667
+ parse_str( parse_url( $activation_url, PHP_URL_QUERY ), $activation_url_params );
4668
+
4669
+ $request_url_params = array();
4670
+ parse_str( parse_url( $request_url, PHP_URL_QUERY ), $request_url_params );
4671
+
4672
+
4673
+ foreach ( $activation_url_params as $key => $val ) {
4674
+ if ( ! isset( $request_url_params[ $key ] ) || $val != $request_url_params[ $key ] ) {
4675
+ // Not matching query string - DO NOT OVERRIDE PAGE.
4676
+ return;
4677
+ }
4678
+ }
4679
+ }
4680
+
4681
+ foreach ( $menus as $parent_slug ) {
4682
+ $hook = $this->_menu->override_submenu_action(
4683
+ $parent_slug,
4684
+ $this->_menu->get_raw_slug(),
4685
+ array( &$this, '_connect_page_render' )
4686
+ );
4687
+
4688
+ if ( false !== $hook ) {
4689
+ // Found plugin's submenu item.
4690
+ break;
4691
+ }
4692
+ }
4693
+ }
4694
+
4695
+ if ( $this->_menu->is_activation_page() ) {
4696
+ // Clean admin page from distracting content.
4697
+ $this->_clean_admin_content_section();
4698
+ }
4699
+
4700
+ if ( false !== $hook ) {
4701
+ if ( fs_request_is_action( $this->_slug . '_activate_existing' ) ) {
4702
+ add_action( "load-$hook", array( &$this, '_install_with_current_user' ) );
4703
+ } else if ( fs_request_is_action( $this->_slug . '_activate_new' ) ) {
4704
+ add_action( "load-$hook", array( &$this, '_install_with_new_user' ) );
4705
+ }
4706
+ }
4707
+ }
4708
+
4709
+ /**
4710
+ * @author Vova Feldman (@svovaf)
4711
+ * @since 1.0.0
4712
+ *
4713
+ * @return string
4714
+ */
4715
+ private function get_top_level_menu_slug() {
4716
+ return ( $this->is_addon() ?
4717
+ $this->get_parent_instance()->_menu->get_top_level_menu_slug() :
4718
+ $this->_menu->get_top_level_menu_slug() );
4719
+ }
4720
+
4721
+ /**
4722
+ * Add default Freemius menu items.
4723
+ *
4724
+ * @author Vova Feldman (@svovaf)
4725
+ * @since 1.0.0
4726
+ */
4727
+ private function add_submenu_items() {
4728
+ $this->_logger->entrance();
4729
+
4730
+ $this->do_action( 'before_admin_menu_init' );
4731
+
4732
+ if ( ! $this->is_addon() ) {
4733
+ if ( $this->is_registered() || $this->is_anonymous() ) {
4734
+ if ( $this->is_registered() ) {
4735
+ // Add user account page.
4736
+ $this->add_submenu_item(
4737
+ __fs( 'account' ),
4738
+ array( &$this, '_account_page_render' ),
4739
+ $this->get_plugin_name() . ' &ndash; ' . __fs( 'account' ),
4740
+ 'manage_options',
4741
+ 'account',
4742
+ array( &$this, '_account_page_load' ),
4743
+ WP_FS__DEFAULT_PRIORITY,
4744
+ $this->_menu->is_submenu_item_visible( 'account' )
4745
+ );
4746
+ }
4747
+
4748
+ // Add contact page.
4749
+ $this->add_submenu_item(
4750
+ __fs( 'contact-us' ),
4751
+ array( &$this, '_contact_page_render' ),
4752
+ $this->get_plugin_name() . ' &ndash; ' . __fs( 'contact-us' ),
4753
+ 'manage_options',
4754
+ 'contact',
4755
+ array( &$this, '_clean_admin_content_section' ),
4756
+ WP_FS__DEFAULT_PRIORITY,
4757
+ $this->_menu->is_submenu_item_visible( 'contact' )
4758
+ );
4759
+
4760
+ if ( $this->_has_addons() ) {
4761
+ $this->add_submenu_item(
4762
+ __fs( 'add-ons' ),
4763
+ array( &$this, '_addons_page_render' ),
4764
+ $this->get_plugin_name() . ' &ndash; ' . __fs( 'add-ons' ),
4765
+ 'manage_options',
4766
+ 'addons',
4767
+ array( &$this, '_addons_page_load' ),
4768
+ WP_FS__LOWEST_PRIORITY - 1,
4769
+ $this->_menu->is_submenu_item_visible( 'addons' )
4770
+ );
4771
+ }
4772
+
4773
+ $show_pricing = ($this->has_paid_plan() && $this->_menu->is_submenu_item_visible( 'pricing' ));
4774
+ // If user don't have paid plans, add pricing page
4775
+ // to support add-ons checkout but don't add the submenu item.
4776
+ // || (isset( $_GET['page'] ) && $this->_menu->get_slug( 'pricing' ) == $_GET['page']);
4777
+
4778
+ // Add upgrade/pricing page.
4779
+ $this->add_submenu_item(
4780
+ ( $this->is_paying() ? __fs( 'pricing' ) : __fs( 'upgrade' ) . '&nbsp;&nbsp;&#x27a4;' ),
4781
+ array( &$this, '_pricing_page_render' ),
4782
+ $this->get_plugin_name() . ' &ndash; ' . __fs( 'pricing' ),
4783
+ 'manage_options',
4784
+ 'pricing',
4785
+ array( &$this, '_clean_admin_content_section' ),
4786
+ WP_FS__LOWEST_PRIORITY,
4787
+ $show_pricing
4788
+ );
4789
+ }
4790
+ }
4791
+
4792
+
4793
+ if ( 0 < count( $this->_menu_items ) ) {
4794
+ if ( ! $this->_menu->is_top_level() ) {
4795
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
4796
+
4797
+ // Append submenu items right after the plugin's submenu item.
4798
+ $this->order_sub_submenu_items();
4799
+ } else {
4800
+ // Append submenu items.
4801
+ $this->embed_submenu_items();
4802
+ }
4803
+ }
4804
+ }
4805
+
4806
+ /**
4807
+ * Moved the actual submenu item additions to a separated function,
4808
+ * in order to support sub-submenu items when the plugin's settings
4809
+ * only have a submenu and not top-level menu item.
4810
+ *
4811
+ * @author Vova Feldman (@svovaf)
4812
+ * @since 1.1.4
4813
+ */
4814
+ private function embed_submenu_items() {
4815
+ $item_template = $this->_menu->is_top_level() ?
4816
+ '<span class="fs-submenu-item">%s</span>' :
4817
+ '<span class="fs-submenu-item fs-sub">%s</span>';
4818
+
4819
+ ksort( $this->_menu_items );
4820
+
4821
+ foreach ( $this->_menu_items as $priority => $items ) {
4822
+ foreach ( $items as $item ) {
4823
+ if ( ! isset( $item['url'] ) ) {
4824
+ $hook = add_submenu_page(
4825
+ $item['show_submenu'] ?
4826
+ $this->get_top_level_menu_slug() :
4827
+ null,
4828
+ $item['page_title'],
4829
+ sprintf( $item_template, $item['menu_title'] ),
4830
+ $item['capability'],
4831
+ $item['menu_slug'],
4832
+ $item['render_function']
4833
+ );
4834
+
4835
+ if ( false !== $item['before_render_function'] ) {
4836
+ add_action( "load-$hook", $item['before_render_function'] );
4837
+ }
4838
+ } else {
4839
+ add_submenu_page(
4840
+ $this->get_top_level_menu_slug(),
4841
+ $item['page_title'],
4842
+ sprintf( $item_template, $item['menu_title'] ),
4843
+ $item['capability'],
4844
+ $item['menu_slug'],
4845
+ array( $this, '' )
4846
+ );
4847
+ }
4848
+ }
4849
+ }
4850
+ }
4851
+
4852
+ /**
4853
+ * Re-order the submenu items so all Freemius added new submenu items
4854
+ * are added right after the plugin's settings submenu item.
4855
+ *
4856
+ * @author Vova Feldman (@svovaf)
4857
+ * @since 1.1.4
4858
+ */
4859
+ private function order_sub_submenu_items() {
4860
+ global $submenu;
4861
+
4862
+ $top_level_menu = &$submenu[ $this->_menu->get_top_level_menu_slug() ];
4863
+
4864
+ $all_submenu_items_after = array();
4865
+
4866
+ $found_submenu_item = false;
4867
+
4868
+ foreach ( $top_level_menu as $submenu_id => $meta ) {
4869
+ if ( $found_submenu_item ) {
4870
+ // Remove all submenu items after the plugin's submenu item.
4871
+ $all_submenu_items_after[] = $meta;
4872
+ unset( $top_level_menu[ $submenu_id ] );
4873
+ }
4874
+
4875
+ if ( $this->_menu->get_raw_slug() === $meta[2] ) {
4876
+ // Found the submenu item, put all below.
4877
+ $found_submenu_item = true;
4878
+ continue;
4879
+ }
4880
+ }
4881
+
4882
+ // Embed all plugin's new submenu items.
4883
+ $this->embed_submenu_items();
4884
+
4885
+ // Start with specially high number to make sure it's appended.
4886
+ $i = 10000;
4887
+ foreach ( $all_submenu_items_after as $meta ) {
4888
+ $top_level_menu[ $i ] = $meta;
4889
+ $i ++;
4890
+ }
4891
+
4892
+ // Sort submenu items.
4893
+ ksort( $top_level_menu );
4894
+ }
4895
+
4896
+ function _add_default_submenu_items() {
4897
+ if ( ! $this->is_on() ) {
4898
+ return;
4899
+ }
4900
+
4901
+ if ( $this->is_registered() ) {
4902
+ if ( $this->_menu->is_submenu_item_visible( 'support' ) ) {
4903
+ $this->add_submenu_link_item(
4904
+ $this->apply_filters( 'support_forum_submenu', __fs( 'support-forum' ) ),
4905
+ $this->apply_filters( 'support_forum_url', 'https://wordpress.org/support/plugin/' . $this->_slug ),
4906
+ 'wp-support-forum',
4907
+ 'read',
4908
+ 50
4909
+ );
4910
+ }
4911
+ }
4912
+ }
4913
+
4914
+ /**
4915
+ * @author Vova Feldman (@svovaf)
4916
+ * @since 1.0.1
4917
+ *
4918
+ * @param string $menu_title
4919
+ * @param callable $render_function
4920
+ * @param bool|string $page_title
4921
+ * @param string $capability
4922
+ * @param bool|string $menu_slug
4923
+ * @param bool|callable $before_render_function
4924
+ * @param int $priority
4925
+ * @param bool $show_submenu
4926
+ */
4927
+ function add_submenu_item(
4928
+ $menu_title,
4929
+ $render_function,
4930
+ $page_title = false,
4931
+ $capability = 'manage_options',
4932
+ $menu_slug = false,
4933
+ $before_render_function = false,
4934
+ $priority = WP_FS__DEFAULT_PRIORITY,
4935
+ $show_submenu = true
4936
+ ) {
4937
+ $this->_logger->entrance( 'Title = ' . $menu_title );
4938
+
4939
+ if ( $this->is_addon() ) {
4940
+ $parent_fs = $this->get_parent_instance();
4941
+
4942
+ if ( is_object( $parent_fs ) ) {
4943
+ $parent_fs->add_submenu_item(
4944
+ $menu_title,
4945
+ $render_function,
4946
+ $page_title,
4947
+ $capability,
4948
+ $menu_slug,
4949
+ $before_render_function,
4950
+ $priority,
4951
+ $show_submenu
4952
+ );
4953
+
4954
+ return;
4955
+ }
4956
+ }
4957
+
4958
+ if ( ! isset( $this->_menu_items[ $priority ] ) ) {
4959
+ $this->_menu_items[ $priority ] = array();
4960
+ }
4961
+
4962
+ $this->_menu_items[ $priority ][] = array(
4963
+ 'page_title' => is_string( $page_title ) ? $page_title : $menu_title,
4964
+ 'menu_title' => $menu_title,
4965
+ 'capability' => $capability,
4966
+ 'menu_slug' => $this->_menu->get_slug( is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ) ),
4967
+ 'render_function' => $render_function,
4968
+ 'before_render_function' => $before_render_function,
4969
+ 'show_submenu' => $show_submenu,
4970
+ );
4971
+ }
4972
+
4973
+ /**
4974
+ * @author Vova Feldman (@svovaf)
4975
+ * @since 1.0.1
4976
+ *
4977
+ * @param string $menu_title
4978
+ * @param string $url
4979
+ * @param bool $menu_slug
4980
+ * @param string $capability
4981
+ * @param int $priority
4982
+ *
4983
+ */
4984
+ function add_submenu_link_item(
4985
+ $menu_title,
4986
+ $url,
4987
+ $menu_slug = false,
4988
+ $capability = 'read',
4989
+ $priority = WP_FS__DEFAULT_PRIORITY
4990
+ ) {
4991
+ $this->_logger->entrance( 'Title = ' . $menu_title . '; Url = ' . $url );
4992
+
4993
+ if ( $this->is_addon() ) {
4994
+ $parent_fs = $this->get_parent_instance();
4995
+
4996
+ if ( is_object( $parent_fs ) ) {
4997
+ $parent_fs->add_submenu_link_item(
4998
+ $menu_title,
4999
+ $url,
5000
+ $menu_slug,
5001
+ $capability,
5002
+ $priority
5003
+ );
5004
+
5005
+ return;
5006
+ }
5007
+ }
5008
+
5009
+ if ( ! isset( $this->_menu_items[ $priority ] ) ) {
5010
+ $this->_menu_items[ $priority ] = array();
5011
+ }
5012
+
5013
+ $this->_menu_items[ $priority ][] = array(
5014
+ 'menu_title' => $menu_title,
5015
+ 'capability' => $capability,
5016
+ 'menu_slug' => $this->_menu->get_slug( is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ) ),
5017
+ 'url' => $url,
5018
+ 'page_title' => $menu_title,
5019
+ 'render_function' => 'fs_dummy',
5020
+ 'before_render_function' => '',
5021
+ );
5022
+ }
5023
+
5024
+ #endregion ------------------------------------------------------------------
5025
+
5026
+ /* Actions / Hooks / Filters
5027
+ ------------------------------------------------------------------------------------------------------------------*/
5028
+ /**
5029
+ * Do action, specific for the current context plugin.
5030
+ *
5031
+ * @author Vova Feldman (@svovaf)
5032
+ * @since 1.0.1
5033
+ *
5034
+ * @param string $tag The name of the action to be executed.
5035
+ * @param mixed $arg,... Optional. Additional arguments which are passed on to the
5036
+ * functions hooked to the action. Default empty.
5037
+ *
5038
+ * @uses do_action()
5039
+ */
5040
+ function do_action( $tag, $arg = '' ) {
5041
+ $this->_logger->entrance( $tag );
5042
+
5043
+ $args = func_get_args();
5044
+
5045
+ call_user_func_array( 'do_action', array_merge(
5046
+ array( 'fs_' . $tag . '_' . $this->_slug ),
5047
+ array_slice( $args, 1 ) )
5048
+ );
5049
+ }
5050
+
5051
+ /**
5052
+ * Add action, specific for the current context plugin.
5053
+ *
5054
+ * @author Vova Feldman (@svovaf)
5055
+ * @since 1.0.1
5056
+ *
5057
+ * @param string $tag
5058
+ * @param callable $function_to_add
5059
+ * @param int $priority
5060
+ * @param int $accepted_args
5061
+ *
5062
+ * @uses add_action()
5063
+ */
5064
+ function add_action( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) {
5065
+ $this->_logger->entrance( $tag );
5066
+
5067
+ add_action( 'fs_' . $tag . '_' . $this->_slug, $function_to_add, $priority, $accepted_args );
5068
+ }
5069
+
5070
+ /**
5071
+ * Apply filter, specific for the current context plugin.
5072
+ *
5073
+ * @author Vova Feldman (@svovaf)
5074
+ * @since 1.0.9
5075
+ *
5076
+ * @param string $tag The name of the filter hook.
5077
+ * @param mixed $value The value on which the filters hooked to `$tag` are applied on.
5078
+ *
5079
+ * @return mixed The filtered value after all hooked functions are applied to it.
5080
+ *
5081
+ * @uses apply_filters()
5082
+ */
5083
+ function apply_filters( $tag, $value ) {
5084
+ $this->_logger->entrance( $tag );
5085
+
5086
+ $args = func_get_args();
5087
+
5088
+ return call_user_func_array( 'apply_filters', array_merge(
5089
+ array( 'fs_' . $tag . '_' . $this->_slug ),
5090
+ array_slice( $args, 1 ) )
5091
+ );
5092
+ }
5093
+
5094
+ /**
5095
+ * Add filter, specific for the current context plugin.
5096
+ *
5097
+ * @author Vova Feldman (@svovaf)
5098
+ * @since 1.0.9
5099
+ *
5100
+ * @param string $tag
5101
+ * @param callable $function_to_add
5102
+ * @param int $priority
5103
+ * @param int $accepted_args
5104
+ *
5105
+ * @uses add_filter()
5106
+ */
5107
+ function add_filter( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) {
5108
+ $this->_logger->entrance( $tag );
5109
+
5110
+ add_filter( 'fs_' . $tag . '_' . $this->_slug, $function_to_add, $priority, $accepted_args );
5111
+ }
5112
+
5113
+ /**
5114
+ * Check if has filter.
5115
+ *
5116
+ * @author Vova Feldman (@svovaf)
5117
+ * @since 1.1.4
5118
+ *
5119
+ * @param string $tag
5120
+ * @param callable|bool $function_to_check Optional. The callback to check for. Default false.
5121
+ */
5122
+ function has_filter( $tag, $function_to_check = false ) {
5123
+ $this->_logger->entrance( $tag );
5124
+
5125
+ return has_filter( 'fs_' . $tag . '_' . $this->_slug, $function_to_check );
5126
+ }
5127
+
5128
+ /* Account Page
5129
+ ------------------------------------------------------------------------------------------------------------------*/
5130
+ /**
5131
+ * Update site information.
5132
+ *
5133
+ * @author Vova Feldman (@svovaf)
5134
+ * @since 1.0.1
5135
+ *
5136
+ * @param bool $store Flush to Database if true.
5137
+ */
5138
+ private function _store_site( $store = true ) {
5139
+ $this->_logger->entrance();
5140
+
5141
+ $encrypted_site = clone $this->_site;
5142
+ $encrypted_site->plan = $this->_encrypt_entity( $this->_site->plan );
5143
+
5144
+ $sites = self::get_all_sites();
5145
+ $sites[ $this->_slug ] = $encrypted_site;
5146
+ self::$_accounts->set_option( 'sites', $sites, $store );
5147
+ }
5148
+
5149
+ /**
5150
+ * Update plugin's plans information.
5151
+ *
5152
+ * @author Vova Feldman (@svovaf)
5153
+ * @since 1.0.2
5154
+ *
5155
+ * @param bool $store Flush to Database if true.
5156
+ */
5157
+ private function _store_plans( $store = true ) {
5158
+ $this->_logger->entrance();
5159
+
5160
+ $plans = self::get_all_plans();
5161
+
5162
+ // Copy plans.
5163
+ $encrypted_plans = array();
5164
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
5165
+ $encrypted_plans[] = $this->_encrypt_entity( $this->_plans[ $i ] );
5166
+ }
5167
+
5168
+ $plans[ $this->_slug ] = $encrypted_plans;
5169
+ self::$_accounts->set_option( 'plans', $plans, $store );
5170
+ }
5171
+
5172
+ /**
5173
+ * Update user's plugin licenses.
5174
+ *
5175
+ * @author Vova Feldman (@svovaf)
5176
+ * @since 1.0.5
5177
+ *
5178
+ * @param bool $store
5179
+ * @param string|bool $plugin_slug
5180
+ * @param FS_Plugin_License[] $licenses
5181
+ */
5182
+ private function _store_licenses( $store = true, $plugin_slug = false, $licenses = array() ) {
5183
+ $this->_logger->entrance();
5184
+
5185
+ $all_licenses = self::get_all_licenses();
5186
+
5187
+ if ( ! is_string( $plugin_slug ) ) {
5188
+ $plugin_slug = $this->_slug;
5189
+ $licenses = $this->_licenses;
5190
+ }
5191
+
5192
+ if ( ! isset( $all_licenses[ $plugin_slug ] ) ) {
5193
+ $all_licenses[ $plugin_slug ] = array();
5194
+ }
5195
+
5196
+ $all_licenses[ $plugin_slug ][ $this->_user->id ] = $licenses;
5197
+
5198
+ self::$_accounts->set_option( 'licenses', $all_licenses, $store );
5199
+ }
5200
+
5201
+ /**
5202
+ * Update user information.
5203
+ *
5204
+ * @author Vova Feldman (@svovaf)
5205
+ * @since 1.0.1
5206
+ *
5207
+ * @param bool $store Flush to Database if true.
5208
+ */
5209
+ private function _store_user( $store = true ) {
5210
+ $this->_logger->entrance();
5211
+
5212
+ $users = self::get_all_users();
5213
+ $users[ $this->_user->id ] = $this->_user;
5214
+ self::$_accounts->set_option( 'users', $users, $store );
5215
+ }
5216
+
5217
+ /**
5218
+ * Update new updates information.
5219
+ *
5220
+ * @author Vova Feldman (@svovaf)
5221
+ * @since 1.0.4
5222
+ *
5223
+ * @param FS_Plugin_Tag|null $update
5224
+ * @param bool $store Flush to Database if true.
5225
+ * @param bool|number $plugin_id
5226
+ */
5227
+ private function _store_update( $update, $store = true, $plugin_id = false ) {
5228
+ $this->_logger->entrance();
5229
+
5230
+ if ( $update instanceof FS_Plugin_Tag ) {
5231
+ $update->updated = time();
5232
+ }
5233
+
5234
+ if ( ! is_numeric( $plugin_id ) ) {
5235
+ $plugin_id = $this->_plugin->id;
5236
+ }
5237
+
5238
+ $updates = self::get_all_updates();
5239
+ $updates[ $plugin_id ] = $update;
5240
+ self::$_accounts->set_option( 'updates', $updates, $store );
5241
+ }
5242
+
5243
+ /**
5244
+ * Update new updates information.
5245
+ *
5246
+ * @author Vova Feldman (@svovaf)
5247
+ * @since 1.0.6
5248
+ *
5249
+ * @param FS_Plugin[] $plugin_addons
5250
+ * @param bool $store Flush to Database if true.
5251
+ */
5252
+ private function _store_addons( $plugin_addons, $store = true ) {
5253
+ $this->_logger->entrance();
5254
+
5255
+ $addons = self::get_all_addons();
5256
+ $addons[ $this->_plugin->id ] = $plugin_addons;
5257
+ self::$_accounts->set_option( 'addons', $addons, $store );
5258
+ }
5259
+
5260
+ /**
5261
+ * Delete plugin's associated add-ons.
5262
+ *
5263
+ * @author Vova Feldman (@svovaf)
5264
+ * @since 1.0.8
5265
+ *
5266
+ * @param bool $store
5267
+ *
5268
+ * @return bool
5269
+ */
5270
+ private function _delete_account_addons( $store = true ) {
5271
+ $all_addons = self::get_all_account_addons();
5272
+
5273
+ if ( ! isset( $all_addons[ $this->_plugin->id ] ) ) {
5274
+ return false;
5275
+ }
5276
+
5277
+ unset( $all_addons[ $this->_plugin->id ] );
5278
+
5279
+ self::$_accounts->set_option( 'account_addons', $all_addons, $store );
5280
+
5281
+ return true;
5282
+ }
5283
+
5284
+ /**
5285
+ * Update account add-ons list.
5286
+ *
5287
+ * @author Vova Feldman (@svovaf)
5288
+ * @since 1.0.6
5289
+ *
5290
+ * @param FS_Plugin[] $addons
5291
+ * @param bool $store Flush to Database if true.
5292
+ */
5293
+ private function _store_account_addons( $addons, $store = true ) {
5294
+ $this->_logger->entrance();
5295
+
5296
+ $all_addons = self::get_all_account_addons();
5297
+ $all_addons[ $this->_plugin->id ] = $addons;
5298
+ self::$_accounts->set_option( 'account_addons', $all_addons, $store );
5299
+ }
5300
+
5301
+ /**
5302
+ * Store account params in the Database.
5303
+ *
5304
+ * @author Vova Feldman (@svovaf)
5305
+ * @since 1.0.1
5306
+ */
5307
+ private function _store_account() {
5308
+ $this->_logger->entrance();
5309
+
5310
+ $this->_store_site( false );
5311
+ $this->_store_user( false );
5312
+ $this->_store_plans( false );
5313
+ $this->_store_licenses( false );
5314
+
5315
+ self::$_accounts->store();
5316
+ }
5317
+
5318
+ /**
5319
+ * Sync user's information.
5320
+ *
5321
+ * @author Vova Feldman (@svovaf)
5322
+ * @since 1.0.3
5323
+ * @uses FS_Api
5324
+ */
5325
+ private function _handle_account_user_sync() {
5326
+ $this->_logger->entrance();
5327
+
5328
+ $api = $this->get_api_user_scope();
5329
+
5330
+ // Get user's information.
5331
+ $user = $api->get( '/', true );
5332
+
5333
+ if ( isset( $user->id ) ) {
5334
+ $this->_user->first = $user->first;
5335
+ $this->_user->last = $user->last;
5336
+ $this->_user->email = $user->email;
5337
+
5338
+ if ( ( ! isset( $this->_user->is_verified ) || false === $this->_user->is_verified ) && $user->is_verified ) {
5339
+ $this->_user->is_verified = $user->is_verified;
5340
+
5341
+ $this->do_action( 'account_email_verified', $user->email );
5342
+
5343
+ $this->_admin_notices->add(
5344
+ __fs( 'email-verified-message' ),
5345
+ __fs( 'right-on' ) . '!'
5346
+ );
5347
+ }
5348
+
5349
+ // Flush user details to DB.
5350
+ $this->_store_user();
5351
+
5352
+ $this->do_action( 'after_account_user_sync', $user );
5353
+ }
5354
+ }
5355
+
5356
+ /**
5357
+ * @author Vova Feldman (@svovaf)
5358
+ * @since 1.0.5
5359
+ * @uses FS_Api
5360
+ *
5361
+ * @param bool $flush
5362
+ *
5363
+ * @return object|\FS_Site
5364
+ */
5365
+ private function _fetch_site( $flush = false ) {
5366
+ $this->_logger->entrance();
5367
+ $api = $this->get_api_site_scope();
5368
+
5369
+ $site = $api->get( '/', $flush );
5370
+
5371
+ if ( ! isset( $site->error ) ) {
5372
+ $site = new FS_Site( $site );
5373
+ $site->slug = $this->_slug;
5374
+ $site->version = $this->get_plugin_version();
5375
+ }
5376
+
5377
+ return $site;
5378
+ }
5379
+
5380
+ /**
5381
+ * @param bool $store
5382
+ *
5383
+ * @return FS_Plugin_Plan|object|false
5384
+ */
5385
+ private function _enrich_site_plan( $store = true ) {
5386
+ // Try to load plan from local cache.
5387
+ $plan = $this->_get_plan_by_id( $this->_site->plan->id );
5388
+
5389
+ if ( false === $plan ) {
5390
+ $plan = $this->_fetch_site_plan();
5391
+ }
5392
+
5393
+ if ( $plan instanceof FS_Plugin_Plan ) {
5394
+ $this->_update_plan( $plan, $store );
5395
+ }
5396
+
5397
+ return $plan;
5398
+ }
5399
+
5400
+ /**
5401
+ * @author Vova Feldman (@svovaf)
5402
+ * @since 1.0.9
5403
+ * @uses FS_Api
5404
+ *
5405
+ * @param bool $store
5406
+ *
5407
+ * @return FS_Plugin_Plan|object|false
5408
+ */
5409
+ private function _enrich_site_trial_plan( $store = true ) {
5410
+ // Try to load plan from local cache.
5411
+ $trial_plan = $this->_get_plan_by_id( $this->_site->trial_plan_id );
5412
+
5413
+ if ( false === $trial_plan ) {
5414
+ $trial_plan = $this->_fetch_site_plan( $this->_site->trial_plan_id );
5415
+ }
5416
+
5417
+ if ( $trial_plan instanceof FS_Plugin_Plan ) {
5418
+ $this->_storage->store( 'trial_plan', $trial_plan, $store );
5419
+ }
5420
+
5421
+ return $trial_plan;
5422
+ }
5423
+
5424
+ /**
5425
+ * @author Vova Feldman (@svovaf)
5426
+ * @since 1.0.9
5427
+ * @uses FS_Api
5428
+ *
5429
+ * @param number|bool $license_id
5430
+ *
5431
+ * @return FS_Subscription|object|bool
5432
+ */
5433
+ private function _fetch_site_license_subscription( $license_id = false ) {
5434
+ $this->_logger->entrance();
5435
+ $api = $this->get_api_site_scope();
5436
+
5437
+ if ( ! is_numeric( $license_id ) ) {
5438
+ $license_id = $this->_license->id;
5439
+ }
5440
+
5441
+ $result = $api->get( "/licenses/{$license_id}/subscriptions.json", true );
5442
+
5443
+ return ! isset( $result->error ) ?
5444
+ ( ( is_array( $result->subscriptions ) && 0 < count( $result->subscriptions ) ) ?
5445
+ new FS_Subscription( $result->subscriptions[0] ) :
5446
+ false
5447
+ ) :
5448
+ $result;
5449
+ }
5450
+
5451
+ /**
5452
+ * @author Vova Feldman (@svovaf)
5453
+ * @since 1.0.4
5454
+ * @uses FS_Api
5455
+ *
5456
+ * @param number|bool $plan_id
5457
+ *
5458
+ * @return FS_Plugin_Plan|object
5459
+ */
5460
+ private function _fetch_site_plan( $plan_id = false ) {
5461
+ $this->_logger->entrance();
5462
+ $api = $this->get_api_site_scope();
5463
+
5464
+ if ( ! is_numeric( $plan_id ) ) {
5465
+ $plan_id = $this->_site->plan->id;
5466
+ }
5467
+
5468
+ $plan = $api->get( "/plans/{$plan_id}.json", true );
5469
+
5470
+ return ! isset( $plan->error ) ? new FS_Plugin_Plan( $plan ) : $plan;
5471
+ }
5472
+
5473
+ /**
5474
+ * @author Vova Feldman (@svovaf)
5475
+ * @since 1.0.5
5476
+ * @uses FS_Api
5477
+ *
5478
+ * @return FS_Plugin_Plan[]|object
5479
+ */
5480
+ private function _fetch_plugin_plans() {
5481
+ $this->_logger->entrance();
5482
+ $api = $this->get_api_site_scope();
5483
+
5484
+ $result = $api->get( '/plans.json', true );
5485
+
5486
+ if ( ! $this->is_api_error( $result ) ) {
5487
+ for ( $i = 0, $len = count( $result->plans ); $i < $len; $i ++ ) {
5488
+ $result->plans[ $i ] = new FS_Plugin_Plan( $result->plans[ $i ] );
5489
+ }
5490
+
5491
+ $result = $result->plans;
5492
+ }
5493
+
5494
+ return $result;
5495
+ }
5496
+
5497
+ /**
5498
+ * @author Vova Feldman (@svovaf)
5499
+ * @since 1.0.5
5500
+ * @uses FS_Api
5501
+ *
5502
+ * @param number|bool $plugin_id
5503
+ *
5504
+ * @return FS_Plugin_License[]|object
5505
+ */
5506
+ private function _fetch_licenses( $plugin_id = false ) {
5507
+ $this->_logger->entrance();
5508
+
5509
+ $api = $this->get_api_user_scope();
5510
+
5511
+ if ( ! is_numeric( $plugin_id ) ) {
5512
+ $plugin_id = $this->_plugin->id;
5513
+ }
5514
+
5515
+ $result = $api->get( "/plugins/{$plugin_id}/licenses.json", true );
5516
+
5517
+ if ( ! isset( $result->error ) ) {
5518
+ for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
5519
+ $result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
5520
+ }
5521
+
5522
+ $result = $result->licenses;
5523
+ }
5524
+
5525
+ return $result;
5526
+ }
5527
+
5528
+ /**
5529
+ * @author Vova Feldman (@svovaf)
5530
+ * @since 1.0.4
5531
+ *
5532
+ * @param FS_Plugin_Plan $plan
5533
+ * @param bool $store
5534
+ */
5535
+ private function _update_plan( $plan, $store = false ) {
5536
+ $this->_logger->entrance();
5537
+
5538
+ $this->_site->plan = $plan;
5539
+ $this->_store_site( $store );
5540
+ }
5541
+
5542
+ /**
5543
+ * @author Vova Feldman (@svovaf)
5544
+ * @since 1.0.5
5545
+ *
5546
+ * @param FS_Plugin_License[] $licenses
5547
+ * @param string|bool $plugin_slug
5548
+ */
5549
+ private function _update_licenses( $licenses, $plugin_slug = false ) {
5550
+ $this->_logger->entrance();
5551
+
5552
+ if ( is_array( $licenses ) ) {
5553
+ for ( $i = 0, $len = count( $licenses ); $i < $len; $i ++ ) {
5554
+ $licenses[ $i ]->updated = time();
5555
+ }
5556
+ }
5557
+
5558
+ if ( ! is_string( $plugin_slug ) ) {
5559
+ $this->_licenses = $licenses;
5560
+ }
5561
+
5562
+ $this->_store_licenses( true, $plugin_slug, $licenses );
5563
+ }
5564
+
5565
+ /**
5566
+ * @author Vova Feldman (@svovaf)
5567
+ * @since 1.0.4
5568
+ *
5569
+ * @param bool|number $plugin_id
5570
+ *
5571
+ * @return object|false New plugin tag info if exist.
5572
+ */
5573
+ private function _fetch_newer_version( $plugin_id = false ) {
5574
+ $latest_tag = $this->_fetch_latest_version( $plugin_id );
5575
+
5576
+ if ( ! is_object( $latest_tag ) ) {
5577
+ return false;
5578
+ }
5579
+
5580
+ // Check if version is actually newer.
5581
+ $has_new_version =
5582
+ // If it's an non-installed add-on then always return latest.
5583
+ ( $this->_is_addon_id( $plugin_id ) && ! $this->is_addon_activated( $plugin_id ) ) ||
5584
+ // Compare versions.
5585
+ version_compare( $this->get_plugin_version(), $latest_tag->version, '<' );
5586
+
5587
+ $this->_logger->departure( $has_new_version ? 'Found newer plugin version ' . $latest_tag->version : 'No new version' );
5588
+
5589
+ return $has_new_version ? $latest_tag : false;
5590
+ }
5591
+
5592
+ /**
5593
+ * @author Vova Feldman (@svovaf)
5594
+ * @since 1.0.5
5595
+ *
5596
+ * @param bool|number $plugin_id
5597
+ *
5598
+ * @return bool|FS_Plugin_Tag
5599
+ */
5600
+ function get_update( $plugin_id = false ) {
5601
+ $this->_logger->entrance();
5602
+
5603
+ if ( ! is_numeric( $plugin_id ) ) {
5604
+ $plugin_id = $this->_plugin->id;
5605
+ }
5606
+
5607
+ $this->_check_updates( true, $plugin_id );
5608
+ $updates = $this->get_all_updates();
5609
+
5610
+ return isset( $updates[ $plugin_id ] ) && is_object( $updates[ $plugin_id ] ) ? $updates[ $plugin_id ] : false;
5611
+ }
5612
+
5613
+ /**
5614
+ * Check if site assigned with active license.
5615
+ *
5616
+ * @author Vova Feldman (@svovaf)
5617
+ * @since 1.0.6
5618
+ */
5619
+ function has_active_license() {
5620
+ return (
5621
+ is_object( $this->_license ) &&
5622
+ is_numeric( $this->_license->id ) &&
5623
+ ! $this->_license->is_expired()
5624
+ );
5625
+ }
5626
+
5627
+ /**
5628
+ * Check if site assigned with license with enabled features.
5629
+ *
5630
+ * @author Vova Feldman (@svovaf)
5631
+ * @since 1.0.6
5632
+ *
5633
+ * @return bool
5634
+ */
5635
+ function has_features_enabled_license() {
5636
+ return (
5637
+ is_object( $this->_license ) &&
5638
+ is_numeric( $this->_license->id ) &&
5639
+ $this->_license->is_features_enabled()
5640
+ );
5641
+ }
5642
+
5643
+ /**
5644
+ * Sync site's plan.
5645
+ *
5646
+ * @author Vova Feldman (@svovaf)
5647
+ * @since 1.0.3
5648
+ *
5649
+ * @uses FS_Api
5650
+ *
5651
+ * @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
5652
+ * the admin.
5653
+ */
5654
+ private function _sync_license( $background = false ) {
5655
+ $this->_logger->entrance();
5656
+
5657
+ $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
5658
+
5659
+ $is_addon_sync = ( ! $this->_plugin->is_addon() && $plugin_id != $this->get_id() );
5660
+
5661
+ if ( $is_addon_sync ) {
5662
+ $this->_sync_addon_license( $plugin_id, $background );
5663
+ } else {
5664
+ $this->_sync_plugin_license( $background );
5665
+ }
5666
+
5667
+ $this->do_action( 'after_account_plan_sync', $this->_site->plan->name );
5668
+ }
5669
+
5670
+ /**
5671
+ * Sync plugin's add-on license.
5672
+ *
5673
+ * @author Vova Feldman (@svovaf)
5674
+ * @since 1.0.6
5675
+ * @uses FS_Api
5676
+ *
5677
+ * @param number $addon_id
5678
+ * @param bool $background
5679
+ */
5680
+ private function _sync_addon_license( $addon_id, $background ) {
5681
+ $this->_logger->entrance();
5682
+
5683
+ if ( $this->is_addon_activated( $addon_id ) ) {
5684
+ // If already installed, use add-on sync.
5685
+ $fs_addon = self::get_instance_by_id( $addon_id );
5686
+ $fs_addon->_sync_license( $background );
5687
+
5688
+ return;
5689
+ }
5690
+
5691
+ // Validate add-on exists.
5692
+ $addon = $this->get_addon( $addon_id );
5693
+
5694
+ if ( ! is_object( $addon ) ) {
5695
+ return;
5696
+ }
5697
+
5698
+ // Add add-on into account add-ons.
5699
+ $account_addons = $this->get_account_addons();
5700
+ if ( ! is_array( $account_addons ) ) {
5701
+ $account_addons = array();
5702
+ }
5703
+ $account_addons[] = $addon->id;
5704
+ $account_addons = array_unique( $account_addons );
5705
+ $this->_store_account_addons( $account_addons );
5706
+
5707
+ // Load add-on licenses.
5708
+ $licenses = $this->_fetch_licenses( $addon->id );
5709
+
5710
+ // Sync add-on licenses.
5711
+ if ( ! isset( $licenses->error ) ) {
5712
+ $this->_update_licenses( $licenses, $addon->slug );
5713
+
5714
+ if ( ! $this->is_addon_installed( $addon->slug ) && FS_License_Manager::has_premium_license( $licenses ) ) {
5715
+ $plans_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$addon_id}/plans.json" );
5716
+
5717
+ if ( ! isset( $plans_result->error ) ) {
5718
+ $plans = array();
5719
+ foreach ( $plans_result->plans as $plan ) {
5720
+ $plans[] = new FS_Plugin_Plan( $plan );
5721
+ }
5722
+
5723
+ $this->_admin_notices->add_sticky(
5724
+ FS_Plan_Manager::instance()->has_free_plan( $plans ) ?
5725
+ sprintf(
5726
+ __fs( 'addon-successfully-upgraded-message' ),
5727
+ $addon->title
5728
+ ) . ' ' . $this->_get_latest_download_link(
5729
+ __fs( 'download-latest-version' ),
5730
+ $addon_id
5731
+ )
5732
+ :
5733
+ sprintf(
5734
+ __fs( 'addon-successfully-purchased-message' ),
5735
+ $addon->title
5736
+ ) . ' ' . $this->_get_latest_download_link(
5737
+ __fs( 'download-latest-version' ),
5738
+ $addon_id
5739
+ ),
5740
+ 'addon_plan_upgraded_' . $addon->slug,
5741
+ __fs( 'yee-haw' ) . '!'
5742
+ );
5743
+ }
5744
+ }
5745
+ }
5746
+ }
5747
+
5748
+ /**
5749
+ * Sync site's plugin plan.
5750
+ *
5751
+ * @author Vova Feldman (@svovaf)
5752
+ * @since 1.0.6
5753
+ * @uses FS_Api
5754
+ *
5755
+ * @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
5756
+ * the admin.
5757
+ */
5758
+ private function _sync_plugin_license( $background = false ) {
5759
+ $this->_logger->entrance();
5760
+
5761
+ // Sync site info.
5762
+ $site = $this->send_install_update( array(), true );
5763
+
5764
+ $plan_change = 'none';
5765
+
5766
+ if ( $this->is_api_error( $site ) ) {
5767
+ $api = $this->get_api_site_scope();
5768
+
5769
+ // Try to ping API to see if not blocked.
5770
+ if ( ! $api->test() ) {
5771
+ // Failed to ping API - blocked!
5772
+ $this->_admin_notices->add(
5773
+ sprintf(
5774
+ __fs( 'server-blocking-access' ),
5775
+ $this->get_plugin_name(),
5776
+ '<a href="' . $api->get_url() . '" target="_blank">' . $api->get_url() . '</a>'
5777
+ ) . '<br> ' . __fs( 'server-error-message' ) . var_export( $site->error, true ),
5778
+ __fs( 'oops' ) . '...',
5779
+ 'error',
5780
+ $background
5781
+ );
5782
+ } else {
5783
+ // Authentication params are broken.
5784
+ $this->_admin_notices->add(
5785
+ __fs( 'wrong-authentication-param-message' ),
5786
+ __fs( 'oops' ) . '...',
5787
+ 'error'
5788
+ );
5789
+ }
5790
+ } else {
5791
+ $site = new FS_Site( $site );
5792
+
5793
+ // Sync licenses.
5794
+ $this->_sync_licenses();
5795
+
5796
+ // Sync plans.
5797
+ $this->_sync_plans();
5798
+
5799
+ // Check if plan / license changed.
5800
+ if ( ! FS_Entity::equals( $site->plan, $this->_site->plan ) ||
5801
+ // Check if trial started.
5802
+ $site->trial_plan_id != $this->_site->trial_plan_id ||
5803
+ $site->trial_ends != $this->_site->trial_ends ||
5804
+ // Check if license changed.
5805
+ $site->license_id != $this->_site->license_id
5806
+ ) {
5807
+ if ( $site->is_trial() && ! $this->_site->is_trial() ) {
5808
+ // New trial started.
5809
+ $this->_site = $site;
5810
+ $plan_change = 'trial_started';
5811
+
5812
+ // Store trial plan information.
5813
+ $this->_enrich_site_trial_plan( true );
5814
+
5815
+ } else if ( $this->_site->is_trial() && ! $site->is_trial() && ! is_numeric( $site->license_id ) ) {
5816
+ // Was in trial, but now trial expired and no license ID.
5817
+ // New trial started.
5818
+ $this->_site = $site;
5819
+ $plan_change = 'trial_expired';
5820
+
5821
+ // Clear trial plan information.
5822
+ $this->_storage->trial_plan = null;
5823
+
5824
+ } else {
5825
+ $is_free = $this->is_free_plan();
5826
+
5827
+ // Make sure license exist and not expired.
5828
+ $new_license = is_null( $site->license_id ) ? null : $this->_get_license_by_id( $site->license_id );
5829
+
5830
+ if ( $is_free && ( ( ! is_object( $new_license ) || $new_license->is_expired() ) ) ) {
5831
+ // The license is expired, so ignore upgrade method.
5832
+ } else {
5833
+ // License changed.
5834
+ $this->_site = $site;
5835
+ $this->_update_site_license( $new_license );
5836
+ $this->_store_licenses();
5837
+ $this->_enrich_site_plan( true );
5838
+
5839
+ $plan_change = $is_free ?
5840
+ 'upgraded' :
5841
+ ( is_object( $new_license ) ?
5842
+ 'changed' :
5843
+ 'downgraded' );
5844
+ }
5845
+ }
5846
+
5847
+ // Store updated site info.
5848
+ $this->_store_site();
5849
+ } else {
5850
+ if ( is_object( $this->_license ) && $this->_license->is_expired() ) {
5851
+ if ( ! $this->has_features_enabled_license() ) {
5852
+ $this->_deactivate_license();
5853
+ $plan_change = 'downgraded';
5854
+ } else {
5855
+ $plan_change = 'expired';
5856
+ }
5857
+ }
5858
+
5859
+ if ( is_numeric( $site->license_id ) && is_object( $this->_license ) ) {
5860
+ $this->_sync_site_subscription( $this->_license );
5861
+ }
5862
+ }
5863
+ }
5864
+
5865
+ switch ( $plan_change ) {
5866
+ case 'none':
5867
+ if ( ! $background && is_admin() ) {
5868
+ $this->_admin_notices->add(
5869
+ sprintf(
5870
+ __fs( 'plan-did-not-change-message' ) . ' ' .
5871
+ sprintf(
5872
+ '<a href="%s">%s</a>',
5873
+ $this->contact_url(
5874
+ 'bug',
5875
+ sprintf( __fs( 'plan-did-not-change-email-message', 'freemius' ),
5876
+ strtoupper( $this->_site->plan->name )
5877
+ )
5878
+ ),
5879
+ __fs( 'contact-us-here' )
5880
+ )
5881
+ ),
5882
+ __fs( 'hmm' ) . '...',
5883
+ 'error'
5884
+ );
5885
+ }
5886
+ break;
5887
+ case 'upgraded':
5888
+ $this->_admin_notices->add_sticky(
5889
+ sprintf(
5890
+ __fs( 'plan-upgraded-message' ),
5891
+ '<i>' . $this->get_plugin_name() . '</i>'
5892
+ ) . ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
5893
+ __fs( 'download-latest-x-version' ),
5894
+ $this->_site->plan->title
5895
+ ) )
5896
+ ),
5897
+ 'plan_upgraded',
5898
+ __fs( 'yee-haw' ) . '!'
5899
+ );
5900
+
5901
+ $this->_admin_notices->remove_sticky( array(
5902
+ 'trial_started',
5903
+ 'trial_promotion',
5904
+ 'trial_expired',
5905
+ 'activation_complete',
5906
+ ) );
5907
+ break;
5908
+ case 'changed':
5909
+ $this->_admin_notices->add_sticky(
5910
+ sprintf(
5911
+ __fs( 'plan-changed-to-x-message' ),
5912
+ $this->_site->plan->title
5913
+ ),
5914
+ 'plan_changed'
5915
+ );
5916
+
5917
+ $this->_admin_notices->remove_sticky( array(
5918
+ 'trial_started',
5919
+ 'trial_promotion',
5920
+ 'trial_expired',
5921
+ 'activation_complete',
5922
+ ) );
5923
+ break;
5924
+ case 'downgraded':
5925
+ $this->_admin_notices->add_sticky(
5926
+ sprintf( __fs( 'license-expired-blocking-message' ) ),
5927
+ 'license_expired',
5928
+ __fs( 'hmm' ) . '...'
5929
+ );
5930
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
5931
+ break;
5932
+ case 'expired':
5933
+ $this->_admin_notices->add_sticky(
5934
+ sprintf( __fs( 'license-expired-non-blocking-message' ), $this->_site->plan->title ),
5935
+ 'license_expired',
5936
+ __fs( 'hmm' ) . '...'
5937
+ );
5938
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
5939
+ break;
5940
+ case 'trial_started':
5941
+ $this->_admin_notices->add_sticky(
5942
+ sprintf(
5943
+ __fs( 'trial-started-message' ),
5944
+ '<i>' . $this->get_plugin_name() . '</i>'
5945
+ ) . ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
5946
+ __fs( 'download-latest-x-version' ),
5947
+ $this->_storage->trial_plan->title
5948
+ ) ) ),
5949
+ 'trial_started',
5950
+ __fs( 'yee-haw' ) . '!'
5951
+ );
5952
+
5953
+ $this->_admin_notices->remove_sticky( array(
5954
+ 'trial_promotion',
5955
+ ) );
5956
+ break;
5957
+ case 'trial_expired':
5958
+ $this->_admin_notices->add_sticky(
5959
+ __fs( 'trial-expired-message' ),
5960
+ 'trial_expired',
5961
+ __fs( 'hmm' ) . '...'
5962
+ );
5963
+ $this->_admin_notices->remove_sticky( array(
5964
+ 'trial_started',
5965
+ 'trial_promotion',
5966
+ 'plan_upgraded',
5967
+ ) );
5968
+ break;
5969
+ }
5970
+
5971
+ if ( 'none' !== $plan_change ) {
5972
+ $this->do_action( 'after_license_change', $plan_change, $this->_site->plan );
5973
+ }
5974
+ }
5975
+
5976
+ /**
5977
+ * @author Vova Feldman (@svovaf)
5978
+ * @since 1.0.5
5979
+ *
5980
+ * @param bool $background
5981
+ */
5982
+ protected function _activate_license( $background = false ) {
5983
+ $this->_logger->entrance();
5984
+
5985
+ $premium_license = $this->_get_available_premium_license();
5986
+
5987
+ if ( ! is_object( $premium_license ) ) {
5988
+ return;
5989
+ }
5990
+
5991
+ $api = $this->get_api_site_scope();
5992
+ $license = $api->call( "/licenses/{$premium_license->id}.json", 'put' );
5993
+
5994
+ if ( isset( $license->error ) ) {
5995
+ if ( ! $background ) {
5996
+ $this->_admin_notices->add(
5997
+ __fs( 'license-activation-failed-message' ) . '<br> ' .
5998
+ __fs( 'server-error-message' ) . ' ' . var_export( $license->error, true ),
5999
+ __fs( 'hmm' ) . '...',
6000
+ 'error'
6001
+ );
6002
+ }
6003
+
6004
+ return;
6005
+ }
6006
+
6007
+ $premium_license = new FS_Plugin_License( $license );
6008
+
6009
+ // Updated site plan.
6010
+ $this->_site->plan->id = $premium_license->plan_id;
6011
+ $this->_update_site_license( $premium_license );
6012
+ $this->_enrich_site_plan( false );
6013
+
6014
+ $this->_store_account();
6015
+
6016
+ if ( ! $background ) {
6017
+ $this->_admin_notices->add_sticky(
6018
+ __fs( 'license-activated-message' ) .
6019
+ ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
6020
+ __fs( 'download-latest-x-version' ),
6021
+ $this->_site->plan->title
6022
+ ) ) ),
6023
+ 'license_activated',
6024
+ __fs( 'yee-haw' ) . '!'
6025
+ );
6026
+ }
6027
+
6028
+ $this->_admin_notices->remove_sticky( array(
6029
+ 'trial_promotion',
6030
+ 'license_expired',
6031
+ ) );
6032
+ }
6033
+
6034
+ /**
6035
+ * @author Vova Feldman (@svovaf)
6036
+ * @since 1.0.5
6037
+ *
6038
+ * @param bool $show_notice
6039
+ */
6040
+ protected function _deactivate_license( $show_notice = true ) {
6041
+ $this->_logger->entrance();
6042
+
6043
+ if ( ! is_object( $this->_license ) ) {
6044
+ $this->_admin_notices->add(
6045
+ sprintf( __fs( 'no-active-license-message' ), $this->_site->plan->title ),
6046
+ __fs( 'hmm' ) . '...'
6047
+ );
6048
+
6049
+ return;
6050
+ }
6051
+
6052
+ $api = $this->get_api_site_scope();
6053
+ $license = $api->call( "/licenses/{$this->_site->license_id}.json", 'delete' );
6054
+
6055
+ if ( isset( $license->error ) ) {
6056
+ $this->_admin_notices->add(
6057
+ __fs( 'license-deactivation-failed-message' ) . '<br> ' .
6058
+ __fs( 'server-error-message' ) . ' ' . var_export( $license->error, true ),
6059
+ __fs( 'hmm' ) . '...',
6060
+ 'error'
6061
+ );
6062
+
6063
+ return;
6064
+ }
6065
+
6066
+ // Update license cache.
6067
+ for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
6068
+ if ( $license->id == $this->_licenses[ $i ]->id ) {
6069
+ $this->_licenses[ $i ] = new FS_Plugin_License( $license );
6070
+ }
6071
+ }
6072
+
6073
+ // Updated site plan to default.
6074
+ $this->_sync_plans();
6075
+ $this->_site->plan->id = $this->_plans[0]->id;
6076
+ // Unlink license from site.
6077
+ $this->_update_site_license( null );
6078
+ $this->_enrich_site_plan( false );
6079
+
6080
+ $this->_store_account();
6081
+
6082
+ if ( $show_notice ) {
6083
+ $this->_admin_notices->add(
6084
+ sprintf( __fs( 'license-deactivation-message' ), $this->_site->plan->title ),
6085
+ __fs( 'ok' )
6086
+ );
6087
+ }
6088
+
6089
+ $this->_admin_notices->remove_sticky( array(
6090
+ 'plan_upgraded',
6091
+ 'license_activated',
6092
+ ) );
6093
+ }
6094
+
6095
+ /**
6096
+ * Site plan downgrade.
6097
+ *
6098
+ * @author Vova Feldman (@svovaf)
6099
+ * @since 1.0.4
6100
+ *
6101
+ * @uses FS_Api
6102
+ */
6103
+ private function _downgrade_site() {
6104
+ $this->_logger->entrance();
6105
+
6106
+ $api = $this->get_api_site_scope();
6107
+ $site = $api->call( 'downgrade.json', 'put' );
6108
+
6109
+ $plan_downgraded = false;
6110
+ $plan = false;
6111
+ if ( ! isset( $site->error ) ) {
6112
+ $prev_plan_id = $this->_site->plan->id;
6113
+
6114
+ // Update new site plan id.
6115
+ $this->_site->plan->id = $site->plan_id;
6116
+
6117
+ $plan = $this->_enrich_site_plan();
6118
+ $subscription = $this->_sync_site_subscription( $this->_license );
6119
+
6120
+ // Plan downgraded if plan was changed or subscription was cancelled.
6121
+ $plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) ||
6122
+ ( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() );
6123
+ } else {
6124
+ // handle different error cases.
6125
+
6126
+ }
6127
+
6128
+ if ( $plan_downgraded ) {
6129
+ // Remove previous sticky message about upgrade (if exist).
6130
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
6131
+
6132
+ $this->_admin_notices->add(
6133
+ sprintf( __fs( 'plan-x-downgraded-message' ),
6134
+ $plan->title,
6135
+ human_time_diff( time(), strtotime( $this->_license->expiration ) )
6136
+ )
6137
+ );
6138
+
6139
+ // Store site updates.
6140
+ $this->_store_site();
6141
+ } else {
6142
+ $this->_admin_notices->add(
6143
+ __fs( 'plan-downgraded-failure-message' ),
6144
+ __fs( 'oops' ) . '...',
6145
+ 'error'
6146
+ );
6147
+ }
6148
+ }
6149
+
6150
+ /**
6151
+ * Cancel site trial.
6152
+ *
6153
+ * @author Vova Feldman (@svovaf)
6154
+ * @since 1.0.9
6155
+ *
6156
+ * @uses FS_Api
6157
+ */
6158
+ private function _cancel_trial() {
6159
+ $this->_logger->entrance();
6160
+
6161
+ if ( ! $this->is_trial() ) {
6162
+ $this->_admin_notices->add(
6163
+ __fs( 'trial-cancel-no-trial-message' ),
6164
+ __fs( 'oops' ) . '...',
6165
+ 'error'
6166
+ );
6167
+
6168
+ return;
6169
+ }
6170
+
6171
+ $api = $this->get_api_site_scope();
6172
+ $site = $api->call( 'trials.json', 'delete' );
6173
+
6174
+ $trial_cancelled = false;
6175
+
6176
+ if ( ! isset( $site->error ) ) {
6177
+ $prev_trial_ends = $this->_site->trial_ends;
6178
+
6179
+ // Update new site plan id.
6180
+ $this->_site->trial_ends = $site->trial_ends;
6181
+
6182
+ $trial_cancelled = ( $prev_trial_ends != $site->trial_ends );
6183
+ } else {
6184
+ // handle different error cases.
6185
+
6186
+ }
6187
+
6188
+ if ( $trial_cancelled ) {
6189
+ // Remove previous sticky message about upgrade (if exist).
6190
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
6191
+
6192
+ $this->_admin_notices->add(
6193
+ sprintf( __fs( 'trial-cancel-message' ), $this->_storage->trial_plan->title )
6194
+ );
6195
+
6196
+ $this->_admin_notices->remove_sticky( array(
6197
+ 'trial_started',
6198
+ 'trial_promotion',
6199
+ 'plan_upgraded',
6200
+ ) );
6201
+
6202
+ // Store site updates.
6203
+ $this->_store_site();
6204
+
6205
+ // Clear trial plan information.
6206
+ unset( $this->_storage->trial_plan );
6207
+ } else {
6208
+ $this->_admin_notices->add(
6209
+ __fs( 'trial-cancel-failure-message' ),
6210
+ __fs( 'oops' ) . '...',
6211
+ 'error'
6212
+ );
6213
+ }
6214
+ }
6215
+
6216
+ /**
6217
+ * @author Vova Feldman (@svovaf)
6218
+ * @since 1.0.6
6219
+ *
6220
+ * @param bool|number $plugin_id
6221
+ *
6222
+ * @return bool
6223
+ */
6224
+ private function _is_addon_id( $plugin_id ) {
6225
+ return is_numeric( $plugin_id ) && ( $this->get_id() != $plugin_id );
6226
+ }
6227
+
6228
+ /**
6229
+ * Check if user eligible to download premium version updates.
6230
+ *
6231
+ * @author Vova Feldman (@svovaf)
6232
+ * @since 1.0.6
6233
+ *
6234
+ * @return bool
6235
+ */
6236
+ private function _can_download_premium() {
6237
+ return $this->has_active_license() ||
6238
+ ( $this->is_trial() && ! $this->get_trial_plan()->is_free() );
6239
+ }
6240
+
6241
+ /**
6242
+ *
6243
+ * @author Vova Feldman (@svovaf)
6244
+ * @since 1.0.6
6245
+ *
6246
+ * @param bool|number $addon_id
6247
+ * @param string $type "json" or "zip"
6248
+ *
6249
+ * @return string
6250
+ */
6251
+ private function _get_latest_version_endpoint( $addon_id = false, $type = 'json' ) {
6252
+
6253
+ $is_addon = $this->_is_addon_id( $addon_id );
6254
+
6255
+ $is_premium = null;
6256
+ if ( ! $is_addon ) {
6257
+ $is_premium = $this->_can_download_premium();
6258
+ } else if ( $this->is_addon_activated( $addon_id ) ) {
6259
+ $is_premium = self::get_instance_by_id( $addon_id )->_can_download_premium();
6260
+ }
6261
+
6262
+ return // If add-on, then append add-on ID.
6263
+ ( $is_addon ? "/addons/$addon_id" : '' ) .
6264
+ '/updates/latest.' . $type .
6265
+ // If add-on and not yet activated, try to fetch based on server licensing.
6266
+ ( is_bool( $is_premium ) ? '?is_premium=' . json_encode( $is_premium ) : '' );
6267
+ }
6268
+
6269
+ /**
6270
+ * @author Vova Feldman (@svovaf)
6271
+ * @since 1.0.4
6272
+ *
6273
+ * @param bool|number $addon_id
6274
+ *
6275
+ * @return object|false Plugin latest tag info.
6276
+ */
6277
+ function _fetch_latest_version( $addon_id = false ) {
6278
+ $tag = $this->get_api_site_or_plugin_scope()->get(
6279
+ $this->_get_latest_version_endpoint( $addon_id, 'json' ),
6280
+ true
6281
+ );
6282
+ $latest_version = ( is_object( $tag ) && isset( $tag->version ) ) ? $tag->version : 'couldn\'t get';
6283
+ $this->_logger->departure( 'Latest version ' . $latest_version );
6284
+
6285
+ return ( is_object( $tag ) && isset( $tag->version ) ) ? $tag : false;
6286
+ }
6287
+
6288
+ #region Download Plugin ------------------------------------------------------------------
6289
+
6290
+ /**
6291
+ * Download latest plugin version, based on plan.
6292
+ * The download will be fetched via the API first.
6293
+ *
6294
+ * @author Vova Feldman (@svovaf)
6295
+ * @since 1.0.4
6296
+ *
6297
+ * @param bool|number $plugin_id
6298
+ *
6299
+ * @uses FS_Api
6300
+ *
6301
+ * @deprecated
6302
+ */
6303
+ private function _download_latest( $plugin_id = false ) {
6304
+ $this->_logger->entrance();
6305
+
6306
+ $is_addon = $this->_is_addon_id( $plugin_id );
6307
+
6308
+ $is_premium = $this->_can_download_premium();
6309
+
6310
+ $latest = $this->get_api_site_scope()->call(
6311
+ $this->_get_latest_version_endpoint( $plugin_id, 'zip' )
6312
+ );
6313
+
6314
+ $slug = $this->_slug;
6315
+ if ( $is_addon ) {
6316
+ $addon = $this->get_addon( $plugin_id );
6317
+ $slug = is_object( $addon ) ? $addon->slug : 'addon';
6318
+ }
6319
+
6320
+ if ( ! is_object( $latest ) ) {
6321
+ header( "Content-Type: application/zip" );
6322
+ header( "Content-Disposition: attachment; filename={$slug}" . ( ! $is_addon && $is_premium ? '-premium' : '' ) . ".zip" );
6323
+ header( "Content-Length: " . strlen( $latest ) );
6324
+ echo $latest;
6325
+
6326
+ exit();
6327
+ }
6328
+ }
6329
+
6330
+ /**
6331
+ * Download latest plugin version, based on plan.
6332
+ *
6333
+ * Not like _download_latest(), this will redirect the page
6334
+ * to secure download url to prevent dual download (from FS to WP server,
6335
+ * and then from WP server to the client / browser).
6336
+ *
6337
+ * @author Vova Feldman (@svovaf)
6338
+ * @since 1.0.9
6339
+ *
6340
+ * @param bool|number $plugin_id
6341
+ *
6342
+ * @uses FS_Api
6343
+ * @uses wp_redirect()
6344
+ */
6345
+ private function _download_latest_directly( $plugin_id = false ) {
6346
+ $this->_logger->entrance();
6347
+
6348
+ wp_redirect( $this->_get_latest_download_api_url( $plugin_id ) );
6349
+ }
6350
+
6351
+ /**
6352
+ * Get latest plugin FS API download URL.
6353
+ *
6354
+ * @author Vova Feldman (@svovaf)
6355
+ * @since 1.0.9
6356
+ *
6357
+ * @param bool|number $plugin_id
6358
+ *
6359
+ * @return string
6360
+ */
6361
+ private function _get_latest_download_api_url( $plugin_id = false ) {
6362
+ $this->_logger->entrance();
6363
+
6364
+ return $this->get_api_site_scope()->get_signed_url(
6365
+ $this->_get_latest_version_endpoint( $plugin_id, 'zip' )
6366
+ );
6367
+ }
6368
+
6369
+ /**
6370
+ * Get latest plugin download link.
6371
+ *
6372
+ * @author Vova Feldman (@svovaf)
6373
+ * @since 1.0.9
6374
+ *
6375
+ * @param string $label
6376
+ * @param bool|number $plugin_id
6377
+ *
6378
+ * @return string
6379
+ */
6380
+ private function _get_latest_download_link( $label, $plugin_id = false ) {
6381
+ return sprintf(
6382
+ '<a target="_blank" href="%s">%s</a>',
6383
+ $this->_get_latest_download_local_url( $plugin_id ),
6384
+ $label
6385
+ );
6386
+ }
6387
+
6388
+ /**
6389
+ * Get latest plugin download local URL.
6390
+ *
6391
+ * @author Vova Feldman (@svovaf)
6392
+ * @since 1.0.9
6393
+ *
6394
+ * @param bool|number $plugin_id
6395
+ *
6396
+ * @return string
6397
+ */
6398
+ function _get_latest_download_local_url( $plugin_id = false ) {
6399
+ // Add timestamp to protect from caching.
6400
+ $params = array( 'ts' => WP_FS__SCRIPT_START_TIME );
6401
+
6402
+ if ( ! empty( $plugin_id ) ) {
6403
+ $params['plugin_id'] = $plugin_id;
6404
+ }
6405
+
6406
+ return $this->get_account_url( 'download_latest', $params );
6407
+ }
6408
+
6409
+ #endregion Download Plugin ------------------------------------------------------------------
6410
+
6411
+ /**
6412
+ * @author Vova Feldman (@svovaf)
6413
+ * @since 1.0.4
6414
+ *
6415
+ * @uses FS_Api
6416
+ *
6417
+ * @param bool $background Hints the method if it's a background updates check. If false, it means that
6418
+ * was initiated by the admin.
6419
+ * @param bool|number $plugin_id
6420
+ */
6421
+ private function _check_updates( $background = false, $plugin_id = false ) {
6422
+ $this->_logger->entrance();
6423
+
6424
+ // Check if there's a newer version for download.
6425
+ $new_version = $this->_fetch_newer_version( $plugin_id );
6426
+
6427
+ $update = null;
6428
+ if ( is_object( $new_version ) ) {
6429
+ $update = new FS_Plugin_Tag( $new_version );
6430
+
6431
+ if ( ! $background ) {
6432
+ $this->_admin_notices->add(
6433
+ sprintf(
6434
+ __fs( 'version-x-released' ) . ' ' . __fS( 'please-download-x' ),
6435
+ $update->version,
6436
+ sprintf(
6437
+ '<a href="%s" target="_blank">%s</a>',
6438
+ $this->get_account_url( 'download_latest' ),
6439
+ sprintf( __fs( 'latest-x-version' ), $this->_site->plan->title )
6440
+ )
6441
+ ),
6442
+ __fs( 'new' ) . '!'
6443
+ );
6444
+ }
6445
+ } else if ( false === $new_version && ! $background ) {
6446
+ $this->_admin_notices->add(
6447
+ __fs( 'you-have-latest' ),
6448
+ __fs( 'you-are-good' )
6449
+ );
6450
+ }
6451
+
6452
+ $this->_store_update( $update, true, $plugin_id );
6453
+ }
6454
+
6455
+ /**
6456
+ * @author Vova Feldman (@svovaf)
6457
+ * @since 1.0.4
6458
+ *
6459
+ * @uses FS_Api
6460
+ *
6461
+ */
6462
+ private function _sync_addons() {
6463
+ $this->_logger->entrance();
6464
+
6465
+ $result = $this->get_api_site_or_plugin_scope()->get( '/addons.json?enriched=true', true );
6466
+
6467
+ if ( isset( $result->error ) ) {
6468
+ return;
6469
+ }
6470
+
6471
+ $addons = array();
6472
+ for ( $i = 0, $len = count( $result->plugins ); $i < $len; $i ++ ) {
6473
+ $addons[ $i ] = new FS_Plugin( $result->plugins[ $i ] );
6474
+ }
6475
+
6476
+ $this->_store_addons( $addons, true );
6477
+ }
6478
+
6479
+ /**
6480
+ * Handle user email update.
6481
+ *
6482
+ * @author Vova Feldman (@svovaf)
6483
+ * @since 1.0.3
6484
+ * @uses FS_Api
6485
+ *
6486
+ * @param string $new_email
6487
+ *
6488
+ * @return object
6489
+ */
6490
+ private function _update_email( $new_email ) {
6491
+ $this->_logger->entrance();
6492
+
6493
+
6494
+ $api = $this->get_api_user_scope();
6495
+ $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,email,is_verified", 'put', array(
6496
+ 'email' => $new_email,
6497
+ 'after_email_confirm_url' => $this->_get_admin_page_url(
6498
+ 'account',
6499
+ array( 'fs_action' => 'sync_user' )
6500
+ ),
6501
+ ) );
6502
+
6503
+ if ( ! isset( $user->error ) ) {
6504
+ $this->_user->email = $user->email;
6505
+ $this->_user->is_verified = $user->is_verified;
6506
+ $this->_store_user();
6507
+ } else {
6508
+ // handle different error cases.
6509
+
6510
+ }
6511
+
6512
+ return $user;
6513
+ }
6514
+
6515
+ /**
6516
+ * @author Vova Feldman (@svovaf)
6517
+ * @since 1.1.1
6518
+ *
6519
+ * @param mixed $result
6520
+ *
6521
+ * @return bool Is API result contains an error.
6522
+ */
6523
+ private function is_api_error( $result ) {
6524
+ return ( is_object( $result ) && isset( $result->error ) ) ||
6525
+ is_string( $result );
6526
+ }
6527
+
6528
+ /**
6529
+ * Start install ownership change.
6530
+ *
6531
+ * @author Vova Feldman (@svovaf)
6532
+ * @since 1.1.1
6533
+ * @uses FS_Api
6534
+ *
6535
+ * @param string $candidate_email
6536
+ *
6537
+ * @return bool Is ownership change successfully initiated.
6538
+ */
6539
+ private function init_change_owner( $candidate_email ) {
6540
+ $this->_logger->entrance();
6541
+
6542
+ $api = $this->get_api_site_scope();
6543
+ $result = $api->call( "/users/{$this->_user->id}.json", 'put', array(
6544
+ 'email' => $candidate_email,
6545
+ 'after_confirm_url' => $this->_get_admin_page_url(
6546
+ 'account',
6547
+ array( 'fs_action' => 'change_owner' )
6548
+ ),
6549
+ ) );
6550
+
6551
+ return ! $this->is_api_error( $result );
6552
+ }
6553
+
6554
+ /**
6555
+ * Handle install ownership change.
6556
+ *
6557
+ * @author Vova Feldman (@svovaf)
6558
+ * @since 1.1.1
6559
+ * @uses FS_Api
6560
+ *
6561
+ * @return bool Was ownership change successfully complete.
6562
+ */
6563
+ private function complete_change_owner() {
6564
+ $this->_logger->entrance();
6565
+
6566
+ $site_result = $this->get_api_site_scope( true )->get();
6567
+ $site = new FS_Site( $site_result );
6568
+ $this->_site = $site;
6569
+
6570
+ $user = new FS_User();
6571
+ $user->id = fs_request_get( 'user_id' );
6572
+
6573
+ // Validate install's user and given user.
6574
+ if ( $user->id != $this->_site->user_id ) {
6575
+ return false;
6576
+ }
6577
+
6578
+ $user->public_key = fs_request_get( 'user_public_key' );
6579
+ $user->secret_key = fs_request_get( 'user_secret_key' );
6580
+
6581
+ // Fetch new user information.
6582
+ $this->_user = $user;
6583
+ $user_result = $this->get_api_user_scope( true )->get();
6584
+ $user = new FS_User( $user_result );
6585
+ $this->_user = $user;
6586
+
6587
+ $this->_set_account( $user, $site );
6588
+
6589
+ return true;
6590
+ }
6591
+
6592
+ /**
6593
+ * Handle user name update.
6594
+ *
6595
+ * @author Vova Feldman (@svovaf)
6596
+ * @since 1.0.9
6597
+ * @uses FS_Api
6598
+ *
6599
+ * @return object
6600
+ */
6601
+ private function update_user_name() {
6602
+ $this->_logger->entrance();
6603
+ $name = fs_request_get( 'fs_user_name_' . $this->_slug, '' );
6604
+
6605
+ $api = $this->get_api_user_scope();
6606
+ $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,first,last", 'put', array(
6607
+ 'name' => $name,
6608
+ ) );
6609
+
6610
+ if ( ! isset( $user->error ) ) {
6611
+ $this->_user->first = $user->first;
6612
+ $this->_user->last = $user->last;
6613
+ $this->_store_user();
6614
+ } else {
6615
+ // handle different error cases.
6616
+
6617
+ }
6618
+
6619
+ return $user;
6620
+ }
6621
+
6622
+ /**
6623
+ * Verify user email.
6624
+ *
6625
+ * @author Vova Feldman (@svovaf)
6626
+ * @since 1.0.3
6627
+ * @uses FS_Api
6628
+ */
6629
+ private function verify_email() {
6630
+ $this->_handle_account_user_sync();
6631
+
6632
+ if ( $this->_user->is_verified() ) {
6633
+ return;
6634
+ }
6635
+
6636
+ $api = $this->get_api_site_scope();
6637
+ $result = $api->call( "/users/{$this->_user->id}/verify.json", 'put', array(
6638
+ 'after_email_confirm_url' => $this->_get_admin_page_url(
6639
+ 'account',
6640
+ array( 'fs_action' => 'sync_user' )
6641
+ )
6642
+ ) );
6643
+
6644
+ if ( ! isset( $result->error ) ) {
6645
+ $this->_admin_notices->add( sprintf(
6646
+ __fs( 'verification-email-sent-message' ),
6647
+ sprintf( '<a href="mailto:%1s">%2s</a>', esc_url( $this->_user->email ), $this->_user->email )
6648
+ ) );
6649
+ } else {
6650
+ // handle different error cases.
6651
+
6652
+ }
6653
+ }
6654
+
6655
+ /**
6656
+ * @author Vova Feldman (@svovaf)
6657
+ * @since 1.1.2
6658
+ *
6659
+ * @return string
6660
+ */
6661
+ private function get_activation_url() {
6662
+ return $this->apply_filters( 'connect_url', $this->_get_admin_page_url() );
6663
+ }
6664
+
6665
+ /**
6666
+ * @author Vova Feldman (@svovaf)
6667
+ * @since 1.1.3
6668
+ *
6669
+ * @param string $filter Filter name.
6670
+ *
6671
+ * @return string
6672
+ */
6673
+ private function get_after_activation_url( $filter ) {
6674
+ $first_time_path = $this->_menu->get_first_time_path();
6675
+
6676
+ return $this->apply_filters(
6677
+ $filter,
6678
+ empty( $first_time_path ) ?
6679
+ $this->_get_admin_page_url() :
6680
+ $first_time_path
6681
+ );
6682
+ }
6683
+
6684
+ /**
6685
+ * Handle account page updates / edits / actions.
6686
+ *
6687
+ * @author Vova Feldman (@svovaf)
6688
+ * @since 1.0.2
6689
+ *
6690
+ */
6691
+ private function _handle_account_edits() {
6692
+ if ( ! current_user_can( 'activate_plugins' ) ) {
6693
+ return;
6694
+ }
6695
+
6696
+ $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
6697
+ $action = fs_get_action();
6698
+
6699
+ switch ( $action ) {
6700
+ case 'delete_account':
6701
+ check_admin_referer( $action );
6702
+
6703
+ if ( $plugin_id == $this->get_id() ) {
6704
+ $this->delete_account_event();
6705
+
6706
+ // Clear user and site.
6707
+ $this->_site = null;
6708
+ $this->_user = null;
6709
+
6710
+ if ( fs_redirect( $this->get_activation_url() ) ) {
6711
+ exit();
6712
+ }
6713
+ } else {
6714
+ if ( $this->is_addon_activated( $plugin_id ) ) {
6715
+ $fs_addon = self::get_instance_by_id( $plugin_id );
6716
+ $fs_addon->delete_account_event();
6717
+
6718
+ if ( fs_redirect( $this->_get_admin_page_url( 'account' ) ) ) {
6719
+ exit();
6720
+ }
6721
+ }
6722
+ }
6723
+
6724
+ return;
6725
+
6726
+ case 'downgrade_account':
6727
+ check_admin_referer( $action );
6728
+ $this->_downgrade_site();
6729
+
6730
+ return;
6731
+
6732
+ case 'activate_license':
6733
+ check_admin_referer( $action );
6734
+
6735
+ if ( $plugin_id == $this->get_id() ) {
6736
+ $this->_activate_license();
6737
+ } else {
6738
+ if ( $this->is_addon_activated( $plugin_id ) ) {
6739
+ $fs_addon = self::get_instance_by_id( $plugin_id );
6740
+ $fs_addon->_activate_license();
6741
+ }
6742
+ }
6743
+
6744
+ return;
6745
+
6746
+ case 'deactivate_license':
6747
+ check_admin_referer( $action );
6748
+
6749
+ if ( $plugin_id == $this->get_id() ) {
6750
+ $this->_deactivate_license();
6751
+ } else {
6752
+ if ( $this->is_addon_activated( $plugin_id ) ) {
6753
+ $fs_addon = self::get_instance_by_id( $plugin_id );
6754
+ $fs_addon->_deactivate_license();
6755
+ }
6756
+ }
6757
+
6758
+ return;
6759
+
6760
+ case 'check_updates':
6761
+ check_admin_referer( $action );
6762
+ $this->_check_updates();
6763
+
6764
+ return;
6765
+
6766
+ case 'change_owner':
6767
+ $state = fs_request_get( 'state', 'init' );
6768
+ switch ( $state ) {
6769
+ case 'init':
6770
+ $candidate_email = fs_request_get( 'candidate_email', '' );
6771
+
6772
+ if ( $this->init_change_owner( $candidate_email ) ) {
6773
+ $this->_admin_notices->add( sprintf( __fs( 'change-owner-request-sent-x' ), '<b>' . $this->_user->email . '</b>' ) );
6774
+ }
6775
+ break;
6776
+ case 'owner_confirmed':
6777
+ $candidate_email = fs_request_get( 'candidate_email', '' );
6778
+
6779
+ $this->_admin_notices->add( sprintf( __fs( 'change-owner-request_owner-confirmed' ), '<b>' . $candidate_email . '</b>' ) );
6780
+ break;
6781
+ case 'candidate_confirmed':
6782
+ if ( $this->complete_change_owner() ) {
6783
+ $this->_admin_notices->add_sticky(
6784
+ sprintf( __fs( 'change-owner-request_candidate-confirmed' ), '<b>' . $this->_user->email . '</b>' ),
6785
+ 'ownership_changed',
6786
+ __fs( 'congrats' ) . '!'
6787
+ );
6788
+ } else {
6789
+ // @todo Handle failed ownership change message.
6790
+ }
6791
+ break;
6792
+ }
6793
+
6794
+ return;
6795
+
6796
+ case 'update_email':
6797
+ check_admin_referer( 'update_email' );
6798
+
6799
+ $new_email = fs_request_get( 'fs_email_' . $this->_slug, '' );
6800
+ $result = $this->_update_email( $new_email );
6801
+
6802
+ if ( isset( $result->error ) ) {
6803
+ switch ( $result->error->code ) {
6804
+ case 'user_exist':
6805
+ $this->_admin_notices->add(
6806
+ __fs( 'user-exist-message' ) . ' ' .
6807
+ sprintf( __fs( 'user-exist-message_ownership' ), '<b>' . $new_email . '</b>' ) .
6808
+ sprintf(
6809
+ '<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
6810
+ $this->get_account_url( 'change_owner', array(
6811
+ 'state' => 'init',
6812
+ 'candidate_email' => $new_email
6813
+ ) ),
6814
+ __fs( 'change-ownership' )
6815
+ ),
6816
+ __fs( 'oops' ) . '...',
6817
+ 'error'
6818
+ );
6819
+ break;
6820
+ }
6821
+ } else {
6822
+ $this->_admin_notices->add( __fs( 'email-updated-message' ) );
6823
+ }
6824
+
6825
+ return;
6826
+
6827
+ case 'update_user_name':
6828
+ check_admin_referer( 'update_user_name' );
6829
+
6830
+ $result = $this->update_user_name();
6831
+
6832
+ if ( isset( $result->error ) ) {
6833
+ $this->_admin_notices->add(
6834
+ __fs( 'name-update-failed-message' ),
6835
+ __fs( 'oops' ) . '...',
6836
+ 'error'
6837
+ );
6838
+ } else {
6839
+ $this->_admin_notices->add( __fs( 'name-updated-message' ) );
6840
+ }
6841
+
6842
+ return;
6843
+
6844
+ #region Actions that might be called from external links (e.g. email)
6845
+
6846
+ case 'cancel_trial':
6847
+ $this->_cancel_trial();
6848
+
6849
+ return;
6850
+
6851
+ case 'verify_email':
6852
+ $this->verify_email();
6853
+
6854
+ return;
6855
+
6856
+ case 'sync_user':
6857
+ $this->_handle_account_user_sync();
6858
+
6859
+ return;
6860
+
6861
+ case $this->_slug . '_sync_license':
6862
+ $this->_sync_license();
6863
+
6864
+ return;
6865
+
6866
+ case 'download_latest':
6867
+ $this->_download_latest_directly( $plugin_id );
6868
+
6869
+ return;
6870
+
6871
+ #endregion
6872
+ }
6873
+
6874
+ if ( WP_FS__IS_POST_REQUEST ) {
6875
+ $properties = array( 'site_secret_key', 'site_id', 'site_public_key' );
6876
+ foreach ( $properties as $p ) {
6877
+ if ( 'update_' . $p === $action ) {
6878
+ check_admin_referer( $action );
6879
+
6880
+ $this->_logger->log( $action );
6881
+
6882
+ $site_property = substr( $p, strlen( 'site_' ) );
6883
+ $site_property_value = fs_request_get( 'fs_' . $p . '_' . $this->_slug, '' );
6884
+ $this->get_site()->{$site_property} = $site_property_value;
6885
+
6886
+ // Store account after modification.
6887
+ $this->_store_site();
6888
+
6889
+ $this->do_action( 'account_property_edit', 'site', $site_property, $site_property_value );
6890
+
6891
+ $this->_admin_notices->add( sprintf(
6892
+ __fs( 'x-updated' ),
6893
+ '<b>' . str_replace( '_', ' ', $p ) . '</b>' ) );
6894
+
6895
+ return;
6896
+ }
6897
+ }
6898
+ }
6899
+ }
6900
+
6901
+ /**
6902
+ * Account page resources load.
6903
+ *
6904
+ * @author Vova Feldman (@svovaf)
6905
+ * @since 1.0.6
6906
+ */
6907
+ function _account_page_load() {
6908
+ $this->_logger->entrance();
6909
+
6910
+ $this->_logger->info( var_export( $_REQUEST, true ) );
6911
+
6912
+ fs_enqueue_local_style( 'fs_account', '/admin/account.css' );
6913
+
6914
+ if ( $this->_has_addons() ) {
6915
+ wp_enqueue_script( 'plugin-install' );
6916
+ add_thickbox();
6917
+
6918
+ function fs_addons_body_class( $classes ) {
6919
+ $classes .= ' plugins-php';
6920
+
6921
+ return $classes;
6922
+ }
6923
+
6924
+ add_filter( 'admin_body_class', 'fs_addons_body_class' );
6925
+ }
6926
+
6927
+ $this->_handle_account_edits();
6928
+
6929
+ $this->do_action( 'account_page_load_before_departure' );
6930
+ }
6931
+
6932
+ /**
6933
+ * Render account page.
6934
+ *
6935
+ * @author Vova Feldman (@svovaf)
6936
+ * @since 1.0.0
6937
+ */
6938
+ function _account_page_render() {
6939
+ $this->_logger->entrance();
6940
+
6941
+ $vars = array( 'slug' => $this->_slug );
6942
+ fs_require_once_template( 'account.php', $vars );
6943
+ }
6944
+
6945
+ /**
6946
+ * Render account connect page.
6947
+ *
6948
+ * @author Vova Feldman (@svovaf)
6949
+ * @since 1.0.7
6950
+ */
6951
+ function _connect_page_render() {
6952
+ $this->_logger->entrance();
6953
+
6954
+ $vars = array( 'slug' => $this->_slug );
6955
+ if ( $this->is_pending_activation() ) {
6956
+ fs_require_once_template( 'pending-activation.php', $vars );
6957
+ } else {
6958
+ fs_require_once_template( 'connect.php', $vars );
6959
+ }
6960
+ }
6961
+
6962
+ /**
6963
+ * Load required resources before add-ons page render.
6964
+ *
6965
+ * @author Vova Feldman (@svovaf)
6966
+ * @since 1.0.6
6967
+ */
6968
+ function _addons_page_load() {
6969
+ $this->_logger->entrance();
6970
+
6971
+ fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
6972
+
6973
+ wp_enqueue_script( 'plugin-install' );
6974
+ add_thickbox();
6975
+
6976
+ function fs_addons_body_class( $classes ) {
6977
+ $classes .= ' plugins-php';
6978
+
6979
+ return $classes;
6980
+ }
6981
+
6982
+ add_filter( 'admin_body_class', 'fs_addons_body_class' );
6983
+
6984
+ if ( ! $this->is_registered() && $this->is_org_repo_compliant() ) {
6985
+ $this->_admin_notices->add(
6986
+ sprintf( __fs( 'addons-info-external-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
6987
+ __fs( 'heads-up' ),
6988
+ 'update-nag'
6989
+ );
6990
+ }
6991
+ }
6992
+
6993
+ /**
6994
+ * Render add-ons page.
6995
+ *
6996
+ * @author Vova Feldman (@svovaf)
6997
+ * @since 1.0.6
6998
+ */
6999
+ function _addons_page_render() {
7000
+ $this->_logger->entrance();
7001
+
7002
+ $vars = array( 'slug' => $this->_slug );
7003
+ fs_require_once_template( 'add-ons.php', $vars );
7004
+ }
7005
+
7006
+ /* Pricing & Upgrade
7007
+ ------------------------------------------------------------------------------------------------------------------*/
7008
+ /**
7009
+ * Render pricing page.
7010
+ *
7011
+ * @author Vova Feldman (@svovaf)
7012
+ * @since 1.0.0
7013
+ */
7014
+ function _pricing_page_render() {
7015
+ $this->_logger->entrance();
7016
+
7017
+ $vars = array( 'slug' => $this->_slug );
7018
+
7019
+ if ( 'true' === fs_request_get( 'checkout', false ) ) {
7020
+ fs_require_once_template( 'checkout.php', $vars );
7021
+ } else {
7022
+ fs_require_once_template( 'pricing.php', $vars );
7023
+ }
7024
+ }
7025
+
7026
+ #region Contact Us ------------------------------------------------------------------
7027
+
7028
+ /**
7029
+ * Render contact-us page.
7030
+ *
7031
+ * @author Vova Feldman (@svovaf)
7032
+ * @since 1.0.3
7033
+ */
7034
+ function _contact_page_render() {
7035
+ $this->_logger->entrance();
7036
+
7037
+ $vars = array( 'slug' => $this->_slug );
7038
+ fs_require_once_template( 'contact.php', $vars );
7039
+ }
7040
+
7041
+ #endregion ------------------------------------------------------------------
7042
+
7043
+ /**
7044
+ * Hide all admin notices to prevent distractions.
7045
+ *
7046
+ * @author Vova Feldman (@svovaf)
7047
+ * @since 1.0.3
7048
+ *
7049
+ * @uses remove_all_actions()
7050
+ */
7051
+ function _hide_admin_notices() {
7052
+ remove_all_actions( 'admin_notices' );
7053
+ remove_all_actions( 'network_admin_notices' );
7054
+ remove_all_actions( 'all_admin_notices' );
7055
+ remove_all_actions( 'user_admin_notices' );
7056
+ }
7057
+
7058
+ function _clean_admin_content_section_hook() {
7059
+ $this->_hide_admin_notices();
7060
+
7061
+ // Hide footer.
7062
+ echo '<style>#wpfooter { display: none !important; }</style>';
7063
+ }
7064
+
7065
+ /**
7066
+ * Attach to admin_head hook to hide all admin notices.
7067
+ *
7068
+ * @author Vova Feldman (@svovaf)
7069
+ * @since 1.0.3
7070
+ */
7071
+ function _clean_admin_content_section() {
7072
+ add_action( 'admin_head', array( &$this, '_clean_admin_content_section_hook' ) );
7073
+ }
7074
+
7075
+ /* CSS & JavaScript
7076
+ ------------------------------------------------------------------------------------------------------------------*/
7077
+ /* function _enqueue_script($handle, $src) {
7078
+ $url = plugins_url( substr( WP_FS__DIR_JS, strlen( $this->_plugin_dir_path ) ) . '/assets/js/' . $src );
7079
+
7080
+ $this->_logger->entrance( 'script = ' . $url );
7081
+
7082
+ wp_enqueue_script( $handle, $url );
7083
+ }*/
7084
+
7085
+ /* SDK
7086
+ ------------------------------------------------------------------------------------------------------------------*/
7087
+ private $_user_api;
7088
+
7089
+ /**
7090
+ *
7091
+ * @author Vova Feldman (@svovaf)
7092
+ * @since 1.0.2
7093
+ *
7094
+ * @param bool $flush
7095
+ *
7096
+ * @return FS_Api
7097
+ */
7098
+ function get_api_user_scope( $flush = false ) {
7099
+ if ( ! isset( $this->_user_api ) || $flush ) {
7100
+ $this->_user_api = FS_Api::instance(
7101
+ $this->_slug,
7102
+ 'user',
7103
+ $this->_user->id,
7104
+ $this->_user->public_key,
7105
+ ! $this->is_live(),
7106
+ $this->_user->secret_key
7107
+ );
7108
+ }
7109
+
7110
+ return $this->_user_api;
7111
+ }
7112
+
7113
+ private $_site_api;
7114
+
7115
+ /**
7116
+ *
7117
+ * @author Vova Feldman (@svovaf)
7118
+ * @since 1.0.2
7119
+ *
7120
+ * @param bool $flush
7121
+ *
7122
+ * @return FS_Api
7123
+ */
7124
+ function get_api_site_scope( $flush = false ) {
7125
+ if ( ! isset( $this->_site_api ) || $flush ) {
7126
+ $this->_site_api = FS_Api::instance(
7127
+ $this->_slug,
7128
+ 'install',
7129
+ $this->_site->id,
7130
+ $this->_site->public_key,
7131
+ ! $this->is_live(),
7132
+ $this->_site->secret_key
7133
+ );
7134
+ }
7135
+
7136
+ return $this->_site_api;
7137
+ }
7138
+
7139
+ private $_plugin_api;
7140
+
7141
+ /**
7142
+ * Get plugin public API scope.
7143
+ *
7144
+ * @author Vova Feldman (@svovaf)
7145
+ * @since 1.0.7
7146
+ *
7147
+ * @return FS_Api
7148
+ */
7149
+ function get_api_plugin_scope() {
7150
+ if ( ! isset( $this->_plugin_api ) ) {
7151
+ $this->_plugin_api = FS_Api::instance(
7152
+ $this->_slug,
7153
+ 'plugin',
7154
+ $this->_plugin->id,
7155
+ $this->_plugin->public_key,
7156
+ ! $this->is_live()
7157
+ );
7158
+ }
7159
+
7160
+ return $this->_plugin_api;
7161
+ }
7162
+
7163
+ /**
7164
+ * Get site API scope object (fallback to public plugin scope when not registered).
7165
+ *
7166
+ * @author Vova Feldman (@svovaf)
7167
+ * @since 1.0.7
7168
+ *
7169
+ * @return FS_Api
7170
+ */
7171
+ function get_api_site_or_plugin_scope() {
7172
+ return $this->is_registered() ?
7173
+ $this->get_api_site_scope() :
7174
+ $this->get_api_plugin_scope();
7175
+ }
7176
+
7177
+ /**
7178
+ * Show trial promotional notice (if any trial exist).
7179
+ *
7180
+ * @author Vova Feldman (@svovaf)
7181
+ * @since 1.0.9
7182
+ *
7183
+ * @param $plans
7184
+ */
7185
+ function _check_for_trial_plans( $plans ) {
7186
+ $this->_storage->has_trial_plan = FS_Plan_Manager::instance()->has_trial_plan( $plans );
7187
+ }
7188
+
7189
+ /**
7190
+ * Show trial promotional notice (if any trial exist).
7191
+ *
7192
+ * @author Vova Feldman (@svovaf)
7193
+ * @since 1.0.9
7194
+ */
7195
+ function _add_trial_notice() {
7196
+ // Check if trial already utilized.
7197
+ if ( $this->_site->is_trial_utilized() ) {
7198
+ return;
7199
+ }
7200
+
7201
+ // Check if already paying.
7202
+ if ( $this->is_paying() ) {
7203
+ return;
7204
+ }
7205
+
7206
+ // Check if trial message is already shown.
7207
+ if ( $this->_admin_notices->has_sticky( 'trial_promotion' ) ) {
7208
+ return;
7209
+ }
7210
+
7211
+ $trial_plans = FS_Plan_Manager::instance()->get_trial_plans( $this->_plans );
7212
+ $trial_plans_count = count( $trial_plans );
7213
+
7214
+ // Check if any of the plans contains trial.
7215
+ if ( 0 === $trial_plans_count ) {
7216
+ return;
7217
+ }
7218
+
7219
+ /**
7220
+ * @var FS_Plugin_Plan $paid_plan
7221
+ */
7222
+ $paid_plan = $trial_plans[0];
7223
+ $require_subscription = $paid_plan->is_require_subscription;
7224
+ $upgrade_url = $this->get_trial_url();
7225
+ $cc_string = $require_subscription ?
7226
+ sprintf( __fs( 'no-commitment-for-x-days' ), $paid_plan->trial_period ) :
7227
+ __fs( 'no-cc-required' ) . '!';
7228
+
7229
+
7230
+ $total_paid_plans = count( $this->_plans ) - ( FS_Plan_Manager::instance()->has_free_plan( $this->_plans ) ? 1 : 0 );
7231
+
7232
+ if ( $total_paid_plans === $trial_plans_count ) {
7233
+ // All paid plans have trials.
7234
+ $message = sprintf(
7235
+ __fs( 'hey' ) . '! ' . __fs( 'trial-x-promotion-message' ),
7236
+ sprintf( '<b>%s</b>', $this->get_plugin_name() ),
7237
+ strtolower( __fs( 'awesome' ) ),
7238
+ $paid_plan->trial_period
7239
+ );
7240
+ } else {
7241
+ $plans_string = '';
7242
+ for ( $i = 0; $i < $trial_plans_count; $i ++ ) {
7243
+ $plans_string .= sprintf( '<a href="%s">%s</a>', $upgrade_url, $trial_plans[ $i ]->title );
7244
+
7245
+ if ( $i < $trial_plans_count - 2 ) {
7246
+ $plans_string .= ', ';
7247
+ } else if ( $i == $trial_plans_count - 2 ) {
7248
+ $plans_string .= ' and ';
7249
+ }
7250
+ }
7251
+
7252
+ // Not all paid plans have trials.
7253
+ $message = sprintf(
7254
+ __fs( 'hey' ) . '! ' . __fs( 'trial-x-promotion-message' ),
7255
+ sprintf( '<b>%s</b>', $this->get_plugin_name() ),
7256
+ $plans_string,
7257
+ $paid_plan->trial_period
7258
+ );
7259
+ }
7260
+
7261
+ $message .= ' ' . $cc_string;
7262
+
7263
+ // Add start trial button.
7264
+ $message .= ' ' . sprintf(
7265
+ '<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
7266
+ $upgrade_url,
7267
+ __fs( 'start-free-trial' )
7268
+ );
7269
+
7270
+ $this->_admin_notices->add_sticky(
7271
+ $this->apply_filters( 'trial_promotion_message', $message ),
7272
+ 'trial_promotion',
7273
+ '',
7274
+ 'promotion'
7275
+ );
7276
+
7277
+ $this->_storage->trial_promotion_shown = WP_FS__SCRIPT_START_TIME;
7278
+ }
7279
+
7280
+ /* Action Links
7281
+ ------------------------------------------------------------------------------------------------------------------*/
7282
+ private $_action_links_hooked = false;
7283
+ private $_action_links = array();
7284
+
7285
+ /**
7286
+ * @author Vova Feldman (@svovaf)
7287
+ * @since 1.0.0
7288
+ *
7289
+ * @return bool
7290
+ */
7291
+ private function is_plugin_action_links_hooked() {
7292
+ $this->_logger->entrance( json_encode( $this->_action_links_hooked ) );
7293
+
7294
+ return $this->_action_links_hooked;
7295
+ }
7296
+
7297
+ /**
7298
+ * Hook to plugin action links filter.
7299
+ *
7300
+ * @author Vova Feldman (@svovaf)
7301
+ * @since 1.0.0
7302
+ */
7303
+ private function hook_plugin_action_links() {
7304
+ $this->_logger->entrance();
7305
+
7306
+ $this->_action_links_hooked = true;
7307
+
7308
+ $this->_logger->log( 'Adding action links hooks.' );
7309
+
7310
+ // Add action link to settings page.
7311
+ add_filter( 'plugin_action_links_' . $this->_plugin_basename, array(
7312
+ &$this,
7313
+ '_modify_plugin_action_links_hook'
7314
+ ), WP_FS__DEFAULT_PRIORITY, 2 );
7315
+ add_filter( 'network_admin_plugin_action_links_' . $this->_plugin_basename, array(
7316
+ &$this,
7317
+ '_modify_plugin_action_links_hook'
7318
+ ), WP_FS__DEFAULT_PRIORITY, 2 );
7319
+ }
7320
+
7321
+ /**
7322
+ * Add plugin action link.
7323
+ *
7324
+ * @author Vova Feldman (@svovaf)
7325
+ * @since 1.0.0
7326
+ *
7327
+ * @param $label
7328
+ * @param $url
7329
+ * @param bool $external
7330
+ * @param int $priority
7331
+ * @param bool $key
7332
+ */
7333
+ function add_plugin_action_link( $label, $url, $external = false, $priority = WP_FS__DEFAULT_PRIORITY, $key = false ) {
7334
+ $this->_logger->entrance();
7335
+
7336
+ if ( ! isset( $this->_action_links[ $priority ] ) ) {
7337
+ $this->_action_links[ $priority ] = array();
7338
+ }
7339
+
7340
+ if ( false === $key ) {
7341
+ $key = preg_replace( "/[^A-Za-z0-9 ]/", '', strtolower( $label ) );
7342
+ }
7343
+
7344
+ $this->_action_links[ $priority ][] = array(
7345
+ 'label' => $label,
7346
+ 'href' => $url,
7347
+ 'key' => $key,
7348
+ 'external' => $external
7349
+ );
7350
+ }
7351
+
7352
+ /**
7353
+ * Adds Upgrade and Add-Ons links to the main Plugins page link actions collection.
7354
+ *
7355
+ * @author Vova Feldman (@svovaf)
7356
+ * @since 1.0.0
7357
+ */
7358
+ function _add_upgrade_action_link() {
7359
+ $this->_logger->entrance();
7360
+
7361
+ if ( $this->is_registered() ) {
7362
+ if ( ! $this->is_paying() && $this->has_paid_plan() ) {
7363
+ $this->add_plugin_action_link(
7364
+ __fs( 'upgrade' ),
7365
+ $this->get_upgrade_url(),
7366
+ false,
7367
+ 20,
7368
+ 'upgrade'
7369
+ );
7370
+ }
7371
+
7372
+ if ( $this->_has_addons() ) {
7373
+ $this->add_plugin_action_link(
7374
+ __fs( 'add-ons' ),
7375
+ $this->_get_admin_page_url( 'addons' ),
7376
+ false,
7377
+ WP_FS__DEFAULT_PRIORITY,
7378
+ 'addons'
7379
+ );
7380
+ }
7381
+ }
7382
+ }
7383
+
7384
+ /**
7385
+ * Forward page to activation page.
7386
+ *
7387
+ * @author Vova Feldman (@svovaf)
7388
+ * @since 1.0.3
7389
+ */
7390
+ function _redirect_on_activation_hook() {
7391
+ $url = false;
7392
+ $plugin_fs = false;
7393
+
7394
+ if ( ! $this->is_addon() ) {
7395
+ $first_time_path = $this->_menu->get_first_time_path();
7396
+ $plugin_fs = $this;
7397
+ $url = $plugin_fs->is_activation_mode() ?
7398
+ $plugin_fs->get_activation_url() :
7399
+ ( empty( $first_time_path ) ?
7400
+ $this->_get_admin_page_url() :
7401
+ $first_time_path );
7402
+ } else {
7403
+ if ( $this->is_parent_plugin_installed() ) {
7404
+ $plugin_fs = self::get_parent_instance();
7405
+ }
7406
+
7407
+ if ( is_object( $plugin_fs ) ) {
7408
+ if ( ! $plugin_fs->is_registered() ) {
7409
+ // Forward to parent plugin connect when parent not registered.
7410
+ $url = $plugin_fs->get_activation_url();
7411
+ } else {
7412
+ // Forward to account page.
7413
+ $url = $plugin_fs->_get_admin_page_url( 'account' );
7414
+ }
7415
+ }
7416
+ }
7417
+
7418
+ if ( is_string( $url ) ) {
7419
+ fs_redirect( $url );
7420
+ exit();
7421
+ }
7422
+ }
7423
+
7424
+ /**
7425
+ * Modify plugin's page action links collection.
7426
+ *
7427
+ * @author Vova Feldman (@svovaf)
7428
+ * @since 1.0.0
7429
+ *
7430
+ * @param array $links
7431
+ * @param $file
7432
+ *
7433
+ * @return array
7434
+ */
7435
+ function _modify_plugin_action_links_hook( $links, $file ) {
7436
+ $this->_logger->entrance();
7437
+
7438
+ ksort( $this->_action_links );
7439
+
7440
+ foreach ( $this->_action_links as $new_links ) {
7441
+ foreach ( $new_links as $link ) {
7442
+ $links[ $link['key'] ] = '<a href="' . $link['href'] . '"' . ( $link['external'] ? ' target="_blank"' : '' ) . '>' . $link['label'] . '</a>';
7443
+ }
7444
+ }
7445
+
7446
+ /*
7447
+ * This HTML element is used to identify the correct plugin when attaching an event to its Deactivate link.
7448
+ *
7449
+ * If user is paying or in trial and have the free version installed,
7450
+ * assume that the deactivation is for the upgrade process, so this is not needed.
7451
+ */
7452
+ if ( ! $this->is_paying_or_trial() || $this->is_premium() ) {
7453
+ if ( isset( $links['deactivate'] ) ) {
7454
+ $links['deactivate'] .= '<i class="fs-slug" data-slug="' . $this->_slug . '"></i>';
7455
+ }
7456
+ }
7457
+
7458
+ return $links;
7459
+ }
7460
+
7461
+ /**
7462
+ * Adds admin message.
7463
+ *
7464
+ * @author Vova Feldman (@svovaf)
7465
+ * @since 1.0.4
7466
+ *
7467
+ * @param string $message
7468
+ * @param string $title
7469
+ * @param string $type
7470
+ */
7471
+ function add_admin_message( $message, $title = '', $type = 'success' ) {
7472
+ $this->_admin_notices->add( $message, $title, $type );
7473
+ }
7474
+
7475
+ /**
7476
+ * Adds sticky admin message.
7477
+ *
7478
+ * @author Vova Feldman (@svovaf)
7479
+ * @since 1.1.0
7480
+ *
7481
+ * @param string $message
7482
+ * @param string $id
7483
+ * @param string $title
7484
+ * @param string $type
7485
+ */
7486
+ function add_sticky_admin_message( $message, $id, $title = '', $type = 'success' ) {
7487
+ $this->_admin_notices->add_sticky( $message, $id, $title, $type );
7488
+ }
7489
+
7490
+ /* Plugin Auto-Updates (@since 1.0.4)
7491
+ ------------------------------------------------------------------------------------------------------------------*/
7492
+ /**
7493
+ * @var string[]
7494
+ */
7495
+ private static $_auto_updated_plugins;
7496
+
7497
+ /**
7498
+ * @todo TEST IF IT WORKS!!!
7499
+ *
7500
+ * Include plugins for automatic updates based on stored settings.
7501
+ *
7502
+ * @see http://wordpress.stackexchange.com/questions/131394/how-do-i-exclude-plugins-from-getting-automatically-updated/131404#131404
7503
+ *
7504
+ * @author Vova Feldman (@svovaf)
7505
+ * @since 1.0.4
7506
+ *
7507
+ * @param bool $update Whether to update (not used for plugins)
7508
+ * @param object $item The plugin's info
7509
+ *
7510
+ * @return bool
7511
+ */
7512
+ static function _include_plugins_in_auto_update( $update, $item ) {
7513
+ // Before version 3.8.2 the $item was the file name of the plugin,
7514
+ // while in 3.8.2 statistics were added (https://core.trac.wordpress.org/changeset/27905).
7515
+ $by_slug = ( (int) str_replace( '.', '', get_bloginfo( 'version' ) ) >= 382 );
7516
+
7517
+ if ( ! isset( self::$_auto_updated_plugins ) ) {
7518
+ $plugins = self::$_accounts->get_option( 'plugins', array() );
7519
+
7520
+ $identifiers = array();
7521
+ foreach ( $plugins as $p ) {
7522
+ /**
7523
+ * @var FS_Plugin $p
7524
+ */
7525
+ if ( isset( $p->auto_update ) && $p->auto_update ) {
7526
+ $identifiers[] = ( $by_slug ? $p->slug : plugin_basename( $p->file ) );
7527
+ }
7528
+ }
7529
+
7530
+ self::$_auto_updated_plugins = $identifiers;
7531
+ }
7532
+
7533
+ if ( in_array( $by_slug ? $item->slug : $item, self::$_auto_updated_plugins ) ) {
7534
+ return true;
7535
+ }
7536
+
7537
+ // Pass update decision to next filters
7538
+ return $update;
7539
+ }
7540
+
7541
+ #region Versioning ------------------------------------------------------------------
7542
+
7543
+ /**
7544
+ * Check if Freemius in SDK upgrade mode.
7545
+ *
7546
+ * @author Vova Feldman (@svovaf)
7547
+ * @since 1.0.9
7548
+ *
7549
+ * @return bool
7550
+ */
7551
+ function is_sdk_upgrade_mode() {
7552
+ return isset( $this->_storage->sdk_upgrade_mode ) ?
7553
+ $this->_storage->sdk_upgrade_mode :
7554
+ false;
7555
+ }
7556
+
7557
+ /**
7558
+ * Turn SDK upgrade mode off.
7559
+ *
7560
+ * @author Vova Feldman (@svovaf)
7561
+ * @since 1.0.9
7562
+ *
7563
+ * @return bool
7564
+ */
7565
+ function set_sdk_upgrade_complete() {
7566
+ $this->_storage->sdk_upgrade_mode = false;
7567
+ }
7568
+
7569
+ /**
7570
+ * Check if plugin upgrade mode.
7571
+ *
7572
+ * @author Vova Feldman (@svovaf)
7573
+ * @since 1.0.9
7574
+ *
7575
+ * @return bool
7576
+ */
7577
+ function is_plugin_upgrade_mode() {
7578
+ return isset( $this->_storage->plugin_upgrade_mode ) ?
7579
+ $this->_storage->plugin_upgrade_mode :
7580
+ false;
7581
+ }
7582
+
7583
+ /**
7584
+ * Turn plugin upgrade mode off.
7585
+ *
7586
+ * @author Vova Feldman (@svovaf)
7587
+ * @since 1.0.9
7588
+ *
7589
+ * @return bool
7590
+ */
7591
+ function set_plugin_upgrade_complete() {
7592
+ $this->_storage->plugin_upgrade_mode = false;
7593
+ }
7594
+
7595
+ #endregion ------------------------------------------------------------------
7596
+
7597
+ #region Marketing ------------------------------------------------------------------
7598
+
7599
+ /**
7600
+ * Check if current user purchased any other plugins before.
7601
+ *
7602
+ * @author Vova Feldman (@svovaf)
7603
+ * @since 1.0.9
7604
+ *
7605
+ * @return bool
7606
+ */
7607
+ function has_purchased_before() {
7608
+ // TODO: Implement has_purchased_before() method.
7609
+ }
7610
+
7611
+ /**
7612
+ * Check if current user classified as an agency.
7613
+ *
7614
+ * @author Vova Feldman (@svovaf)
7615
+ * @since 1.0.9
7616
+ *
7617
+ * @return bool
7618
+ */
7619
+ function is_agency() {
7620
+ // TODO: Implement is_agency() method.
7621
+ }
7622
+
7623
+ /**
7624
+ * Check if current user classified as a developer.
7625
+ *
7626
+ * @author Vova Feldman (@svovaf)
7627
+ * @since 1.0.9
7628
+ *
7629
+ * @return bool
7630
+ */
7631
+ function is_developer() {
7632
+ // TODO: Implement is_developer() method.
7633
+ }
7634
+
7635
+ /**
7636
+ * Check if current user classified as a business.
7637
+ *
7638
+ * @author Vova Feldman (@svovaf)
7639
+ * @since 1.0.9
7640
+ *
7641
+ * @return bool
7642
+ */
7643
+ function is_business() {
7644
+ // TODO: Implement is_business() method.
7645
+ }
7646
+
7647
+ #endregion ------------------------------------------------------------------
7648
+ }
classes/freemius/includes/class-fs-api.php ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Class FS_Api
15
+ *
16
+ * Wraps Freemius API SDK to handle:
17
+ * 1. Clock sync.
18
+ * 2. Fallback to HTTP when HTTPS fails.
19
+ * 3. Adds caching layer to GET requests.
20
+ * 4. Adds consistency for failed requests by using last cached version.
21
+ */
22
+ class FS_Api {
23
+ /**
24
+ * @var FS_Api[]
25
+ */
26
+ private static $_instances = array();
27
+
28
+ /**
29
+ * @var FS_Option_Manager Freemius options, options-manager.
30
+ */
31
+ private static $_options;
32
+
33
+ /**
34
+ * @var FS_Option_Manager API Caching layer
35
+ */
36
+ private static $_cache;
37
+
38
+ /**
39
+ * @var int Clock diff in seconds between current server to API server.
40
+ */
41
+ private static $_clock_diff;
42
+
43
+ /**
44
+ * @var Freemius_Api
45
+ */
46
+ private $_api;
47
+
48
+ /**
49
+ * @var string
50
+ */
51
+ private $_slug;
52
+
53
+ /**
54
+ * @var FS_Logger
55
+ * @since 1.0.4
56
+ */
57
+ private $_logger;
58
+
59
+ /**
60
+ * @param string $slug
61
+ * @param string $scope 'app', 'developer', 'user' or 'install'.
62
+ * @param number $id Element's id.
63
+ * @param string $public_key Public key.
64
+ * @param bool $is_sandbox
65
+ * @param bool|string $secret_key Element's secret key.
66
+ *
67
+ * @return FS_Api
68
+ */
69
+ static function instance( $slug, $scope, $id, $public_key, $is_sandbox, $secret_key = false ) {
70
+ $identifier = md5( $slug . $scope . $id . $public_key . ( is_string( $secret_key ) ? $secret_key : '' ) . json_encode( $is_sandbox ) );
71
+
72
+ if ( ! isset( self::$_instances[ $identifier ] ) ) {
73
+ if ( 0 === count( self::$_instances ) ) {
74
+ self::_init();
75
+ }
76
+
77
+ self::$_instances[ $identifier ] = new FS_Api( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox );
78
+ }
79
+
80
+ return self::$_instances[ $identifier ];
81
+ }
82
+
83
+ private static function _init() {
84
+ if ( ! class_exists( 'Freemius_Api' ) ) {
85
+ require_once( WP_FS__DIR_SDK . '/Freemius.php' );
86
+ }
87
+
88
+ self::$_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true );
89
+ self::$_cache = FS_Option_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME, true );
90
+
91
+ self::$_clock_diff = self::$_options->get_option( 'api_clock_diff', 0 );
92
+ Freemius_Api::SetClockDiff( self::$_clock_diff );
93
+
94
+ if ( self::$_options->get_option( 'api_force_http', false ) ) {
95
+ Freemius_Api::SetHttp();
96
+ }
97
+ }
98
+
99
+ /**
100
+ * @param string $slug
101
+ * @param string $scope 'app', 'developer', 'user' or 'install'.
102
+ * @param number $id Element's id.
103
+ * @param string $public_key Public key.
104
+ * @param bool|string $secret_key Element's secret key.
105
+ * @param bool $is_sandbox
106
+ */
107
+ private function __construct( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox ) {
108
+ $this->_api = new Freemius_Api( $scope, $id, $public_key, $secret_key, $is_sandbox );
109
+
110
+ $this->_slug = $slug;
111
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_api', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
112
+ }
113
+
114
+ /**
115
+ * Find clock diff between server and API server, and store the diff locally.
116
+ *
117
+ * @param bool|int $diff
118
+ *
119
+ * @return bool|int False if clock diff didn't change, otherwise returns the clock diff in seconds.
120
+ */
121
+ private function _sync_clock_diff( $diff = false ) {
122
+ $this->_logger->entrance();
123
+
124
+ // Sync clock and store.
125
+ $new_clock_diff = ( false === $diff ) ?
126
+ $this->_api->FindClockDiff() :
127
+ $diff;
128
+
129
+ if ( $new_clock_diff === self::$_clock_diff ) {
130
+ return false;
131
+ }
132
+
133
+ self::$_clock_diff = $new_clock_diff;
134
+
135
+ // Update API clock's diff.
136
+ $this->_api->SetClockDiff( self::$_clock_diff );
137
+
138
+ // Store new clock diff in storage.
139
+ self::$_options->set_option( 'api_clock_diff', self::$_clock_diff, true );
140
+
141
+ return $new_clock_diff;
142
+ }
143
+
144
+ /**
145
+ * Override API call to enable retry with servers' clock auto sync method.
146
+ *
147
+ * @param string $path
148
+ * @param string $method
149
+ * @param array $params
150
+ * @param bool $retry Is in retry or first call attempt.
151
+ *
152
+ * @return array|mixed|string|void
153
+ */
154
+ private function _call( $path, $method = 'GET', $params = array(), $retry = false ) {
155
+ $this->_logger->entrance();
156
+
157
+ $result = $this->_api->Api( $path, $method, $params );
158
+
159
+ if ( null !== $result &&
160
+ isset( $result->error ) &&
161
+ 'request_expired' === $result->error->code
162
+ ) {
163
+ if ( ! $retry ) {
164
+ $diff = isset( $result->error->timestamp ) ?
165
+ ( time() - strtotime( $result->error->timestamp ) ) :
166
+ false;
167
+
168
+ // Try to sync clock diff.
169
+ if ( false !== $this->_sync_clock_diff( $diff ) ) {
170
+ // Retry call with new synced clock.
171
+ return $this->_call( $path, $method, $params, true );
172
+ }
173
+ }
174
+ }
175
+
176
+ if ( null !== $result && isset( $result->error ) ) {
177
+ // Log API errors.
178
+ $this->_logger->error( $result->error->message );
179
+ }
180
+
181
+ return $result;
182
+ }
183
+
184
+ /**
185
+ * Override API call to wrap it in servers' clock sync method.
186
+ *
187
+ * @param string $path
188
+ * @param string $method
189
+ * @param array $params
190
+ *
191
+ * @return array|mixed|string|void
192
+ * @throws Freemius_Exception
193
+ */
194
+ function call( $path, $method = 'GET', $params = array() ) {
195
+ return $this->_call( $path, $method, $params );
196
+ }
197
+
198
+ /**
199
+ * Get API request URL signed via query string.
200
+ *
201
+ * @param string $path
202
+ *
203
+ * @return string
204
+ */
205
+ function get_signed_url( $path ) {
206
+ return $this->_api->GetSignedUrl( $path );
207
+ }
208
+
209
+ /**
210
+ * @param string $path
211
+ * @param bool $flush
212
+ * @param int $expiration (optional) Time until expiration in seconds from now, defaults to 24 hours
213
+ *
214
+ * @return stdClass|mixed
215
+ */
216
+ function get( $path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
217
+ $cache_key = $this->get_cache_key( $path );
218
+
219
+ // Always flush during development.
220
+ if ( WP_FS__DEV_MODE || $this->_api->IsSandbox() ) {
221
+ $flush = true;
222
+ }
223
+
224
+ // Get result from cache.
225
+ $cache_entry = self::$_cache->get_option( $cache_key, false );
226
+
227
+ $fetch = false;
228
+ if ( $flush ||
229
+ false === $cache_entry ||
230
+ ! isset( $cache_entry->timestamp ) ||
231
+ ! is_numeric( $cache_entry->timestamp ) ||
232
+ $cache_entry->timestamp < WP_FS__SCRIPT_START_TIME
233
+ ) {
234
+ $fetch = true;
235
+ }
236
+
237
+ if ( $fetch ) {
238
+ $result = $this->call( $path );
239
+
240
+ if ( ! is_object( $result ) || isset( $result->error ) ) {
241
+ if ( is_object( $cache_entry ) &&
242
+ isset( $cache_entry->result ) &&
243
+ ! isset( $cache_entry->result->error )
244
+ ) {
245
+ // If there was an error during a newer data fetch,
246
+ // fallback to older data version.
247
+ $result = $cache_entry->result;
248
+ } else {
249
+ // If no older data version, return result without
250
+ // caching the error.
251
+ return $result;
252
+ }
253
+ }
254
+
255
+ $cache_entry = new stdClass();
256
+ $cache_entry->result = $result;
257
+ $cache_entry->timestamp = WP_FS__SCRIPT_START_TIME + $expiration;
258
+ self::$_cache->set_option( $cache_key, $cache_entry, true );
259
+ }
260
+
261
+ return $cache_entry->result;
262
+ }
263
+
264
+ private function get_cache_key( $path, $method = 'GET', $params = array() ) {
265
+ $canonized = $this->_api->CanonizePath( $path );
266
+ // $exploded = explode('/', $canonized);
267
+ // return $method . '_' . array_pop($exploded) . '_' . md5($canonized . json_encode($params));
268
+ return $method . ':' . $canonized . ( ! empty( $params ) ? '#' . md5( json_encode( $params ) ) : '' );
269
+ }
270
+
271
+ /**
272
+ * Test API connectivity.
273
+ *
274
+ * @since 1.0.9 If fails, try to fallback to HTTP.
275
+ *
276
+ * @param null|string $unique_anonymous_id
277
+ *
278
+ * @return bool True if successful connectivity to the API.
279
+ */
280
+ function test( $unique_anonymous_id = null ) {
281
+ $this->_logger->entrance();
282
+
283
+ if ( ! function_exists( 'curl_version' ) ) {
284
+ // cUrl extension is not active.
285
+ return false;
286
+ }
287
+
288
+ $test = is_null( $unique_anonymous_id ) ?
289
+ $this->_api->Test() :
290
+ $this->_api->Test( $this->_call( 'ping.json?uid=' . $unique_anonymous_id ) );
291
+
292
+ if ( false === $test && $this->_api->IsHttps() ) {
293
+ // Fallback to HTTP, since HTTPS fails.
294
+ $this->_api->SetHttp();
295
+
296
+ self::$_options->set_option( 'api_force_http', true, true );
297
+
298
+ $test = is_null( $unique_anonymous_id ) ?
299
+ $this->_api->Test() :
300
+ $this->_api->Test( $this->_call( 'ping.json?uid=' . $unique_anonymous_id ) );
301
+ }
302
+
303
+ return $test;
304
+ }
305
+
306
+ /**
307
+ * Ping API for connectivity test, and return result object.
308
+ *
309
+ * @author Vova Feldman (@svovaf)
310
+ * @since 1.0.9
311
+ *
312
+ * @param null|string $unique_anonymous_id
313
+ * @param bool $is_update False if new plugin installation.
314
+ *
315
+ * @return object
316
+ */
317
+ function ping( $unique_anonymous_id = null, $is_update = false ) {
318
+ return is_null( $unique_anonymous_id ) ?
319
+ $this->_api->Ping() :
320
+ $this->_call( 'ping.json?' . http_build_query( array(
321
+ 'uid' => $unique_anonymous_id,
322
+ 'is_update' => $is_update,
323
+ ) ) );
324
+ }
325
+
326
+ /**
327
+ * Check if valid ping request result.
328
+ *
329
+ * @author Vova Feldman (@svovaf)
330
+ * @since 1.1.1
331
+ *
332
+ * @param mixed $pong
333
+ *
334
+ * @return bool
335
+ */
336
+ function is_valid_ping( $pong ) {
337
+ return $this->_api->Test( $pong );
338
+ }
339
+
340
+ function get_url( $path = '' ) {
341
+ return $this->_api->GetUrl( $path );
342
+ }
343
+
344
+ /**
345
+ * Clear API cache.
346
+ *
347
+ * @author Vova Feldman (@svovaf)
348
+ * @since 1.0.9
349
+ */
350
+ static function clear_cache() {
351
+ self::$_cache = FS_Option_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME, true );
352
+ self::$_cache->clear( true );
353
+ }
354
+ }
classes/freemius/includes/class-fs-logger.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Logger {
14
+ private $_id;
15
+ private $_on = false;
16
+ private $_echo = false;
17
+ private $_file_start = 0;
18
+
19
+ private static $LOGGERS = array();
20
+ private static $LOG = array();
21
+ private static $CNT = 0;
22
+ private static $_HOOKED_FOOTER = false;
23
+
24
+ private function __construct( $id, $on = false, $echo = false ) {
25
+ $this->_id = $id;
26
+
27
+ $bt = debug_backtrace();
28
+ $caller = $bt[2];
29
+
30
+ $this->_file_start = strpos( $caller['file'], 'plugins' ) + strlen( 'plugins/' );
31
+
32
+ if ( $on ) {
33
+ $this->on();
34
+ }
35
+ if ( $echo ) {
36
+ $this->echo_on();
37
+ }
38
+ }
39
+
40
+ /**
41
+ * @param string $id
42
+ * @param bool $on
43
+ * @param bool $echo
44
+ *
45
+ * @return FS_Logger
46
+ */
47
+ public static function get_logger( $id, $on = false, $echo = false ) {
48
+ $id = strtolower( $id );
49
+
50
+ if ( ! isset( self::$LOGGERS[ $id ] ) ) {
51
+ self::$LOGGERS[ $id ] = new FS_Logger( $id, $on, $echo );
52
+ }
53
+
54
+ return self::$LOGGERS[ $id ];
55
+ }
56
+
57
+ private static function _hook_footer() {
58
+ if ( self::$_HOOKED_FOOTER ) {
59
+ return;
60
+ }
61
+
62
+ if ( is_admin() ) {
63
+ add_action( 'admin_footer', 'FS_Logger::dump', 100 );
64
+ } else {
65
+ add_action( 'wp_footer', 'FS_Logger::dump', 100 );
66
+ }
67
+ }
68
+
69
+ function is_on() {
70
+ return $this->_on;
71
+ }
72
+
73
+ function on() {
74
+ $this->_on = true;
75
+
76
+ self::_hook_footer();
77
+ }
78
+
79
+ function echo_on() {
80
+ $this->_on;
81
+
82
+ $this->_echo = true;
83
+ }
84
+
85
+ function is_echo_on() {
86
+ return $this->_echo;
87
+ }
88
+
89
+
90
+ private function _log( &$message, $type = 'log', $wrapper ) {
91
+ if ( ! $this->is_on() ) {
92
+ return;
93
+ }
94
+
95
+ $bt = debug_backtrace();
96
+ $depth = $wrapper ? 3 : 2;
97
+ while ( $depth < count( $bt ) - 1 && 'eval' === $bt[ $depth ]['function'] ) {
98
+ $depth ++;
99
+ }
100
+
101
+ $caller = $bt[ $depth ];
102
+
103
+ $log = array_merge( $caller, array(
104
+ 'cnt' => self::$CNT ++,
105
+ 'logger' => $this,
106
+ 'timestamp' => date( WP_FS__LOG_DATETIME_FORMAT . ':u' ),
107
+ 'type' => $type,
108
+ 'msg' => $message,
109
+ ) );
110
+
111
+ self::$LOG[] = $log;
112
+
113
+ if ( $this->is_echo_on() ) {
114
+ echo self::_format_html( $log ) . "\n";
115
+ }
116
+ }
117
+
118
+ function log( $message, $wrapper = false ) {
119
+ $this->_log( $message, 'log', $wrapper );
120
+ }
121
+
122
+ function info( $message, $wrapper = false ) {
123
+ $this->_log( $message, 'info', $wrapper );
124
+ }
125
+
126
+ function warn( $message, $wrapper = false ) {
127
+ $this->_log( $message, 'warn', $wrapper );
128
+ }
129
+
130
+ function error( $message, $wrapper = false ) {
131
+ $this->_log( $message, 'error', $wrapper );
132
+ }
133
+
134
+ function entrance( $message = '', $wrapper = false ) {
135
+ $msg = 'Entrance' . ( empty( $message ) ? '' : ' > ' ) . $message;
136
+
137
+ $this->_log( $msg, 'log', $wrapper );
138
+ }
139
+
140
+ function departure( $message = '', $wrapper = false ) {
141
+ $msg = 'Departure' . ( empty( $message ) ? '' : ' > ' ) . $message;
142
+
143
+ $this->_log( $msg, 'log', $wrapper );
144
+ }
145
+
146
+ private static function _format( $log, $show_type = true ) {
147
+ return '[' . str_pad( $log['cnt'], strlen( self::$CNT ), '0', STR_PAD_LEFT ) . '] [' . $log['logger']->_id . '] ' . ( $show_type ? '[' . $log['type'] . ']' : '' ) . $log['function'] . ' >> ' . $log['msg'] . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ') ' : '' ) . ' [' . $log['timestamp'] . ']';
148
+ }
149
+
150
+ private static function _format_html( $log ) {
151
+ return '<div style="font-size: 11px; padding: 3px; background: #ccc; margin-bottom: 3px;">[' . $log['cnt'] . '] [' . $log['logger']->_id . '] [' . $log['type'] . '] <b><code style="color: blue;">' . $log['function'] . '</code> >> <b style="color: darkorange;">' . $log['msg'] . '</b></b>' . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ')' : '' ) . ' [' . $log['timestamp'] . ']</div>';
152
+ }
153
+
154
+ static function dump() {
155
+ ?>
156
+ <!-- BEGIN: Freemius PHP Console Log -->
157
+ <script type="text/javascript">
158
+ <?php
159
+ foreach (self::$LOG as $log)
160
+ {
161
+ echo 'console.' . $log['type'] . '(' . json_encode(self::_format($log, false)) . ')' . "\n";
162
+ }
163
+ ?>
164
+ </script>
165
+ <!-- END: Freemius PHP Console Log -->
166
+ <?php
167
+ }
168
+ }
classes/freemius/includes/class-fs-plugin-updater.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ *
8
+ * @link https://github.com/easydigitaldownloads/EDD-License-handler/blob/master/EDD_SL_Plugin_Updater.php
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ // Uncomment this line for testing.
16
+ // set_site_transient( 'update_plugins', null );
17
+
18
+ class FS_Plugin_Updater {
19
+
20
+ /**
21
+ * @var Freemius
22
+ * @since 1.0.4
23
+ */
24
+ private $_fs;
25
+ /**
26
+ * @var FS_Logger
27
+ * @since 1.0.4
28
+ */
29
+ private $_logger;
30
+
31
+ function __construct( Freemius $freemius ) {
32
+ $this->_fs = $freemius;
33
+
34
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $freemius->get_slug() . '_updater', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
35
+
36
+ $this->_filters();
37
+ }
38
+
39
+ /**
40
+ * Initiate required filters.
41
+ *
42
+ * @author Vova Feldman (@svovaf)
43
+ * @since 1.0.4
44
+ */
45
+ private function _filters() {
46
+ // Override request for plugin information
47
+ add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 );
48
+
49
+ // WP 3.0+
50
+ add_filter( 'pre_set_site_transient_update_plugins', array(
51
+ &$this,
52
+ 'pre_set_site_transient_update_plugins_filter'
53
+ ) );
54
+
55
+ if ( ! WP_FS__IS_PRODUCTION_MODE ) {
56
+ add_filter( 'http_request_host_is_external', array(
57
+ $this,
58
+ 'http_request_host_is_external_filter'
59
+ ), 10, 3 );
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Since WP version 3.6, a new security feature was added that denies access to repository with a local ip.
65
+ * During development mode we want to be able updating plugin versions via our localhost repository. This
66
+ * filter white-list all domains including "api.freemius".
67
+ *
68
+ * @link http://www.emanueletessore.com/wordpress-download-failed-valid-url-provided/
69
+ *
70
+ * @author Vova Feldman (@svovaf)
71
+ * @since 1.0.4
72
+ *
73
+ * @param bool $allow
74
+ * @param string $host
75
+ * @param string $url
76
+ *
77
+ * @return bool
78
+ */
79
+ function http_request_host_is_external_filter( $allow, $host, $url ) {
80
+ return ( false !== strpos( $host, 'freemius' ) ) ? true : $allow;
81
+ }
82
+
83
+ /**
84
+ * Check for Updates at the defined API endpoint and modify the update array.
85
+ *
86
+ * This function dives into the update api just when WordPress creates its update array,
87
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
88
+ * It is reassembled from parts of the native WordPress plugin update code.
89
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
90
+ *
91
+ * @author Vova Feldman (@svovaf)
92
+ * @since 1.0.4
93
+ *
94
+ * @uses FS_Api
95
+ *
96
+ * @param stdClass $transient_data Update array build by WordPress.
97
+ *
98
+ * @return array Modified update array with custom plugin data.
99
+ */
100
+ function pre_set_site_transient_update_plugins_filter( $transient_data ) {
101
+ $this->_logger->entrance();
102
+
103
+ if ( empty( $transient_data ) ||
104
+ defined( 'WP_FS__UNINSTALL_MODE' )
105
+ ) {
106
+ return $transient_data;
107
+ }
108
+
109
+ // Get plugin's newest update.
110
+ $new_version = $this->_fs->get_update();
111
+
112
+ if ( is_object( $new_version ) ) {
113
+ $this->_logger->log( 'Found newer plugin version ' . $new_version->version );
114
+
115
+ $plugin_details = new stdClass();
116
+ $plugin_details->slug = $this->_fs->get_slug();
117
+ $plugin_details->new_version = $new_version->version;
118
+ $plugin_details->url = WP_FS__ADDRESS;
119
+ $plugin_details->package = $new_version->url;
120
+ $plugin_details->plugin = $this->_fs->get_plugin_basename();
121
+
122
+ // Add plugin to transient data.
123
+ $transient_data->response[ $this->_fs->get_plugin_basename() ] = $plugin_details;
124
+ }
125
+
126
+ return $transient_data;
127
+ }
128
+
129
+ /**
130
+ * Try to fetch plugin's info from .org repository.
131
+ *
132
+ * @author Vova Feldman (@svovaf)
133
+ * @since 1.0.5
134
+ *
135
+ * @param string $action
136
+ * @param array $args
137
+ *
138
+ * @return bool|mixed
139
+ */
140
+ private function _fetch_plugin_info_from_repository( $action, $args ) {
141
+ $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
142
+ if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
143
+ $url = set_url_scheme( $url, 'https' );
144
+ }
145
+
146
+ $args = array(
147
+ 'timeout' => 15,
148
+ 'body' => array(
149
+ 'action' => $action,
150
+ 'request' => serialize( $args )
151
+ )
152
+ );
153
+
154
+ $request = wp_remote_post( $url, $args );
155
+
156
+ if ( is_wp_error( $request ) ) {
157
+ return false;
158
+ }
159
+
160
+ $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
161
+
162
+ if ( ! is_object( $res ) && ! is_array( $res ) ) {
163
+ return false;
164
+ }
165
+
166
+ return $res;
167
+ }
168
+
169
+ /**
170
+ * Updates information on the "View version x.x details" page with custom data.
171
+ *
172
+ * @author Vova Feldman (@svovaf)
173
+ * @since 1.0.4
174
+ *
175
+ * @uses FS_Api
176
+ *
177
+ * @param object $data
178
+ * @param string $action
179
+ * @param mixed $args
180
+ *
181
+ * @return object
182
+ */
183
+ function plugins_api_filter( $data, $action = '', $args = null ) {
184
+ $this->_logger->entrance();
185
+
186
+ if ( ( 'plugin_information' !== $action ) ||
187
+ ! isset( $args->slug )
188
+ ) {
189
+ return $data;
190
+ }
191
+
192
+ $addon = false;
193
+ $is_addon = false;
194
+
195
+ if ( $this->_fs->get_slug() !== $args->slug ) {
196
+ $addon = $this->_fs->get_addon_by_slug( $args->slug );
197
+
198
+ if ( ! is_object( $addon ) ) {
199
+ return $data;
200
+ }
201
+
202
+ $is_addon = true;
203
+ }
204
+
205
+ $plugin_in_repo = false;
206
+ if ( ! $is_addon ) {
207
+ // Try to fetch info from .org repository.
208
+ $data = $this->_fetch_plugin_info_from_repository( $action, $args );
209
+
210
+ $plugin_in_repo = ( false !== $data );
211
+ }
212
+
213
+ if ( ! $plugin_in_repo ) {
214
+ $data = $args;
215
+
216
+ // Fetch as much as possible info from local files.
217
+ $plugin_local_data = $this->_fs->get_plugin_data();
218
+ $data->name = $plugin_local_data['Name'];
219
+ $data->author = $plugin_local_data['Author'];
220
+ $data->sections = array(
221
+ 'description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.',
222
+ );
223
+
224
+ // @todo Store extra plugin info on Freemius or parse readme.txt markup.
225
+ /*$info = $this->_fs->get_api_site_scope()->call('/information.json');
226
+
227
+ if ( !isset($info->error) ) {
228
+ $data = $info;
229
+ }*/
230
+ }
231
+
232
+ // Get plugin's newest update.
233
+ $new_version = $this->_fs->_fetch_latest_version( $is_addon ? $addon->id : false );
234
+
235
+ if ( $is_addon ) {
236
+ $data->name = $addon->title . ' ' . __fs( 'addon' );
237
+ $data->slug = $addon->slug;
238
+ $data->url = WP_FS__ADDRESS;
239
+ $data->package = $new_version->url;
240
+ }
241
+
242
+ if ( ! $plugin_in_repo ) {
243
+ $data->last_updated = ! is_null( $new_version->updated ) ? $new_version->updated : $new_version->created;
244
+ $data->requires = $new_version->requires_platform_version;
245
+ $data->tested = $new_version->tested_up_to_version;
246
+ }
247
+
248
+ $data->version = $new_version->version;
249
+ $data->download_link = $new_version->url;
250
+
251
+ return $data;
252
+ }
253
+ }
classes/freemius/includes/class-fs-security.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ define( 'WP_FS__SECURITY_PARAMS_PREFIX', 's_' );
14
+
15
+ class FS_Security {
16
+ /**
17
+ * @var FS_Security
18
+ * @since 1.0.3
19
+ */
20
+ private static $_instance;
21
+ /**
22
+ * @var FS_Logger
23
+ * @since 1.0.3
24
+ */
25
+ private static $_logger;
26
+
27
+ public static function instance() {
28
+ if ( ! isset( self::$_instance ) ) {
29
+ self::$_instance = new FS_Security();
30
+ self::$_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
31
+ }
32
+
33
+ return self::$_instance;
34
+ }
35
+
36
+ private function __construct() {
37
+ }
38
+
39
+ function get_secure_token( FS_Scope_Entity $entity, $timestamp, $action = '' ) {
40
+ return md5(
41
+ $timestamp .
42
+ $entity->id .
43
+ $entity->secret_key .
44
+ $entity->public_key .
45
+ $action
46
+ );
47
+ }
48
+
49
+ function get_context_params( FS_Scope_Entity $entity, $timestamp = false, $action = '' ) {
50
+ if ( false === $timestamp ) {
51
+ $timestamp = time();
52
+ }
53
+
54
+ return array(
55
+ 's_ctx_type' => $entity->get_type(),
56
+ 's_ctx_id' => $entity->id,
57
+ 's_ctx_ts' => $timestamp,
58
+ 's_ctx_secure' => $this->get_secure_token( $entity, $timestamp, $action ),
59
+ );
60
+ }
61
+ }
classes/freemius/includes/entities/class-fs-entity.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Get object's public variables.
15
+ *
16
+ * @author Vova Feldman (@svovaf)
17
+ * @since 1.0.0
18
+ *
19
+ * @param object $object
20
+ *
21
+ * @return array
22
+ */
23
+ function fs_get_object_public_vars( $object ) {
24
+ return get_object_vars( $object );
25
+ }
26
+
27
+ class FS_Entity {
28
+ /**
29
+ * @var number
30
+ */
31
+ public $id;
32
+ /**
33
+ * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
34
+ */
35
+ public $updated;
36
+ /**
37
+ * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
38
+ */
39
+ public $created;
40
+
41
+ /**
42
+ * @param bool|stdClass $entity
43
+ */
44
+ function __construct( $entity = false ) {
45
+ if ( ! ( $entity instanceof stdClass ) ) {
46
+ return;
47
+ }
48
+
49
+ $props = fs_get_object_public_vars( $this );
50
+
51
+ foreach ( $props as $key => $def_value ) {
52
+ $this->{$key} = isset( $entity->{$key} ) ?
53
+ $entity->{$key} :
54
+ $def_value;
55
+ }
56
+ }
57
+
58
+ static function get_type() {
59
+ return 'type';
60
+ }
61
+
62
+ /**
63
+ * @author Vova Feldman (@svovaf)
64
+ * @since 1.0.6
65
+ *
66
+ * @param FS_Entity $entity1
67
+ * @param FS_Entity $entity2
68
+ *
69
+ * @return bool
70
+ */
71
+ static function equals( $entity1, $entity2 ) {
72
+ if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
73
+ return true;
74
+ } else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
75
+ return ( $entity1->id == $entity2->id );
76
+ } else if ( is_object( $entity1 ) ) {
77
+ return is_null( $entity1->id );
78
+ } else {
79
+ return is_null( $entity2->id );
80
+ }
81
+ }
82
+
83
+ private $_is_updated = false;
84
+
85
+ /**
86
+ * Update object property.
87
+ *
88
+ * @author Vova Feldman (@svovaf)
89
+ * @since 1.0.9
90
+ *
91
+ * @param string|array[string]mixed $key
92
+ * @param string|bool $val
93
+ *
94
+ * @return bool
95
+ */
96
+ function update( $key, $val = false ) {
97
+ if ( ! is_array( $key ) ) {
98
+ $key = array( $key => $val );
99
+ }
100
+
101
+ $is_updated = false;
102
+
103
+ foreach ( $key as $k => $v ) {
104
+ if ( $this->{$k} === $v ) {
105
+ continue;
106
+ }
107
+
108
+ if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
109
+ ( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
110
+ $this->{$k} == $v
111
+ ) {
112
+ continue;
113
+ }
114
+
115
+ // Update value.
116
+ $this->{$k} = $v;
117
+
118
+ $is_updated = true;
119
+ }
120
+
121
+ $this->_is_updated = $is_updated;
122
+
123
+ return $is_updated;
124
+ }
125
+
126
+ /**
127
+ * Checks if entity was updated.
128
+ *
129
+ * @author Vova Feldman (@svovaf)
130
+ * @since 1.0.9
131
+ *
132
+ * @return bool
133
+ */
134
+ function is_updated() {
135
+ return $this->_is_updated;
136
+ }
137
+
138
+ /**
139
+ * @param $id
140
+ *
141
+ * @author Vova Feldman (@svovaf)
142
+ * @since 1.1.2
143
+ *
144
+ * @return bool
145
+ */
146
+ static function is_valid_id($id){
147
+ return is_numeric($id);
148
+ }
149
+ }
classes/freemius/includes/entities/class-fs-plugin-info.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_Info extends FS_Entity {
14
+ public $plugin_id;
15
+ public $description;
16
+ public $short_description;
17
+ public $banner_url;
18
+ public $card_banner_url;
19
+ public $selling_point_0;
20
+ public $selling_point_1;
21
+ public $selling_point_2;
22
+ public $screenshots;
23
+
24
+ /**
25
+ * @param stdClass|bool $plugin_info
26
+ */
27
+ function __construct( $plugin_info = false ) {
28
+ parent::__construct( $plugin_info );
29
+ }
30
+
31
+ static function get_type() {
32
+ return 'plugin';
33
+ }
34
+ }
classes/freemius/includes/entities/class-fs-plugin-license.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.5
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_License extends FS_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var number
19
+ */
20
+ public $plugin_id;
21
+ /**
22
+ * @var number
23
+ */
24
+ public $user_id;
25
+ /**
26
+ * @var number
27
+ */
28
+ public $plan_id;
29
+ /**
30
+ * @var number
31
+ */
32
+ public $pricing_id;
33
+ /**
34
+ * @var int
35
+ */
36
+ public $quota;
37
+ /**
38
+ * @var int
39
+ */
40
+ public $activated;
41
+ /**
42
+ * @var int
43
+ */
44
+ public $activated_local;
45
+ /**
46
+ * @var string
47
+ */
48
+ public $expiration;
49
+ /**
50
+ * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
51
+ * license.
52
+ */
53
+ public $is_free_localhost;
54
+ /**
55
+ * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
56
+ * block updates and support.
57
+ */
58
+ public $is_block_features;
59
+ /**
60
+ * @var bool
61
+ */
62
+ public $is_cancelled;
63
+
64
+ #endregion Properties
65
+
66
+ /**
67
+ * @param stdClass|bool $license
68
+ */
69
+ function __construct( $license = false ) {
70
+ parent::__construct( $license );
71
+ }
72
+
73
+ static function get_type() {
74
+ return 'license';
75
+ }
76
+
77
+ /**
78
+ * Check how many site activations left.
79
+ *
80
+ * @author Vova Feldman (@svovaf)
81
+ * @since 1.0.5
82
+ *
83
+ * @return int
84
+ */
85
+ function left() {
86
+ if ( $this->is_expired() ) {
87
+ return 0;
88
+ }
89
+
90
+ return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
91
+ }
92
+
93
+ /**
94
+ * @author Vova Feldman (@svovaf)
95
+ * @since 1.0.5
96
+ *
97
+ * @return bool
98
+ */
99
+ function is_expired() {
100
+ return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME );
101
+ }
102
+
103
+ /**
104
+ * @author Vova Feldman (@svovaf)
105
+ * @since 1.0.6
106
+ *
107
+ * @return bool
108
+ */
109
+ function is_lifetime() {
110
+ return is_null( $this->expiration );
111
+ }
112
+
113
+ /**
114
+ * Check if license is fully utilized.
115
+ *
116
+ * @author Vova Feldman (@svovaf)
117
+ * @since 1.0.6
118
+ *
119
+ * @param bool $is_localhost
120
+ *
121
+ * @return bool
122
+ */
123
+ function is_utilized( $is_localhost = null ) {
124
+ if ( is_null( $is_localhost ) ) {
125
+ $is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER;
126
+ }
127
+
128
+ return ! ( $this->is_free_localhost && $is_localhost ) &&
129
+ ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
130
+ }
131
+
132
+ /**
133
+ * Check if license's plan features are enabled.
134
+ *
135
+ * - Either if plan not expired
136
+ * - If expired, based on the configuration to block features or not.
137
+ *
138
+ * @author Vova Feldman (@svovaf)
139
+ * @since 1.0.6
140
+ *
141
+ * @return bool
142
+ */
143
+ function is_features_enabled() {
144
+ return ( ! $this->is_block_features || ! $this->is_expired() );
145
+ }
146
+
147
+ /**
148
+ * Subscription considered to be new without any payments
149
+ * if the license expires in less than 24 hours
150
+ * from the license creation.
151
+ *
152
+ * @author Vova Feldman (@svovaf)
153
+ * @since 1.0.9
154
+ *
155
+ * @return bool
156
+ */
157
+ function is_first_payment_pending() {
158
+ return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );
159
+ }
160
+ }
classes/freemius/includes/entities/class-fs-plugin-plan.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.5
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_Plan extends FS_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var string
19
+ */
20
+ public $title;
21
+ /**
22
+ * @var string
23
+ */
24
+ public $name;
25
+ /**
26
+ * @var int Trial days.
27
+ */
28
+ public $trial_period;
29
+ /**
30
+ * @var string If true, require payment for trial.
31
+ */
32
+ public $is_require_subscription;
33
+
34
+ #endregion Properties
35
+
36
+ /**
37
+ * @param object|bool $plan
38
+ */
39
+ function __construct( $plan = false ) {
40
+ parent::__construct( $plan );
41
+
42
+ if ( is_object( $plan ) ) {
43
+ $this->name = strtolower( $plan->name );
44
+ }
45
+ }
46
+
47
+ static function get_type() {
48
+ return 'plan';
49
+ }
50
+
51
+ /**
52
+ * @author Vova Feldman (@svovaf)
53
+ * @since 1.0.9
54
+ *
55
+ * @return bool
56
+ */
57
+ function is_free() {
58
+ return ( 'free' === $this->name );
59
+ }
60
+
61
+ /**
62
+ * @author Vova Feldman (@svovaf)
63
+ * @since 1.0.9
64
+ *
65
+ * @return bool
66
+ */
67
+ function has_trial() {
68
+ return ! $this->is_free() &&
69
+ is_numeric( $this->trial_period ) && ( $this->trial_period > 0 );
70
+ }
71
+ }
classes/freemius/includes/entities/class-fs-plugin-tag.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_Tag extends FS_Entity {
14
+ public $version;
15
+ public $url;
16
+
17
+ function __construct( $tag = false ) {
18
+ parent::__construct( $tag );
19
+ }
20
+
21
+ static function get_type() {
22
+ return 'tag';
23
+ }
24
+ }
classes/freemius/includes/entities/class-fs-plugin.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin extends FS_Scope_Entity {
14
+ /**
15
+ * @since 1.0.6
16
+ * @var null|number
17
+ */
18
+ public $parent_plugin_id;
19
+ /**
20
+ * @var string
21
+ */
22
+ public $title;
23
+ /**
24
+ * @var string
25
+ */
26
+ public $slug;
27
+
28
+ #region Install Specific Properties
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ public $file;
34
+ /**
35
+ * @var string
36
+ */
37
+ public $version;
38
+ /**
39
+ * @var bool
40
+ */
41
+ public $auto_update;
42
+ /**
43
+ * @var FS_Plugin_Info
44
+ */
45
+ public $info;
46
+ /**
47
+ * @since 1.0.9
48
+ *
49
+ * @var bool
50
+ */
51
+ public $is_premium;
52
+ /**
53
+ * @since 1.0.9
54
+ *
55
+ * @var bool
56
+ */
57
+ public $is_live;
58
+
59
+ #endregion Install Specific Properties
60
+
61
+ /**
62
+ * @param stdClass|bool $plugin
63
+ */
64
+ function __construct( $plugin = false ) {
65
+ parent::__construct( $plugin );
66
+
67
+ $this->is_premium = false;
68
+ $this->is_live = true;
69
+
70
+ if ( isset( $plugin->info ) && is_object( $plugin->info ) ) {
71
+ $this->info = new FS_Plugin_Info( $plugin->info );
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Check if plugin is an add-on (has parent).
77
+ *
78
+ * @author Vova Feldman (@svovaf)
79
+ * @since 1.0.6
80
+ *
81
+ * @return bool
82
+ */
83
+ function is_addon() {
84
+ return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
85
+ }
86
+
87
+ static function get_type() {
88
+ return 'plugin';
89
+ }
90
+ }
classes/freemius/includes/entities/class-fs-scope-entity.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Scope_Entity extends FS_Entity {
14
+ /**
15
+ * @var string
16
+ */
17
+ public $public_key;
18
+ /**
19
+ * @var string
20
+ */
21
+ public $secret_key;
22
+
23
+ /**
24
+ * @param bool|stdClass $scope_entity
25
+ */
26
+ function __construct( $scope_entity = false ) {
27
+ parent::__construct( $scope_entity );
28
+ }
29
+ }
classes/freemius/includes/entities/class-fs-site.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Site extends FS_Scope_Entity {
14
+ /**
15
+ * @var string
16
+ */
17
+ public $slug;
18
+ /**
19
+ * @var number
20
+ */
21
+ public $user_id;
22
+ /**
23
+ * @var string
24
+ */
25
+ public $title;
26
+ /**
27
+ * @var string
28
+ */
29
+ public $url;
30
+ /**
31
+ * @var string
32
+ */
33
+ public $version;
34
+ /**
35
+ * @var string E.g. en-GB
36
+ */
37
+ public $language;
38
+ /**
39
+ * @var string E.g. UTF-8
40
+ */
41
+ public $charset;
42
+ /**
43
+ * @var string Platform version (e.g WordPress version).
44
+ */
45
+ public $platform_version;
46
+ /**
47
+ * @var string Programming language version (e.g PHP version).
48
+ */
49
+ public $programming_language_version;
50
+ /**
51
+ * @var FS_Plugin_Plan $plan
52
+ */
53
+ public $plan;
54
+ /**
55
+ * @var number|null
56
+ */
57
+ public $license_id;
58
+ /**
59
+ * @var number|null
60
+ */
61
+ public $trial_plan_id;
62
+ /**
63
+ * @var string|null
64
+ */
65
+ public $trial_ends;
66
+ /**
67
+ * @since 1.0.9
68
+ *
69
+ * @var bool
70
+ */
71
+ public $is_premium = false;
72
+
73
+ /**
74
+ * @param stdClass|bool $site
75
+ */
76
+ function __construct( $site = false ) {
77
+ $this->plan = new FS_Plugin_Plan();
78
+
79
+ parent::__construct( $site );
80
+
81
+ if ( is_object( $site ) ) {
82
+ $this->plan->id = $site->plan_id;
83
+ }
84
+ }
85
+
86
+ static function get_type() {
87
+ return 'install';
88
+ }
89
+
90
+ function is_localhost() {
91
+ // The server has no way to verify if localhost unless localhost appears in domain.
92
+ return WP_FS__IS_LOCALHOST_FOR_SERVER;
93
+ // return (substr($_SERVER['REMOTE_ADDR'], 0, 4) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1');
94
+ }
95
+
96
+ /**
97
+ * Check if site in trial.
98
+ *
99
+ * @author Vova Feldman (@svovaf)
100
+ * @since 1.0.9
101
+ *
102
+ * @return bool
103
+ */
104
+ function is_trial() {
105
+ return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
106
+ }
107
+
108
+ /**
109
+ * Check if user already utilized the trial with the current install.
110
+ *
111
+ * @author Vova Feldman (@svovaf)
112
+ * @since 1.0.9
113
+ *
114
+ * @return bool
115
+ */
116
+ function is_trial_utilized() {
117
+ return is_numeric( $this->trial_plan_id );
118
+ }
119
+ }
classes/freemius/includes/entities/class-fs-subscription.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.9
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Subscription extends FS_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var number
19
+ */
20
+ public $user_id;
21
+ /**
22
+ * @var number
23
+ */
24
+ public $install_id;
25
+ /**
26
+ * @var number
27
+ */
28
+ public $plan_id;
29
+ /**
30
+ * @var number
31
+ */
32
+ public $license_id;
33
+ /**
34
+ * @var float
35
+ */
36
+ public $total_gross;
37
+ /**
38
+ * @var float
39
+ */
40
+ public $amount_per_cycle;
41
+ /**
42
+ * @var int # of months
43
+ */
44
+ public $billing_cycle;
45
+ /**
46
+ * @var float
47
+ */
48
+ public $outstanding_balance;
49
+ /**
50
+ * @var int
51
+ */
52
+ public $failed_payments;
53
+ /**
54
+ * @var string
55
+ */
56
+ public $gateway;
57
+ /**
58
+ * @var string
59
+ */
60
+ public $external_id;
61
+ /**
62
+ * @var string|null
63
+ */
64
+ public $trial_ends;
65
+ /**
66
+ * @var string|null Datetime of the next payment, or null if cancelled
67
+ */
68
+ public $next_payment;
69
+ /**
70
+ * @var string|null
71
+ */
72
+ public $vat_id;
73
+ /**
74
+ * @var string Two characters country code
75
+ */
76
+ public $country_code;
77
+
78
+ #endregion Properties
79
+
80
+ /**
81
+ * @param object|bool $subscription
82
+ */
83
+ function __construct( $subscription = false ) {
84
+ parent::__construct( $subscription );
85
+ }
86
+
87
+ static function get_type() {
88
+ return 'subscription';
89
+ }
90
+
91
+ /**
92
+ * Check if subscription is active.
93
+ *
94
+ * @author Vova Feldman (@svovaf)
95
+ * @since 1.0.9
96
+ *
97
+ * @return bool
98
+ */
99
+ function is_active() {
100
+ return ! empty( $this->next_payment ) &&
101
+ ( strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME );
102
+ }
103
+
104
+ /**
105
+ * Subscription considered to be new without any payments
106
+ * if the next payment should be made within less than 24 hours
107
+ * from the subscription creation.
108
+ *
109
+ * @author Vova Feldman (@svovaf)
110
+ * @since 1.0.9
111
+ *
112
+ * @return bool
113
+ */
114
+ function is_first_payment_pending() {
115
+ return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
116
+ }
117
+ }
classes/freemius/includes/entities/class-fs-user.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_User extends FS_Scope_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var string
19
+ */
20
+ public $email;
21
+ /**
22
+ * @var string
23
+ */
24
+ public $first;
25
+ /**
26
+ * @var string
27
+ */
28
+ public $last;
29
+ /**
30
+ * @var bool
31
+ */
32
+ public $is_verified;
33
+ /**
34
+ * @var string|null
35
+ */
36
+ public $customer_id;
37
+ /**
38
+ * @var float
39
+ */
40
+ public $gross;
41
+
42
+ #endregion Properties
43
+
44
+ /**
45
+ * @param object|bool $user
46
+ */
47
+ function __construct( $user = false ) {
48
+ parent::__construct( $user );
49
+ }
50
+
51
+ function get_name() {
52
+ return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) );
53
+ }
54
+
55
+ function is_verified() {
56
+ return ( isset( $this->is_verified ) && true === $this->is_verified );
57
+ }
58
+
59
+ static function get_type() {
60
+ return 'user';
61
+ }
62
+ }
classes/freemius/includes/fs-core-functions.php ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ global $fs_core_logger;
14
+
15
+ $fs_core_logger = FS_Logger::get_logger( WP_FS__SLUG . '_core', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
16
+
17
+ function fs_dummy() {
18
+ }
19
+
20
+ /* Url.
21
+ --------------------------------------------------------------------------------------------*/
22
+ function fs_get_url_daily_cache_killer() {
23
+ return date( '\YY\Mm\Dd' );
24
+ }
25
+
26
+ /* Templates / Views.
27
+ --------------------------------------------------------------------------------------------*/
28
+ function fs_get_template_path( $path ) {
29
+ return WP_FS__DIR_TEMPLATES . '/' . trim( $path, '/' );
30
+ }
31
+
32
+ function fs_include_template( $path, &$params = null ) {
33
+ $VARS = &$params;
34
+ include( fs_get_template_path( $path ) );
35
+ }
36
+
37
+ function fs_include_once_template( $path, &$params = null ) {
38
+ $VARS = &$params;
39
+ include_once( fs_get_template_path( $path ) );
40
+ }
41
+
42
+ function fs_require_template( $path, &$params = null ) {
43
+ $VARS = &$params;
44
+ require( fs_get_template_path( $path ) );
45
+ }
46
+
47
+ function fs_require_once_template( $path, &$params = null ) {
48
+ $VARS = &$params;
49
+ require_once( fs_get_template_path( $path ) );
50
+ }
51
+
52
+ function fs_get_template( $path, &$params = null ) {
53
+ ob_start();
54
+
55
+ $VARS = &$params;
56
+ require_once( fs_get_template_path( $path ) );
57
+
58
+ return ob_get_clean();
59
+ }
60
+
61
+ function __fs( $key ) {
62
+ global $fs_text;
63
+
64
+ if ( ! isset( $fs_text ) ) {
65
+ require_once( dirname( __FILE__ ) . '/i18n.php' );
66
+ }
67
+
68
+ return isset( $fs_text[ $key ] ) ? $fs_text[ $key ] : $key;
69
+ }
70
+
71
+ function _efs( $key ) {
72
+ echo __fs( $key );
73
+ }
74
+
75
+ /* Scripts and styles including.
76
+ --------------------------------------------------------------------------------------------*/
77
+ function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
78
+ global $fs_core_logger;
79
+ if ( $fs_core_logger->is_on() ) {
80
+ $fs_core_logger->info( 'handle = ' . $handle . '; path = ' . $path . ';' );
81
+ $fs_core_logger->info( 'plugin_basename = ' . plugins_url( WP_FS__DIR_CSS . trim( $path, '/' ) ) );
82
+ $fs_core_logger->info( 'plugins_url = ' . plugins_url( plugin_basename( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ) ) );
83
+ }
84
+
85
+ wp_enqueue_style( $handle, plugins_url( plugin_basename( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $media );
86
+ }
87
+
88
+ function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
89
+ global $fs_core_logger;
90
+ if ( $fs_core_logger->is_on() ) {
91
+ $fs_core_logger->info( 'handle = ' . $handle . '; path = ' . $path . ';' );
92
+ $fs_core_logger->info( 'plugin_basename = ' . plugins_url( WP_FS__DIR_JS . trim( $path, '/' ) ) );
93
+ $fs_core_logger->info( 'plugins_url = ' . plugins_url( plugin_basename( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ) ) );
94
+ }
95
+
96
+ wp_enqueue_script( $handle, plugins_url( plugin_basename( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $in_footer );
97
+ }
98
+
99
+ function fs_img_url( $path ) {
100
+ return plugins_url( plugin_basename( WP_FS__DIR_IMG . '/' . trim( $path, '/' ) ) );
101
+ }
102
+
103
+ /* Request handlers.
104
+ --------------------------------------------------------------------------------------------*/
105
+ /**
106
+ * @param string $key
107
+ * @param mixed $def
108
+ *
109
+ * @return mixed
110
+ */
111
+ function fs_request_get( $key, $def = false ) {
112
+ return isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def;
113
+ }
114
+
115
+ function fs_request_has( $key ) {
116
+ return isset( $_REQUEST[ $key ] );
117
+ }
118
+
119
+ function fs_request_get_bool( $key, $def = false ) {
120
+ return ( isset( $_REQUEST[ $key ] ) && ( 1 == $_REQUEST[ $key ] || 'true' === strtolower( $_REQUEST[ $key ] ) ) ) ? true : $def;
121
+ }
122
+
123
+ function fs_request_is_post() {
124
+ return ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
125
+ }
126
+
127
+ function fs_request_is_get() {
128
+ return ( 'get' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
129
+ }
130
+
131
+ function fs_get_action( $action_key = 'action' ) {
132
+ if ( ! empty( $_REQUEST[ $action_key ] ) ) {
133
+ return strtolower( $_REQUEST[ $action_key ] );
134
+ }
135
+
136
+ if ( 'action' == $action_key ) {
137
+ $action_key = 'fs_action';
138
+
139
+ if ( ! empty( $_REQUEST[ $action_key ] ) ) {
140
+ return strtolower( $_REQUEST[ $action_key ] );
141
+ }
142
+ }
143
+
144
+ return false;
145
+ }
146
+
147
+ function fs_request_is_action( $action, $action_key = 'action' ) {
148
+ return ( strtolower( $action ) === fs_get_action( $action_key ) );
149
+ }
150
+
151
+ function fs_is_plugin_page( $menu_slug ) {
152
+ return ( is_admin() && $_REQUEST['page'] === $menu_slug );
153
+ }
154
+
155
+ /**
156
+ * Get client IP.
157
+ *
158
+ * @author Vova Feldman (@svovaf)
159
+ * @since 1.1.2
160
+ *
161
+ * @return string|null
162
+ */
163
+ function fs_get_ip() {
164
+ $fields = array(
165
+ 'HTTP_CF_CONNECTING_IP',
166
+ 'HTTP_CLIENT_IP',
167
+ 'HTTP_X_FORWARDED_FOR',
168
+ 'HTTP_X_FORWARDED',
169
+ 'HTTP_FORWARDED_FOR',
170
+ 'HTTP_FORWARDED',
171
+ 'REMOTE_ADDR',
172
+ );
173
+
174
+ foreach ( $fields as $ip_field ) {
175
+ if ( ! empty( $_SERVER[ $ip_field ] ) ) {
176
+ return $_SERVER[ $ip_field ];
177
+ }
178
+ }
179
+
180
+ return null;
181
+ }
182
+
183
+ /* Core UI.
184
+ --------------------------------------------------------------------------------------------*/
185
+ function fs_ui_action_button( $slug, $page, $action, $title, $params = array(), $is_primary = true ) {
186
+ ?><a class="button<?php if ( $is_primary ) {
187
+ echo ' button-primary';
188
+ } ?>"
189
+ href="<?php echo wp_nonce_url( freemius( $slug )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ) ?>"><?php echo $title ?></a><?php
190
+ }
191
+
192
+ function fs_ui_action_link( $slug, $page, $action, $title, $params = array() ) {
193
+ ?><a class=""
194
+ href="<?php echo wp_nonce_url( freemius( $slug )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ) ?>"><?php echo $title ?></a><?php
195
+ }
196
+
197
+ /* Core Redirect (copied from BuddyPress).
198
+ --------------------------------------------------------------------------------------------*/
199
+ /**
200
+ * Redirects to another page, with a workaround for the IIS Set-Cookie bug.
201
+ *
202
+ * @link http://support.microsoft.com/kb/q176113/
203
+ * @since 1.5.1
204
+ * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
205
+ *
206
+ * @param string $location The path to redirect to
207
+ * @param int $status Status code to use
208
+ *
209
+ * @return bool False if $location is not set
210
+ */
211
+ function fs_redirect( $location, $status = 302 ) {
212
+ global $is_IIS;
213
+
214
+ if ( headers_sent() ) {
215
+ return false;
216
+ }
217
+
218
+ if ( ! $location ) // allows the wp_redirect filter to cancel a redirect
219
+ {
220
+ return false;
221
+ }
222
+
223
+ $location = fs_sanitize_redirect( $location );
224
+
225
+ if ( $is_IIS ) {
226
+ header( "Refresh: 0;url=$location" );
227
+ } else {
228
+ if ( php_sapi_name() != 'cgi-fcgi' ) {
229
+ status_header( $status );
230
+ } // This causes problems on IIS and some FastCGI setups
231
+ header( "Location: $location" );
232
+ }
233
+
234
+ return true;
235
+ }
236
+
237
+ /**
238
+ * Sanitizes a URL for use in a redirect.
239
+ *
240
+ * @since 2.3
241
+ *
242
+ * @param string $location
243
+ *
244
+ * @return string redirect-sanitized URL
245
+ */
246
+ function fs_sanitize_redirect( $location ) {
247
+ $location = preg_replace( '|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location );
248
+ $location = fs_kses_no_null( $location );
249
+
250
+ // remove %0d and %0a from location
251
+ $strip = array( '%0d', '%0a' );
252
+ $found = true;
253
+ while ( $found ) {
254
+ $found = false;
255
+ foreach ( (array) $strip as $val ) {
256
+ while ( strpos( $location, $val ) !== false ) {
257
+ $found = true;
258
+ $location = str_replace( $val, '', $location );
259
+ }
260
+ }
261
+ }
262
+
263
+ return $location;
264
+ }
265
+
266
+ /**
267
+ * Removes any NULL characters in $string.
268
+ *
269
+ * @since 1.0.0
270
+ *
271
+ * @param string $string
272
+ *
273
+ * @return string
274
+ */
275
+ function fs_kses_no_null( $string ) {
276
+ $string = preg_replace( '/\0+/', '', $string );
277
+ $string = preg_replace( '/(\\\\0)+/', '', $string );
278
+
279
+ return $string;
280
+ }
281
+
282
+ /*function fs_error_handler($errno, $errstr, $errfile, $errline)
283
+ {
284
+ if (false === strpos($errfile, 'freemius/'))
285
+ {
286
+ // @todo Dump Freemius errors to local log.
287
+ }
288
+
289
+ // switch ($errno) {
290
+ // case E_USER_ERROR:
291
+ // break;
292
+ // case E_WARNING:
293
+ // case E_USER_WARNING:
294
+ // break;
295
+ // case E_NOTICE:
296
+ // case E_USER_NOTICE:
297
+ // break;
298
+ // default:
299
+ // break;
300
+ // }
301
+ }
302
+
303
+ set_error_handler('fs_error_handler');*/
304
+
305
+ if ( function_exists( 'wp_normalize_path' ) ) {
306
+ /**
307
+ * Normalize a filesystem path.
308
+ *
309
+ * Replaces backslashes with forward slashes for Windows systems, and ensures
310
+ * no duplicate slashes exist.
311
+ *
312
+ * @param string $path Path to normalize.
313
+ *
314
+ * @return string Normalized path.
315
+ */
316
+ function fs_normalize_path( $path ) {
317
+ return wp_normalize_path( $path );
318
+ }
319
+ } else {
320
+ function fs_normalize_path( $path ) {
321
+ $path = str_replace( '\\', '/', $path );
322
+ $path = preg_replace( '|/+|', '/', $path );
323
+
324
+ return $path;
325
+ }
326
+ }
327
+
328
+ function fs_nonce_url( $actionurl, $action = - 1, $name = '_wpnonce' ) {
329
+ // $actionurl = str_replace( '&amp;', '&', $actionurl );
330
+ return add_query_arg( $name, wp_create_nonce( $action ), $actionurl );
331
+ }
332
+
333
+ /**
334
+ * Check if string starts with.
335
+ *
336
+ * @author Vova Feldman (@svovaf)
337
+ * @since 1.1.3
338
+ *
339
+ * @param string $haystack
340
+ * @param string $needle
341
+ *
342
+ * @return bool
343
+ */
344
+ function fs_starts_with( $haystack, $needle ) {
345
+ $length = strlen( $needle );
346
+
347
+ return ( substr( $haystack, 0, $length ) === $needle );
348
+ }
349
+
350
+ #region Url Canonization ------------------------------------------------------------------
351
+
352
+ /**
353
+ * @author Vova Feldman (@svovaf)
354
+ * @since 1.1.3
355
+ *
356
+ * @param string $url
357
+ * @param bool $omit_host
358
+ * @param array $ignore_params
359
+ *
360
+ * @return string
361
+ */
362
+ function fs_canonize_url( $url, $omit_host = false, $ignore_params = array() ) {
363
+ $parsed_url = parse_url( strtolower( $url ) );
364
+
365
+ // if ( ! isset( $parsed_url['host'] ) ) {
366
+ // return $url;
367
+ // }
368
+
369
+ $canonical = ( ( $omit_host || ! isset( $parsed_url['host'] ) ) ? '' : $parsed_url['host'] ) . $parsed_url['path'];
370
+
371
+ if ( isset( $parsed_url['query'] ) ) {
372
+ parse_str( $parsed_url['query'], $queryString );
373
+ $canonical .= '?' . fs_canonize_query_string( $queryString, $ignore_params );
374
+ }
375
+
376
+ return $canonical;
377
+ }
378
+
379
+ /**
380
+ * @author Vova Feldman (@svovaf)
381
+ * @since 1.1.3
382
+ *
383
+ * @param array $params
384
+ * @param array $ignore_params
385
+ * @param bool $params_prefix
386
+ *
387
+ * @return string
388
+ */
389
+ function fs_canonize_query_string( array $params, array &$ignore_params, $params_prefix = false ) {
390
+ if ( ! is_array( $params ) || 0 === count( $params ) ) {
391
+ return '';
392
+ }
393
+
394
+ // Urlencode both keys and values
395
+ $keys = fs_urlencode_rfc3986( array_keys( $params ) );
396
+ $values = fs_urlencode_rfc3986( array_values( $params ) );
397
+ $params = array_combine( $keys, $values );
398
+
399
+ // Parameters are sorted by name, using lexicographical byte value ordering.
400
+ // Ref: Spec: 9.1.1 (1)
401
+ uksort( $params, 'strcmp' );
402
+
403
+ $pairs = array();
404
+ foreach ( $params as $parameter => $value ) {
405
+ $lower_param = strtolower( $parameter );
406
+
407
+ // Skip ignore params.
408
+ if ( in_array( $lower_param, $ignore_params ) || ( false !== $params_prefix && startsWith( $lower_param, $params_prefix ) ) ) {
409
+ continue;
410
+ }
411
+
412
+ if ( is_array( $value ) ) {
413
+ // If two or more parameters share the same name, they are sorted by their value
414
+ // Ref: Spec: 9.1.1 (1)
415
+ natsort( $value );
416
+ foreach ( $value as $duplicate_value ) {
417
+ $pairs[] = $lower_param . '=' . $duplicate_value;
418
+ }
419
+ } else {
420
+ $pairs[] = $lower_param . '=' . $value;
421
+ }
422
+ }
423
+
424
+ if ( 0 === count( $pairs ) ) {
425
+ return '';
426
+ }
427
+
428
+ return implode( "&", $pairs );
429
+ }
430
+
431
+ /**
432
+ * @author Vova Feldman (@svovaf)
433
+ * @since 1.1.3
434
+ *
435
+ * @param string|string[] $input
436
+ *
437
+ * @return array|mixed|string
438
+ */
439
+ function fs_urlencode_rfc3986( $input ) {
440
+ if ( is_array( $input ) ) {
441
+ return array_map( 'fs_urlencode_rfc3986', $input );
442
+ } else if ( is_scalar( $input ) ) {
443
+ return str_replace( '+', ' ', str_replace( '%7E', '~', rawurlencode( $input ) ) );
444
+ }
445
+
446
+ return '';
447
+ }
448
+
449
+ #endregion Url Canonization ------------------------------------------------------------------
450
+
451
+ function fs_download_image( $from, $to ) {
452
+ $ch = curl_init( $from );
453
+ $fp = fopen( fs_normalize_path( $to ), 'wb' );
454
+ curl_setopt( $ch, CURLOPT_FILE, $fp );
455
+ curl_setopt( $ch, CURLOPT_HEADER, 0 );
456
+ curl_exec( $ch );
457
+ curl_close( $ch );
458
+ fclose( $fp );
459
+ }
460
+
461
+
classes/freemius/includes/fs-plugin-functions.php ADDED
@@ -0,0 +1,411 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Display plugin information in dialog box form.
15
+ *
16
+ * @since 2.7.0
17
+ */
18
+ function fs_install_plugin_information() {
19
+ global $tab;
20
+
21
+ if ( empty( $_REQUEST['plugin'] ) ) {
22
+ return;
23
+ }
24
+
25
+ $args = array(
26
+ 'slug' => wp_unslash( $_REQUEST['plugin'] ),
27
+ 'is_ssl' => is_ssl(),
28
+ 'fields' => array( 'banners' => true, 'reviews' => true )
29
+ );
30
+
31
+ if ( is_array( $args ) ) {
32
+ $args = (object) $args;
33
+ }
34
+
35
+ if ( ! isset( $args->per_page ) ) {
36
+ $args->per_page = 24;
37
+ }
38
+
39
+ if ( ! isset( $args->locale ) ) {
40
+ $args->locale = get_locale();
41
+ }
42
+
43
+ $api = apply_filters( 'fs_plugins_api', false, 'plugin_information', $args );
44
+
45
+ if ( is_wp_error( $api ) ) {
46
+ wp_die( $api );
47
+ }
48
+
49
+ $plugins_allowedtags = array(
50
+ 'a' => array(
51
+ 'href' => array(),
52
+ 'title' => array(),
53
+ 'target' => array(),
54
+ // Add image style for screenshots.
55
+ 'class' => array()
56
+ ),
57
+ 'style' => array(),
58
+ 'abbr' => array( 'title' => array() ),
59
+ 'acronym' => array( 'title' => array() ),
60
+ 'code' => array(),
61
+ 'pre' => array(),
62
+ 'em' => array(),
63
+ 'strong' => array(),
64
+ 'div' => array( 'class' => array() ),
65
+ 'span' => array( 'class' => array() ),
66
+ 'p' => array(),
67
+ 'ul' => array(),
68
+ 'ol' => array(),
69
+ 'li' => array( 'class' => array() ),
70
+ 'i' => array( 'class' => array() ),
71
+ 'h1' => array(),
72
+ 'h2' => array(),
73
+ 'h3' => array(),
74
+ 'h4' => array(),
75
+ 'h5' => array(),
76
+ 'h6' => array(),
77
+ 'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() ),
78
+ // 'table' => array(),
79
+ // 'td' => array(),
80
+ // 'tr' => array(),
81
+ // 'th' => array(),
82
+ // 'thead' => array(),
83
+ // 'tbody' => array(),
84
+ );
85
+
86
+ $plugins_section_titles = array(
87
+ 'description' => _x( 'Description', 'Plugin installer section title' ),
88
+ 'installation' => _x( 'Installation', 'Plugin installer section title' ),
89
+ 'faq' => _x( 'FAQ', 'Plugin installer section title' ),
90
+ 'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ),
91
+ 'changelog' => _x( 'Changelog', 'Plugin installer section title' ),
92
+ 'reviews' => _x( 'Reviews', 'Plugin installer section title' ),
93
+ 'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ),
94
+ 'features' => __fs( 'features-and-pricing' ),
95
+ );
96
+
97
+ // Sanitize HTML
98
+ // foreach ( (array) $api->sections as $section_name => $content ) {
99
+ // $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags );
100
+ // }
101
+
102
+ foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
103
+ if ( isset( $api->$key ) ) {
104
+ $api->$key = wp_kses( $api->$key, $plugins_allowedtags );
105
+ }
106
+ }
107
+
108
+ $_tab = esc_attr( $tab );
109
+
110
+ $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
111
+ if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
112
+ $section_titles = array_keys( (array) $api->sections );
113
+ $section = array_shift( $section_titles );
114
+ }
115
+
116
+ iframe_header( __( 'Plugin Install' ) );
117
+
118
+ $_with_banner = '';
119
+
120
+ // var_dump($api->banners);
121
+ if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) {
122
+ $_with_banner = 'with-banner';
123
+ $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low'];
124
+ $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high'];
125
+ ?>
126
+ <style type="text/css">
127
+ #plugin-information-title.with-banner
128
+ {
129
+ background-image: url( <?php echo esc_url( $low ); ?> );
130
+ }
131
+
132
+ @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 )
133
+ {
134
+ #plugin-information-title.with-banner
135
+ {
136
+ background-image: url( <?php echo esc_url( $high ); ?> );
137
+ }
138
+ }
139
+ </style>
140
+ <?php
141
+ }
142
+
143
+ echo '<div id="plugin-information-scrollable">';
144
+ echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>";
145
+ echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n";
146
+
147
+ foreach ( (array) $api->sections as $section_name => $content ) {
148
+ if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) {
149
+ continue;
150
+ }
151
+
152
+ if ( isset( $plugins_section_titles[ $section_name ] ) ) {
153
+ $title = $plugins_section_titles[ $section_name ];
154
+ } else {
155
+ $title = ucwords( str_replace( '_', ' ', $section_name ) );
156
+ }
157
+
158
+ $class = ( $section_name === $section ) ? ' class="current"' : '';
159
+ $href = add_query_arg( array( 'tab' => $tab, 'section' => $section_name ) );
160
+ $href = esc_url( $href );
161
+ $san_section = esc_attr( $section_name );
162
+ echo "\t<a name='$san_section' href='$href' $class>$title</a>\n";
163
+ }
164
+
165
+ echo "</div>\n";
166
+
167
+ ?>
168
+ <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
169
+ <div class="fyi">
170
+ <?php if ( isset( $api->plans ) ) : ?>
171
+ <div class="plugin-information-pricing">
172
+ <?php foreach ($api->plans as $plan) : ?>
173
+ <h3 data-plan="<?php echo $plan->id ?>"><?php printf( __fs( 'x-plan' ), $plan->title ) ?></h3>
174
+ <ul>
175
+ <?php $billing_cycle = 'annual' ?>
176
+ <?php if ( 1 === count( $plan->pricing ) && 1 == $plan->pricing[0]->licenses ) : ?>
177
+ <?php $pricing = $plan->pricing[0] ?>
178
+ <li><label><?php _efs( 'price' ) ?>: $<?php
179
+ if ( isset( $pricing->annual_price ) ) {
180
+ echo $pricing->annual_price . ( $plan->is_block_features ? ' / year' : '' );
181
+ $billing_cycle = 'annual';
182
+ } else if ( isset( $pricing->monthly_price ) ) {
183
+ echo $pricing->monthly_price . ' / mo';
184
+ $billing_cycle = 'monthly';
185
+ } else if ( isset( $pricing->lifetime_price ) ) {
186
+ echo $pricing->lifetime_price;
187
+ $billing_cycle = 'lifetime';
188
+ }
189
+ ?></label></li>
190
+ <?php else : ?>
191
+ <?php $first = true;
192
+ foreach ( $plan->pricing as $pricing ) : ?>
193
+ <li><label><input name="pricing-<?php echo $plan->id ?>" type="radio"
194
+ value="<?php echo $pricing->id ?>"<?php checked( $first, true ) ?>><?php
195
+ switch ( $pricing->licenses ) {
196
+ case '1':
197
+ _efs( 'license-single-site' );
198
+ break;
199
+ case null:
200
+ _efs( 'license-unlimited' );
201
+ break;
202
+ default:
203
+ printf( __fs( 'license-x-sites' ), $pricing->licenses );
204
+ break;
205
+ }
206
+ ?> - $<?php
207
+ if ( isset( $pricing->annual_price ) ) {
208
+ echo $pricing->annual_price . ( $plan->is_block_features ? ' / year' : '' );
209
+ $billing_cycle = 'annual';
210
+ } else if ( isset( $pricing->monthly_price ) ) {
211
+ echo $pricing->monthly_price . ' / mo';
212
+ $billing_cycle = 'monthly';
213
+ } else if ( isset( $pricing->lifetime_price ) ) {
214
+ echo $pricing->lifetime_price;
215
+ $billing_cycle = 'lifetime';
216
+ }
217
+ ?></label></li>
218
+ <?php $first = false; endforeach ?>
219
+ <?php endif ?>
220
+ </ul>
221
+ <?php echo ' <a class="button button-primary right" href="' . esc_url( add_query_arg( array(
222
+ 'plugin_id' => $plan->plugin_id,
223
+ 'plan_id' => $plan->id,
224
+ 'pricing_id' => $plan->pricing[0]->id,
225
+ 'billing_cycle' => $billing_cycle,
226
+ ), $api->checkout_link ) ) . '" target="_parent">' . __fs( 'purchase' ) . '</a>' ?>
227
+ </div>
228
+ <?php endforeach ?>
229
+ <?php wp_enqueue_script( 'jquery' ); ?>
230
+ <script type="text/javascript">
231
+ (function ($) {
232
+ $('.plugin-information-pricing input[type=radio]').click(function () {
233
+ var checkout_url = '<?php echo esc_url_raw(add_query_arg(array(
234
+ 'plugin_id' => $plan->plugin_id,
235
+ 'billing_cycle' => $billing_cycle,
236
+ ), $api->checkout_link)) ?>&plan_id=' +
237
+ $(this).parents('.plugin-information-pricing').find('h3').attr('data-plan') +
238
+ '&pricing_id=' + $(this).val();
239
+
240
+ $('.plugin-information-pricing .button, #plugin-information-footer .button').attr('href', checkout_url);
241
+ });
242
+ })(jQuery);
243
+ </script>
244
+ <?php endif ?>
245
+ <div>
246
+ <h3><?php _efs( 'details' ) ?></h3>
247
+ <ul>
248
+ <?php if ( ! empty( $api->version ) ) { ?>
249
+ <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li>
250
+ <?php }
251
+ if ( ! empty( $api->author ) ) { ?>
252
+ <li>
253
+ <strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?>
254
+ </li>
255
+ <?php }
256
+ if ( ! empty( $api->last_updated ) ) { ?>
257
+ <li><strong><?php _e( 'Last Updated:' ); ?></strong> <span
258
+ title="<?php echo $api->last_updated; ?>">
259
+ <?php printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); ?>
260
+ </span></li>
261
+ <?php }
262
+ if ( ! empty( $api->requires ) ) { ?>
263
+ <li>
264
+ <strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php printf( __( '%s or higher' ), $api->requires ); ?>
265
+ </li>
266
+ <?php }
267
+ if ( ! empty( $api->tested ) ) { ?>
268
+ <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
269
+ <?php }
270
+ if ( ! empty( $api->downloaded ) ) { ?>
271
+ <li>
272
+ <strong><?php _e( 'Downloaded:' ); ?></strong> <?php printf( _n( '%s time', '%s times', $api->downloaded ), number_format_i18n( $api->downloaded ) ); ?>
273
+ </li>
274
+ <?php }
275
+ if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
276
+ <li><a target="_blank"
277
+ href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a>
278
+ </li>
279
+ <?php }
280
+ if ( ! empty( $api->homepage ) ) { ?>
281
+ <li><a target="_blank"
282
+ href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a>
283
+ </li>
284
+ <?php }
285
+ if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
286
+ <li><a target="_blank"
287
+ href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a>
288
+ </li>
289
+ <?php } ?>
290
+ </ul>
291
+ </div>
292
+ <?php if ( ! empty( $api->rating ) ) { ?>
293
+ <h3><?php _e( 'Average Rating' ); ?></h3>
294
+ <?php wp_star_rating( array(
295
+ 'rating' => $api->rating,
296
+ 'type' => 'percent',
297
+ 'number' => $api->num_ratings
298
+ ) ); ?>
299
+ <small><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></small>
300
+ <?php
301
+ }
302
+
303
+ if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) {
304
+ foreach ( $api->ratings as $key => $ratecount ) {
305
+ // Avoid div-by-zero.
306
+ $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
307
+ ?>
308
+ <div class="counter-container">
309
+ <span class="counter-label"><a
310
+ href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
311
+ target="_blank"
312
+ title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span>
313
+ <span class="counter-back">
314
+ <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
315
+ </span>
316
+ <span class="counter-count"><?php echo number_format_i18n( $ratecount ); ?></span>
317
+ </div>
318
+ <?php
319
+ }
320
+ }
321
+ if ( ! empty( $api->contributors ) ) {
322
+ ?>
323
+ <h3><?php _e( 'Contributors' ); ?></h3>
324
+ <ul class="contributors">
325
+ <?php
326
+ foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) {
327
+ if ( empty( $contrib_username ) && empty( $contrib_profile ) ) {
328
+ continue;
329
+ }
330
+ if ( empty( $contrib_username ) ) {
331
+ $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile );
332
+ }
333
+ $contrib_username = sanitize_user( $contrib_username );
334
+ if ( empty( $contrib_profile ) ) {
335
+ echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&amp;s=36' width='18' height='18' />{$contrib_username}</li>";
336
+ } else {
337
+ echo "<li><a href='{$contrib_profile}' target='_blank'><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&amp;s=36' width='18' height='18' />{$contrib_username}</a></li>";
338
+ }
339
+ }
340
+ ?>
341
+ </ul>
342
+ <?php if ( ! empty( $api->donate_link ) ) { ?>
343
+ <a target="_blank"
344
+ href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a>
345
+ <?php } ?>
346
+ <?php } ?>
347
+ </div>
348
+ <div id="section-holder" class="wrap">
349
+ <?php
350
+ if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
351
+ echo '<div class="notice notice-warning"><p>' . '<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This plugin has not been tested with your current version of WordPress.' ) . '</p></div>';
352
+ } else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
353
+ echo '<div class="notice notice-warning"><p>' . '<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This plugin has not been marked as compatible with your version of WordPress.' ) . '</p></div>';
354
+ }
355
+
356
+ foreach ( (array) $api->sections as $section_name => $content ) {
357
+ $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
358
+ $content = links_add_target( $content, '_blank' );
359
+
360
+ $san_section = esc_attr( $section_name );
361
+
362
+ $display = ( $section_name === $section ) ? 'block' : 'none';
363
+
364
+ echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
365
+ echo $content;
366
+ echo "\t</div>\n";
367
+ }
368
+ echo "</div>\n";
369
+ echo "</div>\n";
370
+ echo "</div>\n"; // #plugin-information-scrollable
371
+ echo "<div id='$tab-footer'>\n";
372
+ if ( ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) {
373
+
374
+ if ( ! empty( $api->checkout_link ) && isset( $api->plans ) && 0 < is_array( $api->plans ) ) {
375
+ echo ' <a class="button button-primary right" href="' . esc_url( add_query_arg( array(
376
+ 'plugin_id' => $plan->plugin_id,
377
+ 'plan_id' => $plan->id,
378
+ 'pricing_id' => $plan->pricing[0]->id,
379
+ 'billing_cycle' => $billing_cycle,
380
+ ), $api->checkout_link ) ) . '" target="_parent">' . __fs( 'purchase' ) . '</a>';
381
+
382
+ // @todo Add Cart concept.
383
+ // echo ' <a class="button right" href="' . $status['url'] . '" target="_parent">' . __( 'Add to Cart' ) . '</a>';
384
+
385
+ } else if ( ! empty( $api->download_link ) ) {
386
+ $status = install_plugin_install_status( $api );
387
+ switch ( $status['status'] ) {
388
+ case 'install':
389
+ if ( $status['url'] ) {
390
+ echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>';
391
+ }
392
+ break;
393
+ case 'update_available':
394
+ if ( $status['url'] ) {
395
+ echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) . '</a>';
396
+ }
397
+ break;
398
+ case 'newer_installed':
399
+ echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed' ), $status['version'] ) . '</a>';
400
+ break;
401
+ case 'latest_installed':
402
+ echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>';
403
+ break;
404
+ }
405
+ }
406
+ }
407
+ echo "</div>\n";
408
+
409
+ iframe_footer();
410
+ exit;
411
+ }
classes/freemius/includes/i18n.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ global $fs_text;
3
+
4
+ $fs_text = array(
5
+ 'account' => __( 'Account', 'freemius' ),
6
+ 'addon' => __( 'Add On', 'freemius' ),
7
+ 'contact-us' => __( 'Contact Us', 'freemius' ),
8
+ 'change-ownership' => __( 'Change Ownership', 'freemius' ),
9
+ 'support' => __( 'Support', 'freemius' ),
10
+ 'support-forum' => __( 'Support Forum', 'freemius' ),
11
+ 'add-ons' => __( 'Add Ons', 'freemius' ),
12
+ 'upgrade' => _x( 'Upgrade', 'verb', 'freemius' ),
13
+ 'awesome' => __( 'Awesome', 'freemius' ),
14
+ 'pricing' => _x( 'Pricing', 'noun', 'freemius' ),
15
+ 'price' => _x( 'Price', 'noun', 'freemius' ),
16
+ 'unlimited-updates' => __( 'Unlimited Updates', 'freemius' ),
17
+ 'downgrade' => _x( 'Downgrade', 'verb', 'freemius' ),
18
+ 'free-trial' => __( 'Free Trial', 'freemius' ),
19
+ 'details' => __( 'Details', 'freemius' ),
20
+ 'account-details' => __( 'Account Details', 'freemius' ),
21
+ 'delete' => _x( 'Delete', 'verb', 'freemius' ),
22
+ 'delete-account' => __( 'Delete Account', 'freemius' ),
23
+ 'dismiss' => _x( 'Dismiss', 'as close a window', 'freemius' ),
24
+ 'plan' => _x( 'Plan', 'as product pricing plan', 'freemius' ),
25
+ 'change-plan' => __( 'Change Plan', 'freemius' ),
26
+ 'download-x-version' => _x( 'Download %s Version', 'as download professional version', 'freemius' ),
27
+ 'download-x-version-now' => _x( 'Download %s version now', 'as download professional version now', 'freemius' ),
28
+ 'download-latest' => _x( 'Download Latest', 'as download latest version', 'freemius' ),
29
+ 'you-have-x-license' => _x( 'You have a %s license.', 'E.g. you have a professional license.', 'freemius' ),
30
+ 'new' => __( 'New', 'freemius' ),
31
+ 'free' => __( 'Free', 'freemius' ),
32
+ 'trial' => _x( 'Trial', 'as trial plan', 'freemius' ),
33
+ 'purchase' => _x( 'Purchase', 'verb', 'freemius' ),
34
+ 'license-single-site' => __( 'Single Site License', 'freemius' ),
35
+ 'license-unlimited' => __( 'Unlimited Licenses', 'freemius' ),
36
+ 'license-x-sites' => __( 'Up to %s Sites', 'freemius' ),
37
+ 'x-plan' => _x( '%s Plan', 'e.g. Professional Plan', 'freemius' ),
38
+ 'you-are-step-away' => __( 'You are just one step away - %s', 'freemius' ),
39
+ 'activate-x-now' => _x( 'Complete "%s" Activation Now', '%s - plugin name. As complete "Jetpack" activation now', 'freemius' ),
40
+ 'few-plugin-tweaks' => __( 'We made a few tweaks to the plugin, %s', 'freemius' ),
41
+ 'optin-x-now' => __( 'Opt-in to make "%s" Better!', 'freemius' ),
42
+ 'error' => __( 'Error', 'freemius' ),
43
+ 'failed-finding-main-path' => __( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'freemius' ),
44
+ #region Account
45
+
46
+ 'expiration' => _x( 'Expiration', 'as expiration date', 'freemius' ),
47
+ 'not-verified' => __( 'not verified', 'freemius' ),
48
+ 'verify-email' => __( 'Verify Email', 'freemius' ),
49
+ 'expires-in' => _x( 'Expires in %s', 'e.g. expires in 2 months', 'freemius' ),
50
+ 'renews-in' => _x( 'Auto renews in %s', 'e.g. auto renews in 2 months', 'freemius' ),
51
+ 'no-expiration' => __( 'No expiration', 'freemius' ),
52
+ 'expired' => __( 'Expired', 'freemius' ),
53
+ 'in-x' => __( 'In %s', 'freemius' ),
54
+ 'version' => _x( 'Version', 'as plugin version', 'freemius' ),
55
+ 'name' => __( 'Name', 'freemius' ),
56
+ 'email' => __( 'Email', 'freemius' ),
57
+ 'verified' => __( 'Verified', 'freemius' ),
58
+ 'plugin' => __( 'Plugin', 'freemius' ),
59
+ 'title' => __( 'Title', 'freemius' ),
60
+ 'slug' => _x( 'Slug', 'as WP plugin slug', 'freemius' ),
61
+ 'id' => __( 'ID', 'freemius' ),
62
+ 'users' => __( 'Users', 'freemius' ),
63
+ 'plugin-installs' => __( 'Plugin Installs', 'freemius' ),
64
+ 'sites' => _x( 'Sites', 'like websites', 'freemius' ),
65
+ 'user-id' => __( 'User ID', 'freemius' ),
66
+ 'site-id' => __( 'Site ID', 'freemius' ),
67
+ 'public-key' => __( 'Public Key', 'freemius' ),
68
+ 'secret-key' => __( 'Secret Key', 'freemius' ),
69
+ 'no-secret' => _x( 'No Secret', 'as secret encryption key missing', 'freemius' ),
70
+ 'no-id' => __( 'No ID', 'freemius' ),
71
+ 'sync-license' => _x( 'Sync License', 'as synchronize license', 'freemius' ),
72
+ 'deactivate-license' => __( 'Deactivate License', 'freemius' ),
73
+ 'activate' => __( 'Activate', 'freemius' ),
74
+ 'deactivate' => __( 'Deactivate', 'freemius' ),
75
+ 'active' => _x( 'Active', 'active mode', 'freemius' ),
76
+ 'install-now' => __( 'Install Now', 'freemius' ),
77
+ 'install-update-now' => __( 'Install Update Now', 'freemius' ),
78
+ 'more-information-about-x' => __( 'More information about %s', 'freemius' ),
79
+ 'localhost' => __( 'Localhost', 'freemius' ),
80
+ 'activate-x-plan' => _x( 'Activate %s Plan', 'as activate Professional plan', 'freemius' ),
81
+ 'what-is-your-x' => __( 'What is your %s?', 'freemius' ),
82
+ 'activate-this-addon' => __( 'Activate this add-on', 'freemius' ),
83
+ 'deactivate-license-confirm' => __( 'Deactivating your license will block all premium features, but will enable you to activate the license on another site. Are you sure you want to proceed?', 'freemius' ),
84
+ 'delete-account-x-confirm' => __( 'Deleting the account will automatically deactivate your %s plan license so you can use it on other sites. If you want to terminate the recurring payments as well, click the "Cancel" button, and first "Downgrade" your account. Are you sure you would like to continue with the deletion?', 'freemius' ),
85
+ 'delete-account-confirm' => __( 'Deletion is not temporary. Only delete if you no longer want to use this plugin anymore. Are you sure you would like to continue with the deletion?', 'freemius' ),
86
+ 'downgrade-x-confirm' => __( 'Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'freemius' ),
87
+ 'after-downgrade-non-blocking' => __( 'You can still enjoy all %s features but you will not have access to plugin updates and support.', 'freemius' ),
88
+ 'after-downgrade-blocking' => __( 'Once your license expire you can still use the Free version but you will NOT have access to the %s features.', 'freemius' ),
89
+ 'proceed-confirmation' => __( 'Are you sure you want to proceed?', 'freemius' ),
90
+ #endregion Account
91
+
92
+ 'add-ons-for-x' => __( 'Add Ons for %s', 'freemius' ),
93
+ #region Plugin Deactivation
94
+ 'deactivation-share-reason' => __( 'If you have a moment, please let us know why you are deactivating', 'freemius' ),
95
+ 'deactivation-modal-button-deactivate' => __( 'Deactivate', 'freemius' ),
96
+ 'deactivation-modal-button-confirm' => __( 'Yes - Deactivate', 'freemius' ),
97
+ 'deactivation-modal-button-submit' => __( 'Submit & Deactivate', 'freemius' ),
98
+ 'deactivation-modal-button-cancel' => _x( 'Cancel', 'the text of the cancel button of the plugin deactivation dialog box.', 'freemius' ),
99
+ 'reason-no-longer-needed' => __( 'I no longer need the plugin', 'freemius' ),
100
+ 'reason-found-a-better-plugin' => __( 'I found a better plugin', 'freemius' ),
101
+ 'reason-needed-for-a-short-period' => __( 'I only needed the plugin for a short period', 'freemius' ),
102
+ 'reason-broke-my-site' => __( 'The plugin broke my site', 'freemius' ),
103
+ 'reason-suddenly-stopped-working' => __( 'The plugin suddenly stopped working', 'freemius' ),
104
+ 'reason-cant-pay-anymore' => __( "I can't pay for it anymore", 'freemius' ),
105
+ 'reason-other' => _x( 'Other', 'the text of the "other" reason for deactivating the plugin that is shown in the modal box.', 'freemius' ),
106
+ 'placeholder-plugin-name' => __( "What's the plugin's name?", 'freemius' ),
107
+ 'placeholder-comfortable-price' => __( 'What price would you feel comfortable paying?', 'freemius' ),
108
+ 'reason-couldnt-make-it-work' => __( "I couldn't understand how to make it work", 'freemius' ),
109
+ 'reason-great-but-need-specific-feature' => __( "The plugin is great, but I need specific feature that you don't support", 'freemius' ),
110
+ 'reason-not-working' => __( 'The plugin is not working', 'freemius' ),
111
+ 'reason-not-what-i-was-looking-for' => __( "It's not what I was looking for", 'freemius' ),
112
+ 'reason-didnt-work-as-expected' => __( "The plugin didn't work as expected", 'freemius' ),
113
+ 'placeholder-feature' => __( 'What feature?', 'freemius' ),
114
+ 'placeholder-share-what-didnt-work' => __( "Kindly share what didn't work so we can fix it for future users...", 'freemius' ),
115
+ 'placeholder-what-youve-been-looking-for' => __( "What you've been looking for?", 'freemius' ),
116
+ 'placeholder-what-did-you-expect' => __( "What did you expect?", 'freemius' ),
117
+ 'reason-didnt-work' => __( "The plugin didn't work", 'freemius' ),
118
+ 'reason-dont-like-to-share-my-information' => __( "I don't like to share my information with you", 'freemius' ),
119
+ #endregion Plugin Deactivation
120
+
121
+ #region Connect
122
+ 'hey-x' => _x( 'Hey %s,', 'greeting', 'freemius' ),
123
+ 'thanks-x' => _x( 'Thanks %s!', 'a greeting. E.g. Thanks John!', 'freemius' ),
124
+ 'connect-message' => __( 'In order to enjoy all our features and functionality, %s needs to connect your user, %s at %s, to %s', 'freemius' ),
125
+ 'pending-activation-message' => __( '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 complete the install.', 'freemius' ),
126
+ 'what-permissions' => __( 'What permissions are being granted?', 'freemius' ),
127
+ 'permissions-profile' => __( 'Your Profile Overview', 'freemius' ),
128
+ 'permissions-profile_desc' => __( 'Name and email address', 'freemius' ),
129
+ 'permissions-site' => __( 'Your Site Overview', 'freemius' ),
130
+ 'permissions-site_desc' => __( 'Site address and WordPress version', 'freemius' ),
131
+ 'permissions-events' => __( 'Current Plugin Events', 'freemius' ),
132
+ 'permissions-events_desc' => __( 'Activation, deactivation and uninstall', 'freemius' ),
133
+ 'privacy-policy' => __( 'Privacy Policy', 'freemius' ),
134
+ 'tos' => __( 'Terms of Service', 'freemius' ),
135
+ 'activating' => _x( 'Activating', 'as activating plugin', 'freemius' ),
136
+ 'opt-in-connect' => _x( 'Allow & Continue', 'button label', 'freemius' ),
137
+ 'skip' => _x( 'Skip', 'verb', 'freemius' ),
138
+ 'resend-activation-email' => __( 'Re-send activation email', 'freemius' ),
139
+ #endregion Connect
140
+
141
+ #region Screenshots
142
+ 'screenshots' => __( 'Screenshots', 'freemius' ),
143
+ 'view-full-size-x' => __( 'Click to view full-size screenshot %d', 'freemius' ),
144
+ #endregion Screenshots
145
+
146
+ #region Debug
147
+ 'addons-of-x' => __( 'Add Ons of Plugin %s', 'freemius' ),
148
+ 'delete-all-confirm' => __( 'Are you sure you want to delete the all Freemius data?', 'freemius' ),
149
+ 'delete-all-accounts' => __( 'Delete All Accounts', 'freemius' ),
150
+ #endregion Debug
151
+
152
+ #region Expressions
153
+ 'congrats' => _x( 'Congrats', 'as congratulations', 'freemius' ),
154
+ 'oops' => _x( 'Oops', 'exclamation', 'freemius' ),
155
+ 'yee-haw' => _x( 'Yee-haw', 'interjection expressing joy or exuberance', 'freemius' ),
156
+ 'woot' => _x( 'W00t', '(especially in electronic communication) used to express elation, enthusiasm, or triumph.', 'freemius' ),
157
+ 'right-on' => _x( 'Right on', 'a positive response', 'freemius' ),
158
+ 'hmm' => _x( 'Hmm', 'something somebody says when they are thinking about what you have just said. ', 'freemius' ),
159
+ 'ok' => __( 'O.K', 'freemius' ),
160
+ 'hey' => _x( 'Hey', 'exclamation', 'freemius' ),
161
+ 'heads-up' => _x( 'Heads up', 'advance notice of something that will need attention.', 'freemius' ),
162
+ #endregion Expressions
163
+
164
+ #region Admin Notices
165
+ 'you-have-latest' => __( 'Seems like you got the latest release.', 'freemius' ),
166
+ 'you-are-good' => __( 'You are all good!', 'freemius' ),
167
+ 'user-exist-message' => __( 'Sorry, we could not complete the email update. Another user with the same email is already registered.', 'freemius' ),
168
+ 'user-exist-message_ownership' => __( 'If you would like to give up the ownership of the plugin\'s account to %s click the Change Ownership button.', 'freemius' ),
169
+ 'email-updated-message' => __( 'Your email was successfully updated. You should receive an email with confirmation instructions in few moments.', 'freemius' ),
170
+ 'name-updated-message' => __( 'Your name was successfully updated.', 'freemius' ),
171
+ 'x-updated' => __( 'You have successfully updated your %s.', 'freemius' ),
172
+ 'name-update-failed-message' => __( 'Please provide your full name.', 'freemius' ),
173
+ 'verification-email-sent-message' => __( 'Verification mail was just sent to %s. If you can\'t find it after 5 min, please check your spam box.', 'freemius' ),
174
+ 'addons-info-external-message' => __( 'Just letting you know that the add-ons information of %s is being pulled from external server.', 'freemius' ),
175
+ 'no-cc-required' => __( 'No credit card required', 'freemius' ),
176
+ 'premium-activated-message' => __( 'Premium plugin version was successfully activated.', 'freemius' ),
177
+ 'successful-version-upgrade-message' => __( 'The upgrade of %s was successfully completed.', 'freemius' ),
178
+ 'activation-with-plan-x-message' => __( 'Your account was successfully activated with the %s plan.', 'freemius' ),
179
+ 'download-latest-x-version' => __( 'Download the latest %s version now', 'freemius' ),
180
+ 'download-latest-version' => __( 'Download the latest version now', 'freemius' ),
181
+ 'addon-successfully-purchased-message' => _x( '%s Add-on was successfully purchased.', '%s - product name, e.g. Facebook add-on was successfully...', 'freemius' ),
182
+ 'addon-successfully-upgraded-message' => __( 'Your %s Add-on plan was successfully upgraded.', 'freemius' ),
183
+ 'email-verified-message' => __( 'Your email has been successfully verified - you are AWESOME!', 'freemius' ),
184
+ 'plan-upgraded-message' => __( 'Your plan was successfully upgraded.', 'freemius' ),
185
+ 'plan-changed-to-x-message' => __( 'Your plan was successfully changed to %s.', 'freemius' ),
186
+ 'license-expired-blocking-message' => __( 'Your license has expired. You can still continue using the free plugin forever.', 'freemius' ),
187
+ 'trial-started-message' => __( 'Your trial has been successfully started.', 'freemius' ),
188
+ 'license-activated-message' => __( 'Your license was successfully activated.', 'freemius' ),
189
+ 'no-active-license-message' => __( 'It looks like your site currently don\'t have an active license.', 'freemius' ),
190
+ 'license-deactivation-message' => __( 'Your license was successfully deactivated, you are back to the %s plan.', 'freemius' ),
191
+ 'license-deactivation-failed-message' => __( 'It looks like the license deactivation failed.', 'freemius' ),
192
+ 'license-activation-failed-message' => __( 'It looks like the license could not be activated.', 'freemius' ),
193
+ 'server-error-message' => __( 'Error received from the server:', 'freemius' ),
194
+ 'trial-expired-message' => __( 'Your trial has expired. You can still continue using all our free features.', 'freemius' ),
195
+ 'plan-x-downgraded-message' => __( 'Your plan was successfully downgraded. Your %s plan license will expire in %s.', 'freemius' ),
196
+ 'plan-downgraded-failure-message' => __( 'Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes.', 'freemius' ),
197
+ 'trial-cancel-no-trial-message' => __( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', 'freemius' ),
198
+ 'trial-cancel-message' => __( 'Your %s Plan trial was successfully cancelled.', 'freemius' ),
199
+ 'version-x-released' => _x( 'Version %s was released.', '%s - numeric version number', 'freemius' ),
200
+ 'please-download-x' => __( 'Please download %s.', 'freemius' ),
201
+ 'latest-x-version' => _x( 'the latest %s version here', '%s - plan name, as the latest professional version here', 'freemius' ),
202
+ 'trial-x-promotion-message' => __( 'How do you like %s so far? Test all our %s premium features with a %d-day free trial.', 'freemius' ),
203
+ 'start-free-trial' => _x( 'Start free trial', 'call to action', 'freemius' ),
204
+ 'trial-cancel-failure-message' => __( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', 'freemius' ),
205
+ 'no-commitment-for-x-days' => __( 'No commitment for %s days - cancel anytime!', 'freemius' ),
206
+ 'license-expired-non-blocking-message' => __( 'Your license has expired. You can still continue using all the %s features, but you\'ll need to renew your license to continue getting updates and support.', 'freemius' ),
207
+ 'could-not-activate-x' => __( 'Couldn\'t activate %s.', 'freemius' ),
208
+ 'contact-us-with-error-message' => __( 'Please contact us with the following message:', 'freemius' ),
209
+ 'plan-did-not-change-message' => __( 'It looks like your plan did\'t change. If you did upgrade, it\'s probably an issue on our side - sorry.', 'freemius' ),
210
+ 'contact-us-here' => __( 'Please contact us here', 'freemius' ),
211
+ 'plan-did-not-change-email-message' => __( 'I have upgraded my account but when I try to Sync the License, the plan remains %s.', 'freemius' ),
212
+ #endregion Admin Notices
213
+ #region Connectivity Issues
214
+ 'connectivity-test-fails-message' => __( 'From unknown reason, the API connectivity test fails.', 'freemius' ),
215
+ 'curl-missing-message' => __( 'We use PHP cURL library for the API calls, which is a very common library and usually installed out of the box. Unfortunately, cURL is not installed on your server.', 'freemius' ),
216
+ 'cloudflare-blocks-connection-message' => __( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'freemius' ),
217
+ 'x-requires-access-to-api' => _x( '%s requires an access to our API.', 'as pluginX requires an access to our API', 'freemius' ),
218
+ 'squid-blocks-connection-message' => __( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'freemius' ),
219
+ 'squid-no-clue-title' => __( 'I don\'t know what is Squid or ACL, help me!', 'freemius' ),
220
+ 'squid-no-clue-desc' => __( '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.', 'freemius' ),
221
+ 'sysadmin-title' => __( 'I\'m a system administrator', 'freemius' ),
222
+ 'squid-sysadmin-desc' => __( 'Great, please whitelist the following domains: %s. Once you done, deactivate the plugin and activate it again.', 'freemius' ),
223
+ 'curl-missing-no-clue-title' => __( 'I don\'t know what is cURL or how to install it, help me!', 'freemius' ),
224
+ 'curl-missing-no-clue-desc' => __( '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.', 'freemius' ),
225
+ 'curl-missing-sysadmin-desc' => __( 'Great, please install cURL and enable it in your php.ini file. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the plugin and reactivate it back again.', 'freemius' ),
226
+ 'happy-to-resolve-issue-asap' => __( '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.', 'freemius' ),
227
+ 'fix-issue-title' => __( 'Yes - I\'m giving you a chance to fix it', 'freemius' ),
228
+ 'fix-issue-desc' => __( '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.', 'freemius' ),
229
+ 'install-previous-title' => __( 'Let\'s try your previous version', 'freemius' ),
230
+ 'install-previous-desc' => __( 'Uninstall this version and install the previous one.', 'freemius' ),
231
+ 'deactivate-plugin-title' => __( 'That\'s exhausting, please deactivate', 'freemius' ),
232
+ 'deactivate-plugin-desc' => __( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.', 'freemius' ),
233
+ 'fix-request-sent-message' => __( '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.', 'freemius' ),
234
+ 'server-blocking-access' => _x( 'Your server is blocking the access to Freemius\' API, which is crucial for %1s license synchronization. Please contact your host to whitelist %2s', '%1s - plugin title, %2s - API domain', 'freemius' ),
235
+ 'wrong-authentication-param-message' => __( 'It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again.', 'freemius' ),
236
+ #endregion Connectivity Issues
237
+ #region Change Owner
238
+ 'change-owner-request-sent-x' => __( 'Please check your mailbox, you should receive an email via %s to confirm the ownership change. From security reasons, you must confirm the change within the next 15 min. If you cannot find the email, please check your spam folder.', 'freemius' ),
239
+ 'change-owner-request_owner-confirmed' => __( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.', 'freemius' ),
240
+ 'change-owner-request_candidate-confirmed' => __( '%s is the new owner of the account.', 'freemius' ),
241
+ #endregion Change Owner
242
+ 'freemius-debug' => __( 'Freemius Debug', 'freemius' ),
243
+ 'addon-x-cannot-run-without-y' => _x( '%s cannot run without %s.', 'addonX cannot run without pluginY', 'freemius' ),
244
+ 'addon-x-cannot-run-without-parent' => _x( '%s cannot run without the plugin.', 'addonX cannot run...', 'freemius' ),
245
+ 'plugin-x-activation-message' => _x( '%s activation was successfully completed.', 'pluginX activation was successfully...', 'freemius' ),
246
+ 'features-and-pricing' => _x( 'Features & Pricing', 'Plugin installer section title', 'freemius' ),
247
+ );
classes/freemius/includes/managers/class-fs-admin-menu-manager.php ADDED
@@ -0,0 +1,544 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Admin_Menu_Manager {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var string
19
+ */
20
+ protected $_plugin_slug;
21
+
22
+ /**
23
+ * @since 1.0.6
24
+ *
25
+ * @var string
26
+ */
27
+ private $_menu_slug;
28
+ /**
29
+ * @since 1.1.3
30
+ *
31
+ * @var string
32
+ */
33
+ private $_parent_slug;
34
+ /**
35
+ * @since 1.1.3
36
+ *
37
+ * @var string
38
+ */
39
+ private $_parent_type;
40
+ /**
41
+ * @since 1.1.3
42
+ *
43
+ * @var string
44
+ */
45
+ private $_type;
46
+ /**
47
+ * @since 1.1.3
48
+ *
49
+ * @var bool
50
+ */
51
+ private $_is_top_level;
52
+ /**
53
+ * @since 1.1.3
54
+ *
55
+ * @var bool
56
+ */
57
+ private $_is_override_exact;
58
+ /**
59
+ * @since 1.1.3
60
+ *
61
+ * @var string[]bool
62
+ */
63
+ private $_default_submenu_items;
64
+ /**
65
+ * @since 1.1.3
66
+ *
67
+ * @var string
68
+ */
69
+ private $_first_time_path;
70
+
71
+ #endregion Properties
72
+
73
+ /**
74
+ * @var FS_Logger
75
+ */
76
+ protected $_logger;
77
+
78
+ #region Singleton
79
+
80
+ /**
81
+ * @var FS_Admin_Menu_Manager[]
82
+ */
83
+ private static $_instances = array();
84
+
85
+ /**
86
+ * @param string $plugin_slug
87
+ *
88
+ * @return FS_Admin_Notice_Manager
89
+ */
90
+ static function instance( $plugin_slug ) {
91
+ if ( ! isset( self::$_instances[ $plugin_slug ] ) ) {
92
+ self::$_instances[ $plugin_slug ] = new FS_Admin_Menu_Manager( $plugin_slug );
93
+ }
94
+
95
+ return self::$_instances[ $plugin_slug ];
96
+ }
97
+
98
+ protected function __construct( $plugin_slug ) {
99
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $plugin_slug . '_admin_menu', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
100
+
101
+ $this->_plugin_slug = $plugin_slug;
102
+ }
103
+
104
+ #endregion Singleton
105
+
106
+ #region Helpers
107
+
108
+ private function get_option( &$options, $key, $default = false ) {
109
+ return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
110
+ }
111
+
112
+ private function get_bool_option( &$options, $key, $default = false ) {
113
+ return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
114
+ }
115
+
116
+ #endregion Helpers
117
+
118
+ /**
119
+ * @param array $menu
120
+ * @param bool $is_addon
121
+ */
122
+ function init( $menu, $is_addon = false ) {
123
+ $this->_menu_slug = $menu['slug'];
124
+
125
+ $this->_default_submenu_items = array();
126
+ // @deprecated
127
+ $this->_type = 'page';
128
+ $this->_is_top_level = true;
129
+ $this->_is_override_exact = false;
130
+ $this->_parent_slug = false;
131
+ // @deprecated
132
+ $this->_parent_type = 'page';
133
+
134
+ if ( ! $is_addon && isset( $menu ) ) {
135
+ $this->_default_submenu_items = array(
136
+ 'contact' => $this->get_bool_option( $menu, 'contact', true ),
137
+ 'support' => $this->get_bool_option( $menu, 'support', true ),
138
+ 'account' => $this->get_bool_option( $menu, 'account', true ),
139
+ 'pricing' => $this->get_bool_option( $menu, 'pricing', true ),
140
+ 'addons' => $this->get_bool_option( $menu, 'addons', true ),
141
+ );
142
+
143
+ // @deprecated
144
+ $this->_type = $this->get_option( $menu, 'type', 'page' );
145
+ $this->_is_override_exact = $this->get_bool_option( $menu, 'override_exact' );
146
+
147
+ if ( isset( $menu['parent'] ) ) {
148
+ $this->_parent_slug = $this->get_option( $menu['parent'], 'slug' );
149
+ // @deprecated
150
+ $this->_parent_type = $this->get_option( $menu['parent'], 'type', 'page' );
151
+
152
+ // If parent's slug is different, then it's NOT a top level menu item.
153
+ $this->_is_top_level = ( $this->_parent_slug === $this->_menu_slug );
154
+ } else {
155
+ /**
156
+ * If no parent then top level if:
157
+ * - Has custom admin menu ('page')
158
+ * - CPT menu type ('cpt')
159
+ */
160
+ // $this->_is_top_level = in_array( $this->_type, array(
161
+ // 'cpt',
162
+ // 'page'
163
+ // ) );
164
+ }
165
+
166
+ $this->_first_time_path = $this->get_option( $menu, 'first-path', false );
167
+ if ( ! empty( $this->_first_time_path ) && is_string( $this->_first_time_path ) ) {
168
+ $this->_first_time_path = admin_url( $this->_first_time_path, 'admin' );
169
+ }
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Check if top level menu.
175
+ *
176
+ * @author Vova Feldman (@svovaf)
177
+ * @since 1.1.3
178
+ *
179
+ * @return bool False if submenu item.
180
+ */
181
+ function is_top_level() {
182
+ return $this->_is_top_level;
183
+ }
184
+
185
+ /**
186
+ * Check if the page should be override on exact URL match.
187
+ *
188
+ * @author Vova Feldman (@svovaf)
189
+ * @since 1.1.3
190
+ *
191
+ * @return bool False if submenu item.
192
+ */
193
+ function is_override_exact() {
194
+ return $this->_is_override_exact;
195
+ }
196
+
197
+
198
+ /**
199
+ * Get the path of the page the user should be forwarded to after first activation.
200
+ *
201
+ * @author Vova Feldman (@svovaf)
202
+ * @since 1.1.3
203
+ *
204
+ * @return string
205
+ */
206
+ function get_first_time_path() {
207
+ return $this->_first_time_path;
208
+ }
209
+
210
+ /**
211
+ * Check if plugin's menu item is part of a custom top level menu.
212
+ *
213
+ * @author Vova Feldman (@svovaf)
214
+ * @since 1.1.3
215
+ *
216
+ * @return bool
217
+ */
218
+ function has_custom_parent() {
219
+ return ! $this->_is_top_level && is_string( $this->_parent_slug );
220
+ }
221
+
222
+ /**
223
+ * @author Vova Feldman (@svovaf)
224
+ * @since 1.1.3
225
+ *
226
+ * @return string
227
+ */
228
+ // function slug(){
229
+ // return $this->_menu_slug;
230
+ // }
231
+
232
+ /**
233
+ * @author Vova Feldman (@svovaf)
234
+ * @since 1.1.3
235
+ *
236
+ * @param string $id
237
+ * @param bool $default
238
+ *
239
+ * @return bool
240
+ */
241
+ function is_submenu_item_visible( $id, $default = true ) {
242
+ return $this->get_bool_option( $this->_default_submenu_items, $id, $default );
243
+ }
244
+
245
+ /**
246
+ * Calculates admin settings menu slug.
247
+ * If plugin's menu slug is a file (e.g. CPT), uses plugin's slug as the menu slug.
248
+ *
249
+ * @author Vova Feldman (@svovaf)
250
+ * @since 1.1.3
251
+ *
252
+ * @param string $page
253
+ *
254
+ * @return string
255
+ */
256
+ function get_slug( $page = '' ) {
257
+ return ( ( false === strpos( $this->_menu_slug, '.php?' ) ) ?
258
+ $this->_menu_slug :
259
+ $this->_plugin_slug ) . ( empty( $page ) ? '' : ( '-' . $page ) );
260
+ }
261
+
262
+ /**
263
+ * @author Vova Feldman (@svovaf)
264
+ * @since 1.1.3
265
+ *
266
+ * @return string
267
+ */
268
+ function get_parent_slug() {
269
+ return $this->_parent_slug;
270
+ }
271
+
272
+ /**
273
+ * @author Vova Feldman (@svovaf)
274
+ * @since 1.1.3
275
+ *
276
+ * @return string
277
+ */
278
+ function get_type() {
279
+ return $this->_type;
280
+ }
281
+
282
+ /**
283
+ * @author Vova Feldman (@svovaf)
284
+ * @since 1.1.3
285
+ *
286
+ * @return bool
287
+ */
288
+ function is_cpt() {
289
+ return ( 0 === strpos( $this->_menu_slug, 'edit.php?post_type=' ) ||
290
+ // Back compatibility.
291
+ 'cpt' === $this->_type
292
+ );
293
+ }
294
+
295
+ /**
296
+ * @author Vova Feldman (@svovaf)
297
+ * @since 1.1.3
298
+ *
299
+ * @return string
300
+ */
301
+ function get_parent_type() {
302
+ return $this->_parent_type;
303
+ }
304
+
305
+ /**
306
+ * @author Vova Feldman (@svovaf)
307
+ * @since 1.1.3
308
+ *
309
+ * @return string
310
+ */
311
+ function get_raw_slug() {
312
+ return $this->_menu_slug;
313
+ }
314
+
315
+ /**
316
+ * Get plugin's original menu slug.
317
+ *
318
+ * @author Vova Feldman (@svovaf)
319
+ * @since 1.1.3
320
+ *
321
+ * @return string
322
+ */
323
+ function get_original_menu_slug() {
324
+ if ( 'cpt' === $this->_type ) {
325
+ return add_query_arg( array(
326
+ 'post_type' => $this->_menu_slug
327
+ ), 'edit.php' );
328
+ }
329
+
330
+ if ( false === strpos( $this->_menu_slug, '.php?' ) ) {
331
+ return $this->_menu_slug;
332
+ } else {
333
+ return $this->_plugin_slug;
334
+ }
335
+ }
336
+
337
+ /**
338
+ * @author Vova Feldman (@svovaf)
339
+ * @since 1.1.3
340
+ *
341
+ * @return string
342
+ */
343
+ function get_top_level_menu_slug() {
344
+ return $this->has_custom_parent() ?
345
+ $this->get_parent_slug() :
346
+ $this->get_raw_slug();
347
+ }
348
+
349
+ /**
350
+ * Is user on plugin's admin activation page.
351
+ *
352
+ * @author Vova Feldman (@svovaf)
353
+ * @since 1.0.8
354
+ *
355
+ * @return bool
356
+ */
357
+ function is_activation_page() {
358
+ return isset( $_GET['page'] ) &&
359
+ ( ( strtolower( $this->_menu_slug ) === strtolower( $_GET['page'] ) ) ||
360
+ ( strtolower( $this->_plugin_slug ) === strtolower( $_GET['page'] ) ) );
361
+ }
362
+
363
+ #region Submenu Override
364
+
365
+ /**
366
+ * Override submenu's action.
367
+ *
368
+ * @author Vova Feldman (@svovaf)
369
+ * @since 1.1.0
370
+ *
371
+ * @param string $parent_slug
372
+ * @param string $menu_slug
373
+ * @param callable $function
374
+ *
375
+ * @return false|string If submenu exist, will return the hook name.
376
+ */
377
+ function override_submenu_action( $parent_slug, $menu_slug, $function ) {
378
+ global $submenu;
379
+
380
+ $menu_slug = plugin_basename( $menu_slug );
381
+ $parent_slug = plugin_basename( $parent_slug );
382
+
383
+ if ( ! isset( $submenu[ $parent_slug ] ) ) {
384
+ // Parent menu not exist.
385
+ return false;
386
+ }
387
+
388
+ $found_submenu_item = false;
389
+ foreach ( $submenu[ $parent_slug ] as $submenu_item ) {
390
+ if ( $menu_slug === $submenu_item[2] ) {
391
+ $found_submenu_item = $submenu_item;
392
+ break;
393
+ }
394
+ }
395
+
396
+ if ( false === $found_submenu_item ) {
397
+ // Submenu item not found.
398
+ return false;
399
+ }
400
+
401
+ // Remove current function.
402
+ $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
403
+ remove_all_actions( $hookname );
404
+
405
+ // Attach new action.
406
+ add_action( $hookname, $function );
407
+
408
+ return $hookname;
409
+ }
410
+
411
+ #endregion Submenu Override
412
+
413
+ #region Top level menu Override
414
+
415
+ /**
416
+ * Find plugin's admin dashboard main menu item.
417
+ *
418
+ * @author Vova Feldman (@svovaf)
419
+ * @since 1.0.2
420
+ *
421
+ * @return string[]|false
422
+ */
423
+ private function find_top_level_menu() {
424
+ global $menu;
425
+
426
+ $position = - 1;
427
+ $found_menu = false;
428
+
429
+ $menu_slug = $this->get_raw_slug();
430
+
431
+ $hook_name = get_plugin_page_hookname( $menu_slug, '' );
432
+ foreach ( $menu as $pos => $m ) {
433
+ if ( $menu_slug === $m[2] ) {
434
+ $position = $pos;
435
+ $found_menu = $m;
436
+ break;
437
+ }
438
+ }
439
+
440
+ if ( false === $found_menu ) {
441
+ return false;
442
+ }
443
+
444
+ return array(
445
+ 'menu' => $found_menu,
446
+ 'position' => $position,
447
+ 'hook_name' => $hook_name
448
+ );
449
+ }
450
+
451
+ /**
452
+ * Remove all sub-menu items.
453
+ *
454
+ * @author Vova Feldman (@svovaf)
455
+ * @since 1.0.7
456
+ *
457
+ * @return bool If submenu with plugin's menu slug was found.
458
+ */
459
+ private function remove_all_submenu_items() {
460
+ global $submenu;
461
+
462
+ $menu_slug = $this->get_raw_slug();
463
+
464
+ if ( ! isset( $submenu[ $menu_slug ] ) ) {
465
+ return false;
466
+ }
467
+
468
+ $submenu[ $menu_slug ] = array();
469
+
470
+ return true;
471
+ }
472
+
473
+ /**
474
+ *
475
+ * @author Vova Feldman (@svovaf)
476
+ * @since 1.0.9
477
+ *
478
+ * @return array[string]mixed
479
+ */
480
+ function remove_menu_item() {
481
+ $this->_logger->entrance();
482
+
483
+ // Find main menu item.
484
+ $menu = $this->find_top_level_menu();
485
+
486
+ if ( false === $menu ) {
487
+ return false;
488
+ }
489
+
490
+ // Remove it with its actions.
491
+ remove_all_actions( $menu['hook_name'] );
492
+
493
+ // Remove all submenu items.
494
+ $this->remove_all_submenu_items();
495
+
496
+ return $menu;
497
+ }
498
+
499
+ /**
500
+ *
501
+ * @author Vova Feldman (@svovaf)
502
+ * @since 1.1.4
503
+ *
504
+ * @param callable $function
505
+ *
506
+ * @return array[string]mixed
507
+ */
508
+ function override_menu_item( $function ) {
509
+ $found_menu = $this->remove_menu_item();
510
+
511
+ if ( false === $found_menu ) {
512
+ return false;
513
+ }
514
+
515
+ if ( ! $this->is_top_level() || ! $this->is_cpt() ) {
516
+ $menu_slug = plugin_basename( $this->get_slug() );
517
+
518
+ $hookname = get_plugin_page_hookname( $menu_slug, '' );
519
+
520
+ // Override menu action.
521
+ add_action( $hookname, $function );
522
+ } else {
523
+ global $menu;
524
+
525
+ // Create new top-level menu action.
526
+ $hookname = add_menu_page(
527
+ $found_menu['menu'][3],
528
+ $found_menu['menu'][0],
529
+ 'manage_options',
530
+ $this->get_slug(),
531
+ $function,
532
+ $found_menu['menu'][6],
533
+ $found_menu['position']
534
+ );
535
+
536
+ // Remove original CPT menu.
537
+ unset( $menu[ $found_menu['position'] ] );
538
+ }
539
+
540
+ return $hookname;
541
+ }
542
+
543
+ #endregion Top level menu Override
544
+ }
classes/freemius/includes/managers/class-fs-admin-notice-manager.php ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.7
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Admin_Notice_Manager {
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_slug;
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_title;
22
+ /**
23
+ * @var array[]
24
+ */
25
+ private $_admin_messages = array();
26
+ /**
27
+ * @var FS_Key_Value_Storage
28
+ */
29
+ private $_sticky_storage;
30
+ /**
31
+ * @var FS_Plugin_Manager[]
32
+ */
33
+ private static $_instances = array();
34
+ /**
35
+ * @var FS_Logger
36
+ */
37
+ protected $_logger;
38
+
39
+ /**
40
+ * @param string $slug
41
+ * @param string $title
42
+ *
43
+ * @return FS_Admin_Notice_Manager
44
+ */
45
+ static function instance( $slug, $title = '' ) {
46
+ if ( ! isset( self::$_instances[ $slug ] ) ) {
47
+ self::$_instances[ $slug ] = new FS_Admin_Notice_Manager( $slug, $title );
48
+ }
49
+
50
+ return self::$_instances[ $slug ];
51
+ }
52
+
53
+ protected function __construct( $slug, $title = '' ) {
54
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_data', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
55
+
56
+ $this->_slug = $slug;
57
+ $this->_title = ! empty( $title ) ? $title : '';
58
+ $this->_sticky_storage = FS_Key_Value_Storage::instance( 'admin_notices', $this->_slug );
59
+
60
+ if ( is_admin() ) {
61
+ if ( 0 < count( $this->_sticky_storage ) ) {
62
+ // If there are sticky notices for the current slug, add a callback
63
+ // to the AJAX action that handles message dismiss.
64
+ add_action( "wp_ajax_{$slug}_dismiss_notice_action", array(
65
+ &$this,
66
+ 'dismiss_notice_ajax_callback'
67
+ ) );
68
+
69
+ foreach ( $this->_sticky_storage as $id => $msg ) {
70
+ // Add admin notice.
71
+ $this->add(
72
+ $msg['message'],
73
+ $msg['title'],
74
+ $msg['type'],
75
+ true,
76
+ $msg['all'],
77
+ $msg['id'],
78
+ false
79
+ );
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Remove sticky message by ID.
87
+ *
88
+ * @author Vova Feldman (@svovaf)
89
+ * @since 1.0.7
90
+ *
91
+ */
92
+ function dismiss_notice_ajax_callback() {
93
+ $this->_sticky_storage->remove( $_POST['message_id'] );
94
+ wp_die();
95
+ }
96
+
97
+ /**
98
+ * Rendered sticky message dismiss JavaScript.
99
+ *
100
+ * @author Vova Feldman (@svovaf)
101
+ * @since 1.0.7
102
+ */
103
+ static function _add_sticky_dismiss_javascript() {
104
+ $params = array();
105
+ fs_require_once_template( 'sticky-admin-notice-js.php', $params );
106
+ }
107
+
108
+ private static $_added_sticky_javascript = false;
109
+
110
+ /**
111
+ * Hook to the admin_footer to add sticky message dismiss JavaScript handler.
112
+ *
113
+ * @author Vova Feldman (@svovaf)
114
+ * @since 1.0.7
115
+ */
116
+ private static function has_sticky_messages() {
117
+ if ( ! self::$_added_sticky_javascript ) {
118
+ add_action( 'admin_footer', array( 'FS_Admin_Notice_Manager', '_add_sticky_dismiss_javascript' ) );
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Handle admin_notices by printing the admin messages stacked in the queue.
124
+ *
125
+ * @author Vova Feldman (@svovaf)
126
+ * @since 1.0.4
127
+ *
128
+ */
129
+ function _admin_notices_hook() {
130
+ $notice_type = 'admin_notices';
131
+
132
+ if ( ! isset( $this->_admin_messages[ $notice_type ] ) || ! is_array( $this->_admin_messages[ $notice_type ] ) ) {
133
+ return;
134
+ }
135
+
136
+ foreach ( $this->_admin_messages[ $notice_type ] as $id => $msg ) {
137
+ fs_require_template( 'admin-notice.php', $msg );
138
+
139
+ if ( $msg['sticky'] ) {
140
+ self::has_sticky_messages();
141
+ }
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Handle all_admin_notices by printing the admin messages stacked in the queue.
147
+ *
148
+ * @author Vova Feldman (@svovaf)
149
+ * @since 1.0.4
150
+ *
151
+ */
152
+ function _all_admin_notices_hook() {
153
+ $notice_type = 'all_admin_notices';
154
+
155
+ if ( ! isset( $this->_admin_messages[ $notice_type ] ) || ! is_array( $this->_admin_messages[ $notice_type ] ) ) {
156
+ return;
157
+ }
158
+
159
+ foreach ( $this->_admin_messages[ $notice_type ] as $id => $msg ) {
160
+ fs_require_template( 'all-admin-notice.php', $msg );
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Enqueue common stylesheet to style admin notice.
166
+ *
167
+ * @author Vova Feldman (@svovaf)
168
+ * @since 1.0.7
169
+ */
170
+ function _enqueue_styles() {
171
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
172
+ }
173
+
174
+ /**
175
+ * Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
176
+ *
177
+ * @author Vova Feldman (@svovaf)
178
+ * @since 1.0.4
179
+ *
180
+ * @param string $message
181
+ * @param string $title
182
+ * @param string $type
183
+ * @param bool $is_sticky
184
+ * @param bool $all_admin
185
+ * @param string $id Message ID
186
+ * @param bool $store_if_sticky
187
+ *
188
+ * @uses add_action()
189
+ */
190
+ function add( $message, $title = '', $type = 'success', $is_sticky = false, $all_admin = false, $id = '', $store_if_sticky = true ) {
191
+ $key = ( $all_admin ? 'all_admin_notices' : 'admin_notices' );
192
+
193
+ if ( ! isset( $this->_admin_messages[ $key ] ) ) {
194
+ $this->_admin_messages[ $key ] = array();
195
+
196
+ add_action( $key, array( &$this, "_{$key}_hook" ) );
197
+ add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_styles' ) );
198
+
199
+ }
200
+
201
+ if ( '' === $id ) {
202
+ $id = md5( $title . ' ' . $message . ' ' . $type );
203
+ }
204
+
205
+ $message_object = array(
206
+ 'message' => $message,
207
+ 'title' => $title,
208
+ 'type' => $type,
209
+ 'sticky' => $is_sticky,
210
+ 'id' => $id,
211
+ 'all' => $all_admin,
212
+ 'slug' => $this->_slug,
213
+ 'plugin' => $this->_title,
214
+ );
215
+
216
+ if ( $is_sticky && $store_if_sticky ) {
217
+ $this->_sticky_storage->{$id} = $message_object;
218
+ }
219
+
220
+ $this->_admin_messages[ $key ][ $id ] = $message_object;
221
+ }
222
+
223
+ /**
224
+ * @author Vova Feldman (@svovaf)
225
+ * @since 1.0.7
226
+ *
227
+ * @param string $ids
228
+ */
229
+ function remove_sticky( $ids ) {
230
+ if ( ! is_array( $ids ) ) {
231
+ $ids = array( $ids );
232
+ }
233
+
234
+ foreach ( $ids as $id ) {
235
+ // Remove from sticky storage.
236
+ $this->_sticky_storage->remove( $id );
237
+
238
+ // Remove from current admin messages.
239
+ if ( isset( $this->_admin_messages['all_admin_notices'] ) && isset( $this->_admin_messages['all_admin_notices'][ $id ] ) ) {
240
+ unset( $this->_admin_messages['all_admin_notices'][ $id ] );
241
+ }
242
+ if ( isset( $this->_admin_messages['admin_notices'] ) && isset( $this->_admin_messages['admin_notices'][ $id ] ) ) {
243
+ unset( $this->_admin_messages['admin_notices'][ $id ] );
244
+ }
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Check if sticky message exists by id.
250
+ *
251
+ * @author Vova Feldman (@svovaf)
252
+ * @since 1.0.9
253
+ *
254
+ * @param $id
255
+ *
256
+ * @return bool
257
+ */
258
+ function has_sticky( $id ) {
259
+ return isset( $this->_sticky_storage[ $id ] );
260
+ }
261
+
262
+ /**
263
+ * Adds sticky admin notification.
264
+ *
265
+ * @author Vova Feldman (@svovaf)
266
+ * @since 1.0.7
267
+ *
268
+ * @param string $message
269
+ * @param string $id Message ID
270
+ * @param string $title
271
+ * @param string $type
272
+ * @param bool $all_admin
273
+ */
274
+ function add_sticky( $message, $id, $title = '', $type = 'success', $all_admin = false ) {
275
+ $this->add( $message, $title, $type, true, $all_admin, $id );
276
+ }
277
+
278
+ /**
279
+ * Clear all sticky messages.
280
+ *
281
+ * @author Vova Feldman (@svovaf)
282
+ * @since 1.0.8
283
+ */
284
+ function clear_all_sticky() {
285
+ $this->_sticky_storage->clear_all();
286
+ }
287
+
288
+ /**
289
+ * Add admin message to all admin messages queue, and hook to all_admin_notices if not yet hooked.
290
+ *
291
+ * @author Vova Feldman (@svovaf)
292
+ * @since 1.0.4
293
+ *
294
+ * @param string $message
295
+ * @param string $title
296
+ * @param string $type
297
+ * @param bool $is_sticky
298
+ * @param string $id Message ID
299
+ */
300
+ function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) {
301
+ $this->add( $message, $title, $type, $is_sticky, true, $id );
302
+ }
303
+ }
classes/freemius/includes/managers/class-fs-key-value-storage.php ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.7
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Key_Value_Storage implements ArrayAccess, Iterator, Countable {
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_id;
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_slug;
22
+ /**
23
+ * @var array
24
+ */
25
+ protected $_data;
26
+
27
+ /**
28
+ * @var FS_Plugin_Manager[]
29
+ */
30
+ private static $_instances = array();
31
+ /**
32
+ * @var FS_Logger
33
+ */
34
+ protected $_logger;
35
+
36
+ /**
37
+ * @param string $id
38
+ * @param string $slug
39
+ *
40
+ * @return FS_Key_Value_Storage
41
+ */
42
+ static function instance( $id, $slug ) {
43
+ $key = $id . ':' . $slug;
44
+ if ( ! isset( self::$_instances[ $key ] ) ) {
45
+ self::$_instances[ $key ] = new FS_Key_Value_Storage( $id, $slug );
46
+ }
47
+
48
+ return self::$_instances[ $key ];
49
+ }
50
+
51
+ protected function __construct( $id, $slug ) {
52
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
53
+
54
+ $this->_slug = $slug;
55
+ $this->_id = $id;
56
+ $this->load();
57
+ }
58
+
59
+ protected function get_option_manager() {
60
+ return FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
61
+ }
62
+
63
+ protected function get_all_data() {
64
+ return $this->get_option_manager()->get_option( $this->_id, array() );
65
+ }
66
+
67
+ /**
68
+ * Load plugin data from local DB.
69
+ *
70
+ * @author Vova Feldman (@svovaf)
71
+ * @since 1.0.7
72
+ */
73
+ function load() {
74
+ $all_plugins_data = $this->get_all_data();
75
+ $this->_data = isset( $all_plugins_data[ $this->_slug ] ) ?
76
+ $all_plugins_data[ $this->_slug ] :
77
+ array();
78
+ }
79
+
80
+ /**
81
+ * @author Vova Feldman (@svovaf)
82
+ * @since 1.0.7
83
+ *
84
+ * @param string $key
85
+ * @param mixed $value
86
+ * @param bool $flush
87
+ */
88
+ function store( $key, $value, $flush = true ) {
89
+ if ( array_key_exists( $key, $this->_data ) && $value === $this->_data[ $key ] ) {
90
+ // No need to store data if the value wasn't changed.
91
+ return;
92
+ }
93
+
94
+ $all_data = $this->get_all_data();
95
+
96
+ $this->_data[ $key ] = $value;
97
+
98
+ $all_data[ $this->_slug ] = $this->_data;
99
+
100
+ $options_manager = $this->get_option_manager();
101
+ $options_manager->set_option( $this->_id, $all_data, $flush );
102
+ }
103
+
104
+ /**
105
+ * @author Vova Feldman (@svovaf)
106
+ * @since 1.0.7
107
+ *
108
+ * @param bool $store
109
+ * @param string[] $exceptions Set of keys to keep and not clear.
110
+ */
111
+ function clear_all( $store = true, $exceptions = array() ) {
112
+ $new_data = array();
113
+ foreach ( $exceptions as $key ) {
114
+ if ( isset( $this->_data[ $key ] ) ) {
115
+ $new_data[ $key ] = $this->_data[ $key ];
116
+ }
117
+ }
118
+
119
+ $this->_data = $new_data;
120
+
121
+ if ( $store ) {
122
+ $all_data = $this->get_all_data();
123
+ $all_data[ $this->_slug ] = $this->_data;
124
+ $options_manager = $this->get_option_manager();
125
+ $options_manager->set_option( $this->_id, $all_data, true );
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Delete key-value storage.
131
+ *
132
+ * @author Vova Feldman (@svovaf)
133
+ * @since 1.0.9
134
+ */
135
+ function delete() {
136
+ $this->_data = array();
137
+
138
+ $all_data = $this->get_all_data();
139
+ unset( $all_data[ $this->_slug ] );
140
+ $options_manager = $this->get_option_manager();
141
+ $options_manager->set_option( $this->_id, $all_data, true );
142
+ }
143
+
144
+ /**
145
+ * @author Vova Feldman (@svovaf)
146
+ * @since 1.0.7
147
+ *
148
+ * @param string $key
149
+ * @param bool $store
150
+ */
151
+ function remove( $key, $store = true ) {
152
+ if ( ! array_key_exists( $key, $this->_data ) ) {
153
+ return;
154
+ }
155
+
156
+ unset( $this->_data[ $key ] );
157
+
158
+ if ( $store ) {
159
+ $all_data = $this->get_all_data();
160
+ $all_data[ $this->_slug ] = $this->_data;
161
+ $options_manager = $this->get_option_manager();
162
+ $options_manager->set_option( $this->_id, $all_data, true );
163
+ }
164
+ }
165
+
166
+ /**
167
+ * @author Vova Feldman (@svovaf)
168
+ * @since 1.0.7
169
+ *
170
+ * @param string $key
171
+ * @param mixed $default
172
+ *
173
+ * @return bool|\FS_Plugin
174
+ */
175
+ function get( $key, $default = false ) {
176
+ return array_key_exists( $key, $this->_data ) ?
177
+ $this->_data[ $key ] :
178
+ $default;
179
+ }
180
+
181
+
182
+ /* ArrayAccess + Magic Access (better for refactoring)
183
+ -----------------------------------------------------------------------------------*/
184
+ function __set( $k, $v ) {
185
+ $this->store( $k, $v );
186
+ }
187
+
188
+ function __isset( $k ) {
189
+ return array_key_exists( $k, $this->_data );
190
+ }
191
+
192
+ function __unset( $k ) {
193
+ $this->remove( $k );
194
+ }
195
+
196
+ function __get( $k ) {
197
+ return $this->get( $k, null );
198
+ }
199
+
200
+ function offsetSet( $k, $v ) {
201
+ if ( is_null( $k ) ) {
202
+ throw new Exception( 'Can\'t append value to request params.' );
203
+ } else {
204
+ $this->{$k} = $v;
205
+ }
206
+ }
207
+
208
+ function offsetExists( $k ) {
209
+ return array_key_exists( $k, $this->_data );
210
+ }
211
+
212
+ function offsetUnset( $k ) {
213
+ unset( $this->$k );
214
+ }
215
+
216
+ function offsetGet( $k ) {
217
+ return $this->get( $k, null );
218
+ }
219
+
220
+ /**
221
+ * (PHP 5 &gt;= 5.0.0)<br/>
222
+ * Return the current element
223
+ *
224
+ * @link http://php.net/manual/en/iterator.current.php
225
+ * @return mixed Can return any type.
226
+ */
227
+ public function current() {
228
+ return current( $this->_data );
229
+ }
230
+
231
+ /**
232
+ * (PHP 5 &gt;= 5.0.0)<br/>
233
+ * Move forward to next element
234
+ *
235
+ * @link http://php.net/manual/en/iterator.next.php
236
+ * @return void Any returned value is ignored.
237
+ */
238
+ public function next() {
239
+ return next( $this->_data );
240
+ }
241
+
242
+ /**
243
+ * (PHP 5 &gt;= 5.0.0)<br/>
244
+ * Return the key of the current element
245
+ *
246
+ * @link http://php.net/manual/en/iterator.key.php
247
+ * @return mixed scalar on success, or null on failure.
248
+ */
249
+ public function key() {
250
+ return key( $this->_data );
251
+ }
252
+
253
+ /**
254
+ * (PHP 5 &gt;= 5.0.0)<br/>
255
+ * Checks if current position is valid
256
+ *
257
+ * @link http://php.net/manual/en/iterator.valid.php
258
+ * @return boolean The return value will be casted to boolean and then evaluated.
259
+ * Returns true on success or false on failure.
260
+ */
261
+ public function valid() {
262
+ $key = key( $this->_data );
263
+
264
+ return ( $key !== null && $key !== false );
265
+ }
266
+
267
+ /**
268
+ * (PHP 5 &gt;= 5.0.0)<br/>
269
+ * Rewind the Iterator to the first element
270
+ *
271
+ * @link http://php.net/manual/en/iterator.rewind.php
272
+ * @return void Any returned value is ignored.
273
+ */
274
+ public function rewind() {
275
+ reset( $this->_data );
276
+ }
277
+
278
+ /**
279
+ * (PHP 5 &gt;= 5.1.0)<br/>
280
+ * Count elements of an object
281
+ *
282
+ * @link http://php.net/manual/en/countable.count.php
283
+ * @return int The custom count as an integer.
284
+ * </p>
285
+ * <p>
286
+ * The return value is cast to an integer.
287
+ */
288
+ public function count() {
289
+ return count( $this->_data );
290
+ }
291
+ }
classes/freemius/includes/managers/class-fs-license-manager.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_License_Manager /*extends FS_Abstract_Manager*/
14
+ {
15
+ //
16
+ //
17
+ // /**
18
+ // * @var FS_License_Manager[]
19
+ // */
20
+ // private static $_instances = array();
21
+ //
22
+ // static function instance( Freemius $fs ) {
23
+ // $slug = strtolower( $fs->get_slug() );
24
+ //
25
+ // if ( ! isset( self::$_instances[ $slug ] ) ) {
26
+ // self::$_instances[ $slug ] = new FS_License_Manager( $slug, $fs );
27
+ // }
28
+ //
29
+ // return self::$_instances[ $slug ];
30
+ // }
31
+ //
32
+ //// private function __construct($slug) {
33
+ //// parent::__construct($slug);
34
+ //// }
35
+ //
36
+ // function entry_id() {
37
+ // return 'licenses';
38
+ // }
39
+ //
40
+ // function sync( $id ) {
41
+ //
42
+ // }
43
+ //
44
+ // /**
45
+ // * @author Vova Feldman (@svovaf)
46
+ // * @since 1.0.5
47
+ // * @uses FS_Api
48
+ // *
49
+ // * @param number|bool $plugin_id
50
+ // *
51
+ // * @return FS_Plugin_License[]|stdClass Licenses or API error.
52
+ // */
53
+ // function api_get_user_plugin_licenses( $plugin_id = false ) {
54
+ // $api = $this->_fs->get_api_user_scope();
55
+ //
56
+ // if ( ! is_numeric( $plugin_id ) ) {
57
+ // $plugin_id = $this->_fs->get_id();
58
+ // }
59
+ //
60
+ // $result = $api->call( "/plugins/{$plugin_id}/licenses.json" );
61
+ //
62
+ // if ( ! isset( $result->error ) ) {
63
+ // for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
64
+ // $result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
65
+ // }
66
+ //
67
+ // $result = $result->licenses;
68
+ // }
69
+ //
70
+ // return $result;
71
+ // }
72
+ //
73
+ // function api_get_many() {
74
+ //
75
+ // }
76
+ //
77
+ // function api_activate( $id ) {
78
+ //
79
+ // }
80
+ //
81
+ // function api_deactivate( $id ) {
82
+ //
83
+ // }
84
+
85
+ /**
86
+ * @param FS_Plugin_License[] $licenses
87
+ *
88
+ * @return bool
89
+ */
90
+ static function has_premium_license( $licenses ) {
91
+ if ( is_array( $licenses ) ) {
92
+ foreach ( $licenses as $license ) {
93
+ if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
94
+ return true;
95
+ }
96
+ }
97
+ }
98
+
99
+ return false;
100
+ }
101
+ }
classes/freemius/includes/managers/class-fs-option-manager.php ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * 3-layer lazy options manager.
15
+ * layer 3: Memory
16
+ * layer 2: Cache (if there's any caching plugin and if WP_FS__DEBUG_SDK is FALSE)
17
+ * layer 1: Database (options table). All options stored as one option record in the DB to reduce number of DB
18
+ * queries.
19
+ *
20
+ * If load() is not explicitly called, starts as empty manager. Same thing about saving the data - you have to
21
+ * explicitly call store().
22
+ *
23
+ * Class Freemius_Option_Manager
24
+ */
25
+ class FS_Option_Manager {
26
+ /**
27
+ * @var string
28
+ */
29
+ private $_id;
30
+ /**
31
+ * @var array
32
+ */
33
+ private $_options;
34
+ /**
35
+ * @var FS_Logger
36
+ */
37
+ private $_logger;
38
+
39
+ /**
40
+ * @var FS_Option_Manager[]
41
+ */
42
+ private static $_MANAGERS = array();
43
+
44
+ /**
45
+ * @author Vova Feldman (@svovaf)
46
+ * @since 1.0.3
47
+ *
48
+ * @param string $id
49
+ * @param bool $load
50
+ */
51
+ private function __construct( $id, $load = false ) {
52
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_opt_mngr_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
53
+
54
+ $this->_logger->entrance();
55
+ $this->_logger->log( 'id = ' . $id );
56
+
57
+ $this->_id = $id;
58
+
59
+ if ( $load ) {
60
+ $this->load();
61
+ }
62
+ }
63
+
64
+ /**
65
+ * @author Vova Feldman (@svovaf)
66
+ * @since 1.0.3
67
+ *
68
+ * @param $id
69
+ * @param $load
70
+ *
71
+ * @return FS_Option_Manager
72
+ */
73
+ static function get_manager( $id, $load = false ) {
74
+ $id = strtolower( $id );
75
+
76
+ if ( ! isset( self::$_MANAGERS[ $id ] ) ) {
77
+ self::$_MANAGERS[ $id ] = new FS_Option_Manager( $id, $load );
78
+ } // If load required but not yet loaded, load.
79
+ else if ( $load && ! self::$_MANAGERS[ $id ]->is_loaded() ) {
80
+ self::$_MANAGERS[ $id ]->load();
81
+ }
82
+
83
+ return self::$_MANAGERS[ $id ];
84
+ }
85
+
86
+ private function _get_option_manager_name() {
87
+ // return WP_FS__SLUG . '_' . $this->_id;
88
+ return $this->_id;
89
+ }
90
+
91
+ /**
92
+ * @author Vova Feldman (@svovaf)
93
+ * @since 1.0.3
94
+ *
95
+ * @param bool $flush
96
+ */
97
+ function load( $flush = false ) {
98
+ $this->_logger->entrance();
99
+
100
+ $option_name = $this->_get_option_manager_name();
101
+
102
+ if ( $flush || ! isset( $this->_options ) ) {
103
+ if ( ! WP_FS__DEBUG_SDK ) {
104
+ $this->_options = wp_cache_get( $option_name, WP_FS__SLUG );
105
+ }
106
+
107
+ // $this->_logger->info('wp_cache_get = ' . var_export($this->_options, true));
108
+
109
+ // if ( is_array( $this->_options ) ) {
110
+ // $this->clear();
111
+ // }
112
+
113
+ $cached = true;
114
+
115
+ if ( empty( $this->_options ) ) {
116
+ $this->_options = get_option( $option_name );
117
+
118
+ if ( is_string( $this->_options ) ) {
119
+ $this->_options = json_decode( $this->_options );
120
+ }
121
+
122
+ // $this->_logger->info('get_option = ' . var_export($this->_options, true));
123
+
124
+ if ( false === $this->_options ) {
125
+ $this->clear();
126
+ }
127
+
128
+ $cached = false;
129
+ }
130
+
131
+ if ( ! WP_FS__DEBUG_SDK && ! $cached ) // Set non encoded cache.
132
+ {
133
+ wp_cache_set( $option_name, $this->_options, WP_FS__SLUG );
134
+ }
135
+ }
136
+ }
137
+
138
+ /**
139
+ * @author Vova Feldman (@svovaf)
140
+ * @since 1.0.3
141
+ *
142
+ * @return bool
143
+ */
144
+ function is_loaded() {
145
+ return isset( $this->_options );
146
+ }
147
+
148
+ /**
149
+ * @author Vova Feldman (@svovaf)
150
+ * @since 1.0.3
151
+ *
152
+ * @return bool
153
+ */
154
+ function is_empty() {
155
+ return ( $this->is_loaded() && false === $this->_options );
156
+ }
157
+
158
+ /**
159
+ * @author Vova Feldman (@svovaf)
160
+ * @since 1.0.6
161
+ *
162
+ * @param bool $flush
163
+ */
164
+ function clear( $flush = false ) {
165
+ $this->_logger->entrance();
166
+
167
+ $this->_options = array();
168
+
169
+ if ( $flush ) {
170
+ $this->store();
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Delete options manager from DB.
176
+ *
177
+ * @author Vova Feldman (@svovaf)
178
+ * @since 1.0.9
179
+ */
180
+ function delete() {
181
+ delete_option( $this->_get_option_manager_name() );
182
+ }
183
+
184
+ /**
185
+ * @author Vova Feldman (@svovaf)
186
+ * @since 1.0.6
187
+ *
188
+ * @param string $option
189
+ *
190
+ * @return bool
191
+ */
192
+ function has_option( $option ) {
193
+ return array_key_exists( $option, $this->_options );
194
+ }
195
+
196
+ /**
197
+ * @author Vova Feldman (@svovaf)
198
+ * @since 1.0.3
199
+ *
200
+ * @param string $option
201
+ * @param mixed $default
202
+ *
203
+ * @return mixed
204
+ */
205
+ function get_option( $option, $default = null ) {
206
+ $this->_logger->entrance( 'option = ' . $option );
207
+
208
+ if ( is_array( $this->_options ) ) {
209
+ return isset( $this->_options[ $option ] ) ? $this->_options[ $option ] : $default;
210
+ } else if ( is_object( $this->_options ) ) {
211
+ return isset( $this->_options->{$option} ) ? $this->_options->{$option} : $default;
212
+ }
213
+
214
+ return $default;
215
+ }
216
+
217
+ /**
218
+ * @author Vova Feldman (@svovaf)
219
+ * @since 1.0.3
220
+ *
221
+ * @param string $option
222
+ * @param mixed $value
223
+ * @param bool $flush
224
+ */
225
+ function set_option( $option, $value, $flush = false ) {
226
+ $this->_logger->entrance( 'option = ' . $option );
227
+
228
+ if ( ! $this->is_loaded() ) {
229
+ $this->clear();
230
+ }
231
+
232
+ if ( is_array( $this->_options ) ) {
233
+ $this->_options[ $option ] = $value;
234
+ } else if ( is_object( $this->_options ) ) {
235
+ $this->_options->{$option} = $value;
236
+ }
237
+
238
+ if ( $flush ) {
239
+ $this->store();
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Unset option.
245
+ *
246
+ * @author Vova Feldman (@svovaf)
247
+ * @since 1.0.3
248
+ *
249
+ * @param string $option
250
+ * @param bool $flush
251
+ */
252
+ function unset_option( $option, $flush = false ) {
253
+ $this->_logger->entrance( 'option = ' . $option );
254
+
255
+ if ( is_array( $this->_options ) ) {
256
+ if ( ! isset( $this->_options[ $option ] ) ) {
257
+ return;
258
+ }
259
+
260
+ unset( $this->_options[ $option ] );
261
+
262
+ } else if ( is_object( $this->_options ) ) {
263
+ if ( ! isset( $this->_options->{$option} ) ) {
264
+ return;
265
+ }
266
+
267
+ unset( $this->_options->{$option} );
268
+ }
269
+
270
+ if ( $flush ) {
271
+ $this->store();
272
+ }
273
+ }
274
+
275
+ /**
276
+ * Dump options to database.
277
+ *
278
+ * @author Vova Feldman (@svovaf)
279
+ * @since 1.0.3
280
+ */
281
+ function store() {
282
+ $this->_logger->entrance();
283
+
284
+ $option_name = $this->_get_option_manager_name();
285
+
286
+ if ( $this->_logger->is_on() ) {
287
+ $this->_logger->info( $option_name . ' = ' . var_export( $this->_options, true ) );
288
+ }
289
+
290
+ // Update DB.
291
+ update_option( $option_name, $this->_options );
292
+
293
+ if ( ! WP_FS__DEBUG_SDK ) {
294
+ wp_cache_set( $option_name, $this->_options, WP_FS__SLUG );
295
+ }
296
+ }
297
+ }
classes/freemius/includes/managers/class-fs-plan-manager.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plan_Manager {
14
+ /**
15
+ * @var FS_Plan_Manager
16
+ */
17
+ private static $_instance;
18
+
19
+ /**
20
+ * @return FS_Plan_Manager
21
+ */
22
+ static function instance() {
23
+ if ( ! isset( self::$_instance ) ) {
24
+ self::$_instance = new FS_Plan_Manager();
25
+ }
26
+
27
+ return self::$_instance;
28
+ }
29
+
30
+ private function __construct() {
31
+ }
32
+
33
+ /**
34
+ * @param FS_Plugin_License[] $licenses
35
+ *
36
+ * @return bool
37
+ */
38
+ function has_premium_license( $licenses ) {
39
+ if ( is_array( $licenses ) ) {
40
+ foreach ( $licenses as $license ) {
41
+ if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
42
+ return true;
43
+ }
44
+ }
45
+ }
46
+
47
+ return false;
48
+ }
49
+
50
+ /**
51
+ * Check if plugin has any paid plans.
52
+ *
53
+ * @author Vova Feldman (@svovaf)
54
+ * @since 1.0.7
55
+ *
56
+ * @param FS_Plugin_Plan[] $plans
57
+ *
58
+ * @return bool
59
+ */
60
+ function has_paid_plan( $plans ) {
61
+ if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
62
+ return false;
63
+ }
64
+
65
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
66
+ if ( ! $plans[ $i ]->is_free() ) {
67
+ return true;
68
+ }
69
+ }
70
+
71
+ return false;
72
+ }
73
+
74
+ /**
75
+ * Check if plugin has any free plan, or is it premium only.
76
+ *
77
+ * Note: If no plans configured, assume plugin is free.
78
+ *
79
+ * @author Vova Feldman (@svovaf)
80
+ * @since 1.0.7
81
+ *
82
+ * @param FS_Plugin_Plan[] $plans
83
+ *
84
+ * @return bool
85
+ */
86
+ function has_free_plan( $plans ) {
87
+ if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
88
+ return true;
89
+ }
90
+
91
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
92
+ if ( $plans[ $i ]->is_free() ) {
93
+ return true;
94
+ }
95
+ }
96
+
97
+ return false;
98
+ }
99
+
100
+ /**
101
+ * Find all plans that have trial.
102
+ *
103
+ * @author Vova Feldman (@svovaf)
104
+ * @since 1.0.9
105
+ *
106
+ * @param FS_Plugin_Plan[] $plans
107
+ *
108
+ * @return FS_Plugin_Plan[]
109
+ */
110
+ function get_trial_plans( $plans ) {
111
+ $trial_plans = array();
112
+
113
+ if ( is_array( $plans ) && 0 < count( $plans ) ) {
114
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
115
+ if ( $plans[ $i ]->has_trial() ) {
116
+ $trial_plans[] = $plans[ $i ];
117
+ }
118
+ }
119
+ }
120
+
121
+ return $trial_plans;
122
+ }
123
+
124
+ /**
125
+ * Check if plugin has any trial plan.
126
+ *
127
+ * @author Vova Feldman (@svovaf)
128
+ * @since 1.0.9
129
+ *
130
+ * @param FS_Plugin_Plan[] $plans
131
+ *
132
+ * @return bool
133
+ */
134
+ function has_trial_plan( $plans ) {
135
+ if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
136
+ return true;
137
+ }
138
+
139
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
140
+ if ( $plans[ $i ]->has_trial() ) {
141
+ return true;
142
+ }
143
+ }
144
+
145
+ return false;
146
+ }
147
+ }
classes/freemius/includes/managers/class-fs-plugin-manager.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_Manager {
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_slug;
18
+ /**
19
+ * @var FS_Plugin
20
+ */
21
+ protected $_plugin;
22
+
23
+ /**
24
+ * @var FS_Plugin_Manager[]
25
+ */
26
+ private static $_instances = array();
27
+ /**
28
+ * @var FS_Logger
29
+ */
30
+ protected $_logger;
31
+
32
+ /**
33
+ * @param string $slug
34
+ *
35
+ * @return FS_Plugin_Manager
36
+ */
37
+ static function instance( $slug ) {
38
+ if ( ! isset( self::$_instances[ $slug ] ) ) {
39
+ self::$_instances[ $slug ] = new FS_Plugin_Manager( $slug );
40
+ }
41
+
42
+ return self::$_instances[ $slug ];
43
+ }
44
+
45
+ protected function __construct( $slug ) {
46
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_' . 'plugins', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
47
+
48
+ $this->_slug = $slug;
49
+ $this->load();
50
+ }
51
+
52
+ protected function get_option_manager() {
53
+ return FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
54
+ }
55
+
56
+ protected function get_all_plugins() {
57
+ return $this->get_option_manager()->get_option( 'plugins', array() );
58
+ }
59
+
60
+ /**
61
+ * Load plugin data from local DB.
62
+ *
63
+ * @author Vova Feldman (@svovaf)
64
+ * @since 1.0.6
65
+ */
66
+ function load() {
67
+ $all_plugins = $this->get_all_plugins();
68
+ $this->_plugin = isset( $all_plugins[ $this->_slug ] ) ?
69
+ $all_plugins[ $this->_slug ] :
70
+ null;
71
+ }
72
+
73
+ /**
74
+ * Store plugin on local DB.
75
+ *
76
+ * @author Vova Feldman (@svovaf)
77
+ * @since 1.0.6
78
+ *
79
+ * @param bool|FS_Plugin $plugin
80
+ * @param bool $flush
81
+ *
82
+ * @return bool|\FS_Plugin
83
+ */
84
+ function store( $plugin = false, $flush = true ) {
85
+ $all_plugins = $this->get_all_plugins();
86
+
87
+ if ( false !== $plugin ) {
88
+ $this->_plugin = $plugin;
89
+ }
90
+
91
+ $all_plugins[ $this->_slug ] = $this->_plugin;
92
+
93
+ $options_manager = $this->get_option_manager();
94
+ $options_manager->set_option( 'plugins', $all_plugins, $flush );
95
+
96
+ return $this->_plugin;
97
+ }
98
+
99
+ /**
100
+ * Update local plugin data if different.
101
+ *
102
+ * @author Vova Feldman (@svovaf)
103
+ * @since 1.0.6
104
+ *
105
+ * @param \FS_Plugin $plugin
106
+ * @param bool $store
107
+ *
108
+ * @return bool True if plugin was updated.
109
+ */
110
+ function update( FS_Plugin $plugin, $store = true ) {
111
+ if ( ! ( $this->_plugin instanceof FS_Plugin ) ||
112
+ $this->_plugin->slug != $plugin->slug ||
113
+ $this->_plugin->public_key != $plugin->public_key ||
114
+ $this->_plugin->secret_key != $plugin->secret_key ||
115
+ $this->_plugin->parent_plugin_id != $plugin->parent_plugin_id ||
116
+ $this->_plugin->title != $plugin->title
117
+ ) {
118
+ $this->store( $plugin, $store );
119
+
120
+ return true;
121
+ }
122
+
123
+ return false;
124
+ }
125
+
126
+ /**
127
+ * @author Vova Feldman (@svovaf)
128
+ * @since 1.0.6
129
+ *
130
+ * @param FS_Plugin $plugin
131
+ * @param bool $store
132
+ */
133
+ function set( FS_Plugin $plugin, $store = false ) {
134
+ $this->_plugin = $plugin;
135
+
136
+ if ( $store ) {
137
+ $this->store();
138
+ }
139
+ }
140
+
141
+ /**
142
+ * @author Vova Feldman (@svovaf)
143
+ * @since 1.0.6
144
+ *
145
+ * @return bool|\FS_Plugin
146
+ */
147
+ function get() {
148
+ return isset( $this->_plugin ) ?
149
+ $this->_plugin :
150
+ false;
151
+ }
152
+
153
+
154
+ }
classes/freemius/includes/sdk/Exceptions/ArgumentNotExistException.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ class Freemius_ArgumentNotExistException extends Freemius_InvalidArgumentException { }
classes/freemius/includes/sdk/Exceptions/EmptyArgumentException.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ class Freemius_EmptyArgumentException extends Freemius_InvalidArgumentException { }
classes/freemius/includes/sdk/Exceptions/Exception.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Thrown when an API call returns an exception.
4
+ *
5
+ */
6
+ class Freemius_Exception extends Exception
7
+ {
8
+ protected $_result;
9
+ protected $_type;
10
+ protected $_code;
11
+
12
+ /**
13
+ * Make a new API Exception with the given result.
14
+ *
15
+ * @param array $result The result from the API server.
16
+ */
17
+ public function __construct($result)
18
+ {
19
+ $this->_result = $result;
20
+
21
+ $code = 0;
22
+ $message = 'Unknown error, please check GetResult().';
23
+ $type = '';
24
+
25
+ if (isset($result['error']) && is_array($result['error']))
26
+ {
27
+ if (isset($result['error']['code']))
28
+ $code = $result['error']['code'];
29
+ if (isset($result['error']['message']))
30
+ $message = $result['error']['message'];
31
+ if (isset($result['error']['type']))
32
+ $type = $result['error']['type'];
33
+ }
34
+
35
+ $this->_type = $type;
36
+ $this->_code = $code;
37
+
38
+ parent::__construct($message, is_numeric($code) ? $code : 0);
39
+ }
40
+
41
+ /**
42
+ * Return the associated result object returned by the API server.
43
+ *
44
+ * @return array The result from the API server
45
+ */
46
+ public function getResult()
47
+ {
48
+ return $this->_result;
49
+ }
50
+
51
+ public function getStringCode()
52
+ {
53
+ return $this->_code;
54
+ }
55
+
56
+ public function getType()
57
+ {
58
+ return $this->_type;
59
+ }
60
+
61
+ /**
62
+ * To make debugging easier.
63
+ *
64
+ * @return string The string representation of the error
65
+ */
66
+ public function __toString()
67
+ {
68
+ $str = $this->getType() . ': ';
69
+
70
+ if ($this->code != 0)
71
+ $str .= $this->getStringCode() . ': ';
72
+
73
+ return $str . $this->getMessage();
74
+ }
75
+ }
classes/freemius/includes/sdk/Exceptions/InvalidArgumentException.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ class Freemius_InvalidArgumentException extends Freemius_Exception { }
classes/freemius/includes/sdk/Exceptions/OAuthException.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Freemius_OAuthException extends Freemius_Exception
3
+ {
4
+ public function __construct($pResult)
5
+ {
6
+ parent::__construct($pResult);
7
+ }
8
+ }
classes/freemius/includes/sdk/Freemius.php ADDED
@@ -0,0 +1,403 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2014 Freemius, Inc.
4
+ *
5
+ * Licensed under the GPL v2 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://choosealicense.com/licenses/gpl-v2/
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ */
17
+
18
+ require_once( dirname( __FILE__ ) . '/FreemiusBase.php' );
19
+
20
+ define( 'FS_SDK__USER_AGENT', 'fs-php-' . Freemius_Api_Base::VERSION );
21
+
22
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_CURL' ) ) {
23
+ define( 'FS_SDK__SIMULATE_NO_CURL', false );
24
+ }
25
+
26
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
27
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
28
+ }
29
+
30
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
31
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
32
+ }
33
+
34
+ define( 'FS_SDK__HAS_CURL', ! FS_SDK__SIMULATE_NO_CURL && function_exists( 'curl_version' ) );
35
+
36
+ if ( ! FS_SDK__HAS_CURL ) {
37
+ $curl_version = array( 'version' => '7.0.0' );
38
+ } else {
39
+ $curl_version = curl_version();
40
+ }
41
+
42
+ define( 'FS_API__PROTOCOL', version_compare( $curl_version['version'], '7.37', '>=' ) ? 'https' : 'http' );
43
+
44
+ if ( ! defined( 'FS_API__ADDRESS' ) ) {
45
+ define( 'FS_API__ADDRESS', '://api.freemius.com' );
46
+ }
47
+ if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
48
+ define( 'FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' );
49
+ }
50
+
51
+ class Freemius_Api extends Freemius_Api_Base {
52
+ /**
53
+ * Default options for curl.
54
+ */
55
+ public static $CURL_OPTS = array(
56
+ CURLOPT_CONNECTTIMEOUT => 10,
57
+ CURLOPT_RETURNTRANSFER => true,
58
+ CURLOPT_TIMEOUT => 60,
59
+ CURLOPT_USERAGENT => FS_SDK__USER_AGENT,
60
+ );
61
+
62
+ /**
63
+ * @param string $pScope 'app', 'developer', 'user' or 'install'.
64
+ * @param number $pID Element's id.
65
+ * @param string $pPublic Public key.
66
+ * @param string|bool $pSecret Element's secret key.
67
+ * @param bool $pSandbox Whether or not to run API in sandbox mode.
68
+ */
69
+ public function __construct( $pScope, $pID, $pPublic, $pSecret = false, $pSandbox = false ) {
70
+ // If secret key not provided, use public key encryption.
71
+ if ( is_bool( $pSecret ) ) {
72
+ $pSecret = $pPublic;
73
+ }
74
+
75
+ parent::Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox );
76
+ }
77
+
78
+ public function GetUrl( $pCanonizedPath = '' ) {
79
+ $address = ( $this->_sandbox ? FS_API__SANDBOX_ADDRESS : FS_API__ADDRESS );
80
+
81
+ if ( ':' === $address[0] ) {
82
+ $address = self::$_protocol . $address;
83
+ }
84
+
85
+ return $address . $pCanonizedPath;
86
+ }
87
+
88
+ /**
89
+ * @var int Clock diff in seconds between current server to API server.
90
+ */
91
+ private static $_clock_diff = 0;
92
+
93
+ /**
94
+ * Set clock diff for all API calls.
95
+ *
96
+ * @since 1.0.3
97
+ *
98
+ * @param $pSeconds
99
+ */
100
+ public static function SetClockDiff( $pSeconds ) {
101
+ self::$_clock_diff = $pSeconds;
102
+ }
103
+
104
+ /**
105
+ * @var string http or https
106
+ */
107
+ private static $_protocol = FS_API__PROTOCOL;
108
+
109
+ /**
110
+ * Set API connection protocol.
111
+ *
112
+ * @since 1.0.4
113
+ */
114
+ public static function SetHttp() {
115
+ self::$_protocol = 'http';
116
+ }
117
+
118
+ /**
119
+ * @since 1.0.4
120
+ *
121
+ * @return bool
122
+ */
123
+ public static function IsHttps() {
124
+ return ( 'https' === self::$_protocol );
125
+ }
126
+
127
+ /**
128
+ * Sign request with the following HTTP headers:
129
+ * Content-MD5: MD5(HTTP Request body)
130
+ * Date: Current date (i.e Sat, 14 Feb 2015 20:24:46 +0000)
131
+ * Authorization: FS {scope_entity_id}:{scope_entity_public_key}:base64encode(sha256(string_to_sign,
132
+ * {scope_entity_secret_key}))
133
+ *
134
+ * @param string $pResourceUrl
135
+ * @param array $opts
136
+ */
137
+ protected function SignRequest( $pResourceUrl, &$opts ) {
138
+ $eol = "\n";
139
+ $content_md5 = '';
140
+ $now = ( time() - self::$_clock_diff );
141
+ $date = date( 'r', $now );
142
+ $content_type = '';
143
+
144
+ if ( isset( $opts[ CURLOPT_POST ] ) && 0 < $opts[ CURLOPT_POST ] ) {
145
+ $content_md5 = md5( $opts[ CURLOPT_POSTFIELDS ] );
146
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Content-MD5: ' . $content_md5;
147
+ $content_type = 'application/json';
148
+ }
149
+
150
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Date: ' . $date;
151
+
152
+ $string_to_sign = implode( $eol, array(
153
+ $opts[ CURLOPT_CUSTOMREQUEST ],
154
+ $content_md5,
155
+ $content_type,
156
+ $date,
157
+ $pResourceUrl
158
+ ) );
159
+
160
+ // If secret and public keys are identical, it means that
161
+ // the signature uses public key hash encoding.
162
+ $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
163
+
164
+ // Add authorization header.
165
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Authorization: ' .
166
+ $auth_type . ' ' .
167
+ $this->_id . ':' .
168
+ $this->_public . ':' .
169
+ self::Base64UrlEncode(
170
+ hash_hmac( 'sha256', $string_to_sign, $this->_secret )
171
+ );
172
+ }
173
+
174
+ /**
175
+ * Get API request URL signed via query string.
176
+ *
177
+ * @param string $pPath
178
+ *
179
+ * @throws Freemius_Exception
180
+ *
181
+ * @return string
182
+ */
183
+ function GetSignedUrl( $pPath ) {
184
+ $resource = explode( '?', $this->CanonizePath( $pPath ) );
185
+ $pResourceUrl = $resource[0];
186
+
187
+ $eol = "\n";
188
+ $content_md5 = '';
189
+ $content_type = '';
190
+ $now = ( time() - self::$_clock_diff );
191
+ $date = date( 'r', $now );
192
+
193
+ $string_to_sign = implode( $eol, array(
194
+ 'GET',
195
+ $content_md5,
196
+ $content_type,
197
+ $date,
198
+ $pResourceUrl
199
+ ) );
200
+
201
+ // If secret and public keys are identical, it means that
202
+ // the signature uses public key hash encoding.
203
+ $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
204
+
205
+ return $this->GetUrl(
206
+ $pResourceUrl . '?' .
207
+ ( 1 < count( $resource ) && ! empty( $resource[1] ) ? $resource[1] . '&' : '' ) .
208
+ http_build_query( array(
209
+ 'auth_date' => $date,
210
+ 'authorization' => $auth_type . ' ' . $this->_id . ':' .
211
+ $this->_public . ':' .
212
+ self::Base64UrlEncode( hash_hmac(
213
+ 'sha256', $string_to_sign, $this->_secret
214
+ ) )
215
+ ) ) );
216
+ }
217
+
218
+ /**
219
+ * Makes an HTTP request. This method can be overridden by subclasses if
220
+ * developers want to do fancier things or use something other than curl to
221
+ * make the request.
222
+ *
223
+ * @param string $pCanonizedPath The URL to make the request to
224
+ * @param string $pMethod HTTP method
225
+ * @param array $params The parameters to use for the POST body
226
+ * @param null|resource $ch Initialized curl handle
227
+ *
228
+ * @return object[]|object|null
229
+ *
230
+ * @throws Freemius_Exception
231
+ */
232
+ public function MakeRequest( $pCanonizedPath, $pMethod = 'GET', $params = array(), $ch = null ) {
233
+ if ( !FS_SDK__HAS_CURL ) {
234
+ $this->ThrowNoCurlException();
235
+ }
236
+
237
+ // Connectivity errors simulation.
238
+ if ( FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
239
+ $this->ThrowCloudFlareDDoSException();
240
+ } else if ( FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
241
+ $this->ThrowSquidAclException();
242
+ }
243
+
244
+ if ( ! $ch ) {
245
+ $ch = curl_init();
246
+ }
247
+
248
+ $opts = self::$CURL_OPTS;
249
+
250
+ if ( ! isset( $opts[ CURLOPT_HTTPHEADER ] ) || ! is_array( $opts[ CURLOPT_HTTPHEADER ] ) ) {
251
+ $opts[ CURLOPT_HTTPHEADER ] = array();
252
+ }
253
+
254
+ if ( 'POST' === $pMethod || 'PUT' === $pMethod ) {
255
+ if ( is_array( $params ) && 0 < count( $params ) ) {
256
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Content-Type: application/json';
257
+ $opts[ CURLOPT_POST ] = count( $params );
258
+ $opts[ CURLOPT_POSTFIELDS ] = json_encode( $params );
259
+ }
260
+
261
+ $opts[ CURLOPT_RETURNTRANSFER ] = true;
262
+ }
263
+
264
+ $opts[ CURLOPT_URL ] = $this->GetUrl( $pCanonizedPath );
265
+ $opts[ CURLOPT_CUSTOMREQUEST ] = $pMethod;
266
+
267
+ $resource = explode( '?', $pCanonizedPath );
268
+
269
+ // Only sign request if not ping.json connectivity test.
270
+ if ( '/v1/ping.json' !== strtolower( substr( $resource[0], - strlen( '/v1/ping.json' ) ) ) ) {
271
+ $this->SignRequest( $resource[0], $opts );
272
+ }
273
+
274
+ // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
275
+ // for 2 seconds if the server does not support this header.
276
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Expect:';
277
+
278
+ if ( 'https' === substr( strtolower( $pCanonizedPath ), 0, 5 ) ) {
279
+ $opts[ CURLOPT_SSL_VERIFYHOST ] = false;
280
+ $opts[ CURLOPT_SSL_VERIFYPEER ] = false;
281
+ }
282
+
283
+ curl_setopt_array( $ch, $opts );
284
+ $result = curl_exec( $ch );
285
+
286
+ /*if (curl_errno($ch) == 60) // CURLE_SSL_CACERT
287
+ {
288
+ self::errorLog('Invalid or no certificate authority found, using bundled information');
289
+ curl_setopt($ch, CURLOPT_CAINFO,
290
+ dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
291
+ $result = curl_exec($ch);
292
+ }*/
293
+
294
+ // With dual stacked DNS responses, it's possible for a server to
295
+ // have IPv6 enabled but not have IPv6 connectivity. If this is
296
+ // the case, curl will try IPv4 first and if that fails, then it will
297
+ // fall back to IPv6 and the error EHOSTUNREACH is returned by the
298
+ // operating system.
299
+ if ( false === $result && empty( $opts[ CURLOPT_IPRESOLVE ] ) ) {
300
+ $matches = array();
301
+ $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
302
+ if ( preg_match( $regex, curl_error( $ch ), $matches ) ) {
303
+ if ( strlen( @inet_pton( $matches[1] ) ) === 16 ) {
304
+ // self::errorLog('Invalid IPv6 configuration on server, Please disable or get native IPv6 on your server.');
305
+ self::$CURL_OPTS[ CURLOPT_IPRESOLVE ] = CURL_IPRESOLVE_V4;
306
+ curl_setopt( $ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
307
+ $result = curl_exec( $ch );
308
+ }
309
+ }
310
+ }
311
+
312
+ if ( $result === false ) {
313
+ $e = new Freemius_Exception( array(
314
+ 'error' => array(
315
+ 'code' => curl_errno( $ch ),
316
+ 'message' => curl_error( $ch ),
317
+ 'type' => 'CurlException',
318
+ ),
319
+ ) );
320
+
321
+ curl_close( $ch );
322
+ throw $e;
323
+ }
324
+
325
+ curl_close( $ch );
326
+
327
+ if (empty($result))
328
+ return null;
329
+
330
+ $decoded = json_decode( $result );
331
+
332
+ if ( is_null( $decoded ) ) {
333
+ if ( preg_match( '/Please turn JavaScript on/i', $result ) &&
334
+ preg_match( '/text\/javascript/', $result )
335
+ ) {
336
+ $this->ThrowCloudFlareDDoSException( $result );
337
+ } else if ( preg_match( '/Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect./', $result ) &&
338
+ preg_match( '/squid/', $result )
339
+ ) {
340
+ $this->ThrowSquidAclException( $result );
341
+ } else {
342
+ $decoded = (object) array(
343
+ 'error' => (object) array(
344
+ 'type' => 'Unknown',
345
+ 'message' => $result,
346
+ 'code' => 'unknown',
347
+ 'http' => 402
348
+ )
349
+ );
350
+ }
351
+ }
352
+
353
+ return $decoded;
354
+ }
355
+
356
+ /**
357
+ * @param string $pResult
358
+ *
359
+ * @throws Freemius_Exception
360
+ */
361
+ private function ThrowNoCurlException( $pResult = '' ) {
362
+ throw new Freemius_Exception( array(
363
+ 'error' => (object) array(
364
+ 'type' => 'cUrlMissing',
365
+ 'message' => $pResult,
366
+ 'code' => 'curl_missing',
367
+ 'http' => 402
368
+ )
369
+ ) );
370
+ }
371
+
372
+ /**
373
+ * @param string $pResult
374
+ *
375
+ * @throws Freemius_Exception
376
+ */
377
+ private function ThrowCloudFlareDDoSException( $pResult = '' ) {
378
+ throw new Freemius_Exception( array(
379
+ 'error' => (object) array(
380
+ 'type' => 'CloudFlareDDoSProtection',
381
+ 'message' => $pResult,
382
+ 'code' => 'cloudflare_ddos_protection',
383
+ 'http' => 402
384
+ )
385
+ ) );
386
+ }
387
+
388
+ /**
389
+ * @param string $pResult
390
+ *
391
+ * @throws Freemius_Exception
392
+ */
393
+ private function ThrowSquidAclException( $pResult = '' ) {
394
+ throw new Freemius_Exception( array(
395
+ 'error' => (object) array(
396
+ 'type' => 'SquidCacheBlock',
397
+ 'message' => $pResult,
398
+ 'code' => 'squid_cache_block',
399
+ 'http' => 402
400
+ )
401
+ ) );
402
+ }
403
+ }
classes/freemius/includes/sdk/FreemiusBase.php ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2014 Freemius, Inc.
4
+ *
5
+ * Licensed under the GPL v2 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://choosealicense.com/licenses/gpl-v2/
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ */
17
+
18
+ define( 'FS_API__VERSION', '1' );
19
+ define( 'FS_SDK__PATH', dirname( __FILE__ ) );
20
+ define( 'FS_SDK__EXCEPTIONS_PATH', FS_SDK__PATH . '/Exceptions/' );
21
+
22
+ if ( ! function_exists( 'json_decode' ) ) {
23
+ throw new Exception( 'Freemius needs the JSON PHP extension.' );
24
+ }
25
+
26
+ // Include all exception files.
27
+ $exceptions = array(
28
+ 'Exception',
29
+ 'InvalidArgumentException',
30
+ 'ArgumentNotExistException',
31
+ 'EmptyArgumentException',
32
+ 'OAuthException'
33
+ );
34
+
35
+ foreach ( $exceptions as $e ) {
36
+ require FS_SDK__EXCEPTIONS_PATH . $e . '.php';
37
+ }
38
+
39
+ abstract class Freemius_Api_Base {
40
+ const VERSION = '1.0.4';
41
+ const FORMAT = 'json';
42
+
43
+ protected $_id;
44
+ protected $_public;
45
+ protected $_secret;
46
+ protected $_scope;
47
+ protected $_sandbox;
48
+
49
+ /**
50
+ * @param string $pScope 'app', 'developer', 'user' or 'install'.
51
+ * @param number $pID Element's id.
52
+ * @param string $pPublic Public key.
53
+ * @param string $pSecret Element's secret key.
54
+ * @param bool $pSandbox Whether or not to run API in sandbox mode.
55
+ */
56
+ public function Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox = false ) {
57
+ $this->_id = $pID;
58
+ $this->_public = $pPublic;
59
+ $this->_secret = $pSecret;
60
+ $this->_scope = $pScope;
61
+ $this->_sandbox = $pSandbox;
62
+ }
63
+
64
+ public function IsSandbox() {
65
+ return $this->_sandbox;
66
+ }
67
+
68
+ function CanonizePath( $pPath ) {
69
+ $pPath = trim( $pPath, '/' );
70
+ $query_pos = strpos( $pPath, '?' );
71
+ $query = '';
72
+
73
+ if ( false !== $query_pos ) {
74
+ $query = substr( $pPath, $query_pos );
75
+ $pPath = substr( $pPath, 0, $query_pos );
76
+ }
77
+
78
+ // Trim '.json' suffix.
79
+ $format_length = strlen( '.' . self::FORMAT );
80
+ $start = $format_length * ( - 1 ); //negative
81
+ if ( substr( strtolower( $pPath ), $start ) === ( '.' . self::FORMAT ) ) {
82
+ $pPath = substr( $pPath, 0, strlen( $pPath ) - $format_length );
83
+ }
84
+
85
+ switch ( $this->_scope ) {
86
+ case 'app':
87
+ $base = '/apps/' . $this->_id;
88
+ break;
89
+ case 'developer':
90
+ $base = '/developers/' . $this->_id;
91
+ break;
92
+ case 'user':
93
+ $base = '/users/' . $this->_id;
94
+ break;
95
+ case 'plugin':
96
+ $base = '/plugins/' . $this->_id;
97
+ break;
98
+ case 'install':
99
+ $base = '/installs/' . $this->_id;
100
+ break;
101
+ default:
102
+ throw new Freemius_Exception( 'Scope not implemented.' );
103
+ }
104
+
105
+ return '/v' . FS_API__VERSION . $base .
106
+ ( ! empty( $pPath ) ? '/' : '' ) . $pPath .
107
+ ( ( false === strpos( $pPath, '.' ) ) ? '.' . self::FORMAT : '' ) . $query;
108
+ }
109
+
110
+ abstract function MakeRequest( $pCanonizedPath, $pMethod = 'GET', $pParams = array() );
111
+
112
+ /**
113
+ * @param string $pPath
114
+ * @param string $pMethod
115
+ * @param array $pParams
116
+ *
117
+ * @return object[]|object|null
118
+ */
119
+ private function _Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
120
+ $pMethod = strtoupper( $pMethod );
121
+
122
+ try {
123
+ $result = $this->MakeRequest( $pPath, $pMethod, $pParams );
124
+ } catch ( Freemius_Exception $e ) {
125
+ // Map to error object.
126
+ $result = (object) $e->getResult();
127
+ } catch ( Exception $e ) {
128
+ // Map to error object.
129
+ $result = (object) array(
130
+ 'error' => array(
131
+ 'type' => 'Unknown',
132
+ 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
133
+ 'code' => 'unknown',
134
+ 'http' => 402
135
+ )
136
+ );
137
+ }
138
+
139
+ return $result;
140
+ }
141
+
142
+ /**
143
+ * If successful connectivity to the API endpoint using ping.json endpoint.
144
+ *
145
+ * - OR -
146
+ *
147
+ * Validate if ping result object is valid.
148
+ *
149
+ * @param mixed $pPong
150
+ *
151
+ * @return bool
152
+ */
153
+ public function Test( $pPong = null ) {
154
+ $pong = is_null( $pPong ) ? $this->Ping() : $pPong;
155
+
156
+ return ( is_object( $pong ) && isset( $pong->api ) && 'pong' === $pong->api );
157
+ }
158
+
159
+ /**
160
+ * Ping API to test connectivity.
161
+ *
162
+ * @return object
163
+ */
164
+ public function Ping() {
165
+ return $this->_Api( '/v' . FS_API__VERSION . '/ping.json' );
166
+ }
167
+
168
+ /**
169
+ * Find clock diff between current server to API server.
170
+ *
171
+ * @since 1.0.2
172
+ * @return int Clock diff in seconds.
173
+ */
174
+ public function FindClockDiff() {
175
+ $time = time();
176
+ $pong = $this->_Api( '/v' . FS_API__VERSION . '/ping.json' );
177
+
178
+ return ( $time - strtotime( $pong->timestamp ) );
179
+ }
180
+
181
+ public function Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
182
+ return $this->_Api( $this->CanonizePath( $pPath ), $pMethod, $pParams );
183
+ }
184
+
185
+ /**
186
+ * Base64 encoding that does not need to be urlencode()ed.
187
+ * Exactly the same as base64_encode except it uses
188
+ * - instead of +
189
+ * _ instead of /
190
+ * No padded =
191
+ *
192
+ * @param string $input base64UrlEncoded string
193
+ *
194
+ * @return string
195
+ */
196
+ protected static function Base64UrlDecode( $input ) {
197
+ return base64_decode( strtr( $input, '-_', '+/' ) );
198
+ }
199
+
200
+ /**
201
+ * Base64 encoding that does not need to be urlencode()ed.
202
+ * Exactly the same as base64_encode except it uses
203
+ * - instead of +
204
+ * _ instead of /
205
+ *
206
+ * @param string $input string
207
+ *
208
+ * @return string base64Url encoded string
209
+ */
210
+ protected static function Base64UrlEncode( $input ) {
211
+ $str = strtr( base64_encode( $input ), '+/', '-_' );
212
+ $str = str_replace( '=', '', $str );
213
+
214
+ return $str;
215
+ }
216
+
217
+ }
classes/freemius/includes/sdk/LICENSE.txt ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
340
+
classes/freemius/start.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Freemius hooks collection:
15
+ * fs_after_license_loaded
16
+ */
17
+
18
+ if ( ! class_exists( 'Freemius' ) ) {
19
+
20
+ // Configuration should be loaded first.
21
+ require_once dirname( __FILE__ ) . '/config.php';
22
+
23
+ // Logger must be loaded before any other.
24
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-logger.php';
25
+
26
+ require_once WP_FS__DIR_INCLUDES . '/fs-core-functions.php';
27
+ // require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-abstract-manager.php';
28
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-option-manager.php';
29
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-admin-notice-manager.php';
30
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-admin-menu-manager.php';
31
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-key-value-storage.php';
32
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-license-manager.php';
33
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-plan-manager.php';
34
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-plugin-manager.php';
35
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-entity.php';
36
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-scope-entity.php';
37
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-user.php';
38
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-site.php';
39
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin.php';
40
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-info.php';
41
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-tag.php';
42
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-plan.php';
43
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-license.php';
44
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-subscription.php';
45
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-api.php';
46
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-plugin-updater.php';
47
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-security.php';
48
+ require_once WP_FS__DIR_INCLUDES . '/class-freemius-abstract.php';
49
+ require_once WP_FS__DIR_INCLUDES . '/class-freemius.php';
50
+
51
+ /**
52
+ * Quick shortcut to get Freemius for specified plugin.
53
+ * Used by various templates.
54
+ *
55
+ * @param string $slug
56
+ *
57
+ * @return Freemius
58
+ */
59
+ function freemius( $slug ) {
60
+ return Freemius::instance( $slug );
61
+ }
62
+
63
+ /**
64
+ * @param string $slug
65
+ * @param number $plugin_id
66
+ * @param string $public_key
67
+ * @param bool $is_live Is live or test plugin.
68
+ * @param bool $is_premium Hints freemius if running the premium plugin or not.
69
+ *
70
+ * @return Freemius
71
+ */
72
+ function fs_init( $slug, $plugin_id, $public_key, $is_live = true, $is_premium = true ) {
73
+ $fs = Freemius::instance( $slug );
74
+ $fs->init( $plugin_id, $public_key, $is_live, $is_premium );
75
+
76
+ return $fs;
77
+ }
78
+
79
+ /**
80
+ * @param array [string]string $plugin
81
+ *
82
+ * @return Freemius
83
+ * @throws Freemius_Exception
84
+ */
85
+ function fs_dynamic_init( $plugin ) {
86
+ $fs = Freemius::instance( $plugin['slug'] );
87
+ $fs->dynamic_init( $plugin );
88
+
89
+ return $fs;
90
+ }
91
+
92
+ function fs_dump_log() {
93
+ FS_Logger::dump();
94
+ }
95
+ }
classes/freemius/templates/account.php ADDED
@@ -0,0 +1,442 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ $slug = $VARS['slug'];
10
+ /**
11
+ * @var Freemius $fs
12
+ */
13
+ $fs = freemius( $slug );
14
+
15
+ /**
16
+ * @var FS_Plugin_Tag $update
17
+ */
18
+ $update = $fs->get_update();
19
+
20
+ $is_paying = $fs->is_paying();
21
+ $user = $fs->get_user();
22
+ $site = $fs->get_site();
23
+ $name = $user->get_name();
24
+ $license = $fs->_get_license();
25
+ $subscription = $fs->_get_subscription();
26
+ $plan = $fs->get_plan();
27
+ $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
28
+ ?>
29
+
30
+ <div class="wrap">
31
+ <h2 class="nav-tab-wrapper">
32
+ <a href="<?php $fs->get_account_url() ?>" class="nav-tab nav-tab-active"><?php _efs( 'account' ) ?></a>
33
+ <?php if ( $fs->_has_addons() ) : ?>
34
+ <a href="<?php echo $fs->_get_admin_page_url( 'addons' ) ?>" class="nav-tab"><?php _efs( 'add-ons' ) ?></a>
35
+ <?php endif ?>
36
+ <?php if ( $fs->is_not_paying() && $fs->has_paid_plan() ) : ?>
37
+ <a href="<?php echo $fs->get_upgrade_url() ?>" class="nav-tab"><?php _efs( 'upgrade' ) ?></a>
38
+ <?php if ( ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?>
39
+ <a href="<?php echo $fs->get_trial_url() ?>" class="nav-tab"><?php _efs( 'free-trial' ) ?></a>
40
+ <?php endif ?>
41
+ <?php endif ?>
42
+ </h2>
43
+
44
+ <div id="poststuff">
45
+ <div id="fs_account">
46
+ <div class="has-sidebar has-right-sidebar">
47
+ <div class="has-sidebar-content">
48
+ <div class="postbox">
49
+ <h3><?php _efs( 'account-details' ) ?></h3>
50
+
51
+ <div class="fs-header-actions">
52
+ <ul>
53
+ <li>
54
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
55
+ <input type="hidden" name="fs_action" value="delete_account">
56
+ <?php wp_nonce_field( 'delete_account' ) ?>
57
+ <a href="#" onclick="if (confirm('<?php
58
+ if ( $is_active_subscription ) {
59
+ echo esc_attr( sprintf( __fs( 'delete-account-x-confirm' ), $plan->title ) );
60
+ } else {
61
+ _efs( 'delete-account-confirm' );
62
+ }
63
+ ?>')) this.parentNode.submit(); return false;"><?php _efs( 'delete-account' ) ?></a>
64
+ </form>
65
+ </li>
66
+ <?php if ( $is_paying ) : ?>
67
+ <li>
68
+ &nbsp;•&nbsp;
69
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
70
+ <input type="hidden" name="fs_action" value="deactivate_license">
71
+ <?php wp_nonce_field( 'deactivate_license' ) ?>
72
+ <a href="#"
73
+ onclick="if (confirm('<?php _efs( 'deactivate-license-confirm' ) ?>')) this.parentNode.submit(); return false;"><?php _efs( 'deactivate-license' ) ?></a>
74
+ </form>
75
+ </li>
76
+ <?php if ( ! $license->is_lifetime() &&
77
+ $is_active_subscription
78
+ ) : ?>
79
+ <li>
80
+ &nbsp;•&nbsp;
81
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
82
+ <input type="hidden" name="fs_action" value="downgrade_account">
83
+ <?php wp_nonce_field( 'downgrade_account' ) ?>
84
+ <a href="#"
85
+ onclick="if (confirm('<?php printf( __fs( 'downgrade-x-confirm' ), $plan->title, human_time_diff( time(), strtotime( $license->expiration ) ) ) ?> <?php if ( ! $license->is_block_features ) {
86
+ printf( __fs( 'after-downgrade-non-blocking' ), $plan->title );
87
+ } else {
88
+ printf( __fs( 'after-downgrade-blocking' ), $plan->title );
89
+ }?> <?php _efs( 'proceed-confirmation' ) ?>')) this.parentNode.submit(); return false;"><?php _efs( 'downgrade' ) ?></a>
90
+ </form>
91
+ </li>
92
+ <?php endif ?>
93
+ <li>
94
+ &nbsp;•&nbsp;
95
+ <a href="<?php echo $fs->get_upgrade_url() ?>"><?php _efs( 'change-plan' ) ?></a>
96
+ </li>
97
+ <?php endif ?>
98
+ </ul>
99
+ </div>
100
+ <div class="inside">
101
+ <table id="fs_account_details" cellspacing="0" class="fs-key-value-table">
102
+ <?php
103
+ $profile = array();
104
+ $profile[] = array(
105
+ 'id' => 'user_name',
106
+ 'title' => __fs( 'name' ),
107
+ 'value' => $name
108
+ );
109
+ // if (isset($user->email) && false !== strpos($user->email, '@'))
110
+ $profile[] = array(
111
+ 'id' => 'email',
112
+ 'title' => __fs( 'email' ),
113
+ 'value' => $user->email
114
+ );
115
+ if ( is_numeric( $user->id ) ) {
116
+ $profile[] = array(
117
+ 'id' => 'user_id',
118
+ 'title' => __fs( 'user-id' ),
119
+ 'value' => $user->id
120
+ );
121
+ }
122
+
123
+ $profile[] = array(
124
+ 'id' => 'site_id',
125
+ 'title' => __fs( 'site-id' ),
126
+ 'value' => is_string( $site->id ) ?
127
+ $site->id :
128
+ __fs( 'no-id' )
129
+ );
130
+
131
+ $profile[] = array(
132
+ 'id' => 'site_public_key',
133
+ 'title' => __fs( 'public-key' ),
134
+ 'value' => $site->public_key
135
+ );
136
+
137
+ $profile[] = array(
138
+ 'id' => 'site_secret_key',
139
+ 'title' => __fs( 'secret-key' ),
140
+ 'value' => ( ( is_string( $site->secret_key ) ) ?
141
+ $site->secret_key :
142
+ __fs( 'no-secret' )
143
+ )
144
+ );
145
+
146
+ if ( $fs->is_trial() ) {
147
+ $trial_plan = $fs->get_trial_plan();
148
+
149
+ $profile[] = array(
150
+ 'id' => 'plan',
151
+ 'title' => __fs( 'plan' ),
152
+ 'value' => ( is_string( $trial_plan->name ) ?
153
+ strtoupper( $trial_plan->title ) . ' ' :
154
+ '' ) . strtoupper( __fs( 'trial' ) )
155
+ );
156
+ } else {
157
+ $profile[] = array(
158
+ 'id' => 'plan',
159
+ 'title' => __fs( 'plan' ),
160
+ 'value' => is_string( $site->plan->name ) ?
161
+ strtoupper( $site->plan->title ) :
162
+ strtoupper( __fs( 'free' ) )
163
+ );
164
+ }
165
+
166
+ $profile[] = array(
167
+ 'id' => 'version',
168
+ 'title' => __fs( 'version' ),
169
+ 'value' => $fs->get_plugin_version()
170
+ );
171
+ ?>
172
+ <?php $odd = true;
173
+ foreach ( $profile as $p ) : ?>
174
+ <?php
175
+ if ( 'plan' === $p['id'] && ! $fs->has_paid_plan() ) {
176
+ // If plugin don't have any paid plans, there's no reason
177
+ // to show current plan.
178
+ continue;
179
+ }
180
+ ?>
181
+ <tr class="fs-field-<?php echo $p['id'] ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
182
+ <td>
183
+ <nobr><?php echo $p['title'] ?>:</nobr>
184
+ </td>
185
+ <td>
186
+ <code><?php echo htmlspecialchars( $p['value'] ) ?></code>
187
+ <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
188
+ <label><?php _efs( 'not-verified' ) ?></label>
189
+ <?php endif ?>
190
+ <?php if ( 'plan' === $p['id'] ) : ?>
191
+ <?php if ( $fs->is_trial() ) : ?>
192
+ <label><?php printf( __fs( 'expires-in' ), human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ?></label>
193
+ <?php elseif ( is_object( $license ) && ! $license->is_lifetime() ) : ?>
194
+ <?php if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) : ?>
195
+ <label><?php printf( __fs( 'expires-in' ), human_time_diff( time(), strtotime( $license->expiration ) ) ) ?></label>
196
+ <?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?>
197
+ <label><?php printf( __fs( 'renews-in' ), human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ?></label>
198
+ <?php endif ?>
199
+ <?php endif ?>
200
+ <?php endif ?>
201
+
202
+ </td>
203
+ <td class="fs-right">
204
+ <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
205
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
206
+ <input type="hidden" name="fs_action" value="verify_email">
207
+ <?php wp_nonce_field( 'verify_email' ) ?>
208
+ <input type="submit" class="button button-small"
209
+ value="<?php _efs( 'verify-email' ) ?>">
210
+ </form>
211
+ <?php endif ?>
212
+ <?php if ( 'plan' === $p['id'] ) : ?>
213
+ <div class="button-group">
214
+ <?php $license = $fs->is_not_paying() ? $fs->_get_available_premium_license() : false ?>
215
+ <?php if ( false !== $license && ( $license->left() > 0 || ( $site->is_localhost() && $license->is_free_localhost ) ) ) : ?>
216
+ <?php $premium_plan = $fs->_get_plan_by_id( $license->plan_id ) ?>
217
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
218
+ method="POST">
219
+ <input type="hidden" name="fs_action" value="activate_license">
220
+ <?php wp_nonce_field( 'activate_license' ) ?>
221
+ <input type="submit" class="button button-primary"
222
+ value="<?php printf(
223
+ __fs( 'activate-x-plan' ),
224
+ $premium_plan->title,
225
+ ( $site->is_localhost() && $license->is_free_localhost ) ?
226
+ '[' . __fs( 'localhost' ) . ']' :
227
+ ( 1 < $license->left() ? $license->left() . ' left' : '' )
228
+ ) ?> ">
229
+ </form>
230
+ <?php else : ?>
231
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
232
+ method="POST" class="button-group">
233
+ <input type="submit" class="button"
234
+ value="<?php _efs( 'sync-license' ) ?>">
235
+ <input type="hidden" name="fs_action"
236
+ value="<?php echo $slug ?>_sync_license">
237
+ <?php wp_nonce_field( $slug . '_sync_license' ) ?>
238
+ <a href="<?php echo $fs->get_upgrade_url() ?>"
239
+ class="button<?php if ( ! $is_paying ) {
240
+ echo ' button-primary';
241
+ } ?> button-upgrade"><?php ( ! $is_paying ) ?
242
+ _efs( 'upgrade' ) :
243
+ _efs( 'change-plan' )
244
+ ?></a>
245
+ </form>
246
+ <?php endif ?>
247
+ </div>
248
+ <?php elseif ( 'version' === $p['id'] ) : ?>
249
+ <div class="button-group">
250
+ <?php if ( $is_paying || $fs->is_trial() ) : ?>
251
+ <?php if ( ! $fs->is_allowed_to_install() ) : ?>
252
+ <a target="_blank" class="button button-primary"
253
+ href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php echo sprintf( __fs( 'download-x-version' ), $site->plan->title ) . ( is_object( $update ) ? ' [' . $update->version . ']' : '' ) ?></a>
254
+ <?php elseif ( is_object( $update ) ) : ?>
255
+ <a class="button button-primary"
256
+ href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $fs->get_plugin_basename() ), 'upgrade-plugin_' . $fs->get_plugin_basename() ) ?>"><?php echo __fs( 'install-update-now' ) . ' [' . $update->version . ']' ?></a>
257
+ <?php endif ?>
258
+ <?php endif; ?>
259
+ </div>
260
+ <?php
261
+ elseif (/*in_array($p['id'], array('site_secret_key', 'site_id', 'site_public_key')) ||*/
262
+ ( is_string( $user->secret_key ) && in_array( $p['id'], array(
263
+ 'email',
264
+ 'user_name'
265
+ ) ) )
266
+ ) : ?>
267
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"
268
+ onsubmit="var val = prompt('<?php printf( __fs( 'what-is-your-x' ), $p['title'] ) ?>', '<?php echo $p['value'] ?>'); if (null == val || '' === val) return false; jQuery('input[name=fs_<?php echo $p['id'] ?>_<?php echo $slug ?>]').val(val); return true;">
269
+ <input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>">
270
+ <input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $slug ?>"
271
+ value="">
272
+ <?php wp_nonce_field( 'update_' . $p['id'] ) ?>
273
+ <input type="submit" class="button button-small"
274
+ value="<?php _ex( 'Edit', 'verb', 'freemius' ) ?>">
275
+ </form>
276
+ <?php endif ?>
277
+ </td>
278
+ </tr>
279
+ <?php $odd = ! $odd; endforeach ?>
280
+ </table>
281
+ </div>
282
+ </div>
283
+ <?php
284
+ $account_addons = $fs->get_account_addons();
285
+ if ( ! is_array( $account_addons ) ) {
286
+ $account_addons = array();
287
+ }
288
+
289
+ $installed_addons = $fs->get_installed_addons();
290
+ $installed_addons_ids = array();
291
+ foreach ( $installed_addons as $fs_addon ) {
292
+ $installed_addons_ids[] = $fs_addon->get_id();
293
+ }
294
+
295
+ $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
296
+ ?>
297
+ <?php if ( 0 < count( $addons_to_show ) ) : ?>
298
+ <div class="postbox">
299
+ <table id="fs_addons" class="widefat">
300
+ <thead>
301
+ <tr>
302
+ <th></th>
303
+ <th><?php _efs( 'version' ) ?></th>
304
+ <th><?php _efs( 'plan' ) ?></th>
305
+ <th><?php _efs( 'expiration' ) ?></th>
306
+ <th></th>
307
+ <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
308
+ <th></th>
309
+ <?php endif ?>
310
+ </tr>
311
+ </thead>
312
+ <tbody>
313
+ <?php foreach ( $addons_to_show as $addon_id ) : ?>
314
+ <?php
315
+ $addon = $fs->get_addon( $addon_id );
316
+ $is_addon_activated = $fs->is_addon_activated( $addon->slug );
317
+
318
+ $fs_addon = $is_addon_activated ? freemius( $addon->slug ) : false;
319
+ ?>
320
+ <tr>
321
+ <td>
322
+ <?php echo $addon->title ?>
323
+ </td>
324
+ <?php if ( $is_addon_activated ) : ?>
325
+ <?php // Add-on Installed ?>
326
+ <?php $addon_site = $fs_addon->get_site(); ?>
327
+ <td><?php echo $fs_addon->get_plugin_version() ?></td>
328
+ <td><?php echo is_string( $addon_site->plan->name ) ? strtoupper( $addon_site->plan->title ) : 'FREE' ?></td>
329
+ <?php
330
+ $current_license = $fs_addon->_get_license();
331
+ $is_current_license_expired = is_object( $current_license ) && $current_license->is_expired();
332
+ ?>
333
+ <?php if ( $fs_addon->is_not_paying() ) : ?>
334
+ <?php if ( $is_current_license_expired ) : ?>
335
+ <td><?php _efs( 'expired' ) ?></td>
336
+ <?php endif ?>
337
+ <?php $premium_license = $fs_addon->_get_available_premium_license() ?>
338
+ <td<?php if ( ! $is_current_license_expired ) {
339
+ echo ' colspan="2"';
340
+ } ?>>
341
+ <?php if ( is_object( $premium_license ) && ! $premium_license->is_utilized() ) : ?>
342
+ <?php $site = $fs_addon->get_site() ?>
343
+ <?php fs_ui_action_button(
344
+ $slug, 'account',
345
+ 'activate_license',
346
+ sprintf( __fs( 'activate-x-plan' ), $fs_addon->get_plan_title(), ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ),
347
+ array( 'plugin_id' => $addon_id )
348
+ ) ?>
349
+ <?php else : ?>
350
+ <div class="button-group">
351
+ <?php fs_ui_action_button(
352
+ $slug, 'account',
353
+ $slug . '_sync_license',
354
+ __fs( 'sync-license' ),
355
+ array( 'plugin_id' => $addon_id ),
356
+ false
357
+ ) ?>
358
+ <?php echo sprintf( '<a href="%s" class="thickbox button button-primary" aria-label="%s" data-title="%s">%s</a>',
359
+ esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
360
+ '&TB_iframe=true&width=600&height=550' ) ),
361
+ esc_attr( sprintf( __fs( 'more-information-about-x' ), $addon->title ) ),
362
+ esc_attr( $addon->title ),
363
+ __fs( 'upgrade' )
364
+ ) ?>
365
+ </div>
366
+ <?php endif ?>
367
+ </td>
368
+ <?php else : ?>
369
+ <?php if ( is_object( $current_license ) ) : ?>
370
+ <td><?php
371
+ if ( $current_license->is_lifetime() ) {
372
+ _efs( 'no-expiration' );
373
+ } else if ( $current_license->is_expired() ) {
374
+ _efs( 'expired' );
375
+ } else {
376
+ echo sprintf(
377
+ __fs( 'in-x' ),
378
+ human_time_diff( time(), strtotime( $current_license->expiration ) )
379
+ );
380
+ }
381
+ ?></td>
382
+ <td>
383
+ <?php fs_ui_action_button(
384
+ $slug, 'account',
385
+ 'deactivate_license',
386
+ __fs( 'deactivate-license' ),
387
+ array( 'plugin_id' => $addon_id ),
388
+ false
389
+ ) ?>
390
+ </td>
391
+ <?php endif ?>
392
+ <?php endif ?>
393
+ <?php else : ?>
394
+ <?php // Add-on NOT Installed
395
+ ?>
396
+ <td colspan="4">
397
+ <?php if ( $fs->is_addon_installed( $addon->slug ) ) : ?>
398
+ <?php $addon_file = $fs->get_addon_basename( $addon->slug ) ?>
399
+ <a class="button button-primary"
400
+ href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
401
+ title="<?php esc_attr( __fs( 'activate-this-addon' ) ) ?>"
402
+ class="edit"><?php _efs( 'activate' ) ?></a>
403
+ <?php else : ?>
404
+ <?php if ( $fs->is_allowed_to_install() ) : ?>
405
+ <a class="button button-primary"
406
+ href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ) ?>"><?php _efs( 'install-now' ) ?></a>
407
+ <?php else : ?>
408
+ <a target="_blank" class="button button-primary"
409
+ href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php _efs( 'download-latest' ) ?></a>
410
+ <?php endif ?>
411
+ <?php endif ?>
412
+ </td>
413
+ <?php endif ?>
414
+ <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
415
+ <td>
416
+ <?php
417
+ if ( $is_addon_activated ) {
418
+ fs_ui_action_button(
419
+ $slug, 'account',
420
+ 'delete_account',
421
+ __fs( 'delete' ),
422
+ array( 'plugin_id' => $addon_id ),
423
+ false
424
+ );
425
+ }
426
+ ?>
427
+ </td>
428
+ <?php endif ?>
429
+ </tr>
430
+ <?php endforeach ?>
431
+ </tbody>
432
+ </table>
433
+ </div>
434
+ <?php endif ?>
435
+
436
+ <?php $fs->do_action( 'after_account_details' ) ?>
437
+ </div>
438
+ </div>
439
+ </div>
440
+ </div>
441
+ </div>
442
+ <?php fs_require_template( 'powered-by.php' ) ?>
classes/freemius/templates/add-ons.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ $slug = $VARS['slug'];
10
+ /**
11
+ * @var Freemius
12
+ */
13
+ $fs = freemius( $slug );
14
+
15
+ $open_addon_slug = fs_request_get( 'slug' );
16
+
17
+ $open_addon = false;
18
+
19
+ /**
20
+ * @var FS_Plugin[]
21
+ */
22
+ $addons = $fs->get_addons();
23
+ ?>
24
+ <div id="fs_addons" class="wrap">
25
+ <h2><?php printf( __fs( 'add-ons-for-x' ), $fs->get_plugin_name() ) ?></h2>
26
+
27
+ <div id="poststuff">
28
+ <ul class="fs-cards-list">
29
+ <?php foreach ( $addons as $addon ) : ?>
30
+ <?php
31
+ $open_addon = ( $open_addon || ( $open_addon_slug === $addon->slug ) );
32
+
33
+ $price = 0;
34
+ $plans_result = $fs->get_api_site_or_plugin_scope()->get( "/addons/{$addon->id}/plans.json" );
35
+ if ( ! isset( $plans_result->error ) ) {
36
+ $plans = $plans_result->plans;
37
+ if ( is_array( $plans ) && 0 < count( $plans ) ) {
38
+ $plan = $plans[0];
39
+ $pricing_result = $fs->get_api_site_or_plugin_scope()->get( "/addons/{$addon->id}/plans/{$plan->id}/pricing.json" );
40
+ if ( ! isset( $pricing_result->error ) ) {
41
+ // Update plan's pricing.
42
+ $plan->pricing = $pricing_result->pricing;
43
+
44
+ if ( is_array( $plan->pricing ) && 0 < count( $plan->pricing ) ) {
45
+ $min_price = 999999;
46
+ foreach ( $plan->pricing as $pricing ) {
47
+ if ( ! is_null( $pricing->annual_price ) && $pricing->annual_price > 0 ) {
48
+ $min_price = min( $min_price, $pricing->annual_price );
49
+ } else if ( ! is_null( $pricing->monthly_price ) && $pricing->monthly_price > 0 ) {
50
+ $min_price = min( $min_price, 12 * $pricing->monthly_price );
51
+ }
52
+ }
53
+
54
+ if ( $min_price < 999999 ) {
55
+ $price = $min_price;
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ ?>
62
+ <li class="fs-card" data-slug="<?php echo $addon->slug ?>">
63
+ <?php
64
+ echo sprintf( '<a href="%s" class="thickbox fs-overlay" aria-label="%s" data-title="%s"></a>',
65
+ esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
66
+ '&TB_iframe=true&width=600&height=550' ) ),
67
+ esc_attr( sprintf( __fs( 'more-information-about-x' ), $addon->title ) ),
68
+ esc_attr( $addon->title )
69
+ );
70
+ ?>
71
+ <?php
72
+ if ( is_null( $addon->info ) ) {
73
+ $addon->info = new stdClass();
74
+ }
75
+ if ( ! isset( $addon->info->card_banner_url ) ) {
76
+ $addon->info->card_banner_url = '//dashboard.freemius.com/assets/img/marketing/blueprint-300x100.jpg';
77
+ }
78
+ if ( ! isset( $addon->info->short_description ) ) {
79
+ $addon->info->short_description = 'What\'s the one thing your add-on does really, really well?';
80
+ }
81
+ ?>
82
+ <div class="fs-inner">
83
+ <ul>
84
+ <li class="fs-card-banner"
85
+ style="background-image: url('<?php echo $addon->info->card_banner_url ?>');"></li>
86
+ <li class="fs-title"><?php echo $addon->title ?></li>
87
+ <li class="fs-offer">
88
+ <span
89
+ class="fs-price"><?php echo ( 0 == $price ) ? __fs( 'free' ) : '$' . number_format( $price, 2 ) ?></span>
90
+ </li>
91
+ <li class="fs-description"><?php echo ! empty( $addon->info->short_description ) ? $addon->info->short_description : 'SHORT DESCRIPTION' ?></li>
92
+ </ul>
93
+ </div>
94
+ </li>
95
+ <?php endforeach ?>
96
+ </ul>
97
+ </div>
98
+ </div>
99
+ <?php if ( $open_addon ) : ?>
100
+ <script type="text/javascript">
101
+ (function ($) {
102
+ var interval = setInterval(function () {
103
+ // Open add-on information page.
104
+ $('.fs-card[data-slug=<?php echo $open_addon_slug ?>] a').click();
105
+ if ($('#TB_iframeContent').length > 0) {
106
+ clearInterval(interval);
107
+ interval = null;
108
+ }
109
+ }, 200);
110
+ })(jQuery);
111
+ </script>
112
+ <?php endif ?>
113
+ <?php fs_require_template( 'powered-by.php' ) ?>
classes/freemius/templates/admin-notice.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+ ?>
9
+ <div data-id="<?php echo $VARS['id'] ?>" data-slug="<?php echo $VARS['slug'] ?>" class="<?php
10
+ switch ( $VARS['type'] ) {
11
+ case 'error':
12
+ echo 'error form-invalid';
13
+ break;
14
+ case 'promotion':
15
+ echo 'updated promotion';
16
+ break;
17
+ case 'update':
18
+ // echo 'update-nag update';
19
+ // break;
20
+ case 'success':
21
+ default:
22
+ echo 'updated success';
23
+ break;
24
+ }
25
+ ?> fs-notice<?php if ( $VARS['sticky'] ) {
26
+ echo ' fs-sticky';
27
+ } ?><?php if ( ! empty( $VARS['plugin'] ) ) {
28
+ echo ' fs-has-title';
29
+ } ?>"><?php if ( ! empty( $VARS['plugin'] ) ) : ?><label
30
+ class="fs-plugin-title"><?php echo $VARS['plugin'] ?></label><?php endif ?><p>
31
+ <?php if ( ! empty( $VARS['title'] ) ) : ?><b><?php echo $VARS['title'] ?></b> <?php endif ?>
32
+ <?php echo $VARS['message'] ?>
33
+ </p><?php if ( $VARS['sticky'] ) : ?><i class="fs-close dashicons dashicons-no"
34
+ title="<?php _efs( 'dismiss' ) ?>"></i><?php endif ?></div>
classes/freemius/templates/all-admin-notice.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+ ?>
9
+ <div class="<?php
10
+ switch ($VARS['type']) {
11
+ case 'error':
12
+ echo 'error form-invalid';
13
+ break;
14
+ case 'update-nag':
15
+ echo 'update-nag ';
16
+ break;
17
+ case 'update':
18
+ case 'success':
19
+ default:
20
+ echo 'updated success';
21
+ break;
22
+ }
23
+ ?> fs-notice">
24
+ <?php if ('update-nag' !== $VARS['type']) : ?><p><?php endif ?>
25
+ <?php if (!empty($VARS['title'])) : ?>
26
+ <b><?php echo $VARS['title'] ?></b>
27
+ <?php endif ?>
28
+ <?php echo $VARS['message'] ?>
29
+ <?php if ('update-nag' !== $VARS['type']) : ?></p><?php endif ?>
30
+ <?php if ($VARS['sticky']) : ?><i class="dashicons dashicons-no"></i><?php endif ?>
31
+ </div>
classes/freemius/templates/checkout.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ wp_enqueue_script( 'jquery' );
10
+ wp_enqueue_script( 'json2' );
11
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
14
+
15
+ $slug = $VARS['slug'];
16
+ $fs = freemius( $slug );
17
+
18
+ $timestamp = time();
19
+
20
+ $context_params = array(
21
+ 'plugin_id' => $fs->get_id(),
22
+ 'plugin_public_key' => $fs->get_public_key(),
23
+ 'plugin_version' => $fs->get_plugin_version(),
24
+ );
25
+
26
+ // Get site context secure params.
27
+ if ( $fs->is_registered() ) {
28
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
29
+ $fs->get_site(),
30
+ $timestamp,
31
+ 'checkout'
32
+ ) );
33
+ } else {
34
+ $current_user = wp_get_current_user();
35
+
36
+ // Add site and user info to the request, this information
37
+ // is NOT being stored unless the user complete the purchase
38
+ // and agrees to the TOS.
39
+ $context_params = array_merge( $context_params, array(
40
+ 'user_firstname' => $current_user->user_firstname,
41
+ 'user_lastname' => $current_user->user_lastname,
42
+ 'user_email' => $current_user->user_email,
43
+ // 'user_nickname' => $current_user->user_nicename,
44
+ // 'plugin_slug' => $slug,
45
+ // 'site_url' => get_site_url(),
46
+ // 'site_name' => get_bloginfo( 'name' ),
47
+ // 'platform_version' => get_bloginfo( 'version' ),
48
+ // 'language' => get_bloginfo( 'language' ),
49
+ // 'charset' => get_bloginfo( 'charset' ),
50
+ // 'account_url' => fs_nonce_url( $fs->_get_admin_page_url(
51
+ // 'account',
52
+ // array( 'fs_action' => 'sync_user' )
53
+ // ), 'sync_user' ),
54
+ ) );
55
+
56
+ $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
57
+
58
+ if ( is_object( $fs_user ) ) {
59
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
60
+ $fs_user,
61
+ $timestamp,
62
+ 'checkout'
63
+ ) );
64
+ }
65
+ }
66
+
67
+ if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.)
68
+ {
69
+ $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
70
+ $fs->get_plugin(),
71
+ $timestamp,
72
+ 'checkout'
73
+ );
74
+ }
75
+
76
+ $return_url = fs_nonce_url( $fs->_get_admin_page_url(
77
+ 'account',
78
+ array(
79
+ 'fs_action' => $slug . '_sync_license',
80
+ 'plugin_id' => isset( $_GET['plugin_id'] ) ? $_GET['plugin_id'] : $fs->get_id()
81
+ )
82
+ ), $slug . '_sync_license' );
83
+
84
+ $query_params = array_merge( $context_params, $_GET, array(
85
+ // Current plugin version.
86
+ 'plugin_version' => $fs->get_plugin_version(),
87
+ 'return_url' => $return_url,
88
+ // Admin CSS URL for style/design competability.
89
+ // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
90
+ ) );
91
+ ?>
92
+ <div class="fs-secure-notice">
93
+ <i class="dashicons dashicons-lock"></i>
94
+ <span><b>Secure HTTPS Checkout</b> - PCI compliant, running via iframe from external domain</span>
95
+ </div>
96
+ <div id="fs_contact" class="wrap" style="margin: 40px 0 -65px -20px;">
97
+ <div id="iframe"></div>
98
+ <script type="text/javascript">
99
+ // http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
100
+ jQuery(function ($) {
101
+ $.extend({
102
+ form: function (url, data, method) {
103
+ if (method == null) method = 'POST';
104
+ if (data == null) data = {};
105
+
106
+ var form = $('<form>').attr({
107
+ method: method,
108
+ action: url
109
+ }).css({
110
+ display: 'none'
111
+ });
112
+
113
+ var addData = function (name, data) {
114
+ if ($.isArray(data)) {
115
+ for (var i = 0; i < data.length; i++) {
116
+ var value = data[i];
117
+ addData(name + '[]', value);
118
+ }
119
+ } else if (typeof data === 'object') {
120
+ for (var key in data) {
121
+ if (data.hasOwnProperty(key)) {
122
+ addData(name + '[' + key + ']', data[key]);
123
+ }
124
+ }
125
+ } else if (data != null) {
126
+ form.append($('<input>').attr({
127
+ type : 'hidden',
128
+ name : String(name),
129
+ value: String(data)
130
+ }));
131
+ }
132
+ };
133
+
134
+ for (var key in data) {
135
+ if (data.hasOwnProperty(key)) {
136
+ addData(key, data[key]);
137
+ }
138
+ }
139
+
140
+ return form.appendTo('body');
141
+ }
142
+ });
143
+ });
144
+
145
+ (function ($) {
146
+ $(function () {
147
+
148
+ var
149
+ // Keep track of the iframe height.
150
+ iframe_height = 800,
151
+ base_url = '<?php echo WP_FS__ADDRESS ?>',
152
+ // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
153
+ // passed via query string or hard coded into the child page, it depends on your needs).
154
+ src = base_url + '/checkout/?<?php echo (isset($_REQUEST['XDEBUG_SESSION']) ? 'XDEBUG_SESSION=' . $_REQUEST['XDEBUG_SESSION'] . '&' : '') . http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
155
+
156
+ // Append the Iframe into the DOM.
157
+ iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
158
+ .appendTo('#iframe');
159
+
160
+ FS.PostMessage.init(base_url);
161
+ FS.PostMessage.receiveOnce('height', function (data) {
162
+ var h = data.height;
163
+ if (!isNaN(h) && h > 0 && h != iframe_height) {
164
+ iframe_height = h;
165
+ $("#iframe iframe").height(iframe_height + 'px');
166
+ }
167
+ });
168
+
169
+ FS.PostMessage.receiveOnce('install', function (data) {
170
+ // Post data to activation URL.
171
+ $.form('<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array(
172
+ 'fs_action' => $slug . '_activate_new',
173
+ 'plugin_id' => isset($_GET['plugin_id']) ? $_GET['plugin_id'] : $fs->get_id()
174
+ )), $slug . '_activate_new') ?>', {
175
+ user_id : data.user.id,
176
+ user_secret_key : data.user.secret_key,
177
+ user_public_key : data.user.public_key,
178
+ install_id : data.install.id,
179
+ install_secret_key: data.install.secret_key,
180
+ install_public_key: data.install.public_key
181
+ }).submit();
182
+ });
183
+
184
+ FS.PostMessage.receiveOnce('pending_activation', function (data) {
185
+ $.form('<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array(
186
+ 'fs_action' => $slug . '_activate_new',
187
+ 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()),
188
+ 'pending_activation' => true,
189
+ )), $slug . '_activate_new') ?>', {
190
+ user_email: data.user_email
191
+ }).submit();
192
+ });
193
+
194
+ FS.PostMessage.receiveOnce('get_context', function () {
195
+ console.debug('receiveOnce', 'get_context');
196
+
197
+ // If the user didn't connect his account with Freemius,
198
+ // once he accepts the Terms of Service and Privacy Policy,
199
+ // and then click the purchase button, the context information
200
+ // of the user will be shared with Freemius in order to complete the
201
+ // purchase workflow and activate the license for the right user.
202
+ <?php $current_user = wp_get_current_user() ?>
203
+ FS.PostMessage.post('context', {
204
+ // user_firstname: '<?php //echo $current_user->user_firstname ?>//',
205
+ // user_lastname: '<?php //echo $current_user->user_lastname ?>//',
206
+ // user_email: '<?php //echo $current_user->user_email ?>//'
207
+ plugin_id : '<?php echo $fs->get_id() ?>',
208
+ plugin_public_key: '<?php echo $fs->get_public_key() ?>',
209
+ plugin_version : '<?php echo $fs->get_plugin_version() ?>',
210
+ plugin_slug : '<?php echo $slug ?>',
211
+ site_name : '<?php echo get_bloginfo('name') ?>',
212
+ platform_version : '<?php echo get_bloginfo('version') ?>',
213
+ language : '<?php echo get_bloginfo('language') ?>',
214
+ charset : '<?php echo get_bloginfo('charset') ?>',
215
+ return_url : '<?php echo $return_url ?>',
216
+ account_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url(
217
+ 'account',
218
+ array('fs_action' => 'sync_user')
219
+ ), 'sync_user') ?>',
220
+ activation_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url('',
221
+ array(
222
+ 'fs_action' => $slug . '_activate_new',
223
+ 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()),
224
+
225
+ )),
226
+ $slug . '_activate_new') ?>'
227
+ }, iframe[0]);
228
+ });
229
+
230
+ FS.PostMessage.receiveOnce('get_dimensions', function (data) {
231
+ console.debug('receiveOnce', 'get_dimensions');
232
+
233
+ FS.PostMessage.post('dimensions', {
234
+ height : $(document.body).height(),
235
+ scrollTop: $(document).scrollTop()
236
+ }, iframe[0]);
237
+ });
238
+ });
239
+ })(jQuery);
240
+ </script>
241
+ </div>
242
+ <?php fs_require_template( 'powered-by.php' ) ?>
classes/freemius/templates/connect.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.7
7
+ */
8
+
9
+ $slug = $VARS['slug'];
10
+ $fs = freemius( $slug );
11
+
12
+ $fs->_enqueue_connect_essentials();
13
+
14
+ $current_user = wp_get_current_user();
15
+
16
+ $first_name = $current_user->user_firstname;
17
+ if ( empty( $first_name ) ) {
18
+ $first_name = $current_user->nickname;
19
+ }
20
+
21
+ $site_url = get_site_url();
22
+ $protocol_pos = strpos( $site_url, '://' );
23
+ if ( false !== $protocol_pos ) {
24
+ $site_url = substr( $site_url, $protocol_pos + 3 );
25
+ }
26
+
27
+ $freemius_site_url = $fs->has_paid_plan() ?
28
+ 'https://freemius.com/wordpress/' :
29
+ // Insights platform information.
30
+ 'https://freemius.com/wordpress/insights/';
31
+ ?>
32
+ <div id="fs_connect" class="wrap<?php if ( ! $fs->enable_anonymous() ) {
33
+ echo ' fs-anonymous-disabled';
34
+ } ?>">
35
+ <div class="fs-visual">
36
+ <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b>
37
+ <i class="dashicons dashicons-plus fs-first"></i>
38
+ <?php
39
+ $vars = array( 'slug' => $slug );
40
+ fs_require_once_template( 'plugin-icon.php', $vars );
41
+ ?>
42
+ <i class="dashicons dashicons-plus fs-second"></i>
43
+ <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/>
44
+ </div>
45
+ <div class="fs-content">
46
+ <p><?php
47
+ echo $fs->apply_filters( 'connect_message',
48
+ sprintf(
49
+ __fs( 'hey-x' ) . '<br>' .
50
+ __fs( 'connect-message' ),
51
+ $first_name,
52
+ '<b>' . $fs->get_plugin_name() . '</b>',
53
+ '<b>' . $current_user->user_login . '</b>',
54
+ '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
55
+ '<a href="' . $freemius_site_url . '" target="_blank">freemius.com</a>'
56
+ ),
57
+ $first_name,
58
+ $fs->get_plugin_name(),
59
+ $current_user->user_login,
60
+ '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
61
+ '<a href="' . $freemius_site_url . '" target="_blank">freemius.com</a>'
62
+ );
63
+ ?></p>
64
+ </div>
65
+ <div class="fs-actions">
66
+ <?php if ( $fs->enable_anonymous() ) : ?>
67
+ <a href="<?php echo wp_nonce_url( $fs->_get_admin_page_url( '', array( 'fs_action' => $slug . '_skip_activation' ) ), $slug . '_skip_activation' ) ?>"
68
+ class="button button-secondary" tabindex="2"><?php _efs( 'skip' ) ?></a>
69
+ <?php endif ?>
70
+ <?php $fs_user = Freemius::_get_user_by_email( $current_user->user_email ) ?>
71
+ <?php if ( is_object( $fs_user ) ) : ?>
72
+ <form action="" method="POST">
73
+ <input type="hidden" name="fs_action" value="<?php echo $slug ?>_activate_existing">
74
+ <?php wp_nonce_field( 'activate_existing_' . $fs->get_public_key() ) ?>
75
+ <button class="button button-primary" tabindex="1"
76
+ type="submit"><?php _efs( 'opt-in-connect' ) ?></button>
77
+ </form>
78
+ <?php else : ?>
79
+ <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
80
+ <?php
81
+ $params = array(
82
+ 'user_firstname' => $current_user->user_firstname,
83
+ 'user_lastname' => $current_user->user_lastname,
84
+ 'user_nickname' => $current_user->user_nicename,
85
+ 'user_email' => $current_user->user_email,
86
+ 'user_ip' => fs_get_ip(),
87
+ 'plugin_slug' => $slug,
88
+ 'plugin_id' => $fs->get_id(),
89
+ 'plugin_public_key' => $fs->get_public_key(),
90
+ 'plugin_version' => $fs->get_plugin_version(),
91
+ 'return_url' => wp_nonce_url( $fs->_get_admin_page_url(
92
+ '',
93
+ array( 'fs_action' => $slug . '_activate_new' )
94
+ ), $slug . '_activate_new' ),
95
+ 'account_url' => wp_nonce_url( $fs->_get_admin_page_url(
96
+ 'account',
97
+ array( 'fs_action' => 'sync_user' )
98
+ ), 'sync_user' ),
99
+ 'site_uid' => $fs->get_anonymous_id(),
100
+ 'site_url' => get_site_url(),
101
+ 'site_name' => get_bloginfo( 'name' ),
102
+ 'platform_version' => get_bloginfo( 'version' ),
103
+ 'php_version' => phpversion(),
104
+ 'language' => get_bloginfo( 'language' ),
105
+ 'charset' => get_bloginfo( 'charset' ),
106
+ );
107
+
108
+ if ( WP_FS__SKIP_EMAIL_ACTIVATION && $fs->has_secret_key() ) {
109
+ // Even though rand() is known for its security issues,
110
+ // the timestamp adds another layer of protection.
111
+ // It would be very hard for an attacker to get the secret key form here.
112
+ // Plus, this should never run in production since the secret should never
113
+ // be included in the production version.
114
+ $params['ts'] = WP_FS__SCRIPT_START_TIME;
115
+ $params['salt'] = md5( uniqid( rand() ) );
116
+ $params['secure'] = md5(
117
+ $params['ts'] .
118
+ $params['salt'] .
119
+ $fs->get_secret_key()
120
+ );
121
+ }
122
+ ?>
123
+ <?php foreach ( $params as $name => $value ) : ?>
124
+ <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
125
+ <?php endforeach ?>
126
+ <button class="button button-primary" tabindex="1"
127
+ type="submit"><?php _efs( 'opt-in-connect' ) ?></button>
128
+ </form>
129
+ <?php endif ?>
130
+ </div>
131
+ <div class="fs-permissions">
132
+ <a class="fs-trigger" href="#"><?php _efs( 'what-permissions' ) ?></a>
133
+ <ul>
134
+ <li>
135
+ <i class="dashicons dashicons-admin-users"></i>
136
+
137
+ <div>
138
+ <span><?php _efs( 'permissions-profile' ) ?></span>
139
+
140
+ <p><?php _efs( 'permissions-profile_desc' ) ?></p>
141
+ </div>
142
+ </li>
143
+ <li>
144
+ <i class="dashicons dashicons-wordpress"></i>
145
+
146
+ <div>
147
+ <span><?php _efs( 'permissions-site' ) ?></span>
148
+
149
+ <p><?php _efs( 'permissions-site_desc' ) ?></p>
150
+ </div>
151
+ </li>
152
+ <li>
153
+ <i class="dashicons dashicons-admin-plugins"></i>
154
+
155
+ <div>
156
+ <span><?php _efs( 'permissions-events' ) ?></span>
157
+
158
+ <p><?php _efs( 'permissions-events_desc' ) ?></p>
159
+ </div>
160
+ </li>
161
+ </ul>
162
+ </div>
163
+ <div class="fs-terms">
164
+ <a href="https://freemius.com/privacy/" target="_blank"><?php _efs( 'privacy-policy' ) ?></a>
165
+ &nbsp;&nbsp;-&nbsp;&nbsp;
166
+ <a href="https://freemius.com/terms/" target="_blank"><?php _efs( 'tos' ) ?></a>
167
+ </div>
168
+ </div>
169
+ <script type="text/javascript">
170
+ (function ($) {
171
+ $('.button').on('click', function () {
172
+ // Set loading mode.
173
+ $(document.body).css({'cursor': 'wait'});
174
+ });
175
+ $('.button.button-primary').on('click', function () {
176
+ $(this).html('<?php _efs( 'activating' ) ?>...').css({'cursor': 'wait'});
177
+ });
178
+ $('.fs-permissions .fs-trigger').on('click', function () {
179
+ $('.fs-permissions').toggleClass('fs-open');
180
+ });
181
+ })(jQuery);
182
+ </script>
classes/freemius/templates/contact.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ wp_enqueue_script( 'jquery' );
10
+ wp_enqueue_script( 'json2' );
11
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
+ fs_enqueue_local_style( 'fs_checkout', '/admin/common.css' );
14
+
15
+ $slug = $VARS['slug'];
16
+ $fs = freemius( $slug );
17
+
18
+ $context_params = array(
19
+ 'plugin_id' => $fs->get_id(),
20
+ 'plugin_public_key' => $fs->get_public_key(),
21
+ 'plugin_version' => $fs->get_plugin_version(),
22
+ );
23
+
24
+
25
+ // Get site context secure params.
26
+ if ( $fs->is_registered() ) {
27
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
28
+ $fs->get_site(),
29
+ time(),
30
+ 'contact'
31
+ ) );
32
+ }
33
+
34
+ $query_params = array_merge( $_GET, array_merge( $context_params, array(
35
+ 'plugin_version' => $fs->get_plugin_version(),
36
+ 'wp_login_url' => wp_login_url(),
37
+ // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
38
+ ) ) );
39
+ ?>
40
+ <div class="fs-secure-notice">
41
+ <i class="dashicons dashicons-lock"></i>
42
+ <span><b>Secure HTTPS contact page</b>, running via iframe from external domain</span>
43
+ </div>
44
+ <div id="fs_contact" class="wrap" style="margin: 40px 0 -65px -20px;">
45
+ <div id="iframe"></div>
46
+ <script type="text/javascript">
47
+ (function ($) {
48
+ $(function () {
49
+
50
+ var
51
+ // Keep track of the iframe height.
52
+ iframe_height = 800,
53
+ base_url = '<?php echo WP_FS__ADDRESS ?>',
54
+ src = base_url + '/contact/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
55
+
56
+ // Append the Iframe into the DOM.
57
+ iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
58
+ .appendTo('#iframe');
59
+
60
+ FS.PostMessage.init(base_url);
61
+ FS.PostMessage.receive('height', function (data) {
62
+ var h = data.height;
63
+ if (!isNaN(h) && h > 0 && h != iframe_height) {
64
+ iframe_height = h;
65
+ $("#iframe iframe").height(iframe_height + 'px');
66
+ }
67
+ });
68
+ });
69
+ })(jQuery);
70
+ </script>
71
+ </div>
72
+ <?php fs_require_template( 'powered-by.php' ) ?>
classes/freemius/templates/deactivation-feedback-modal.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.2
7
+ */
8
+ $slug = $VARS['slug'];
9
+ $fs = freemius( $slug );
10
+
11
+ $confirmation_message = $fs->apply_filters( 'uninstall_confirmation_message', '' );
12
+
13
+ $reasons = $VARS['reasons'];
14
+
15
+ $reasons_list_items_html = '';
16
+
17
+ foreach ( $reasons as $reason ) {
18
+ $list_item_classes = 'reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' );
19
+ $reasons_list_items_html .= '<li class="' . $list_item_classes . '" data-input-type="' . $reason['input_type'] . '" data-input-placeholder="' . $reason['input_placeholder'] . '"><label><span><input type="radio" name="selected-reason" value="' . $reason['id'] . '"/></span><span>' . $reason['text'] . '</span></label></li>';
20
+ }
21
+ ?>
22
+ <script>
23
+ (function( $ ) {
24
+ var reasonsHtml = <?php echo json_encode( $reasons_list_items_html ); ?>,
25
+ modalHtml =
26
+ '<div class="fs-modal<?php echo empty( $confirmation_message ) ? ' no-confirmation-message' : ''; ?>">'
27
+ + ' <div class="fs-modal-dialog">'
28
+ + ' <div class="fs-modal-body">'
29
+ + ' <div class="fs-modal-panel" data-panel-id="confirm"><p><?php echo $confirmation_message; ?></p></div>'
30
+ + ' <div class="fs-modal-panel active" data-panel-id="reasons"><h3><strong><?php printf( __fs( 'deactivation-share-reason' ) ); ?>:</strong></h3><ul id="reasons-list">' + reasonsHtml + '</ul></div>'
31
+ + ' </div>'
32
+ + ' <div class="fs-modal-footer">'
33
+ + ' <a href="#" class="button button-secondary button-deactivate"></a>'
34
+ + ' <a href="#" class="button button-primary button-close"><?php printf( __fs( 'deactivation-modal-button-cancel' ) ); ?></a>'
35
+ + ' </div>'
36
+ + ' </div>'
37
+ + '</div>',
38
+ $modal = $( modalHtml ),
39
+ $deactivateLink = $( '#the-list .deactivate > [data-slug=<?php echo $VARS['slug']; ?>].fs-slug' ).prev();
40
+
41
+ $modal.appendTo( $( 'body' ) );
42
+
43
+ registerEventHandlers();
44
+
45
+ function registerEventHandlers() {
46
+ $deactivateLink.click(function ( evt ) {
47
+ evt.preventDefault();
48
+
49
+ showModal();
50
+ });
51
+
52
+ $modal.on( 'click', '.button', function( evt ) {
53
+ evt.preventDefault();
54
+
55
+ if ( $( this ).hasClass( 'disabled' ) ) {
56
+ return;
57
+ }
58
+
59
+ var _parent = $( this ).parents( '.fs-modal:first' );
60
+ var _this = $( this );
61
+
62
+ if ( _this.hasClass( 'allow-deactivate' ) ) {
63
+ var $radio = $( 'input[type="radio"]:checked' );
64
+
65
+ if ( 0 === $radio.length ) {
66
+ // If no selected reason, just deactivate the plugin.
67
+ window.location.href = $deactivateLink.attr( 'href' );
68
+ return;
69
+ }
70
+
71
+ var $selected_reason = $radio.parents( 'li:first' ),
72
+ $input = $selected_reason.find( 'textarea, input[type="text"]' );
73
+
74
+ $.ajax({
75
+ url: ajaxurl,
76
+ method: 'POST',
77
+ data: {
78
+ 'action' : 'submit-uninstall-reason',
79
+ 'reason_id' : $radio.val(),
80
+ 'reason_info' : ( 0 !== $input.length ) ? $input.val().trim() : ''
81
+ },
82
+ beforeSend: function() {
83
+ _parent.find( '.button' ).addClass( 'disabled' );
84
+ _parent.find( '.button-secondary' ).text( 'Processing...' );
85
+ },
86
+ complete: function() {
87
+ // Do not show the dialog box, deactivate the plugin.
88
+ window.location.href = $deactivateLink.attr( 'href' );
89
+ }
90
+ });
91
+ } else if ( _this.hasClass( 'button-deactivate' ) ) {
92
+ // Change the Deactivate button's text and show the reasons panel.
93
+ _parent.find( '.button-deactivate').addClass( 'allow-deactivate' );
94
+
95
+ showPanel( 'reasons' );
96
+ }
97
+ });
98
+
99
+ $modal.on( 'click', 'input[type="radio"]', function() {
100
+ var _parent = $( this ).parents( 'li:first' );
101
+
102
+ $modal.find( '.reason-input' ).remove();
103
+ $modal.find( '.button-deactivate').text( '<?php printf( __fs( 'deactivation-modal-button-submit' ) ); ?>' );
104
+
105
+ if ( _parent.hasClass( 'has-input' ) ) {
106
+ var inputType = _parent.data( 'input-type' ),
107
+ inputPlaceholder = _parent.data( 'input-placeholder' ),
108
+ reasonInputHtml = '<div class="reason-input">' + ( ( 'textfield' === inputType ) ? '<input type="text" />' : '<textarea rows="5"></textarea>' ) + '</div>';
109
+
110
+ _parent.append( $( reasonInputHtml ) );
111
+ _parent.find( 'input, textarea' ).attr( 'placeholder', inputPlaceholder ).focus();
112
+ }
113
+ });
114
+
115
+ // If the user has clicked outside the window, cancel it.
116
+ $modal.on( 'click', function( evt ) {
117
+ var $target = $( evt.target );
118
+
119
+ // If the user has clicked anywhere in the modal dialog, just return.
120
+ if ( $target.hasClass( 'fs-modal-body' ) || $target.hasClass( 'fs-modal-footer' ) ) {
121
+ return;
122
+ }
123
+
124
+ // If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
125
+ if ( ! $target.hasClass( 'button-close' ) && ( $target.parents( '.fs-modal-body').length > 0 || $target.parents( '.fs-modal-footer').length > 0 ) ) {
126
+ return;
127
+ }
128
+
129
+ closeModal();
130
+ });
131
+ }
132
+
133
+ function showModal() {
134
+ resetModal();
135
+
136
+ // Display the dialog box.
137
+ $modal.addClass( 'active' );
138
+
139
+ $( 'body' ).addClass( 'has-fs-modal' );
140
+ }
141
+
142
+ function closeModal() {
143
+ $modal.removeClass( 'active' );
144
+
145
+ $( 'body' ).removeClass( 'has-fs-modal' );
146
+ }
147
+
148
+ function resetModal() {
149
+ $modal.find( '.button' ).removeClass( 'disabled' );
150
+
151
+ // Uncheck all radio buttons.
152
+ $modal.find( 'input[type="radio"]' ).prop( 'checked', false );
153
+
154
+ // Remove all input fields ( textfield, textarea ).
155
+ $modal.find( '.reason-input' ).remove();
156
+
157
+ var $deactivateButton = $modal.find( '.button-deactivate' );
158
+
159
+ /*
160
+ * If the modal dialog has no confirmation message, that is, it has only one panel, then ensure
161
+ * that clicking the deactivate button will actually deactivate the plugin.
162
+ */
163
+ if ( $modal.hasClass( 'no-confirmation-message' ) ) {
164
+ $deactivateButton.addClass( 'allow-deactivate' );
165
+
166
+ showPanel( 'reasons' );
167
+ } else {
168
+ $deactivateButton.removeClass( 'allow-deactivate' );
169
+
170
+ showPanel( 'confirm' );
171
+ }
172
+ }
173
+
174
+ function showPanel( panelType ) {
175
+ $modal.find( '.fs-modal-panel' ).removeClass( 'active ');
176
+ $modal.find( '[data-panel-id="' + panelType + '"]' ).addClass( 'active' );
177
+
178
+ updateButtonLabels();
179
+ }
180
+
181
+ function updateButtonLabels() {
182
+ var $deactivateButton = $modal.find( '.button-deactivate' );
183
+
184
+ // Reset the deactivate button's text.
185
+ if ( 'confirm' === getCurrentPanel() ) {
186
+ $deactivateButton.text( '<?php printf( __fs( 'deactivation-modal-button-confirm' ) ); ?>' );
187
+ } else {
188
+ $deactivateButton.text( '<?php printf( __fs( 'deactivation-modal-button-deactivate' ) ); ?>' );
189
+ }
190
+ }
191
+
192
+ function getCurrentPanel() {
193
+ return $modal.find( '.fs-modal-panel.active' ).attr( 'data-panel-id' );
194
+ }
195
+ })( jQuery );
196
+ </script>
classes/freemius/templates/debug.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h2><?php _efs( 'plugin-installs' ) ?> / <?php _efs( 'sites' ) ?></h2>
2
+ <?php
3
+ /**
4
+ * @var FS_Site[] $sites
5
+ */
6
+ $sites = $VARS['sites'];
7
+ ?>
8
+ <table id="fs_installs" class="widefat">
9
+ <thead>
10
+ <tr>
11
+ <th><?php _efs( 'id' ) ?></th>
12
+ <th><?php _efs( 'plugin' ) ?></th>
13
+ <th><?php _efs( 'plan' ) ?></th>
14
+ <th><?php _efs( 'public-key' ) ?></th>
15
+ <th><?php _efs( 'secret-key' ) ?></th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ <?php foreach ( $sites as $plugin_basename => $site ) : ?>
20
+ <tr>
21
+ <td><?php echo $site->id ?></td>
22
+ <td><?php echo dirname( $plugin_basename ) ?></td>
23
+ <td><?php
24
+ echo is_object( $site->plan ) ? $site->plan->name : ''
25
+ ?></td>
26
+ <td><?php echo $site->public_key ?></td>
27
+ <td><?php echo $site->secret_key ?></td>
28
+ </tr>
29
+ <?php endforeach ?>
30
+ </tbody>
31
+ </table>
32
+ <?php
33
+ $addons = $VARS['addons'];
34
+ ?>
35
+ <?php foreach ( $addons as $plugin_id => $plugin_addons ) : ?>
36
+ <h2><?php printf( __fs( 'addons-of-x' ), $plugin_id ) ?></h2>
37
+ <table id="fs_addons" class="widefat">
38
+ <thead>
39
+ <tr>
40
+ <th><?php _efs( 'id' ) ?></th>
41
+ <th><?php _efs( 'title' ) ?></th>
42
+ <th><?php _efs( 'slug' ) ?></th>
43
+ <th><?php _efs( 'version' ) ?></th>
44
+ <th><?php _efs( 'public-key' ) ?></th>
45
+ <th><?php _efs( 'secret-key' ) ?></th>
46
+ </tr>
47
+ </thead>
48
+ <tbody>
49
+ <?php
50
+ /**
51
+ * @var FS_Plugin[] $plugin_addons
52
+ */
53
+ foreach ( $plugin_addons as $addon ) : ?>
54
+ <tr>
55
+ <td><?php echo $addon->id ?></td>
56
+ <td><?php echo $addon->title ?></td>
57
+ <td><?php echo $addon->slug ?></td>
58
+ <td><?php echo $addon->version ?></td>
59
+ <td><?php echo $addon->public_key ?></td>
60
+ <td><?php echo $addon->secret_key ?></td>
61
+ </tr>
62
+ <?php endforeach ?>
63
+ </tbody>
64
+ </table>
65
+ <?php endforeach ?>
66
+ <h2><?php _efs( 'users' ) ?></h2>
67
+ <?php
68
+ /**
69
+ * @var FS_User[] $users
70
+ */
71
+ $users = $VARS['users'];
72
+ ?>
73
+ <table id="fs_users" class="widefat">
74
+ <thead>
75
+ <tr>
76
+ <th><?php _efs( 'id' ) ?></th>
77
+ <th><?php _efs( 'name' ) ?></th>
78
+ <th><?php _efs( 'email' ) ?></th>
79
+ <th><?php _efs( 'verified' ) ?></th>
80
+ <th><?php _efs( 'public-key' ) ?></th>
81
+ <th><?php _efs( 'secret-key' ) ?></th>
82
+ </tr>
83
+ </thead>
84
+ <tbody>
85
+ <?php foreach ( $users as $user_id => $user ) : ?>
86
+ <tr>
87
+ <td><?php echo $user->id ?></td>
88
+ <td><?php echo $user->get_name() ?></td>
89
+ <td><?php echo $user->email ?></td>
90
+ <td><?php echo json_encode( $user->is_verified ) ?></td>
91
+ <td><?php echo $user->public_key ?></td>
92
+ <td><?php echo $user->secret_key ?></td>
93
+ </tr>
94
+ <?php endforeach ?>
95
+ </tbody>
96
+ </table>
97
+ <br><br>
98
+ <form action="" method="POST">
99
+ <input type="hidden" name="fs_action" value="delete_all_accounts">
100
+ <?php wp_nonce_field( 'delete_all_accounts' ) ?>
101
+ <button class="button button-primary"
102
+ onclick="if (confirm('<?php _efs( 'delete-all-confirm' ) ?>')) this.parentNode.submit(); return false;"><?php _efs( 'delete-all-accounts' ) ?></button>
103
+ </form>
classes/freemius/templates/email.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.1
7
+ */
8
+
9
+ $sections = $VARS['sections'];
10
+ ?>
11
+ <table>
12
+ <?php
13
+ foreach ( $sections as $section_id => $section ) {
14
+ ?>
15
+ <thead>
16
+ <tr><th colspan="2" style="text-align: left; background: #333; color: #fff; padding: 5px;"><?php echo $section['title']; ?></th></tr>
17
+ </thead>
18
+ <tbody>
19
+ <?php
20
+ foreach ( $section['rows'] as $row_id => $row ) {
21
+ $col_count = count( $row );
22
+ ?>
23
+ <tr>
24
+ <?php
25
+ if ( 1 === $col_count ) { ?>
26
+ <td style="vertical-align: top;" colspan="2"><?php echo $row[0]; ?></td>
27
+ <?php
28
+ } else { ?>
29
+ <td style="vertical-align: top;"><b><?php echo $row[0]; ?>:</b></td>
30
+ <td><?php echo $row[1]; ?></td>
31
+ <?php
32
+ }
33
+ ?>
34
+ </tr>
35
+ <?php
36
+ }
37
+ ?>
38
+ </tbody>
39
+ <?php
40
+ }
41
+ ?>
42
+ </table>
classes/freemius/templates/firewall-issues-js.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * API connectivity issues (CloudFlare's firewall) handler for handling different
4
+ * scenarios selected by the user after connectivity issue is detected, by sending
5
+ * AJAX call to the server in order to make the actual actions.
6
+ *
7
+ * @package Freemius
8
+ * @copyright Copyright (c) 2015, Freemius, Inc.
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.0.9
11
+ */
12
+ ?>
13
+ <script type="text/javascript">
14
+ jQuery(document).ready(function ($) {
15
+ $('#fs_firewall_issue_options a.fs-resolve').click(function () {
16
+ var
17
+ error_type = $(this).attr('data-type'),
18
+ notice = $(this).parents('.fs-notice'),
19
+ slug = notice.attr('data-slug');
20
+
21
+ var data = {
22
+ action : slug + '_resolve_firewall_issues',
23
+ slug : slug,
24
+ error_type: error_type
25
+ };
26
+
27
+ if ('squid' === error_type) {
28
+ data.hosting_company = prompt('What is the name or URL of your hosting company?');
29
+ if (null == data.hosting_company)
30
+ return false;
31
+
32
+ if ('' === data.hosting_company) {
33
+ alert('We won\'t be able to help without knowing your hosting company.');
34
+ return false;
35
+ }
36
+ }
37
+
38
+ $(this).css({'cursor': 'wait'});
39
+
40
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
41
+ $.post(ajaxurl, data, function (response) {
42
+ if (1 == response) {
43
+ // Refresh page on success.
44
+ location.reload();
45
+ }
46
+ });
47
+ });
48
+ });
49
+ </script>
classes/freemius/templates/pending-activation.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.9
7
+ */
8
+
9
+ wp_enqueue_script( 'jquery' );
10
+ wp_enqueue_script( 'json2' );
11
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
+
14
+ fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
15
+
16
+ $slug = $VARS['slug'];
17
+ $fs = freemius( $slug );
18
+ $current_user = wp_get_current_user();
19
+
20
+ $first_name = $current_user->user_firstname;
21
+ if ( empty( $first_name ) ) {
22
+ $first_name = $current_user->nickname;
23
+ }
24
+
25
+ $site_url = get_site_url();
26
+ $protocol_pos = strpos( $site_url, '://' );
27
+ if ( false !== $protocol_pos ) {
28
+ $site_url = substr( $site_url, $protocol_pos + 3 );
29
+ }
30
+ ?>
31
+ <div id="fs_connect" class="wrap fs-anonymous-disabled">
32
+ <div class="fs-visual">
33
+ <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b>
34
+ <i class="dashicons dashicons-plus fs-first"></i>
35
+
36
+ <div class="fs-plugin-icon">
37
+ <object data="//plugins.svn.wordpress.org/<?php echo $slug ?>/assets/icon-128x128.png" type="image/png">
38
+ <object data="//plugins.svn.wordpress.org/<?php echo $slug ?>/assets/icon-128x128.jpg" type="image/png">
39
+ <object data="//plugins.svn.wordpress.org/<?php echo $slug ?>/assets/icon-256x256.png"
40
+ type="image/png">
41
+ <object data="//plugins.svn.wordpress.org/<?php echo $slug ?>/assets/icon-256x256.jpg"
42
+ type="image/png">
43
+ <img src="//wimg.freemius.com/plugin-icon.png"/>
44
+ </object>
45
+ </object>
46
+ </object>
47
+ </object>
48
+ </div>
49
+ <i class="dashicons dashicons-plus fs-second"></i>
50
+ <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/>
51
+ </div>
52
+ <div class="fs-content">
53
+ <p><?php
54
+ echo $fs->apply_filters( 'pending_activation_message', sprintf(
55
+ __fs( 'thanks-x' ) . '<br>' .
56
+ __fs( 'pending-activation-message' ),
57
+ $first_name,
58
+ '<b>' . $fs->get_plugin_name() . '</b>',
59
+ '<b>' . $current_user->user_email . '</b>'
60
+ ) )
61
+ ?></p>
62
+ </div>
63
+ <div class="fs-actions">
64
+ <?php $fs_user = Freemius::_get_user_by_email( $current_user->user_email ) ?>
65
+ <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
66
+ <?php
67
+ $params = array(
68
+ 'user_firstname' => $current_user->user_firstname,
69
+ 'user_lastname' => $current_user->user_lastname,
70
+ 'user_nickname' => $current_user->user_nicename,
71
+ 'user_email' => $current_user->user_email,
72
+ 'plugin_slug' => $slug,
73
+ 'plugin_id' => $fs->get_id(),
74
+ 'plugin_public_key' => $fs->get_public_key(),
75
+ 'plugin_version' => $fs->get_plugin_version(),
76
+ 'return_url' => wp_nonce_url( $fs->_get_admin_page_url(
77
+ '',
78
+ array( 'fs_action' => $slug . '_activate_new' )
79
+ ), $slug . '_activate_new' ),
80
+ 'account_url' => wp_nonce_url( $fs->_get_admin_page_url(
81
+ 'account',
82
+ array( 'fs_action' => 'sync_user' )
83
+ ), 'sync_user' ),
84
+ 'site_url' => get_site_url(),
85
+ 'site_name' => get_bloginfo( 'name' ),
86
+ 'platform_version' => get_bloginfo( 'version' ),
87
+ 'language' => get_bloginfo( 'language' ),
88
+ 'charset' => get_bloginfo( 'charset' ),
89
+ );
90
+ ?>
91
+ <?php foreach ( $params as $name => $value ) : ?>
92
+ <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
93
+ <?php endforeach ?>
94
+ <button class="button button-primary" tabindex="1"
95
+ type="submit"><?php _efs( 'resend-activation-email' ) ?></button>
96
+ </form>
97
+ </div>
98
+ <div class="fs-permissions">
99
+ <a class="fs-trigger" href="#"><?php _efs( 'what-permissions' ) ?></a>
100
+ <ul>
101
+ <li>
102
+ <i class="dashicons dashicons-admin-users"></i>
103
+
104
+ <div>
105
+ <span><?php _efs( 'permissions-profile' ) ?></span>
106
+
107
+ <p><?php _efs( 'permissions-profile_desc' ) ?></p>
108
+ </div>
109
+ </li>
110
+ <li>
111
+ <i class="dashicons dashicons-wordpress"></i>
112
+
113
+ <div>
114
+ <span><?php _efs( 'permissions-site' ) ?></span>
115
+
116
+ <p><?php _efs( 'permissions-site_desc' ) ?></p>
117
+ </div>
118
+ </li>
119
+ <li>
120
+ <i class="dashicons dashicons-admin-plugins"></i>
121
+
122
+ <div>
123
+ <span><?php _efs( 'permissions-events' ) ?></span>
124
+
125
+ <p><?php _efs( 'permissions-events_desc' ) ?></p>
126
+ </div>
127
+ </li>
128
+ </ul>
129
+ </div>
130
+ <div class="fs-terms">
131
+ <a href="https://freemius.com/privacy/" target="_blank"><?php _efs( 'privacy-policy' ) ?></a>
132
+ &nbsp;&nbsp;-&nbsp;&nbsp;
133
+ <a href="https://freemius.com/terms/" target="_blank"><?php _efs( 'tos' ) ?></a>
134
+ </div>
135
+ </div>
136
+ <script type="text/javascript">
137
+ (function ($) {
138
+ $('.button.button-primary').on('click', function () {
139
+ $(document.body).css({'cursor': 'wait'});
140
+ $(this).html('Sending email...').css({'cursor': 'wait'});
141
+ });
142
+ $('.fs-permissions .fs-trigger').on('click', function () {
143
+ $('.fs-permissions').toggleClass('fs-open');
144
+ });
145
+ })(jQuery);
146
+ </script>
classes/freemius/templates/plugin-icon.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.4
7
+ */
8
+ $slug = $VARS['slug'];
9
+ $fs = freemius( $slug );
10
+
11
+ $icons = glob( fs_normalize_path( WP_FS__DIR_IMG . '/icon.*' ) );
12
+ if ( ! is_array( $icons ) || 0 === count( $icons ) ) {
13
+ $icon_found = false;
14
+ $local_path = fs_normalize_path( WP_FS__DIR_IMG . '/icon.png' );
15
+
16
+ if ( WP_FS__IS_LOCALHOST && $fs->is_org_repo_compliant() ) {
17
+ /**
18
+ * IMPORTANT: THIS CODE WILL NEVER RUN AFTER THE PLUGIN IS IN THE REPO.
19
+ *
20
+ * This code will only be executed once during the testing
21
+ * of the plugin in a local environment. The plugin icon file WILL
22
+ * already exist in the assets folder when the plugin is deployed to
23
+ * the repository.
24
+ */
25
+ $suffixes = array(
26
+ '-128x128.png',
27
+ '-128x128.jpg',
28
+ '-256x256.png',
29
+ '-256x256.jpg',
30
+ '.svg',
31
+ );
32
+
33
+ $base_url = 'https://plugins.svn.wordpress.org/' . $slug . '/assets/icon';
34
+
35
+ foreach ( $suffixes as $s ) {
36
+ $headers = get_headers( $base_url . $s );
37
+ if ( strpos( $headers[0], '200' ) ) {
38
+ $local_path = fs_normalize_path( WP_FS__DIR_IMG . '/icon.' . substr( $s, strpos( $s, '.' ) + 1 ) );
39
+ fs_download_image( $base_url . $s, $local_path );
40
+ $icon_found = true;
41
+ break;
42
+ }
43
+ }
44
+ }
45
+
46
+ if ( ! $icon_found ) {
47
+ // No icons found, fallback to default icon.
48
+ copy( fs_normalize_path( WP_FS__DIR_IMG . '/plugin-icon.png' ), $local_path );
49
+ }
50
+
51
+ $icons = array( $local_path );
52
+ }
53
+
54
+ $relative_url = fs_img_url( substr( $icons[0], strlen( fs_normalize_path( WP_FS__DIR_IMG ) ) ) );
55
+ ?>
56
+ <div class="fs-plugin-icon">
57
+ <img src="<?php echo $relative_url ?>"/>
58
+ </div>
classes/freemius/templates/plugin-info/description.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var FS_Plugin $plugin
4
+ */
5
+ $plugin = $VARS['plugin'];
6
+
7
+ if ( ! empty( $plugin->info->selling_point_0 ) ||
8
+ ! empty( $plugin->info->selling_point_1 ) ||
9
+ ! empty( $plugin->info->selling_point_2 )
10
+ ) : ?>
11
+ <div class="fs-selling-points">
12
+ <ul>
13
+ <?php for ( $i = 0; $i < 3; $i ++ ) : ?>
14
+ <?php if ( ! empty( $plugin->info->{'selling_point_' . $i} ) ) : ?>
15
+ <li><i class="dashicons dashicons-yes"></i>
16
+
17
+ <h3><?php echo $plugin->info->{'selling_point_' . $i} ?></h3></li>
18
+ <?php endif ?>
19
+ <?php endfor ?>
20
+ </ul>
21
+ </div>
22
+ <?php endif ?>
23
+ <div>
24
+ <?php
25
+ echo wp_kses( $plugin->info->description, array(
26
+ 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ),
27
+ 'b' => array(),
28
+ 'i' => array(),
29
+ 'p' => array(),
30
+ 'blockquote' => array(),
31
+ 'h2' => array(),
32
+ 'h3' => array(),
33
+ 'ul' => array(),
34
+ 'ol' => array(),
35
+ 'li' => array()
36
+ ) );
37
+ ?>
38
+ </div>
39
+ <?php if ( ! empty( $plugin->info->screenshots ) ) : ?>
40
+ <?php $screenshots = $plugin->info->screenshots ?>
41
+ <div class="fs-screenshots clearfix">
42
+ <h2><?php _efs( 'screenshots' ) ?></h2>
43
+ <ul>
44
+ <?php $i = 0;
45
+ foreach ( $screenshots as $s => $url ) : ?>
46
+ <?php
47
+ // Relative URLs are replaced with WordPress.org base URL
48
+ // therefore we need to set absolute URLs.
49
+ $url = 'http' . ( WP_FS__IS_HTTPS ? 's' : '' ) . ':' . $url; ?>
50
+ <li class="<?php echo ( 0 === $i % 2 ) ? 'odd' : 'even' ?>">
51
+ <style>
52
+ #section-description .fs-screenshots .fs-screenshot-<?php echo $i ?>
53
+ {
54
+ background-image: url('<?php echo $url ?>');
55
+ }
56
+ </style>
57
+ <a href="<?php echo $url ?>" title="<?php printf( __fs( 'view-full-size-x' ), $i ) ?>"
58
+ class="fs-screenshot-<?php echo $i ?>"></a>
59
+ </li>
60
+ <?php $i ++; endforeach ?>
61
+ </ul>
62
+ </div>
63
+ <?php endif ?>
classes/freemius/templates/plugin-info/features.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $plans = $VARS['plans'];
3
+
4
+ $features_plan_map = array();
5
+ foreach ( $plans as $plan ) {
6
+ foreach ( $plan->features as $feature ) {
7
+ if ( ! isset( $features_plan_map[ $feature->id ] ) ) {
8
+ $features_plan_map[ $feature->id ] = array( 'feature' => $feature, 'plans' => array() );
9
+ }
10
+
11
+ $features_plan_map[ $feature->id ]['plans'][ $plan->id ] = $feature;
12
+ }
13
+
14
+ // Add support as a feature.
15
+ if ( ! empty( $plan->support_email ) ||
16
+ ! empty( $plan->support_skype ) ||
17
+ ! empty( $plan->support_phone ) ||
18
+ true === $plan->is_success_manager
19
+ ) {
20
+ if ( ! isset( $features_plan_map['support'] ) ) {
21
+ $support_feature = new stdClass();
22
+ $support_feature->id = 'support';
23
+ $support_feature->title = __fs( 'Support' );
24
+ $features_plan_map[ $support_feature->id ] = array( 'feature' => $support_feature, 'plans' => array() );
25
+ } else {
26
+ $support_feature = $features_plan_map['support'];
27
+ }
28
+
29
+ $features_plan_map[ $support_feature->id ]['plans'][ $plan->id ] = $support_feature;
30
+ }
31
+ }
32
+
33
+ // Add updates as a feature for all plans.
34
+ $updates_feature = new stdClass();
35
+ $updates_feature->id = 'updates';
36
+ $updates_feature->title = __fs( 'unlimited-updates' );
37
+ $features_plan_map[ $updates_feature->id ] = array( 'feature' => $updates_feature, 'plans' => array() );
38
+ foreach ( $plans as $plan ) {
39
+ $features_plan_map[ $updates_feature->id ]['plans'][ $plan->id ] = $updates_feature;
40
+ }
41
+ ?>
42
+ <div class="fs-features">
43
+ <table>
44
+ <thead>
45
+ <tr>
46
+ <th></th>
47
+ <?php foreach ( $plans as $plan ) : ?>
48
+ <th>
49
+ <?php echo $plan->title ?>
50
+ <span class="fs-price">
51
+ <?php foreach ( $plan->pricing as $pricing ) : ?>
52
+ <?php if ( 1 == $pricing->licenses ) : ?>
53
+ $<?php echo $pricing->annual_price ?> / year
54
+ <?php endif ?>
55
+ <?php endforeach ?>
56
+ </span>
57
+ </th>
58
+ <?php endforeach ?>
59
+ </tr>
60
+ </thead>
61
+ <tbody>
62
+ <?php $odd = true;
63
+ foreach ( $features_plan_map as $feature_id => $data ) : ?>
64
+ <tr class="fs-<?php echo $odd ? 'odd' : 'even' ?>">
65
+ <td><?php echo ucfirst( $data['feature']->title ) ?></td>
66
+ <?php foreach ( $plans as $plan ) : ?>
67
+ <td>
68
+ <?php if ( isset( $data['plans'][ $plan->id ] ) ) : ?>
69
+ <?php if ( ! empty( $data['plans'][ $plan->id ]->value ) ) : ?>
70
+ <b><?php echo $data['plans'][ $plan->id ]->value ?></b>
71
+ <?php else : ?>
72
+ <i class="dashicons dashicons-yes"></i>
73
+ <?php endif ?>
74
+ <?php endif ?>
75
+ </td>
76
+ <?php endforeach ?>
77
+ </tr>
78
+ <?php $odd = ! $odd; endforeach ?>
79
+ </tbody>
80
+ </table>
81
+ </div>
classes/freemius/templates/plugin-info/screenshots.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var FS_Plugin $plugin
4
+ */
5
+ $screenshots = $VARS['screenshots'];
6
+ ?>
7
+ <ol>
8
+ <?php $i = 0;
9
+ foreach ( $screenshots as $s => $url ) : ?>
10
+ <?php
11
+ // Relative URLs are replaced with WordPress.org base URL
12
+ // therefore we need to set absolute URLs.
13
+ $url = 'http' . ( WP_FS__IS_HTTPS ? 's' : '' ) . ':' . $url; ?>
14
+ <li>
15
+ <a href="<?php echo $url ?>" title="<?php printf( __fs( 'view-full-size-x' ), $i ) ?>"><img
16
+ src="<?php echo $url ?>"></a>
17
+ </li>
18
+ <?php $i ++; endforeach ?>
19
+ </ol>
classes/freemius/templates/powered-by.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.5
7
+ */
8
+
9
+ /**
10
+ * KEEP THE POWERED BY TAB AND GET ADDITIONAL - 2% - OFF THE COMMISSION
11
+ */
12
+
13
+ wp_enqueue_script( 'jquery' );
14
+ wp_enqueue_script( 'json2' );
15
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
16
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
17
+ ?>
18
+
19
+ <div id="piframe"></div>
20
+ <script type="text/javascript">
21
+ (function ($) {
22
+ $(function () {
23
+ var
24
+ base_url = '<?php echo WP_FS__ADDRESS ?>',
25
+ piframe = $('<iframe id="fs_promo_tab" src="' + base_url + '/promotional-tab/?page=contact#' + encodeURIComponent(document.location.href) + '" height="350" width="60" frameborder="0" style=" background: transparent; position: fixed; top: 20%; right: 0;" scrolling="no"></iframe>')
26
+ .appendTo('#piframe');
27
+
28
+ FS.PostMessage.init(base_url);
29
+ FS.PostMessage.receive('state', function (state) {
30
+ if ('closed' === state)
31
+ $('#fs_promo_tab').css('width', '60px');
32
+ else
33
+ $('#fs_promo_tab').css('width', '345px');
34
+ });
35
+ });
36
+ })(jQuery);
37
+ </script>
classes/freemius/templates/pricing.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ wp_enqueue_script( 'jquery' );
10
+ wp_enqueue_script( 'json2' );
11
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
+
14
+ $slug = $VARS['slug'];
15
+ $fs = freemius( $slug );
16
+ $timestamp = time();
17
+
18
+ $context_params = array(
19
+ 'plugin_id' => $fs->get_id(),
20
+ 'plugin_public_key' => $fs->get_public_key(),
21
+ 'plugin_version' => $fs->get_plugin_version(),
22
+ );
23
+
24
+ // Get site context secure params.
25
+ if ( $fs->is_registered() ) {
26
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
27
+ $fs->get_site(),
28
+ $timestamp,
29
+ 'upgrade'
30
+ ) );
31
+ }
32
+
33
+ if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.)
34
+ {
35
+ $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
36
+ $fs->get_plugin(),
37
+ $timestamp,
38
+ 'checkout'
39
+ );
40
+ }
41
+
42
+ $query_params = array_merge( $context_params, $_GET, array(
43
+ 'next' => $fs->_get_admin_page_url( 'account', array( 'fs_action' => $slug . '_sync_license' ) ),
44
+ 'plugin_version' => $fs->get_plugin_version(),
45
+ // Billing cycle.
46
+ 'billing_cycle' => fs_request_get( 'billing_cycle', WP_FS__PERIOD_ANNUALLY ),
47
+ ) );
48
+ ?>
49
+
50
+ <div id="fs_pricing" class="wrap" style="margin: 0 0 -65px -20px;">
51
+ <div id="iframe"></div>
52
+ <form action="" method="POST">
53
+ <input type="hidden" name="user_id"/>
54
+ <input type="hidden" name="user_email"/>
55
+ <input type="hidden" name="site_id"/>
56
+ <input type="hidden" name="public_key"/>
57
+ <input type="hidden" name="secret_key"/>
58
+ <input type="hidden" name="action" value="account"/>
59
+ </form>
60
+
61
+ <script type="text/javascript">
62
+ (function ($, undef) {
63
+ $(function () {
64
+ var
65
+ // Keep track of the iframe height.
66
+ iframe_height = 800,
67
+ base_url = '<?php echo WP_FS__ADDRESS ?>',
68
+ // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
69
+ // passed via query string or hard coded into the child page, it depends on your needs).
70
+ src = base_url + '/pricing/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
71
+
72
+ // Append the Iframe into the DOM.
73
+ iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
74
+ .appendTo('#iframe');
75
+
76
+ FS.PostMessage.init(base_url);
77
+
78
+ FS.PostMessage.receive('height', function (data) {
79
+ var h = data.height;
80
+ if (!isNaN(h) && h > 0 && h != iframe_height) {
81
+ iframe_height = h;
82
+ $("#iframe iframe").height(iframe_height + 'px');
83
+ }
84
+ });
85
+
86
+ FS.PostMessage.receive('get_dimensions', function (data) {
87
+ FS.PostMessage.post('dimensions', {
88
+ height : $(document.body).height(),
89
+ scrollTop: $(document).scrollTop()
90
+ }, iframe[0]);
91
+ });
92
+ });
93
+ })(jQuery);
94
+ </script>
95
+ </div>
96
+ <?php fs_require_template( 'powered-by.php' ) ?>
classes/freemius/templates/sticky-admin-notice-js.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sticky admin notices JavaScript handler for dismissing notice messages
4
+ * by sending AJAX call to the server in order to remove the message from the Database.
5
+ *
6
+ * @package Freemius
7
+ * @copyright Copyright (c) 2015, Freemius, Inc.
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.0.7
10
+ */
11
+ ?>
12
+ <script type="text/javascript" >
13
+ jQuery(document).ready(function($) {
14
+ $('.fs-notice.fs-sticky .fs-close').click(function(){
15
+ var
16
+ notice = $(this).parents('.fs-notice'),
17
+ id = notice.attr('data-id'),
18
+ slug = notice.attr('data-slug');
19
+
20
+ notice.fadeOut('fast', function(){
21
+ var data = {
22
+ action: slug + '_dismiss_notice_action',
23
+ slug: slug,
24
+ message_id: id
25
+ };
26
+
27
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
28
+ $.post(ajaxurl, data, function(response) {
29
+
30
+ });
31
+
32
+ notice.remove();
33
+ });
34
+ });
35
+ });
36
+ </script>
hooks/class-aal-hook-posts.php CHANGED
@@ -7,7 +7,7 @@ class AAL_Hook_Posts extends AAL_Hook_Base {
7
  $title = get_the_title( $post );
8
 
9
  if ( empty( $title ) )
10
- $title = __( '(no title)', 'aryo-aal' );
11
 
12
  return $title;
13
  }
@@ -23,7 +23,7 @@ class AAL_Hook_Posts extends AAL_Hook_Base {
23
  }
24
  elseif ( 'trash' === $new_status ) {
25
  // page was deleted.
26
- $action = 'deleted';
27
  }
28
  else {
29
  // page updated. i guess.
7
  $title = get_the_title( $post );
8
 
9
  if ( empty( $title ) )
10
+ $title = __( '(no title)', 'aryo-activity-log' );
11
 
12
  return $title;
13
  }
23
  }
24
  elseif ( 'trash' === $new_status ) {
25
  // page was deleted.
26
+ $action = 'trashed';
27
  }
28
  else {
29
  // page updated. i guess.
language/aryo-aal-ru_RU.mo DELETED
Binary file
language/aryo-aal.pot DELETED
@@ -1,716 +0,0 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- #, fuzzy
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: aryo-activity-log 2.2.6\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2015-08-26 18:41+0300\n"
12
- "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
- "Language-Team: LANGUAGE <LL@li.org>\n"
15
- "Language: \n"
16
- "MIME-Version: 1.0\n"
17
- "Content-Type: text/plain; charset=CHARSET\n"
18
- "Content-Transfer-Encoding: 8bit\n"
19
-
20
- #: aryo-activity-log.php:116 aryo-activity-log.php:127
21
- msgid "Cheatin&#8217; huh?"
22
- msgstr ""
23
-
24
- #: classes/class-aal-activity-log-list-table.php:104
25
- msgid "Activities"
26
- msgstr ""
27
-
28
- #: classes/class-aal-activity-log-list-table.php:115
29
- msgid "Date"
30
- msgstr ""
31
-
32
- #: classes/class-aal-activity-log-list-table.php:116
33
- msgid "Author"
34
- msgstr ""
35
-
36
- #: classes/class-aal-activity-log-list-table.php:117
37
- msgid "IP"
38
- msgstr ""
39
-
40
- #: classes/class-aal-activity-log-list-table.php:118
41
- msgid "Type"
42
- msgstr ""
43
-
44
- #: classes/class-aal-activity-log-list-table.php:119
45
- msgid "Label"
46
- msgstr ""
47
-
48
- #: classes/class-aal-activity-log-list-table.php:120
49
- msgid "Action"
50
- msgstr ""
51
-
52
- #: classes/class-aal-activity-log-list-table.php:121
53
- msgid "Description"
54
- msgstr ""
55
-
56
- #: classes/class-aal-activity-log-list-table.php:142
57
- #, php-format
58
- msgid "%s ago"
59
- msgstr ""
60
-
61
- #: classes/class-aal-activity-log-list-table.php:171
62
- msgid "Unknown"
63
- msgstr ""
64
-
65
- #: classes/class-aal-activity-log-list-table.php:177
66
- #: classes/class-aal-activity-log-list-table.php:296
67
- msgid "Guest"
68
- msgstr ""
69
-
70
- #: classes/class-aal-activity-log-list-table.php:220
71
- msgid "All"
72
- msgstr ""
73
-
74
- #: classes/class-aal-activity-log-list-table.php:240
75
- msgid "Search"
76
- msgstr ""
77
-
78
- #: classes/class-aal-activity-log-list-table.php:283
79
- msgid "All Roles"
80
- msgstr ""
81
-
82
- #: classes/class-aal-activity-log-list-table.php:307
83
- msgid "All Users"
84
- msgstr ""
85
-
86
- #: classes/class-aal-activity-log-list-table.php:335
87
- msgid "All Types"
88
- msgstr ""
89
-
90
- #: classes/class-aal-activity-log-list-table.php:361
91
- msgid "All Actions"
92
- msgstr ""
93
-
94
- #: classes/class-aal-activity-log-list-table.php:372
95
- msgid "All Time"
96
- msgstr ""
97
-
98
- #: classes/class-aal-activity-log-list-table.php:373
99
- msgid "Today"
100
- msgstr ""
101
-
102
- #: classes/class-aal-activity-log-list-table.php:374
103
- msgid "Yesterday"
104
- msgstr ""
105
-
106
- #: classes/class-aal-activity-log-list-table.php:375
107
- msgid "Week"
108
- msgstr ""
109
-
110
- #: classes/class-aal-activity-log-list-table.php:376
111
- msgid "Month"
112
- msgstr ""
113
-
114
- #: classes/class-aal-activity-log-list-table.php:383
115
- msgid "Filter"
116
- msgstr ""
117
-
118
- #: classes/class-aal-admin-ui.php:16 classes/class-aal-admin-ui.php:26
119
- #: language/strings.php:5
120
- msgid "Activity Log"
121
- msgstr ""
122
-
123
- #: classes/class-aal-help.php:20
124
- msgid "Overview"
125
- msgstr ""
126
-
127
- #: classes/class-aal-help.php:23 classes/class-aal-settings.php:125
128
- #: classes/class-aal-settings.php:197
129
- msgid "Notifications"
130
- msgstr ""
131
-
132
- #: classes/class-aal-help.php:24
133
- msgid ""
134
- "This screen lets you control what will happen once a user on your site does "
135
- "something you define. For instance, let us assume that you have created a "
136
- "user on your site\n"
137
- " for your content editor. Now, let's say that every time "
138
- "that user updates a post, you want to know about it. You can easily do it "
139
- "from this page."
140
- msgstr ""
141
-
142
- #: classes/class-aal-notifications.php:290
143
- msgid "The AAL notification handler you are trying to register does not exist."
144
- msgstr ""
145
-
146
- #: classes/class-aal-settings.php:26
147
- msgid "GitHub"
148
- msgstr ""
149
-
150
- #: classes/class-aal-settings.php:29 classes/class-aal-settings.php:44
151
- msgid "Settings"
152
- msgstr ""
153
-
154
- #: classes/class-aal-settings.php:43 classes/class-aal-settings.php:227
155
- msgid "Activity Log Settings"
156
- msgstr ""
157
-
158
- #: classes/class-aal-settings.php:82
159
- msgid "Display Options"
160
- msgstr ""
161
-
162
- #: classes/class-aal-settings.php:89
163
- msgid "Keep logs for"
164
- msgstr ""
165
-
166
- #: classes/class-aal-settings.php:98
167
- msgid "days."
168
- msgstr ""
169
-
170
- #: classes/class-aal-settings.php:99 classes/class-aal-settings.php:139
171
- msgid ""
172
- "Maximum number of days to keep activity log. Leave blank to keep activity "
173
- "log forever (not recommended)."
174
- msgstr ""
175
-
176
- #: classes/class-aal-settings.php:106
177
- msgid "Delete Log Activities"
178
- msgstr ""
179
-
180
- #: classes/class-aal-settings.php:111
181
- #, php-format
182
- msgid "<a href=\"%s\" id=\"%s\">Reset Database</a>"
183
- msgstr ""
184
-
185
- #: classes/class-aal-settings.php:115
186
- msgid "Warning: Clicking this will delete all activities from the database."
187
- msgstr ""
188
-
189
- #: classes/class-aal-settings.php:132
190
- msgid "Notification Events"
191
- msgstr ""
192
-
193
- #: classes/class-aal-settings.php:160
194
- msgid "Enable?"
195
- msgstr ""
196
-
197
- #: classes/class-aal-settings.php:196
198
- msgid "General"
199
- msgstr ""
200
-
201
- #: classes/class-aal-settings.php:246
202
- msgid "All activities have been successfully deleted."
203
- msgstr ""
204
-
205
- #: classes/class-aal-settings.php:257
206
- msgid "Are you sure you want to do this action?"
207
- msgstr ""
208
-
209
- #: classes/class-aal-settings.php:268
210
- msgid "You do not have sufficient permissions to access this page."
211
- msgstr ""
212
-
213
- #: classes/class-aal-settings.php:321
214
- msgid "These are some basic settings for Activity Log."
215
- msgstr ""
216
-
217
- #: classes/class-aal-settings.php:327
218
- msgid ""
219
- "Serve yourself with custom-tailored notifications. First, define your "
220
- "conditions. Then, choose how the notifications will be sent."
221
- msgstr ""
222
-
223
- #: classes/class-aal-settings.php:426
224
- msgid "Yes"
225
- msgstr ""
226
-
227
- #: classes/class-aal-settings.php:427
228
- msgid "No"
229
- msgstr ""
230
-
231
- #: classes/class-aal-settings.php:444 language/strings.php:22
232
- #: notifications/abstract-class-aal-notification-base.php:98
233
- msgid "User"
234
- msgstr ""
235
-
236
- #: classes/class-aal-settings.php:445
237
- #: notifications/abstract-class-aal-notification-base.php:101
238
- msgid "Action Type"
239
- msgstr ""
240
-
241
- #: classes/class-aal-settings.php:446
242
- msgid "Action Performed"
243
- msgstr ""
244
-
245
- #: classes/class-aal-settings.php:450
246
- msgid "equals to"
247
- msgstr ""
248
-
249
- #: classes/class-aal-settings.php:451
250
- msgid "not equals to"
251
- msgstr ""
252
-
253
- #: classes/class-aal-settings.php:461
254
- msgid ""
255
- "A notification will be sent upon a successful match with the following "
256
- "conditions:"
257
- msgstr ""
258
-
259
- #: hooks/class-aal-hook-posts.php:10
260
- msgid "(no title)"
261
- msgstr ""
262
-
263
- #: language/strings.php:6
264
- msgid ""
265
- "Get aware of any activities that are taking place on your dashboard! Imagine "
266
- "it like a black-box for your WordPress site. e.g. post was deleted, plugin "
267
- "was activated, user logged in or logged out - it's all these for you to see."
268
- msgstr ""
269
-
270
- #: language/strings.php:8
271
- msgid "Administrator"
272
- msgstr ""
273
-
274
- #: language/strings.php:9
275
- msgid "Editor"
276
- msgstr ""
277
-
278
- #: language/strings.php:12
279
- msgid "Post"
280
- msgstr ""
281
-
282
- #: language/strings.php:13
283
- msgid "created"
284
- msgstr ""
285
-
286
- #: language/strings.php:14
287
- msgid "updated"
288
- msgstr ""
289
-
290
- #: language/strings.php:15
291
- msgid "deleted"
292
- msgstr ""
293
-
294
- #: language/strings.php:18
295
- msgid "Attachment"
296
- msgstr ""
297
-
298
- #: language/strings.php:19
299
- msgid "added"
300
- msgstr ""
301
-
302
- #: language/strings.php:23
303
- msgid "logged_out"
304
- msgstr ""
305
-
306
- #: language/strings.php:24
307
- msgid "logged_in"
308
- msgstr ""
309
-
310
- #: language/strings.php:25
311
- msgid "wrong_password"
312
- msgstr ""
313
-
314
- #: language/strings.php:28
315
- msgid "Plugin"
316
- msgstr ""
317
-
318
- #: language/strings.php:29
319
- msgid "activated"
320
- msgstr ""
321
-
322
- #: language/strings.php:30
323
- msgid "deactivated"
324
- msgstr ""
325
-
326
- #: language/strings.php:31
327
- msgid "installed"
328
- msgstr ""
329
-
330
- #: language/strings.php:32
331
- msgid "File Updated"
332
- msgstr ""
333
-
334
- #: language/strings.php:35
335
- msgid "Theme"
336
- msgstr ""
337
-
338
- #: language/strings.php:36
339
- msgid "Theme Customizer"
340
- msgstr ""
341
-
342
- #: language/strings.php:39
343
- msgid "Widget"
344
- msgstr ""
345
-
346
- #: language/strings.php:42
347
- msgid "Options"
348
- msgstr ""
349
-
350
- #: language/strings.php:45
351
- msgid "Menu"
352
- msgstr ""
353
-
354
- #: language/strings.php:48
355
- msgid "Taxonomy"
356
- msgstr ""
357
-
358
- #: language/strings.php:51
359
- msgid "Core"
360
- msgstr ""
361
-
362
- #: language/strings.php:52
363
- msgid "WordPress Updated"
364
- msgstr ""
365
-
366
- #: language/strings.php:53
367
- msgid "WordPress Auto Updated"
368
- msgstr ""
369
-
370
- #: language/strings.php:56
371
- msgid "Comments"
372
- msgstr ""
373
-
374
- #: language/strings.php:57
375
- msgid "pending"
376
- msgstr ""
377
-
378
- #: language/strings.php:58
379
- msgid "approved"
380
- msgstr ""
381
-
382
- #: language/strings.php:59
383
- msgid "unapproved"
384
- msgstr ""
385
-
386
- #: language/strings.php:60
387
- msgid "trashed"
388
- msgstr ""
389
-
390
- #: language/strings.php:61
391
- msgid "untrashed"
392
- msgstr ""
393
-
394
- #: language/strings.php:62
395
- msgid "spammed"
396
- msgstr ""
397
-
398
- #: language/strings.php:63
399
- msgid "unspammed"
400
- msgstr ""
401
-
402
- #: language/strings.php:68
403
- msgid "blogname"
404
- msgstr ""
405
-
406
- #: language/strings.php:69
407
- msgid "blogdescription"
408
- msgstr ""
409
-
410
- #: language/strings.php:70
411
- msgid "siteurl"
412
- msgstr ""
413
-
414
- #: language/strings.php:71
415
- msgid "home"
416
- msgstr ""
417
-
418
- #: language/strings.php:72
419
- msgid "admin_email"
420
- msgstr ""
421
-
422
- #: language/strings.php:73
423
- msgid "users_can_register"
424
- msgstr ""
425
-
426
- #: language/strings.php:74
427
- msgid "default_role"
428
- msgstr ""
429
-
430
- #: language/strings.php:75
431
- msgid "timezone_string"
432
- msgstr ""
433
-
434
- #: language/strings.php:76
435
- msgid "date_format"
436
- msgstr ""
437
-
438
- #: language/strings.php:77
439
- msgid "time_format"
440
- msgstr ""
441
-
442
- #: language/strings.php:78
443
- msgid "start_of_week"
444
- msgstr ""
445
-
446
- #: language/strings.php:81
447
- msgid "use_smilies"
448
- msgstr ""
449
-
450
- #: language/strings.php:82
451
- msgid "use_balanceTags"
452
- msgstr ""
453
-
454
- #: language/strings.php:83
455
- msgid "default_category"
456
- msgstr ""
457
-
458
- #: language/strings.php:84
459
- msgid "default_post_format"
460
- msgstr ""
461
-
462
- #: language/strings.php:85
463
- msgid "mailserver_url"
464
- msgstr ""
465
-
466
- #: language/strings.php:86
467
- msgid "mailserver_login"
468
- msgstr ""
469
-
470
- #: language/strings.php:87
471
- msgid "mailserver_pass"
472
- msgstr ""
473
-
474
- #: language/strings.php:88
475
- msgid "default_email_category"
476
- msgstr ""
477
-
478
- #: language/strings.php:89
479
- msgid "ping_sites"
480
- msgstr ""
481
-
482
- #: language/strings.php:92
483
- msgid "show_on_front"
484
- msgstr ""
485
-
486
- #: language/strings.php:93
487
- msgid "page_on_front"
488
- msgstr ""
489
-
490
- #: language/strings.php:94
491
- msgid "page_for_posts"
492
- msgstr ""
493
-
494
- #: language/strings.php:95
495
- msgid "posts_per_page"
496
- msgstr ""
497
-
498
- #: language/strings.php:96
499
- msgid "posts_per_rss"
500
- msgstr ""
501
-
502
- #: language/strings.php:97
503
- msgid "rss_use_excerpt"
504
- msgstr ""
505
-
506
- #: language/strings.php:98
507
- msgid "blog_public"
508
- msgstr ""
509
-
510
- #: language/strings.php:101
511
- msgid "default_pingback_flag"
512
- msgstr ""
513
-
514
- #: language/strings.php:102
515
- msgid "default_ping_status"
516
- msgstr ""
517
-
518
- #: language/strings.php:103
519
- msgid "default_comment_status"
520
- msgstr ""
521
-
522
- #: language/strings.php:104
523
- msgid "require_name_email"
524
- msgstr ""
525
-
526
- #: language/strings.php:105
527
- msgid "comment_registration"
528
- msgstr ""
529
-
530
- #: language/strings.php:106
531
- msgid "close_comments_for_old_posts"
532
- msgstr ""
533
-
534
- #: language/strings.php:107
535
- msgid "close_comments_days_old"
536
- msgstr ""
537
-
538
- #: language/strings.php:108
539
- msgid "thread_comments"
540
- msgstr ""
541
-
542
- #: language/strings.php:109
543
- msgid "thread_comments_depth"
544
- msgstr ""
545
-
546
- #: language/strings.php:110
547
- msgid "page_comments"
548
- msgstr ""
549
-
550
- #: language/strings.php:111
551
- msgid "comments_per_page"
552
- msgstr ""
553
-
554
- #: language/strings.php:112
555
- msgid "default_comments_page"
556
- msgstr ""
557
-
558
- #: language/strings.php:113
559
- msgid "comment_order"
560
- msgstr ""
561
-
562
- #: language/strings.php:114
563
- msgid "comments_notify"
564
- msgstr ""
565
-
566
- #: language/strings.php:115
567
- msgid "moderation_notify"
568
- msgstr ""
569
-
570
- #: language/strings.php:116
571
- msgid "comment_moderation"
572
- msgstr ""
573
-
574
- #: language/strings.php:117
575
- msgid "comment_whitelist"
576
- msgstr ""
577
-
578
- #: language/strings.php:118
579
- msgid "comment_max_links"
580
- msgstr ""
581
-
582
- #: language/strings.php:119
583
- msgid "moderation_keys"
584
- msgstr ""
585
-
586
- #: language/strings.php:120
587
- msgid "blacklist_keys"
588
- msgstr ""
589
-
590
- #: language/strings.php:121
591
- msgid "show_avatars"
592
- msgstr ""
593
-
594
- #: language/strings.php:122
595
- msgid "avatar_rating"
596
- msgstr ""
597
-
598
- #: language/strings.php:123
599
- msgid "avatar_default"
600
- msgstr ""
601
-
602
- #: language/strings.php:126
603
- msgid "thumbnail_size_w"
604
- msgstr ""
605
-
606
- #: language/strings.php:127
607
- msgid "thumbnail_size_h"
608
- msgstr ""
609
-
610
- #: language/strings.php:128
611
- msgid "thumbnail_crop"
612
- msgstr ""
613
-
614
- #: language/strings.php:129
615
- msgid "medium_size_w"
616
- msgstr ""
617
-
618
- #: language/strings.php:130
619
- msgid "medium_size_h"
620
- msgstr ""
621
-
622
- #: language/strings.php:131
623
- msgid "large_size_w"
624
- msgstr ""
625
-
626
- #: language/strings.php:132
627
- msgid "large_size_h"
628
- msgstr ""
629
-
630
- #: language/strings.php:133
631
- msgid "uploads_use_yearmonth_folders"
632
- msgstr ""
633
-
634
- #: language/strings.php:136
635
- msgid "permalink_structure"
636
- msgstr ""
637
-
638
- #: language/strings.php:137
639
- msgid "category_base"
640
- msgstr ""
641
-
642
- #: language/strings.php:138
643
- msgid "tag_base"
644
- msgstr ""
645
-
646
- #: language/strings.php:141
647
- msgid "Export"
648
- msgstr ""
649
-
650
- #: language/strings.php:142
651
- msgid "downloaded"
652
- msgstr ""
653
-
654
- #: notifications/abstract-class-aal-notification-base.php:99
655
- msgid "Object Type"
656
- msgstr ""
657
-
658
- #: notifications/abstract-class-aal-notification-base.php:100
659
- msgid "Object Name"
660
- msgstr ""
661
-
662
- #: notifications/abstract-class-aal-notification-base.php:102
663
- msgid "IP Address"
664
- msgstr ""
665
-
666
- #: notifications/abstract-class-aal-notification-base.php:121
667
- msgid "N/A"
668
- msgstr ""
669
-
670
- #: notifications/class-aal-notification-email.php:15
671
- msgid "Email"
672
- msgstr ""
673
-
674
- #: notifications/class-aal-notification-email.php:16
675
- msgid "Get notified by Email."
676
- msgstr ""
677
-
678
- #: notifications/class-aal-notification-email.php:49
679
- msgid "New notification from Activity Log"
680
- msgstr ""
681
-
682
- #: notifications/class-aal-notification-email.php:65
683
- msgid ""
684
- "Hi there!\n"
685
- "\n"
686
- "A notification condition on [sitename] was matched. Here are the details:\n"
687
- "\n"
688
- "[action-details]\n"
689
- "\n"
690
- "Sent by ARYO Activity Log"
691
- msgstr ""
692
-
693
- #: notifications/class-aal-notification-email.php:67
694
- msgid "From Email"
695
- msgstr ""
696
-
697
- #: notifications/class-aal-notification-email.php:67
698
- msgid "The source Email address"
699
- msgstr ""
700
-
701
- #: notifications/class-aal-notification-email.php:68
702
- msgid "To Email"
703
- msgstr ""
704
-
705
- #: notifications/class-aal-notification-email.php:68
706
- msgid "The Email address notifications will be sent to"
707
- msgstr ""
708
-
709
- #: notifications/class-aal-notification-email.php:69
710
- msgid "Message"
711
- msgstr ""
712
-
713
- #: notifications/class-aal-notification-email.php:69
714
- #, php-format
715
- msgid "Customize the message using the following placeholders: %s"
716
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
language/{aryo-aal-cs_CZ.mo → aryo-activity-log-cs_CZ.mo} RENAMED
File without changes
language/{aryo-aal-cs_CZ.po → aryo-activity-log-cs_CZ.po} RENAMED
File without changes
language/{aryo-aal-da_DK.mo → aryo-activity-log-da_DK.mo} RENAMED
File without changes
language/{aryo-aal-da_DK.po → aryo-activity-log-da_DK.po} RENAMED
File without changes
language/{aryo-aal-de_DE.mo → aryo-activity-log-de_DE.mo} RENAMED
File without changes
language/{aryo-aal-de_DE.po → aryo-activity-log-de_DE.po} RENAMED
File without changes
language/{aryo-aal-fi.mo → aryo-activity-log-fi.mo} RENAMED
File without changes
language/{aryo-aal-fi.po → aryo-activity-log-fi.po} RENAMED
File without changes
language/{aryo-aal-he_IL.mo → aryo-activity-log-he_IL.mo} RENAMED
File without changes
language/{aryo-aal-he_IL.po → aryo-activity-log-he_IL.po} RENAMED
File without changes
language/{aryo-aal-hy_AM.mo → aryo-activity-log-hy_AM.mo} RENAMED
File without changes
language/{aryo-aal-hy_AM.po → aryo-activity-log-hy_AM.po} RENAMED
File without changes
language/{aryo-aal-nl_NL.mo → aryo-activity-log-nl_NL.mo} RENAMED
File without changes
language/{aryo-aal-nl_NL.po → aryo-activity-log-nl_NL.po} RENAMED
File without changes
language/{aryo-aal-pl_PL.mo → aryo-activity-log-pl_PL.mo} RENAMED
File without changes
language/{aryo-aal-pl_PL.po → aryo-activity-log-pl_PL.po} RENAMED
File without changes
language/{aryo-aal-pt_BR.mo → aryo-activity-log-pt_BR.mo} RENAMED
File without changes
language/{aryo-aal-pt_BR.po → aryo-activity-log-pt_BR.po} RENAMED
File without changes
language/aryo-activity-log-ru_RU.mo ADDED
Binary file
language/{aryo-aal-ru_RU.po → aryo-activity-log-ru_RU.po} RENAMED
@@ -5,111 +5,120 @@
5
  #
6
  msgid ""
7
  msgstr ""
8
- "Project-Id-Version: aryo-activity-log 2.1.15\n"
9
  "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2015-03-10 14:37+0200\n"
11
- "PO-Revision-Date: 2015-04-23 10:19+0900\n"
 
 
12
  "Language: ru\n"
13
  "MIME-Version: 1.0\n"
14
  "Content-Type: text/plain; charset=UTF-8\n"
15
  "Content-Transfer-Encoding: 8bit\n"
16
  "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
17
  "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
18
- "Last-Translator: \n"
19
- "Language-Team: \n"
20
  "X-Generator: Poedit 1.7.4\n"
21
 
22
- #: aryo-activity-log.php:110 aryo-activity-log.php:121
23
  msgid "Cheatin&#8217; huh?"
24
  msgstr ""
25
 
26
- #: classes/class-aal-activity-log-list-table.php:100
27
  msgid "Activities"
28
  msgstr "Активность"
29
 
30
- #: classes/class-aal-activity-log-list-table.php:111
31
  msgid "Date"
32
  msgstr "Дата"
33
 
34
- #: classes/class-aal-activity-log-list-table.php:112
35
  msgid "Author"
36
  msgstr "Пользователь"
37
 
38
- #: classes/class-aal-activity-log-list-table.php:113
39
  msgid "IP"
40
  msgstr "IP"
41
 
42
- #: classes/class-aal-activity-log-list-table.php:114
43
  msgid "Type"
44
  msgstr "Тип"
45
 
46
- #: classes/class-aal-activity-log-list-table.php:115
47
  msgid "Label"
48
  msgstr "Вид"
49
 
50
- #: classes/class-aal-activity-log-list-table.php:116
51
  msgid "Action"
52
  msgstr "Действие"
53
 
54
- #: classes/class-aal-activity-log-list-table.php:117
55
  msgid "Description"
56
  msgstr "Описание"
57
 
58
- #: classes/class-aal-activity-log-list-table.php:137
59
  #, php-format
60
  msgid "%s ago"
61
  msgstr "%s назад"
62
 
63
- #: classes/class-aal-activity-log-list-table.php:164
64
  msgid "Unknown"
65
  msgstr "неизвестно"
66
 
67
- #: classes/class-aal-activity-log-list-table.php:170
68
- #: classes/class-aal-activity-log-list-table.php:281
69
  msgid "Guest"
70
  msgstr "Гость"
71
 
72
- #: classes/class-aal-activity-log-list-table.php:209
73
  msgid "All"
74
  msgstr "Все"
75
 
76
- #: classes/class-aal-activity-log-list-table.php:268
 
 
 
 
77
  msgid "All Roles"
78
  msgstr "Все роли"
79
 
80
- #: classes/class-aal-activity-log-list-table.php:292
81
  msgid "All Users"
82
  msgstr "Все пользователи"
83
 
84
- #: classes/class-aal-activity-log-list-table.php:319
85
  msgid "All Types"
86
  msgstr "Все типы"
87
 
88
- #: classes/class-aal-activity-log-list-table.php:330
 
 
 
 
89
  msgid "All Time"
90
  msgstr "за всё время"
91
 
92
- #: classes/class-aal-activity-log-list-table.php:331
93
  msgid "Today"
94
  msgstr "сегодня"
95
 
96
- #: classes/class-aal-activity-log-list-table.php:332
97
  msgid "Yesterday"
98
  msgstr "вчера"
99
 
100
- #: classes/class-aal-activity-log-list-table.php:333
101
  msgid "Week"
102
  msgstr "за неделю"
103
 
104
- #: classes/class-aal-activity-log-list-table.php:334
105
  msgid "Month"
106
  msgstr "за месяц"
107
 
108
- #: classes/class-aal-activity-log-list-table.php:341
109
  msgid "Filter"
110
  msgstr "Отфильтровать"
111
 
112
  #: classes/class-aal-admin-ui.php:16 classes/class-aal-admin-ui.php:26
 
113
  msgid "Activity Log"
114
  msgstr "Активность"
115
 
@@ -131,10 +140,15 @@ msgid ""
131
  "that user updates a post, you want to know about it. You can easily do it "
132
  "from this page."
133
  msgstr ""
 
 
 
 
 
134
 
135
- #: classes/class-aal-notifications.php:273
136
  msgid "The AAL notification handler you are trying to register does not exist."
137
- msgstr ""
138
 
139
  #: classes/class-aal-settings.php:26
140
  msgid "GitHub"
@@ -253,14 +267,10 @@ msgid ""
253
  "conditions:"
254
  msgstr "Уведомление будет отправлено, если сработают следующие условия:"
255
 
256
- #: hooks/class-aal-hook-posts.php:9
257
  msgid "(no title)"
258
  msgstr "(без заголовка)"
259
 
260
- #: language/strings.php:5
261
- msgid "ARYO Activity Log"
262
- msgstr "ARYO Activity Log"
263
-
264
  #: language/strings.php:6
265
  msgid ""
266
  "Get aware of any activities that are taking place on your dashboard! Imagine "
@@ -274,11 +284,11 @@ msgstr ""
274
 
275
  #: language/strings.php:8
276
  msgid "Administrator"
277
- msgstr "администратор"
278
 
279
  #: language/strings.php:9
280
  msgid "Editor"
281
- msgstr "редактор"
282
 
283
  #: language/strings.php:12
284
  msgid "Post"
@@ -290,7 +300,7 @@ msgstr "создана"
290
 
291
  #: language/strings.php:14
292
  msgid "updated"
293
- msgstr "обновлена"
294
 
295
  #: language/strings.php:15
296
  msgid "deleted"
@@ -332,333 +342,337 @@ msgstr "деактивирован"
332
  msgid "installed"
333
  msgstr "установлен"
334
 
335
- #: language/strings.php:34
336
- msgid "Theme"
337
- msgstr "Тема"
338
 
339
  #: language/strings.php:35
 
 
 
 
340
  msgid "Theme Customizer"
341
- msgstr "Настройки темы"
342
 
343
- #: language/strings.php:38
344
  msgid "Widget"
345
- msgstr "Виджет"
346
 
347
- #: language/strings.php:41
348
  msgid "Options"
349
  msgstr "настройка"
350
 
351
- #: language/strings.php:44
352
  msgid "Menu"
353
- msgstr "Меню"
354
 
355
- #: language/strings.php:47
356
  msgid "Taxonomy"
357
- msgstr "Рубрики"
358
 
359
- #: language/strings.php:50
360
  msgid "Core"
361
- msgstr "Ядро"
362
 
363
- #: language/strings.php:51
364
  msgid "WordPress Updated"
365
  msgstr "WordPress обновился"
366
 
367
- #: language/strings.php:52
368
  msgid "WordPress Auto Updated"
369
  msgstr "Wordpress обновился автоматически"
370
 
371
- #: language/strings.php:55
372
  msgid "Comments"
373
  msgstr "комментарии"
374
 
375
- #: language/strings.php:56
376
  msgid "pending"
377
  msgstr "на модерацию"
378
 
379
- #: language/strings.php:57
380
  msgid "approved"
381
  msgstr "принятые"
382
 
383
- #: language/strings.php:58
384
  msgid "unapproved"
385
  msgstr "отклонённые"
386
 
387
- #: language/strings.php:59
388
  msgid "trashed"
389
  msgstr "удалённые"
390
 
391
- #: language/strings.php:60
392
  msgid "untrashed"
393
  msgstr "восстановленные"
394
 
395
- #: language/strings.php:61
396
  msgid "spammed"
397
  msgstr "помечены как спам"
398
 
399
- #: language/strings.php:62
400
  msgid "unspammed"
401
  msgstr "не спам"
402
 
403
- #: language/strings.php:67
404
  msgid "blogname"
405
  msgstr "название блога"
406
 
407
- #: language/strings.php:68
408
  msgid "blogdescription"
409
  msgstr "описание блога"
410
 
411
- #: language/strings.php:69
412
  msgid "siteurl"
413
  msgstr "адрес блога"
414
 
415
- #: language/strings.php:70
416
  msgid "home"
417
  msgstr "начальная страница"
418
 
419
- #: language/strings.php:71
420
  msgid "admin_email"
421
  msgstr "адрес e-mail"
422
 
423
- #: language/strings.php:72
424
  msgid "users_can_register"
425
  msgstr "регистрация открыта"
426
 
427
- #: language/strings.php:73
428
  msgid "default_role"
429
  msgstr "роль нового пользователя"
430
 
431
- #: language/strings.php:74
432
  msgid "timezone_string"
433
  msgstr "часовой пояс"
434
 
435
- #: language/strings.php:75
436
  msgid "date_format"
437
  msgstr "формат даты"
438
 
439
- #: language/strings.php:76
440
  msgid "time_format"
441
  msgstr "формат времени"
442
 
443
- #: language/strings.php:77
444
  msgid "start_of_week"
445
  msgstr "первый день недели"
446
 
447
- #: language/strings.php:80
448
  msgid "use_smilies"
449
  msgstr "использовать смайлы"
450
 
451
- #: language/strings.php:81
452
  msgid "use_balanceTags"
453
- msgstr ""
454
 
455
- #: language/strings.php:82
456
  msgid "default_category"
457
  msgstr "основная рубрика"
458
 
459
- #: language/strings.php:83
460
  msgid "default_post_format"
461
  msgstr "основной формат записей"
462
 
463
- #: language/strings.php:84
464
  msgid "mailserver_url"
465
- msgstr ""
466
 
467
- #: language/strings.php:85
468
  msgid "mailserver_login"
469
- msgstr ""
470
 
471
- #: language/strings.php:86
472
  msgid "mailserver_pass"
473
- msgstr ""
474
 
475
- #: language/strings.php:87
476
  msgid "default_email_category"
477
- msgstr ""
478
 
479
- #: language/strings.php:88
480
  msgid "ping_sites"
481
- msgstr ""
482
 
483
- #: language/strings.php:91
484
  msgid "show_on_front"
485
  msgstr "отображать на главной"
486
 
487
- #: language/strings.php:92
488
  msgid "page_on_front"
489
  msgstr "статическая страница"
490
 
491
- #: language/strings.php:93
492
  msgid "page_for_posts"
493
  msgstr "основная страница блога"
494
 
495
- #: language/strings.php:94
496
  msgid "posts_per_page"
497
  msgstr "записей на страницу"
498
 
499
- #: language/strings.php:95
500
  msgid "posts_per_rss"
501
  msgstr "записей в rss-ленте"
502
 
503
- #: language/strings.php:96
504
  msgid "rss_use_excerpt"
505
  msgstr "отображать текст/анонс в rss"
506
 
507
- #: language/strings.php:97
508
  msgid "blog_public"
509
  msgstr "видимость для поисковых систем"
510
 
511
- #: language/strings.php:100
512
  msgid "default_pingback_flag"
513
  msgstr "оповещение упомянутых блогов"
514
 
515
- #: language/strings.php:101
516
  msgid "default_ping_status"
517
  msgstr "оповещения с других блогов"
518
 
519
- #: language/strings.php:102
520
  msgid "default_comment_status"
521
  msgstr "разрешить оставлять комментарии"
522
 
523
- #: language/strings.php:103
524
  msgid "require_name_email"
525
  msgstr "автор комментария должен указать имя и e-mail"
526
 
527
- #: language/strings.php:104
528
  msgid "comment_registration"
529
  msgstr "авторизация для комментирования"
530
 
531
- #: language/strings.php:105
532
  msgid "close_comments_for_old_posts"
533
  msgstr "автоматически закрывать обсуждение"
534
 
535
- #: language/strings.php:106
536
  msgid "close_comments_days_old"
537
  msgstr "срок обсуждения"
538
 
539
- #: language/strings.php:107
540
  msgid "thread_comments"
541
  msgstr "древовидные комментарии"
542
 
543
- #: language/strings.php:108
544
  msgid "thread_comments_depth"
545
  msgstr "вложенность комментариев"
546
 
547
- #: language/strings.php:109
548
  msgid "page_comments"
549
  msgstr "комментарии постранично"
550
 
551
- #: language/strings.php:110
552
  msgid "comments_per_page"
553
  msgstr "комментариев на страницу"
554
 
555
- #: language/strings.php:111
556
  msgid "default_comments_page"
557
  msgstr "первая/последняя страница комментариев"
558
 
559
- #: language/strings.php:112
560
  msgid "comment_order"
561
  msgstr "сортировка комментариев"
562
 
563
- #: language/strings.php:113
564
  msgid "comments_notify"
565
  msgstr "письмо об оставленном комментарии"
566
 
567
- #: language/strings.php:114
568
  msgid "moderation_notify"
569
  msgstr "письмо о комментарии на модерацию"
570
 
571
- #: language/strings.php:115
572
  msgid "comment_moderation"
573
  msgstr "модерация комментариев"
574
 
575
- #: language/strings.php:116
576
  msgid "comment_whitelist"
577
- msgstr ""
578
 
579
- #: language/strings.php:117
580
  msgid "comment_max_links"
581
  msgstr "количество ссылок в комментарии"
582
 
583
- #: language/strings.php:118
584
  msgid "moderation_keys"
585
  msgstr "ключевые слова на модерацию"
586
 
587
- #: language/strings.php:119
588
  msgid "blacklist_keys"
589
  msgstr "чёрный список"
590
 
591
- #: language/strings.php:120
592
  msgid "show_avatars"
593
  msgstr "показывать аватары"
594
 
595
- #: language/strings.php:121
596
  msgid "avatar_rating"
597
  msgstr "рейтинг аватаров"
598
 
599
- #: language/strings.php:122
600
  msgid "avatar_default"
601
  msgstr "аватар по умолчанию"
602
 
603
- #: language/strings.php:125
604
  msgid "thumbnail_size_w"
605
  msgstr "ширина миниатюры"
606
 
607
- #: language/strings.php:126
608
  msgid "thumbnail_size_h"
609
  msgstr "высота миниатюры"
610
 
611
- #: language/strings.php:127
612
  msgid "thumbnail_crop"
613
  msgstr "обрезать по размерам"
614
 
615
- #: language/strings.php:128
616
  msgid "medium_size_w"
617
  msgstr "ширина среднего размера"
618
 
619
- #: language/strings.php:129
620
  msgid "medium_size_h"
621
  msgstr "высота среднего размера"
622
 
623
- #: language/strings.php:130
624
  msgid "large_size_w"
625
  msgstr "ширина крупного размера"
626
 
627
- #: language/strings.php:131
628
  msgid "large_size_h"
629
  msgstr "высота крупного размера"
630
 
631
- #: language/strings.php:132
632
  msgid "uploads_use_yearmonth_folders"
633
  msgstr "использовать структуру папок «год – месяц» для загрузок"
634
 
635
- #: language/strings.php:135
636
  msgid "permalink_structure"
637
  msgstr "структура постоянных ссылок"
638
 
639
- #: language/strings.php:136
640
  msgid "category_base"
641
  msgstr "префикс для рубрик"
642
 
643
- #: language/strings.php:137
644
  msgid "tag_base"
645
  msgstr "префикс для меток"
646
 
647
- #: language/strings.php:140
648
  msgid "Export"
649
  msgstr "Экспорт"
650
 
651
- #: language/strings.php:141
652
  msgid "downloaded"
653
  msgstr "скачано"
654
 
655
  #: notifications/abstract-class-aal-notification-base.php:99
656
  msgid "Object Type"
657
- msgstr ""
658
 
659
  #: notifications/abstract-class-aal-notification-base.php:100
660
  msgid "Object Name"
661
- msgstr ""
662
 
663
  #: notifications/abstract-class-aal-notification-base.php:102
664
  msgid "IP Address"
@@ -666,7 +680,7 @@ msgstr "IP"
666
 
667
  #: notifications/abstract-class-aal-notification-base.php:121
668
  msgid "N/A"
669
- msgstr ""
670
 
671
  #: notifications/class-aal-notification-email.php:15
672
  msgid "Email"
@@ -722,3 +736,6 @@ msgstr "Текст"
722
  #, php-format
723
  msgid "Customize the message using the following placeholders: %s"
724
  msgstr "Составьте текст уведомления с использованием маркеров %s"
 
 
 
5
  #
6
  msgid ""
7
  msgstr ""
8
+ "Project-Id-Version: aryo-activity-log 2.2.6\n"
9
  "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2015-08-26 18:41+0300\n"
11
+ "PO-Revision-Date: 2015-09-01 09:49+1000\n"
12
+ "Last-Translator: \n"
13
+ "Language-Team: Олег Резников\n"
14
  "Language: ru\n"
15
  "MIME-Version: 1.0\n"
16
  "Content-Type: text/plain; charset=UTF-8\n"
17
  "Content-Transfer-Encoding: 8bit\n"
18
  "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
19
  "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
 
 
20
  "X-Generator: Poedit 1.7.4\n"
21
 
22
+ #: aryo-activity-log.php:116 aryo-activity-log.php:127
23
  msgid "Cheatin&#8217; huh?"
24
  msgstr ""
25
 
26
+ #: classes/class-aal-activity-log-list-table.php:104
27
  msgid "Activities"
28
  msgstr "Активность"
29
 
30
+ #: classes/class-aal-activity-log-list-table.php:115
31
  msgid "Date"
32
  msgstr "Дата"
33
 
34
+ #: classes/class-aal-activity-log-list-table.php:116
35
  msgid "Author"
36
  msgstr "Пользователь"
37
 
38
+ #: classes/class-aal-activity-log-list-table.php:117
39
  msgid "IP"
40
  msgstr "IP"
41
 
42
+ #: classes/class-aal-activity-log-list-table.php:118
43
  msgid "Type"
44
  msgstr "Тип"
45
 
46
+ #: classes/class-aal-activity-log-list-table.php:119
47
  msgid "Label"
48
  msgstr "Вид"
49
 
50
+ #: classes/class-aal-activity-log-list-table.php:120
51
  msgid "Action"
52
  msgstr "Действие"
53
 
54
+ #: classes/class-aal-activity-log-list-table.php:121
55
  msgid "Description"
56
  msgstr "Описание"
57
 
58
+ #: classes/class-aal-activity-log-list-table.php:142
59
  #, php-format
60
  msgid "%s ago"
61
  msgstr "%s назад"
62
 
63
+ #: classes/class-aal-activity-log-list-table.php:171
64
  msgid "Unknown"
65
  msgstr "неизвестно"
66
 
67
+ #: classes/class-aal-activity-log-list-table.php:177
68
+ #: classes/class-aal-activity-log-list-table.php:296
69
  msgid "Guest"
70
  msgstr "Гость"
71
 
72
+ #: classes/class-aal-activity-log-list-table.php:220
73
  msgid "All"
74
  msgstr "Все"
75
 
76
+ #: classes/class-aal-activity-log-list-table.php:240
77
+ msgid "Search"
78
+ msgstr "Найти"
79
+
80
+ #: classes/class-aal-activity-log-list-table.php:283
81
  msgid "All Roles"
82
  msgstr "Все роли"
83
 
84
+ #: classes/class-aal-activity-log-list-table.php:307
85
  msgid "All Users"
86
  msgstr "Все пользователи"
87
 
88
+ #: classes/class-aal-activity-log-list-table.php:335
89
  msgid "All Types"
90
  msgstr "Все типы"
91
 
92
+ #: classes/class-aal-activity-log-list-table.php:361
93
+ msgid "All Actions"
94
+ msgstr "Все действия"
95
+
96
+ #: classes/class-aal-activity-log-list-table.php:372
97
  msgid "All Time"
98
  msgstr "за всё время"
99
 
100
+ #: classes/class-aal-activity-log-list-table.php:373
101
  msgid "Today"
102
  msgstr "сегодня"
103
 
104
+ #: classes/class-aal-activity-log-list-table.php:374
105
  msgid "Yesterday"
106
  msgstr "вчера"
107
 
108
+ #: classes/class-aal-activity-log-list-table.php:375
109
  msgid "Week"
110
  msgstr "за неделю"
111
 
112
+ #: classes/class-aal-activity-log-list-table.php:376
113
  msgid "Month"
114
  msgstr "за месяц"
115
 
116
+ #: classes/class-aal-activity-log-list-table.php:383
117
  msgid "Filter"
118
  msgstr "Отфильтровать"
119
 
120
  #: classes/class-aal-admin-ui.php:16 classes/class-aal-admin-ui.php:26
121
+ #: language/strings.php:5
122
  msgid "Activity Log"
123
  msgstr "Активность"
124
 
140
  "that user updates a post, you want to know about it. You can easily do it "
141
  "from this page."
142
  msgstr ""
143
+ "На этой странице можно указывать, что произойдёт, когда пользователь "
144
+ "совершит заданное действие. Допустим, вы создали пользователя,\n"
145
+ " который может редактировать записи. Теперь, когда этот "
146
+ "пользователь обновляет запись, вы хотите об этом узнавать. Вы легко можете "
147
+ "это делать на этой странице."
148
 
149
+ #: classes/class-aal-notifications.php:290
150
  msgid "The AAL notification handler you are trying to register does not exist."
151
+ msgstr "Указанный обработчик уведомлений AAL не существует."
152
 
153
  #: classes/class-aal-settings.php:26
154
  msgid "GitHub"
267
  "conditions:"
268
  msgstr "Уведомление будет отправлено, если сработают следующие условия:"
269
 
270
+ #: hooks/class-aal-hook-posts.php:10
271
  msgid "(no title)"
272
  msgstr "(без заголовка)"
273
 
 
 
 
 
274
  #: language/strings.php:6
275
  msgid ""
276
  "Get aware of any activities that are taking place on your dashboard! Imagine "
284
 
285
  #: language/strings.php:8
286
  msgid "Administrator"
287
+ msgstr "Администратор"
288
 
289
  #: language/strings.php:9
290
  msgid "Editor"
291
+ msgstr "Редактор"
292
 
293
  #: language/strings.php:12
294
  msgid "Post"
300
 
301
  #: language/strings.php:14
302
  msgid "updated"
303
+ msgstr "обновление"
304
 
305
  #: language/strings.php:15
306
  msgid "deleted"
342
  msgid "installed"
343
  msgstr "установлен"
344
 
345
+ #: language/strings.php:32
346
+ msgid "File Updated"
347
+ msgstr "обновлён файл"
348
 
349
  #: language/strings.php:35
350
+ msgid "Theme"
351
+ msgstr "тема"
352
+
353
+ #: language/strings.php:36
354
  msgid "Theme Customizer"
355
+ msgstr "настройки темы"
356
 
357
+ #: language/strings.php:39
358
  msgid "Widget"
359
+ msgstr "виджет"
360
 
361
+ #: language/strings.php:42
362
  msgid "Options"
363
  msgstr "настройка"
364
 
365
+ #: language/strings.php:45
366
  msgid "Menu"
367
+ msgstr "меню"
368
 
369
+ #: language/strings.php:48
370
  msgid "Taxonomy"
371
+ msgstr "рубрики"
372
 
373
+ #: language/strings.php:51
374
  msgid "Core"
375
+ msgstr "ядро"
376
 
377
+ #: language/strings.php:52
378
  msgid "WordPress Updated"
379
  msgstr "WordPress обновился"
380
 
381
+ #: language/strings.php:53
382
  msgid "WordPress Auto Updated"
383
  msgstr "Wordpress обновился автоматически"
384
 
385
+ #: language/strings.php:56
386
  msgid "Comments"
387
  msgstr "комментарии"
388
 
389
+ #: language/strings.php:57
390
  msgid "pending"
391
  msgstr "на модерацию"
392
 
393
+ #: language/strings.php:58
394
  msgid "approved"
395
  msgstr "принятые"
396
 
397
+ #: language/strings.php:59
398
  msgid "unapproved"
399
  msgstr "отклонённые"
400
 
401
+ #: language/strings.php:60
402
  msgid "trashed"
403
  msgstr "удалённые"
404
 
405
+ #: language/strings.php:61
406
  msgid "untrashed"
407
  msgstr "восстановленные"
408
 
409
+ #: language/strings.php:62
410
  msgid "spammed"
411
  msgstr "помечены как спам"
412
 
413
+ #: language/strings.php:63
414
  msgid "unspammed"
415
  msgstr "не спам"
416
 
417
+ #: language/strings.php:68
418
  msgid "blogname"
419
  msgstr "название блога"
420
 
421
+ #: language/strings.php:69
422
  msgid "blogdescription"
423
  msgstr "описание блога"
424
 
425
+ #: language/strings.php:70
426
  msgid "siteurl"
427
  msgstr "адрес блога"
428
 
429
+ #: language/strings.php:71
430
  msgid "home"
431
  msgstr "начальная страница"
432
 
433
+ #: language/strings.php:72
434
  msgid "admin_email"
435
  msgstr "адрес e-mail"
436
 
437
+ #: language/strings.php:73
438
  msgid "users_can_register"
439
  msgstr "регистрация открыта"
440
 
441
+ #: language/strings.php:74
442
  msgid "default_role"
443
  msgstr "роль нового пользователя"
444
 
445
+ #: language/strings.php:75
446
  msgid "timezone_string"
447
  msgstr "часовой пояс"
448
 
449
+ #: language/strings.php:76
450
  msgid "date_format"
451
  msgstr "формат даты"
452
 
453
+ #: language/strings.php:77
454
  msgid "time_format"
455
  msgstr "формат времени"
456
 
457
+ #: language/strings.php:78
458
  msgid "start_of_week"
459
  msgstr "первый день недели"
460
 
461
+ #: language/strings.php:81
462
  msgid "use_smilies"
463
  msgstr "использовать смайлы"
464
 
465
+ #: language/strings.php:82
466
  msgid "use_balanceTags"
467
+ msgstr "исправлять XHTML"
468
 
469
+ #: language/strings.php:83
470
  msgid "default_category"
471
  msgstr "основная рубрика"
472
 
473
+ #: language/strings.php:84
474
  msgid "default_post_format"
475
  msgstr "основной формат записей"
476
 
477
+ #: language/strings.php:85
478
  msgid "mailserver_url"
479
+ msgstr "сервер публикации по e-mail"
480
 
481
+ #: language/strings.php:86
482
  msgid "mailserver_login"
483
+ msgstr "логин публикации по e-mail"
484
 
485
+ #: language/strings.php:87
486
  msgid "mailserver_pass"
487
+ msgstr "пароль публикации по e-mail"
488
 
489
+ #: language/strings.php:88
490
  msgid "default_email_category"
491
+ msgstr "рубрика для публикации по e-mail"
492
 
493
+ #: language/strings.php:89
494
  msgid "ping_sites"
495
+ msgstr "сервисы обновления"
496
 
497
+ #: language/strings.php:92
498
  msgid "show_on_front"
499
  msgstr "отображать на главной"
500
 
501
+ #: language/strings.php:93
502
  msgid "page_on_front"
503
  msgstr "статическая страница"
504
 
505
+ #: language/strings.php:94
506
  msgid "page_for_posts"
507
  msgstr "основная страница блога"
508
 
509
+ #: language/strings.php:95
510
  msgid "posts_per_page"
511
  msgstr "записей на страницу"
512
 
513
+ #: language/strings.php:96
514
  msgid "posts_per_rss"
515
  msgstr "записей в rss-ленте"
516
 
517
+ #: language/strings.php:97
518
  msgid "rss_use_excerpt"
519
  msgstr "отображать текст/анонс в rss"
520
 
521
+ #: language/strings.php:98
522
  msgid "blog_public"
523
  msgstr "видимость для поисковых систем"
524
 
525
+ #: language/strings.php:101
526
  msgid "default_pingback_flag"
527
  msgstr "оповещение упомянутых блогов"
528
 
529
+ #: language/strings.php:102
530
  msgid "default_ping_status"
531
  msgstr "оповещения с других блогов"
532
 
533
+ #: language/strings.php:103
534
  msgid "default_comment_status"
535
  msgstr "разрешить оставлять комментарии"
536
 
537
+ #: language/strings.php:104
538
  msgid "require_name_email"
539
  msgstr "автор комментария должен указать имя и e-mail"
540
 
541
+ #: language/strings.php:105
542
  msgid "comment_registration"
543
  msgstr "авторизация для комментирования"
544
 
545
+ #: language/strings.php:106
546
  msgid "close_comments_for_old_posts"
547
  msgstr "автоматически закрывать обсуждение"
548
 
549
+ #: language/strings.php:107
550
  msgid "close_comments_days_old"
551
  msgstr "срок обсуждения"
552
 
553
+ #: language/strings.php:108
554
  msgid "thread_comments"
555
  msgstr "древовидные комментарии"
556
 
557
+ #: language/strings.php:109
558
  msgid "thread_comments_depth"
559
  msgstr "вложенность комментариев"
560
 
561
+ #: language/strings.php:110
562
  msgid "page_comments"
563
  msgstr "комментарии постранично"
564
 
565
+ #: language/strings.php:111
566
  msgid "comments_per_page"
567
  msgstr "комментариев на страницу"
568
 
569
+ #: language/strings.php:112
570
  msgid "default_comments_page"
571
  msgstr "первая/последняя страница комментариев"
572
 
573
+ #: language/strings.php:113
574
  msgid "comment_order"
575
  msgstr "сортировка комментариев"
576
 
577
+ #: language/strings.php:114
578
  msgid "comments_notify"
579
  msgstr "письмо об оставленном комментарии"
580
 
581
+ #: language/strings.php:115
582
  msgid "moderation_notify"
583
  msgstr "письмо о комментарии на модерацию"
584
 
585
+ #: language/strings.php:116
586
  msgid "comment_moderation"
587
  msgstr "модерация комментариев"
588
 
589
+ #: language/strings.php:117
590
  msgid "comment_whitelist"
591
+ msgstr "автор должен иметь одобренные комментарии"
592
 
593
+ #: language/strings.php:118
594
  msgid "comment_max_links"
595
  msgstr "количество ссылок в комментарии"
596
 
597
+ #: language/strings.php:119
598
  msgid "moderation_keys"
599
  msgstr "ключевые слова на модерацию"
600
 
601
+ #: language/strings.php:120
602
  msgid "blacklist_keys"
603
  msgstr "чёрный список"
604
 
605
+ #: language/strings.php:121
606
  msgid "show_avatars"
607
  msgstr "показывать аватары"
608
 
609
+ #: language/strings.php:122
610
  msgid "avatar_rating"
611
  msgstr "рейтинг аватаров"
612
 
613
+ #: language/strings.php:123
614
  msgid "avatar_default"
615
  msgstr "аватар по умолчанию"
616
 
617
+ #: language/strings.php:126
618
  msgid "thumbnail_size_w"
619
  msgstr "ширина миниатюры"
620
 
621
+ #: language/strings.php:127
622
  msgid "thumbnail_size_h"
623
  msgstr "высота миниатюры"
624
 
625
+ #: language/strings.php:128
626
  msgid "thumbnail_crop"
627
  msgstr "обрезать по размерам"
628
 
629
+ #: language/strings.php:129
630
  msgid "medium_size_w"
631
  msgstr "ширина среднего размера"
632
 
633
+ #: language/strings.php:130
634
  msgid "medium_size_h"
635
  msgstr "высота среднего размера"
636
 
637
+ #: language/strings.php:131
638
  msgid "large_size_w"
639
  msgstr "ширина крупного размера"
640
 
641
+ #: language/strings.php:132
642
  msgid "large_size_h"
643
  msgstr "высота крупного размера"
644
 
645
+ #: language/strings.php:133
646
  msgid "uploads_use_yearmonth_folders"
647
  msgstr "использовать структуру папок «год – месяц» для загрузок"
648
 
649
+ #: language/strings.php:136
650
  msgid "permalink_structure"
651
  msgstr "структура постоянных ссылок"
652
 
653
+ #: language/strings.php:137
654
  msgid "category_base"
655
  msgstr "префикс для рубрик"
656
 
657
+ #: language/strings.php:138
658
  msgid "tag_base"
659
  msgstr "префикс для меток"
660
 
661
+ #: language/strings.php:141
662
  msgid "Export"
663
  msgstr "Экспорт"
664
 
665
+ #: language/strings.php:142
666
  msgid "downloaded"
667
  msgstr "скачано"
668
 
669
  #: notifications/abstract-class-aal-notification-base.php:99
670
  msgid "Object Type"
671
+ msgstr "Тип объекта"
672
 
673
  #: notifications/abstract-class-aal-notification-base.php:100
674
  msgid "Object Name"
675
+ msgstr "Имя объекта"
676
 
677
  #: notifications/abstract-class-aal-notification-base.php:102
678
  msgid "IP Address"
680
 
681
  #: notifications/abstract-class-aal-notification-base.php:121
682
  msgid "N/A"
683
+ msgstr "не известно"
684
 
685
  #: notifications/class-aal-notification-email.php:15
686
  msgid "Email"
736
  #, php-format
737
  msgid "Customize the message using the following placeholders: %s"
738
  msgstr "Составьте текст уведомления с использованием маркеров %s"
739
+
740
+ #~ msgid "ARYO Activity Log"
741
+ #~ msgstr "ARYO Activity Log"
language/{aryo-aal-sr_RS.mo → aryo-activity-log-sr_RS.mo} RENAMED
File without changes
language/{aryo-aal-sr_RS.po → aryo-activity-log-sr_RS.po} RENAMED
File without changes
language/{aryo-aal-tr_TR.mo → aryo-activity-log-tr_TR.mo} RENAMED
File without changes
language/{aryo-aal-tr_TR.po → aryo-activity-log-tr_TR.po} RENAMED
File without changes
language/aryo-activity-log.pot ADDED
@@ -0,0 +1,1927 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the aryo-activity-log package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: aryo-activity-log 2.2.7\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2016-01-04 18:51+0200\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=CHARSET\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
20
+
21
+ #: aryo-activity-log.php:123 aryo-activity-log.php:134
22
+ msgid "Cheatin&#8217; huh?"
23
+ msgstr ""
24
+
25
+ #: aryo-activity-log.php:174
26
+ #, php-format
27
+ msgid ""
28
+ "<b>Please help us improve %1$s!</b><br>\n"
29
+ "\t\t \tIf you opt-in, some data about your usage of <b>%1$s</b> will be "
30
+ "sent to %2$s.\n"
31
+ "\t\t \tIf you skip this, that's okay! <b>%1$s</b> will still work just "
32
+ "fine."
33
+ msgstr ""
34
+
35
+ #: classes/class-aal-activity-log-list-table.php:104
36
+ msgid "Activities"
37
+ msgstr ""
38
+
39
+ #: classes/class-aal-activity-log-list-table.php:115
40
+ msgid "Date"
41
+ msgstr ""
42
+
43
+ #: classes/class-aal-activity-log-list-table.php:116
44
+ msgid "Author"
45
+ msgstr ""
46
+
47
+ #: classes/class-aal-activity-log-list-table.php:117
48
+ msgid "IP"
49
+ msgstr ""
50
+
51
+ #: classes/class-aal-activity-log-list-table.php:118
52
+ msgid "Type"
53
+ msgstr ""
54
+
55
+ #: classes/class-aal-activity-log-list-table.php:119
56
+ msgid "Label"
57
+ msgstr ""
58
+
59
+ #: classes/class-aal-activity-log-list-table.php:120
60
+ msgid "Action"
61
+ msgstr ""
62
+
63
+ #: classes/class-aal-activity-log-list-table.php:121
64
+ msgid "Description"
65
+ msgstr ""
66
+
67
+ #: classes/class-aal-activity-log-list-table.php:142
68
+ #: classes/freemius/includes/fs-plugin-functions.php:259
69
+ #, php-format
70
+ msgid "%s ago"
71
+ msgstr ""
72
+
73
+ #: classes/class-aal-activity-log-list-table.php:171
74
+ msgid "Unknown"
75
+ msgstr ""
76
+
77
+ #: classes/class-aal-activity-log-list-table.php:177
78
+ #: classes/class-aal-activity-log-list-table.php:296
79
+ msgid "Guest"
80
+ msgstr ""
81
+
82
+ #: classes/class-aal-activity-log-list-table.php:220
83
+ msgid "All"
84
+ msgstr ""
85
+
86
+ #: classes/class-aal-activity-log-list-table.php:240
87
+ msgid "Search"
88
+ msgstr ""
89
+
90
+ #: classes/class-aal-activity-log-list-table.php:283
91
+ msgid "All Roles"
92
+ msgstr ""
93
+
94
+ #: classes/class-aal-activity-log-list-table.php:307
95
+ msgid "All Users"
96
+ msgstr ""
97
+
98
+ #: classes/class-aal-activity-log-list-table.php:335
99
+ msgid "All Types"
100
+ msgstr ""
101
+
102
+ #: classes/class-aal-activity-log-list-table.php:361
103
+ msgid "All Actions"
104
+ msgstr ""
105
+
106
+ #: classes/class-aal-activity-log-list-table.php:372
107
+ msgid "All Time"
108
+ msgstr ""
109
+
110
+ #: classes/class-aal-activity-log-list-table.php:373
111
+ msgid "Today"
112
+ msgstr ""
113
+
114
+ #: classes/class-aal-activity-log-list-table.php:374
115
+ msgid "Yesterday"
116
+ msgstr ""
117
+
118
+ #: classes/class-aal-activity-log-list-table.php:375
119
+ msgid "Week"
120
+ msgstr ""
121
+
122
+ #: classes/class-aal-activity-log-list-table.php:376
123
+ msgid "Month"
124
+ msgstr ""
125
+
126
+ #: classes/class-aal-activity-log-list-table.php:383
127
+ msgid "Filter"
128
+ msgstr ""
129
+
130
+ #: classes/class-aal-admin-ui.php:16 classes/class-aal-admin-ui.php:26
131
+ #: language/strings.php:5
132
+ msgid "Activity Log"
133
+ msgstr ""
134
+
135
+ #: classes/class-aal-help.php:20
136
+ msgid "Overview"
137
+ msgstr ""
138
+
139
+ #: classes/class-aal-help.php:23 classes/class-aal-settings.php:125
140
+ #: classes/class-aal-settings.php:197
141
+ msgid "Notifications"
142
+ msgstr ""
143
+
144
+ #: classes/class-aal-help.php:24
145
+ msgid ""
146
+ "This screen lets you control what will happen once a user on your site does "
147
+ "something you define. For instance, let us assume that you have created a "
148
+ "user on your site\n"
149
+ " for your content editor. Now, let's say that every time "
150
+ "that user updates a post, you want to know about it. You can easily do it "
151
+ "from this page."
152
+ msgstr ""
153
+
154
+ #: classes/class-aal-notifications.php:290
155
+ msgid "The AAL notification handler you are trying to register does not exist."
156
+ msgstr ""
157
+
158
+ #: classes/class-aal-settings.php:26
159
+ msgid "GitHub"
160
+ msgstr ""
161
+
162
+ #: classes/class-aal-settings.php:29 classes/class-aal-settings.php:44
163
+ msgid "Settings"
164
+ msgstr ""
165
+
166
+ #: classes/class-aal-settings.php:43 classes/class-aal-settings.php:227
167
+ msgid "Activity Log Settings"
168
+ msgstr ""
169
+
170
+ #: classes/class-aal-settings.php:82
171
+ msgid "Display Options"
172
+ msgstr ""
173
+
174
+ #: classes/class-aal-settings.php:89
175
+ msgid "Keep logs for"
176
+ msgstr ""
177
+
178
+ #: classes/class-aal-settings.php:98
179
+ msgid "days."
180
+ msgstr ""
181
+
182
+ #: classes/class-aal-settings.php:99 classes/class-aal-settings.php:139
183
+ msgid ""
184
+ "Maximum number of days to keep activity log. Leave blank to keep activity "
185
+ "log forever (not recommended)."
186
+ msgstr ""
187
+
188
+ #: classes/class-aal-settings.php:106
189
+ msgid "Delete Log Activities"
190
+ msgstr ""
191
+
192
+ #: classes/class-aal-settings.php:111
193
+ #, php-format
194
+ msgid "<a href=\"%s\" id=\"%s\">Reset Database</a>"
195
+ msgstr ""
196
+
197
+ #: classes/class-aal-settings.php:115
198
+ msgid "Warning: Clicking this will delete all activities from the database."
199
+ msgstr ""
200
+
201
+ #: classes/class-aal-settings.php:132
202
+ msgid "Notification Events"
203
+ msgstr ""
204
+
205
+ #: classes/class-aal-settings.php:160
206
+ msgid "Enable?"
207
+ msgstr ""
208
+
209
+ #: classes/class-aal-settings.php:196
210
+ msgid "General"
211
+ msgstr ""
212
+
213
+ #: classes/class-aal-settings.php:246
214
+ msgid "All activities have been successfully deleted."
215
+ msgstr ""
216
+
217
+ #: classes/class-aal-settings.php:257
218
+ msgid "Are you sure you want to do this action?"
219
+ msgstr ""
220
+
221
+ #: classes/class-aal-settings.php:268
222
+ msgid "You do not have sufficient permissions to access this page."
223
+ msgstr ""
224
+
225
+ #: classes/class-aal-settings.php:321
226
+ msgid "These are some basic settings for Activity Log."
227
+ msgstr ""
228
+
229
+ #: classes/class-aal-settings.php:327
230
+ msgid ""
231
+ "Serve yourself with custom-tailored notifications. First, define your "
232
+ "conditions. Then, choose how the notifications will be sent."
233
+ msgstr ""
234
+
235
+ #: classes/class-aal-settings.php:426
236
+ msgid "Yes"
237
+ msgstr ""
238
+
239
+ #: classes/class-aal-settings.php:427
240
+ msgid "No"
241
+ msgstr ""
242
+
243
+ #: classes/class-aal-settings.php:444 language/strings.php:23
244
+ #: notifications/abstract-class-aal-notification-base.php:98
245
+ msgid "User"
246
+ msgstr ""
247
+
248
+ #: classes/class-aal-settings.php:445
249
+ #: notifications/abstract-class-aal-notification-base.php:101
250
+ msgid "Action Type"
251
+ msgstr ""
252
+
253
+ #: classes/class-aal-settings.php:446
254
+ msgid "Action Performed"
255
+ msgstr ""
256
+
257
+ #: classes/class-aal-settings.php:450
258
+ msgid "equals to"
259
+ msgstr ""
260
+
261
+ #: classes/class-aal-settings.php:451
262
+ msgid "not equals to"
263
+ msgstr ""
264
+
265
+ #: classes/class-aal-settings.php:461
266
+ msgid ""
267
+ "A notification will be sent upon a successful match with the following "
268
+ "conditions:"
269
+ msgstr ""
270
+
271
+ #: classes/freemius/includes/fs-plugin-functions.php:87
272
+ msgctxt "Plugin installer section title"
273
+ msgid "Description"
274
+ msgstr ""
275
+
276
+ #: classes/freemius/includes/fs-plugin-functions.php:88
277
+ msgctxt "Plugin installer section title"
278
+ msgid "Installation"
279
+ msgstr ""
280
+
281
+ #: classes/freemius/includes/fs-plugin-functions.php:89
282
+ msgctxt "Plugin installer section title"
283
+ msgid "FAQ"
284
+ msgstr ""
285
+
286
+ #: classes/freemius/includes/fs-plugin-functions.php:90
287
+ msgctxt "Plugin installer section title"
288
+ msgid "Screenshots"
289
+ msgstr ""
290
+
291
+ #: classes/freemius/includes/fs-plugin-functions.php:91
292
+ msgctxt "Plugin installer section title"
293
+ msgid "Changelog"
294
+ msgstr ""
295
+
296
+ #: classes/freemius/includes/fs-plugin-functions.php:92
297
+ msgctxt "Plugin installer section title"
298
+ msgid "Reviews"
299
+ msgstr ""
300
+
301
+ #: classes/freemius/includes/fs-plugin-functions.php:93
302
+ msgctxt "Plugin installer section title"
303
+ msgid "Other Notes"
304
+ msgstr ""
305
+
306
+ #: classes/freemius/includes/fs-plugin-functions.php:116
307
+ msgid "Plugin Install"
308
+ msgstr ""
309
+
310
+ #: classes/freemius/includes/fs-plugin-functions.php:249
311
+ msgid "Version:"
312
+ msgstr ""
313
+
314
+ #: classes/freemius/includes/fs-plugin-functions.php:253
315
+ msgid "Author:"
316
+ msgstr ""
317
+
318
+ #: classes/freemius/includes/fs-plugin-functions.php:257
319
+ msgid "Last Updated:"
320
+ msgstr ""
321
+
322
+ #: classes/freemius/includes/fs-plugin-functions.php:264
323
+ msgid "Requires WordPress Version:"
324
+ msgstr ""
325
+
326
+ #: classes/freemius/includes/fs-plugin-functions.php:264
327
+ #, php-format
328
+ msgid "%s or higher"
329
+ msgstr ""
330
+
331
+ #: classes/freemius/includes/fs-plugin-functions.php:268
332
+ msgid "Compatible up to:"
333
+ msgstr ""
334
+
335
+ #: classes/freemius/includes/fs-plugin-functions.php:272
336
+ msgid "Downloaded:"
337
+ msgstr ""
338
+
339
+ #: classes/freemius/includes/fs-plugin-functions.php:272
340
+ #, php-format
341
+ msgid "%s time"
342
+ msgid_plural "%s times"
343
+ msgstr[0] ""
344
+ msgstr[1] ""
345
+
346
+ #: classes/freemius/includes/fs-plugin-functions.php:277
347
+ msgid "WordPress.org Plugin Page &#187;"
348
+ msgstr ""
349
+
350
+ #: classes/freemius/includes/fs-plugin-functions.php:282
351
+ msgid "Plugin Homepage &#187;"
352
+ msgstr ""
353
+
354
+ #: classes/freemius/includes/fs-plugin-functions.php:287
355
+ #: classes/freemius/includes/fs-plugin-functions.php:344
356
+ msgid "Donate to this plugin &#187;"
357
+ msgstr ""
358
+
359
+ #: classes/freemius/includes/fs-plugin-functions.php:293
360
+ msgid "Average Rating"
361
+ msgstr ""
362
+
363
+ #: classes/freemius/includes/fs-plugin-functions.php:299
364
+ #, php-format
365
+ msgid "(based on %s rating)"
366
+ msgid_plural "(based on %s ratings)"
367
+ msgstr[0] ""
368
+ msgstr[1] ""
369
+
370
+ #: classes/freemius/includes/fs-plugin-functions.php:312
371
+ #, php-format
372
+ msgid "Click to see reviews that provided a rating of %d star"
373
+ msgid_plural "Click to see reviews that provided a rating of %d stars"
374
+ msgstr[0] ""
375
+ msgstr[1] ""
376
+
377
+ #: classes/freemius/includes/fs-plugin-functions.php:312
378
+ #, php-format
379
+ msgid "%d star"
380
+ msgid_plural "%d stars"
381
+ msgstr[0] ""
382
+ msgstr[1] ""
383
+
384
+ #: classes/freemius/includes/fs-plugin-functions.php:323
385
+ msgid "Contributors"
386
+ msgstr ""
387
+
388
+ #: classes/freemius/includes/fs-plugin-functions.php:351
389
+ #: classes/freemius/includes/fs-plugin-functions.php:353
390
+ msgid "Warning:"
391
+ msgstr ""
392
+
393
+ #: classes/freemius/includes/fs-plugin-functions.php:351
394
+ msgid "This plugin has not been tested with your current version of WordPress."
395
+ msgstr ""
396
+
397
+ #: classes/freemius/includes/fs-plugin-functions.php:353
398
+ msgid ""
399
+ "This plugin has not been marked as compatible with your version of WordPress."
400
+ msgstr ""
401
+
402
+ #: classes/freemius/includes/fs-plugin-functions.php:390
403
+ #: classes/freemius/includes/i18n.php:76
404
+ msgid "Install Now"
405
+ msgstr ""
406
+
407
+ #: classes/freemius/includes/fs-plugin-functions.php:395
408
+ #: classes/freemius/includes/i18n.php:77
409
+ msgid "Install Update Now"
410
+ msgstr ""
411
+
412
+ #: classes/freemius/includes/fs-plugin-functions.php:399
413
+ #, php-format
414
+ msgid "Newer Version (%s) Installed"
415
+ msgstr ""
416
+
417
+ #: classes/freemius/includes/fs-plugin-functions.php:402
418
+ msgid "Latest Version Installed"
419
+ msgstr ""
420
+
421
+ #: classes/freemius/includes/i18n.php:5
422
+ msgid "Account"
423
+ msgstr ""
424
+
425
+ #: classes/freemius/includes/i18n.php:6
426
+ msgid "Add On"
427
+ msgstr ""
428
+
429
+ #: classes/freemius/includes/i18n.php:7
430
+ msgid "Contact Us"
431
+ msgstr ""
432
+
433
+ #: classes/freemius/includes/i18n.php:8
434
+ msgid "Change Ownership"
435
+ msgstr ""
436
+
437
+ #: classes/freemius/includes/i18n.php:9
438
+ msgid "Support"
439
+ msgstr ""
440
+
441
+ #: classes/freemius/includes/i18n.php:10
442
+ msgid "Support Forum"
443
+ msgstr ""
444
+
445
+ #: classes/freemius/includes/i18n.php:11
446
+ msgid "Add Ons"
447
+ msgstr ""
448
+
449
+ #: classes/freemius/includes/i18n.php:12
450
+ msgctxt "verb"
451
+ msgid "Upgrade"
452
+ msgstr ""
453
+
454
+ #: classes/freemius/includes/i18n.php:13
455
+ msgid "Awesome"
456
+ msgstr ""
457
+
458
+ #: classes/freemius/includes/i18n.php:14
459
+ msgctxt "noun"
460
+ msgid "Pricing"
461
+ msgstr ""
462
+
463
+ #: classes/freemius/includes/i18n.php:15
464
+ msgctxt "noun"
465
+ msgid "Price"
466
+ msgstr ""
467
+
468
+ #: classes/freemius/includes/i18n.php:16
469
+ msgid "Unlimited Updates"
470
+ msgstr ""
471
+
472
+ #: classes/freemius/includes/i18n.php:17
473
+ msgctxt "verb"
474
+ msgid "Downgrade"
475
+ msgstr ""
476
+
477
+ #: classes/freemius/includes/i18n.php:18
478
+ msgid "Free Trial"
479
+ msgstr ""
480
+
481
+ #: classes/freemius/includes/i18n.php:19
482
+ msgid "Details"
483
+ msgstr ""
484
+
485
+ #: classes/freemius/includes/i18n.php:20
486
+ msgid "Account Details"
487
+ msgstr ""
488
+
489
+ #: classes/freemius/includes/i18n.php:21
490
+ msgctxt "verb"
491
+ msgid "Delete"
492
+ msgstr ""
493
+
494
+ #: classes/freemius/includes/i18n.php:22
495
+ msgid "Delete Account"
496
+ msgstr ""
497
+
498
+ #: classes/freemius/includes/i18n.php:23
499
+ msgctxt "as close a window"
500
+ msgid "Dismiss"
501
+ msgstr ""
502
+
503
+ #: classes/freemius/includes/i18n.php:24
504
+ msgctxt "as product pricing plan"
505
+ msgid "Plan"
506
+ msgstr ""
507
+
508
+ #: classes/freemius/includes/i18n.php:25
509
+ msgid "Change Plan"
510
+ msgstr ""
511
+
512
+ #: classes/freemius/includes/i18n.php:26
513
+ #, php-format
514
+ msgctxt "as download professional version"
515
+ msgid "Download %s Version"
516
+ msgstr ""
517
+
518
+ #: classes/freemius/includes/i18n.php:27
519
+ #, php-format
520
+ msgctxt "as download professional version now"
521
+ msgid "Download %s version now"
522
+ msgstr ""
523
+
524
+ #: classes/freemius/includes/i18n.php:28
525
+ msgctxt "as download latest version"
526
+ msgid "Download Latest"
527
+ msgstr ""
528
+
529
+ #: classes/freemius/includes/i18n.php:29
530
+ #, php-format
531
+ msgctxt "E.g. you have a professional license."
532
+ msgid "You have a %s license."
533
+ msgstr ""
534
+
535
+ #: classes/freemius/includes/i18n.php:30
536
+ msgid "New"
537
+ msgstr ""
538
+
539
+ #: classes/freemius/includes/i18n.php:31
540
+ msgid "Free"
541
+ msgstr ""
542
+
543
+ #: classes/freemius/includes/i18n.php:32
544
+ msgctxt "as trial plan"
545
+ msgid "Trial"
546
+ msgstr ""
547
+
548
+ #: classes/freemius/includes/i18n.php:33
549
+ msgctxt "verb"
550
+ msgid "Purchase"
551
+ msgstr ""
552
+
553
+ #: classes/freemius/includes/i18n.php:34
554
+ msgid "Single Site License"
555
+ msgstr ""
556
+
557
+ #: classes/freemius/includes/i18n.php:35
558
+ msgid "Unlimited Licenses"
559
+ msgstr ""
560
+
561
+ #: classes/freemius/includes/i18n.php:36
562
+ #, php-format
563
+ msgid "Up to %s Sites"
564
+ msgstr ""
565
+
566
+ #: classes/freemius/includes/i18n.php:37
567
+ #, php-format
568
+ msgctxt "e.g. Professional Plan"
569
+ msgid "%s Plan"
570
+ msgstr ""
571
+
572
+ #: classes/freemius/includes/i18n.php:38
573
+ #, php-format
574
+ msgid "You are just one step away - %s"
575
+ msgstr ""
576
+
577
+ #: classes/freemius/includes/i18n.php:39
578
+ #, php-format
579
+ msgctxt "%s - plugin name. As complete \"Jetpack\" activation now"
580
+ msgid "Complete \"%s\" Activation Now"
581
+ msgstr ""
582
+
583
+ #: classes/freemius/includes/i18n.php:40
584
+ #, php-format
585
+ msgid "We made a few tweaks to the plugin, %s"
586
+ msgstr ""
587
+
588
+ #: classes/freemius/includes/i18n.php:41
589
+ #, php-format
590
+ msgid "Opt-in to make \"%s\" Better!"
591
+ msgstr ""
592
+
593
+ #: classes/freemius/includes/i18n.php:42
594
+ msgid "Error"
595
+ msgstr ""
596
+
597
+ #: classes/freemius/includes/i18n.php:43
598
+ msgid ""
599
+ "Freemius SDK couldn't find the plugin's main file. Please contact "
600
+ "sdk@freemius.com with the current error."
601
+ msgstr ""
602
+
603
+ #: classes/freemius/includes/i18n.php:46
604
+ msgctxt "as expiration date"
605
+ msgid "Expiration"
606
+ msgstr ""
607
+
608
+ #: classes/freemius/includes/i18n.php:47
609
+ msgid "not verified"
610
+ msgstr ""
611
+
612
+ #: classes/freemius/includes/i18n.php:48
613
+ msgid "Verify Email"
614
+ msgstr ""
615
+
616
+ #: classes/freemius/includes/i18n.php:49
617
+ #, php-format
618
+ msgctxt "e.g. expires in 2 months"
619
+ msgid "Expires in %s"
620
+ msgstr ""
621
+
622
+ #: classes/freemius/includes/i18n.php:50
623
+ #, php-format
624
+ msgctxt "e.g. auto renews in 2 months"
625
+ msgid "Auto renews in %s"
626
+ msgstr ""
627
+
628
+ #: classes/freemius/includes/i18n.php:51
629
+ msgid "No expiration"
630
+ msgstr ""
631
+
632
+ #: classes/freemius/includes/i18n.php:52
633
+ msgid "Expired"
634
+ msgstr ""
635
+
636
+ #: classes/freemius/includes/i18n.php:53
637
+ #, php-format
638
+ msgid "In %s"
639
+ msgstr ""
640
+
641
+ #: classes/freemius/includes/i18n.php:54
642
+ msgctxt "as plugin version"
643
+ msgid "Version"
644
+ msgstr ""
645
+
646
+ #: classes/freemius/includes/i18n.php:55
647
+ msgid "Name"
648
+ msgstr ""
649
+
650
+ #: classes/freemius/includes/i18n.php:56
651
+ #: notifications/class-aal-notification-email.php:15
652
+ msgid "Email"
653
+ msgstr ""
654
+
655
+ #: classes/freemius/includes/i18n.php:57
656
+ msgid "Verified"
657
+ msgstr ""
658
+
659
+ #: classes/freemius/includes/i18n.php:58 language/strings.php:29
660
+ msgid "Plugin"
661
+ msgstr ""
662
+
663
+ #: classes/freemius/includes/i18n.php:59
664
+ msgid "Title"
665
+ msgstr ""
666
+
667
+ #: classes/freemius/includes/i18n.php:60
668
+ msgctxt "as WP plugin slug"
669
+ msgid "Slug"
670
+ msgstr ""
671
+
672
+ #: classes/freemius/includes/i18n.php:61
673
+ msgid "ID"
674
+ msgstr ""
675
+
676
+ #: classes/freemius/includes/i18n.php:62
677
+ msgid "Users"
678
+ msgstr ""
679
+
680
+ #: classes/freemius/includes/i18n.php:63
681
+ msgid "Plugin Installs"
682
+ msgstr ""
683
+
684
+ #: classes/freemius/includes/i18n.php:64
685
+ msgctxt "like websites"
686
+ msgid "Sites"
687
+ msgstr ""
688
+
689
+ #: classes/freemius/includes/i18n.php:65
690
+ msgid "User ID"
691
+ msgstr ""
692
+
693
+ #: classes/freemius/includes/i18n.php:66
694
+ msgid "Site ID"
695
+ msgstr ""
696
+
697
+ #: classes/freemius/includes/i18n.php:67
698
+ msgid "Public Key"
699
+ msgstr ""
700
+
701
+ #: classes/freemius/includes/i18n.php:68
702
+ msgid "Secret Key"
703
+ msgstr ""
704
+
705
+ #: classes/freemius/includes/i18n.php:69
706
+ msgctxt "as secret encryption key missing"
707
+ msgid "No Secret"
708
+ msgstr ""
709
+
710
+ #: classes/freemius/includes/i18n.php:70
711
+ msgid "No ID"
712
+ msgstr ""
713
+
714
+ #: classes/freemius/includes/i18n.php:71
715
+ msgctxt "as synchronize license"
716
+ msgid "Sync License"
717
+ msgstr ""
718
+
719
+ #: classes/freemius/includes/i18n.php:72
720
+ msgid "Deactivate License"
721
+ msgstr ""
722
+
723
+ #: classes/freemius/includes/i18n.php:73
724
+ msgid "Activate"
725
+ msgstr ""
726
+
727
+ #: classes/freemius/includes/i18n.php:74 classes/freemius/includes/i18n.php:95
728
+ msgid "Deactivate"
729
+ msgstr ""
730
+
731
+ #: classes/freemius/includes/i18n.php:75
732
+ msgctxt "active mode"
733
+ msgid "Active"
734
+ msgstr ""
735
+
736
+ #: classes/freemius/includes/i18n.php:78
737
+ #, php-format
738
+ msgid "More information about %s"
739
+ msgstr ""
740
+
741
+ #: classes/freemius/includes/i18n.php:79
742
+ msgid "Localhost"
743
+ msgstr ""
744
+
745
+ #: classes/freemius/includes/i18n.php:80
746
+ #, php-format
747
+ msgctxt "as activate Professional plan"
748
+ msgid "Activate %s Plan"
749
+ msgstr ""
750
+
751
+ #: classes/freemius/includes/i18n.php:81
752
+ #, php-format
753
+ msgid "What is your %s?"
754
+ msgstr ""
755
+
756
+ #: classes/freemius/includes/i18n.php:82
757
+ msgid "Activate this add-on"
758
+ msgstr ""
759
+
760
+ #: classes/freemius/includes/i18n.php:83
761
+ msgid ""
762
+ "Deactivating your license will block all premium features, but will enable "
763
+ "you to activate the license on another site. Are you sure you want to "
764
+ "proceed?"
765
+ msgstr ""
766
+
767
+ #: classes/freemius/includes/i18n.php:84
768
+ #, php-format
769
+ msgid ""
770
+ "Deleting the account will automatically deactivate your %s plan license so "
771
+ "you can use it on other sites. If you want to terminate the recurring "
772
+ "payments as well, click the \"Cancel\" button, and first \"Downgrade\" your "
773
+ "account. Are you sure you would like to continue with the deletion?"
774
+ msgstr ""
775
+
776
+ #: classes/freemius/includes/i18n.php:85
777
+ msgid ""
778
+ "Deletion is not temporary. Only delete if you no longer want to use this "
779
+ "plugin anymore. Are you sure you would like to continue with the deletion?"
780
+ msgstr ""
781
+
782
+ #: classes/freemius/includes/i18n.php:86
783
+ #, php-format
784
+ msgid ""
785
+ "Downgrading your plan will immediately stop all future recurring payments "
786
+ "and your %s plan license will expire in %s."
787
+ msgstr ""
788
+
789
+ #: classes/freemius/includes/i18n.php:87
790
+ #, php-format
791
+ msgid ""
792
+ "You can still enjoy all %s features but you will not have access to plugin "
793
+ "updates and support."
794
+ msgstr ""
795
+
796
+ #: classes/freemius/includes/i18n.php:88
797
+ #, php-format
798
+ msgid ""
799
+ "Once your license expire you can still use the Free version but you will NOT "
800
+ "have access to the %s features."
801
+ msgstr ""
802
+
803
+ #: classes/freemius/includes/i18n.php:89
804
+ msgid "Are you sure you want to proceed?"
805
+ msgstr ""
806
+
807
+ #: classes/freemius/includes/i18n.php:92
808
+ #, php-format
809
+ msgid "Add Ons for %s"
810
+ msgstr ""
811
+
812
+ #: classes/freemius/includes/i18n.php:94
813
+ msgid "If you have a moment, please let us know why you are deactivating"
814
+ msgstr ""
815
+
816
+ #: classes/freemius/includes/i18n.php:96
817
+ msgid "Yes - Deactivate"
818
+ msgstr ""
819
+
820
+ #: classes/freemius/includes/i18n.php:97
821
+ msgid "Submit & Deactivate"
822
+ msgstr ""
823
+
824
+ #: classes/freemius/includes/i18n.php:98
825
+ msgctxt "the text of the cancel button of the plugin deactivation dialog box."
826
+ msgid "Cancel"
827
+ msgstr ""
828
+
829
+ #: classes/freemius/includes/i18n.php:99
830
+ msgid "I no longer need the plugin"
831
+ msgstr ""
832
+
833
+ #: classes/freemius/includes/i18n.php:100
834
+ msgid "I found a better plugin"
835
+ msgstr ""
836
+
837
+ #: classes/freemius/includes/i18n.php:101
838
+ msgid "I only needed the plugin for a short period"
839
+ msgstr ""
840
+
841
+ #: classes/freemius/includes/i18n.php:102
842
+ msgid "The plugin broke my site"
843
+ msgstr ""
844
+
845
+ #: classes/freemius/includes/i18n.php:103
846
+ msgid "The plugin suddenly stopped working"
847
+ msgstr ""
848
+
849
+ #: classes/freemius/includes/i18n.php:104
850
+ msgid "I can't pay for it anymore"
851
+ msgstr ""
852
+
853
+ #: classes/freemius/includes/i18n.php:105
854
+ msgctxt ""
855
+ "the text of the \"other\" reason for deactivating the plugin that is shown "
856
+ "in the modal box."
857
+ msgid "Other"
858
+ msgstr ""
859
+
860
+ #: classes/freemius/includes/i18n.php:106
861
+ msgid "What's the plugin's name?"
862
+ msgstr ""
863
+
864
+ #: classes/freemius/includes/i18n.php:107
865
+ msgid "What price would you feel comfortable paying?"
866
+ msgstr ""
867
+
868
+ #: classes/freemius/includes/i18n.php:108
869
+ msgid "I couldn't understand how to make it work"
870
+ msgstr ""
871
+
872
+ #: classes/freemius/includes/i18n.php:109
873
+ msgid "The plugin is great, but I need specific feature that you don't support"
874
+ msgstr ""
875
+
876
+ #: classes/freemius/includes/i18n.php:110
877
+ msgid "The plugin is not working"
878
+ msgstr ""
879
+
880
+ #: classes/freemius/includes/i18n.php:111
881
+ msgid "It's not what I was looking for"
882
+ msgstr ""
883
+
884
+ #: classes/freemius/includes/i18n.php:112
885
+ msgid "The plugin didn't work as expected"
886
+ msgstr ""
887
+
888
+ #: classes/freemius/includes/i18n.php:113
889
+ msgid "What feature?"
890
+ msgstr ""
891
+
892
+ #: classes/freemius/includes/i18n.php:114
893
+ msgid "Kindly share what didn't work so we can fix it for future users..."
894
+ msgstr ""
895
+
896
+ #: classes/freemius/includes/i18n.php:115
897
+ msgid "What you've been looking for?"
898
+ msgstr ""
899
+
900
+ #: classes/freemius/includes/i18n.php:116
901
+ msgid "What did you expect?"
902
+ msgstr ""
903
+
904
+ #: classes/freemius/includes/i18n.php:117
905
+ msgid "The plugin didn't work"
906
+ msgstr ""
907
+
908
+ #: classes/freemius/includes/i18n.php:118
909
+ msgid "I don't like to share my information with you"
910
+ msgstr ""
911
+
912
+ #: classes/freemius/includes/i18n.php:122
913
+ #, php-format
914
+ msgctxt "greeting"
915
+ msgid "Hey %s,"
916
+ msgstr ""
917
+
918
+ #: classes/freemius/includes/i18n.php:123
919
+ #, php-format
920
+ msgctxt "a greeting. E.g. Thanks John!"
921
+ msgid "Thanks %s!"
922
+ msgstr ""
923
+
924
+ #: classes/freemius/includes/i18n.php:124
925
+ #, php-format
926
+ msgid ""
927
+ "In order to enjoy all our features and functionality, %s needs to connect "
928
+ "your user, %s at %s, to %s"
929
+ msgstr ""
930
+
931
+ #: classes/freemius/includes/i18n.php:125
932
+ #, php-format
933
+ msgid ""
934
+ "You should receive an activation email for %s to your mailbox at %s. Please "
935
+ "make sure you click the activation button in that email to complete the "
936
+ "install."
937
+ msgstr ""
938
+
939
+ #: classes/freemius/includes/i18n.php:126
940
+ msgid "What permissions are being granted?"
941
+ msgstr ""
942
+
943
+ #: classes/freemius/includes/i18n.php:127
944
+ msgid "Your Profile Overview"
945
+ msgstr ""
946
+
947
+ #: classes/freemius/includes/i18n.php:128
948
+ msgid "Name and email address"
949
+ msgstr ""
950
+
951
+ #: classes/freemius/includes/i18n.php:129
952
+ msgid "Your Site Overview"
953
+ msgstr ""
954
+
955
+ #: classes/freemius/includes/i18n.php:130
956
+ msgid "Site address and WordPress version"
957
+ msgstr ""
958
+
959
+ #: classes/freemius/includes/i18n.php:131
960
+ msgid "Current Plugin Events"
961
+ msgstr ""
962
+
963
+ #: classes/freemius/includes/i18n.php:132
964
+ msgid "Activation, deactivation and uninstall"
965
+ msgstr ""
966
+
967
+ #: classes/freemius/includes/i18n.php:133
968
+ msgid "Privacy Policy"
969
+ msgstr ""
970
+
971
+ #: classes/freemius/includes/i18n.php:134
972
+ msgid "Terms of Service"
973
+ msgstr ""
974
+
975
+ #: classes/freemius/includes/i18n.php:135
976
+ msgctxt "as activating plugin"
977
+ msgid "Activating"
978
+ msgstr ""
979
+
980
+ #: classes/freemius/includes/i18n.php:136
981
+ msgctxt "button label"
982
+ msgid "Allow & Continue"
983
+ msgstr ""
984
+
985
+ #: classes/freemius/includes/i18n.php:137
986
+ msgctxt "verb"
987
+ msgid "Skip"
988
+ msgstr ""
989
+
990
+ #: classes/freemius/includes/i18n.php:138
991
+ msgid "Re-send activation email"
992
+ msgstr ""
993
+
994
+ #: classes/freemius/includes/i18n.php:142
995
+ msgid "Screenshots"
996
+ msgstr ""
997
+
998
+ #: classes/freemius/includes/i18n.php:143
999
+ #, php-format
1000
+ msgid "Click to view full-size screenshot %d"
1001
+ msgstr ""
1002
+
1003
+ #: classes/freemius/includes/i18n.php:147
1004
+ #, php-format
1005
+ msgid "Add Ons of Plugin %s"
1006
+ msgstr ""
1007
+
1008
+ #: classes/freemius/includes/i18n.php:148
1009
+ msgid "Are you sure you want to delete the all Freemius data?"
1010
+ msgstr ""
1011
+
1012
+ #: classes/freemius/includes/i18n.php:149
1013
+ msgid "Delete All Accounts"
1014
+ msgstr ""
1015
+
1016
+ #: classes/freemius/includes/i18n.php:153
1017
+ msgctxt "as congratulations"
1018
+ msgid "Congrats"
1019
+ msgstr ""
1020
+
1021
+ #: classes/freemius/includes/i18n.php:154
1022
+ msgctxt "exclamation"
1023
+ msgid "Oops"
1024
+ msgstr ""
1025
+
1026
+ #: classes/freemius/includes/i18n.php:155
1027
+ msgctxt "interjection expressing joy or exuberance"
1028
+ msgid "Yee-haw"
1029
+ msgstr ""
1030
+
1031
+ #: classes/freemius/includes/i18n.php:156
1032
+ msgctxt ""
1033
+ "(especially in electronic communication) used to express elation, "
1034
+ "enthusiasm, or triumph."
1035
+ msgid "W00t"
1036
+ msgstr ""
1037
+
1038
+ #: classes/freemius/includes/i18n.php:157
1039
+ msgctxt "a positive response"
1040
+ msgid "Right on"
1041
+ msgstr ""
1042
+
1043
+ #: classes/freemius/includes/i18n.php:158
1044
+ msgctxt ""
1045
+ "something somebody says when they are thinking about what you have just "
1046
+ "said. "
1047
+ msgid "Hmm"
1048
+ msgstr ""
1049
+
1050
+ #: classes/freemius/includes/i18n.php:159
1051
+ msgid "O.K"
1052
+ msgstr ""
1053
+
1054
+ #: classes/freemius/includes/i18n.php:160
1055
+ msgctxt "exclamation"
1056
+ msgid "Hey"
1057
+ msgstr ""
1058
+
1059
+ #: classes/freemius/includes/i18n.php:161
1060
+ msgctxt "advance notice of something that will need attention."
1061
+ msgid "Heads up"
1062
+ msgstr ""
1063
+
1064
+ #: classes/freemius/includes/i18n.php:165
1065
+ msgid "Seems like you got the latest release."
1066
+ msgstr ""
1067
+
1068
+ #: classes/freemius/includes/i18n.php:166
1069
+ msgid "You are all good!"
1070
+ msgstr ""
1071
+
1072
+ #: classes/freemius/includes/i18n.php:167
1073
+ msgid ""
1074
+ "Sorry, we could not complete the email update. Another user with the same "
1075
+ "email is already registered."
1076
+ msgstr ""
1077
+
1078
+ #: classes/freemius/includes/i18n.php:168
1079
+ #, php-format
1080
+ msgid ""
1081
+ "If you would like to give up the ownership of the plugin's account to %s "
1082
+ "click the Change Ownership button."
1083
+ msgstr ""
1084
+
1085
+ #: classes/freemius/includes/i18n.php:169
1086
+ msgid ""
1087
+ "Your email was successfully updated. You should receive an email with "
1088
+ "confirmation instructions in few moments."
1089
+ msgstr ""
1090
+
1091
+ #: classes/freemius/includes/i18n.php:170
1092
+ msgid "Your name was successfully updated."
1093
+ msgstr ""
1094
+
1095
+ #: classes/freemius/includes/i18n.php:171
1096
+ #, php-format
1097
+ msgid "You have successfully updated your %s."
1098
+ msgstr ""
1099
+
1100
+ #: classes/freemius/includes/i18n.php:172
1101
+ msgid "Please provide your full name."
1102
+ msgstr ""
1103
+
1104
+ #: classes/freemius/includes/i18n.php:173
1105
+ #, php-format
1106
+ msgid ""
1107
+ "Verification mail was just sent to %s. If you can't find it after 5 min, "
1108
+ "please check your spam box."
1109
+ msgstr ""
1110
+
1111
+ #: classes/freemius/includes/i18n.php:174
1112
+ #, php-format
1113
+ msgid ""
1114
+ "Just letting you know that the add-ons information of %s is being pulled "
1115
+ "from external server."
1116
+ msgstr ""
1117
+
1118
+ #: classes/freemius/includes/i18n.php:175
1119
+ msgid "No credit card required"
1120
+ msgstr ""
1121
+
1122
+ #: classes/freemius/includes/i18n.php:176
1123
+ msgid "Premium plugin version was successfully activated."
1124
+ msgstr ""
1125
+
1126
+ #: classes/freemius/includes/i18n.php:177
1127
+ #, php-format
1128
+ msgid "The upgrade of %s was successfully completed."
1129
+ msgstr ""
1130
+
1131
+ #: classes/freemius/includes/i18n.php:178
1132
+ #, php-format
1133
+ msgid "Your account was successfully activated with the %s plan."
1134
+ msgstr ""
1135
+
1136
+ #: classes/freemius/includes/i18n.php:179
1137
+ #, php-format
1138
+ msgid "Download the latest %s version now"
1139
+ msgstr ""
1140
+
1141
+ #: classes/freemius/includes/i18n.php:180
1142
+ msgid "Download the latest version now"
1143
+ msgstr ""
1144
+
1145
+ #: classes/freemius/includes/i18n.php:181
1146
+ #, php-format
1147
+ msgctxt "%s - product name, e.g. Facebook add-on was successfully..."
1148
+ msgid "%s Add-on was successfully purchased."
1149
+ msgstr ""
1150
+
1151
+ #: classes/freemius/includes/i18n.php:182
1152
+ #, php-format
1153
+ msgid "Your %s Add-on plan was successfully upgraded."
1154
+ msgstr ""
1155
+
1156
+ #: classes/freemius/includes/i18n.php:183
1157
+ msgid "Your email has been successfully verified - you are AWESOME!"
1158
+ msgstr ""
1159
+
1160
+ #: classes/freemius/includes/i18n.php:184
1161
+ msgid "Your plan was successfully upgraded."
1162
+ msgstr ""
1163
+
1164
+ #: classes/freemius/includes/i18n.php:185
1165
+ #, php-format
1166
+ msgid "Your plan was successfully changed to %s."
1167
+ msgstr ""
1168
+
1169
+ #: classes/freemius/includes/i18n.php:186
1170
+ msgid ""
1171
+ "Your license has expired. You can still continue using the free plugin "
1172
+ "forever."
1173
+ msgstr ""
1174
+
1175
+ #: classes/freemius/includes/i18n.php:187
1176
+ msgid "Your trial has been successfully started."
1177
+ msgstr ""
1178
+
1179
+ #: classes/freemius/includes/i18n.php:188
1180
+ msgid "Your license was successfully activated."
1181
+ msgstr ""
1182
+
1183
+ #: classes/freemius/includes/i18n.php:189
1184
+ msgid "It looks like your site currently don't have an active license."
1185
+ msgstr ""
1186
+
1187
+ #: classes/freemius/includes/i18n.php:190
1188
+ #, php-format
1189
+ msgid "Your license was successfully deactivated, you are back to the %s plan."
1190
+ msgstr ""
1191
+
1192
+ #: classes/freemius/includes/i18n.php:191
1193
+ msgid "It looks like the license deactivation failed."
1194
+ msgstr ""
1195
+
1196
+ #: classes/freemius/includes/i18n.php:192
1197
+ msgid "It looks like the license could not be activated."
1198
+ msgstr ""
1199
+
1200
+ #: classes/freemius/includes/i18n.php:193
1201
+ msgid "Error received from the server:"
1202
+ msgstr ""
1203
+
1204
+ #: classes/freemius/includes/i18n.php:194
1205
+ msgid ""
1206
+ "Your trial has expired. You can still continue using all our free features."
1207
+ msgstr ""
1208
+
1209
+ #: classes/freemius/includes/i18n.php:195
1210
+ #, php-format
1211
+ msgid ""
1212
+ "Your plan was successfully downgraded. Your %s plan license will expire in "
1213
+ "%s."
1214
+ msgstr ""
1215
+
1216
+ #: classes/freemius/includes/i18n.php:196
1217
+ msgid ""
1218
+ "Seems like we are having some temporary issue with your plan downgrade. "
1219
+ "Please try again in few minutes."
1220
+ msgstr ""
1221
+
1222
+ #: classes/freemius/includes/i18n.php:197
1223
+ msgid ""
1224
+ "It looks like you are not in trial mode anymore so there's nothing to "
1225
+ "cancel :)"
1226
+ msgstr ""
1227
+
1228
+ #: classes/freemius/includes/i18n.php:198
1229
+ #, php-format
1230
+ msgid "Your %s Plan trial was successfully cancelled."
1231
+ msgstr ""
1232
+
1233
+ #: classes/freemius/includes/i18n.php:199
1234
+ #, php-format
1235
+ msgctxt "%s - numeric version number"
1236
+ msgid "Version %s was released."
1237
+ msgstr ""
1238
+
1239
+ #: classes/freemius/includes/i18n.php:200
1240
+ #, php-format
1241
+ msgid "Please download %s."
1242
+ msgstr ""
1243
+
1244
+ #: classes/freemius/includes/i18n.php:201
1245
+ #, php-format
1246
+ msgctxt "%s - plan name, as the latest professional version here"
1247
+ msgid "the latest %s version here"
1248
+ msgstr ""
1249
+
1250
+ #: classes/freemius/includes/i18n.php:202
1251
+ #, php-format
1252
+ msgid ""
1253
+ "How do you like %s so far? Test all our %s premium features with a %d-day "
1254
+ "free trial."
1255
+ msgstr ""
1256
+
1257
+ #: classes/freemius/includes/i18n.php:203
1258
+ msgctxt "call to action"
1259
+ msgid "Start free trial"
1260
+ msgstr ""
1261
+
1262
+ #: classes/freemius/includes/i18n.php:204
1263
+ msgid ""
1264
+ "Seems like we are having some temporary issue with your trial cancellation. "
1265
+ "Please try again in few minutes."
1266
+ msgstr ""
1267
+
1268
+ #: classes/freemius/includes/i18n.php:205
1269
+ #, php-format
1270
+ msgid "No commitment for %s days - cancel anytime!"
1271
+ msgstr ""
1272
+
1273
+ #: classes/freemius/includes/i18n.php:206
1274
+ #, php-format
1275
+ msgid ""
1276
+ "Your license has expired. You can still continue using all the %s features, "
1277
+ "but you'll need to renew your license to continue getting updates and "
1278
+ "support."
1279
+ msgstr ""
1280
+
1281
+ #: classes/freemius/includes/i18n.php:207
1282
+ #, php-format
1283
+ msgid "Couldn't activate %s."
1284
+ msgstr ""
1285
+
1286
+ #: classes/freemius/includes/i18n.php:208
1287
+ msgid "Please contact us with the following message:"
1288
+ msgstr ""
1289
+
1290
+ #: classes/freemius/includes/i18n.php:209
1291
+ msgid ""
1292
+ "It looks like your plan did't change. If you did upgrade, it's probably an "
1293
+ "issue on our side - sorry."
1294
+ msgstr ""
1295
+
1296
+ #: classes/freemius/includes/i18n.php:210
1297
+ msgid "Please contact us here"
1298
+ msgstr ""
1299
+
1300
+ #: classes/freemius/includes/i18n.php:211
1301
+ #, php-format
1302
+ msgid ""
1303
+ "I have upgraded my account but when I try to Sync the License, the plan "
1304
+ "remains %s."
1305
+ msgstr ""
1306
+
1307
+ #: classes/freemius/includes/i18n.php:214
1308
+ msgid "From unknown reason, the API connectivity test fails."
1309
+ msgstr ""
1310
+
1311
+ #: classes/freemius/includes/i18n.php:215
1312
+ msgid ""
1313
+ "We use PHP cURL library for the API calls, which is a very common library "
1314
+ "and usually installed out of the box. Unfortunately, cURL is not installed "
1315
+ "on your server."
1316
+ msgstr ""
1317
+
1318
+ #: classes/freemius/includes/i18n.php:216
1319
+ msgid ""
1320
+ "From unknown reason, CloudFlare, the firewall we use, blocks the connection."
1321
+ msgstr ""
1322
+
1323
+ #: classes/freemius/includes/i18n.php:217
1324
+ #, php-format
1325
+ msgctxt "as pluginX requires an access to our API"
1326
+ msgid "%s requires an access to our API."
1327
+ msgstr ""
1328
+
1329
+ #: classes/freemius/includes/i18n.php:218
1330
+ msgid ""
1331
+ "It looks like your server is using Squid ACL (access control lists), which "
1332
+ "blocks the connection."
1333
+ msgstr ""
1334
+
1335
+ #: classes/freemius/includes/i18n.php:219
1336
+ msgid "I don't know what is Squid or ACL, help me!"
1337
+ msgstr ""
1338
+
1339
+ #: classes/freemius/includes/i18n.php:220
1340
+ #: classes/freemius/includes/i18n.php:224
1341
+ #, php-format
1342
+ msgid ""
1343
+ "We'll make sure to contact your hosting company and resolve the issue. You "
1344
+ "will get a follow-up email to %s once we have an update."
1345
+ msgstr ""
1346
+
1347
+ #: classes/freemius/includes/i18n.php:221
1348
+ msgid "I'm a system administrator"
1349
+ msgstr ""
1350
+
1351
+ #: classes/freemius/includes/i18n.php:222
1352
+ #, php-format
1353
+ msgid ""
1354
+ "Great, please whitelist the following domains: %s. Once you done, deactivate "
1355
+ "the plugin and activate it again."
1356
+ msgstr ""
1357
+
1358
+ #: classes/freemius/includes/i18n.php:223
1359
+ msgid "I don't know what is cURL or how to install it, help me!"
1360
+ msgstr ""
1361
+
1362
+ #: classes/freemius/includes/i18n.php:225
1363
+ msgid ""
1364
+ "Great, please install cURL and enable it in your php.ini file. To make sure "
1365
+ "it was successfully activated, use 'phpinfo()'. Once activated, deactivate "
1366
+ "the plugin and reactivate it back again."
1367
+ msgstr ""
1368
+
1369
+ #: classes/freemius/includes/i18n.php:226
1370
+ msgid ""
1371
+ "We are sure it's an issue on our side and more than happy to resolve it for "
1372
+ "you ASAP if you give us a chance."
1373
+ msgstr ""
1374
+
1375
+ #: classes/freemius/includes/i18n.php:227
1376
+ msgid "Yes - I'm giving you a chance to fix it"
1377
+ msgstr ""
1378
+
1379
+ #: classes/freemius/includes/i18n.php:228
1380
+ #, php-format
1381
+ msgid ""
1382
+ "We will do our best to whitelist your server and resolve this issue ASAP. "
1383
+ "You will get a follow-up email to %s once we have an update."
1384
+ msgstr ""
1385
+
1386
+ #: classes/freemius/includes/i18n.php:229
1387
+ msgid "Let's try your previous version"
1388
+ msgstr ""
1389
+
1390
+ #: classes/freemius/includes/i18n.php:230
1391
+ msgid "Uninstall this version and install the previous one."
1392
+ msgstr ""
1393
+
1394
+ #: classes/freemius/includes/i18n.php:231
1395
+ msgid "That's exhausting, please deactivate"
1396
+ msgstr ""
1397
+
1398
+ #: classes/freemius/includes/i18n.php:232
1399
+ msgid ""
1400
+ "We feel your frustration and sincerely apologize for the inconvenience. Hope "
1401
+ "to see you again in the future."
1402
+ msgstr ""
1403
+
1404
+ #: classes/freemius/includes/i18n.php:233
1405
+ #, php-format
1406
+ msgid ""
1407
+ "Thank for giving us the chance to fix it! A message was just sent to our "
1408
+ "technical staff. We will get back to you as soon as we have an update to %s. "
1409
+ "Appreciate your patience."
1410
+ msgstr ""
1411
+
1412
+ #: classes/freemius/includes/i18n.php:234
1413
+ #, php-format
1414
+ msgctxt "%1s - plugin title, %2s - API domain"
1415
+ msgid ""
1416
+ "Your server is blocking the access to Freemius' API, which is crucial for "
1417
+ "%1s license synchronization. Please contact your host to whitelist %2s"
1418
+ msgstr ""
1419
+
1420
+ #: classes/freemius/includes/i18n.php:235
1421
+ msgid ""
1422
+ "It seems like one of the authentication parameters is wrong. Update your "
1423
+ "Public Key, Secret Key & User ID, and try again."
1424
+ msgstr ""
1425
+
1426
+ #: classes/freemius/includes/i18n.php:238
1427
+ #, php-format
1428
+ msgid ""
1429
+ "Please check your mailbox, you should receive an email via %s to confirm the "
1430
+ "ownership change. From security reasons, you must confirm the change within "
1431
+ "the next 15 min. If you cannot find the email, please check your spam folder."
1432
+ msgstr ""
1433
+
1434
+ #: classes/freemius/includes/i18n.php:239
1435
+ #, php-format
1436
+ msgid ""
1437
+ "Thanks for confirming the ownership change. An email was just sent to %s for "
1438
+ "final approval."
1439
+ msgstr ""
1440
+
1441
+ #: classes/freemius/includes/i18n.php:240
1442
+ #, php-format
1443
+ msgid "%s is the new owner of the account."
1444
+ msgstr ""
1445
+
1446
+ #: classes/freemius/includes/i18n.php:242
1447
+ msgid "Freemius Debug"
1448
+ msgstr ""
1449
+
1450
+ #: classes/freemius/includes/i18n.php:243
1451
+ #, php-format
1452
+ msgctxt "addonX cannot run without pluginY"
1453
+ msgid "%s cannot run without %s."
1454
+ msgstr ""
1455
+
1456
+ #: classes/freemius/includes/i18n.php:244
1457
+ #, php-format
1458
+ msgctxt "addonX cannot run..."
1459
+ msgid "%s cannot run without the plugin."
1460
+ msgstr ""
1461
+
1462
+ #: classes/freemius/includes/i18n.php:245
1463
+ #, php-format
1464
+ msgctxt "pluginX activation was successfully..."
1465
+ msgid "%s activation was successfully completed."
1466
+ msgstr ""
1467
+
1468
+ #: classes/freemius/includes/i18n.php:246
1469
+ msgctxt "Plugin installer section title"
1470
+ msgid "Features & Pricing"
1471
+ msgstr ""
1472
+
1473
+ #: classes/freemius/templates/account.php:274
1474
+ msgctxt "verb"
1475
+ msgid "Edit"
1476
+ msgstr ""
1477
+
1478
+ #: hooks/class-aal-hook-posts.php:10
1479
+ msgid "(no title)"
1480
+ msgstr ""
1481
+
1482
+ #: language/strings.php:6
1483
+ msgid ""
1484
+ "Get aware of any activities that are taking place on your dashboard! Imagine "
1485
+ "it like a black-box for your WordPress site. e.g. post was deleted, plugin "
1486
+ "was activated, user logged in or logged out - it's all these for you to see."
1487
+ msgstr ""
1488
+
1489
+ #: language/strings.php:8
1490
+ msgid "Administrator"
1491
+ msgstr ""
1492
+
1493
+ #: language/strings.php:9
1494
+ msgid "Editor"
1495
+ msgstr ""
1496
+
1497
+ #: language/strings.php:12
1498
+ msgid "Post"
1499
+ msgstr ""
1500
+
1501
+ #: language/strings.php:13
1502
+ msgid "created"
1503
+ msgstr ""
1504
+
1505
+ #: language/strings.php:14
1506
+ msgid "updated"
1507
+ msgstr ""
1508
+
1509
+ #: language/strings.php:15
1510
+ msgid "deleted"
1511
+ msgstr ""
1512
+
1513
+ #: language/strings.php:16
1514
+ msgid "trashed"
1515
+ msgstr ""
1516
+
1517
+ #: language/strings.php:19
1518
+ msgid "Attachment"
1519
+ msgstr ""
1520
+
1521
+ #: language/strings.php:20
1522
+ msgid "added"
1523
+ msgstr ""
1524
+
1525
+ #: language/strings.php:24
1526
+ msgid "logged_out"
1527
+ msgstr ""
1528
+
1529
+ #: language/strings.php:25
1530
+ msgid "logged_in"
1531
+ msgstr ""
1532
+
1533
+ #: language/strings.php:26
1534
+ msgid "wrong_password"
1535
+ msgstr ""
1536
+
1537
+ #: language/strings.php:30
1538
+ msgid "activated"
1539
+ msgstr ""
1540
+
1541
+ #: language/strings.php:31
1542
+ msgid "deactivated"
1543
+ msgstr ""
1544
+
1545
+ #: language/strings.php:32
1546
+ msgid "installed"
1547
+ msgstr ""
1548
+
1549
+ #: language/strings.php:33
1550
+ msgid "File Updated"
1551
+ msgstr ""
1552
+
1553
+ #: language/strings.php:36
1554
+ msgid "Theme"
1555
+ msgstr ""
1556
+
1557
+ #: language/strings.php:37
1558
+ msgid "Theme Customizer"
1559
+ msgstr ""
1560
+
1561
+ #: language/strings.php:40
1562
+ msgid "Widget"
1563
+ msgstr ""
1564
+
1565
+ #: language/strings.php:43
1566
+ msgid "Options"
1567
+ msgstr ""
1568
+
1569
+ #: language/strings.php:46
1570
+ msgid "Menu"
1571
+ msgstr ""
1572
+
1573
+ #: language/strings.php:49
1574
+ msgid "Taxonomy"
1575
+ msgstr ""
1576
+
1577
+ #: language/strings.php:52
1578
+ msgid "Core"
1579
+ msgstr ""
1580
+
1581
+ #: language/strings.php:53
1582
+ msgid "WordPress Updated"
1583
+ msgstr ""
1584
+
1585
+ #: language/strings.php:54
1586
+ msgid "WordPress Auto Updated"
1587
+ msgstr ""
1588
+
1589
+ #: language/strings.php:57
1590
+ msgid "Comments"
1591
+ msgstr ""
1592
+
1593
+ #: language/strings.php:58
1594
+ msgid "pending"
1595
+ msgstr ""
1596
+
1597
+ #: language/strings.php:59
1598
+ msgid "approved"
1599
+ msgstr ""
1600
+
1601
+ #: language/strings.php:60
1602
+ msgid "unapproved"
1603
+ msgstr ""
1604
+
1605
+ #: language/strings.php:61
1606
+ msgid "untrashed"
1607
+ msgstr ""
1608
+
1609
+ #: language/strings.php:62
1610
+ msgid "spammed"
1611
+ msgstr ""
1612
+
1613
+ #: language/strings.php:63
1614
+ msgid "unspammed"
1615
+ msgstr ""
1616
+
1617
+ #: language/strings.php:68
1618
+ msgid "blogname"
1619
+ msgstr ""
1620
+
1621
+ #: language/strings.php:69
1622
+ msgid "blogdescription"
1623
+ msgstr ""
1624
+
1625
+ #: language/strings.php:70
1626
+ msgid "siteurl"
1627
+ msgstr ""
1628
+
1629
+ #: language/strings.php:71
1630
+ msgid "home"
1631
+ msgstr ""
1632
+
1633
+ #: language/strings.php:72
1634
+ msgid "admin_email"
1635
+ msgstr ""
1636
+
1637
+ #: language/strings.php:73
1638
+ msgid "users_can_register"
1639
+ msgstr ""
1640
+
1641
+ #: language/strings.php:74
1642
+ msgid "default_role"
1643
+ msgstr ""
1644
+
1645
+ #: language/strings.php:75
1646
+ msgid "timezone_string"
1647
+ msgstr ""
1648
+
1649
+ #: language/strings.php:76
1650
+ msgid "date_format"
1651
+ msgstr ""
1652
+
1653
+ #: language/strings.php:77
1654
+ msgid "time_format"
1655
+ msgstr ""
1656
+
1657
+ #: language/strings.php:78
1658
+ msgid "start_of_week"
1659
+ msgstr ""
1660
+
1661
+ #: language/strings.php:81
1662
+ msgid "use_smilies"
1663
+ msgstr ""
1664
+
1665
+ #: language/strings.php:82
1666
+ msgid "use_balanceTags"
1667
+ msgstr ""
1668
+
1669
+ #: language/strings.php:83
1670
+ msgid "default_category"
1671
+ msgstr ""
1672
+
1673
+ #: language/strings.php:84
1674
+ msgid "default_post_format"
1675
+ msgstr ""
1676
+
1677
+ #: language/strings.php:85
1678
+ msgid "mailserver_url"
1679
+ msgstr ""
1680
+
1681
+ #: language/strings.php:86
1682
+ msgid "mailserver_login"
1683
+ msgstr ""
1684
+
1685
+ #: language/strings.php:87
1686
+ msgid "mailserver_pass"
1687
+ msgstr ""
1688
+
1689
+ #: language/strings.php:88
1690
+ msgid "default_email_category"
1691
+ msgstr ""
1692
+
1693
+ #: language/strings.php:89
1694
+ msgid "ping_sites"
1695
+ msgstr ""
1696
+
1697
+ #: language/strings.php:92
1698
+ msgid "show_on_front"
1699
+ msgstr ""
1700
+
1701
+ #: language/strings.php:93
1702
+ msgid "page_on_front"
1703
+ msgstr ""
1704
+
1705
+ #: language/strings.php:94
1706
+ msgid "page_for_posts"
1707
+ msgstr ""
1708
+
1709
+ #: language/strings.php:95
1710
+ msgid "posts_per_page"
1711
+ msgstr ""
1712
+
1713
+ #: language/strings.php:96
1714
+ msgid "posts_per_rss"
1715
+ msgstr ""
1716
+
1717
+ #: language/strings.php:97
1718
+ msgid "rss_use_excerpt"
1719
+ msgstr ""
1720
+
1721
+ #: language/strings.php:98
1722
+ msgid "blog_public"
1723
+ msgstr ""
1724
+
1725
+ #: language/strings.php:101
1726
+ msgid "default_pingback_flag"
1727
+ msgstr ""
1728
+
1729
+ #: language/strings.php:102
1730
+ msgid "default_ping_status"
1731
+ msgstr ""
1732
+
1733
+ #: language/strings.php:103
1734
+ msgid "default_comment_status"
1735
+ msgstr ""
1736
+
1737
+ #: language/strings.php:104
1738
+ msgid "require_name_email"
1739
+ msgstr ""
1740
+
1741
+ #: language/strings.php:105
1742
+ msgid "comment_registration"
1743
+ msgstr ""
1744
+
1745
+ #: language/strings.php:106
1746
+ msgid "close_comments_for_old_posts"
1747
+ msgstr ""
1748
+
1749
+ #: language/strings.php:107
1750
+ msgid "close_comments_days_old"
1751
+ msgstr ""
1752
+
1753
+ #: language/strings.php:108
1754
+ msgid "thread_comments"
1755
+ msgstr ""
1756
+
1757
+ #: language/strings.php:109
1758
+ msgid "thread_comments_depth"
1759
+ msgstr ""
1760
+
1761
+ #: language/strings.php:110
1762
+ msgid "page_comments"
1763
+ msgstr ""
1764
+
1765
+ #: language/strings.php:111
1766
+ msgid "comments_per_page"
1767
+ msgstr ""
1768
+
1769
+ #: language/strings.php:112
1770
+ msgid "default_comments_page"
1771
+ msgstr ""
1772
+
1773
+ #: language/strings.php:113
1774
+ msgid "comment_order"
1775
+ msgstr ""
1776
+
1777
+ #: language/strings.php:114
1778
+ msgid "comments_notify"
1779
+ msgstr ""
1780
+
1781
+ #: language/strings.php:115
1782
+ msgid "moderation_notify"
1783
+ msgstr ""
1784
+
1785
+ #: language/strings.php:116
1786
+ msgid "comment_moderation"
1787
+ msgstr ""
1788
+
1789
+ #: language/strings.php:117
1790
+ msgid "comment_whitelist"
1791
+ msgstr ""
1792
+
1793
+ #: language/strings.php:118
1794
+ msgid "comment_max_links"
1795
+ msgstr ""
1796
+
1797
+ #: language/strings.php:119
1798
+ msgid "moderation_keys"
1799
+ msgstr ""
1800
+
1801
+ #: language/strings.php:120
1802
+ msgid "blacklist_keys"
1803
+ msgstr ""
1804
+
1805
+ #: language/strings.php:121
1806
+ msgid "show_avatars"
1807
+ msgstr ""
1808
+
1809
+ #: language/strings.php:122
1810
+ msgid "avatar_rating"
1811
+ msgstr ""
1812
+
1813
+ #: language/strings.php:123
1814
+ msgid "avatar_default"
1815
+ msgstr ""
1816
+
1817
+ #: language/strings.php:126
1818
+ msgid "thumbnail_size_w"
1819
+ msgstr ""
1820
+
1821
+ #: language/strings.php:127
1822
+ msgid "thumbnail_size_h"
1823
+ msgstr ""
1824
+
1825
+ #: language/strings.php:128
1826
+ msgid "thumbnail_crop"
1827
+ msgstr ""
1828
+
1829
+ #: language/strings.php:129
1830
+ msgid "medium_size_w"
1831
+ msgstr ""
1832
+
1833
+ #: language/strings.php:130
1834
+ msgid "medium_size_h"
1835
+ msgstr ""
1836
+
1837
+ #: language/strings.php:131
1838
+ msgid "large_size_w"
1839
+ msgstr ""
1840
+
1841
+ #: language/strings.php:132
1842
+ msgid "large_size_h"
1843
+ msgstr ""
1844
+
1845
+ #: language/strings.php:133
1846
+ msgid "uploads_use_yearmonth_folders"
1847
+ msgstr ""
1848
+
1849
+ #: language/strings.php:136
1850
+ msgid "permalink_structure"
1851
+ msgstr ""
1852
+
1853
+ #: language/strings.php:137
1854
+ msgid "category_base"
1855
+ msgstr ""
1856
+
1857
+ #: language/strings.php:138
1858
+ msgid "tag_base"
1859
+ msgstr ""
1860
+
1861
+ #: language/strings.php:141
1862
+ msgid "Export"
1863
+ msgstr ""
1864
+
1865
+ #: language/strings.php:142
1866
+ msgid "downloaded"
1867
+ msgstr ""
1868
+
1869
+ #: notifications/abstract-class-aal-notification-base.php:99
1870
+ msgid "Object Type"
1871
+ msgstr ""
1872
+
1873
+ #: notifications/abstract-class-aal-notification-base.php:100
1874
+ msgid "Object Name"
1875
+ msgstr ""
1876
+
1877
+ #: notifications/abstract-class-aal-notification-base.php:102
1878
+ msgid "IP Address"
1879
+ msgstr ""
1880
+
1881
+ #: notifications/abstract-class-aal-notification-base.php:121
1882
+ msgid "N/A"
1883
+ msgstr ""
1884
+
1885
+ #: notifications/class-aal-notification-email.php:16
1886
+ msgid "Get notified by Email."
1887
+ msgstr ""
1888
+
1889
+ #: notifications/class-aal-notification-email.php:49
1890
+ msgid "New notification from Activity Log"
1891
+ msgstr ""
1892
+
1893
+ #: notifications/class-aal-notification-email.php:65
1894
+ msgid ""
1895
+ "Hi there!\n"
1896
+ "\n"
1897
+ "A notification condition on [sitename] was matched. Here are the details:\n"
1898
+ "\n"
1899
+ "[action-details]\n"
1900
+ "\n"
1901
+ "Sent by ARYO Activity Log"
1902
+ msgstr ""
1903
+
1904
+ #: notifications/class-aal-notification-email.php:67
1905
+ msgid "From Email"
1906
+ msgstr ""
1907
+
1908
+ #: notifications/class-aal-notification-email.php:67
1909
+ msgid "The source Email address"
1910
+ msgstr ""
1911
+
1912
+ #: notifications/class-aal-notification-email.php:68
1913
+ msgid "To Email"
1914
+ msgstr ""
1915
+
1916
+ #: notifications/class-aal-notification-email.php:68
1917
+ msgid "The Email address notifications will be sent to"
1918
+ msgstr ""
1919
+
1920
+ #: notifications/class-aal-notification-email.php:69
1921
+ msgid "Message"
1922
+ msgstr ""
1923
+
1924
+ #: notifications/class-aal-notification-email.php:69
1925
+ #, php-format
1926
+ msgid "Customize the message using the following placeholders: %s"
1927
+ msgstr ""
language/strings.php CHANGED
@@ -2,141 +2,141 @@
2
 
3
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
 
5
- __( 'Activity Log', 'aryo-aal' );
6
- __( 'Get aware of any activities that are taking place on your dashboard! Imagine it like a black-box for your WordPress site. e.g. post was deleted, plugin was activated, user logged in or logged out - it\'s all these for you to see.', 'aryo-aal' );
7
 
8
- __( 'Administrator', 'aryo-aal' );
9
- __( 'Editor', 'aryo-aal' );
10
 
11
  // Post
12
- __( 'Post', 'aryo-aal' );
13
- __( 'created', 'aryo-aal' );
14
- __( 'updated', 'aryo-aal' );
15
- __( 'deleted', 'aryo-aal' );
 
16
 
17
  // Attachment
18
- __( 'Attachment', 'aryo-aal' );
19
- __( 'added', 'aryo-aal' );
20
 
21
  // User
22
- __( 'User', 'aryo-aal' );
23
- __( 'logged_out', 'aryo-aal' );
24
- __( 'logged_in', 'aryo-aal' );
25
- __( 'wrong_password', 'aryo-aal' );
26
 
27
  // Plugin
28
- __( 'Plugin', 'aryo-aal' );
29
- __( 'activated', 'aryo-aal' );
30
- __( 'deactivated', 'aryo-aal' );
31
- __( 'installed', 'aryo-aal' );
32
- __( 'File Updated', 'aryo-aal' );
33
 
34
  // Theme
35
- __( 'Theme', 'aryo-aal' );
36
- __( 'Theme Customizer', 'aryo-aal' );
37
 
38
  // Widget
39
- __( 'Widget', 'aryo-aal' );
40
 
41
  // Options
42
- __( 'Options', 'aryo-aal' );
43
 
44
  // Menu
45
- __( 'Menu', 'aryo-aal' );
46
 
47
  // Taxonomy
48
- __( 'Taxonomy', 'aryo-aal' );
49
 
50
  // Core
51
- __( 'Core', 'aryo-aal' );
52
- __( 'WordPress Updated', 'aryo-aal' );
53
- __( 'WordPress Auto Updated', 'aryo-aal' );
54
 
55
  // Comments
56
- __( 'Comments', 'aryo-aal' );
57
- __( 'pending', 'aryo-aal' );
58
- __( 'approved', 'aryo-aal' );
59
- __( 'unapproved', 'aryo-aal' );
60
- __( 'trashed', 'aryo-aal' );
61
- __( 'untrashed', 'aryo-aal' );
62
- __( 'spammed', 'aryo-aal' );
63
- __( 'unspammed', 'aryo-aal' );
64
 
65
 
66
 
67
  // Translate Options?
68
- __( 'blogname', 'aryo-aal' );
69
- __( 'blogdescription', 'aryo-aal' );
70
- __( 'siteurl', 'aryo-aal' );
71
- __( 'home', 'aryo-aal' );
72
- __( 'admin_email', 'aryo-aal' );
73
- __( 'users_can_register', 'aryo-aal' );
74
- __( 'default_role', 'aryo-aal' );
75
- __( 'timezone_string', 'aryo-aal' );
76
- __( 'date_format', 'aryo-aal' );
77
- __( 'time_format', 'aryo-aal' );
78
- __( 'start_of_week', 'aryo-aal' );
79
 
80
  // Writing
81
- __( 'use_smilies', 'aryo-aal' );
82
- __( 'use_balanceTags', 'aryo-aal' );
83
- __( 'default_category', 'aryo-aal' );
84
- __( 'default_post_format', 'aryo-aal' );
85
- __( 'mailserver_url', 'aryo-aal' );
86
- __( 'mailserver_login', 'aryo-aal' );
87
- __( 'mailserver_pass', 'aryo-aal' );
88
- __( 'default_email_category', 'aryo-aal' );
89
- __( 'ping_sites', 'aryo-aal' );
90
 
91
  // Reading
92
- __( 'show_on_front', 'aryo-aal' );
93
- __( 'page_on_front', 'aryo-aal' );
94
- __( 'page_for_posts', 'aryo-aal' );
95
- __( 'posts_per_page', 'aryo-aal' );
96
- __( 'posts_per_rss', 'aryo-aal' );
97
- __( 'rss_use_excerpt', 'aryo-aal' );
98
- __( 'blog_public', 'aryo-aal' );
99
 
100
  // Discussion
101
- __( 'default_pingback_flag', 'aryo-aal' );
102
- __( 'default_ping_status', 'aryo-aal' );
103
- __( 'default_comment_status', 'aryo-aal' );
104
- __( 'require_name_email', 'aryo-aal' );
105
- __( 'comment_registration', 'aryo-aal' );
106
- __( 'close_comments_for_old_posts', 'aryo-aal' );
107
- __( 'close_comments_days_old', 'aryo-aal' );
108
- __( 'thread_comments', 'aryo-aal' );
109
- __( 'thread_comments_depth', 'aryo-aal' );
110
- __( 'page_comments', 'aryo-aal' );
111
- __( 'comments_per_page', 'aryo-aal' );
112
- __( 'default_comments_page', 'aryo-aal' );
113
- __( 'comment_order', 'aryo-aal' );
114
- __( 'comments_notify', 'aryo-aal' );
115
- __( 'moderation_notify', 'aryo-aal' );
116
- __( 'comment_moderation', 'aryo-aal' );
117
- __( 'comment_whitelist', 'aryo-aal' );
118
- __( 'comment_max_links', 'aryo-aal' );
119
- __( 'moderation_keys', 'aryo-aal' );
120
- __( 'blacklist_keys', 'aryo-aal' );
121
- __( 'show_avatars', 'aryo-aal' );
122
- __( 'avatar_rating', 'aryo-aal' );
123
- __( 'avatar_default', 'aryo-aal' );
124
 
125
  // Media
126
- __( 'thumbnail_size_w', 'aryo-aal' );
127
- __( 'thumbnail_size_h', 'aryo-aal' );
128
- __( 'thumbnail_crop', 'aryo-aal' );
129
- __( 'medium_size_w', 'aryo-aal' );
130
- __( 'medium_size_h', 'aryo-aal' );
131
- __( 'large_size_w', 'aryo-aal' );
132
- __( 'large_size_h', 'aryo-aal' );
133
- __( 'uploads_use_yearmonth_folders', 'aryo-aal' );
134
 
135
  // Permalinks
136
- __( 'permalink_structure', 'aryo-aal' );
137
- __( 'category_base', 'aryo-aal' );
138
- __( 'tag_base', 'aryo-aal' );
139
 
140
  // Export
141
- __( 'Export', 'aryo-aal' );
142
- __( 'downloaded', 'aryo-aal' );
2
 
3
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
 
5
+ __( 'Activity Log', 'aryo-activity-log' );
6
+ __( 'Get aware of any activities that are taking place on your dashboard! Imagine it like a black-box for your WordPress site. e.g. post was deleted, plugin was activated, user logged in or logged out - it\'s all these for you to see.', 'aryo-activity-log' );
7
 
8
+ __( 'Administrator', 'aryo-activity-log' );
9
+ __( 'Editor', 'aryo-activity-log' );
10
 
11
  // Post
12
+ __( 'Post', 'aryo-activity-log' );
13
+ __( 'created', 'aryo-activity-log' );
14
+ __( 'updated', 'aryo-activity-log' );
15
+ __( 'deleted', 'aryo-activity-log' );
16
+ __( 'trashed', 'aryo-activity-log' );
17
 
18
  // Attachment
19
+ __( 'Attachment', 'aryo-activity-log' );
20
+ __( 'added', 'aryo-activity-log' );
21
 
22
  // User
23
+ __( 'User', 'aryo-activity-log' );
24
+ __( 'logged_out', 'aryo-activity-log' );
25
+ __( 'logged_in', 'aryo-activity-log' );
26
+ __( 'wrong_password', 'aryo-activity-log' );
27
 
28
  // Plugin
29
+ __( 'Plugin', 'aryo-activity-log' );
30
+ __( 'activated', 'aryo-activity-log' );
31
+ __( 'deactivated', 'aryo-activity-log' );
32
+ __( 'installed', 'aryo-activity-log' );
33
+ __( 'File Updated', 'aryo-activity-log' );
34
 
35
  // Theme
36
+ __( 'Theme', 'aryo-activity-log' );
37
+ __( 'Theme Customizer', 'aryo-activity-log' );
38
 
39
  // Widget
40
+ __( 'Widget', 'aryo-activity-log' );
41
 
42
  // Options
43
+ __( 'Options', 'aryo-activity-log' );
44
 
45
  // Menu
46
+ __( 'Menu', 'aryo-activity-log' );
47
 
48
  // Taxonomy
49
+ __( 'Taxonomy', 'aryo-activity-log' );
50
 
51
  // Core
52
+ __( 'Core', 'aryo-activity-log' );
53
+ __( 'WordPress Updated', 'aryo-activity-log' );
54
+ __( 'WordPress Auto Updated', 'aryo-activity-log' );
55
 
56
  // Comments
57
+ __( 'Comments', 'aryo-activity-log' );
58
+ __( 'pending', 'aryo-activity-log' );
59
+ __( 'approved', 'aryo-activity-log' );
60
+ __( 'unapproved', 'aryo-activity-log' );
61
+ __( 'untrashed', 'aryo-activity-log' );
62
+ __( 'spammed', 'aryo-activity-log' );
63
+ __( 'unspammed', 'aryo-activity-log' );
 
64
 
65
 
66
 
67
  // Translate Options?
68
+ __( 'blogname', 'aryo-activity-log' );
69
+ __( 'blogdescription', 'aryo-activity-log' );
70
+ __( 'siteurl', 'aryo-activity-log' );
71
+ __( 'home', 'aryo-activity-log' );
72
+ __( 'admin_email', 'aryo-activity-log' );
73
+ __( 'users_can_register', 'aryo-activity-log' );
74
+ __( 'default_role', 'aryo-activity-log' );
75
+ __( 'timezone_string', 'aryo-activity-log' );
76
+ __( 'date_format', 'aryo-activity-log' );
77
+ __( 'time_format', 'aryo-activity-log' );
78
+ __( 'start_of_week', 'aryo-activity-log' );
79
 
80
  // Writing
81
+ __( 'use_smilies', 'aryo-activity-log' );
82
+ __( 'use_balanceTags', 'aryo-activity-log' );
83
+ __( 'default_category', 'aryo-activity-log' );
84
+ __( 'default_post_format', 'aryo-activity-log' );
85
+ __( 'mailserver_url', 'aryo-activity-log' );
86
+ __( 'mailserver_login', 'aryo-activity-log' );
87
+ __( 'mailserver_pass', 'aryo-activity-log' );
88
+ __( 'default_email_category', 'aryo-activity-log' );
89
+ __( 'ping_sites', 'aryo-activity-log' );
90
 
91
  // Reading
92
+ __( 'show_on_front', 'aryo-activity-log' );
93
+ __( 'page_on_front', 'aryo-activity-log' );
94
+ __( 'page_for_posts', 'aryo-activity-log' );
95
+ __( 'posts_per_page', 'aryo-activity-log' );
96
+ __( 'posts_per_rss', 'aryo-activity-log' );
97
+ __( 'rss_use_excerpt', 'aryo-activity-log' );
98
+ __( 'blog_public', 'aryo-activity-log' );
99
 
100
  // Discussion
101
+ __( 'default_pingback_flag', 'aryo-activity-log' );
102
+ __( 'default_ping_status', 'aryo-activity-log' );
103
+ __( 'default_comment_status', 'aryo-activity-log' );
104
+ __( 'require_name_email', 'aryo-activity-log' );
105
+ __( 'comment_registration', 'aryo-activity-log' );
106
+ __( 'close_comments_for_old_posts', 'aryo-activity-log' );
107
+ __( 'close_comments_days_old', 'aryo-activity-log' );
108
+ __( 'thread_comments', 'aryo-activity-log' );
109
+ __( 'thread_comments_depth', 'aryo-activity-log' );
110
+ __( 'page_comments', 'aryo-activity-log' );
111
+ __( 'comments_per_page', 'aryo-activity-log' );
112
+ __( 'default_comments_page', 'aryo-activity-log' );
113
+ __( 'comment_order', 'aryo-activity-log' );
114
+ __( 'comments_notify', 'aryo-activity-log' );
115
+ __( 'moderation_notify', 'aryo-activity-log' );
116
+ __( 'comment_moderation', 'aryo-activity-log' );
117
+ __( 'comment_whitelist', 'aryo-activity-log' );
118
+ __( 'comment_max_links', 'aryo-activity-log' );
119
+ __( 'moderation_keys', 'aryo-activity-log' );
120
+ __( 'blacklist_keys', 'aryo-activity-log' );
121
+ __( 'show_avatars', 'aryo-activity-log' );
122
+ __( 'avatar_rating', 'aryo-activity-log' );
123
+ __( 'avatar_default', 'aryo-activity-log' );
124
 
125
  // Media
126
+ __( 'thumbnail_size_w', 'aryo-activity-log' );
127
+ __( 'thumbnail_size_h', 'aryo-activity-log' );
128
+ __( 'thumbnail_crop', 'aryo-activity-log' );
129
+ __( 'medium_size_w', 'aryo-activity-log' );
130
+ __( 'medium_size_h', 'aryo-activity-log' );
131
+ __( 'large_size_w', 'aryo-activity-log' );
132
+ __( 'large_size_h', 'aryo-activity-log' );
133
+ __( 'uploads_use_yearmonth_folders', 'aryo-activity-log' );
134
 
135
  // Permalinks
136
+ __( 'permalink_structure', 'aryo-activity-log' );
137
+ __( 'category_base', 'aryo-activity-log' );
138
+ __( 'tag_base', 'aryo-activity-log' );
139
 
140
  // Export
141
+ __( 'Export', 'aryo-activity-log' );
142
+ __( 'downloaded', 'aryo-activity-log' );
notifications/abstract-class-aal-notification-base.php CHANGED
@@ -95,11 +95,11 @@ abstract class AAL_Notification_Base {
95
 
96
  public function prep_notification_body( $args ) {
97
  $details_to_provide = array(
98
- 'user_id' => __( 'User', 'aryo-aal' ),
99
- 'object_type' => __( 'Object Type', 'aryo-aal' ),
100
- 'object_name' => __( 'Object Name', 'aryo-aal' ),
101
- 'action' => __( 'Action Type', 'aryo-aal' ),
102
- 'hist_ip' => __( 'IP Address', 'aryo-aal' ),
103
  );
104
  $message = '';
105
 
@@ -118,7 +118,7 @@ abstract class AAL_Notification_Base {
118
  }
119
  break;
120
  default:
121
- $detail_val = isset( $args[ $detail_key ] ) ? $args[ $detail_key ] : __( 'N/A', 'aryo-aal' );
122
  break;
123
  }
124
 
95
 
96
  public function prep_notification_body( $args ) {
97
  $details_to_provide = array(
98
+ 'user_id' => __( 'User', 'aryo-activity-log' ),
99
+ 'object_type' => __( 'Object Type', 'aryo-activity-log' ),
100
+ 'object_name' => __( 'Object Name', 'aryo-activity-log' ),
101
+ 'action' => __( 'Action Type', 'aryo-activity-log' ),
102
+ 'hist_ip' => __( 'IP Address', 'aryo-activity-log' ),
103
  );
104
  $message = '';
105
 
118
  }
119
  break;
120
  default:
121
+ $detail_val = isset( $args[ $detail_key ] ) ? $args[ $detail_key ] : __( 'N/A', 'aryo-activity-log' );
122
  break;
123
  }
124
 
notifications/class-aal-notification-email.php CHANGED
@@ -12,14 +12,14 @@ class AAL_Notification_Email extends AAL_Notification_Base {
12
  parent::__construct();
13
 
14
  $this->id = 'email';
15
- $this->name = __( 'Email', 'aryo-aal' );
16
- $this->description = __( 'Get notified by Email.', 'aryo-aal' );
17
  }
18
 
19
  public function init() {
20
  $this->options = array_merge( array(
21
  'from_email' => get_option( 'admin_email' ),
22
- // 'message_format' => __( "Hi there!\n\nA notification condition on [sitename] was matched. Here are the details:\n\n[action-details]\n\nSent by ARYO Activity Log", 'aryo-aal' )
23
  ), $this->get_handler_options() );
24
  }
25
 
@@ -46,7 +46,7 @@ class AAL_Notification_Email extends AAL_Notification_Base {
46
 
47
  wp_mail(
48
  $to_email,
49
- __( 'New notification from Activity Log', 'aryo-aal' ),
50
  nl2br( $email_contents ),
51
  array(
52
  "From: Activity Log @ $site_name <$from_email>"
@@ -62,11 +62,11 @@ class AAL_Notification_Email extends AAL_Notification_Base {
62
  }
63
 
64
  public function settings_fields() {
65
- $default_email_message = __( "Hi there!\n\nA notification condition on [sitename] was matched. Here are the details:\n\n[action-details]\n\nSent by ARYO Activity Log", 'aryo-aal' );
66
 
67
- $this->add_settings_field_helper( 'from_email', __( 'From Email', 'aryo-aal' ), array( 'AAL_Settings_Fields', 'text_field' ), __( 'The source Email address', 'aryo-aal' ) );
68
- $this->add_settings_field_helper( 'to_email', __( 'To Email', 'aryo-aal' ), array( 'AAL_Settings_Fields', 'text_field' ), __( 'The Email address notifications will be sent to', 'aryo-aal' ) );
69
- $this->add_settings_field_helper( 'message_format', __( 'Message', 'aryo-aal' ), array( 'AAL_Settings_Fields', 'textarea_field' ), sprintf( __( 'Customize the message using the following placeholders: %s', 'aryo-aal' ), '[sitename], [action-details]' ), $default_email_message );
70
  }
71
 
72
  public function validate_options( $input ) {
12
  parent::__construct();
13
 
14
  $this->id = 'email';
15
+ $this->name = __( 'Email', 'aryo-activity-log' );
16
+ $this->description = __( 'Get notified by Email.', 'aryo-activity-log' );
17
  }
18
 
19
  public function init() {
20
  $this->options = array_merge( array(
21
  'from_email' => get_option( 'admin_email' ),
22
+ // 'message_format' => __( "Hi there!\n\nA notification condition on [sitename] was matched. Here are the details:\n\n[action-details]\n\nSent by ARYO Activity Log", 'aryo-activity-log' )
23
  ), $this->get_handler_options() );
24
  }
25
 
46
 
47
  wp_mail(
48
  $to_email,
49
+ __( 'New notification from Activity Log', 'aryo-activity-log' ),
50
  nl2br( $email_contents ),
51
  array(
52
  "From: Activity Log @ $site_name <$from_email>"
62
  }
63
 
64
  public function settings_fields() {
65
+ $default_email_message = __( "Hi there!\n\nA notification condition on [sitename] was matched. Here are the details:\n\n[action-details]\n\nSent by ARYO Activity Log", 'aryo-activity-log' );
66
 
67
+ $this->add_settings_field_helper( 'from_email', __( 'From Email', 'aryo-activity-log' ), array( 'AAL_Settings_Fields', 'text_field' ), __( 'The source Email address', 'aryo-activity-log' ) );
68
+ $this->add_settings_field_helper( 'to_email', __( 'To Email', 'aryo-activity-log' ), array( 'AAL_Settings_Fields', 'text_field' ), __( 'The Email address notifications will be sent to', 'aryo-activity-log' ) );
69
+ $this->add_settings_field_helper( 'message_format', __( 'Message', 'aryo-activity-log' ), array( 'AAL_Settings_Fields', 'textarea_field' ), sprintf( __( 'Customize the message using the following placeholders: %s', 'aryo-activity-log' ), '[sitename], [action-details]' ), $default_email_message );
70
  }
71
 
72
  public function validate_options( $input ) {
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Activity Log ===
2
- Contributors: pojo.me, KingYes, ariel.k, maor
3
- Tags: administration, activity, event, monitor, multisite, multi-users, log, logger, audit log, stats, security, tracking, woocommerce, notifications, email notifications
4
  Requires at least: 3.5
5
- Tested up to: 4.3
6
- Stable tag: 2.2.6
7
  License: GPLv2 or later
8
 
9
  Get aware of any activities that are taking place on your dashboard! Imagine it like a black-box for your WordPress site.
@@ -96,6 +96,11 @@ Would you like to like to contribute to Activity Log? You are more than welcome
96
 
97
  == Changelog ==
98
 
 
 
 
 
 
99
  = 2.2.6 =
100
  * Tweak! - Added sort by IP address ([#77](https://github.com/KingYes/wordpress-aryo-activity-log/issues/77))
101
  * Tweak! - Added more actions/types in notification
1
  === Activity Log ===
2
+ Contributors: pojo.me, KingYes, ariel.k, maor, freemius
3
+ Tags: actions, activity, Activity Log, activity logs, admin, admin actions, administration, analytics, audit, audit log, audit logs, bbPress, change, changes, dashboard, email notifications, event, event log, log, logger, Logs, monitor, multi-users, multisite, notifications, security, security audit trail, security event log, stats, stream, tracking, troubleshooting, user activity report, user tracking, woocommerce, woocommerce log, woocommerce monitor, woocommerce monitoring, woocommrece security, wordpress activity log, WordPress Admin, wordpress admin monitoring, wordpress audit, wordpress email alerts, wordpress log, wordpress monitor, wordpress monitoring, wordpress multisite, wordpress security, wordpress security alerts, wordpress security audit log, wordpress security monitor, wordpress security plugin, wordpress user tracking
4
  Requires at least: 3.5
5
+ Tested up to: 4.4
6
+ Stable tag: 2.2.7
7
  License: GPLv2 or later
8
 
9
  Get aware of any activities that are taking place on your dashboard! Imagine it like a black-box for your WordPress site.
96
 
97
  == Changelog ==
98
 
99
+ = 2.2.7 =
100
+ * Added! - Freemius Insights platform to improve plugin UX
101
+ * Tweak! Update translate: Russian (ru_RU) - Thanks to Oleg Reznikov
102
+ * Tested up to WordPress v4.4
103
+
104
  = 2.2.6 =
105
  * Tweak! - Added sort by IP address ([#77](https://github.com/KingYes/wordpress-aryo-activity-log/issues/77))
106
  * Tweak! - Added more actions/types in notification