myCRED - Version 2.1.1

Version Description

New features and Bug fixes.

Download this release

Release Info

Developer wpexpertsio
Plugin Icon 128x128 myCRED
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1.0.3 to 2.1.1

Files changed (46) hide show
  1. addons/badges/assets/js/admin.js +5 -1
  2. addons/badges/assets/js/front.js +32 -8
  3. addons/badges/includes/mycred-badge-functions.php +154 -0
  4. addons/badges/includes/mycred-badge-object.php +13 -5
  5. addons/badges/includes/mycred-badge-shortcodes.php +26 -139
  6. addons/badges/myCRED-addon-badges.php +18 -39
  7. addons/buy-creds/abstracts/mycred-abstract-payment-gateway.php +1 -1
  8. addons/buy-creds/includes/buycred-functions.php +54 -0
  9. addons/buy-creds/includes/buycred-shortcodes.php +1 -1
  10. addons/buy-creds/modules/buycred-module-core.php +2 -1
  11. addons/cash-creds/gateways/bank-transfer.php +8 -8
  12. addons/cash-creds/includes/cashcred-functions.php +79 -67
  13. addons/cash-creds/modules/cashcred-module-core.php +19 -15
  14. addons/cash-creds/modules/cashcred-module-withdrawal.php +2 -2
  15. addons/coupons/includes/mycred-coupon-functions.php +1 -1
  16. addons/coupons/myCRED-addon-coupons.php +1 -10
  17. addons/email-notices/includes/mycred-email-functions.php +11 -3
  18. addons/email-notices/includes/mycred-email-object.php +66 -11
  19. addons/email-notices/myCRED-addon-email-notices.php +89 -19
  20. addons/gateway/carts/mycred-woocommerce.php +1 -1
  21. addons/notifications/myCRED-addon-notifications.php +1 -6
  22. addons/ranks/myCRED-addon-ranks.php +1 -18
  23. addons/sell-content/includes/mycred-sell-functions.php +48 -0
  24. addons/sell-content/includes/mycred-sell-shortcodes.php +26 -5
  25. addons/sell-content/myCRED-addon-sell-content.php +2 -13
  26. addons/stats/myCRED-addon-stats.php +1 -7
  27. addons/transfer/myCRED-addon-transfer.php +1 -24
  28. assets/css/mycred-front.css +1 -1
  29. assets/js/admin.js +0 -0
  30. includes/classes/class.query-log.php +2 -2
  31. includes/hooks/external/mycred-hook-invite-anyone.php +2 -2
  32. includes/hooks/mycred-hook-referrals.php +58 -32
  33. includes/importers/mycred-cubepoints.php +68 -2
  34. includes/mycred-about.php +2 -2
  35. includes/mycred-functions.php +159 -8
  36. includes/mycred-install.php +226 -105
  37. includes/mycred-referrals.php +1 -1
  38. includes/mycred-setup.php +1 -1
  39. includes/mycred-uninstall.php +122 -0
  40. includes/mycred-walkthrough.php +23 -27
  41. includes/shortcodes/mycred_referal_stats.php +51 -0
  42. modules/mycred-module-addons.php +2 -2
  43. modules/mycred-module-export.php +7 -2
  44. modules/mycred-module-hooks.php +17 -8
  45. mycred.php +48 -8
  46. readme.txt +65 -2
addons/badges/assets/js/admin.js CHANGED
@@ -1,4 +1,6 @@
1
  jQuery(document).ready(function (){
 
 
2
  jQuery(document).on( 'click', '#mycred-badge-is-open-badge', function (){
3
  if ( jQuery('input#mycred-badge-is-open-badge').is(':checked') ) {
4
  if ( confirm('Activating Open Badge loss will all Levels of this badge.') ) {
@@ -8,6 +10,8 @@ jQuery(document).ready(function (){
8
  }
9
  }
10
  } );
 
 
11
  jQuery(document).on( 'click', '#switch-all-to-open-badge', function (e){
12
  e.preventDefault();
13
  if ( confirm('Activating Open Badge loss will all Levels of this badge.') ) {
@@ -28,5 +32,5 @@ jQuery(document).ready(function (){
28
  } else {
29
  return false;
30
  }
31
- } )
32
  })
1
  jQuery(document).ready(function (){
2
+
3
+ //Validation before switching to Open Badge
4
  jQuery(document).on( 'click', '#mycred-badge-is-open-badge', function (){
5
  if ( jQuery('input#mycred-badge-is-open-badge').is(':checked') ) {
6
  if ( confirm('Activating Open Badge loss will all Levels of this badge.') ) {
10
  }
11
  }
12
  } );
13
+
14
+ //Switch all to open badge
15
  jQuery(document).on( 'click', '#switch-all-to-open-badge', function (e){
16
  e.preventDefault();
17
  if ( confirm('Activating Open Badge loss will all Levels of this badge.') ) {
32
  } else {
33
  return false;
34
  }
35
+ } );
36
  })
addons/badges/assets/js/front.js CHANGED
@@ -1,9 +1,33 @@
1
- // jQuery(document).ready(function(){
2
- // jQuery("#myInput").on("keyup", function() {
3
- // var value = jQuery(this).val().toLowerCase();
4
- // jQuery(".mycred-tab-panels .mycred-badges-list-item").filter(function() {
5
- // jQuery(this).toggle(jQuery(this).text().toLowerCase().indexOf(value) > -1)
6
- // });
7
- // });
8
- // });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
1
+ jQuery(document).ready(function(){
2
+
3
+ //Badges Search Filter
4
+ jQuery("#mycerd-badges-search").on("keyup", function() {
5
+ var value = jQuery(this).val().toLowerCase();
6
+ jQuery(".mycred-badges-list .mycred-badges-list-item").filter(function() {
7
+ jQuery(this).toggle(jQuery(this).text().toLowerCase().indexOf(value) > -1)
8
+ });
9
+ });
10
+
11
+ //Show Achieved Badges
12
+ jQuery(document).on( 'click', '.mycred-achieved-badge-btn', function(e){
13
+ e.preventDefault();
14
+ jQuery('.not-earned').hide();
15
+ jQuery('.earned').show();
16
+ });
17
+
18
+ //Show Not Achieved Badges
19
+ jQuery(document).on( 'click', '.mycred-not-achieved-badge-btn', function(e){
20
+ e.preventDefault();
21
+ jQuery('.earned').hide();
22
+ jQuery('.not-earned').show();
23
+ });
24
+
25
+ //Clear Filter Button
26
+ jQuery(document).on( 'click', '.mycred-clear-filter-btn', function(e){
27
+ e.preventDefault()
28
+ jQuery('.earned').show();
29
+ jQuery('.not-earned').show();
30
+ jQuery('#mycerd-badges-search').val('');
31
+ } )
32
+ });
33
 
addons/badges/includes/mycred-badge-functions.php CHANGED
@@ -1044,5 +1044,159 @@ if ( ! function_exists( 'mycred_set_badge_evidence_page' ) ) :
1044
 
1045
  }
1046
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1047
  }
1048
  endif;
1044
 
1045
  }
1046
 
1047
+ }
1048
+ endif;
1049
+
1050
+ /**
1051
+ * Get badges list
1052
+ * @since 2.1.1
1053
+ * @version 1.0
1054
+ */
1055
+ if ( ! function_exists( 'mycred_get_uncategorized_badge_list' ) ) :
1056
+ function mycred_get_uncategorized_badge_list() {
1057
+
1058
+ $badge_list = '';
1059
+
1060
+ //Get Badges
1061
+ $args = array(
1062
+ 'numberposts' => -1,
1063
+ 'post_type' => MYCRED_BADGE_KEY
1064
+ );
1065
+
1066
+ $badges = get_posts( $args );
1067
+
1068
+ $user_id = get_current_user_id();
1069
+ $categories = get_categories( $args );
1070
+ $category_count = count( $categories );
1071
+
1072
+ //Show Badges
1073
+ foreach ( $badges as $badge ) {
1074
+
1075
+ $badge_object = mycred_get_badge( $badge->ID );
1076
+
1077
+ $image_url = $badge_object->main_image_url;
1078
+
1079
+ $has_earned = $badge_object->user_has_badge( $user_id ) ? 'earned' : 'not-earned';
1080
+
1081
+ $category = mycred_get_badge_type( $badge->ID );
1082
+
1083
+ $categories = explode( ',', $category );
1084
+
1085
+ $badge_list .= '<div class="mycred-badges-list-item '.$has_earned.'" data-url="'.mycred_get_permalink( $badge->ID ).'">';
1086
+
1087
+ if ( $image_url )
1088
+ $badge_list .= '<img src="'.esc_url( $image_url ).'" alt="Badge Image">';
1089
+
1090
+ $badge_list .= '<div class="mycred-left">';
1091
+ $badge_list .= '<h3>'.$badge->post_title.'</h3>';
1092
+ if( $category_count > 0 ) {
1093
+
1094
+ foreach ( $categories as $category ) {
1095
+
1096
+ if( $category != '' ) {
1097
+
1098
+ $badge_list .= '<sup class="mycred-sup-category">'.$category.'</sup>';
1099
+
1100
+ }
1101
+
1102
+ }
1103
+
1104
+ }
1105
+
1106
+ $badge_list .= '<p>'.$badge->post_excerpt.'</p>';
1107
+
1108
+ //mycred-left
1109
+ $badge_list .= '</div>';
1110
+
1111
+ $badge_list .= '<div class="clear"></div>';
1112
+
1113
+ //mycred-badges-list-item
1114
+ $badge_list .= '</div>';
1115
+
1116
+ }
1117
+
1118
+ return $badge_list;
1119
+
1120
+ }
1121
+ endif;
1122
+
1123
+ /**
1124
+ * Get badges list by categories
1125
+ * @since 2.1.1
1126
+ * @version 1.0
1127
+ */
1128
+ if ( ! function_exists( 'mycred_get_categorized_badge_list' ) ) :
1129
+ function mycred_get_categorized_badge_list() {
1130
+
1131
+ $user_id = get_current_user_id();
1132
+
1133
+ $args = array(
1134
+ 'taxonomy' => MYCRED_BADGE_CATEGORY,
1135
+ 'orderby' => 'name',
1136
+ 'field' => 'name',
1137
+ 'order' => 'ASC',
1138
+ 'hide_empty' => false
1139
+ );
1140
+
1141
+ $categories = get_categories( $args );
1142
+ $category_count = count( $categories );
1143
+ $badges_list_tabs = array();
1144
+ $badges_list_panels = array();
1145
+
1146
+ $counter = 1;
1147
+
1148
+ foreach ( $categories as $category ) {
1149
+
1150
+ $category_id = $category->cat_ID;
1151
+ $category_name = $category->cat_name;
1152
+ $category_badges = mycred_get_badges_by_term_id( $category_id );
1153
+ $badges_count = count( $category_badges );
1154
+
1155
+ if ( $badges_count > 0 ) {
1156
+
1157
+ $badges_list_tabs[ $category_id ] = '<li data-id="' . $category_id . '" '. ( $counter == 1 ? 'class="active"' : '' ) .'>';
1158
+ $badges_list_tabs[ $category_id ] .= $category_name . '<span class="mycred-badge-count">' . $badges_count . '</span>';
1159
+ $badges_list_tabs[ $category_id ] .= '</li>';
1160
+
1161
+ $badges_list_panels[ $category_id ] = '<div data-id="'.$category_id.'" class="mycred-badges-list-panel '. ( $counter == 1 ? 'active' : '' ) .'">';
1162
+
1163
+ foreach ( $category_badges as $badge ) {
1164
+
1165
+ $badge_id = $badge->ID;
1166
+
1167
+ $badge_object = mycred_get_badge( $badge_id );
1168
+
1169
+ $image_url = $badge_object->main_image_url;
1170
+
1171
+ $has_earned = $badge_object->user_has_badge( $user_id ) ? 'earned' : 'not-earned';
1172
+
1173
+ $badges_list_panels[ $category_id ] .= '<div class="mycred-badges-list-item '. $has_earned .'" data-url="' . mycred_get_permalink( $badge_id ) . '">';
1174
+
1175
+ if ( $image_url ) {
1176
+
1177
+ $badges_list_panels[ $category_id ] .= '<img src="' . esc_url( $image_url ) . '" alt="Badge Image">';
1178
+
1179
+ }
1180
+
1181
+ $badges_list_panels[ $category_id ] .= '<div class="mycred-left"><h3>' . $badge->post_title . '</h3>' . $badge->post_excerpt . '</div>';
1182
+ $badges_list_panels[ $category_id ] .= '<div class="clear"></div>';
1183
+ $badges_list_panels[ $category_id ] .= '</div>';
1184
+
1185
+ }
1186
+
1187
+ $badges_list_panels[ $category_id ] .= '</div>';
1188
+
1189
+ $counter++;
1190
+
1191
+ }
1192
+
1193
+ }
1194
+
1195
+ return array(
1196
+ 'tabs' => $badges_list_tabs,
1197
+ 'panels' => $badges_list_panels,
1198
+ 'category_count' => $category_count,
1199
+ );
1200
+
1201
  }
1202
  endif;
addons/badges/includes/mycred-badge-object.php CHANGED
@@ -103,8 +103,17 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
103
  $this->manual = true;
104
 
105
  // Indicate open badge
106
- if ( absint( mycred_get_post_meta( $this->post_id, 'open_badge', true ) ) === 1 )
107
- $this->open_badge = true;
 
 
 
 
 
 
 
 
 
108
 
109
  // If we requested a particular level
110
  if ( $level_id !== NULL )
@@ -228,7 +237,7 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
228
  return absint( $mycred_current_account->badge_ids[ $this->post_id ] );
229
 
230
  $current_level = mycred_get_user_meta( $user_id, $this->user_meta_key, '', true );
231
- $current_level = ( ! empty( $current_level ) ) ? absint( $current_level ) : false;
232
 
233
  return $current_level;
234
 
@@ -718,8 +727,7 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
718
  $image_width = ( $this->image_width !== false ) ? ' width="' . esc_attr( $this->image_width ) . '"' : '';
719
  $image_height = ( $this->image_height !== false ) ? ' height="' . esc_attr( $this->image_height ) . '"' : '';
720
 
721
- if ( !$image_url )
722
- return false;
723
 
724
  $html = '<img src="' . esc_url( $image_url ) . '" class="' . MYCRED_SLUG . '-badge-image badge-level' . esc_attr( $level ) . '" title="' . esc_attr( $this->title ) . '" alt="' . esc_attr( $this->title ) . '"' . $image_width . $image_height . ' />';
725
 
103
  $this->manual = true;
104
 
105
  // Indicate open badge
106
+ if ( absint( mycred_get_post_meta( $this->post_id, 'open_badge', true ) ) === 1 ) {
107
+
108
+ $badge_setting = mycred_get_addon_settings( 'badges' );
109
+
110
+ if ( isset( $badge_setting['open_badge'] ) && $badge_setting['open_badge'] === 1 ) {
111
+
112
+ $this->open_badge = true;
113
+
114
+ }
115
+
116
+ }
117
 
118
  // If we requested a particular level
119
  if ( $level_id !== NULL )
237
  return absint( $mycred_current_account->badge_ids[ $this->post_id ] );
238
 
239
  $current_level = mycred_get_user_meta( $user_id, $this->user_meta_key, '', true );
240
+ $current_level = ( ! empty( $current_level ) || $current_level === '0' ) ? absint( $current_level ) : false;
241
 
242
  return $current_level;
243
 
727
  $image_width = ( $this->image_width !== false ) ? ' width="' . esc_attr( $this->image_width ) . '"' : '';
728
  $image_height = ( $this->image_height !== false ) ? ' height="' . esc_attr( $this->image_height ) . '"' : '';
729
 
730
+ if ( ! $image_url ) return false;
 
731
 
732
  $html = '<img src="' . esc_url( $image_url ) . '" class="' . MYCRED_SLUG . '-badge-image badge-level' . esc_attr( $level ) . '" title="' . esc_attr( $this->title ) . '" alt="' . esc_attr( $this->title ) . '"' . $image_width . $image_height . ' />';
733
 
addons/badges/includes/mycred-badge-shortcodes.php CHANGED
@@ -115,7 +115,7 @@ if ( ! function_exists( 'mycred_render_badges' ) ) :
115
  $row = str_replace( '%badge_title%', $badge->title, $row );
116
  $row = str_replace( '%requirements%', mycred_display_badge_requirements( $badge_id ), $row );
117
  $row = str_replace( '%count%', $badge->earnedby, $row );
118
- $row = str_replace( '%default_image%', $badge->main_image, $row );
119
 
120
  if( mycred_user_has_badge( get_current_user_id(), $badge_id) ) {
121
  $row = str_replace( '%main_image%', $badge->level_image, $row );
@@ -152,94 +152,28 @@ if( !function_exists( 'mycred_render_badges_list' ) ) :
152
  $atts, MYCRED_SLUG . '_badges_list'
153
  ) );
154
 
155
- //User Id
156
- $user_id = get_current_user_id();
157
 
158
- $args = array(
159
- 'taxonomy' => MYCRED_BADGE_CATEGORY,
160
- 'orderby' => 'name',
161
- 'field' => 'name',
162
- 'order' => 'ASC',
163
- 'hide_empty' => false
164
- );
 
 
165
 
166
- $categories = get_categories( $args );
167
- $category_count = count( $categories );
168
 
169
- //Get Badges
170
- $args = array(
171
- 'post_type' => MYCRED_BADGE_KEY
172
- );
173
 
