myCRED - Version 2.4.8

Version Description

Bug fixes.

Download this release

Release Info

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

Code changes from version 2.4.7 to 2.4.8

addons/cash-creds/assets/css/withdraw.css CHANGED
@@ -90,3 +90,6 @@
90
  font-size: smaller;
91
  }
92
 
 
 
 
90
  font-size: smaller;
91
  }
92
 
93
+ #cashcred_total span.amount_label {
94
+ margin-right: 5px;
95
+ }
addons/cash-creds/gateways/bank-transfer.php CHANGED
@@ -197,6 +197,8 @@ if ( ! class_exists( 'myCRED_cashcred_Bank_Transfer' ) ) :
197
 
198
  <h3><?php echo esc_html( apply_filters( 'mycred_cashcred_bank_transfer_title', __( 'Bank account details', 'mycred' ) ) ); ?></h3>
199
 
 
 
200
  <?php if( isset( $mycred_pref_cashcreds["gateway_prefs"]["bank"]["enable_additional_notes"] ) ): ?>
201
  <div class="form-group">
202
  <p><?php echo esc_html( $mycred_pref_cashcreds["gateway_prefs"]["bank"]["additional_notes"] ); ?></p>
197
 
198
  <h3><?php echo esc_html( apply_filters( 'mycred_cashcred_bank_transfer_title', __( 'Bank account details', 'mycred' ) ) ); ?></h3>
199
 
200
+ <?php do_action( 'mycred_cashcred_before_bank_form' ); ?>
201
+
202
  <?php if( isset( $mycred_pref_cashcreds["gateway_prefs"]["bank"]["enable_additional_notes"] ) ): ?>
203
  <div class="form-group">
204
  <p><?php echo esc_html( $mycred_pref_cashcreds["gateway_prefs"]["bank"]["additional_notes"] ); ?></p>
addons/cash-creds/includes/cashcred-shortcodes.php CHANGED
@@ -40,6 +40,8 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
40
  if ( empty( $point_types ) ) return $excluded;
41
 
42
  $point_types = cashcred_is_user_have_balances( $point_types, $user_id );
 
 
43
 
44
  //Insufficient points for withdrawal.
45
  if ( empty( $point_types ) ) return $insufficient;
@@ -195,6 +197,10 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
195
  <label><?php echo sprintf( esc_html__('Withdraw %s value', 'mycred'), esc_html( $point_types[ current(array_keys($point_types)) ]->plural() ) ); ?></label>
196
  <?php
197
  $amount = ! empty( $amount ) ? floatval( $amount ) : 0;
 
 
 
 
198
  ?>
199
  <input type="number" id="withdraw_points" name="points" class="form-control" placeholder="0" value="<?php echo ! empty($amount) ? esc_attr( $amount ) : 0; ?>" required />
200
  <p class="cashcred-min"><?php echo esc_html__('Minimum Amount: ', 'mycred');?><span></span></p>
40
  if ( empty( $point_types ) ) return $excluded;
41
 
42
  $point_types = cashcred_is_user_have_balances( $point_types, $user_id );
43
+
44
+ $users_balance = $mycred->get_users_balance( $user_id, $types );
45
 
46
  //Insufficient points for withdrawal.
47
  if ( empty( $point_types ) ) return $insufficient;
197
  <label><?php echo sprintf( esc_html__('Withdraw %s value', 'mycred'), esc_html( $point_types[ current(array_keys($point_types)) ]->plural() ) ); ?></label>
198
  <?php
199
  $amount = ! empty( $amount ) ? floatval( $amount ) : 0;
200
+
201
+ if($amount > $users_balance) {
202
+ return;
203
+ }
204
  ?>
205
  <input type="number" id="withdraw_points" name="points" class="form-control" placeholder="0" value="<?php echo ! empty($amount) ? esc_attr( $amount ) : 0; ?>" required />
206
  <p class="cashcred-min"><?php echo esc_html__('Minimum Amount: ', 'mycred');?><span></span></p>
addons/email-notices/myCRED-addon-email-notices.php CHANGED
@@ -993,6 +993,7 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) :
993
 
