myCRED - Version 1.0.9.3

Version Description

  • Added new template tag %num_members% to show the total number of members on blog.
  • Added support for user related template tags for myCRED Balance widget.
  • Fixed Bug #23 - Misspelled $ref in mycred_add() function.
  • Fixed Bug #24 - Exchange rate returns incorrect value.
  • Fixed Bug #25 - Misspelled the new_reply method name for bbPress Hook.
  • Fixed Bug #26 - Add-on address are incorrect on windows servers.
Download this release

Release Info

Developer designbymerovingi
Plugin Icon 128x128 myCRED
Version 1.0.9.3
Comparing to
See all releases

Code changes from version 1.0.9.2 to 1.0.9.3

addons/buddypress/hooks/bp-press.php CHANGED
@@ -73,7 +73,7 @@ if ( !class_exists( 'myCRED_BuddyPress_bbPress' ) ) {
73
  * @since 0.1
74
  * @version 1.0
75
  */
76
- public function new_replay( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ) {
77
  // Check if user is excluded
78
  if ( $this->core->exclude_user( $reply_author ) ) return;
79
 
73
  * @since 0.1
74
  * @version 1.0
75
  */
76
+ public function new_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ) {
77
  // Check if user is excluded
78
  if ( $this->core->exclude_user( $reply_author ) ) return;
79
 
addons/buy-creds/abstracts/mycred-abstract-payment-gateway.php CHANGED
@@ -375,10 +375,7 @@ if ( !class_exists( 'myCRED_Payment_Gateway' ) ) {
375
  */
376
  public function POST_to_data() {
377
  $data = array();
378
- $id = $this->id;
379
- $allowed_keys = apply_filters( "mycred_POST_to_data_{$gateway_id}", ( isset( $this->allowed ) ) ? $this->allowed : array() );
380
  foreach ( $_POST as $key => $value ) {
381
- if ( !in_array( trim( $key ), $allowed_keys ) ) continue;
382
  $data[$key] = stripslashes( $value );
383
  }
384
  return $data;
375
  */
376
  public function POST_to_data() {
377
  $data = array();
 
 
378
  foreach ( $_POST as $key => $value ) {
 
379
  $data[$key] = stripslashes( $value );
380
  }
381
  return $data;
addons/buy-creds/gateways/netbilling.php CHANGED
@@ -685,12 +685,25 @@ if ( !class_exists( 'myCRED_NETbilling' ) ) {
685
  */
686
  public function sanitise_preferences( $data ) {
687
  $data['sandbox'] = ( isset( $data['sandbox'] ) ) ? 1 : 0;
 
 
 
 
 
 
 
 
 
 
 
 
688
  $data['disable_avs'] = ( isset( $data['disable_avs'] ) ) ? 1 : 0;
689
  $data['disable_cvv2'] = ( isset( $data['disable_cvv2'] ) ) ? 1 : 0;
690
  $data['disable_fraud_checks'] = ( isset( $data['disable_fraud_checks'] ) ) ? 1 : 0;
691
  $data['disable_negative_db'] = ( isset( $data['disable_negative_db'] ) ) ? 1 : 0;
692
  $data['disable_email_receipts'] = ( isset( $data['disable_email_receipts'] ) ) ? 1 : 0;
693
  $data['disable_expiration_check'] = ( isset( $data['disable_expiration_check'] ) ) ? 1 : 0;
 
694
  return $data;
695
  }
696
  }
685
  */
686
  public function sanitise_preferences( $data ) {
687
  $data['sandbox'] = ( isset( $data['sandbox'] ) ) ? 1 : 0;
688
+
689
+ // Exchange can not be empty
690
+ if ( empty( $data['exchange'] ) ) {
691
+ $data['exchange'] = 1;
692
+ }
693
+ // If exchange is less then 1 we must start with a zero
694
+ if ( $data['exchange'] != 1 && substr( $data['exchange'], 0, 1 ) != '0' ) {
695
+ $data['exchange'] = (float) '0' . $data['exchange'];
696
+ }
697
+ // Make sure decimals are marked by a dot and not a comma
698
+ $data['exchange'] = str_replace( ',', '.', $data['exchange'] );
699
+
700
  $data['disable_avs'] = ( isset( $data['disable_avs'] ) ) ? 1 : 0;
701
  $data['disable_cvv2'] = ( isset( $data['disable_cvv2'] ) ) ? 1 : 0;
702
  $data['disable_fraud_checks'] = ( isset( $data['disable_fraud_checks'] ) ) ? 1 : 0;
703
  $data['disable_negative_db'] = ( isset( $data['disable_negative_db'] ) ) ? 1 : 0;
704
  $data['disable_email_receipts'] = ( isset( $data['disable_email_receipts'] ) ) ? 1 : 0;
705
  $data['disable_expiration_check'] = ( isset( $data['disable_expiration_check'] ) ) ? 1 : 0;
706
+
707
  return $data;
708
  }
709
  }
addons/buy-creds/gateways/paypal-standard.php CHANGED
@@ -22,8 +22,7 @@ if ( !class_exists( 'myCRED_PayPal_Standard' ) ) {
22
  'account' => '',
23
  'item_name' => __( 'Purchase of myCRED %plural%', 'mycred' ),
24
  'exchange' => 1
25
- ),
26
- 'allowed' => array( 'mc_gross', 'protection_eligibility', 'payer_id', 'tax', 'payment_date', 'payment_status', 'charset', 'first_name', 'mc_fee', 'notify_version', 'custom', 'payer_status', 'business', 'quantity', 'verify_sign', 'payer_email', 'txn_id', 'payment_type', 'last_name', 'receiver_email', 'payment_fee', 'receiver_id', 'txn_type', 'item_name', 'mc_currency', 'item_number', 'residence_country', 'test_ipn', 'handling_amount', 'transaction_subject', 'payment_gross', 'shipping', 'ipn_track_id' )
27
  ), $gateway_prefs );
28
  }
29
 
22
  'account' => '',
23
  'item_name' => __( 'Purchase of myCRED %plural%', 'mycred' ),
24
  'exchange' => 1
25
+ )
 