174
- $query = new WP_Query( $args );
175
-
176
- $badges_list_tabs = array();
177
- $badges_list_panels = array();
178
-
179
- if ( $achievement_tabs == 1 ) {
180
-
181
- $counter = 1;
182
-
183
- foreach ( $categories as $category ) {
184
-
185
- $category_id = $category->cat_ID;
186
- $category_name = $category->cat_name;
187
- $category_badges = mycred_get_badges_by_term_id( $category_id );
188
- $badges_count = count( $category_badges );
189
-
190
- if ( $badges_count > 0 ) {
191
-
192
- $badges_list_tabs[ $category_id ] = '<li data-id="' . $category_id . '" '. ( $counter == 1 ? 'class="active"' : '' ) .'>';
193
- $badges_list_tabs[ $category_id ] .= $category_name . '<span class="mycred-badge-count">' . $badges_count . '</span>';
194
- $badges_list_tabs[ $category_id ] .= '</li>';
195
-
196
- $badges_list_panels[ $category_id ] = '<div data-id="'.$category_id.'" class="mycred-badges-list-panel '. ( $counter == 1 ? 'active' : '' ) .'">';
197
-
198
- foreach ( $category_badges as $badge ) {
199
-
200
- $badge_id = $badge->ID;
201
-
202
- $badge_object = mycred_get_badge( $badge_id );
203
-
204
- $image_url = $badge_object->main_image_url;
205
-
206
- $has_earned = $badge_object->user_has_badge( $user_id ) ? 'earned' : 'not-earned';
207
-
208
- $badges_list_panels[ $category_id ] .= '<div class="mycred-badges-list-item '. $has_earned .'" data-url="' . mycred_get_permalink( $badge_id ) . '">';
209
-
210
- if ( $image_url ) {
211
-
212
- $badges_list_panels[ $category_id ] .= '<img src="' . esc_url( $image_url ) . '" alt="Badge Image">';
213
-
214
- }
215
-
216
- $badges_list_panels[ $category_id ] .= '<div class="mycred-left"><h3>' . $badge->post_title . '</h3>' . $badge->post_excerpt . '</div>';
217
- $badges_list_panels[ $category_id ] .= '<div class="clear"></div>';
218
- $badges_list_panels[ $category_id ] .= '</div>';
219
-
220
- }
221
-
222
- $badges_list_panels[ $category_id ] .= '</div>';
223
-
224
- $counter++;
225
-
226
- }
227
-
228
- }
229
-
230
- wp_reset_query();
231
-
232
- }
233
-
234
- if ( $achievement_tabs == 1 ) {
235
-
236
- if ( $category_count > 0 ) {?>
237
-
238
- <div class="mycred-badges-list">
239
  <div class="mycred-badges-list-nav">
240
  <ul class="mycred-badges-list-tabs">
241
  <?php
242
- foreach ( $badges_list_tabs as $id => $element ) {
243
 
244
  echo $element;
245
 
@@ -249,74 +183,27 @@ if( !function_exists( 'mycred_render_badges_list' ) ) :
249
  </div>
250
  <div class="mycred-badges-list-panels">
251
  <?php
252
- foreach ( $badges_list_panels as $id => $element ) {
253
 
254
  echo $element;
255
 
256
  }
257
  ?>
258
  </div>
259
- </div>
260
- <?php
 
261
  }
262
  else {
263
 
264
- echo 'First Create Achievements Containing Badges';
265
-
 
 
266
  }
 
267
  ?>
268
-
269
- <?php
270
- }
271
- else {
272
-
273
- //Show Badges
274
- while ( $query->have_posts() ) : $query->the_post();
275
-
276
- $badge_id = get_the_ID();
277
-
278
- $badge_object = mycred_get_badge( $badge_id );
279
-
280
- $image_url = $badge_object->main_image_url;
281
-
282
- $has_earned = $badge_object->user_has_badge( $user_id ) ? 'earned' : 'not-earned';
283
-
284
- $category = mycred_get_badge_type( $badge_id );
285
-
286
- $categories = explode( ',', $category );
287
-
288
- ?>
289
- <div class="mycred-badges-list-item <?php echo $has_earned; ?>" data-url="<?php echo mycred_get_permalink( $badge_id );?>">
290
- <?php if ( $image_url ): ?>
291
- <img src="<?php echo esc_url( $image_url ) ?>" alt="Badge Image">
292
- <?php endif; ?>
293
- <div class="mycred-left">
294
- <h3>
295
- <?php echo get_the_title(); ?>
296
- </h3>
297
- <?php
298
- if( $category_count > 0 ) {
299
-
300
- foreach ( $categories as $category ) {
301
-
302
- if( $category != '' ) {
303
-
304
- echo '<sup class="mycred-sup-category">'.$category.'</sup>';
305
-
306
- }
307
-
308
- }
309
-
310
- }
311
- ?>
312
- <?php echo the_excerpt(); ?>
313
- </div>
314
- <div class="clear"></div>
315
- </div>
316
- <?php
317
- endwhile;
318
- }
319
- ?>
320
  <script type="text/javascript">
321
 
322
  jQuery(document).ready(function(){
115
  $row = str_replace( '%badge_title%', $badge->title, $row );
116
  $row = str_replace( '%requirements%', mycred_display_badge_requirements( $badge_id ), $row );
117
  $row = str_replace( '%count%', $badge->earnedby, $row );
118
+ $row = str_replace( '%default_image%', $badge->get_image( 'main' ), $row );
119
 
120
  if( mycred_user_has_badge( get_current_user_id(), $badge_id) ) {
121
  $row = str_replace( '%main_image%', $badge->level_image, $row );
152
  $atts, MYCRED_SLUG . '_badges_list'
153
  ) );
154
 
155
+ ob_start();?>
 
156
 
157
+ <div class="mycred-badges-list">
158
+ <div class="mycred-search-bar">
159
+ <form method="post">
160
+ <input id="mycerd-badges-search" type="text" placeholder="Search for badge">
161
+ <button class="mycred-achieved-badge-btn">Achieved</button>
162
+ <button class="mycred-not-achieved-badge-btn">Not Achieved</button>
163
+ <button class="mycred-clear-filter-btn">Clear All</button>
164
+ </form>
165
+ </div>
166
 
167
+ <?php
168
+ if ( $achievement_tabs == 1 ) {
169
 
170
+ $badges = mycred_get_categorized_badge_list();
 
 
 
171
 
172
+ if ( $badges['category_count'] > 0 ) { ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  <div class="mycred-badges-list-nav">
174
  <ul class="mycred-badges-list-tabs">
175
  <?php
176
+ foreach ( $badges['tabs'] as $id => $element ) {
177
 
178
  echo $element;
179
 
183
  </div>
184
  <div class="mycred-badges-list-panels">
185
  <?php
186
+ foreach ( $badges['panels'] as $id => $element ) {
187
 
188
  echo $element;
189
 
190
  }
191
  ?>
192
  </div>
193
+ <?php
194
+ }
195
+
196
  }
197
  else {
198
 
199
+ echo '<div class="mycred-badges-list-all">';
200
+ echo mycred_get_uncategorized_badge_list();
201
+ echo '</div>';
202
+
203
  }
204
+ wp_reset_query();
205
  ?>
206
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  <script type="text/javascript">
208
 
209
  jQuery(document).ready(function(){
addons/badges/myCRED-addon-badges.php CHANGED
@@ -48,20 +48,7 @@ if ( ! class_exists( 'myCRED_Badge_Module' ) ) :
48
 
49
  parent::__construct( 'myCRED_Badge_Module', array(
50
  'module_name' => 'badges',
51
- 'defaults' => array(
52
- 'show_level_description' => 0,
53
- 'show_congo_text' => 0,
54
- 'show_steps_to_achieve' => 0,
55
- 'show_levels' => 0,
56
- 'show_level_points' => 0,
57
- 'show_earners' => 0,
58
- 'open_badge' => 0,
59
- 'open_badge_evidence_page' => 0,
60
- 'buddypress' => '',
61
- 'bbpress' => '',
62
- 'show_all_bp' => 0,
63
- 'show_all_bb' => 0
64
- ),
65
  'add_to_core' => true,
66
  'register' => false,
67
  'menu_pos' => 50
@@ -177,7 +164,7 @@ if ( ! class_exists( 'myCRED_Badge_Module' ) ) :
177
  */
178
  public function enqueue_front_scripts()
179
  {
180
- wp_enqueue_script( 'mycred-badge-front', plugins_url( 'assets/js/front.js', myCRED_BADGE ), '', myCRED_BADGE_VERSION );
181
  }
182
 
183
  /**
@@ -201,7 +188,6 @@ if ( ! class_exists( 'myCRED_Badge_Module' ) ) :
201
  add_filter( 'submenu_file', array( $this, 'subparent_file' ), 10, 2 );
202
  add_action( 'mycred_admin_enqueue', array( $this, 'enqueue_scripts' ), $this->menu_pos );
203
 
204
- add_filter( 'post_row_actions', array( $this, 'adjust_row_actions' ), 10, 2 );
205
 
206
  add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
207
  add_filter( 'enter_title_here', array( $this, 'enter_title_here' ) );
@@ -476,8 +462,8 @@ if ( ! class_exists( 'myCRED_Badge_Module' ) ) :
476
 
477
  add_submenu_page(
478
  MYCRED_SLUG,
479
- __( 'Achievement Types', 'mycred' ),
480
- __( 'Achievement Types', 'mycred' ),
481
  $this->core->get_point_editor_capability(),
482
  'edit-tags.php?post_type=' . MYCRED_BADGE_KEY . '&taxonomy=' . MYCRED_BADGE_CATEGORY
483
  );
@@ -676,20 +662,6 @@ if ( ! class_exists( 'myCRED_Badge_Module' ) ) :
676
 
677
  }
678
 
679
- /**
680
- * Adjust Row Actions
681
- * @since 1.0
682
- * @version 1.0
683
- */
684
- public function adjust_row_actions( $actions, $post ) {
685
-
686
- if ( $post->post_type == MYCRED_BADGE_KEY ) {
687
- unset( $actions['inline hide-if-no-js'] );
688
- }
689
-
690
- return $actions;
691
-
692
- }
693
 
694
  /**
695
  * Adjust Enter Title Here
@@ -1713,6 +1685,12 @@ th#badge-users { width: 10%; }
1713
  <?php echo $level_select; ?>
1714
 
1715
  </div>
 
 
 
 
 
 
1716
  </div>
1717
  <?php
1718
 
@@ -1969,8 +1947,7 @@ th#badge-users { width: 10%; }
1969
  $show_steps_to_achieve = false;
1970
  $show_earners = false;
1971
 
1972
- if ( is_array( $mycred->core ) && array_key_exists('badges', $mycred->core ) )
1973
- {
1974
  $show_level_description = $mycred->core["badges"]["show_level_description"] == '1' ? true : false;
1975
  $show_congo_text = $mycred->core["badges"]["show_congo_text"] == '1' ? true : false;
1976
  $show_levels = $mycred->core["badges"]["show_levels"] == '1' ? true : false;
@@ -1997,13 +1974,15 @@ th#badge-users { width: 10%; }
1997
  $content = '<div class="mycred-badge-page">';
1998
 
1999
  if ( $show_congo_text && $has_earned ) {
2000
- if (!empty($badge_object->congratulation_msg))
2001
- {
2002
 
2003
  $content .= '<div class="mycred-badge-congratulation-msg">' . $badge_object->congratulation_msg . '</div>';
 
2004
  }
 
2005
  }
2006
-
2007
  $content .= '<img src="' . $badge_image_url . '" class="mycred-badge-image" alt="">';
2008
 
2009
  //Level Description
@@ -2026,10 +2005,10 @@ th#badge-users { width: 10%; }
2026
  $levels = mycred_show_badge_requirements( $badge_id );
2027
 
2028
  foreach ( $levels as $id => $level ) {
2029
-
2030
  $level_image_url = '';
2031
 
2032
- if( !empty( $level_image_url ) )
2033
  $level_image_url = $level["image"];
2034
 
2035
  $heading = $level["heading"];
48
 
49
  parent::__construct( 'myCRED_Badge_Module', array(
50
  'module_name' => 'badges',
51
+ 'defaults' => mycred_get_addon_defaults( 'badges' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  'add_to_core' => true,
53
  'register' => false,
54
  'menu_pos' => 50
164
  */
165
  public function enqueue_front_scripts()
166
  {
167
+ wp_enqueue_script( 'mycred-badge-front', plugins_url( 'assets/js/front.js', myCRED_BADGE ), array('jquery'), myCRED_BADGE_VERSION );
168
  }
169
 
170
  /**
188
  add_filter( 'submenu_file', array( $this, 'subparent_file' ), 10, 2 );
189
  add_action( 'mycred_admin_enqueue', array( $this, 'enqueue_scripts' ), $this->menu_pos );
190
 
 
191
 
192
  add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
193
  add_filter( 'enter_title_here', array( $this, 'enter_title_here' ) );
462
 
463
  add_submenu_page(
464
  MYCRED_SLUG,
465
+ __( 'Achievements', 'mycred' ),
466
+ __( 'Achievements', 'mycred' ),
467
  $this->core->get_point_editor_capability(),
468
  'edit-tags.php?post_type=' . MYCRED_BADGE_KEY . '&taxonomy=' . MYCRED_BADGE_CATEGORY
469
  );
662
 
663
  }
664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
665
 
666
  /**
667
  * Adjust Enter Title Here
1685
  <?php echo $level_select; ?>
1686
 
1687
  </div>
1688
+
1689
+ <?php if ( $badge->open_badge && array_key_exists( $badge_id, $users_badges ) ):?>
1690
+ <div class="badge-image-wrap">
1691
+ <a href="<?php echo $badge->get_earned_image( $user_id ); ?> " class="button button-primary button-large mycred-open-badge-download" download>Download</a>
1692
+ </div>
1693
+ <?php endif; ?>
1694
  </div>
1695
  <?php
1696
 
1947
  $show_steps_to_achieve = false;
1948
  $show_earners = false;
1949
 
1950
+ if ( is_array( $mycred->core ) && array_key_exists('badges', $mycred->core ) ) {
 
1951
  $show_level_description = $mycred->core["badges"]["show_level_description"] == '1' ? true : false;
1952
  $show_congo_text = $mycred->core["badges"]["show_congo_text"] == '1' ? true : false;
1953
  $show_levels = $mycred->core["badges"]["show_levels"] == '1' ? true : false;
1974
  $content = '<div class="mycred-badge-page">';
1975
 
1976
  if ( $show_congo_text && $has_earned ) {
1977
+
1978
+ if ( ! empty( $badge_object->congratulation_msg ) ) {
1979
 
1980
  $content .= '<div class="mycred-badge-congratulation-msg">' . $badge_object->congratulation_msg . '</div>';
1981
+
1982
  }
1983
+
1984
  }
1985
+
1986
  $content .= '<img src="' . $badge_image_url . '" class="mycred-badge-image" alt="">';
1987
 
1988
  //Level Description
2005
  $levels = mycred_show_badge_requirements( $badge_id );
2006
 
2007
  foreach ( $levels as $id => $level ) {
2008
+
2009
  $level_image_url = '';
2010
 
2011
+ if( ! empty( $level_image_url ) )
2012
  $level_image_url = $level["image"];
2013
 
2014
  $heading = $level["heading"];
addons/buy-creds/abstracts/mycred-abstract-payment-gateway.php CHANGED
@@ -879,7 +879,7 @@ if ( ! class_exists( 'myCRED_Payment_Gateway' ) ) :
879
  public function get_cost( $amount = 0, $point_type = MYCRED_DEFAULT_TYPE_KEY, $raw = false, $custom_rate = 0 ) {
880
 
881
  if(isset($_REQUEST['er_random']) && !empty($_REQUEST['er_random'])){
882
- $custom_rate=base64_decode($_REQUEST['er_random']);
883
  }
884
 
885
  $setup = mycred_get_buycred_sale_setup( $point_type );
879
  public function get_cost( $amount = 0, $point_type = MYCRED_DEFAULT_TYPE_KEY, $raw = false, $custom_rate = 0 ) {
880
 
881
  if(isset($_REQUEST['er_random']) && !empty($_REQUEST['er_random'])){
882
+ $custom_rate=mycred_buycred_decode($_REQUEST['er_random']);
883
  }
884
 
885
  $setup = mycred_get_buycred_sale_setup( $point_type );
addons/buy-creds/includes/buycred-functions.php CHANGED
@@ -758,3 +758,57 @@ if ( ! function_exists( 'buycred_checkout_footer' ) ) :
758
 
759
  }
760
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
758
 
759
  }
760
  endif;
761
+
762
+ if ( ! function_exists( 'mycred_buycred_encode' ) ) :
763
+ function mycred_buycred_encode($value) {
764
+ if (!$value) {
765
+ return false;
766
+ }
767
+
768
+ $key = sha1( AUTH_KEY );
769
+ $strLen = strlen($value);
770
+ $keyLen = strlen($key);
771
+ $j = 0;
772
+ $crypttext = '';
773
+
774
+ for ($i = 0; $i < $strLen; $i++) {
775
+ $ordStr = ord(substr($value, $i, 1));
776
+ if ($j == $keyLen) {
777
+ $j = 0;
778
+ }
779
+ $ordKey = ord(substr($key, $j, 1));
780
+ $j++;
781
+ $crypttext .= strrev(base_convert(dechex($ordStr + $ordKey), 16, 36));
782
+ }
783
+
784
+ return $crypttext;
785
+ }
786
+ endif;
787
+
788
+
789
+
790
+ if ( ! function_exists( 'mycred_buycred_decode' ) ) :
791
+ function mycred_buycred_decode($value) {
792
+ if (!$value) {
793
+ return false;
794
+ }
795
+
796
+ $key = sha1( AUTH_KEY );
797
+ $strLen = strlen($value);
798
+ $keyLen = strlen($key);
799
+ $j = 0;
800
+ $decrypttext = '';
801
+
802
+ for ($i = 0; $i < $strLen; $i += 2) {
803
+ $ordStr = hexdec(base_convert(strrev(substr($value, $i, 2)), 36, 16));
804
+ if ($j == $keyLen) {
805
+ $j = 0;
806
+ }
807
+ $ordKey = ord(substr($key, $j, 1));
808
+ $j++;
809
+ $decrypttext .= chr($ordStr - $ordKey);
810
+ }
811
+
812
+ return $decrypttext;
813
+ }
814
+ endif;
addons/buy-creds/includes/buycred-shortcodes.php CHANGED
@@ -193,7 +193,7 @@ if ( ! function_exists( 'mycred_render_buy_form_points' ) ) :
193
  <input type="hidden" name="token" value="<?php echo wp_create_nonce( 'mycred-buy-creds' ); ?>" />
194
  <input type="hidden" name="ctype" value="<?php echo esc_attr( $ctype ); ?>" />
195
  <?php if( isset($e_rate) && !empty($e_rate)){
196
- $e_rate=base64_encode($e_rate);
197
  ?>
198
  <input type="hidden" name="er_random" value="<?php echo esc_attr($e_rate); ?>" />
199
  <?php } ?>
193
  <input type="hidden" name="token" value="<?php echo wp_create_nonce( 'mycred-buy-creds' ); ?>" />
194
  <input type="hidden" name="ctype" value="<?php echo esc_attr( $ctype ); ?>" />
195
  <?php if( isset($e_rate) && !empty($e_rate)){
196
+ $e_rate=mycred_buycred_encode($e_rate);
197
  ?>
198
  <input type="hidden" name="er_random" value="<?php echo esc_attr($e_rate); ?>" />
199
  <?php } ?>
addons/buy-creds/modules/buycred-module-core.php CHANGED
@@ -596,7 +596,8 @@ if ( ! class_exists( 'myCRED_buyCRED_Module' ) ) :
596
  $type_id = sanitize_key( $type_id );
597
  if ( ! mycred_point_type_exists( $type_id ) ) continue;
598
 
599
- $point_types[] = $type_id;
 
600
 
601
  $settings = array();
602
  $settings['min'] = sanitize_text_field( $setup['min'] );
596
  $type_id = sanitize_key( $type_id );
597
  if ( ! mycred_point_type_exists( $type_id ) ) continue;
598
 
599
+ if ( isset( $setup['enabled'] ) )
600
+ $point_types[] = $type_id;
601
 
602
  $settings = array();
603
  $settings['min'] = sanitize_text_field( $setup['min'] );
addons/cash-creds/gateways/bank-transfer.php CHANGED
@@ -188,9 +188,6 @@ if ( ! class_exists( 'myCRED_cashcred_Bank_Transfer' ) ) :
188
 
189
  $mycred_pref_cashcreds = mycred_get_option( 'mycred_pref_cashcreds' , false );
190
 
191
- $additional_notes_on = $mycred_pref_cashcreds["gateway_prefs"]["bank"]["enable_additional_notes"];
192
- $additional_notes = $mycred_pref_cashcreds["gateway_prefs"]["bank"]["additional_notes"];
193
-
194
  $fields = $this->form_fields();
195
 
196
  $bank_form = new CashCred_Gateway_Fields( $data, $fields );
@@ -202,11 +199,9 @@ if ( ! class_exists( 'myCRED_cashcred_Bank_Transfer' ) ) :
202
  <label><h3><?php _e( 'Bank account details', 'mycred' )?></h3></label>
203
  </div>
204
 
205
- <?php if($additional_notes_on == '1'): ?>
206
  <div class="form-group">
207
- <p>
208
- <?php echo $additional_notes; ?>
209
- </p>
210
  </div>
211
  <?php endif;?>
212
 
@@ -285,7 +280,12 @@ if ( ! class_exists( 'myCRED_cashcred_Bank_Transfer' ) ) :
285
  $new_data = array();
286
 
287
  $new_data['additional_notes'] = sanitize_text_field( $data['additional_notes'] );
288
- $new_data['enable_additional_notes'] = sanitize_text_field( $data['enable_additional_notes'] );
 
 
 
 
 
289
  $new_data['minimum_amount'] = sanitize_text_field( $data['minimum_amount'] );
290
  $new_data['maximum_amount'] = sanitize_text_field( $data['maximum_amount'] );
291
  $new_data['additional_notes'] = wp_kses_post( $data['additional_notes'] );
188
 
189
  $mycred_pref_cashcreds = mycred_get_option( 'mycred_pref_cashcreds' , false );
190
 
 
 
 
191
  $fields = $this->form_fields();
192
 
193
  $bank_form = new CashCred_Gateway_Fields( $data, $fields );
199
  <label><h3><?php _e( 'Bank account details', 'mycred' )?></h3></label>
200
  </div>
201
 
202
+ <?php if( isset( $mycred_pref_cashcreds["gateway_prefs"]["bank"]["enable_additional_notes"] ) ): ?>
203
  <div class="form-group">
204
+ <p><?php echo $mycred_pref_cashcreds["gateway_prefs"]["bank"]["additional_notes"]; ?></p>
 
 
205
  </div>
206
  <?php endif;?>
207
 
280
  $new_data = array();
281
 
282
  $new_data['additional_notes'] = sanitize_text_field( $data['additional_notes'] );
283
+
284
+ if( isset( $data['enable_additional_notes'] ) ) {
285
+
286
+ $new_data['enable_additional_notes'] = sanitize_text_field( $data['enable_additional_notes'] );
287
+
288
+ }
289
  $new_data['minimum_amount'] = sanitize_text_field( $data['minimum_amount'] );
290
  $new_data['maximum_amount'] = sanitize_text_field( $data['maximum_amount'] );
291
  $new_data['additional_notes'] = wp_kses_post( $data['additional_notes'] );
addons/cash-creds/includes/cashcred-functions.php CHANGED
@@ -467,96 +467,108 @@ if ( ! function_exists( 'mycred_get_cashcred_settings' ) ) :
467
  }
468
  endif;
469
 
470
- if(!function_exists('check_site_add_post_meta'))
471
- {
472
- /**
473
- * add postmeta by checking multisite and current blog
474
- * @param $post_id post id
475
- * @param $key meta key
476
- * @param bool $single
477
- * @return mixed
478
- */
479
- function check_site_add_post_meta($post_id, $meta_key, $meta_value, $unique = false)
480
- {
481
- if(is_multisite() AND !is_main_site() AND mycred_override_settings())
482
- {
483
  return add_post_meta( $post_id, $meta_key, $meta_value, $unique );
484
  }
485
- else
486
- {
487
  return mycred_add_post_meta( $post_id, $meta_key, $meta_value, $unique );
488
  }
489
  }
490
- }
491
-
492
- if(!function_exists('check_site_get_post_meta'))
493
- {
494
- /**
495
- * Returns postmeta by checking multisite and current blog
496
- * @param $post_id post id
497
- * @param $key meta key
498
- * @param bool $single
499
- * @return mixed
500
- */
501
- function check_site_get_post_meta($post_id, $key, $single = false)
502
- {
503
- if(is_multisite() AND !is_main_site() AND mycred_override_settings())
504
- {
505
  return get_post_meta( $post_id, $key, $single );
506
  }
507
- else
508
- {
509
  return mycred_get_post_meta( $post_id, $key, $single );
510
  }
511
  }
512
- }
513
-
514
- if(!function_exists('cashcred_get_user_settings'))
515
- {
516
- /**
517
- * cashCred get user's settings
518
- */
519
- function cashcred_get_user_settings()
520
- {
521
  $check = '';
522
  $cashcred_user_setting = '';
523
- if(is_multisite() AND !is_main_site() AND mycred_override_settings())
524
- {
525
  $check = true;
526
  }
527
- else
528
- {
529
  $check = false;
530
  }
531
- if($check)
532
- {
533
  return 'cashcred_user_settings_' . get_current_blog_id();
534
  }
535
- else
536
- {
537
  return 'cashcred_user_settings';
538
  }
539
  }
540
- }
541
-
542
- if(!function_exists('check_site_update_post_meta'))
543
- {
544
- /**
545
- *Checks site is multisite or not and update post meta
546
- * @param $post_id post id
547
- * @param $key meta key
548
- * @param $new_value new meta value
549
- * @return mixed
550
- */
551
- function check_site_update_post_meta( $post_id, $meta_key, $new_value )
552
- {
553
- if(is_multisite() AND !is_main_site() AND mycred_override_settings())
554
- {
555
  return update_post_meta( $post_id, $meta_key, $new_value );
556
  }
557
- else
558
- {
559
  return mycred_update_post_meta( $post_id, $meta_key, $new_value );
560
  }
561
  }
562
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  }
468
  endif;
469
 
470
+ /**
471
+ * add postmeta by checking multisite and current blog
472
+ * @param $post_id post id
473
+ * @param $key meta key
474
+ * @param bool $unique
475
+ * @return mixed
476
+ */
477
+ if( !function_exists('check_site_add_post_meta') ):
478
+ function check_site_add_post_meta( $post_id, $meta_key, $meta_value, $unique = false ) {
479
+ if(is_multisite() AND !is_main_site() AND mycred_override_settings()) {
 
 
 
480
  return add_post_meta( $post_id, $meta_key, $meta_value, $unique );
481
  }
482
+ else {
 
483
  return mycred_add_post_meta( $post_id, $meta_key, $meta_value, $unique );
484
  }
485
  }
486
+ endif;
487
+
488
+ /**
489
+ * Returns postmeta by checking multisite and current blog
490
+ * @param $post_id post id
491
+ * @param $key meta key
492
+ * @param bool $single
493
+ * @return mixed
494
+ */
495
+ if( ! function_exists('check_site_get_post_meta') ):
496
+ function check_site_get_post_meta( $post_id, $key, $single = false ) {
497
+ if( is_multisite() AND !is_main_site() AND mycred_override_settings() ) {
 
 
 
498
  return get_post_meta( $post_id, $key, $single );
499
  }
500
+ else {
 
501
  return mycred_get_post_meta( $post_id, $key, $single );
502
  }
503
  }
504
+ endif;
505
+
506
+ /**
507
+ * cashCred get user's settings
508
+ */
509
+ if(!function_exists('cashcred_get_user_settings')):
510
+ function cashcred_get_user_settings() {
 
 
511
  $check = '';
512
  $cashcred_user_setting = '';
513
+
514
+ if( is_multisite() AND !is_main_site() AND mycred_override_settings() ) {
515
  $check = true;
516
  }
517
+ else {
 
518
  $check = false;
519
  }
520
+
521
+ if( $check ) {
522
  return 'cashcred_user_settings_' . get_current_blog_id();
523
  }
524
+ else {
 
525
  return 'cashcred_user_settings';
526
  }
527
  }
528
+ endif;
529
+
530
+ /**
531
+ *Checks site is multisite or not and update post meta
532
+ * @param $post_id post id
533
+ * @param $key meta key
534
+ * @param $new_value new meta value
535
+ * @return mixed
536
+ */
537
+ if( ! function_exists( 'check_site_update_post_meta' ) ):
538
+ function check_site_update_post_meta( $post_id, $meta_key, $new_value ) {
539
+ if(is_multisite() AND !is_main_site() AND mycred_override_settings()) {
 
 
 
540
  return update_post_meta( $post_id, $meta_key, $new_value );
541
  }
542
+ else {
 
543
  return mycred_update_post_meta( $post_id, $meta_key, $new_value );
544
  }
545
  }
546
+ endif;
547
+
548
+ /**
549
+ * Update payment status
550
+ */
551
+ if( ! function_exists( 'mycred_cashcred_update_status' ) ):
552
+ function mycred_cashcred_update_status( $post_id, $meta_key, $meta_value ) {
553
+ check_site_update_post_meta( $post_id, $meta_key, $meta_value );
554
+
555
+ $mycred_pref_cashcreds = mycred_get_option( 'mycred_pref_cashcreds',false );
556
+
557
+ $point_type = check_site_get_post_meta( $post_id, 'point_type', true );
558
+ $points = check_site_get_post_meta( $post_id, 'points', true );
559
+ $cashcred_pay_method = check_site_get_post_meta( $post_id, 'gateway' , true );
560
+
561
+ $user_id = get_post_field( 'post_author', $post_id );
562
+ $user_balance = mycred_get_users_balance( $user_id, $point_type );
563
+ $payment_withdrawal_request = array(
564
+ 'point_type' => $point_type,
565
+ 'cashcred_pay_method' => $cashcred_pay_method,
566
+ 'points' => $points,
567
+ 'user_balance' => $user_balance,
568
+ 'user_id' => $user_id,
569
+ 'post_id' => $post_id
570
+ );
571
+
572
+ do_action( 'mycred_after_payment_request', $payment_withdrawal_request , $meta_value );
573
+ }
574
+ endif;
addons/cash-creds/modules/cashcred-module-core.php CHANGED
@@ -138,7 +138,6 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
138
  }
139
 
140
  public function cashcred_pay_now( $post_id = false, $auto = false ) {
141
-
142
  global $cashcred_instance;
143
 
144
  $payment_response = array();
@@ -155,6 +154,7 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
155
 
156
  if( ! empty( $_POST['cashcred_pay_method'] ) ) {
157
  $cashcred_pay_method = $_POST['cashcred_pay_method'];
 
158
  }
159
  else {
160
  return $this->response( false, array( 'message' => 'Invalid Payment Gateway' ), $auto );
@@ -163,31 +163,28 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
163
  if ( $cashcred_pay_method !== false && array_key_exists( $cashcred_pay_method, $cashcred_instance->active ) ) {
164
 
165
  $cashcred_instance->gateway = cashcred_gateway( $cashcred_pay_method );
166
-
167
  $cashcred_prefs = mycred_get_option( 'mycred_pref_cashcreds' , false );
168
-
169
  do_action( 'mycred_cashcred_process',$cashcred_pay_method, $cashcred_prefs );
170
  do_action( "mycred_cashcred_process_{$cashcred_pay_method}", $cashcred_prefs );
171
 
172
  $payment_response = $cashcred_instance->gateway->process( $post_id );
173
 
174
  if( $payment_response['status'] == true ) {
175
-
176
  $history_comments = $this->cashcred_update_payment_status( $post_id, $auto );
177
  $payment_response['cashcred_total'] = $history_comments['cashcred_total'];
178
  $payment_response['history_comments'] = $history_comments['comments'];
179
  return $this->response( true, $payment_response, $auto );
180
-
181
  }
182
  else {
183
-
184
  $payment_response['cashcred_total'] = '';
185
  $payment_response['date'] = '';
186
  $payment_response['history_comments'] = '';
187
  return $this->response( false, $payment_response, $auto );
188
 
189
  }
190
-
191
  }
192
  else {
193
 
@@ -271,7 +268,7 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
271
  $cashcred_total = $amount + $cashcred_total;
272
 
273
  update_user_meta( $user_id, 'cashcred_total', $cashcred_total );
274
- update_post_meta( $post_id, 'status', 'Approved' );
275
 
276
  $log_data = array(
277
  'post_id' => $post_id ,
@@ -389,7 +386,6 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
389
  public function process_new_withdraw_request( $gateway_id ){
390
 
391
  global $wp;
392
-
393
  $requested_url = home_url( $wp->request ) . $_SERVER['REQUEST_URI'];
394
  $point_type = sanitize_text_field( $_POST['cashcred_point_type'] );
395
  $cashcred_pay_method = sanitize_text_field( $_POST['cashcred_pay_method'] );
@@ -411,11 +407,13 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
411
 
412
  }
413
 
 
 
414
  $post_id = wp_insert_post( array(
415
  'post_title' => '',
416
  'post_type' => 'cashcred_withdrawal',
417
  'post_status' => 'publish',
418
- 'post_author' => get_current_user_id(),
419
  'ping_status' => 'closed',
420
  'comment_status' => 'open'
421
  ) );
@@ -432,18 +430,24 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
432
  check_site_add_post_meta( $post_id, 'currency', $currency, true );
433
  check_site_add_post_meta( $post_id, 'from', get_current_user_id(), true );
434
  check_site_add_post_meta( $post_id, 'user_ip', $_SERVER['REMOTE_ADDR'], true );
435
- check_site_add_post_meta( $post_id, 'status', 'Pending', true );
436
  check_site_add_post_meta( $post_id, 'manual', 'Manual', true );
437
 
438
- if( isset( $mycred_pref_cashcreds['gateway_prefs'][ $cashcred_pay_method ]["allow_auto_withdrawal"] ) &&
439
  $mycred_pref_cashcreds['gateway_prefs'][ $cashcred_pay_method ]["allow_auto_withdrawal"] == "yes" ) {
440
-
441
  $cashcred_auto_payment = $this->cashcred_pay_now( $post_id, true );
442
-
 
 
 
 
443
  $this->notification_message( $cashcred_auto_payment['message'], $requested_url );
444
 
445
  }
446
-
 
 
 
447
  $this->notification_message( '', $requested_url );
448
 
449
  }
138
  }
139
 
140
  public function cashcred_pay_now( $post_id = false, $auto = false ) {
 
141
  global $cashcred_instance;
142
 
143
  $payment_response = array();
154
 
155
  if( ! empty( $_POST['cashcred_pay_method'] ) ) {
156
  $cashcred_pay_method = $_POST['cashcred_pay_method'];
157
+
158
  }
159
  else {
160
  return $this->response( false, array( 'message' => 'Invalid Payment Gateway' ), $auto );
163
  if ( $cashcred_pay_method !== false && array_key_exists( $cashcred_pay_method, $cashcred_instance->active ) ) {
164
 
165
  $cashcred_instance->gateway = cashcred_gateway( $cashcred_pay_method );
 
166
  $cashcred_prefs = mycred_get_option( 'mycred_pref_cashcreds' , false );
167
+
168
  do_action( 'mycred_cashcred_process',$cashcred_pay_method, $cashcred_prefs );
169
  do_action( "mycred_cashcred_process_{$cashcred_pay_method}", $cashcred_prefs );
170
 
171
  $payment_response = $cashcred_instance->gateway->process( $post_id );
172
 
173
  if( $payment_response['status'] == true ) {
 
174
  $history_comments = $this->cashcred_update_payment_status( $post_id, $auto );
175
  $payment_response['cashcred_total'] = $history_comments['cashcred_total'];
176
  $payment_response['history_comments'] = $history_comments['comments'];
177
  return $this->response( true, $payment_response, $auto );
178
+
179
  }
180
  else {
181
+
182
  $payment_response['cashcred_total'] = '';
183
  $payment_response['date'] = '';
184
  $payment_response['history_comments'] = '';
185
  return $this->response( false, $payment_response, $auto );
186
 
187
  }
 
188
  }
189
  else {
190
 
268
  $cashcred_total = $amount + $cashcred_total;
269
 
270
  update_user_meta( $user_id, 'cashcred_total', $cashcred_total );
271
+ mycred_cashcred_update_status( $post_id, 'status', 'Approved' );
272
 
273
  $log_data = array(
274
  'post_id' => $post_id ,
386
  public function process_new_withdraw_request( $gateway_id ){
387
 
388
  global $wp;
 
389
  $requested_url = home_url( $wp->request ) . $_SERVER['REQUEST_URI'];
390
  $point_type = sanitize_text_field( $_POST['cashcred_point_type'] );
391
  $cashcred_pay_method = sanitize_text_field( $_POST['cashcred_pay_method'] );
407
 
408
  }
409
 
410
+ $user_id = get_current_user_id();
411
+
412
  $post_id = wp_insert_post( array(
413
  'post_title' => '',
414
  'post_type' => 'cashcred_withdrawal',
415
  'post_status' => 'publish',
416
+ 'post_author' => $user_id,
417
  'ping_status' => 'closed',
418
  'comment_status' => 'open'
419
  ) );
430
  check_site_add_post_meta( $post_id, 'currency', $currency, true );
431
  check_site_add_post_meta( $post_id, 'from', get_current_user_id(), true );
432
  check_site_add_post_meta( $post_id, 'user_ip', $_SERVER['REMOTE_ADDR'], true );
 
433
  check_site_add_post_meta( $post_id, 'manual', 'Manual', true );
434
 
435
+ if( isset( $mycred_pref_cashcreds['gateway_prefs'][ $cashcred_pay_method ]["allow_auto_withdrawal"] ) &&
436
  $mycred_pref_cashcreds['gateway_prefs'][ $cashcred_pay_method ]["allow_auto_withdrawal"] == "yes" ) {
437
+
438
  $cashcred_auto_payment = $this->cashcred_pay_now( $post_id, true );
439
+
440
+ if(isset( $cashcred_auto_payment['status'] ) && ! $cashcred_auto_payment['status'] ) {
441
+ mycred_cashcred_update_status( $post_id, 'status', 'Pending' );
442
+ }
443
+
444
  $this->notification_message( $cashcred_auto_payment['message'], $requested_url );
445
 
446
  }
447
+ else {
448
+ mycred_cashcred_update_status( $post_id, 'status', 'Pending' );
449
+ }
450
+
451
  $this->notification_message( '', $requested_url );
452
 
453
  }
addons/cash-creds/modules/cashcred-module-withdrawal.php CHANGED
@@ -1114,7 +1114,7 @@ if ( ! class_exists( 'cashCRED_Pending_Payments' ) ) :
1114
  'currency' => __( 'Currency', 'mycred' )
1115
  );
1116
 
1117
- check_site_update_post_meta( $post_id, 'status', $new_status );
1118
 
1119
  mycred_update_user_meta( $_POST['user_id'], cashcred_get_user_settings(), '', $updated_user_settings );
1120
 
@@ -1124,7 +1124,7 @@ if ( ! class_exists( 'cashCRED_Pending_Payments' ) ) :
1124
  $old_value = check_site_get_post_meta( $post_id, $meta_key, true );
1125
 
1126
  if ( $new_value != $old_value ) {
1127
- check_site_update_post_meta( $post_id, $meta_key, $new_value );
1128
  $changed_fields[] = $withdraw_request_messages[ $meta_key ];
1129
  }
1130
 
1114
  'currency' => __( 'Currency', 'mycred' )
1115
  );
1116
 
1117
+ mycred_cashcred_update_status( $post_id, 'status', $new_status );
1118
 
1119
  mycred_update_user_meta( $_POST['user_id'], cashcred_get_user_settings(), '', $updated_user_settings );
1120
 
1124
  $old_value = check_site_get_post_meta( $post_id, $meta_key, true );
1125
 
1126
  if ( $new_value != $old_value ) {
1127
+ mycred_cashcred_update_status( $post_id, $meta_key, $new_value );
1128
  $changed_fields[] = $withdraw_request_messages[ $meta_key ];
1129
  }
1130
 
addons/coupons/includes/mycred-coupon-functions.php CHANGED
@@ -16,7 +16,7 @@ if ( ! function_exists( 'mycred_get_coupon' ) ) :
16
 
17
  if ( isset( $mycred_coupon )
18
  && ( $mycred_coupon instanceof myCRED_Coupon )
19
- && ( $coupon_id === $mycred_coupon->post_id || $coupon_id === $mycred_coupon->code )
20
  ) {
21
  return $mycred_coupon;
22
  }
16
 
17
  if ( isset( $mycred_coupon )
18
  && ( $mycred_coupon instanceof myCRED_Coupon )
19
+ && ( $coupon_id === $mycred_coupon->post_id || strtoupper($coupon_id) === strtoupper($mycred_coupon->code))
20
  ) {
21
  return $mycred_coupon;
22
  }
addons/coupons/myCRED-addon-coupons.php CHANGED
@@ -33,16 +33,7 @@ if ( ! class_exists( 'myCRED_Coupons_Module' ) ) :
33
 
34
  parent::__construct( 'myCRED_Coupons_Module', array(
35
  'module_name' => 'coupons',
36
- 'defaults' => array(
37
- 'log' => 'Coupon redemption',
38
- 'invalid' => 'This is not a valid coupon',
39
- 'expired' => 'This coupon has expired',
40
- 'user_limit' => 'You have already used this coupon',
41
- 'min' => 'A minimum of %amount% is required to use this coupon',
42
- 'max' => 'A maximum of %amount% is required to use this coupon',
43
- 'excluded' => 'You can not use coupons.',
44
- 'success' => '%amount% successfully deposited into your account'
45
- ),
46
  'register' => false,
47
  'add_to_core' => true,
48
  'menu_pos' => 80
33
 
34
  parent::__construct( 'myCRED_Coupons_Module', array(
35
  'module_name' => 'coupons',
36
+ 'defaults' => mycred_get_addon_defaults( 'coupons' ),
 
 
 
 
 
 
 
 
 
37
  'register' => false,
38
  'add_to_core' => true,
39
  'menu_pos' => 80
addons/email-notices/includes/mycred-email-functions.php CHANGED
@@ -94,6 +94,13 @@ if ( ! function_exists( 'mycred_get_email_instances' ) ) :
94
  $instances['transfer_in'] = __( 'user receives a transfer', 'mycred' );
95
  }
96
 
 
 
 
 
 
 
 
97
  $instances['custom'] = __( 'a custom event occurs', 'mycred' );
98
 
99
  return apply_filters( 'mycred_email_instances', $instances );
@@ -121,7 +128,10 @@ if ( ! function_exists( 'mycred_get_email_triggers' ) ) :
121
  'rank_up' => array(),
122
  'rank_down' => array(),
123
  'transfer_out' => array(),
124
- 'transfer_in' => array()
 
 
 
125
  );
126
 
127
  $defaults = array(
@@ -414,9 +424,7 @@ if ( ! function_exists( 'mycred_get_event_emails' ) ) :
414
 
415
  if ( array_key_exists( $instance, $triggers[ $event_type ] ) && ! empty( $triggers[ $event_type ][ $instance ] ) )
416
  $notices = $triggers[ $event_type ][ $instance ];
417
-
418
  }
419
-
420
  return apply_filters( 'mycred_get_event_emails', $notices, $triggers, $point_type, $event_type, $instance );
421
 
422
  }
94
  $instances['transfer_in'] = __( 'user receives a transfer', 'mycred' );
95
  }
96
 
97
+ if ( class_exists( 'myCRED_cashCRED_Module' ) ) {
98
+ $instances['cashcred_approved'] = __( 'cashcred withdraw approval', 'mycred' );
99
+ $instances['cashcred_pending'] = __( 'cashcred withdraw pending', 'mycred' );
100
+ $instances['cashcred_cancel'] = __( 'cashcred cancel', 'mycred' );
101
+ }
102
+
103
+
104
  $instances['custom'] = __( 'a custom event occurs', 'mycred' );
105
 
106
  return apply_filters( 'mycred_email_instances', $instances );
128
  'rank_up' => array(),
129
  'rank_down' => array(),
130
  'transfer_out' => array(),
131
+ 'transfer_in' => array(),
132
+ 'cashcred_approved' => array(),
133
+ 'cashcred_pending' => array(),
134
+ 'cashcred_cancel' =>array()
135
  );
136
 
137
  $defaults = array(
424
 
425
  if ( array_key_exists( $instance, $triggers[ $event_type ] ) && ! empty( $triggers[ $event_type ][ $instance ] ) )
426
  $notices = $triggers[ $event_type ][ $instance ];
 
427
  }
 
428
  return apply_filters( 'mycred_get_event_emails', $notices, $triggers, $point_type, $event_type, $instance );
429
 
430
  }
addons/email-notices/includes/mycred-email-object.php CHANGED
@@ -361,15 +361,35 @@ if ( ! class_exists( 'myCRED_Email' ) ) :
361
 
362
  if ( ! empty( $content ) ) {
363
 
364
- if ( class_exists( 'myCRED_Ranks_Module' ) )
365
- {
366
- if ( is_array( $event ) && array_key_exists( 'ref_id', $event ) )
367
- {
368
- $rank = mycred_get_rank( $event['ref_id'] );
369
- $rank_title = $rank->title;
370
- $content = str_replace( '%rank_title%', $rank_title, $content );
371
- }
372
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
 
374
  $mycred = mycred( $point_type );
375
 
@@ -390,15 +410,50 @@ if ( ! class_exists( 'myCRED_Email' ) ) :
390
  if( $event['ref']==='transfer' ){
391
  $content = $mycred->template_tags_user( $content, $event['ref_id'] );
392
  $content = mycred_transfer_render_message( $content, $event['data'] );
393
- }elseif( $event['ref']==='woocommerce_payment' ){
 
394
  $content = str_replace( '%order_id%', $event['ref_id'], $content );
395
- }else{
 
396
  $content = $mycred->template_tags_user( $content, $event['user_id'] );
397
  }
398
 
399
  if ( array_key_exists( 'data', $event ) && is_array($event['data']) && ! empty( $event['data'] ) && array_key_exists( 'ref_type', $event['data'] ) && $event['data']['ref_type'] == 'post' )
400
  $content = $mycred->template_tags_post( $content, $event['ref_id'] );
401
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  $content = str_replace( '%amount%', $mycred->format_creds( $event['amount'] ), $content );
403
  $content = str_replace( '%new_balance%', $mycred->format_creds( $event['new'] ), $content );
404
  $content = str_replace( '%old_balance%', $mycred->format_creds( $event['old'] ), $content );
361
 
362
  if ( ! empty( $content ) ) {
363
 
364
+ if ( class_exists( 'myCRED_Ranks_Module' ) ) {
365
+ //rank-title
366
+ if ( is_array( $event ) && array_key_exists( 'ref_id', $event ) ) {
367
+
368
+ $rank = mycred_get_rank( $event['ref_id'] );
369
+
370
+ if ( is_object( $rank ) ) {
371
+
372
+ $rank_title = $rank->title;
373
+ $content = str_replace( '%rank_title%', $rank_title, $content );
374
+
375
+ }
376
+
377
+ }
378
+
379
+ //rank-image
380
+ if ( is_array( $event ) && array_key_exists( 'ref_id', $event ) ) {
381
+
382
+ $rank = mycred_get_rank( $event['ref_id'] );
383
+
384
+ if ( is_object( $rank ) ) {
385
+
386
+ $rank_image = '<img src = '.$rank->logo_url. '>';
387
+ $content = str_replace( '%rank_image%', $rank_image, $content );
388
+
389
+ }
390
+
391
+ }
392
+ }
393
 
394
  $mycred = mycred( $point_type );
395
 
410
  if( $event['ref']==='transfer' ){
411
  $content = $mycred->template_tags_user( $content, $event['ref_id'] );
412
  $content = mycred_transfer_render_message( $content, $event['data'] );
413
+ }
414
+ elseif( $event['ref']==='woocommerce_payment' ){
415
  $content = str_replace( '%order_id%', $event['ref_id'], $content );
416
+ }
417
+ else{
418
  $content = $mycred->template_tags_user( $content, $event['user_id'] );
419
  }
420
 
421
  if ( array_key_exists( 'data', $event ) && is_array($event['data']) && ! empty( $event['data'] ) && array_key_exists( 'ref_type', $event['data'] ) && $event['data']['ref_type'] == 'post' )
422
  $content = $mycred->template_tags_post( $content, $event['ref_id'] );
423
 
424
+ if ( class_exists( 'myCRED_Badge_Module' ) ) {
425
+
426
+ //Badge-image
427
+ if ( is_array( $event ) && array_key_exists( 'ref_id', $event ) ) {
428
+
429
+ $badge = mycred_get_badge( $event['ref_id'] );
430
+
431
+ if ( is_object( $badge ) ) {
432
+
433
+ $image_url = $badge->main_image_url;
434
+ $image_url = "<img src='".esc_url( $image_url )."' alt='Badge Image'>";
435
+ $content = str_replace( '%badge_image%', $image_url, $content );
436
+
437
+ }
438
+
439
+ }
440
+
441
+ //Badge-title
442
+ if ( is_array( $event ) && array_key_exists( 'ref_id', $event ) ) {
443
+
444
+ $badge = mycred_get_badge( $event['ref_id'] );
445
+
446
+ if ( is_object( $badge ) ) {
447
+
448
+ $title = $badge->title;
449
+ $content = str_replace( '%badge_title%', $title , $content );
450
+
451
+ }
452
+
453
+ }
454
+
455
+ }
456
+
457
  $content = str_replace( '%amount%', $mycred->format_creds( $event['amount'] ), $content );
458
  $content = str_replace( '%new_balance%', $mycred->format_creds( $event['new'] ), $content );
459
  $content = str_replace( '%old_balance%', $mycred->format_creds( $event['old'] ), $content );
addons/email-notices/myCRED-addon-email-notices.php CHANGED
@@ -35,22 +35,7 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) :
35
 
36
  parent::__construct( 'myCRED_Email_Notice_Module', array(
37
  'module_name' => 'emailnotices',
38
- 'defaults' => array(
39
- 'from' => array(
40
- 'name' => get_bloginfo( 'name' ),
41
- 'email' => get_bloginfo( 'admin_email' ),
42
- 'reply_to' => get_bloginfo( 'admin_email' )
43
- ),
44
- 'filter' => array(
45
- 'subject' => 0,
46
- 'content' => 0
47
- ),
48
- 'use_html' => true,
49
- 'content' => '',
50
- 'styling' => '',
51
- 'send' => '',
52
- 'override' => 0
53
- ),
54
  'register' => false,
55
  'add_to_core' => true,
56
  'menu_pos' => 90
@@ -75,14 +60,16 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) :
75
 
76
  add_action( 'mycred_badge_level_reached', array( $this, 'badge_check' ), 10, 3 );
77
  add_action( 'mycred_user_got_promoted', array( $this, 'rank_promotion' ), 10, 4 );
78
- add_action( 'mycred_user_got_demoted', array( $this, 'rank_demotion' ), 10, 4 );
79
-
80
- add_action( 'mycred_send_email_notices', 'mycred_email_notice_cron_job' );
81
 
82
  add_shortcode( MYCRED_SLUG . '_email_subscriptions', 'mycred_render_email_subscriptions' );
83
 
84
  add_action( 'mycred_admin_enqueue', array( $this, 'enqueue_scripts' ), $this->menu_pos );
85
  add_action( 'mycred_add_menu', array( $this, 'add_to_menu' ), $this->menu_pos );
 
 
86
 
87
  }
88
 
@@ -848,6 +835,46 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) :
848
  </div>
849
  </div>
850
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
851
  <?php
852
 
853
  }
@@ -1102,6 +1129,7 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) :
1102
 
1103
  }
1104
 
 
1105
  /**
1106
  * Rank Demotions
1107
  * @since 1.7.6
@@ -1136,6 +1164,48 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) :
1136
  }
1137
 
1138
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1139
 
1140
  /**
1141
  * Add to General Settings
35
 
36
  parent::__construct( 'myCRED_Email_Notice_Module', array(
37
  'module_name' => 'emailnotices',
38
+ 'defaults' => mycred_get_addon_defaults( 'emailnotices' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  'register' => false,
40
  'add_to_core' => true,
41
  'menu_pos' => 90
60
 
61
  add_action( 'mycred_badge_level_reached', array( $this, 'badge_check' ), 10, 3 );
62
  add_action( 'mycred_user_got_promoted', array( $this, 'rank_promotion' ), 10, 4 );
63
+ add_action( 'mycred_user_got_demoted', array( $this, 'rank_demotion' ), 10, 4 );
64
+
65
+ add_action( 'mycred_send_email_notices', 'mycred_email_notice_cron_job' );
66
 
67
  add_shortcode( MYCRED_SLUG . '_email_subscriptions', 'mycred_render_email_subscriptions' );
68
 
69
  add_action( 'mycred_admin_enqueue', array( $this, 'enqueue_scripts' ), $this->menu_pos );
70
  add_action( 'mycred_add_menu', array( $this, 'add_to_menu' ), $this->menu_pos );
71
+
72
+ add_action( 'mycred_after_payment_request', array( $this, 'after_payment_request' ), 10, 2);
73
 
74
  }
75
 
835
  </div>
836
  </div>
837
  </div>
838
+ <div class="row">
839
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
840
+ <h3><?php _e( 'Badge Related', 'mycred' ); ?></h3>
841
+ <div class="row">
842
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
843
+ <strong>%badge_title%</strong>
844
+ </div>
845
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
846
+ <div><?php _e( 'Gained badge title', 'mycred' ); ?></div>
847
+ </div>
848
+ </div>
849
+ <div class="row">
850
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
851
+ <strong>%badge_image%</strong>
852
+ </div>
853
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
854
+ <div><?php _e( 'Gained badge image', 'mycred' ); ?></div>
855
+ </div>
856
+ </div>
857
+ </div>
858
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
859
+ <h3><?php _e( 'Rank Related', 'mycred' ); ?></h3>
860
+ <div class="row">
861
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
862
+ <strong>%rank_title%</strong>
863
+ </div>
864
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
865
+ <div><?php _e( 'Users rank title', 'mycred' ); ?></div>
866
+ </div>
867
+ </div>
868
+ <div class="row">
869
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
870
+ <strong>%rank_image%</strong>
871
+ </div>
872
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
873
+ <div><?php _e( 'Users rank image', 'mycred' ); ?></div>
874
+ </div>
875
+ </div>
876
+ </div>
877
+ </div>
878
  <?php
879
 
880
  }
1129
 
1130
  }
1131
 
1132
+
1133
  /**
1134
  * Rank Demotions
1135
  * @since 1.7.6
1164
  }
1165
 
1166
  }
1167
+
1168
+ /**
1169
+ * Cashcred Pending
1170
+ * @since 2.1.1
1171
+ * @version 1.0
1172
+ */
1173
+ public function after_payment_request( $payment_withdrawal_request , $meta_value ) {
1174
+
1175
+ $point_type = $payment_withdrawal_request['point_type'];
1176
+ $user_id = $payment_withdrawal_request['user_id'];
1177
+
1178
+ $status = 'pending';
1179
+ if( $meta_value == 'Approved' )
1180
+ $status = 'approved';
1181
+ elseif( $meta_value == 'Cancelled' )
1182
+ $status = 'cancel';
1183
+
1184
+ $emails = mycred_get_event_emails( $point_type, 'generic', 'cashcred_' . $status );
1185
+ if ( empty( $emails ) ) return;
1186
+ $mycred = mycred( $point_type );
1187
+ $balance = $payment_withdrawal_request['user_balance'];
1188
+
1189
+ $request = array(
1190
+ 'ref' => 'cashcred_payment_process',
1191
+ 'user_id' => $user_id,
1192
+ 'amount' => $payment_withdrawal_request['points'],
1193
+ 'entry' => 'cashcred_payment_request',
1194
+ 'ref_id' => $payment_withdrawal_request['post_id'],
1195
+ 'data' => array( 'ref_type' => 'post' ),
1196
+ 'type' => $point_type,
1197
+ 'new' => $balance,
1198
+ 'old' => $balance
1199
+ );
1200
+
1201
+ foreach ( $emails as $notice_id ) {
1202
+ // Respect unsubscriptions
1203
+ if ( mycred_user_wants_email( $user_id, $notice_id ) )
1204
+ mycred_send_new_email( $notice_id, $request, $point_type );
1205
+
1206
+ }
1207
+
1208
+ }
1209
 
1210
  /**
1211
  * Add to General Settings
addons/gateway/carts/mycred-woocommerce.php CHANGED
@@ -304,7 +304,7 @@ if ( ! function_exists( 'mycred_init_woo_gateway' ) ) :
304
  return;
305
  }
306
 
307
- $user_id = get_current_user_id();
308
 
309
  // Make sure we have not been excluded
310
  if ( $this->mycred->exclude_user( $user_id ) ) {
304
  return;
305
  }
306
 
307
+ $user_id = apply_filters('mycred_woo_gateway_user_id', get_current_user_id(), $order_id);
308
 
309
  // Make sure we have not been excluded
310
  if ( $this->mycred->exclude_user( $user_id ) ) {
addons/notifications/myCRED-addon-notifications.php CHANGED
@@ -24,12 +24,7 @@ if ( ! class_exists( 'myCRED_Notifications_Module' ) ) :
24
 
25
  parent::__construct( 'myCRED_Notifications_Module', array(
26
  'module_name' => 'notifications',
27
- 'defaults' => array(
28
- 'life' => 7,
29
- 'template' => '<p>%entry%</p><h1>%cred_f%</h1>',
30
- 'use_css' => 1,
31
- 'duration' => 3
32
- ),
33
  'register' => false,
34
  'add_to_core' => true
35
  ) );
24
 
25
  parent::__construct( 'myCRED_Notifications_Module', array(
26
  'module_name' => 'notifications',
27
+ 'defaults' => mycred_get_addon_defaults( 'notifications' ),
 
 
 
 
 
28
  'register' => false,
29
  'add_to_core' => true
30
  ) );
addons/ranks/myCRED-addon-ranks.php CHANGED
@@ -44,24 +44,7 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
44
 
45
  parent::__construct( 'myCRED_Ranks_Module', array(
46
  'module_name' => 'rank',
47
- 'defaults' => array(
48
- 'manual' => 0,
49
- 'public' => 0,
50
- 'base' => 'current',
51
- 'slug' => MYCRED_RANK_KEY,
52
- 'bb_location' => 'top',
53
- 'bb_template' => 'Rank: %rank_title%',
54
- 'bp_location' => '',
55
- 'bb_template' => 'Rank: %rank_title%',
56
- 'order' => 'ASC',
57
- 'support' => array(
58
- 'content' => 0,
59
- 'excerpt' => 0,
60
- 'comments' => 0,
61
- 'page-attributes' => 0,
62
- 'custom-fields' => 0
63
- )
64
- ),
65
  'register' => false,
66
  'add_to_core' => false,
67
  'menu_pos' => 100
44
 
45
  parent::__construct( 'myCRED_Ranks_Module', array(
46
  'module_name' => 'rank',
47
+ 'defaults' => mycred_get_addon_defaults( 'rank' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  'register' => false,
49
  'add_to_core' => false,
50
  'menu_pos' => 100
addons/sell-content/includes/mycred-sell-functions.php CHANGED
@@ -372,6 +372,7 @@ if ( ! function_exists( 'mycred_content_purchase_has_expired' ) ) :
372
  if ( $length > 0 ) {
373
 
374
  $expiration = apply_filters( 'mycred_sell_expire_calc', absint( $length * HOUR_IN_SECONDS ), $length, $payment->user_id, $payment->ref_id );
 
375
  $expiration = $expiration + $payment->time;
376
 
377
  if ( $expiration <= current_time( 'timestamp' ) )
@@ -509,7 +510,41 @@ if ( ! function_exists( 'mycred_sell_content_template' ) ) :
509
 
510
  $post_type = get_post_type_object( $post->post_type );
511
  $url = mycred_get_permalink( $post->ID );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
 
 
 
 
 
 
 
513
  // Remove old tags that are no longer supported
514
  $template = str_replace( array( '%price%', '%expires%', ), '', $template );
515
 
@@ -871,3 +906,16 @@ if ( ! function_exists( 'mycred_get_post_type_options' ) ) :
871
 
872
  }
873
  endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  if ( $length > 0 ) {
373
 
374
  $expiration = apply_filters( 'mycred_sell_expire_calc', absint( $length * HOUR_IN_SECONDS ), $length, $payment->user_id, $payment->ref_id );
375
+
376
  $expiration = $expiration + $payment->time;
377
 
378
  if ( $expiration <= current_time( 'timestamp' ) )
510
 
511
  $post_type = get_post_type_object( $post->post_type );
512
  $url = mycred_get_permalink( $post->ID );
513
+
514
+ if ( $status == 'mycred-sell-insufficient' ) {
515
+ $post = mycred_get_post( $post_id );
516
+ $settings = mycred_sell_content_settings();
517
+ $prices = array();
518
+
519
+ foreach ( $settings['type'] as $point_type ) {
520
+
521
+ $setup = mycred_get_option( 'mycred_sell_this_' . $point_type );
522
+ $status = $setup['status'];
523
+
524
+ // Point type not enabled
525
+ if ( $status == 'disabled' ) continue;
526
+
527
+ $mycred = mycred( $point_type );
528
+ $price = mycred_get_content_price( $post->ID, $point_type, $user_id );
529
+
530
+ // Manual mode
531
+ if ( $settings['filters'][ $post->post_type ]['by'] == 'manual' ) {
532
+
533
+ $suffix = ( $point_type != MYCRED_DEFAULT_TYPE_KEY ) ? '_' . $point_type : '';
534
+
535
+ $manual_setup = (array) mycred_get_post_meta( $post->ID, 'myCRED_sell_content' . $suffix, true );
536
+
537
+ if ( ! empty( $manual_setup ) && array_key_exists( 'status', $manual_setup ) )
538
+ $status = $manual_setup['status'];
539
+
540
+ }
541
 
542
+ $prices[] = $mycred->format_creds( $price );
543
+ }
544
+
545
+ $template = str_replace( '%price%',implode(', ',$prices), $template );
546
+ }
547
+
548
  // Remove old tags that are no longer supported
549
  $template = str_replace( array( '%price%', '%expires%', ), '', $template );
550
 
906
 
907
  }
908
  endif;
909
+
910
+ /**
911
+ * Render remaining time
912
+ * @since 2.1.1
913
+ * @version 1.0
914
+ */
915
+ if ( ! function_exists( 'mycred_seconds_to_time' ) ) :
916
+ function mycred_seconds_to_time( $seconds ) {
917
+ $dtF = new \DateTime('@0');
918
+ $dtT = new \DateTime("@$seconds");
919
+ return $dtF->diff($dtT)->format('%a days, %h hours,%i minutes ,%s Seconds');
920
+ }
921
+ endif;
addons/sell-content/includes/mycred-sell-shortcodes.php CHANGED
@@ -227,12 +227,16 @@ if ( ! function_exists( 'mycred_render_sell_history' ) ) :
227
  if ( ! empty( $purchases ) ) {
228
  foreach ( $purchases as $entry ) {
229
 
230
- $mycred = mycred( $entry->ctype );
231
- $expirares_in = mycred_sell_content_get_expiration_length( $entry->ref_id, $entry->ctype );
232
-
 
 
 
233
  echo '<tr>';
234
 
235
  foreach ( $columns as $column_id => $column_label ) {
 
236
 
237
  if ( $column_id == 'col-date' )
238
  echo '<td class="' . $column_id . '">'.date( $date_format, $entry->time ).'</td>';
@@ -246,9 +250,26 @@ if ( ! function_exists( 'mycred_render_sell_history' ) ) :
246
  elseif ( $column_id == 'col-expires' ) {
247
 
248
  $expires = __( 'Never', 'mycred' );
249
- if ( $expirares_in > 0 )
250
- $expires = sprintf( _x( 'Purchase expires in %s', 'e.g. 10 hours', 'mycred' ), $expirares_in . ' ' . $expiration );
251
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  echo '<td class="' . $column_id . '">' . $expires . '</td>';
253
 
254
  }
227
  if ( ! empty( $purchases ) ) {
228
  foreach ( $purchases as $entry ) {
229
 
230
+ $mycred = mycred( $entry->ctype );
231
+
232
+ $hours = mycred_sell_content_get_expiration_length( $entry->ref_id, $entry->ctype );
233
+
234
+ $expires_in = apply_filters( 'mycred_sell_content_expires_in', $hours );
235
+
236
  echo '<tr>';
237
 
238
  foreach ( $columns as $column_id => $column_label ) {
239
+
240
 
241
  if ( $column_id == 'col-date' )
242
  echo '<td class="' . $column_id . '">'.date( $date_format, $entry->time ).'</td>';
250
  elseif ( $column_id == 'col-expires' ) {
251
 
252
  $expires = __( 'Never', 'mycred' );
 
 
253
 
254
+ if ( $expires_in > 0 ) {
255
+ $days = $hours * 60 * 60;
256
+ $date = time()- $entry->time;
257
+ $time_change = $days - $date;
258
+ $expires_in = mycred_seconds_to_time( $time_change );
259
+
260
+ if( $expires < $time_change ){
261
+
262
+ $expires = sprintf( _x( 'Purchase expires in %s', 'e.g. 10 hours', 'mycred' ), $expires_in. ' ' );
263
+
264
+ }
265
+ else{
266
+
267
+ $expires = 'Expired';
268
+
269
+ }
270
+
271
+ }
272
+
273
  echo '<td class="' . $column_id . '">' . $expires . '</td>';
274
 
275
  }
addons/sell-content/myCRED-addon-sell-content.php CHANGED
@@ -35,18 +35,7 @@ if ( ! class_exists( 'myCRED_Sell_Content_Module' ) ) :
35
  parent::__construct( 'myCRED_Sell_Content_Module', array(
36
  'module_name' => 'sell_content',
37
  'register' => false,
38
- 'defaults' => array(
39
- 'post_types' => 'post,page',
40
- 'filters' => array(),
41
- 'type' => array( MYCRED_DEFAULT_TYPE_KEY ),
42
- 'reload' => 0,
43
- 'working' => 'Processing ...',
44
- 'templates' => array(
45
- 'members' => '<div class="text-center"><h3>Premium Content</h3><p>Buy access to this content.</p><p>%buy_button%</p></div>',
46
- 'visitors' => '<div class="text-center"><h3>Premium Content</h3><p>Login to buy access to this content.</p></div>',
47
- 'cantafford' => '<div class="text-center"><h3>Premium Content</h3><p>Buy access to this content.</p><p><strong>Insufficient Funds</strong></p></div>'
48
- )
49
- ),
50
  'add_to_core' => true
51
  ) );
52
 
@@ -897,7 +886,7 @@ if ( ! class_exists( 'myCRED_Sell_Content_Module' ) ) :
897
  'textarea_rows' => 10
898
  ) );
899
 
900
- echo '<p>' . $this->core->available_template_tags( array( 'post' ) ) . '</p>';
901
 
902
  ?>
903
  </div>
35
  parent::__construct( 'myCRED_Sell_Content_Module', array(
36
  'module_name' => 'sell_content',
37
  'register' => false,
38
+ 'defaults' => mycred_get_addon_defaults( 'sell_content' ),
 
 
 
 
 
 
 
 
 
 
 
39
  'add_to_core' => true
40
  ) );
41
 
886
  'textarea_rows' => 10
887
  ) );
888
 
889
+ echo '<p>' . $this->core->available_template_tags( array( 'post' ), '%price%' ) . '</p>';
890
 
891
  ?>
892
  </div>
addons/stats/myCRED-addon-stats.php CHANGED
@@ -35,13 +35,7 @@ if ( ! class_exists( 'myCRED_Stats_Module' ) ) :
35
 
36
  parent::__construct( 'myCRED_Stats_Module', array(
37
  'module_name' => 'stats',
38
- 'defaults' => array(
39
- 'color_positive' => '',
40
- 'color_negative' => '',
41
- 'animate' => 1,
42
- 'bezier' => 1,
43
- 'caching' => 'off'
44
- ),
45
  'accordion' => false,
46
  'register' => false,
47
  'add_to_core' => false
35
 
36
  parent::__construct( 'myCRED_Stats_Module', array(
37
  'module_name' => 'stats',
38
+ 'defaults' => mycred_get_addon_defaults( 'stats' ),
 
 
 
 
 
 
39
  'accordion' => false,
40
  'register' => false,
41
  'add_to_core' => false
addons/transfer/myCRED-addon-transfer.php CHANGED
@@ -32,30 +32,7 @@ if ( ! class_exists( 'myCRED_Transfer_Module' ) ) :
32
 
33
  parent::__construct( 'myCRED_Transfer_Module', array(
34
  'module_name' => 'transfers',
35
- 'defaults' => array(
36
- 'types' => array( MYCRED_DEFAULT_TYPE_KEY ),
37
- 'logs' => array(
38
- 'sending' => 'Transfer of %plural% to %display_name%',
39
- 'receiving' => 'Transfer of %plural% from %display_name%'
40
- ),
41
- 'errors' => array(
42
- 'low' => 'You do not have enough %plural% to send.',
43
- 'over' => 'You have exceeded your %limit% transfer limit.'
44
- ),
45
- 'templates' => array(
46
- 'login' => '',
47
- 'balance' => 'Your current balance is %balance%',
48
- 'limit' => 'Your current %limit% transfer limit is %left%',
49
- 'button' => 'Transfer'
50
- ),
51
- 'autofill' => 'user_login',
52
- 'reload' => 1,
53
- 'message' => 0,
54
- 'limit' => array(
55
- 'amount' => 1000,
56
- 'limit' => 'none'
57
- )
58
- ),
59
  'register' => false,
60
  'add_to_core' => true
61
  ) );
32
 
33
  parent::__construct( 'myCRED_Transfer_Module', array(
34
  'module_name' => 'transfers',
35
+ 'defaults' => mycred_get_addon_defaults( 'transfers' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  'register' => false,
37
  'add_to_core' => true
38
  ) );
assets/css/mycred-front.css CHANGED
@@ -1 +1 @@
1
- .widget .myCRED-rank{float:right}.widget .myCRED-rank span{padding-right:4px;color:gray}.widget .myCRED-balance{display:block;margin-bottom:24px;text-align:center;font-size:larger}.widget .myCRED-leaderboard .cred{float:right}.widget .myCRED-leaderboard .first-item{font-size:110%}.widget .myCRED-history{padding:0;margin:0;list-style-type:none}.widget .myCRED-history .creds{float:right;padding:0;clear:left}.mycred-nav-rank img{display:inherit}input.mycred-submit-transfer.btn.btn-primary.btn-block.btn-lg{margin:20px 0}input.mycred-autofill.form-control.ui-autocomplete-input{margin-left:20px}input.form-control{margin-left:28px;margin-top:10px}.site .button:focus,.wp-block-button .wp-block-button__link:focus,.wp-block-search__button:focus,input[type=reset]:focus,input[type=submit]:focus{background:0;outline-offset:-6px;outline:2px solid currentColor}.site textarea:focus,input[type=color]:focus,input[type=date]:focus,input[type=datetime-local]:focus,input[type=datetime]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,input[type=password]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus{color:var(--form--color-text);outline-offset:2px;outline:0}.site .button:focus,.wp-block-button .wp-block-button__link:focus,.wp-block-search__button:focus,input[type=reset]:focus,input[type=submit]:focus{background:0;outline-offset:-6px;outline:0}span.form-control-static{text-transform:capitalize;font-weight:400;margin-left:20px}p.form-control-static{margin:0 16px}form#mycred-transfer-form-transfer{background:#f9f9f9;padding:25px;margin:150px 0;box-shadow:0 0 20px 0 rgb(0 0 0 / 20%),0 5px 5px 0 rgb(0 0 0 / 24%);border-radius:10px}form#mycred-transfer-form-donation{background:#f9f9f9;padding:25px;margin:150px 0;box-shadow:0 0 20px 0 rgb(0 0 0 / 20%),0 5px 5px 0 rgb(0 0 0 / 24%);border-radius:10px}input#mycred-transfer-form-message-field{margin-left:24px}span#mycred-transfer-form-amount-field{margin-left:28px}.mycred-badges-list-item img{width:25%;display:inline-block;float:left}.mycred-badges-list-item h3{color:red}.mycred-badges-list-item .mycred-left{float:left;width:72%;margin-left:15px}.mycred-badges-list-item .clear{clear:both}.mycred-badges-list-item .mycred-mr-l{margin-left:25px}.mycred-badges-list-item{border-top:0 solid #9c9c9c;min-height:180px;padding:15px 0;cursor:pointer}.mycred-badges-list-item~.mycred-badges-list-item{border-top-width:1px}.mycred-badges-list h3:first-child{margin-bottom:15px;margin-top:0}.mycred-badges-list-item.not-earned{filter:grayscale(1)}.mycred-tabset .mycred-badge-count{color:#fff;font-size:18px;background:#0173aa;border-radius:50%;padding:0 7px}.mycred-badges-list-item .mycred-sup-category{background:#0173aa;color:#fff;margin:0 3px;padding:2px 6px;font-size:14px;border-radius:4px}ul.mycred-badges-list-tabs{list-style-type:none;display:flex;margin:0;padding:0}ul.mycred-badges-list-tabs li{padding:10px;cursor:pointer;border:1px solid transparent;margin-right:5px;margin-bottom:-1px}ul.mycred-badges-list-tabs li.active{border:1px solid #47525d;border-bottom:1px solid #ccc}.mycred-badges-list-panels{border-top:1px solid #47525d}.mycred-badges-list-panel.active{display:initial}.mycred-badges-list-panel{display:none}.mycred-badge-count{color:#fff;font-size:18px;background:#0173aa;border-radius:50%;padding:0 7px;margin-left:5px}.mycred-badge-page .mycred-level-image{width:150px}.mycred-badge-page .mycred-badge-page-level{float:left;width:30%;text-align:center}.mycred-badge-page .mycred-level-requirement{font-size:19px;text-align:left}.mycred-badge-image{width:150px}.mycred-badge-page-level .mycred-level-image{width:70px}.mycred-float-left{float:left}.mycred-float-right{float:right}.mycred-badge-earner-grid img{width:150px;height:150px;padding:10px}.mycred-badge-earner-grid h4{margin:0}.mycred-badge-earner-grid{text-align:center}.mycred-badges-list-item p{margin-top:0}.mycred-left{float:left}.mycred-right{float:right}.mycred-clear{clear:both}.mycred-remove-margin{margin:0}.mycred-remove-padding{padding:0}.mycred-evidence-page .intro{margin-left:45px}.mycred-evidence-page p{font-size:19px;margin:0}.mycred-evidence-page a{text-decoration:none;color:red}.mycred-evidence-page .dashicons-yes-alt{line-height:inherit;color:green}.mycred-badge-page-level ul{margin-left:0;padding-left:20px}.mycred-badge-page-level .mycred-level-reward{text-align:left}.mycred-level-reward{margin-bottom:15px}.mycred-badge-page-level{margin-right:15px}.mycred-badges-list-item:hover{background:#efefef}.mycred-badge-congratulation-msg{background:#f0f0f0;padding:25px 10px;margin:20px 0;border-radius:5px}li.mycred-strike-off{text-decoration:line-through}
1
+ .widget .myCRED-rank{float:right}.widget .myCRED-rank span{padding-right:4px;color:gray}.widget .myCRED-balance{display:block;margin-bottom:24px;text-align:center;font-size:larger}.widget .myCRED-leaderboard .cred{float:right}.widget .myCRED-leaderboard .first-item{font-size:110%}.widget .myCRED-history{padding:0;margin:0;list-style-type:none}.widget .myCRED-history .creds{float:right;padding:0;clear:left}.mycred-nav-rank img{display:inherit}input.mycred-submit-transfer.btn.btn-primary.btn-block.btn-lg{margin:20px 0}input.mycred-autofill.form-control.ui-autocomplete-input{margin-left:20px}input.form-control{margin-left:28px;margin-top:10px}.site .button:focus,.wp-block-button .wp-block-button__link:focus,.wp-block-search__button:focus,input[type=reset]:focus,input[type=submit]:focus{background:0;outline-offset:-6px;outline:2px solid currentColor}.site textarea:focus,input[type=color]:focus,input[type=date]:focus,input[type=datetime-local]:focus,input[type=datetime]:focus,input[type=email]:focus,input[type=month]:focus,input[type=number]:focus,input[type=password]:focus,input[type=search]:focus,input[type=tel]:focus,input[type=text]:focus,input[type=time]:focus,input[type=url]:focus,input[type=week]:focus{color:var(--form--color-text);outline-offset:2px;outline:0}.site .button:focus,.wp-block-button .wp-block-button__link:focus,.wp-block-search__button:focus,input[type=reset]:focus,input[type=submit]:focus{background:0;outline-offset:-6px;outline:0}span.form-control-static{text-transform:capitalize;font-weight:400;margin-left:20px}p.form-control-static{margin:0 16px}form#mycred-transfer-form-transfer{background:#f9f9f9;padding:25px;margin:150px 0;box-shadow:0 0 20px 0 rgb(0 0 0 / 20%),0 5px 5px 0 rgb(0 0 0 / 24%);border-radius:10px}form#mycred-transfer-form-donation{background:#f9f9f9;padding:25px;margin:150px 0;box-shadow:0 0 20px 0 rgb(0 0 0 / 20%),0 5px 5px 0 rgb(0 0 0 / 24%);border-radius:10px}input#mycred-transfer-form-message-field{margin-left:24px}span#mycred-transfer-form-amount-field{margin-left:28px}.mycred-badges-list-item img{width:25%;display:inline-block;float:left}.mycred-badges-list-item h3{color:red}.mycred-badges-list-item .mycred-left{float:left;width:72%;margin-left:15px}.mycred-badges-list-item .clear{clear:both}.mycred-badges-list-item .mycred-mr-l{margin-left:25px}.mycred-badges-list-item{border-top:0 solid #9c9c9c;min-height:180px;padding:15px 0;cursor:pointer}.mycred-badges-list-item~.mycred-badges-list-item{border-top-width:1px}.mycred-badges-list h3:first-child{margin-bottom:15px;margin-top:0}.mycred-badges-list-item.not-earned{filter:grayscale(1)}.mycred-badges-list-item .mycred-sup-category{background:#0173aa;color:#fff;margin:0 3px;padding:2px 6px;font-size:14px;border-radius:4px}ul.mycred-badges-list-tabs{list-style-type:none;display:flex;margin:0;padding:0}ul.mycred-badges-list-tabs li{padding:10px;cursor:pointer;border:1px solid transparent;margin-right:5px;margin-bottom:-1px}ul.mycred-badges-list-tabs li.active{border:1px solid #47525d;border-bottom:1px solid #ccc}.mycred-badges-list-panels{border-top:1px solid #47525d}.mycred-badges-list-panel.active{display:initial}.mycred-badges-list-panel{display:none}.mycred-badge-count{color:#fff;font-size:18px;background:#0173aa;border-radius:50%;padding:0 7px;margin-left:5px}.mycred-badge-page .mycred-level-image{width:150px}.mycred-badge-page .mycred-badge-page-level{float:left;width:30%;text-align:center}.mycred-badge-page .mycred-level-requirement{font-size:19px;text-align:left}.mycred-badge-page .mycred-badge-image{width:150px}.mycred-badge-page-level .mycred-level-image{width:70px}.mycred-float-left{float:left}.mycred-float-right{float:right}.mycred-badge-earner-grid img{width:150px;height:150px;padding:10px}.mycred-badge-earner-grid h4{margin:0}.mycred-badge-earner-grid{text-align:center}.mycred-badges-list-item p{margin-top:0}.mycred-left{float:left}.mycred-right{float:right}.mycred-clear{clear:both}.mycred-remove-margin{margin:0}.mycred-remove-padding{padding:0}.mycred-evidence-page .intro{margin-left:45px}.mycred-evidence-page p{font-size:19px;margin:0}.mycred-evidence-page a{text-decoration:none;color:red}.mycred-evidence-page .dashicons-yes-alt{line-height:inherit;color:green}.mycred-badge-page-level ul{margin-left:0;padding-left:20px}.mycred-badge-page-level .mycred-level-reward{text-align:left}.mycred-level-reward{margin-bottom:15px}.mycred-badge-page-level{margin-right:15px}.mycred-badges-list-item:hover{background:#efefef}.mycred-badge-congratulation-msg{background:#f0f0f0;padding:25px 10px;margin:20px 0;border-radius:5px}li.mycred-strike-off{text-decoration:line-through}.mycred-search-bar{padding:10px 0}.mycred-history-wrapper .pagination>li{display:inline-block;padding:5px}
assets/js/admin.js ADDED
File without changes
includes/classes/class.query-log.php CHANGED
@@ -2529,7 +2529,7 @@ endif;
2529
  /**
2530
  * Get Used Log Entry Count
2531
  * @since 1.7
2532
- * @version 1.0
2533
  */
2534
  if ( ! function_exists( 'mycred_user_has_log_entries' ) ) :
2535
  function mycred_user_has_log_entries( $user_id = NULL ) {
@@ -2538,7 +2538,7 @@ if ( ! function_exists( 'mycred_user_has_log_entries' ) ) :
2538
  if ( $user_id === 0 ) return 0;
2539
 
2540
  $count = mycred_get_user_meta( $user_id, 'mycred-log-count', '', false );
2541
- if ( $count == '' ) {
2542
 
2543
  global $wpdb, $mycred_log_table;
2544
 
2529
  /**
2530
  * Get Used Log Entry Count
2531
  * @since 1.7
2532
+ * @version 1.1
2533
  */
2534
  if ( ! function_exists( 'mycred_user_has_log_entries' ) ) :
2535
  function mycred_user_has_log_entries( $user_id = NULL ) {
2538
  if ( $user_id === 0 ) return 0;
2539
 
2540
  $count = mycred_get_user_meta( $user_id, 'mycred-log-count', '', false );
2541
+ if ( empty( $count ) ) {
2542
 
2543
  global $wpdb, $mycred_log_table;
2544
 
includes/hooks/external/mycred-hook-invite-anyone.php CHANGED
@@ -71,7 +71,7 @@ function mycred_load_invite_anyone_hook() {
71
  if ( $this->prefs['accept_invite']['creds'] != 0 ) {
72
 
73
  // Hook into user activation
74
- if ( function_exists( 'buddypress' ) && apply_filters( 'bp_core_signup_send_activation_key', true ) )
75
  add_action( 'bp_core_activated_user', array( $this, 'verified_signup' ) );
76
 
77
  add_action( 'accepted_email_invite', array( $this, 'accept_invite' ), 10, 2 );
@@ -157,7 +157,7 @@ function mycred_load_invite_anyone_hook() {
157
  // Award Points
158
  $run = true;
159
 
160
- if ( function_exists( 'buddypress' ) && apply_filters( 'bp_core_signup_send_activation_key', true ) ) {
161
 
162
  $run = false;
163
 
71
  if ( $this->prefs['accept_invite']['creds'] != 0 ) {
72
 
73
  // Hook into user activation
74
+ if ( function_exists( 'buddypress' ) )
75
  add_action( 'bp_core_activated_user', array( $this, 'verified_signup' ) );
76
 
77
  add_action( 'accepted_email_invite', array( $this, 'accept_invite' ), 10, 2 );
157
  // Award Points
158
  $run = true;
159
 
160
+ if ( function_exists( 'buddypress' ) ) {
161
 
162
  $run = false;
163
 
includes/hooks/mycred-hook-referrals.php CHANGED
@@ -17,33 +17,37 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
17
  */
18
  function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
19
 
20
- parent::__construct( array(
21
- 'id' => 'affiliate',
22
- 'defaults' => array(
23
- 'visit' => array(
24
- 'creds' => 1,
25
- 'log' => '%plural% for referring a visitor',
26
- 'limit' => 1,
27
- 'limit_by' => 'total'
28
- ),
29
- 'signup' => array(
30
- 'creds' => 10,
31
- 'log' => '%plural% for referring a new member',
32
- 'limit' => 1,
33
- 'limit_by' => 'total'
34
- ),
35
- 'setup' => array(
36
- 'links' => 'username',
37
- 'IP' => 1
38
- ),
39
- 'buddypress' => array(
40
- 'profile' => 0,
41
- 'priority' => 10,
42
- 'title' => __( 'Affiliate Program', 'mycred' ),
43
- 'desc' => ''
44
- )
45
- )
46
- ), $hook_prefs, $type );
 
 
 
 
47
 
48
  // Let others play with the limit by
49
  $this->limit_by = apply_filters( 'mycred_affiliate_limit_by', array(
@@ -71,7 +75,7 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
71
  add_action( 'bp_after_profile_loop_content', array( $this, 'buddypress_profile' ), $this->prefs['buddypress']['priority'] );
72
 
73
  // Hook into user activation
74
- if ( function_exists( 'buddypress' ) && apply_filters( 'bp_core_signup_send_activation_key', true ) )
75
  add_action( 'mycred_bp_user_activated', array( $this, 'verified_signup' ) );
76
 
77
  // Register Shortcodes
@@ -328,13 +332,32 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
328
 
329
  if ( $this->ref_counts( $user_id, $IP, 'signup' ) ) {
330
 
 
 
 
 
331
  // Award when users account gets activated
332
- if ( function_exists( 'buddypress' ) && apply_filters( 'bp_core_signup_send_activation_key', true ) === true ) {
333
  mycred_add_user_meta( $new_user_id, 'referred_by', '', $user_id, true );
334
  mycred_add_user_meta( $new_user_id, 'referred_by_IP', '', $IP, true );
335
  mycred_add_user_meta( $new_user_id, 'referred_by_type', '', $this->mycred_type, true );
336
  }
337
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
338
  // Award now
339
  else {
340
 
@@ -599,10 +622,11 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
599
  <div class="form-group">
600
  <label for="<?php echo $this->field_id( array( 'signup' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
601
  <input type="text" name="<?php echo $this->field_name( array( 'signup' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'signup' => 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['signup']['log'] ); ?>" class="form-control" />
602
- <span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
603
  </div>
604
  </div>
605
- </div>
 
606
 
607
  <?php else : ?>
608
 
@@ -650,6 +674,7 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
650
  </div>
651
  </div>
652
  </div>
 
653
  <?php if ( function_exists( 'bp_is_active' ) && bp_is_active( 'xprofile' ) ) : ?>
654
  <div class="hook-instance">
655
  <h3><?php _e( 'BuddyPress Profile', 'mycred' ); ?></h3>
@@ -739,7 +764,7 @@ if ( ! function_exists( 'mycred_load_referral_program' ) ) :
739
  function mycred_load_referral_program() {
740
 
741
  // BuddyPress: Hook into user activation
742
- if ( function_exists( 'buddypress' ) && apply_filters( 'bp_core_signup_send_activation_key', true ) === true )
743
  add_action( 'bp_core_activated_user', 'mycred_detect_bp_user_activation' );
744
 
745
  // Logged in users do not get points
@@ -747,6 +772,7 @@ if ( ! function_exists( 'mycred_load_referral_program' ) ) :
747
 
748
  // Points for visits
749
  add_action( 'template_redirect', 'mycred_detect_referred_visits' );
 
750
 
751
  // Points for signups
752
  add_action( 'user_register', 'mycred_detect_referred_signups' );
17
  */
18
  function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
19
 
20
+ $hook_defaults = array(
21
+ 'id' => 'affiliate',
22
+ 'defaults' => array(
23
+ 'visit' => array(
24
+ 'creds' => 1,
25
+ 'log' => '%plural% for referring a visitor',
26
+ 'limit' => 1,
27
+ 'limit_by' => 'total'
28
+ ),
29
+ 'signup' => array(
30
+ 'creds' => 10,
31
+ 'log' => '%plural% for referring a new member',
32
+ 'limit' => 1,
33
+ 'limit_by' => 'total'
34
+ ),
35
+ 'setup' => array(
36
+ 'links' => 'username',
37
+ 'IP' => 1
38
+ ),
39
+ 'buddypress' => array(
40
+ 'profile' => 0,
41
+ 'priority' => 10,
42
+ 'title' => __( 'Affiliate Program', 'mycred' ),
43
+ 'desc' => ''
44
+ )
45
+ )
46
+ );
47
+
48
+ $hook_defaults = apply_filters( 'mycred_hook_referrals', $hook_defaults );
49
+
50
+ parent::__construct( $hook_defaults , $hook_prefs, $type );
51
 
52
  // Let others play with the limit by
53
  $this->limit_by = apply_filters( 'mycred_affiliate_limit_by', array(
75
  add_action( 'bp_after_profile_loop_content', array( $this, 'buddypress_profile' ), $this->prefs['buddypress']['priority'] );
76
 
77
  // Hook into user activation
78
+ if ( function_exists( 'buddypress' ) )
79
  add_action( 'mycred_bp_user_activated', array( $this, 'verified_signup' ) );
80
 
81
  // Register Shortcodes
332
 
333
  if ( $this->ref_counts( $user_id, $IP, 'signup' ) ) {
334
 
335
+ $hooks = mycred_get_option( 'mycred_pref_hooks', false );
336
+
337
+ $active_hooks = $hooks['active'];
338
+
339
  // Award when users account gets activated
340
+ if ( function_exists( 'buddypress' ) ) {
341
  mycred_add_user_meta( $new_user_id, 'referred_by', '', $user_id, true );
342
  mycred_add_user_meta( $new_user_id, 'referred_by_IP', '', $IP, true );
343
  mycred_add_user_meta( $new_user_id, 'referred_by_type', '', $this->mycred_type, true );
344
  }
345
 
346
+ if ( is_plugin_active( 'mycred-woocommerce-plus/mycred-woocommerce-plus.php' ) && in_array( 'affiliate', $active_hooks ) )
347
+ {
348
+ $user_log = array(
349
+ 'reference' => 'signup_referral',
350
+ 'referrer' => $user_id,
351
+ 'creds' => $this->prefs['signup']['creds'],
352
+ 'log' => $this->prefs['signup']['log'],
353
+ 'referred' => $new_user_id,
354
+ 'IP' => $IP,
355
+ 'point_type' => $this->mycred_type
356
+ );
357
+
358
+ do_action( 'mycred_after_signup_referred', $user_log );
359
+ }
360
+
361
  // Award now
362
  else {
363
 
622
  <div class="form-group">
623
  <label for="<?php echo $this->field_id( array( 'signup' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
624
  <input type="text" name="<?php echo $this->field_name( array( 'signup' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'signup' => 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['signup']['log'] ); ?>" class="form-control" />
625
+ <span class="description"><?php echo $this->available_template_tags( array( 'general' ), '%user_name%' ); ?></span>
626
  </div>
627
  </div>
628
+ <?php do_action( 'mycred_after_referring_signups', $this, $prefs ); ?>
629
+ </div>
630
 
631
  <?php else : ?>
632
 
674
  </div>
675
  </div>
676
  </div>
677
+
678
  <?php if ( function_exists( 'bp_is_active' ) && bp_is_active( 'xprofile' ) ) : ?>
679
  <div class="hook-instance">
680
  <h3><?php _e( 'BuddyPress Profile', 'mycred' ); ?></h3>
764
  function mycred_load_referral_program() {
765
 
766
  // BuddyPress: Hook into user activation
767
+ if ( function_exists( 'buddypress' ) )
768
  add_action( 'bp_core_activated_user', 'mycred_detect_bp_user_activation' );
769
 
770
  // Logged in users do not get points
772
 
773
  // Points for visits
774
  add_action( 'template_redirect', 'mycred_detect_referred_visits' );
775
+ add_action( 'login_init', 'mycred_detect_referred_visits' );
776
 
777
  // Points for signups
778
  add_action( 'user_register', 'mycred_detect_referred_signups' );
includes/importers/mycred-cubepoints.php CHANGED
@@ -27,7 +27,7 @@ if ( ! class_exists( 'myCRED_Importer_CubePoints' ) ) :
27
  $this->import_page = MYCRED_SLUG . '-import-cp';
28
  $this->delimiter = empty( $_POST['delimiter'] ) ? ',' : (string) strip_tags( trim( $_POST['delimiter'] ) );
29
  $this->documentation = 'http://codex.mycred.me/chapter-ii/import-data/import-cubepoints/';
30
-
31
  }
32
 
33
  /**
@@ -72,6 +72,8 @@ if ( ! class_exists( 'myCRED_Importer_CubePoints' ) ) :
72
  return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
73
  }
74
 
 
 
75
  /**
76
  * Checks CubePoints Installation
77
  * @version 1.1
@@ -90,6 +92,66 @@ if ( ! class_exists( 'myCRED_Importer_CubePoints' ) ) :
90
 
91
  }
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  /**
94
  * Import Function
95
  * Handles the actual import based on a given file.
@@ -109,6 +171,8 @@ if ( ! class_exists( 'myCRED_Importer_CubePoints' ) ) :
109
  if ( ! mycred_point_type_exists( $point_type ) ) $point_type = MYCRED_DEFAULT_TYPE_KEY;
110
  $mycred = mycred( $type );
111
 
 
 
112
  // Import Log
113
  if ( $action == 'log' || $action == 'both' ) {
114
 
@@ -251,7 +315,9 @@ if ( ! class_exists( 'myCRED_Importer_CubePoints' ) ) :
251
  if ( $ref_id === false && ! empty( $entry_data ) && ! is_array( $entry_data ) ) $ref_id = absint( $entry->data );
252
  if ( $ref_id === false ) $ref_id = 0;
253
 
254
- $mycred->add_to_log( $reference, $entry->uid, $entry->points, $log_entry, $ref_id, $data, $point_type );
 
 
255
 
256
  $loop ++;
257
  $this->imported++;
27
  $this->import_page = MYCRED_SLUG . '-import-cp';
28
  $this->delimiter = empty( $_POST['delimiter'] ) ? ',' : (string) strip_tags( trim( $_POST['delimiter'] ) );
29
  $this->documentation = 'http://codex.mycred.me/chapter-ii/import-data/import-cubepoints/';
30
+
31
  }
32
 
33
  /**
72
  return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
73
  }
74
 
75
+
76
+
77
  /**
78
  * Checks CubePoints Installation
79
  * @version 1.1
92
 
93
  }
94
 
95
+ public function add_to_log( $ref = '', $user_id = '', $amount = '', $entry = '', $ref_id = '', $data = '', $type = NULL, $entrytime ) {
96
+
97
+ // Minimum Requirements: Reference not empty, User ID not empty and Amount is not empty
98
+ if ( empty( $ref ) || empty( $user_id ) || empty( $amount ) || empty( $entry ) ) return false;
99
+
100
+ $myCred = mycred($type);
101
+
102
+ // Prep amount
103
+ $amount = $myCred->number( $amount );
104
+ $amount = $myCred->enforce_max( $user_id, $amount );
105
+ if ( $amount === $myCred->zero() || $amount == 0 ) return false;
106
+
107
+ $insert_id = 0;
108
+
109
+ mycred_update_users_history( $user_id, $type, $ref, $ref_id, $amount );
110
+
111
+ // Option to disable logging
112
+ if ( MYCRED_ENABLE_LOGGING ) {
113
+
114
+ global $wpdb, $mycred_types;
115
+
116
+ // Strip HTML from log entry
117
+ $entry = $myCred->allowed_tags( $entry );
118
+
119
+ // Point type
120
+ if ( $type === NULL || ! array_key_exists( $type, $mycred_types ) )
121
+ $type = $myCred->get_point_type_key();
122
+
123
+
124
+ $insert = array(
125
+ 'ref' => $ref,
126
+ 'ref_id' => $ref_id,
127
+ 'user_id' => (int) $user_id,
128
+ 'creds' => $amount,
129
+ 'ctype' => $type,
130
+ 'time' => $entrytime,
131
+ 'entry' => $entry,
132
+ 'data' => ( is_array( $data ) || is_object( $data ) ) ? serialize( $data ) : $data
133
+ );
134
+
135
+ // Insert into DB
136
+ $wpdb->insert(
137
+ $myCred->log_table,
138
+ $insert,
139
+ array( '%s', '%d', '%d', '%s', '%s', '%d', '%s', ( is_numeric( $data ) ) ? '%d' : '%s' )
140
+ );
141
+
142
+ $insert_id = $wpdb->insert_id;
143
+
144
+ wp_cache_delete( 'mycred_references' . $type, MYCRED_SLUG );
145
+
146
+ delete_transient( 'mycred_log_entries' );
147
+
148
+ }
149
+
150
+ return $insert;
151
+
152
+ }
153
+
154
+
155
  /**
156
  * Import Function
157
  * Handles the actual import based on a given file.
171
  if ( ! mycred_point_type_exists( $point_type ) ) $point_type = MYCRED_DEFAULT_TYPE_KEY;
172
  $mycred = mycred( $type );
173
 
174
+
175
+
176
  // Import Log
177
  if ( $action == 'log' || $action == 'both' ) {
178
 
315
  if ( $ref_id === false && ! empty( $entry_data ) && ! is_array( $entry_data ) ) $ref_id = absint( $entry->data );
316
  if ( $ref_id === false ) $ref_id = 0;
317
 
318
+ $this->add_to_log( $reference, $entry->uid, $entry->points, $log_entry, $ref_id, $data, $point_type, $entry->timestamp );
319
+
320
+
321
 
322
  $loop ++;
323
  $this->imported++;
includes/mycred-about.php CHANGED
@@ -400,7 +400,7 @@ function mycred_about_page() {
400
 
401
  <div class="button-wrap mycred-clear">
402
  <div class="left">
403
- <?php
404
  if ( !is_mycred_ready() ) {
405
  ?>
406
  <a href="<?php echo admin_url( 'plugins.php?page=' . MYCRED_SLUG . '-setup&mycred_tour_guide=1' ) ?>" id="first_setup" onclick="startTour()" class="mycred-btn mycred-btn-block mycred-btn-lg mycred-btn-orange">
@@ -410,7 +410,7 @@ function mycred_about_page() {
410
  }
411
  ?>
412
  </div>
413
- <div class="<?php if ( is_mycred_ready() ) echo 'center'; else echo 'right'; ?>">
414
  <a href="https://codex.mycred.me/" class="mycred-btn mycred-btn-block mycred-btn-lg mycred-btn-grey" target="_blank" rel="noopener noreferrer">
415
  Documentation
416
  </a>
400
 
401
  <div class="button-wrap mycred-clear">
402
  <div class="left">
403
+ <?php
404
  if ( !is_mycred_ready() ) {
405
  ?>
406
  <a href="<?php echo admin_url( 'plugins.php?page=' . MYCRED_SLUG . '-setup&mycred_tour_guide=1' ) ?>" id="first_setup" onclick="startTour()" class="mycred-btn mycred-btn-block mycred-btn-lg mycred-btn-orange">
410
  }
411
  ?>
412
  </div>
413
+ <div class="<?php echo ( is_mycred_ready() ? 'center' : 'right' ); ?>">
414
  <a href="https://codex.mycred.me/" class="mycred-btn mycred-btn-block mycred-btn-lg mycred-btn-grey" target="_blank" rel="noopener noreferrer">
415
  Documentation
416
  </a>
includes/mycred-functions.php CHANGED
@@ -441,6 +441,12 @@ if ( ! class_exists( 'myCRED_Settings' ) ) :
441
 
442
  }
443
 
 
 
 
 
 
 
444
  return $content;
445
 
446
  }
@@ -1870,6 +1876,9 @@ if ( ! function_exists( 'mycred_get_addon_settings' ) ) :
1870
  if ( $settings === false && isset( $main_type->$addon ) )
1871
  $settings = $main_type->$addon;
1872
 
 
 
 
1873
  }
1874
 
1875
  return apply_filters( 'mycred_get_addon_settings', $settings, $addon, $point_type );
@@ -3350,19 +3359,21 @@ if ( ! function_exists( 'mycred_plugin_deactivation' ) ) :
3350
  wp_clear_scheduled_hook( 'mycred_banking_interest_compound' );
3351
  wp_clear_scheduled_hook( 'mycred_banking_interest_payout' );
3352
 
 
 
 
 
 
 
 
3353
  do_action( 'mycred_deactivation' );
3354
 
3355
  }
3356
  endif;
3357
 
3358
- /**
3359
- * Runs when the plugin is deleted
3360
- * @since 1.3
3361
- * @version 1.0.2
3362
- */
3363
  if ( ! function_exists( 'mycred_plugin_uninstall' ) ) :
3364
  function mycred_plugin_uninstall() {
3365
-
3366
  // Load Installer
3367
  require_once myCRED_INCLUDES_DIR . 'mycred-install.php';
3368
  $installer = mycred_installer();
@@ -3656,8 +3667,7 @@ endif;
3656
  * @version 1.0
3657
  */
3658
  if ( !function_exists( 'mycred_badge_level_req_check' ) ):
3659
- function mycred_badge_level_req_check( $badge_id, $level_index = 0 )
3660
- {
3661
  $content = '';
3662
  global $wpdb;
3663
  $user_id = get_current_user_id();
@@ -3731,4 +3741,145 @@ if ( !function_exists( 'mycred_badge_level_req_check' ) ):
3731
 
3732
  return $content;
3733
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3734
  endif;
441
 
442
  }
443
 
444
+ if( $reference == 'signup_referral' ){
445
+
446
+ $content = $this->template_tags_user( $content, $ref_id, $data );
447
+
448
+ }
449
+
450
  return $content;
451
 
452
  }
1876
  if ( $settings === false && isset( $main_type->$addon ) )
1877
  $settings = $main_type->$addon;
1878
 
1879
+ if ( empty( $settings ) )
1880
+ $settings = mycred_get_addon_defaults( $addon );
1881
+
1882
  }
1883
 
1884
  return apply_filters( 'mycred_get_addon_settings', $settings, $addon, $point_type );
3359
  wp_clear_scheduled_hook( 'mycred_banking_interest_compound' );
3360
  wp_clear_scheduled_hook( 'mycred_banking_interest_payout' );
3361
 
3362
+ /**
3363
+ * Runs when the plugin is deleted
3364
+ * @since 1.3
3365
+ * @version 1.2
3366
+ */
3367
+ register_uninstall_hook( myCRED_THIS, 'mycred_plugin_uninstall' );
3368
+
3369
  do_action( 'mycred_deactivation' );
3370
 
3371
  }
3372
  endif;
3373
 
 
 
 
 
 
3374
  if ( ! function_exists( 'mycred_plugin_uninstall' ) ) :
3375
  function mycred_plugin_uninstall() {
3376
+
3377
  // Load Installer
3378
  require_once myCRED_INCLUDES_DIR . 'mycred-install.php';
3379
  $installer = mycred_installer();
3667
  * @version 1.0
3668
  */
3669
  if ( !function_exists( 'mycred_badge_level_req_check' ) ):
3670
+ function mycred_badge_level_req_check( $badge_id, $level_index = 0 ) {
 
3671
  $content = '';
3672
  global $wpdb;
3673
  $user_id = get_current_user_id();
3741
 
3742
  return $content;
3743
  }
3744
+ endif;
3745
+
3746
+ /**
3747
+ * Get Addon default Settings
3748
+ * @since 2.1.1
3749
+ * @version 1.0
3750
+ */
3751
+ if ( ! function_exists( 'mycred_get_addon_defaults' ) ) :
3752
+ function mycred_get_addon_defaults( $addon = '' ) {
3753
+
3754
+ $settings = array();
3755
+
3756
+ switch ( $addon ) {
3757
+ case 'badges':
3758
+ $settings = array(
3759
+ 'show_level_description' => 0,
3760
+ 'show_congo_text' => 0,
3761
+ 'show_steps_to_achieve' => 0,
3762
+ 'show_levels' => 0,
3763
+ 'show_level_points' => 0,
3764
+ 'show_earners' => 0,
3765
+ 'open_badge' => 0,
3766
+ 'open_badge_evidence_page' => 0,
3767
+ 'buddypress' => '',
3768
+ 'bbpress' => '',
3769
+ 'show_all_bp' => 0,
3770
+ 'show_all_bb' => 0
3771
+ );
3772
+ break;
3773
+ case 'coupons':
3774
+ $settings = array(
3775
+ 'log' => 'Coupon redemption',
3776
+ 'invalid' => 'This is not a valid coupon',
3777
+ 'expired' => 'This coupon has expired',
3778
+ 'user_limit' => 'You have already used this coupon',
3779
+ 'min' => 'A minimum of %amount% is required to use this coupon',
3780
+ 'max' => 'A maximum of %amount% is required to use this coupon',
3781
+ 'excluded' => 'You can not use coupons.',
3782
+ 'success' => '%amount% successfully deposited into your account'
3783
+ );
3784
+ break;
3785
+ case 'emailnotices':
3786
+ $settings = array(
3787
+ 'from' => array(
3788
+ 'name' => get_bloginfo( 'name' ),
3789
+ 'email' => get_bloginfo( 'admin_email' ),
3790
+ 'reply_to' => get_bloginfo( 'admin_email' )
3791
+ ),
3792
+ 'filter' => array(
3793
+ 'subject' => 0,
3794
+ 'content' => 0
3795
+ ),
3796
+ 'use_html' => true,
3797
+ 'content' => '',
3798
+ 'styling' => '',
3799
+ 'send' => '',
3800
+ 'override' => 0
3801
+ );
3802
+ break;
3803
+ case 'notifications':
3804
+ $settings = array(
3805
+ 'life' => 7,
3806
+ 'template' => '<p>%entry%</p><h1>%cred_f%</h1>',
3807
+ 'use_css' => 1,
3808
+ 'duration' => 3
3809
+ );
3810
+ break;
3811
+ case 'rank':
3812
+ $settings = array(
3813
+ 'manual' => 0,
3814
+ 'public' => 0,
3815
+ 'base' => 'current',
3816
+ 'slug' => MYCRED_RANK_KEY,
3817
+ 'bb_location' => 'top',
3818
+ 'bb_template' => 'Rank: %rank_title%',
3819
+ 'bp_location' => '',
3820
+ 'bb_template' => 'Rank: %rank_title%',
3821
+ 'order' => 'ASC',
3822
+ 'support' => array(
3823
+ 'content' => 0,
3824
+ 'excerpt' => 0,
3825
+ 'comments' => 0,
3826
+ 'page-attributes' => 0,
3827
+ 'custom-fields' => 0
3828
+ )
3829
+ );
3830
+ break;
3831
+ case 'sell_content':
3832
+ $settings = array(
3833
+ 'post_types' => 'post,page',
3834
+ 'filters' => array(),
3835
+ 'type' => array( MYCRED_DEFAULT_TYPE_KEY ),
3836
+ 'reload' => 0,
3837
+ 'working' => 'Processing ...',
3838
+ 'templates' => array(
3839
+ 'members' => '<div class="text-center"><h3>Premium Content</h3><p>Buy access to this content.</p><p>%buy_button%</p></div>',
3840
+ 'visitors' => '<div class="text-center"><h3>Premium Content</h3><p>Login to buy access to this content.</p></div>',
3841
+ 'cantafford' => '<div class="text-center"><h3>Premium Content</h3><p>Buy access to this content.</p><p><strong>Insufficient Funds</strong></p></div>'
3842
+ )
3843
+ );
3844
+ break;
3845
+ case 'stats':
3846
+ $settings = array(
3847
+ 'color_positive' => '',
3848
+ 'color_negative' => '',
3849
+ 'animate' => 1,
3850
+ 'bezier' => 1,
3851
+ 'caching' => 'off'
3852
+ );
3853
+ break;
3854
+ case 'transfers':
3855
+ $settings = array(
3856
+ 'types' => array( MYCRED_DEFAULT_TYPE_KEY ),
3857
+ 'logs' => array(
3858
+ 'sending' => 'Transfer of %plural% to %display_name%',
3859
+ 'receiving' => 'Transfer of %plural% from %display_name%'
3860
+ ),
3861
+ 'errors' => array(
3862
+ 'low' => 'You do not have enough %plural% to send.',
3863
+ 'over' => 'You have exceeded your %limit% transfer limit.'
3864
+ ),
3865
+ 'templates' => array(
3866
+ 'login' => '',
3867
+ 'balance' => 'Your current balance is %balance%',
3868
+ 'limit' => 'Your current %limit% transfer limit is %left%',
3869
+ 'button' => 'Transfer'
3870
+ ),
3871
+ 'autofill' => 'user_login',
3872
+ 'reload' => 1,
3873
+ 'message' => 0,
3874
+ 'limit' => array(
3875
+ 'amount' => 1000,
3876
+ 'limit' => 'none'
3877
+ )
3878
+ );
3879
+ break;
3880
+ }
3881
+
3882
+ return apply_filters( 'mycred_get_addon_defaults', $settings, $addon );
3883
+
3884
+ }
3885
  endif;
includes/mycred-install.php CHANGED
@@ -9,7 +9,7 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
9
  * @version 1.2
10
  */
11
  if ( ! class_exists( 'myCRED_Install' ) ) :
12
- final class myCRED_Install {
13
 
14
  // Instnace
15
  protected static $_instance = NULL;
@@ -123,7 +123,7 @@ if ( ! class_exists( 'myCRED_Install' ) ) :
123
  * @version 1.4
124
  */
125
  public static function reactivate() {
126
-
127
  $version = get_option( 'mycred_version', false );
128
  do_action( 'mycred_reactivation', $version );
129
 
@@ -172,6 +172,24 @@ if ( ! class_exists( 'myCRED_Install' ) ) :
172
 
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  /**
176
  * Uninstall
177
  * Removes all myCRED related data from the database.
@@ -180,25 +198,16 @@ if ( ! class_exists( 'myCRED_Install' ) ) :
180
  */
181
  public static function uninstall() {
182
 
183
- global $wpdb;
184
 
185
  $mycred_types = mycred_get_types();
186
 
187
- $option_id = apply_filters( 'mycred_option_id', 'mycred_pref_hooks' );
188
  // Options to delete
189
- $options_to_delete = array(
190
- 'mycred_setup_completed',
191
- 'mycred_pref_core',
192
- $option_id,
193
- 'mycred_pref_addons',
194
  'mycred_pref_bank',
195
  'mycred_pref_remote',
196
- 'mycred_types',
197
  'woocommerce_mycred_settings',
198
  'mycred_sell_content_one_seven_updated',
199
- 'mycred_version',
200
- 'mycred_version_db',
201
- 'mycred_key',
202
  'mycred_network',
203
  'widget_mycred_widget_balance',
204
  'widget_mycred_widget_list',
@@ -211,37 +220,39 @@ if ( ! class_exists( 'myCRED_Install' ) ) :
211
  MYCRED_SLUG . '-last-clear-stats'
212
  );
213
 
214
- foreach ( $mycred_types as $type => $label ) {
215
- $options_to_delete[] = 'mycred_pref_core_' . $type;
216
- $options_to_delete[] = 'mycred-cache-total-' . $type;
217
- }
218
- $options_to_delete = apply_filters( 'mycred_uninstall_options', $options_to_delete );
219
 
220
- if ( ! empty( $options_to_delete ) ) {
 
221
 
222
- // Multisite installations where we are not using the "Master Template" feature
223
- if ( is_multisite() && ! mycred_override_settings() ) {
224
 
225
- // Remove settings on all sites where myCRED was enabled
226
- $site_ids = get_sites( array( 'fields' => 'ids' ) );
227
- foreach ( $site_ids as $site_id ) {
228
-
229
- // Check if myCRED was installed
230
- $installed = get_blog_option( $site_id, 'mycred_setup_completed', false );
231
- if ( $installed === false ) continue;
232
-
233
- foreach ( $options_to_delete as $option_id )
234
- delete_blog_option( $site_id, $option_id );
235
 
236
- }
237
 
238
- }
 
 
239
 
240
- else {
241
 
242
- foreach ( $options_to_delete as $option_id )
243
- delete_option( $option_id );
 
 
 
 
 
 
244
 
 
 
 
245
  }
246
 
247
  }
@@ -264,7 +275,46 @@ if ( ! class_exists( 'myCRED_Install' ) ) :
264
  }
265
 
266
  // Delete all custom post types created by myCRED
267
- $post_types = get_mycred_post_types();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  $mycred_post_types_to_delete = apply_filters( 'mycred_uninstall_post_types', $post_types );
269
 
270
  if ( ! empty( $mycred_post_types_to_delete ) ) {
@@ -274,7 +324,7 @@ if ( ! class_exists( 'myCRED_Install' ) ) :
274
  if ( $posts->have_posts() ) {
275
 
276
  // wp_delete_post() will also handle all post meta deletions
277
- foreach ( $query->posts as $post_id )
278
  wp_delete_post( $post_id, true );
279
 
280
  }
@@ -283,97 +333,168 @@ if ( ! class_exists( 'myCRED_Install' ) ) :
283
  }
284
  }
285
 
286
- if ( ! defined( 'MYCRED_RANK_KEY' ) ) define( 'MYCRED_RANK_KEY', 'mycred_rank' );
287
- if ( ! defined( 'MYCRED_BADGE_KEY' ) ) define( 'MYCRED_BADGE_KEY', 'mycred_badge' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
 
289
- // Delete user meta
290
- // 'meta_key' => true (exact key) / false (use LIKE)
291
- $mycred_usermeta_to_delete = array(
292
- MYCRED_RANK_KEY => true,
293
- 'mycred-last-send' => true,
294
- 'mycred-last-linkclick' => true,
295
- 'mycred-last-transfer' => true,
296
- 'mycred_affiliate_link' => true,
297
- 'mycred_email_unsubscriptions' => true,
298
- 'mycred_transactions' => true,
299
- MYCRED_BADGE_KEY . '%' => false,
300
- MYCRED_RANK_KEY . '%' => false,
301
- 'mycred_epp_%' => false,
302
- 'mycred_payments_%' => false,
303
- 'mycred_comment_limit_post_%' => false,
304
- 'mycred_comment_limit_day_%' => false,
305
- 'mycred-last-clear-stats' => true
306
- );
307
 
308
- if ( MYCRED_UNINSTALL_CREDS ) {
309
 
310
- foreach ( $mycred_types as $type => $label ) {
 
 
 
 
 
 
 
 
311
 
312
- $mycred_usermeta_to_delete[ $type ] = true;
313
- $mycred_usermeta_to_delete[ $type . '_total' ] = true;
314
- $mycred_usermeta_to_delete[ 'mycred_ref_counts-' . $type ] = true;
315
- $mycred_usermeta_to_delete[ 'mycred_ref_sums-' . $type ] = true;
316
- $mycred_usermeta_to_delete[ $type . '_comp' ] = true;
317
- $mycred_usermeta_to_delete[ 'mycred_banking_rate_' . $type ] = true;
318
- $mycred_usermeta_to_delete[ 'mycred_buycred_rates_' . $type ] = true;
319
- $mycred_usermeta_to_delete[ 'mycred_sell_content_share_' . $type ] = true;
320
- $mycred_usermeta_to_delete[ 'mycred_transactions_' . $type ] = true;
321
 
322
- }
 
323
 
324
- }
325
- $mycred_usermeta_to_delete = apply_filters( 'mycred_uninstall_usermeta', $mycred_usermeta_to_delete );
326
 
327
- if ( ! empty( $mycred_usermeta_to_delete ) ) {
328
- foreach ( $mycred_usermeta_to_delete as $meta_key => $exact ) {
 
 
329
 
330
- if ( $exact )
331
- delete_metadata( 'user', 0, $meta_key, '', true );
332
- else
333
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE %s;", $meta_key ) );
334
 
335
- }
336
- }
337
 
338
- // Delete log table
339
- if ( MYCRED_UNINSTALL_LOG ) {
 
 
 
 
340
 
341
- if ( defined( 'MYCRED_LOG_TABLE' ) )
342
- $table_name = MYCRED_LOG_TABLE;
 
 
343
 
344
- else {
345
 
346
- if ( mycred_centralize_log() )
347
- $table_name = $wpdb->base_prefix . 'myCRED_log';
348
- else
349
- $table_name = $wpdb->prefix . 'myCRED_log';
350
 
351
- }
 
 
352
 
353
- if ( ! is_multisite() || ( is_multisite() && mycred_centralize_log() ) ) {
354
 
355
- $wpdb->query( "DROP TABLE IF EXISTS {$table_name};" );
 
356
 
357
- }
358
- else {
359
 
360
- $site_ids = get_sites( array( 'fields' => 'ids' ) );
361
- foreach ( $site_ids as $site_id ) {
362
 
363
- $site_id = absint( $site_id );
364
- if ( $site_id === 0 ) continue;
 
365
 
366
- $table = $wpdb->base_prefix . $site_id . '_myCRED_log';
367
- if ( $site === 1 )
368
- $table_name = $wpdb->base_prefix . 'myCRED_log';
369
 
370
- $wpdb->query( "DROP TABLE IF EXISTS {$table_name};" );
371
 
372
- }
373
 
374
- }
375
 
376
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
 
378
  // Clear stats data (if enabled)
379
  if ( function_exists( 'mycred_delete_stats_data' ) )
9
  * @version 1.2
10
  */
11
  if ( ! class_exists( 'myCRED_Install' ) ) :
12
+ final class myCRED_Install{
13
 
14
  // Instnace
15
  protected static $_instance = NULL;
123
  * @version 1.4
124
  */
125
  public static function reactivate() {
126
+
127
  $version = get_option( 'mycred_version', false );
128
  do_action( 'mycred_reactivation', $version );
129
 
172
 
173
  }
174
 
175
+ /**
176
+ * Checks if set to remove on installation
177
+ * @param $key
178
+ * @return bool
179
+ * @since 2.1.1
180
+ * @version 1.0
181
+ */
182
+ public static function remove_setting( $key ) {
183
+
184
+ $hooks = mycred_get_option( 'mycred_pref_core', false );
185
+
186
+ if ( is_array( $hooks ) && in_array( $key, $hooks ) )
187
+ if ( $hooks['uninstall'][$key] == 1 )
188
+ return true;
189
+
190
+ return false;
191
+ }
192
+
193
  /**
194
  * Uninstall
195
  * Removes all myCRED related data from the database.
198
  */
199
  public static function uninstall() {
200
 
201
+ global $wpdb;
202
 
203
  $mycred_types = mycred_get_types();
204
 
 
205
  // Options to delete
206
+ $options_to_delete = array(
 
 
 
 
207
  'mycred_pref_bank',
208
  'mycred_pref_remote',
 
209
  'woocommerce_mycred_settings',
210
  'mycred_sell_content_one_seven_updated',
 
 
 
211
  'mycred_network',
212
  'widget_mycred_widget_balance',
213
  'widget_mycred_widget_list',
220
  MYCRED_SLUG . '-last-clear-stats'
221
  );
222
 
223
+ $can_remove_hooks = self::remove_setting( 'hooks' );
 
 
 
 
224
 
225
+ //Delete Hooks
226
+ if ( $can_remove_hooks ) {
227
 
228
+ $options_to_delete[] = 'mycred_pref_hooks';
 
229
 
230
+ foreach ( $mycred_types as $type => $label ) {
231
+ $options_to_delete[] = 'mycred_pref_hooks_' . $type;
232
+ }
233
+
234
+ }
 
 
 
 
 
235
 
236
+ $can_remove_addons = self::remove_setting( 'addon' );
237
 
238
+ //Delete All Addons Settings
239
+ if ( $can_remove_addons )
240
+ $options_to_delete[] = 'mycred_pref_addons';
241
 
242
+ $can_remove_types = self::remove_setting( 'types' );
243
 
244
+ if ( $can_remove_types ) {
245
+
246
+ $options_to_delete[] = 'mycred_setup_completed';
247
+ $options_to_delete[] = 'mycred_version';
248
+ $options_to_delete[] = 'mycred_version_db';
249
+ $options_to_delete[] = 'mycred_key';
250
+ $options_to_delete[] = 'mycred_types';
251
+ $options_to_delete[] = 'mycred_pref_core';
252
 
253
+ foreach ( $mycred_types as $type => $label ) {
254
+ $options_to_delete[] = 'mycred_pref_core_' . $type;
255
+ $options_to_delete[] = 'mycred-cache-total-' . $type;
256
  }
257
 
258
  }
275
  }
276
 
277
  // Delete all custom post types created by myCRED
278
+ $post_types = array( 'buycred_payment' );
279
+
280
+ // Coupons
281
+ $post_types[] = ( defined( 'MYCRED_COUPON_KEY' ) ) ? MYCRED_COUPON_KEY : 'mycred_coupon';
282
+
283
+ if ( ! defined( 'MYCRED_RANK_KEY' ) ) define( 'MYCRED_RANK_KEY', 'mycred_rank' );
284
+ if ( ! defined( 'MYCRED_BADGE_KEY' ) ) define( 'MYCRED_BADGE_KEY', 'mycred_badge' );
285
+ if ( ! defined( 'MYCRED_BADGE_CATEGORY' ) ) define( 'MYCRED_BADGE_CATEGORY', 'mycred_badge' );
286
+
287
+ // Badges
288
+ $can_remove_badges = self::remove_setting( 'badges' );
289
+
290
+ if ( $can_remove_badges ) {
291
+
292
+ $post_types[] = MYCRED_BADGE_KEY;
293
+
294
+ $terms = get_terms(
295
+ array(
296
+ 'hide_empty' => false
297
+ )
298
+ );
299
+
300
+ foreach ( $terms as $term ) {
301
+
302
+ if ( $term->taxonomy == MYCRED_BADGE_CATEGORY )
303
+ wp_delete_term( $term->term_id, MYCRED_BADGE_CATEGORY );
304
+
305
+ }
306
+
307
+ }
308
+
309
+ // Ranks
310
+ $can_remove_ranks = self::remove_setting( 'ranks' );
311
+
312
+ if ( $can_remove_ranks ) {
313
+
314
+ $post_types[] = MYCRED_RANK_KEY;
315
+
316
+ }
317
+
318
  $mycred_post_types_to_delete = apply_filters( 'mycred_uninstall_post_types', $post_types );
319
 
320
  if ( ! empty( $mycred_post_types_to_delete ) ) {
324
  if ( $posts->have_posts() ) {
325
 
326
  // wp_delete_post() will also handle all post meta deletions
327
+ foreach ( $posts->posts as $post_id )
328
  wp_delete_post( $post_id, true );
329
 
330
  }
333
  }
334
  }
335
 
336
+ $can_remove_users_data = self::remove_setting( 'users' );
337
+
338
+ //Delete Users' Data
339
+ if ( $can_remove_users_data ) {
340
+ // Delete user meta
341
+ // 'meta_key' => true (exact key) / false (use LIKE)
342
+ $mycred_usermeta_to_delete = array(
343
+ MYCRED_RANK_KEY => true,
344
+ 'mycred-last-send' => true,
345
+ 'mycred-last-linkclick' => true,
346
+ 'mycred-last-transfer' => true,
347
+ 'mycred_affiliate_link' => true,
348
+ 'mycred_email_unsubscriptions' => true,
349
+ 'mycred_transactions' => true,
350
+ MYCRED_BADGE_KEY . '%' => false,
351
+ MYCRED_RANK_KEY . '%' => false,
352
+ 'mycred_epp_%' => false,
353
+ 'mycred_payments_%' => false,
354
+ 'mycred_comment_limit_post_%' => false,
355
+ 'mycred_comment_limit_day_%' => false,
356
+ 'mycred-last-clear-stats' => true
357
+ );
358
 
359
+ if ( MYCRED_UNINSTALL_CREDS ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
 
361
+ foreach ( $mycred_types as $type => $label ) {
362
 
363
+ $mycred_usermeta_to_delete[ $type ] = true;
364
+ $mycred_usermeta_to_delete[ $type . '_total' ] = true;
365
+ $mycred_usermeta_to_delete[ 'mycred_ref_counts-' . $type ] = true;
366
+ $mycred_usermeta_to_delete[ 'mycred_ref_sums-' . $type ] = true;
367
+ $mycred_usermeta_to_delete[ $type . '_comp' ] = true;
368
+ $mycred_usermeta_to_delete[ 'mycred_banking_rate_' . $type ] = true;
369
+ $mycred_usermeta_to_delete[ 'mycred_buycred_rates_' . $type ] = true;
370
+ $mycred_usermeta_to_delete[ 'mycred_sell_content_share_' . $type ] = true;
371
+ $mycred_usermeta_to_delete[ 'mycred_transactions_' . $type ] = true;
372
 
373
+ }
 
 
 
 
 
 
 
 
374
 
375
+ }
376
+ $mycred_usermeta_to_delete = apply_filters( 'mycred_uninstall_usermeta', $mycred_usermeta_to_delete );
377
 
378
+ if ( ! empty( $mycred_usermeta_to_delete ) ) {
379
+ foreach ( $mycred_usermeta_to_delete as $meta_key => $exact ) {
380
 
381
+ if ( $exact )
382
+ delete_metadata( 'user', 0, $meta_key, '', true );
383
+ else
384
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE %s;", $meta_key ) );
385
 
386
+ }
387
+ }
388
+ }
 
389
 
390
+ $table_name = '';
 
391
 
392
+ if( defined( 'MYCRED_LOG_TABLE' ) ) {
393
+
394
+ $table_name = MYCRED_LOG_TABLE;
395
+
396
+ }
397
+ else {
398
 
399
+ if ( mycred_centralize_log() )
400
+ $table_name = $wpdb->base_prefix . 'myCRED_log';
401
+ else
402
+ $table_name = $wpdb->prefix . 'myCRED_log';
403
 
404
+ }
405
 
406
+ $can_remove_logs = self::remove_setting( 'logs' );
 
 
 
407
 
408
+ if ( ! $can_remove_types && $can_remove_logs ) {
409
+
410
+ if( ! is_multisite() || ( is_multisite() && mycred_centralize_log() ) ) {
411
 
412
+ $wpdb->query( "TRUNCATE TABLE {$table_name};" );
413
 
414
+ }
415
+ else {
416
 
417
+ $site_ids = get_sites( array( 'fields' => 'ids' ) );
418
+ foreach ( $site_ids as $site_id ) {
419
 
420
+ $site_id = absint( $site_id );
421
+ if ( $site_id === 0 ) continue;
422
 
423
+ $table = $wpdb->base_prefix . $site_id . '_myCRED_log';
424
+ if ( $site === 1 )
425
+ $table_name = $wpdb->base_prefix . 'myCRED_log';
426
 
427
+ $wpdb->query( "TRUNCATE TABLE {$table_name};" );
 
 
428
 
429
+ }
430
 
431
+ }
432
 
433
+ }
434
 
435
+ //Delete Logs
436
+ if( $can_remove_types ) {
437
+
438
+ //Delete log table
439
+ if( MYCRED_UNINSTALL_LOG ) {
440
+
441
+ if( ! is_multisite() || ( is_multisite() && mycred_centralize_log() ) ) {
442
+
443
+ $wpdb->query( "DROP TABLE IF EXISTS {$table_name};" );
444
+
445
+ }
446
+ else {
447
+
448
+ $site_ids = get_sites( array( 'fields' => 'ids' ) );
449
+ foreach ( $site_ids as $site_id ) {
450
+
451
+ $site_id = absint( $site_id );
452
+ if ( $site_id === 0 ) continue;
453
+
454
+ $table = $wpdb->base_prefix . $site_id . '_myCRED_log';
455
+ if ( $site === 1 )
456
+ $table_name = $wpdb->base_prefix . 'myCRED_log';
457
+
458
+ $wpdb->query( "DROP TABLE IF EXISTS {$table_name};" );
459
+
460
+ }
461
+
462
+ }
463
+
464
+ }
465
+
466
+ }
467
+
468
+ $options_to_delete = apply_filters( 'mycred_uninstall_options', $options_to_delete );
469
+
470
+ if ( ! empty( $options_to_delete ) ) {
471
+
472
+ // Multisite installations where we are not using the "Master Template" feature
473
+ if ( is_multisite() && ! mycred_override_settings() ) {
474
+
475
+ // Remove settings on all sites where myCRED was enabled
476
+ $site_ids = get_sites( array( 'fields' => 'ids' ) );
477
+ foreach ( $site_ids as $site_id ) {
478
+
479
+ // Check if myCRED was installed
480
+ $installed = get_blog_option( $site_id, 'mycred_setup_completed', false );
481
+ if ( $installed === false ) continue;
482
+
483
+ foreach ( $options_to_delete as $option_id )
484
+ delete_blog_option( $site_id, $option_id );
485
+
486
+ }
487
+
488
+ }
489
+
490
+ else {
491
+
492
+ foreach ( $options_to_delete as $option_id )
493
+ delete_option( $option_id );
494
+
495
+ }
496
+
497
+ }
498
 
499
  // Clear stats data (if enabled)
500
  if ( function_exists( 'mycred_delete_stats_data' ) )
includes/mycred-referrals.php CHANGED
@@ -10,7 +10,7 @@ if ( ! function_exists( 'mycred_load_referral_program' ) ) :
10
  function mycred_load_referral_program() {
11
 
12
  // BuddyPress: Hook into user activation
13
- if ( function_exists( 'buddypress' ) && apply_filters( 'bp_core_signup_send_activation_key', true ) === true )
14
  add_action( 'bp_core_activated_user', 'mycred_detect_bp_user_activation' );
15
 
16
  // Logged in users do not get points
10
  function mycred_load_referral_program() {
11
 
12
  // BuddyPress: Hook into user activation
13
+ if ( function_exists( 'buddypress' ) )
14
  add_action( 'bp_core_activated_user', 'mycred_detect_bp_user_activation' );
15
 
16
  // Logged in users do not get points
includes/mycred-setup.php CHANGED
@@ -232,7 +232,7 @@ jQuery(function($) {
232
 
233
  if ( $( '#toggle-advanced-options' ).hasClass( 'open' ) )
234
  $( '#toggle-advanced-options' ).click();
235
-
236
 
237
  },
238
  success : function( response ) {
232
 
233
  if ( $( '#toggle-advanced-options' ).hasClass( 'open' ) )
234
  $( '#toggle-advanced-options' ).click();
235
+
236
 
237
  },
238
  success : function( response ) {
includes/mycred-uninstall.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists( 'myCred_Uninstall_Settings' ) ):
3
+ class myCred_Uninstall_Settings
4
+ {
5
+ private static $_instance;
6
+
7
+ /**
8
+ * myCred_Uninstall_Settings constructor.
9
+ * @since 2.1.1
10
+ * @version 1.0
11
+ */
12
+ public function __construct()
13
+ {
14
+ add_action( 'mycred_after_core_prefs', array( $this, 'uninstall_settings' ) );
15
+ add_filter( 'mycred_save_core_prefs', array( $this, 'sanitize_extra_settings' ), 10, 3 );
16
+ }
17
+
18
+ /**
19
+ * @return mixed
20
+ * @since 2.1.1
21
+ * @version 1.0
22
+ */
23
+ public static function get_instance()
24
+ {
25
+ if ( self::$_instance == null )
26
+ self::$_instance = new self();
27
+
28
+ return self::$_instance;
29
+ }
30
+
31
+ /**
32
+ * Generates Uninstall Menu In myCred Settings
33
+ * @since 2.1.1
34
+ * @version 1.0
35
+ */
36
+ public function uninstall_settings()
37
+ {
38
+ ?>
39
+ <h4>
40
+ <span class="dashicons dashicons-trash"></span>
41
+ Uninstall
42
+ </h4>
43
+ <div class="body" style="display:none;">
44
+ <div class="row">
45
+ <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
46
+ <div class="form-group">
47
+ <label>Remove</label>
48
+ <div class="radio" style="margin: 10px 0;">
49
+ <label for="mycred-uninstall-types"><input type="checkbox" name="mycred_pref_core[uninstall][types]" <?php echo $this->checked( 'types' ) ? 'checked' : ''; ?> id="mycred-uninstall-types" value="1"> All Point Types</label>
50
+ </div>
51
+ <div class="radio" style="margin: 10px 0;">
52
+ <label for="mycred-uninstall-logs"><input type="checkbox" name="mycred_pref_core[uninstall][logs]" <?php echo $this->checked( 'logs' ) ? 'checked' : ''; ?> id="mycred-uninstall-logs" value="1"> All Logs</label>
53
+ </div>
54
+ <div class="radio" style="margin: 10px 0;">
55
+ <label for="mycred-uninstall-users-data"><input type="checkbox" name="mycred_pref_core[uninstall][users]" <?php echo $this->checked( 'users' ) ? 'checked' : ''; ?> id="mycred-uninstall-users-data" value="1"> All Users' Data</label>
56
+ </div>
57
+ <div class="radio" style="margin: 10px 0;">
58
+ <label for="mycred-uninstall-addon-settings"><input type="checkbox" name="mycred_pref_core[uninstall][addon]" <?php echo $this->checked( 'addon' ) ? 'checked' : ''; ?> id="mycred-uninstall-addon-settings" value="1"> All Addon's Settings</label>
59
+ </div>
60
+ <div class="radio" style="margin: 10px 0;">
61
+ <label for="mycred-uninstall-hooks"><input type="checkbox" name="mycred_pref_core[uninstall][hooks]" <?php echo $this->checked( 'hooks' ) ? 'checked' : ''; ?> id="mycred-uninstall-hooks" value="1"> All Hook's Settings</label>
62
+ </div>
63
+ <div class="radio" style="margin: 10px 0;">
64
+ <label for="mycred-uninstall-badges"><input type="checkbox" name="mycred_pref_core[uninstall][badges]" <?php echo $this->checked( 'badges' ) ? 'checked' : ''; ?> id="mycred-uninstall-badges" value="1"> All Badges</label>
65
+ </div>
66
+ <div class="radio" style="margin: 10px 0;">
67
+ <label for="mycred-uninstall-ranks"><input type="checkbox" name="mycred_pref_core[uninstall][ranks]" <?php echo $this->checked( 'ranks' ) ? 'checked' : ''; ?> id="mycred-uninstall-ranks" value="1"> All Ranks</label>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ <?php
74
+ }
75
+
76
+
77
+ /**
78
+ * Checks the checkbox if already checked
79
+ * @param $key
80
+ * @return bool
81
+ * @since 2.1.1
82
+ * @version 1.0
83
+ */
84
+ public function checked( $key )
85
+ {
86
+ $hooks = mycred_get_option( 'mycred_pref_core', false );
87
+
88
+ if ( is_array( $hooks ) && in_array( $key, $hooks ) )
89
+ if ( array_key_exists( 'uninstall', $hooks ) && array_key_exists( $key, $hooks['uninstall'] ) && $hooks['uninstall'][$key] == 1 )
90
+ return true;
91
+
92
+ return false;
93
+ }
94
+
95
+ /**
96
+ * Sanitizes and saves settings
97
+ * @param $new_data
98
+ * @param $data
99
+ * @param $core
100
+ * @return mixed
101
+ * @since 2.1.1
102
+ * @version 1.0
103
+ */
104
+ public function sanitize_extra_settings($new_data, $data, $core )
105
+ {
106
+ if( array_key_exists( 'uninstall', $data ) )
107
+ {
108
+ $new_data['uninstall']['types'] = ( isset( $data['uninstall']['types'] ) ) ? sanitize_text_field( $data['uninstall']['types'] ) : 0;
109
+ $new_data['uninstall']['logs'] = ( isset( $data['uninstall']['logs'] ) ) ? sanitize_text_field( $data['uninstall']['logs'] ) : 0;
110
+ $new_data['uninstall']['users'] = ( isset( $data['uninstall']['users'] ) ) ? sanitize_text_field( $data['uninstall']['users'] ) : 0 ;
111
+ $new_data['uninstall']['addon'] = ( isset( $data['uninstall']['addon'] ) ) ? sanitize_text_field( $data['uninstall']['addon'] ) : 0 ;
112
+ $new_data['uninstall']['hooks'] = ( isset( $data['uninstall']['hooks'] ) ) ? sanitize_text_field( $data['uninstall']['hooks'] ) : 0 ;
113
+ $new_data['uninstall']['badges'] = ( isset( $data['uninstall']['badges'] ) ) ? sanitize_text_field( $data['uninstall']['badges'] ) : 0 ;
114
+ $new_data['uninstall']['ranks'] = ( isset( $data['uninstall']['ranks'] ) ) ? sanitize_text_field( $data['uninstall']['ranks'] ) : 0 ;
115
+ }
116
+
117
+ return $new_data;
118
+ }
119
+ }
120
+ endif;
121
+
122
+ myCred_Uninstall_Settings::get_instance();
includes/mycred-walkthrough.php CHANGED
@@ -10,15 +10,13 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
10
  */
11
  if ( ! class_exists( 'myCRED_walkthroug' ) ) :
12
  class myCRED_walkthroug {
13
-
14
-
15
  /**
16
  * Construct
17
  */
18
  public function __construct() {
19
 
20
  $this->core = mycred();
21
-
22
  add_action( 'wp_loaded', array( $this, 'load' ) );
23
  }
24
  /**
@@ -28,37 +26,35 @@ if ( ! class_exists( 'myCRED_walkthroug' ) ) :
28
  */
29
  public function load() {
30
 
31
- wp_register_style( 'mycred-tourguide-style', plugins_url( 'assets/css/tourguide.css', myCRED_THIS ), array(), myCRED_VERSION , 'all' );
32
-
33
  wp_register_script( 'mycred-tourguide-script', plugins_url( 'assets/js/tourguide.min.js',myCRED_THIS ), array( 'jquery' ), myCRED_VERSION , true );
34
 
 
35
 
36
- $step = intval($_GET['mycred_tour_guide']);
37
-
38
- $redirect_url = '';
39
 
40
- if( $step == 2 ) {
41
 
42
- $redirect_url = admin_url('admin.php?page=mycred-hooks&mycred_tour_guide=3');
43
 
44
- }
45
- else if( $step == 3 ){
46
 
47
- $redirect_url = admin_url('admin.php?page=mycred-addons&mycred_tour_guide=4');
48
 
49
- }
50
-
51
- wp_localize_script(
52
- 'mycred-tourguide-script',
53
- 'mycred_tour_guide',
54
- array(
55
- 'step' => $step,
56
- 'redirect_url' => $redirect_url
57
- ),
58
- );
59
- wp_enqueue_script( 'mycred-tourguide-script' );
60
- wp_enqueue_style( 'mycred-tourguide-style' );
61
- }
62
 
63
- }
 
64
  endif;
10
  */
11
  if ( ! class_exists( 'myCRED_walkthroug' ) ) :
12
  class myCRED_walkthroug {
 
 
13
  /**
14
  * Construct
15
  */
16
  public function __construct() {
17
 
18
  $this->core = mycred();
19
+
20
  add_action( 'wp_loaded', array( $this, 'load' ) );
21
  }
22
  /**
26
  */
27
  public function load() {
28
 
29
+ wp_register_style( 'mycred-tourguide-style', plugins_url( 'assets/css/tourguide.css', myCRED_THIS ), array(), myCRED_VERSION , 'all' );
 
30
  wp_register_script( 'mycred-tourguide-script', plugins_url( 'assets/js/tourguide.min.js',myCRED_THIS ), array( 'jquery' ), myCRED_VERSION , true );
31
 
32
+ $step = intval( $_GET['mycred_tour_guide'] );
33
 
34
+ $redirect_url = '';
 
 
35
 
36
+ if( $step == 2 ) {
37
 
38
+ $redirect_url = admin_url('admin.php?page=mycred-hooks&mycred_tour_guide=3');
39
 
40
+ }
41
+ else if( $step == 3 ){
42
 
43
+ $redirect_url = admin_url('admin.php?page=mycred-addons&mycred_tour_guide=4');
44
 
45
+ }
46
+
47
+ wp_localize_script(
48
+ 'mycred-tourguide-script',
49
+ 'mycred_tour_guide',
50
+ array(
51
+ 'step' => $step,
52
+ 'redirect_url' => $redirect_url
53
+ )
54
+ );
55
+ wp_enqueue_script( 'mycred-tourguide-script' );
56
+ wp_enqueue_style( 'mycred-tourguide-style' );
 
57
 
58
+ }
59
+ }
60
  endif;
includes/shortcodes/mycred_referal_stats.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
+
4
+ /**
5
+ * myCRED Shortcode: mycred_referal_stats
6
+ * Returns the referal stats.
7
+ * @see http://codex.mycred.me/shortcodes/mycred_referal_stats/
8
+ * @since 2.1.1
9
+ * @version 1.0
10
+ */
11
+
12
+ if ( ! function_exists( 'mycred_referal_front' ) ) :
13
+ function mycred_referal_front( $atts ){
14
+
15
+ extract( shortcode_atts( array(
16
+
17
+ 'ctype' => MYCRED_DEFAULT_TYPE_KEY
18
+
19
+ ), $atts, MYCRED_SLUG . '_referal' ) );
20
+
21
+ $hooks = mycred_get_option( 'mycred_pref_hooks', false );
22
+
23
+ if ( $ctype != MYCRED_DEFAULT_TYPE_KEY )
24
+ $hooks = mycred_get_option( 'mycred_pref_hooks_' . sanitize_key( $ctype ), false );
25
+ $active = $hooks['active'];
26
+ if( is_array( $active) && in_array( 'affiliate' , $active )){
27
+
28
+ $visit = $hooks['hook_prefs']['affiliate']['visit'];
29
+ $signup = $hooks['hook_prefs']['affiliate']['signup'];
30
+
31
+ $output = '';
32
+
33
+ $user_id = get_current_user_id();
34
+
35
+ $output .= '<table class="profile-fields">';
36
+
37
+ // Show Visitor referral count
38
+ if ( $visit['creds'] != 0 )
39
+ $output .= sprintf( '<tr class="field_2 field_ref_count_visit"><td class="label">%s</td><td>%s</td></tr>', __( 'Visitors Referred', 'mycred' ), mycred_count_ref_instances( 'visitor_referral', $user_id, $ctype ) );
40
+
41
+ // Show Signup referral count
42
+ if ( $signup['creds'] != 0 )
43
+ $output .= sprintf( '<tr class="field_3 field_ref_count_signup"><td class="label">%s</td><td>%s</td></tr>', __( 'Signups Referred', 'mycred' ), mycred_count_ref_instances( 'signup_referral', $user_id, $ctype ) );
44
+
45
+ $output .= '</table>';
46
+ return $output;
47
+ }
48
+ }
49
+ endif;
50
+
51
+ add_shortcode( MYCRED_SLUG . '_referral_stats' , 'mycred_referal_front' );
modules/mycred-module-addons.php CHANGED
@@ -199,7 +199,7 @@ if ( ! class_exists( 'myCRED_Addons_Module' ) ) :
199
  $installed['cash-creds'] = array(
200
  'name' => 'cashCRED',
201
  'description' => __( '', 'mycred' ),
202
- 'addon_url' => '#',
203
  'version' => '1.0',
204
  'author' => 'Gabriel S Merovingi',
205
  'author_url' => 'https://www.merovingi.com',
@@ -211,7 +211,7 @@ if ( ! class_exists( 'myCRED_Addons_Module' ) ) :
211
  $installed['banking'] = array(
212
  'name' => 'Central Deposit',
213
  'description' => __( 'Setup recurring payouts or offer / charge interest on user account balances.', 'mycred' ),
214
- 'addon_url' => 'http://codex.mycred.me/chapter-iii/banking/',
215
  'version' => '2.0',
216
  'author' => 'myCred',
217
  'author_url' => 'https://www.mycred.me',
199
  $installed['cash-creds'] = array(
200
  'name' => 'cashCRED',
201
  'description' => __( '', 'mycred' ),
202
+ 'addon_url' => 'https://codex.mycred.me/chapter-iii/cashcred/',
203
  'version' => '1.0',
204
  'author' => 'Gabriel S Merovingi',
205
  'author_url' => 'https://www.merovingi.com',
211
  $installed['banking'] = array(
212
  'name' => 'Central Deposit',
213
  'description' => __( 'Setup recurring payouts or offer / charge interest on user account balances.', 'mycred' ),
214
+ 'addon_url' => 'https://codex.mycred.me/chapter-iii/central-deposit-add-on/',
215
  'version' => '2.0',
216
  'author' => 'myCred',
217
  'author_url' => 'https://www.mycred.me',
modules/mycred-module-export.php CHANGED
@@ -89,11 +89,16 @@ if ( ! class_exists( 'myCRED_Export_Module' ) ) :
89
  /**
90
  * Insert Export Front
91
  * @since 1.7
92
- * @version 1.0.1
93
  */
94
  public function insert_export_front( $user_id ) {
95
 
96
- if ( absint( $this->export['front'] ) !== 1 || ! is_user_logged_in() || get_current_user_id() != $user_id ) return;
 
 
 
 
 
97
 
98
  // No need to export if there is nothing to export
99
  if ( ! mycred_user_has_log_entries( $user_id ) ) return;
89
  /**
90
  * Insert Export Front
91
  * @since 1.7
92
+ * @version 1.0.2
93
  */
94
  public function insert_export_front( $user_id ) {
95
 
96
+ if ( empty( $user_id ) )
97
+ $user_id = get_current_user_id();
98
+
99
+ if ( !empty( $user_id ) && get_current_user_id() != $user_id ) return;
100
+
101
+ if ( absint( $this->export['front'] ) !== 1 || ! is_user_logged_in() ) return;
102
 
103
  // No need to export if there is nothing to export
104
  if ( ! mycred_user_has_log_entries( $user_id ) ) return;
modules/mycred-module-hooks.php CHANGED
@@ -17,6 +17,7 @@ if ( ! class_exists( 'myCRED_Hooks_Module' ) ) :
17
  public function __construct( $type = MYCRED_DEFAULT_TYPE_KEY ) {
18
 
19
  $option_id = apply_filters( 'mycred_option_id', 'mycred_pref_hooks' );
 
20
  parent::__construct( 'myCRED_Hooks_Module', array(
21
  'module_name' => 'hooks',
22
  'option_id' => $option_id,
@@ -552,8 +553,12 @@ jQuery(function($) {
552
  $active_hooks = array_unique( $active_hooks, SORT_STRING );
553
  $this->active = $active_hooks;
554
 
 
 
 
 
555
  // Update our settings to activate the hook(s)
556
- mycred_update_option( $this->option_id, array(
557
  'active' => $this->active,
558
  'installed' => $installed,
559
  'hook_prefs' => $this->hook_prefs
@@ -592,11 +597,13 @@ jQuery(function($) {
592
  if ( isset( $_POST[$mycred_pref_hooks_save] ) || isset($_POST[ $mycred_pref_hooks_save.'_' . $ctype ]) ) {
593
 
594
  // Get hook settings
595
- if ( $ctype == MYCRED_DEFAULT_TYPE_KEY && array_key_exists( $hook_id, $_POST[$mycred_pref_hooks_save]['hook_prefs'] ) )
596
  $hook_prefs = $_POST[$mycred_pref_hooks_save]['hook_prefs'][ $hook_id ];
597
-
598
- elseif ( $ctype != MYCRED_DEFAULT_TYPE_KEY && array_key_exists( $hook_id, $_POST[ $mycred_pref_hooks_save.'_' . $ctype ]['hook_prefs'] ) )
599
  $hook_prefs = $_POST[ $mycred_pref_hooks_save.'_' . $ctype ]['hook_prefs'][ $hook_id ];
 
 
600
 
601
  if ( $hook_prefs === false ) die;
602
 
@@ -614,15 +621,17 @@ jQuery(function($) {
614
 
615
  }
616
 
 
 
617
  // Update our settings to activate the hook(s)
618
- mycred_update_option( $this->option_id, array(
619
- 'active' => $this->active,
620
  'installed' => $installed,
621
- 'hook_prefs' => $this->hook_prefs
622
  ) );
623
 
624
  if ( isset( $_POST['mycred_pref_hooks'] ) || isset($_POST[ 'mycred_pref_hooks_' . $ctype ]) )
625
- $this->call( 'preferences', $installed[ $hook_id ]['callback'] );
626
 
627
  die;
628
 
17
  public function __construct( $type = MYCRED_DEFAULT_TYPE_KEY ) {
18
 
19
  $option_id = apply_filters( 'mycred_option_id', 'mycred_pref_hooks' );
20
+
21
  parent::__construct( 'myCRED_Hooks_Module', array(
22
  'module_name' => 'hooks',
23
  'option_id' => $option_id,
553
  $active_hooks = array_unique( $active_hooks, SORT_STRING );
554
  $this->active = $active_hooks;
555
 
556
+ if ( $ctype != MYCRED_DEFAULT_TYPE_KEY ) {
557
+ $option_id = $option_id . '_' . $ctype;
558
+ }
559
+
560
  // Update our settings to activate the hook(s)
561
+ mycred_update_option( $option_id, array(
562
  'active' => $this->active,
563
  'installed' => $installed,
564
  'hook_prefs' => $this->hook_prefs
597
  if ( isset( $_POST[$mycred_pref_hooks_save] ) || isset($_POST[ $mycred_pref_hooks_save.'_' . $ctype ]) ) {
598
 
599
  // Get hook settings
600
+ if ( $ctype == MYCRED_DEFAULT_TYPE_KEY && array_key_exists( $hook_id, $_POST[$mycred_pref_hooks_save]['hook_prefs'] ) ) {
601
  $hook_prefs = $_POST[$mycred_pref_hooks_save]['hook_prefs'][ $hook_id ];
602
+ }
603
+ elseif ( $ctype != MYCRED_DEFAULT_TYPE_KEY && array_key_exists( $hook_id, $_POST[ $mycred_pref_hooks_save.'_' . $ctype ]['hook_prefs'] ) ) {
604
  $hook_prefs = $_POST[ $mycred_pref_hooks_save.'_' . $ctype ]['hook_prefs'][ $hook_id ];
605
+ $mycred_pref_hooks_save = $mycred_pref_hooks_save . '_' . $ctype;
606
+ }
607
 
608
  if ( $hook_prefs === false ) die;
609
 
621
 
622
  }
623
 
624
+ $hooks_update = apply_filters( 'mycred_before_hooks_save', $this, $mycred_pref_hooks_save, $hook_id );
625
+
626
  // Update our settings to activate the hook(s)
627
+ mycred_update_option( $mycred_pref_hooks_save, array(
628
+ 'active' => $hooks_update->active,
629
  'installed' => $installed,
630
+ 'hook_prefs' => $hooks_update->hook_prefs
631
  ) );
632
 
633
  if ( isset( $_POST['mycred_pref_hooks'] ) || isset($_POST[ 'mycred_pref_hooks_' . $ctype ]) )
634
+ $hooks_update->call( 'preferences', $installed[ $hook_id ]['callback'] );
635
 
636
  die;
637
 
mycred.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: myCred
4
  * Plugin URI: https://mycred.me
5
  * Description: An adaptive points management system for WordPress powered websites.
6
- * Version: 2.1.0.3
7
  * Tags: point, credit, loyalty program, engagement, reward, woocommerce rewards
8
  * Author: myCred
9
  * Author URI: https://mycred.me
10
  * Author Email: support@mycred.me
11
  * Requires at least: WP 4.8
12
- * Tested up to: WP 5.6
13
  * Text Domain: mycred
14
  * Domain Path: /lang
15
  * License: GPLv2 or later
@@ -20,7 +20,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
20
  final class myCRED_Core {
21
 
22
  // Plugin Version
23
- public $version = '2.1.0.3';
24
 
25
  // Instnace
26
  protected static $_instance = NULL;
@@ -118,7 +118,6 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
118
  // Register plugin hooks
119
  register_activation_hook( myCRED_THIS, 'mycred_plugin_activation' );
120
  register_deactivation_hook( myCRED_THIS, 'mycred_plugin_deactivation' );
121
- register_uninstall_hook( myCRED_THIS, 'mycred_plugin_uninstall' );
122
 
123
  // If myCRED is ready to be used
124
  if ( is_mycred_ready() ) {
@@ -152,6 +151,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
152
  add_action( 'admin_menu', array( $this, 'plugin_about_page' ), 10 );
153
  add_filter( 'pre_http_request', array( $this, 'handle_license_request' ), 10, 3 );
154
  add_filter( 'http_request_args', array( $this, 'license_request_args' ), 10, 2 );
 
155
 
156
  }
157
 
@@ -258,14 +258,14 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
258
  $this->file( myCRED_INCLUDES_DIR . 'mycred-protect.php' );
259
  $this->file( myCRED_INCLUDES_DIR . 'mycred-about.php' );
260
  $this->file( myCRED_INCLUDES_DIR . 'mycred-nav-menu.php' );
261
-
262
  if( isset ( $_GET['mycred_tour_guide'] ) ){
263
 
264
  $this->file( myCRED_INCLUDES_DIR . 'mycred-walkthrough.php' );
265
  $walkthrough = new myCRED_walkthroug();
266
 
267
  }
268
-
269
  // If myCRED has been setup and is ready to begin
270
  if ( mycred_is_installed() ) {
271
 
@@ -282,6 +282,9 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
282
  $this->file( myCRED_MODULES_DIR . 'mycred-module-management.php' );
283
  $this->file( myCRED_MODULES_DIR . 'mycred-module-caching.php' );
284
 
 
 
 
285
  if ( is_multisite() ) {
286
 
287
  $this->file( myCRED_MODULES_DIR . 'mycred-module-network.php' );
@@ -531,7 +534,8 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
531
 
532
  // These shortcodes will not work if hooks are disabled
533
  if ( MYCRED_ENABLE_HOOKS ) {
534
-
 
535
  $this->file( myCRED_SHORTCODES_DIR . 'mycred_affiliate_id.php' );
536
  $this->file( myCRED_SHORTCODES_DIR . 'mycred_affiliate_link.php' );
537
  $this->file( myCRED_SHORTCODES_DIR . 'mycred_link.php' );
@@ -759,10 +763,12 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
759
  /**
760
  * Admin Enqueue
761
  * @since 1.7
762
- * @version 1.0
763
  */
764
  public function enqueue_admin_before() {
765
 
 
 
766
  // Let others play
767
  do_action( 'mycred_admin_enqueue' );
768
 
@@ -921,6 +927,40 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
921
 
922
  }
923
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
924
  /**
925
  * Toolbar
926
  * @since 1.7
3
  * Plugin Name: myCred
4
  * Plugin URI: https://mycred.me
5
  * Description: An adaptive points management system for WordPress powered websites.
6
+ * Version: 2.1.1
7
  * Tags: point, credit, loyalty program, engagement, reward, woocommerce rewards
8
  * Author: myCred
9
  * Author URI: https://mycred.me
10
  * Author Email: support@mycred.me
11
  * Requires at least: WP 4.8
12
+ * Tested up to: WP 5.7.2
13
  * Text Domain: mycred
14
  * Domain Path: /lang
15
  * License: GPLv2 or later
20
  final class myCRED_Core {
21
 
22
  // Plugin Version
23
+ public $version = '2.1.1';
24
 
25
  // Instnace
26
  protected static $_instance = NULL;
118
  // Register plugin hooks
119
  register_activation_hook( myCRED_THIS, 'mycred_plugin_activation' );
120
  register_deactivation_hook( myCRED_THIS, 'mycred_plugin_deactivation' );
 
121
 
122
  // If myCRED is ready to be used
123
  if ( is_mycred_ready() ) {
151
  add_action( 'admin_menu', array( $this, 'plugin_about_page' ), 10 );
152
  add_filter( 'pre_http_request', array( $this, 'handle_license_request' ), 10, 3 );
153
  add_filter( 'http_request_args', array( $this, 'license_request_args' ), 10, 2 );
154
+ add_action( 'admin_menu', array( $this,'mycred_add_sub_menu_page'));
155
 
156
  }
157
 
258
  $this->file( myCRED_INCLUDES_DIR . 'mycred-protect.php' );
259
  $this->file( myCRED_INCLUDES_DIR . 'mycred-about.php' );
260
  $this->file( myCRED_INCLUDES_DIR . 'mycred-nav-menu.php' );
261
+
262
  if( isset ( $_GET['mycred_tour_guide'] ) ){
263
 
264
  $this->file( myCRED_INCLUDES_DIR . 'mycred-walkthrough.php' );
265
  $walkthrough = new myCRED_walkthroug();
266
 
267
  }
268
+
269
  // If myCRED has been setup and is ready to begin
270
  if ( mycred_is_installed() ) {
271
 
282
  $this->file( myCRED_MODULES_DIR . 'mycred-module-management.php' );
283
  $this->file( myCRED_MODULES_DIR . 'mycred-module-caching.php' );
284
 
285
+ //Uninstall Settings
286
+ $this->file( myCRED_INCLUDES_DIR . 'mycred-uninstall.php' );
287
+
288
  if ( is_multisite() ) {
289
 
290
  $this->file( myCRED_MODULES_DIR . 'mycred-module-network.php' );
534
 
535
  // These shortcodes will not work if hooks are disabled
536
  if ( MYCRED_ENABLE_HOOKS ) {
537
+
538
+ $this->file( myCRED_SHORTCODES_DIR . 'mycred_referal_stats.php' );
539
  $this->file( myCRED_SHORTCODES_DIR . 'mycred_affiliate_id.php' );
540
  $this->file( myCRED_SHORTCODES_DIR . 'mycred_affiliate_link.php' );
541
  $this->file( myCRED_SHORTCODES_DIR . 'mycred_link.php' );
763
  /**
764
  * Admin Enqueue
765
  * @since 1.7
766
+ * @version 1.1
767
  */
768
  public function enqueue_admin_before() {
769
 
770
+ wp_enqueue_script( 'mycred-admin', plugins_url( 'assets/js/admin.js', myCRED_THIS ), '', myCRED_VERSION );
771
+
772
  // Let others play
773
  do_action( 'mycred_admin_enqueue' );
774
 
927
 
928
  }
929
 
930
+
931
+ function mycred_add_sub_menu_page( $mycred ) {
932
+
933
+ add_submenu_page(
934
+ MYCRED_SLUG,
935
+ 'Support',
936
+ 'Support',
937
+ 'manage_options',
938
+ 'support-screen',
939
+ array( $this,'support_screen_function')
940
+ );
941
+
942
+ }
943
+
944
+ function support_screen_function () {
945
+
946
+ $html = '
947
+
948
+ <div class="mycred_support_heading" style="margin: 5% 0 0.2% 86%; text-align:left; ">
949
+
950
+ <a href="https://mycred.me/support/" class="support_link" style="text-decoration:none; font-size:14px; line-height: 1.55; font-weight:400; text-align:center; margin:10px 0; transition-duration: .05s; transition-timing-function: ease-in-out; transition-property: border,background,color; color: #135e96; ">Contact Support</a>
951
+
952
+ </div>
953
+
954
+ <div class="mycred_iframe">
955
+
956
+ <iframe src="https://app.productstash.io/roadmaps/5f8d483c053518002b4441c4/public" height="900" width="90%" frameborder="0" scrolling="no" style="margin-left: 5%; text-decoration:none;"></iframe>
957
+
958
+ </div>';
959
+
960
+ echo $html;
961
+
962
+ }
963
+
964
  /**
965
  * Toolbar
966
  * @since 1.7
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: mycred,wpexpertsio
3
  Tags: badges, gamification, loyalty, points, rewards
4
  Requires at least: 4.8
5
- Tested up to: 5.7
6
- Stable tag: 2.1.0.3
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -30,6 +30,12 @@ myCred allows **THREE different ways** through which you can award your users:
30
 
31
  * **Badges -** Boost your users’ participation by rewarding them for their exceptional performance.
32
 
 
 
 
 
 
 
33
  = BECOME A VIP MEMBER OF THE MYCRED MEMBERSHIP CLUB =
34
 
35
  Join the myCred membership club today and take advantage of premium services that include priority customer support and hundreds of add-ons at a super-saver price - Save 30% on all 3-year plans!
@@ -90,6 +96,34 @@ The most prominent feature in myCred 2.1 is the **Single Badge Page** which crea
90
 
91
  - Technical support for badge verification purpose.
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  = Features =
94
 
95
  **- Point Balances:** Each user on your website will have their own point balance, where they'll be able to view points that were gained/lost.
@@ -186,6 +220,7 @@ myCred is integrated with a large number of popular learning management systems,
186
  - [myCred BP Group Leaderboards](https://www.mycred.me/store/mycred-bp-group-leaderboards/)
187
  - [myCred for WP-Pro-Quiz](https://www.mycred.me/store/mycred-for-wp-pro-quiz/)
188
  - [myCred for Rating Form](https://www.mycred.me/store/mycred-for-rating-form/)
 
189
  [Explore to find out more...](https://www.mycred.me/product-category/freebies/)
190
 
191
 
@@ -276,6 +311,9 @@ You can find a list of [frequently asked questions](https://mycred.me/about/faq/
276
 
277
  == Upgrade Notice ==
278
 
 
 
 
279
  = 2.1 =
280
  New features and Bug fixes.
281
 
@@ -363,6 +401,31 @@ Bug fixes release.
363
 
364
  == Changelog ==
365
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  = 2.1.0.3 =
367
  FIX - Email notification issues.
368
  FIX - Broken image if badge default image wasn't set.
2
  Contributors: mycred,wpexpertsio
3
  Tags: badges, gamification, loyalty, points, rewards
4
  Requires at least: 4.8
5
+ Tested up to: 5.7.2
6
+ Stable tag: 2.1.1
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
30
 
31
  * **Badges -** Boost your users’ participation by rewarding them for their exceptional performance.
32
 
33
+ **myCred Beta v2.2**
34
+
35
+ myCred Beta v2.2 focuses on improving the overall user interface, single badge page layout, point-type image, and social media sharing for a better user experience and operational eficiency.
36
+
37
+ Read more about myCred v2.2 in these [release notes](https://mycred.me/blog/mycred-2-2-beta-release/).
38
+
39
  = BECOME A VIP MEMBER OF THE MYCRED MEMBERSHIP CLUB =
40
 
41
  Join the myCred membership club today and take advantage of premium services that include priority customer support and hundreds of add-ons at a super-saver price - Save 30% on all 3-year plans!
96
 
97
  - Technical support for badge verification purpose.
98
 
99
+ **Latest update - myCred v2.1.1**
100
+
101
+ In myCred v2.1.1, you can add tags in your outgoing emails so that users can keep a track of their new ranks, badges and referral points. We have also added email support to cashCred and new Open Badge search filters.
102
+
103
+ **Template Tags**
104
+ - **Signup Referral Hook (%user_name%)** - This hook returns a username whenever a user signup using a referral link.
105
+ - **Sell Content (%Price%)** - This template tag returns the exact amount of points a user needs to purchase content.
106
+ - **Badges (%badge_title% and %badge_image%)** - Display users their new badge title and image in the outgoing email.
107
+ - **Ranks (%rank_title% and %rank_image%)** - Display users their new rank title and image in the outgoing email.
108
+
109
+ **Updated settings for plugin installation**
110
+ myCred 2.1.1 version enables the plugin to ask the admin whether they want to altogether remove all/specific data upon plugin deletion from the database or keep it as a backup. Admin can enable/disable the given option at any time.
111
+
112
+ **myCred referral stats shortcode**
113
+ The [mycred_referral_stats] shortcode allows you to display the total count of referred visitors/sign ups users on your website.
114
+
115
+ **Badges Quick Edit**
116
+ On the badges page, you will see a “Quick Edit” hyperlink that enables the admin to modify the information of any particular badge by using the quick edit option.
117
+
118
+ **cashCred Email Events**
119
+ myCred 2.1.1 latest version has added email support for the Cashcred payment gateway in the “Email Notifications” addon. Admin can create email events/templates for cashCred pending/approved/cancel requests.
120
+
121
+ **Open Badge Search Filter**
122
+ The[myCred badge list] shortcode gives you the ability to add search fields and filters for badges.
123
+
124
+ **Badge Evidence Download Button**
125
+ In the latest update, the admin can access Open Badges of any users on the website. The admin can also download any given badge images.
126
+
127
  = Features =
128
 
129
  **- Point Balances:** Each user on your website will have their own point balance, where they'll be able to view points that were gained/lost.
220
  - [myCred BP Group Leaderboards](https://www.mycred.me/store/mycred-bp-group-leaderboards/)
221
  - [myCred for WP-Pro-Quiz](https://www.mycred.me/store/mycred-for-wp-pro-quiz/)
222
  - [myCred for Rating Form](https://www.mycred.me/store/mycred-for-rating-form/)
223
+ - [myCred - Buddyboss Integration](https://wordpress.org/plugins/mycred-buddyboss)
224
  [Explore to find out more...](https://www.mycred.me/product-category/freebies/)
225
 
226
 
311
 
312
  == Upgrade Notice ==
313
 
314
+ = 2.1.1 =
315
+ New features and Bug fixes.
316
+
317
  = 2.1 =
318
  New features and Bug fixes.
319
 
401
 
402
  == Changelog ==
403
 
404
+ = 2.1.1 =
405
+ NEW - Introduced new template tags %badge_image%, %badge_title%, %rank_image% and %rank_title% for myCred email notification addon.
406
+ NEW - Added support for cashCred payment email in myCred email notification addon.
407
+ NEW - Added myCred Open badge image download button in the user profile(backend).
408
+ NEW - Added a new support menu in myCred for suggestions and support.
409
+ NEW - Added search bar and filters in mycred_badges_list shortcode.
410
+ NEW - Introduced a new template tag %price% for myCred sell content "Insufficient Funds Template".
411
+ NEW - myCred Badge Quick Edit.
412
+ NEW - Introduced a new shortcode mycred_referral_stats which shows the referral stats for logged-in users.
413
+ NEW - Introduced a new template tag %user_name% for "Signup Referral" log template.
414
+ NEW - Introduced a setting for uninstalling. Now users can select which data will be deleted during myCred uninstall.
415
+ NEW - Introduced new action hook mycred_after_points_referral.
416
+ NEW - Introduced new action hook mycred_after_referring_signups.
417
+ NEW - Introduced new filter hook mycred_hook_referrals.
418
+ NEW - Introduced new filter hook mycred_before_hooks_save.
419
+ NEW - Introduced new fitler hook mycred_woo_gateway_user_id.
420
+ FIX - Unable to deactivate point types in buyCred Setting.
421
+ FIX - The user was unable to export the log from the frontend.
422
+ FIX - Height and width attributes in the mycred_my_badges shortcode were not working.
423
+ FIX - myCred Cubepoints importer was not importing date correctly.
424
+ FIX - If badges AND ranks were not active email notifications were not sending emails.
425
+ FIX - The user was unable to export the log from the frontend.
426
+ FIX - In the mycred_sales_history shortcode expires time was incorrect.
427
+ FIX - A broken image shows when the badge image does not set.
428
+
429
  = 2.1.0.3 =
430
  FIX - Email notification issues.
431
  FIX - Broken image if badge default image wasn't set.