994
  if ( isset( $_POST['mycred_email']['ctype'] ) && is_array( $_POST['mycred_email']['ctype'] ) ) {
995
 
 
996
  foreach ( $_POST['mycred_email']['ctype'] as $type_key ) {
997
  $type_key = sanitize_key( $type_key );
998
  if ( mycred_point_type_exists( $type_key ) && ! in_array( $type_key, $point_types ) )
993
 
994
  if ( isset( $_POST['mycred_email']['ctype'] ) && is_array( $_POST['mycred_email']['ctype'] ) ) {
995
 
996
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
997
  foreach ( $_POST['mycred_email']['ctype'] as $type_key ) {
998
  $type_key = sanitize_key( $type_key );
999
  if ( mycred_point_type_exists( $type_key ) && ! in_array( $type_key, $point_types ) )
addons/gateway/carts/mycred-woocommerce.php CHANGED
@@ -480,7 +480,7 @@ if ( ! function_exists( 'mycred_init_woo_gateway' ) ) :
480
  function thankyou_page() {
481
 
482
  $thankyou_msg = apply_filters( 'mycred_woo_thank_you_message', '<p>' . __( 'Your account has successfully been charged.', 'mycred' ) . '</p>' );
483
- echo esc_html( $thankyou_msg );
484
  }
485
 
486
  }
480
  function thankyou_page() {
481
 
482
  $thankyou_msg = apply_filters( 'mycred_woo_thank_you_message', '<p>' . __( 'Your account has successfully been charged.', 'mycred' ) . '</p>' );
483
+ echo wp_kses_post( $thankyou_msg );
484
  }
485
 
486
  }
addons/ranks/includes/mycred-rank-functions.php CHANGED
@@ -106,14 +106,15 @@ endif;
106
  * @version 1.3
107
  */
108
  if ( ! function_exists( 'mycred_get_rank' ) ) :
109
- function mycred_get_rank( $rank_identifier = NULL ) {
110
 
111
  global $mycred_rank;
112
 
113
  $rank_id = mycred_get_rank_object_id( $rank_identifier );
114
  if ( $rank_id === false ) return false;
115
 
116
- if ( isset( $mycred_rank )
 
117
  && ( $mycred_rank instanceof myCRED_Rank )
118
  && ( $rank_id === $mycred_rank->post_id )
119
  ) {
@@ -575,7 +576,7 @@ if ( ! function_exists( 'mycred_get_ranks' ) ) :
575
  if ( ! empty( $rank_ids ) ) {
576
 
577
  foreach ( $rank_ids as $rank_id )
578
- $results[] = mycred_get_rank( $rank_id );
579
 
580
  }
581
 
106
  * @version 1.3
107
  */
108
  if ( ! function_exists( 'mycred_get_rank' ) ) :
109
+ function mycred_get_rank( $rank_identifier = NULL, $force = false ) {
110
 
111
  global $mycred_rank;
112
 
113
  $rank_id = mycred_get_rank_object_id( $rank_identifier );
114
  if ( $rank_id === false ) return false;
115
 
116
+ if ( ! $force
117
+ && isset( $mycred_rank )
118
  && ( $mycred_rank instanceof myCRED_Rank )
119
  && ( $rank_id === $mycred_rank->post_id )
120
  ) {
576
  if ( ! empty( $rank_ids ) ) {
577
 
578
  foreach ( $rank_ids as $rank_id )
579
+ $results[] = mycred_get_rank( $rank_id, true );
580
 
581
  }
582
 
includes/classes/class.query-leaderboard.php CHANGED
@@ -818,8 +818,11 @@ if ( ! class_exists( 'myCRED_Query_Leaderboard' ) ) :
818
  $balance_format = 'CAST( %f AS DECIMAL( ' . $length . ', ' . $this->core->format['decimals'] . ' ) )';
819
  }
820
 
821
- $query = $wpdb->prepare( "AND l.meta_value != {$balance_format}", $this->core->zero() );
 
 
822
 
 
823
  }
824
 
825
  return apply_filters( 'mycred_leaderboard_exclude_filter', $query, $this );
818
  $balance_format = 'CAST( %f AS DECIMAL( ' . $length . ', ' . $this->core->format['decimals'] . ' ) )';
819
  }
820
 
821
+ if ( ! $this->args['total'] ) {
822
+ $query = $wpdb->prepare( "AND l.meta_value != {$balance_format}", $this->core->zero() );
823
+ }
824
 
825
+
826
  }
827
 
828
  return apply_filters( 'mycred_leaderboard_exclude_filter', $query, $this );
includes/mycred-tools.php CHANGED
@@ -210,7 +210,7 @@ class myCRED_Tools {
210
  if( isset( $_REQUEST['selected_type'] ) ) {
211
 
212
  $selected_type = sanitize_key( $_REQUEST['selected_type'] );
213
-
214
  switch ( $selected_type ) {
215
  case 'points':
216
  $this->process_points();
@@ -262,7 +262,7 @@ class myCRED_Tools {
262
  $points_to_award = sanitize_text_field( wp_unslash( $_REQUEST['points_to_award'] ) );
263
 
264
  $log_entry = isset( $_REQUEST['log_entry'] ) ? ( sanitize_key( $_REQUEST['log_entry'] ) == 'true' ? true : false ) : false;
265
-
266
  $users_to_award = $this->get_requested_users();
267
 
268
  if ( empty( $users_to_award ) ) return;
@@ -274,7 +274,7 @@ class myCRED_Tools {
274
  //Entries with log
275
  if( $log_entry ) {
276
 
277
- $log_entry_text = isset( $_REQUEST['log_entry_text'] ) ? sanitize_key( $_REQUEST['log_entry_text'] ) : '';
278
 
279
  if( empty( $log_entry_text ) ) {
280
 
@@ -358,9 +358,9 @@ class myCRED_Tools {
358
  }
359
 
360
  if ( $is_revoke )
361
- $selected_badges = isset( $_REQUEST['badges_to_revoke'] ) ? sanitize_key( $_REQUEST['badges_to_revoke'] ) : '';
362
  else
363
- $selected_badges = isset( $_REQUEST['badges_to_award'] ) ? sanitize_key( $_REQUEST['badges_to_award'] ) : '';
364
 
365
  $selected_badges = json_decode( stripslashes( $selected_badges ) );
366
 
@@ -422,7 +422,7 @@ class myCRED_Tools {
422
  }
423
  else {
424
 
425
- $selected_users = isset( $_REQUEST['users'] ) ? sanitize_key( $_REQUEST['users'] ) : '[]';
426
  $selected_user_roles = isset( $_REQUEST['user_roles'] ) ? sanitize_key( $_REQUEST['user_roles'] ) : '[]';
427
 
428
  $selected_users = json_decode( stripslashes( $selected_users ) );
210
  if( isset( $_REQUEST['selected_type'] ) ) {
211
 
212
  $selected_type = sanitize_key( $_REQUEST['selected_type'] );
213
+
214
  switch ( $selected_type ) {
215
  case 'points':
216
  $this->process_points();
262
  $points_to_award = sanitize_text_field( wp_unslash( $_REQUEST['points_to_award'] ) );
263
 
264
  $log_entry = isset( $_REQUEST['log_entry'] ) ? ( sanitize_key( $_REQUEST['log_entry'] ) == 'true' ? true : false ) : false;
265
+
266
  $users_to_award = $this->get_requested_users();
267
 
268
  if ( empty( $users_to_award ) ) return;
274
  //Entries with log
275
  if( $log_entry ) {
276
 
277
+ $log_entry_text = isset( $_REQUEST['log_entry_text'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['log_entry_text'] ) ) : '';
278
 
279
  if( empty( $log_entry_text ) ) {
280
 
358
  }
359
 
360
  if ( $is_revoke )
361
+ $selected_badges = isset( $_REQUEST['badges_to_revoke'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['badges_to_revoke'] ) ) : '';
362
  else
363
+ $selected_badges = isset( $_REQUEST['badges_to_award'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['badges_to_award'] ) ) : '';
364
 
365
  $selected_badges = json_decode( stripslashes( $selected_badges ) );
366
 
422
  }
423
  else {
424
 
425
+ $selected_users = isset( $_REQUEST['users'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['users'] ) ) : '[]';
426
  $selected_user_roles = isset( $_REQUEST['user_roles'] ) ? sanitize_key( $_REQUEST['user_roles'] ) : '[]';
427
 
428
  $selected_users = json_decode( stripslashes( $selected_users ) );
includes/mycred-walkthrough.php CHANGED
@@ -61,7 +61,7 @@ if ( ! class_exists( 'myCRED_walkthroug' ) ) :
61
  array(
62
  'step' => $step,
63
  'redirect_url' => $redirect_url
64
- ),
65
  );
66
  wp_enqueue_script( 'mycred-tourguide-script' );
67
 
61
  array(
62
  'step' => $step,
63
  'redirect_url' => $redirect_url
64
+ )
65
  );
66
  wp_enqueue_script( 'mycred-tourguide-script' );
67
 
includes/shortcodes/mycred_show_if.php CHANGED
@@ -49,6 +49,9 @@ if ( ! function_exists( 'mycred_render_shortcode_show_if' ) ) :
49
 
50
  // Lets start determening if the user can see the content
51
  $should_show = false;
 
 
 
52
 
53
  // Balance related requirement
54
  if ( $balance >= 0 ) {
@@ -58,11 +61,11 @@ if ( ! function_exists( 'mycred_render_shortcode_show_if' ) ) :
58
 
59
  // Zero balance requirement
60
  if ( $balance == $mycred->zero() && $users_balance == $mycred->zero() )
61
- $should_show = true;
62
 
63
  // Balance must be higher or equal to the amount set
64
  elseif ( $users_balance >= $balance )
65
- $should_show = true;
66
 
67
  }
68
 
@@ -73,11 +76,11 @@ if ( ! function_exists( 'mycred_render_shortcode_show_if' ) ) :
73
 
74
  // Combined with a balance requirement we must have references
75
  if ( $balance >= 0 && $ref_count == 0 && $comp === 'AND' )
76
- $should_show = false;
77
 
78
  // Ref count must be higher or equal to the count set
79
  elseif ( $ref_count >= $count )
80
- $should_show = true;
81
 
82
  }
83
 
@@ -97,9 +100,26 @@ if ( ! function_exists( 'mycred_render_shortcode_show_if' ) ) :
97
  if ( isset( $users_rank->post_id ) && $rank_id !== false ) {
98
 
99
  if ( $users_rank->post_id != $rank_id && $comp === 'AND' )
100
- $should_show = false;
101
 
102
  elseif ( $users_rank->post_id == $rank_id )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  $should_show = true;
104
 
105
  }
49
 
50
  // Lets start determening if the user can see the content
51
  $should_show = false;
52
+ $check_bal = $balance == -1 ? true : false;
53
+ $check_ref = empty( $ref ) ? true : false;
54
+ $check_rank = $rank == -1 ? true : false;
55
 
56
  // Balance related requirement
57
  if ( $balance >= 0 ) {
61
 
62
  // Zero balance requirement
63
  if ( $balance == $mycred->zero() && $users_balance == $mycred->zero() )
64
+ $check_bal = true;
65
 
66
  // Balance must be higher or equal to the amount set
67
  elseif ( $users_balance >= $balance )
68
+ $check_bal = true;
69
 
70
  }
71
 
76
 
77
  // Combined with a balance requirement we must have references
78
  if ( $balance >= 0 && $ref_count == 0 && $comp === 'AND' )
79
+ $check_ref = false;
80
 
81
  // Ref count must be higher or equal to the count set
82
  elseif ( $ref_count >= $count )
83
+ $check_ref = true;
84
 
85
  }
86
 
100
  if ( isset( $users_rank->post_id ) && $rank_id !== false ) {
101
 
102
  if ( $users_rank->post_id != $rank_id && $comp === 'AND' )
103
+ $check_rank = false;
104
 
105
  elseif ( $users_rank->post_id == $rank_id )
106
+ $check_rank = true;
107
+
108
+ }
109
+
110
+ }
111
+
112
+ if ( $user_id == get_current_user_id() ) {
113
+
114
+ if ( $comp === 'AND' ) {
115
+
116
+ if( $check_bal && $check_ref && $check_rank )
117
+ $should_show = true;
118
+
119
+ }
120
+ else {
121
+
122
+ if( ( $balance >= 0 && $check_bal ) || ( ! empty( $ref ) && $check_ref ) || ( $rank != -1 && $check_rank ) )
123
  $should_show = true;
124
 
125
  }
mycred.php CHANGED
@@ -3,7 +3,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.4.7
7
  * Tags: point, credit, loyalty program, engagement, reward, woocommerce rewards
8
  * Author: myCred
9
  * Author URI: https://mycred.me
@@ -20,7 +20,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
20
  final class myCRED_Core {
21
 
22
  // Plugin Version
23
- public $version = '2.4.7';
24
 
25
  // Instnace
26
  protected static $_instance = NULL;
@@ -54,14 +54,14 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
54
  * @since 1.7
55
  * @version 1.0
56
  */
57
- public function __clone() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.4.7' ); }
58
 
59
  /**
60
  * Not allowed
61
  * @since 1.7
62
  * @version 1.0
63
  */
64
- public function __wakeup() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.4.7' ); }
65
 
66
  /**
67
  * Get
@@ -82,7 +82,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
82
  if ( ! defined( $name ) )
83
  define( $name, $value );
84
  elseif ( ! $definable && defined( $name ) )
85
- _doing_it_wrong( 'myCRED_Core->define()', 'Could not define: ' . esc_html( $name ) . ' as it is already defined somewhere else!', '2.4.7' );
86
  }
87
 
88
  /**
@@ -94,7 +94,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
94
  if ( file_exists( $required_file ) )
95
  require_once $required_file;
96
  else
97
- _doing_it_wrong( 'myCRED_Core->file()', 'Requested file ' . esc_html( $required_file ) . ' not found.', '2.4.7' );
98
  }
99
 
100
  /**
3
  * Plugin Name: myCred
4
  * Plugin URI: https://mycred.me
5
  * Description: An adaptive points management system for WordPress powered websites.
6
+ * Version: 2.4.8
7
  * Tags: point, credit, loyalty program, engagement, reward, woocommerce rewards
8
  * Author: myCred
9
  * Author URI: https://mycred.me
20
  final class myCRED_Core {
21
 
22
  // Plugin Version
23
+ public $version = '2.4.8';
24
 
25
  // Instnace
26
  protected static $_instance = NULL;
54
  * @since 1.7
55
  * @version 1.0
56
  */
57
+ public function __clone() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.4.8' ); }
58
 
59
  /**
60
  * Not allowed
61
  * @since 1.7
62
  * @version 1.0
63
  */
64
+ public function __wakeup() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.4.8' ); }
65
 
66
  /**
67
  * Get
82
  if ( ! defined( $name ) )
83
  define( $name, $value );
84
  elseif ( ! $definable && defined( $name ) )
85
+ _doing_it_wrong( 'myCRED_Core->define()', 'Could not define: ' . esc_html( $name ) . ' as it is already defined somewhere else!', '2.4.8' );
86
  }
87
 
88
  /**
94
  if ( file_exists( $required_file ) )
95
  require_once $required_file;
96
  else
97
+ _doing_it_wrong( 'myCRED_Core->file()', 'Requested file ' . esc_html( $required_file ) . ' not found.', '2.4.8' );
98
  }
99
 
100
  /**
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mycred,wpexpertsio
3
  Tags: badges, gamification, loyalty, points, rewards
4
  Requires at least: 4.8
5
  Tested up to: 6.0
6
- Stable tag: 2.4.7
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -316,6 +316,9 @@ You can find a list of [frequently asked questions](https://mycred.me/about/faq/
316
 
317
  == Upgrade Notice ==
318
 
 
 
 
319
  = 2.4.7 =
320
  Bug fixes.
321
 
@@ -408,6 +411,12 @@ The banking module have been replaced by Central deposite module, and interest r
408
 
409
  == Changelog ==
410
 
 
 
 
 
 
 
411
  = 2.4.7 =
412
  - **NEW** - Added filter "mycred_email_event".
413
  - **FIX** - mycred_list_ranks order attribute was not working in some cases.
3
  Tags: badges, gamification, loyalty, points, rewards
4
  Requires at least: 4.8
5
  Tested up to: 6.0
6
+ Stable tag: 2.4.8
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
316
 
317
  == Upgrade Notice ==
318
 
319
+ = 2.4.8 =
320
+ Bug fixes.
321
+
322
  = 2.4.7 =
323
  Bug fixes.
324
 
411
 
412
  == Changelog ==
413
 
414
+ = 2.4.8 =
415
+ - **NEW** - Introduced new action hook mycred_cashcred_before_bank_form.
416
+ - **FIX** - Fixed PHP errors.
417
+ - **FIX** - mycred_show_if shortcode was not working correctly when using multiple shortcodes on the same page.
418
+ - **FIX** - The user field issue was fixed in the Bulk Assign tool.
419
+
420
  = 2.4.7 =
421
  - **NEW** - Added filter "mycred_email_event".
422
  - **FIX** - mycred_list_ranks order attribute was not working in some cases.