26
  ), $gateway_prefs );
27
  }
28
 
addons/buy-creds/gateways/skrill.php CHANGED
@@ -415,10 +415,21 @@ if ( !class_exists( 'myCRED_Skrill' ) ) {
415
  public function sanitise_preferences( $data ) {
416
  $data['sandbox'] = ( !isset( $data['sandbox'] ) ) ? 0 : 1;
417
  $data['email_receipt'] = ( !isset( $data['email_receipt'] ) ) ? 0 : 1;
418
- $data['exchange'] = ( empty( $data['exchange'] ) ) ? 1 : $data['exchange'];
 
 
 
 
 
 
 
 
 
 
419
 
420
  $data['account_title'] = substr( $data['account_title'], 0, 30 );
421
  $data['confirmation_note'] = substr( $data['confirmation_note'], 0, 240 );
 
422
  return $data;
423
  }
424
  }
415
  public function sanitise_preferences( $data ) {
416
  $data['sandbox'] = ( !isset( $data['sandbox'] ) ) ? 0 : 1;
417
  $data['email_receipt'] = ( !isset( $data['email_receipt'] ) ) ? 0 : 1;
418
+
419
+ // Exchange can not be empty
420
+ if ( empty( $data['exchange'] ) ) {
421
+ $data['exchange'] = 1;
422
+ }
423
+ // If exchange is less then 1 we must start with a zero
424
+ if ( $data['exchange'] != 1 && substr( $data['exchange'], 0, 1 ) != '0' ) {
425
+ $data['exchange'] = (float) '0' . $data['exchange'];
426
+ }
427
+ // Make sure decimals are marked by a dot and not a comma
428
+ $data['exchange'] = str_replace( ',', '.', $data['exchange'] );
429
 
430
  $data['account_title'] = substr( $data['account_title'], 0, 30 );
431
  $data['confirmation_note'] = substr( $data['confirmation_note'], 0, 240 );
432
+
433
  return $data;
434
  }
435
  }
includes/mycred-functions.php CHANGED
@@ -177,7 +177,7 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
177
  * @param $rate (int|float) the exchange rate to devide by
178
  * @param $round (bool) option to round values, defaults to yes.
179
  * @since 0.1
180
- * @version 1.0
181
  */
182
  public function apply_exchange_rate( $amount, $rate = 1, $round = true ) {
183
  $amount = $this->number( $amount );
@@ -186,7 +186,7 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
186
  $exchange = $amount/(float) $rate;
187
  if ( $round ) $exchange = round( $exchange );
188
 
189
- return $this->format_number( $exchange );
190
  }
191
 
192
  /**
@@ -259,6 +259,9 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
259
  // Logout URL
260
  $content = str_replace( '%logout_url%', wp_logout_url(), $content );
261
  $content = str_replace( '%logout_url_here%', wp_logout_url( get_permalink() ), $content );
 
 
 
262
 
263
  //$content = str_replace( '', , $content );
264
  return $content;
@@ -297,7 +300,7 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
297
 
298
  // Post does not exist
299
  if ( $post === NULL ) {
300
- if ( !array_key_exists( 'ID', $data ) ) return $content;
301
  $post = new StdClass();
302
  foreach ( $data as $key => $value ) {
303
  if ( $key == 'post_title' ) $value .= ' (' . __( 'Deleted', 'mycred' ) . ')';
@@ -350,7 +353,7 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
350
 
351
  // User does not exist
352
  if ( $user === false ) {
353
- if ( !array_key_exists( 'ID', $data ) ) return $content;
354
  $user = new StdClass();
355
  foreach ( $data as $key => $value ) {
356
  $user->$key = $value;
@@ -374,8 +377,8 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
374
  $url = get_bloginfo( 'url' ) . '/' . $wp_rewrite->author_base . '/' . urlencode( $user->user_login ) . '/';
375
  }
376
 
377
- $content = str_replace( '%display_name%', $user->display_name, $content );
378
- $content = str_replace( '%user_profile_url%', $url, $content );
379
  $content = str_replace( '%user_profile_link%', '<a href="' . $url . '">' . $user->display_name . '</a>', $content );
380
 
381
  //$content = str_replace( '', $user->, $content );
@@ -403,7 +406,7 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
403
 
404
  // Comment does not exist
405
  if ( $comment === NULL ) {
406
- if ( !array_key_exists( 'comment_ID', $data ) ) return $content;
407
  $comment = new StdClass();
408
  foreach ( $data as $key => $value ) {
409
  $comment->$key = $value;
@@ -598,6 +601,16 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
598
  return false;
599
  }
600
 
 
 
 
 
 
 
 
 
 
 
601
  /**
602
  * Get Cred ID
603
  * Returns the default cred id.
@@ -962,7 +975,7 @@ if ( !function_exists( 'mycred_get_users_fcred' ) ) {
962
  * @param $data (object|array|string|int), optional extra data to save in the log. Note that arrays gets serialized!
963
  * @returns boolean true on success or false on fail
964
  * @since 0.1
965
- * @version 1.0
966
  */
967
  if ( !function_exists( 'mycred_add' ) ) {
968
  function mycred_add( $ref = '', $user_id = '', $amount = '', $entry = '', $ref_id = '', $data = '', $type = '' )
@@ -974,7 +987,7 @@ if ( !function_exists( 'mycred_add' ) ) {
974
  if ( empty( $type ) ) $type = $mycred->get_cred_id();
975
 
976
  // Add creds
977
- return $mycred->add_creds( $pref, $user_id, $amount, $entry, $ref_id, $data, $type );
978
  }
979
  }
980
 
177
  * @param $rate (int|float) the exchange rate to devide by
178
  * @param $round (bool) option to round values, defaults to yes.
179
  * @since 0.1
180
+ * @version 1.1
181
  */
182
  public function apply_exchange_rate( $amount, $rate = 1, $round = true ) {
183
  $amount = $this->number( $amount );
186
  $exchange = $amount/(float) $rate;
187
  if ( $round ) $exchange = round( $exchange );
188
 
189
+ return $this->number( $exchange );
190
  }
191
 
192
  /**
259
  // Logout URL
260
  $content = str_replace( '%logout_url%', wp_logout_url(), $content );
261
  $content = str_replace( '%logout_url_here%', wp_logout_url( get_permalink() ), $content );
262
+
263
+ // Blog Related
264
+ $content = str_replace( '%num_members%', $this->count_members(), $content );
265
 
266
  //$content = str_replace( '', , $content );
267
  return $content;
300
 
301
  // Post does not exist
302
  if ( $post === NULL ) {
303
+ if ( !is_array( $data ) || !array_key_exists( 'ID', $data ) ) return $content;
304
  $post = new StdClass();
305
  foreach ( $data as $key => $value ) {
306
  if ( $key == 'post_title' ) $value .= ' (' . __( 'Deleted', 'mycred' ) . ')';
353
 
354
  // User does not exist
355
  if ( $user === false ) {
356
+ if ( !is_array( $data ) || !array_key_exists( 'ID', $data ) ) return $content;
357
  $user = new StdClass();
358
  foreach ( $data as $key => $value ) {
359
  $user->$key = $value;
377
  $url = get_bloginfo( 'url' ) . '/' . $wp_rewrite->author_base . '/' . urlencode( $user->user_login ) . '/';
378
  }
379
 
380
+ $content = str_replace( '%display_name%', $user->display_name, $content );
381
+ $content = str_replace( '%user_profile_url%', $url, $content );
382
  $content = str_replace( '%user_profile_link%', '<a href="' . $url . '">' . $user->display_name . '</a>', $content );
383
 
384
  //$content = str_replace( '', $user->, $content );
406
 
407
  // Comment does not exist
408
  if ( $comment === NULL ) {
409
+ if ( !is_array( $data ) || !array_key_exists( 'comment_ID', $data ) ) return $content;
410
  $comment = new StdClass();
411
  foreach ( $data as $key => $value ) {
412
  $comment->$key = $value;
601
  return false;
602
  }
603
 
604
+ /**
605
+ * Count Blog Members
606
+ * @since 1.1
607
+ * @version 1.0
608
+ */
609
+ public function count_members() {
610
+ global $wpdb;
611
+ return $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->users" );
612
+ }
613
+
614
  /**
615
  * Get Cred ID
616
  * Returns the default cred id.
975
  * @param $data (object|array|string|int), optional extra data to save in the log. Note that arrays gets serialized!
976
  * @returns boolean true on success or false on fail
977
  * @since 0.1
978
+ * @version 1.1
979
  */
980
  if ( !function_exists( 'mycred_add' ) ) {
981
  function mycred_add( $ref = '', $user_id = '', $amount = '', $entry = '', $ref_id = '', $data = '', $type = '' )
987
  if ( empty( $type ) ) $type = $mycred->get_cred_id();
988
 
989
  // Add creds
990
+ return $mycred->add_creds( $ref, $user_id, $amount, $entry, $ref_id, $data, $type );
991
  }
992
  }
993
 
includes/mycred-widgets.php CHANGED
@@ -3,7 +3,7 @@ if ( !defined( 'myCRED_VERSION' ) ) exit;
3
  /**
4
  * Widget: myCRED Balance
5
  * @since 0.1
6
- * @version 1.0
7
  */
8
  if ( !class_exists( 'myCRED_Widget_Balance' ) ) {
9
  class myCRED_Widget_Balance extends WP_Widget {
@@ -54,6 +54,7 @@ if ( !class_exists( 'myCRED_Widget_Balance' ) ) {
54
  if ( empty( $balance ) ) $balance = 0;
55
 
56
  $layout = $mycred->template_tags_amount( $instance['cred_format'], $balance );
 
57
 
58
  // Include Ranking
59
  if ( $instance['show_rank'] ) {
3
  /**
4
  * Widget: myCRED Balance
5
  * @since 0.1
6
+ * @version 1.1
7
  */
8
  if ( !class_exists( 'myCRED_Widget_Balance' ) ) {
9
  class myCRED_Widget_Balance extends WP_Widget {
54
  if ( empty( $balance ) ) $balance = 0;
55
 
56
  $layout = $mycred->template_tags_amount( $instance['cred_format'], $balance );
57
+ $layout = $mycred->template_tags_user( $layout, $balance );
58
 
59
  // Include Ranking
60
  if ( $instance['show_rank'] ) {
modules/mycred-module-addons.php CHANGED
@@ -142,7 +142,10 @@ if ( !class_exists( 'myCRED_Addons' ) ) {
142
  $addon_search = glob( $addon_location . "*/$prefix*.php" );
143
  if ( !empty( $addon_search ) && $addon_search !== false ) {
144
  foreach ( $addon_search as $filename ) {
145
- $sub_file = str_replace( ABSPATH, '', $filename );
 
 
 
146
  // Get File Name
147
  preg_match( '/(.{1,})\/(.{1,})/', $sub_file, $matches );
148
  $sub_file_name = $matches[2];
@@ -154,7 +157,7 @@ if ( !class_exists( 'myCRED_Addons' ) ) {
154
  }
155
  // Prevent Duplicates
156
  if ( !array_key_exists( $sub_file_name, $installed ) ) {
157
- $installed[$this->make_id($sub_file_name)] = $addon_info;
158
  }
159
  }
160
  }
@@ -216,7 +219,7 @@ if ( !class_exists( 'myCRED_Addons' ) ) {
216
  /**
217
  * Get Path of Addon
218
  * @since 0.1
219
- * @version 1.0
220
  */
221
  public function get_path( $key ) {
222
  $installed = $this->installed;
142
  $addon_search = glob( $addon_location . "*/$prefix*.php" );
143
  if ( !empty( $addon_search ) && $addon_search !== false ) {
144
  foreach ( $addon_search as $filename ) {
145
+ // Handle windows
146
+ $abspath = str_replace( '/', '', ABSPATH );
147
+ // Remove ABSPATH to prevent long string addresses. Everything starts with wp-content
148
+ $sub_file = str_replace( array( $abspath, ABSPATH ), '', $filename );
149
  // Get File Name
150
  preg_match( '/(.{1,})\/(.{1,})/', $sub_file, $matches );
151
  $sub_file_name = $matches[2];
157
  }
158
  // Prevent Duplicates
159
  if ( !array_key_exists( $sub_file_name, $installed ) ) {
160
+ $installed[$this->make_id( $sub_file_name )] = $addon_info;
161
  }
162
  }
163
  }
219
  /**
220
  * Get Path of Addon
221
  * @since 0.1
222
+ * @version 1.1
223
  */
224
  public function get_path( $key ) {
225
  $installed = $this->installed;
mycred.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: myCRED
4
  Plugin URI: http://mycred.me
5
  Description: <strong>my</strong>CRED is an adaptive points management system for WordPress powered websites, giving you full control on how points are gained, used, traded, managed, logged or presented.
6
- Version: 1.0.9.2
7
  Tags: points, tokens, credit, management, reward, charge
8
  Author: Gabriel S Merovingi
9
  Author URI: http://www.merovingi.com
@@ -13,7 +13,7 @@ Tested up to: WP 3.5.1
13
  License: GPLv2 or later
14
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
  */
16
- define( 'myCRED_VERSION', '1.0.9.2' );
17
  define( 'myCRED_SLUG', 'mycred' );
18
 
19
  define( 'myCRED_THIS', __FILE__ );
3
  Plugin Name: myCRED
4
  Plugin URI: http://mycred.me
5
  Description: <strong>my</strong>CRED is an adaptive points management system for WordPress powered websites, giving you full control on how points are gained, used, traded, managed, logged or presented.
6
+ Version: 1.0.9.3
7
  Tags: points, tokens, credit, management, reward, charge
8
  Author: Gabriel S Merovingi
9
  Author URI: http://www.merovingi.com
13
  License: GPLv2 or later
14
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
15
  */
16
+ define( 'myCRED_VERSION', '1.0.9.3' );
17
  define( 'myCRED_SLUG', 'mycred' );
18
 
19
  define( 'myCRED_THIS', __FILE__ );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate Link: http://mycred.me/donate/
4
  Tags:points, tokens, credit, management, reward, charge, community, BuddyPress, Jetpack
5
  Requires at least: 3.1
6
  Tested up to: 3.5.1
7
- Stable tag: 1.0.9.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -122,6 +122,14 @@ Yes but if one of them is bought, all is shown. The mycred_sell_this shortcode w
122
 
123
  == Changelog ==
124
 
 
 
 
 
 
 
 
 
125
  = 1.0.9.2 =
126
  * Fixed Bug #22 - BadgeOS Badge ID issue. Critical for BadgeOS users!
127
  * Adjusted plugin to handle custom features when adjusting a users points balance.
4
  Tags:points, tokens, credit, management, reward, charge, community, BuddyPress, Jetpack
5
  Requires at least: 3.1
6
  Tested up to: 3.5.1
7
+ Stable tag: 1.0.9.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
122
 
123
  == Changelog ==
124
 
125
+ = 1.0.9.3 =
126
+ * Added new template tag %num_members% to show the total number of members on blog.
127
+ * Added support for user related template tags for myCRED Balance widget.
128
+ * Fixed Bug #23 - Misspelled $ref in mycred_add() function.
129
+ * Fixed Bug #24 - Exchange rate returns incorrect value.
130
+ * Fixed Bug #25 - Misspelled the new_reply method name for bbPress Hook.
131
+ * Fixed Bug #26 - Add-on address are incorrect on windows servers.
132
+
133
  = 1.0.9.2 =
134
  * Fixed Bug #22 - BadgeOS Badge ID issue. Critical for BadgeOS users!
135
  * Adjusted plugin to handle custom features when adjusting a users points balance.