myCRED - Version 1.1.2

Version Description

See: http://mycred.me/download/changelog/

Download this release

Release Info

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

Code changes from version 1.1.1 to 1.1.2

abstracts/mycred-abstract-hook.php CHANGED
@@ -4,7 +4,7 @@ if ( !defined( 'myCRED_VERSION' ) ) exit;
4
  * myCRED_Hook class
5
  * @see http://mycred.me/classes/mycred_hook/
6
  * @since 0.1
7
- * @version 1.0
8
  */
9
  if ( !class_exists( 'myCRED_Hook' ) ) {
10
  abstract class myCRED_Hook {
@@ -27,16 +27,24 @@ if ( !class_exists( 'myCRED_Hook' ) ) {
27
  $this->$key = $value;
28
  }
29
  }
 
 
 
 
 
30
  if ( $hook_prefs !== NULL ) {
31
  // Assign prefs if set
32
  if ( isset( $hook_prefs[$this->id] ) )
33
  $this->prefs = $hook_prefs[$this->id];
34
 
35
- // Apply defaults (if needed)
36
- if ( empty( $this->prefs ) || $this->prefs === false )
37
- $this->prefs = $this->defaults;
38
  }
39
- $this->core = mycred_get_settings();
 
 
 
40
  }
41
 
42
  /**
4
  * myCRED_Hook class
5
  * @see http://mycred.me/classes/mycred_hook/
6
  * @since 0.1
7
+ * @version 1.1
8
  */
9
  if ( !class_exists( 'myCRED_Hook' ) ) {
10
  abstract class myCRED_Hook {
27
  $this->$key = $value;
28
  }
29
  }
30
+
31
+ // Grab myCRED Settings
32
+ $this->core = mycred_get_settings();
33
+
34
+ // Grab settings
35
  if ( $hook_prefs !== NULL ) {
36
  // Assign prefs if set
37
  if ( isset( $hook_prefs[$this->id] ) )
38
  $this->prefs = $hook_prefs[$this->id];
39
 
40
+ // Defaults must be set
41
+ if ( !isset( $this->defaults ) || empty( $this->defaults ) )
42
+ $this->defaults = array();
43
  }
44
+
45
+ // Apply default settings if needed
46
+ if ( !empty( $this->defaults ) )
47
+ $this->prefs = wp_parse_args( $this->prefs, $this->defaults );
48
  }
49
 
50
  /**
abstracts/mycred-abstract-module.php CHANGED
@@ -4,7 +4,7 @@ if ( !defined( 'myCRED_VERSION' ) ) exit;
4
  * myCRED_Module class
5
  * @see http://mycred.me/classes/mycred_module/
6
  * @since 0.1
7
- * @version 1.1
8
  */
9
  if ( !class_exists( 'myCRED_Module' ) ) {
10
  abstract class myCRED_Module {
@@ -80,9 +80,9 @@ if ( !class_exists( 'myCRED_Module' ) ) {
80
  /**
81
  * Set Settings
82
  * @since 0.1
83
- * @version 1.0
84
  */
85
- function set_settings( $defaults ) {
86
  $module = $this->module_name;
87
 
88
  // Reqest not to register any settings
@@ -93,6 +93,10 @@ if ( !class_exists( 'myCRED_Module' ) ) {
93
  // Else append settings
94
  else
95
  $this->$module = $this->core->$module;
 
 
 
 
96
  }
97
  // Request to register settings
98
  else {
@@ -115,6 +119,10 @@ if ( !class_exists( 'myCRED_Module' ) ) {
115
  $this->$module[$option_name] = $defaults[$option_id];
116
  else
117
  $this->$module[$option_name] = $settings;
 
 
 
 
118
  }
119
  }
120
  // String = one
@@ -132,6 +140,10 @@ if ( !class_exists( 'myCRED_Module' ) ) {
132
 
133
  if ( $this->$module === false && !empty( $defaults ) )
134
  $this->$module = $defaults;
 
 
 
 
135
  }
136
  }
137
 
4
  * myCRED_Module class
5
  * @see http://mycred.me/classes/mycred_module/
6
  * @since 0.1
7
+ * @version 1.2
8
  */
9
  if ( !class_exists( 'myCRED_Module' ) ) {
10
  abstract class myCRED_Module {
80
  /**
81
  * Set Settings
82
  * @since 0.1
83
+ * @version 1.1
84
  */
85
+ function set_settings( $defaults = array() ) {
86
  $module = $this->module_name;
87
 
88
  // Reqest not to register any settings
93
  // Else append settings
94
  else
95
  $this->$module = $this->core->$module;
96
+
97
+ // Apply defaults in case new settings have been applied
98
+ if ( !empty( $defaults ) )
99
+ $this->$module = mycred_apply_defaults( $defaults, $this->$module );
100
  }
101
  // Request to register settings
102
  else {
119
  $this->$module[$option_name] = $defaults[$option_id];
120
  else
121
  $this->$module[$option_name] = $settings;
122
+
123
+ // Apply defaults in case new settings have been applied
124
+ if ( array_key_exists( $option_id, $defaults ) )
125
+ $this->$module[$option_name] = mycred_apply_defaults( $defaults[$option_id], $this->$module[$option_name] );
126
  }
127
  }
128
  // String = one
140
 
141
  if ( $this->$module === false && !empty( $defaults ) )
142
  $this->$module = $defaults;
143
+
144
+ // Apply defaults in case new settings have been applied
145
+ if ( !empty( $defaults ) )
146
+ $this->$module = mycred_apply_defaults( $defaults, $this->$module );
147
  }
148
  }
149
 
addons/buddypress/myCRED-addon-buddypress.php CHANGED
@@ -61,7 +61,7 @@ if ( !class_exists( 'myCRED_BuddyPress' ) ) {
61
  /**
62
  * Init
63
  * @since 0.1
64
- * @version 1.0
65
  */
66
  public function module_init() {
67
  add_filter( 'mycred_setup_hooks', array( $this, 'register_hooks' ) );
@@ -101,7 +101,7 @@ if ( !class_exists( 'myCRED_BuddyPress' ) ) {
101
  /**
102
  * Show Balance in Profile
103
  * @since 0.1
104
- * @version 1.0
105
  */
106
  public function show_balance_profile() {
107
  $user_id = bp_displayed_user_id();
@@ -133,7 +133,7 @@ if ( !class_exists( 'myCRED_BuddyPress' ) ) {
133
  /**
134
  * Show Balance in Header
135
  * @since 0.1
136
- * @version 1.0
137
  */
138
  public function show_balance( $table_row = false ) {
139
  if ( bp_is_my_profile() || ( !bp_is_my_profile() && $this->buddypress['visibility']['balance'] ) || mycred_is_admin() ) {
@@ -149,6 +149,7 @@ if ( !class_exists( 'myCRED_BuddyPress' ) ) {
149
  $rank_name = mycred_get_users_rank( $user_id );
150
  $template = str_replace( '%rank%', $rank_name, $template );
151
  $template = str_replace( '%rank_logo%', mycred_get_rank_logo( $rank_name ), $template );
 
152
  }
153
  else {
154
  $template = str_replace( '%rank%', mycred_rankings_position( $user_id ), $template );
61
  /**
62
  * Init
63
  * @since 0.1
64
+ * @version 1.1
65
  */
66
  public function module_init() {
67
  add_filter( 'mycred_setup_hooks', array( $this, 'register_hooks' ) );
101
  /**
102
  * Show Balance in Profile
103
  * @since 0.1
104
+ * @version 1.1
105
  */
106
  public function show_balance_profile() {
107
  $user_id = bp_displayed_user_id();
133
  /**
134
  * Show Balance in Header
135
  * @since 0.1
136
+ * @version 1.1
137
  */
138
  public function show_balance( $table_row = false ) {
139
  if ( bp_is_my_profile() || ( !bp_is_my_profile() && $this->buddypress['visibility']['balance'] ) || mycred_is_admin() ) {
149
  $rank_name = mycred_get_users_rank( $user_id );
150
  $template = str_replace( '%rank%', $rank_name, $template );
151
  $template = str_replace( '%rank_logo%', mycred_get_rank_logo( $rank_name ), $template );
152
+ $template = str_replace( '%ranking%', mycred_rankings_position( $user_id ), $template );
153
  }
154
  else {
155
  $template = str_replace( '%rank%', mycred_rankings_position( $user_id ), $template );
addons/gateway/carts/mycred-woocommerce.php CHANGED
@@ -190,7 +190,7 @@ if ( !function_exists( 'mycred_init_woo_gateway' ) ) {
190
  }
191
 
192
  // Charge
193
- $this->mycred->add_creds( 'woocommerce_payment', $cui, '-' . $cost, $this->log_template, $order_id, array( 'ref_type' => 'post' ) );
194
  $order->payment_complete();
195
 
196
  // Return the good news
190
  }
191
 
192
  // Charge
193
+ $this->mycred->add_creds( 'woocommerce_payment', $cui, 0-$cost, $this->log_template, $order_id, array( 'ref_type' => 'post' ) );
194
  $order->payment_complete();
195
 
196
  // Return the good news
addons/ranks/myCRED-addon-ranks.php CHANGED
@@ -100,7 +100,7 @@ if ( !class_exists( 'myCRED_Ranks' ) ) {
100
  /**
101
  * Hook into Admin Init
102
  * @since 1.1
103
- * @version 1.0
104
  */
105
  public function module_admin_init() {
106
  add_filter( 'manage_mycred_rank_posts_columns', array( $this, 'adjust_column_headers' ) );
@@ -109,13 +109,13 @@ if ( !class_exists( 'myCRED_Ranks' ) ) {
109
  add_filter( 'manage_users_columns', array( $this, 'custom_user_column' ) );
110
  add_action( 'manage_users_custom_column', array( $this, 'custom_user_column_content' ), 10, 3 );
111
 
112
- add_filter( 'post_row_actions', array( $this, 'adjust_row_actions' ), 10, 2 );
113
 
114
- add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
115
- add_filter( 'enter_title_here', array( $this, 'enter_title_here' ) );
116
 
117
- add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
118
- add_action( 'save_post', array( $this, 'save_rank_settings' ) );
119
  }
120
 
121
  /**
@@ -281,9 +281,12 @@ if ( !class_exists( 'myCRED_Ranks' ) ) {
281
  * Parse Rank
282
  * Parses the %rank% and %rank_logo% template tags.
283
  * @since 1.1
284
- * @version 1.0
285
  */
286
  public function parse_rank( $content, $user = '', $data = '' ) {
 
 
 
287
  if ( !isset( $user->ID ) ) {
288
  if ( is_array( $data ) && isset( $data['ID'] ) )
289
  $user_id = $data['ID'];
100
  /**
101
  * Hook into Admin Init
102
  * @since 1.1
103
+ * @version 1.1
104
  */
105
  public function module_admin_init() {
106
  add_filter( 'manage_mycred_rank_posts_columns', array( $this, 'adjust_column_headers' ) );
109
  add_filter( 'manage_users_columns', array( $this, 'custom_user_column' ) );
110
  add_action( 'manage_users_custom_column', array( $this, 'custom_user_column_content' ), 10, 3 );
111
 
112
+ add_filter( 'post_row_actions', array( $this, 'adjust_row_actions' ), 10, 2 );
113
 
114
+ add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
115
+ add_filter( 'enter_title_here', array( $this, 'enter_title_here' ) );
116
 
117
+ add_action( 'add_meta_boxes_mycred_rank', array( $this, 'add_meta_boxes' ) );
118
+ add_action( 'save_post', array( $this, 'save_rank_settings' ) );
119
  }
120
 
121
  /**
281
  * Parse Rank
282
  * Parses the %rank% and %rank_logo% template tags.
283
  * @since 1.1
284
+ * @version 1.1
285
  */
286
  public function parse_rank( $content, $user = '', $data = '' ) {
287
+ // No rank no need to run
288
+ if ( !preg_match( '/(%rank[%|_])/', $content ) ) return $content;
289
+
290
  if ( !isset( $user->ID ) ) {
291
  if ( is_array( $data ) && isset( $data['ID'] ) )
292
  $user_id = $data['ID'];
addons/sell-content/myCRED-addon-sell-content.php CHANGED
@@ -112,7 +112,7 @@ if ( !class_exists( 'myCRED_Sell_Content' ) ) {
112
  'purchase_id' => 'TXID' . date_i18n( 'U' ),
113
  'seller' => $author
114
  );
115
- $this->core->add_creds( 'buy_content', $user_id, '-' . $prefs['price'], $log, $post_id, $data );
116
 
117
  do_action( 'mycred_sell_content_purchase_ready', $request );
118
 
112
  'purchase_id' => 'TXID' . date_i18n( 'U' ),
113
  'seller' => $author
114
  );
115
+ $this->core->add_creds( 'buy_content', $user_id, 0-$prefs['price'], $log, $post_id, $data );
116
 
117
  do_action( 'mycred_sell_content_purchase_ready', $request );
118
 
addons/transfer/js/transfer.js CHANGED
@@ -91,7 +91,7 @@ jQuery(function($){
91
  // @api http://api.jqueryui.com/autocomplete/
92
  var cache = {};
93
  $('input.mycred-autofill').autocomplete({
94
- minLength: 1,
95
  source: function( request, response ) {
96
  var term = request.term;
97
  if ( term in cache ) {
91
  // @api http://api.jqueryui.com/autocomplete/
92
  var cache = {};
93
  $('input.mycred-autofill').autocomplete({
94
+ minLength: 2,
95
  source: function( request, response ) {
96
  var term = request.term;
97
  if ( term in cache ) {
addons/transfer/myCRED-addon-transfer.php CHANGED
@@ -391,7 +391,7 @@ if ( !class_exists( 'myCRED_Transfer_Creds' ) ) {
391
  $this->core->add_creds(
392
  'transfer',
393
  $from,
394
- '-' . $amount,
395
  $prefs['logs']['sending'],
396
  $recipient_id,
397
  array( 'ref_type' => 'user', 'tid' => $transaction_id )
@@ -520,6 +520,9 @@ if ( !class_exists( 'myCRED_Widget_Transfer' ) ) {
520
  // Prep
521
  $title = $instance['title'];
522
  $mycred = mycred_get_settings();
 
 
 
523
  $pref = $mycred->transfers;
524
 
525
  global $mycred_load;
@@ -831,7 +834,7 @@ if ( !function_exists( 'mycred_user_can_transfer' ) ) {
831
  // Weekly limit
832
  elseif ( $pref['limit']['limit'] == 'weekly' ) {
833
  // New week, new limits
834
- if ( $this_week != $transfers['frame'] ) {
835
  $new_data = array(
836
  'frame' => $this_week,
837
  'amount' => $mycred->number( 0 )
@@ -853,7 +856,7 @@ if ( !function_exists( 'mycred_user_can_transfer' ) ) {
853
 
854
  // others limits
855
  else {
856
- return apply_filters( 'mycred_user_can_transfer', $mycred->number( $pref['limit']['amount'] ), $user_id, $balance, $transfers, $mycred );
857
  }
858
  }
859
  }
391
  $this->core->add_creds(
392
  'transfer',
393
  $from,
394
+ 0-$amount,
395
  $prefs['logs']['sending'],
396
  $recipient_id,
397
  array( 'ref_type' => 'user', 'tid' => $transaction_id )
520
  // Prep
521
  $title = $instance['title'];
522
  $mycred = mycred_get_settings();
523
+ if ( !isset( $mycred->transfers ) )
524
+ return '<p>' . __( 'The myCRED Transfer add-on has not yet been setup!', 'mycred' ) . '</p>';
525
+
526
  $pref = $mycred->transfers;
527
 
528
  global $mycred_load;
834
  // Weekly limit
835
  elseif ( $pref['limit']['limit'] == 'weekly' ) {
836
  // New week, new limits
837
+ if ( $this_week != $history['frame'] ) {
838
  $new_data = array(
839
  'frame' => $this_week,
840
  'amount' => $mycred->number( 0 )
856
 
857
  // others limits
858
  else {
859
+ return apply_filters( 'mycred_user_can_transfer', $mycred->number( $pref['limit']['amount'] ), $user_id, $balance, $history, $mycred );
860
  }
861
  }
862
  }
includes/mycred-functions.php CHANGED
@@ -347,13 +347,16 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
347
  * @param $data (object) Log entry data object
348
  * @return (string) parsed string
349
  * @since 0.1
350
- * @version 1.0.3
351
  */
352
  public function template_tags_user( $content, $ref_id = NULL, $data = '' ) {
353
  if ( $ref_id === NULL ) return $content;
354
 
355
  // Get User Object
356
- $user = get_userdata( $ref_id );
 
 
 
357
 
358
  // User does not exist
359
  if ( $user === false ) {
@@ -389,7 +392,6 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
389
  $content = str_replace( '%user_profile_link%', '<a href="' . $url . '">' . $user->display_name . '</a>', $content );
390
 
391
  $content = str_replace( '%user_nicename%', ( isset( $user->user_nicename ) ) ? $user->user_nicename : '', $content );
392
- $content = str_replace( '%nickname%', ( isset( $user->nickname ) ) ? $user->nickname : '', $content );
393
  $content = str_replace( '%user_email%', ( isset( $user->user_email ) ) ? $user->user_email : '', $content );
394
  $content = str_replace( '%user_url%', ( isset( $user->user_url ) ) ? $user->user_url : '', $content );
395
 
@@ -709,7 +711,7 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
709
  * @param $type (string), optional point name, defaults to 'mycred_default'
710
  * @returns boolean true on success or false on fail
711
  * @since 0.1
712
- * @version 1.1
713
  */
714
  public function add_creds( $ref = '', $user_id = '', $amount = '', $entry = '', $ref_id = '', $data = '', $type = 'mycred_default' ) {
715
  // All the reasons we would fail
@@ -733,10 +735,18 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
733
  if ( !empty( $entry ) )
734
  $this->add_to_log( $ref, $user_id, $amount, $entry, $ref_id, $data, $type );
735
 
 
 
 
 
736
  return true;
737
  }
738
  // done (string) - "Already done"
739
  elseif ( $execute === 'done' ) {
 
 
 
 
740
  return true;
741
  }
742
  // false (boolean) - "No"
@@ -744,6 +754,22 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
744
  return false;
745
  }
746
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
747
 
748
  /**
749
  * Add Log Entry
@@ -1171,4 +1197,28 @@ if ( !function_exists( 'mycred_get_total_by_time' ) ) {
1171
  return $mycred->format_number( $count );
1172
  }
1173
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1174
  ?>
347
  * @param $data (object) Log entry data object
348
  * @return (string) parsed string
349
  * @since 0.1
350
+ * @version 1.0.4
351
  */
352
  public function template_tags_user( $content, $ref_id = NULL, $data = '' ) {
353
  if ( $ref_id === NULL ) return $content;
354
 
355
  // Get User Object
356
+ if ( $ref_id !== false )
357
+ $user = get_userdata( $ref_id );
358
+ else
359
+ $user = $ref_id;
360
 
361
  // User does not exist
362
  if ( $user === false ) {
392
  $content = str_replace( '%user_profile_link%', '<a href="' . $url . '">' . $user->display_name . '</a>', $content );
393
 
394
  $content = str_replace( '%user_nicename%', ( isset( $user->user_nicename ) ) ? $user->user_nicename : '', $content );
 
395
  $content = str_replace( '%user_email%', ( isset( $user->user_email ) ) ? $user->user_email : '', $content );
396
  $content = str_replace( '%user_url%', ( isset( $user->user_url ) ) ? $user->user_url : '', $content );
397
 
711
  * @param $type (string), optional point name, defaults to 'mycred_default'
712
  * @returns boolean true on success or false on fail
713
  * @since 0.1
714
+ * @version 1.2
715
  */
716
  public function add_creds( $ref = '', $user_id = '', $amount = '', $entry = '', $ref_id = '', $data = '', $type = 'mycred_default' ) {
717
  // All the reasons we would fail
735
  if ( !empty( $entry ) )
736
  $this->add_to_log( $ref, $user_id, $amount, $entry, $ref_id, $data, $type );
737
 
738
+ // Update rankings
739
+ if ( $this->frequency['rate'] == 'always' )
740
+ $this->update_rankings();
741
+
742
  return true;
743
  }
744
  // done (string) - "Already done"
745
  elseif ( $execute === 'done' ) {
746
+ // Update rankings
747
+ if ( $this->frequency['rate'] == 'always' )
748
+ $this->update_rankings();
749
+
750
  return true;
751
  }
752
  // false (boolean) - "No"
754
  return false;
755
  }
756
  }
757
+
758
+ /**
759
+ * Update Rankings
760
+ * Updates the rankings for a given points type.
761
+ *
762
+ * @param $force (bool), if rankings are updated on a set interval, this option can override
763
+ * and force a new setting to be saved.
764
+ * @param $type (string), optional points type
765
+ * @since 1.1.2
766
+ * @version 1.0
767
+ */
768
+ public function update_rankings( $force = false, $type = 'mycred_default' ) {
769
+ $ranking = new myCRED_Query_Rankings( array( 'type' => $type ) );
770
+ $ranking->get_rankings();
771
+ $ranking->save( $force );
772
+ }
773
 
774
  /**
775
  * Add Log Entry
1197
  return $mycred->format_number( $count );
1198
  }
1199
  }
1200
+
1201
+ /**
1202
+ * Apply Defaults
1203
+ * Based on the shortcode_atts() function with support for
1204
+ * multidimentional arrays.
1205
+ * @since 1.1.2
1206
+ * @version 1.0
1207
+ */
1208
+ if ( !function_exists( 'mycred_apply_defaults' ) ) {
1209
+ function mycred_apply_defaults( &$pref, $set ) {
1210
+ $set = (array) $set;
1211
+ $return = array();
1212
+ foreach ( $pref as $key => $value ) {
1213
+ if ( array_key_exists( $key, $set ) ) {
1214
+ if ( is_array( $value ) && !empty( $value ) )
1215
+ $return[$key] = mycred_apply_defaults( $value, $set[$key] );
1216
+ else
1217
+ $return[$key] = $set[$key];
1218
+ }
1219
+ else $return[$key] = $value;
1220
+ }
1221
+ return $return;
1222
+ }
1223
+ }
1224
  ?>
includes/mycred-install.php CHANGED
@@ -113,9 +113,18 @@ if ( !class_exists( 'myCRED_Install' ) ) {
113
  /**
114
  * Re-activation
115
  * @since 0.1
116
- * @version 1.0
117
  */
118
  public function reactivate() {
 
 
 
 
 
 
 
 
 
119
  do_action( 'mycred_reactivation' );
120
  }
121
 
113
  /**
114
  * Re-activation
115
  * @since 0.1
116
+ * @version 1.1
117
  */
118
  public function reactivate() {
119
+ // Update rankings on re-activation
120
+ if ( !class_exists( 'myCRED_Query_Rankings' ) )
121
+ include_once( myCRED_INCLUDES_DIR . '/mycred-rankings.php' );
122
+
123
+ $ranking = new myCRED_Query_Rankings();
124
+ $ranking->get_rankings();
125
+ $ranking->save( true );
126
+ unset( $ranking );
127
+
128
  do_action( 'mycred_reactivation' );
129
  }
130
 
includes/mycred-rankings.php CHANGED
@@ -1,130 +1,199 @@
1
  <?php
2
  if ( !defined( 'myCRED_VERSION' ) ) exit;
 
3
  /**
4
- * myCRED_Rankings class
5
- * @see http://mycred.me/features/mycred_rankings/
6
- * @since 0.1
7
  * @version 1.0
8
  */
9
- if ( !class_exists( 'myCRED_Rankings' ) ) {
10
- class myCRED_Rankings {
11
 
12
- public $core;
13
  public $args;
14
- public $results;
15
-
16
- private $frequency;
17
 
18
  /**
19
  * Constructor
20
  */
21
- public function __construct( $args = array(), $reload = false ) {
22
- // Get settings
23
- $mycred = mycred_get_settings();
24
- $this->core = $mycred;
25
-
26
- // Parse arguments
27
- $this->args = wp_parse_args( $args, array(
28
- 'number' => '-1',
29
- 'offset' => 0,
30
- 'order' => 'DESC',
31
- 'allowed_tags' => '',
32
- 'meta_key' => $mycred->get_cred_id(),
33
- 'template' => '#%ranking% %user_profile_link% %cred_f%'
34
- ) );
35
- $this->frequency = 12 * HOUR_IN_SECONDS;
36
-
37
- // Delete transient forcing a new query.
38
- $this->_transients( $reload );
39
-
40
- // Get rankings
41
- $this->get_rankings();
42
  }
43
-
44
  /**
45
- * Transients
46
- * Removes the transient if needed.
47
- * @since 0.1
48
  * @version 1.0
49
  */
50
- public function _transients( $reload = false ) {
51
- if ( $this->core->frequency['rate'] == 'always' && $reload === false ) return;
 
 
 
52
 
53
- // Get history
54
- $history = get_option( 'mycred_transients' );
 
 
 
 
 
 
55
 
56
- // Rate
57
- if ( $this->core->frequency['rate'] == 'daily' )
58
- $today = date_i18n( 'd' );
59
- elseif ( $this->core->frequency['rate'] == 'weekly' )
60
- $today = date_i18n( 'W' );
61
  else
62
- $today = date_i18n( 'Y-m-d' );
63
-
64
- // If history is missing create it now
65
- if ( $history === false ) $history = array( $this->args['meta_key'] => '' );
66
-
67
- // Reset on a specific date
68
- if ( $this->core->frequency['rate'] == 'date' && $today == $this->core->frequency['date'] && empty( $history[$this->args['meta_key']] ) ) {
69
- $reload = true;
70
- }
71
- // Reset on a regular basis
72
- elseif ( $this->core->frequency['rate'] != 'date' && $today != $history[$this->args['meta_key']] ) {
73
- $reload = true;
74
- }
75
 
76
- // "Reset" by deleting the transient forcing a new database query
77
- if ( $reload === true ) {
78
- delete_transient( $this->args['meta_key'] . '_ranking' );
79
- $history[$this->args['meta_key']] = $today;
80
- update_option( 'mycred_transients', $history );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
 
84
  /**
85
- * Get Rankings
86
- * Returns either the transient copy of the current results or queries a new one.
87
- * @since 0.1
 
 
88
  * @version 1.0
89
  */
90
- protected function get_rankings() {
91
- // Get any existing copies of our transient data
92
- if ( false === ( $this->results = get_transient( $this->args['meta_key'] . '_ranking' ) ) ) {
93
- global $wpdb;
94
-
95
- // Transient missing, run new query
96
- $wp = $wpdb->prefix;
97
- $this->results = $wpdb->get_results( $wpdb->prepare( "SELECT {$wp}users.ID AS user_id, {$wp}users.display_name, {$wp}users.user_login, {$wp}usermeta.meta_value AS creds FROM {$wp}users LEFT JOIN {$wp}usermeta ON {$wp}users.ID = {$wp}usermeta.user_id AND {$wp}usermeta.meta_key= %s ORDER BY {$wp}usermeta.meta_value+1 DESC", ( empty( $this->args['meta_key'] ) ) ? 'mycred_default' : $this->args['meta_key'] ), 'ARRAY_A' );
98
-
99
- // Excludes
100
- foreach ( $this->results as $row_id => $row_data ) {
101
- if ( $this->core->exclude_user( $row_data['user_id'] ) )
102
- unset( $this->results[$row_id] );
103
- }
104
 
105
- // Save new transient
106
- set_transient( $this->args['meta_key'] . '_ranking', $this->results, $this->frequency );
107
- }
 
 
 
 
 
 
108
 
109
- // Reverse order if requested
110
- if ( $this->args['order'] == 'ASC' ) {
111
- $this->results = array_reverse( $this->results, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
- // Limit result if requested
115
- if ( $this->args['number'] != '-1' ) {
116
- $this->results = array_slice( $this->results, (int) $this->args['offset'], (int) $this->args['number'] );
 
 
 
 
 
 
117
  }
118
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
  /**
121
  * Have Results
122
  * @returns true or false
123
  * @since 0.1
124
- * @version 1.0
125
  */
126
  public function have_results() {
127
- if ( !empty( $this->results ) ) return true;
128
  return false;
129
  }
130
 
@@ -133,15 +202,21 @@ if ( !class_exists( 'myCRED_Rankings' ) ) {
133
  * @param $user_id (int) required user id
134
  * @returns position (int)
135
  * @since 0.1
136
- * @version 1.0
137
  */
138
- public function users_position( $user_id = '' ) {
139
- if ( $this->have_results() ) {
140
- foreach ( $this->results as $row_id => $row_data ) {
141
- if ( $row_data['user_id'] == $user_id ) return $row_id+1;
 
 
 
 
 
142
  }
143
  }
144
- else return 1;
 
145
  }
146
 
147
  /**
@@ -149,35 +224,38 @@ if ( !class_exists( 'myCRED_Rankings' ) ) {
149
  * @param $user_id (int) user id
150
  * @returns position (int) or empty
151
  * @since 0.1
152
- * @version 1.0
153
  */
154
  public function users_creds( $user_id = NULL ) {
155
- if ( $user_id === NULL ) $user_id = get_current_user_id();
156
- if ( $this->have_results() ) {
157
- foreach ( $this->results as $row_id => $row_data ) {
158
- if ( $row_data['user_id'] == $user_id ) return $row_data['creds'];
 
 
 
 
159
  }
160
  }
161
- else return '';
 
162
  }
163
 
164
  /**
165
- * Display
166
  * @since 0.1
167
  * @version 1.0
168
  */
169
- public function display() {
170
- echo $this->get_display();
171
  }
172
 
173
  /**
174
- * Get Display
175
- * Generates an organized list for our results.
176
- *
177
  * @since 0.1
178
- * @version 1.0
179
  */
180
- public function get_display() {
181
  // Default template
182
  if ( empty( $this->args['template'] ) ) $this->args['template'] = '#%ranking% %user_profile_link% %cred_f%';
183
 
@@ -185,10 +263,9 @@ if ( !class_exists( 'myCRED_Rankings' ) ) {
185
  $output = '<ol class="myCRED-leaderboard">';
186
 
187
  // Loop
188
- foreach ( $this->results as $position => $row ) {
189
  // Prep
190
  $class = array();
191
- $url = get_author_posts_url( $row['user_id'] );
192
 
193
  // Classes
194
  $class[] = 'item-' . $position;
@@ -199,12 +276,15 @@ if ( !class_exists( 'myCRED_Rankings' ) ) {
199
  $class[] = 'alt';
200
 
201
  // Template Tags
202
- $layout = str_replace( '%rank%', $position+1, $this->args['template'] );
 
 
 
203
 
204
- $layout = $this->core->template_tags_amount( $layout, $row['creds'] );
205
- $layout = $this->core->template_tags_user( $layout, $row['user_id'], $row );
206
 
207
- $layout = apply_filters( 'mycred_ranking_row', $layout, $this->args['template'], $row, $position );
208
  $output .= '<li class="' . implode( ' ', $class ) . '">' . $layout . '</li>';
209
  }
210
 
@@ -220,22 +300,53 @@ if ( !class_exists( 'myCRED_Rankings' ) ) {
220
  * Returns the myCRED_Rankings object containing results.
221
  *
222
  * @param $args (array) optional array of arguments for the ranking
223
- * @var $number (int) number of results to return
224
- * @var $order (string) ASC to return with lowest creds or DESC to return highest creds first
225
- * @var $meta_key (string) optional cred meta key to check for
226
- * @var $offset (int) optional number to start from when returning records. defaults to zero (first result)
227
- * @var $allowed_tags (string) optional string containing all HTML elements that are allowed to used.
 
 
 
 
228
  * @returns class object
229
  * @since 0.1
230
- * @version 1.0
231
  */
232
  if ( !function_exists( 'mycred_rankings' ) ) {
233
- function mycred_rankings( $args = array() )
234
  {
 
 
 
 
 
 
 
 
 
 
 
235
  global $mycred_rankings;
236
- if ( !isset( $mycred_rankings ) || !empty( $args ) ) {
237
- $mycred_rankings = new myCRED_Rankings( $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  }
 
 
239
  return $mycred_rankings;
240
  }
241
  }
@@ -245,33 +356,29 @@ if ( !function_exists( 'mycred_rankings' ) ) {
245
  * Returns a given users position in the ranking list.
246
  *
247
  * @param $user_id (int) required user id
248
- * @param $args (array) optinal arguments to pass on for the db query
249
  * @returns position (int) or empty if no record could be made
250
  * @since 0.1
251
- * @version 1.0
252
  */
253
  if ( !function_exists( 'mycred_rankings_position' ) ) {
254
- function mycred_rankings_position( $user_id = '' )
255
  {
256
- $rankings = mycred_rankings();
257
- if ( $rankings->have_results() ) {
258
- foreach ( $rankings->results as $row_id => $row_data ) {
259
- if ( $row_data['user_id'] == $user_id ) return $row_id+1;
260
- }
261
- }
262
- return '';
263
  }
264
  }
265
 
266
  /**
267
  * Force Leaderboard Update
268
  * @since 1.0.9.1
269
- * @version 1.0
270
  */
271
  add_action( 'delete_user', 'mycred_adjust_ranking_delete_user' );
272
  function mycred_adjust_ranking_delete_user( $user_id )
273
  {
274
- $rankings = mycred_rankings();
275
- $rankings->_transients( true );
 
276
  }
277
  ?>
1
  <?php
2
  if ( !defined( 'myCRED_VERSION' ) ) exit;
3
+
4
  /**
5
+ * myCRED Query Rankings Class
6
+ * @see http://mycred.me/features/mycred_query_rankings/
7
+ * @since 1.1.2
8
  * @version 1.0
9
  */
10
+ if ( !class_exists( 'myCRED_Query_Rankings' ) ) {
11
+ class myCRED_Query_Rankings {
12
 
 
13
  public $args;
14
+ public $count = 0;
15
+ public $result;
 
16
 
17
  /**
18
  * Constructor
19
  */
20
+ public function __construct( $args = '' ) {
21
+ $this->args = shortcode_atts( array(
22
+ 'number' => '-1',
23
+ 'order' => 'DESC',
24
+ 'user_fields' => 'user_login,display_name,user_email,user_nicename,user_url',
25
+ 'offset' => 0,
26
+ 'type' => 'mycred_default'
27
+ ), $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
+
30
  /**
31
+ * Have Results
32
+ * @returns true or false
33
+ * @since 1.1.2
34
  * @version 1.0
35
  */
36
+ public function have_results() {
37
+ if ( !empty( $this->result ) ) return true;
38
+
39
+ return false;
40
+ }
41
 
42
+ /**
43
+ * Get Rankings
44
+ * Queries the DB for all users in order of their point balance.
45
+ * @since 1.1.2
46
+ * @version 1.0
47
+ */
48
+ public function get_rankings() {
49
+ global $wpdb;
50
 
51
+ // Type can not be empty
52
+ if ( !empty( $this->args['type'] ) )
53
+ $key = $this->args['type'];
 
 
54
  else
55
+ $key = 'mycred_default';
56
+
57
+ // Order
58
+ if ( !empty( $this->args['order'] ) )
59
+ $order = $this->args['order'];
60
+ else
61
+ $order = 'DESC';
 
 
 
 
 
 
62
 
63
+ // Number
64
+ if ( $this->args['number'] != '-1' )
65
+ $limit = 'LIMIT ' . abs( $this->args['offset'] ) . ',' . abs( $this->args['number'] );
66
+ else
67
+ $limit = '';
68
+
69
+ // User fields
70
+ if ( empty( $this->args['user_fields'] ) )
71
+ $this->args['user_fields'] = 'display_name,user_login';
72
+
73
+ $user_fields = trim( $this->args['user_fields'] );
74
+ $user_fields = str_replace( ' ', '', $user_fields );
75
+ $user_fields = explode( ',', $user_fields );
76
+
77
+ // Start constructing query
78
+
79
+ $prep = array();
80
+
81
+ $wp = $wpdb->prefix;
82
+
83
+ // SELECT
84
+ $selects = array( $wp . 'users.ID' );
85
+ foreach ( $user_fields as $field ) {
86
+ if ( $field == 'ID' ) continue;
87
+ $selects[] = $wp . 'users.' . $field;
88
  }
89
+ $selects[] = $wp . 'usermeta.meta_value AS cred';
90
+
91
+ $select = implode( ', ', $selects );
92
+ $SQL = "SELECT {$select}
93
+ FROM {$wp}users
94
+ LEFT JOIN {$wp}usermeta
95
+ ON {$wp}users.ID = {$wp}usermeta.user_id AND {$wp}usermeta.meta_key = %s
96
+ ORDER BY {$wp}usermeta.meta_value+1 {$order} " . $limit;
97
+
98
+ $this->result = $wpdb->get_results( $wpdb->prepare( $SQL, $key ), 'ARRAY_A' );
99
+ $this->count = $wpdb->num_rows;
100
  }
101
 
102
  /**
103
+ * Save
104
+ * With the option to reset and bypass any set frequency.
105
+ * If a frequency is set to something other then 'always', then that
106
+ * setting is enforced.
107
+ * @since 1.1.2
108
  * @version 1.0
109
  */
110
+ public function save( $reset = false ) {
111
+ // Will not save no results
112
+ if ( !$this->have_results() ) return;
 
 
 
 
 
 
 
 
 
 
 
113
 
114
+ // Prep
115
+ $mycred = mycred_get_settings();
116
+ $save = $reset;
117
+ $lifespan = 1 * DAY_IN_SECONDS;
118
+
119
+ $history = get_option( 'mycred_transients' );
120
+ // If history has never been set
121
+ if ( $history === false )
122
+ $history = array( $this->args['type'] => '' );
123
 
124
+ // If transiet is missing for this type
125
+ if ( !isset( $history[ $this->args['type'] ] ) )
126
+ $history[ $this->args['type'] ] = '';
127
+
128
+ // Always updated
129
+ if ( $mycred->frequency['rate'] == 'always' ) {
130
+ $save = true;
131
+ }
132
+ // Daily updates
133
+ elseif ( $mycred->frequency['rate'] == 'daily' ) {
134
+ $today = date_i18n( 'd' );
135
+ if ( $today != $history[ $this->args['type'] ] ) $save = true;
136
+ }
137
+ // Weekly update
138
+ elseif ( $mycred->frequency['rate'] == 'weekly' ) {
139
+ $today = date_i18n( 'W' );
140
+ if ( $today != $history[ $this->args['type'] ] ) $save = true;
141
+ $lifespan = 1 * WEEK_IN_SECONDS;
142
+ }
143
+ // Update on specific date
144
+ elseif ( $mycred->frequency['rate'] == 'date' ) {
145
+ $date = $mycred->frequency['date'];
146
+ $today = date_i18n( 'Y-m-d' );
147
+ if ( $today == $date ) $save = true;
148
+ $lifespan = 12 * HOUR_IN_SECONDS;
149
  }
150
 
151
+ // Save new transient
152
+ if ( $save === true ) {
153
+ delete_transient( $this->args['type'] . '_ranking' );
154
+ set_transient( $this->args['type'] . '_ranking', $this->result, $lifespan );
155
+
156
+ if ( $mycred->frequency['rate'] != 'always' ) {
157
+ $history[ $this->args['type'] ] = $today;
158
+ update_option( 'mycred_transients', $history );
159
+ }
160
  }
161
  }
162
+ }
163
+ }
164
+
165
+ /**
166
+ * myCRED_Rankings class
167
+ * @see http://mycred.me/features/mycred_rankings/
168
+ * @since 0.1
169
+ * @version 2.0
170
+ */
171
+ if ( !class_exists( 'myCRED_Rankings' ) ) {
172
+ class myCRED_Rankings {
173
+
174
+ public $core;
175
+ public $args;
176
+ public $result;
177
+
178
+ /**
179
+ * Constructor
180
+ */
181
+ public function __construct( $args = array(), $results = array() ) {
182
+ // Get settings
183
+ $mycred = mycred_get_settings();
184
+ $this->core = $mycred;
185
+ $this->args = $args;
186
+ $this->result = $results;
187
+ }
188
 
189
  /**
190
  * Have Results
191
  * @returns true or false
192
  * @since 0.1
193
+ * @version 1.1
194
  */
195
  public function have_results() {
196
+ if ( !empty( $this->result ) ) return true;
197
  return false;
198
  }
199
 
202
  * @param $user_id (int) required user id
203
  * @returns position (int)
204
  * @since 0.1
205
+ * @version 1.1
206
  */
207
+ public function users_position( $user_id = NULL ) {
208
+ if ( $user_id !== NULL ) {
209
+ if ( $this->have_results() ) {
210
+ foreach ( $this->result as $row_id => $row_data ) {
211
+ if ( !isset( $row_data['ID'] ) ) $row_uid = $row_data['user_id'];
212
+ else $row_uid = $row_data['ID'];
213
+
214
+ if ( $row_uid == (int) $user_id ) return $row_id+1;
215
+ }
216
  }
217
  }
218
+
219
+ return 0;
220
  }
221
 
222
  /**
224
  * @param $user_id (int) user id
225
  * @returns position (int) or empty
226
  * @since 0.1
227
+ * @version 1.1
228
  */
229
  public function users_creds( $user_id = NULL ) {
230
+ if ( $user_id !== NULL ) {
231
+ if ( $this->have_results() ) {
232
+ foreach ( $this->result as $row_id => $row_data ) {
233
+ if ( !isset( $row_data['ID'] ) ) $row_uid = $row_data['user_id'];
234
+ else $row_uid = $row_data['ID'];
235
+
236
+ if ( $row_uid == (int) $user_id ) return $row_data['creds'];
237
+ }
238
  }
239
  }
240
+
241
+ return 0;
242
  }
243
 
244
  /**
245
+ * Leaderboard
246
  * @since 0.1
247
  * @version 1.0
248
  */
249
+ public function leaderboard() {
250
+ echo $this->get_leaderboard();
251
  }
252
 
253
  /**
254
+ * Get Leaderboard
 
 
255
  * @since 0.1
256
+ * @version 1.2
257
  */
258
+ public function get_leaderboard() {
259
  // Default template
260
  if ( empty( $this->args['template'] ) ) $this->args['template'] = '#%ranking% %user_profile_link% %cred_f%';
261
 
263
  $output = '<ol class="myCRED-leaderboard">';
264
 
265
  // Loop
266
+ foreach ( $this->result as $position => $row ) {
267
  // Prep
268
  $class = array();
 
269
 
270
  // Classes
271
  $class[] = 'item-' . $position;
276
  $class[] = 'alt';
277
 
278
  // Template Tags
279
+ if ( !function_exists( 'mycred_get_users_rank' ) )
280
+ $layout = str_replace( array( '%rank%', '%ranking%' ), $position+1, $this->args['template'] );
281
+ else
282
+ $layout = str_replace( '%ranking%', $position+1, $this->args['template'] );
283
 
284
+ $layout = $this->core->template_tags_amount( $layout, $row['cred'] );
285
+ $layout = $this->core->template_tags_user( $layout, false, $row );
286
 
287
+ $layout = apply_filters( 'mycred_ranking_row', $layout, $this->args['template'], $row, $position+1 );
288
  $output .= '<li class="' . implode( ' ', $class ) . '">' . $layout . '</li>';
289
  }
290
 
300
  * Returns the myCRED_Rankings object containing results.
301
  *
302
  * @param $args (array) optional array of arguments for the ranking
303
+ * @var number (int) number of results to return
304
+ * @var order (string) ASC to return with lowest creds or DESC to return highest creds first
305
+ * @var user_fields (string) comma seperated list of table columns to return with each user.
306
+ * @var offset (int) optional number to start from when returning records. defaults to zero (first result)
307
+ * @var type (string) optional points type
308
+ * @var template (string) if this function is called to create a leaderboard this string can contain the template
309
+ * for each user
310
+ * @uses myCRED_Query_Rankings()
311
+ * @uses myCRED_Rankings()
312
  * @returns class object
313
  * @since 0.1
314
+ * @version 2.0
315
  */
316
  if ( !function_exists( 'mycred_rankings' ) ) {
317
+ function mycred_rankings( $args = array(), $reset = false )
318
  {
319
+ $default = array(
320
+ 'number' => '-1',
321
+ 'order' => 'DESC',
322
+ 'user_fields' => 'user_login,display_name,user_email,user_nicename,user_url',
323
+ 'offset' => 0,
324
+ 'type' => 'mycred_default',
325
+ 'template' => '#%ranking% %user_profile_link% %cred_f%'
326
+ );
327
+ $args = shortcode_atts( $default, $args );
328
+ $diff = array_diff( $args, $default );
329
+
330
  global $mycred_rankings;
331
+
332
+ $_rankings = get_transient( $args['type'] . '_ranking' );
333
+ // Transient is missing or request for reset
334
+ if ( false === $_rankings || true === $reset ) {
335
+ $ranking = new myCRED_Query_Rankings( array( 'type' => $args['type'] ) );
336
+ $ranking->get_rankings();
337
+ $ranking->save( $reset );
338
+
339
+ $_rankings = $ranking->result;
340
+ }
341
+ // Else if arguments are not the default and a new query is required
342
+ elseif ( !empty( $diff ) ) {
343
+ $ranking = new myCRED_Query_Rankings( $args );
344
+ $ranking->get_rankings();
345
+
346
+ $_rankings = $ranking->result;
347
  }
348
+ $mycred_rankings = new myCRED_Rankings( $args, $_rankings );
349
+
350
  return $mycred_rankings;
351
  }
352
  }
356
  * Returns a given users position in the ranking list.
357
  *
358
  * @param $user_id (int) required user id
359
+ * @param $type (string) optional points type
360
  * @returns position (int) or empty if no record could be made
361
  * @since 0.1
362
+ * @version 1.1
363
  */
364
  if ( !function_exists( 'mycred_rankings_position' ) ) {
365
+ function mycred_rankings_position( $user_id = '', $type = 'mycred_default' )
366
  {
367
+ $rankings = mycred_rankings( array( 'type' => $type ) );
368
+ return $rankings->users_position( $user_id );
 
 
 
 
 
369
  }
370
  }
371
 
372
  /**
373
  * Force Leaderboard Update
374
  * @since 1.0.9.1
375
+ * @version 1.1
376
  */
377
  add_action( 'delete_user', 'mycred_adjust_ranking_delete_user' );
378
  function mycred_adjust_ranking_delete_user( $user_id )
379
  {
380
+ $ranking = new myCRED_Query_Rankings();
381
+ $ranking->get_rankings();
382
+ $ranking->save( true );
383
  }
384
  ?>
includes/mycred-shortcodes.php CHANGED
@@ -52,35 +52,40 @@ if ( !function_exists( 'mycred_render_shortcode_my_balance' ) ) {
52
  /**
53
  * myCRED Shortcode: mycred_leaderboard
54
  * @since 0.1
55
- * @version 1.0
56
  */
57
  if ( !function_exists( 'mycred_render_leaderboard' ) ) {
58
  function mycred_render_leaderboard( $atts, $content = NULL )
59
  {
60
  $attr = shortcode_atts( array(
61
  'number' => '-1',
62
- 'offset' => 0,
63
  'order' => 'DESC',
64
- 'template' => '',
65
- 'type' => '',
 
 
66
  'nothing' => __( 'Leaderboard is empty.', 'mycred' )
67
  ), $atts );
68
 
69
  // Template can also be passed though the content
70
- if ( empty( $attr['template'] ) && $content !== NULL )
71
  $attr['template'] = do_shortcode( $content );
72
 
73
- // Points type
74
- if ( !empty( $attr['type'] ) ) {
75
- $attr['meta_key'] = $attr['type'];
76
- unset( $attr['type'] );
77
- }
78
-
79
- $rankings = mycred_rankings( $attr );
80
 
81
  // Have results
82
- if ( $rankings->have_results() )
83
- return $rankings->get_display();
 
 
 
 
 
 
84
 
85
  // No result template is set
86
  if ( !empty( $attr['nothing'] ) )
@@ -153,7 +158,7 @@ if ( !function_exists( 'mycred_render_shortcode_give' ) ) {
153
 
154
  $amount = $mycred->number( $amount );
155
  $mycred->add_creds(
156
- $reference,
157
  $user_id,
158
  $amount,
159
  $log,
52
  /**
53
  * myCRED Shortcode: mycred_leaderboard
54
  * @since 0.1
55
+ * @version 1.2
56
  */
57
  if ( !function_exists( 'mycred_render_leaderboard' ) ) {
58
  function mycred_render_leaderboard( $atts, $content = NULL )
59
  {
60
  $attr = shortcode_atts( array(
61
  'number' => '-1',
 
62
  'order' => 'DESC',
63
+ 'offset' => 0,
64
+ 'type' => 'mycred_default',
65
+ 'wrap' => 'li',
66
+ 'template' => '#%ranking% %user_profile_link% %cred_f%',
67
  'nothing' => __( 'Leaderboard is empty.', 'mycred' )
68
  ), $atts );
69
 
70
  // Template can also be passed though the content
71
+ if ( empty( $attr['template'] ) || $content !== NULL )
72
  $attr['template'] = do_shortcode( $content );
73
 
74
+ $_attr = $attr;
75
+ $_attr['user_fields'] = 'user_login,display_name,user_email,user_nicename,user_url';
76
+ unset( $_attr['wrap'] );
77
+ unset( $_attr['nothing'] );
78
+ $rankings = mycred_rankings( $_attr );
 
 
79
 
80
  // Have results
81
+ if ( $rankings->have_results() ) {
82
+ // Default organized list
83
+ if ( $attr['wrap'] == 'li' )
84
+ return $rankings->get_leaderboard();
85
+ // Just the loop for custom header and footer
86
+ else
87
+ return $rankings->loop( $attr['wrap'] );
88
+ }
89
 
90
  // No result template is set
91
  if ( !empty( $attr['nothing'] ) )
158
 
159
  $amount = $mycred->number( $amount );
160
  $mycred->add_creds(
161
+ $ref,
162
  $user_id,
163
  $amount,
164
  $log,
includes/mycred-widgets.php CHANGED
@@ -257,7 +257,11 @@ if ( !class_exists( 'myCRED_Widget_Balance' ) ) {
257
 
258
  $instance['show_rank'] = (bool) $new_instance['show_rank'];
259
  $rank_format = trim( $new_instance['rank_format'] );
260
- $instance['rank_format'] = str_replace( '%rank%', '%ranking%', $rank_format );
 
 
 
 
261
 
262
  $instance['show_history'] = (bool) $new_instance['show_history'];
263
  $instance['history_title'] = trim( $new_instance['history_title'] );
@@ -333,7 +337,7 @@ if ( !class_exists( 'myCRED_Widget_List' ) ) {
333
  }
334
 
335
  // Result
336
- $rankings->display();
337
 
338
  // Footer
339
  echo $after_widget;
257
 
258
  $instance['show_rank'] = (bool) $new_instance['show_rank'];
259
  $rank_format = trim( $new_instance['rank_format'] );
260
+
261
+ if ( !function_exists( 'mycred_get_users_rank' ) )
262
+ $instance['rank_format'] = str_replace( '%rank%', '%ranking%', $rank_format );
263
+ else
264
+ $instance['rank_format'] = $rank_format;
265
 
266
  $instance['show_history'] = (bool) $new_instance['show_history'];
267
  $instance['history_title'] = trim( $new_instance['history_title'] );
337
  }
338
 
339
  // Result
340
+ $rankings->leaderboard();
341
 
342
  // Footer
343
  echo $after_widget;
modules/mycred-module-general.php CHANGED
@@ -48,6 +48,7 @@ if ( !class_exists( 'myCRED_General' ) ) {
48
  <div id="mycred-social">
49
  <a href="https://www.facebook.com/myCRED" class="zocial facebook" target="_blank">Facebook</a>
50
  <a href="https://plus.google.com/b/102981932999764129220/102981932999764129220/posts" class="zocial googleplus" target="_blank">Google Plus</a>
 
51
  </div>
52
  <form method="post" action="options.php">
53
  <?php settings_fields( 'myCRED-general' ); ?>
48
  <div id="mycred-social">
49
  <a href="https://www.facebook.com/myCRED" class="zocial facebook" target="_blank">Facebook</a>
50
  <a href="https://plus.google.com/b/102981932999764129220/102981932999764129220/posts" class="zocial googleplus" target="_blank">Google Plus</a>
51
+ <a href="http://wordpress.org/support/plugin/mycred" class="zocial wordpress" target="_blank">Support Forum</a>
52
  </div>
53
  <form method="post" action="options.php">
54
  <?php settings_fields( 'myCRED-general' ); ?>
modules/mycred-module-hooks.php CHANGED
@@ -7,7 +7,7 @@ require_once( myCRED_MODULES_DIR . 'mycred-module-plugins.php' );
7
  /**
8
  * myCRED_Hooks class
9
  * @since 0.1
10
- * @version 1.0
11
  */
12
  if ( !class_exists( 'myCRED_Hooks' ) ) {
13
  class myCRED_Hooks extends myCRED_Module {
@@ -54,7 +54,7 @@ if ( !class_exists( 'myCRED_Hooks' ) ) {
54
  * Call
55
  * Either runs a given class method or function.
56
  * @since 0.1
57
- * @version 1.0
58
  */
59
  public function call( $call, $callback, $return = NULL ) {
60
  // Class
@@ -262,7 +262,7 @@ if ( !class_exists( 'myCRED_Hooks' ) ) {
262
  /**
263
  * Sanititze Settings
264
  * @since 0.1
265
- * @version 1.0
266
  */
267
  public function sanitize_settings( $post ) {
268
  // Loop though all installed hooks
@@ -270,6 +270,7 @@ if ( !class_exists( 'myCRED_Hooks' ) ) {
270
 
271
  // Construct new settings
272
  $new_post['installed'] = $installed;
 
273
  $new_post['active'] = $post['active'];
274
 
275
  if ( !empty( $installed ) ) {
@@ -408,9 +409,15 @@ if ( !class_exists( 'myCRED_Hook_Logging_In' ) ) {
408
  /**
409
  * Login Hook
410
  * @since 0.1
411
- * @version 1.1
412
  */
413
- public function logging_in( $user_login, $user ) {
 
 
 
 
 
 
414
  // Check for exclusion
415
  if ( $this->core->exclude_user( $user->ID ) === true ) return;
416
 
@@ -725,154 +732,134 @@ if ( !class_exists( 'myCRED_Hook_Comments' ) ) {
725
  /**
726
  * Run
727
  * @since 0.1
728
- * @version 1.0
729
  */
730
  public function run() {
731
- add_action( 'comment_post', array( $this, 'new_comment' ), 10, 2 );
732
-
733
- if ( $this->prefs['approved'] != 0 ) {
734
- add_action( 'comment_unapproved_to_approved', array( $this, 'approved_comments' ) );
735
- add_action( 'comment_trash_to_approved', array( $this, 'approved_comments' ) );
736
- add_action( 'comment_spam_to_approved', array( $this, 'approved_comments' ) );
737
- }
738
-
739
- if ( $this->prefs['spam'] != 0 ) {
740
- add_action( 'comment_approved_to_spam', array( $this, 'spam_comments' ) );
741
- add_action( 'comment_unapproved_to_spam', array( $this, 'spam_comments' ) );
742
- }
743
-
744
- if ( $this->prefs['trash'] != 0 ) {
745
- add_action( 'comment_approved_to_unapproved', array( $this, 'trash_comments' ) );
746
- add_action( 'comment_approved_to_trash', array( $this, 'trash_comments' ) );
747
- add_action( 'comment_unapproved_to_trash', array( $this, 'trash_comments' ) );
748
- }
749
  }
750
-
751
  /**
752
  * New Comment
753
  * If comments are approved without moderation, we apply the corresponding method
754
  * or else we will wait till the appropriate instance.
755
  *
756
  * @since 0.1
757
- * @version 1.0
758
  */
759
  public function new_comment( $comment_id, $comment_status ) {
760
  // Marked SPAM
761
  if ( $comment_status === 'spam' && $this->prefs['spam'] != 0 )
762
- $this->spam_comments( $comment_id );
763
  // Approved comment
764
  elseif ( $comment_status == '1' && $this->prefs['approved'] != 0 )
765
- $this->approved_comments( $comment_id );
766
-
767
- // All else comments are moderated and we will award / deduct points in a different instance
768
- return;
769
  }
770
-
771
  /**
772
- * Approved Comments
773
- * Validate and execute our settings for approved comments.
774
- *
775
- * @since 0.1
776
  * @version 1.0
777
  */
778
- public function approved_comments( $comment ) {
779
  // Passing an integer instead of an object means we need to grab the comment object ourselves
780
  if ( !is_object( $comment ) )
781
  $comment = get_comment( $comment );
782
 
 
 
 
783
  // Logged out users miss out
784
  if ( $comment->user_id == 0 ) return;
785
 
786
  // Check if user should be excluded
787
  if ( $this->core->exclude_user( $comment->user_id ) === true ) return;
788
 
789
- // Make sure this is unique event
790
- if ( $this->has_entry( 'approved_comment', $comment->comment_ID, $comment->user_id ) ) return;
791
-
792
  // Check if we are allowed to comment our own comment
793
  if ( $this->prefs['limits']['self_reply'] != 0 && $comment->comment_parent != 0 ) {
794
  $parent = get_comment( $comment->comment_parent );
795
  if ( $parent->user_id == $comment->user_id ) return;
796
  }
797
 
798
- // Enforce limits
799
- if ( $this->user_exceeds_limit( $comment->user_id, $comment->comment_post_ID ) ) return;
800
 
801
- // Execute
802
- $this->core->add_creds(
803
- 'approved_comment',
804
- $comment->user_id,
805
- $this->prefs['approved']['creds'],
806
- $this->prefs['approved']['log'],
807
- $comment->comment_ID,
808
- array( 'ref_type' => 'comment' )
809
- );
810
- }
811
 
812
- /**
813
- * SPAM Comments
814
- * Validate and execute our settings for comments marked as SPAM.
815
- *
816
- * @since 0.1
817
- * @version 1.0
818
- */
819
- public function spam_comments( $comment ) {
820
- // Passing an integer instead of an object means we need to grab the comment object ourselves
821
- if ( !is_object( $comment ) )
822
- $comment = get_comment( $comment );
823
 
824
- // Logged out users miss out
825
- if ( $comment->user_id == 0 ) return;
 
826
 
827
- // Check if user should be excluded
828
- if ( $this->core->exclude_user( $comment->user_id ) === true ) return;
 
 
 
829
 
830
- // Make sure this is unique event
831
- if ( $this->has_entry( 'spam_comment', $comment->comment_ID, $comment->user_id ) ) return;
832
 
833
- // Execute
834
- $this->core->add_creds(
835
- 'spam_comment',
836
- $comment->user_id,
837
- $this->prefs['spam']['creds'],
838
- $this->prefs['spam']['log'],
839
- $comment->comment_ID,
840
- array( 'ref_type' => 'comment' )
841
- );
842
- }
 
 
843
 
844
- /**
845
- * Trashed Comments
846
- * Validate and execute our settings for trashed or unapproved comments.
847
- *
848
- * @since 0.1
849
- * @version 1.0
850
- */
851
- public function trash_comments( $comment ) {
852
- // Passing an integer instead of an object means we need to grab the comment object ourselves
853
- if ( !is_object( $comment ) )
854
- $comment = get_comment( $comment );
855
 
856
- // Logged out users miss out
857
- if ( $comment->user_id == 0 ) return;
 
 
 
 
858
 
859
- // Check if user should be excluded
860
- if ( $this->core->exclude_user( $comment->user_id ) === true ) return;
 
 
 
 
 
 
861
 
862
- // Make sure this is unique event
863
- if ( $this->has_entry( 'deleted_comment', $comment->comment_ID, $comment->user_id ) ) return;
 
 
864
 
865
  // Execute
866
  $this->core->add_creds(
867
- 'deleted_comment',
868
  $comment->user_id,
869
- $this->prefs['trash']['creds'],
870
- $this->prefs['trash']['log'],
871
  $comment->comment_ID,
872
  array( 'ref_type' => 'comment' )
873
  );
874
  }
875
-
876
  /**
877
  * Check if user exceeds limit
878
  * @since 1.1.1
@@ -1132,7 +1119,7 @@ if ( !class_exists( 'myCRED_Hook_Click_Links' ) ) {
1132
  * @since 1.1
1133
  * @version 1.0
1134
  */
1135
- public function has_entry( $action = '', $reference = '' ) {
1136
  global $wpdb;
1137
 
1138
  if ( $this->prefs['limit_by'] == 'url' ) {
7
  /**
8
  * myCRED_Hooks class
9
  * @since 0.1
10
+ * @version 1.1
11
  */
12
  if ( !class_exists( 'myCRED_Hooks' ) ) {
13
  class myCRED_Hooks extends myCRED_Module {
54
  * Call
55
  * Either runs a given class method or function.
56
  * @since 0.1
57
+ * @version 1.1
58
  */
59
  public function call( $call, $callback, $return = NULL ) {
60
  // Class
262
  /**
263
  * Sanititze Settings
264
  * @since 0.1
265
+ * @version 1.1
266
  */
267
  public function sanitize_settings( $post ) {
268
  // Loop though all installed hooks
270
 
271
  // Construct new settings
272
  $new_post['installed'] = $installed;
273
+ if ( empty( $post['active'] ) || !isset( $post['active'] ) ) $post['active'] = array();
274
  $new_post['active'] = $post['active'];
275
 
276
  if ( !empty( $installed ) ) {
409
  /**
410
  * Login Hook
411
  * @since 0.1
412
+ * @version 1.2
413
  */
414
+ public function logging_in( $user_login, $user = '' ) {
415
+ // In case the user object is not past along
416
+ if ( !is_object( $user ) ) {
417
+ $user = get_user_by( 'login', $user_login );
418
+ if ( !is_object( $user ) ) return;
419
+ }
420
+
421
  // Check for exclusion
422
  if ( $this->core->exclude_user( $user->ID ) === true ) return;
423
 
732
  /**
733
  * Run
734
  * @since 0.1
735
+ * @version 1.1
736
  */
737
  public function run() {
738
+ add_action( 'comment_post', array( $this, 'new_comment' ), 10, 2 );
739
+ add_action( 'transition_comment_status', array( $this, 'comment_transitions' ), 10, 3 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
740
  }
741
+
742
  /**
743
  * New Comment
744
  * If comments are approved without moderation, we apply the corresponding method
745
  * or else we will wait till the appropriate instance.
746
  *
747
  * @since 0.1
748
+ * @version 1.1
749
  */
750
  public function new_comment( $comment_id, $comment_status ) {
751
  // Marked SPAM
752
  if ( $comment_status === 'spam' && $this->prefs['spam'] != 0 )
753
+ $this->comment_transitions( 'spam', 'unapproved', $comment_id );
754
  // Approved comment
755
  elseif ( $comment_status == '1' && $this->prefs['approved'] != 0 )
756
+ $this->comment_transitions( 'approved', 'unapproved', $comment_id );
 
 
 
757
  }
758
+
759
  /**
760
+ * Comment Transitions
761
+ * @since 1.1.2
 
 
762
  * @version 1.0
763
  */
764
+ public function comment_transitions( $new_status, $old_status, $comment ) {
765
  // Passing an integer instead of an object means we need to grab the comment object ourselves
766
  if ( !is_object( $comment ) )
767
  $comment = get_comment( $comment );
768
 
769
+ // Ignore Pingbacks or Trackbacks
770
+ if ( !empty( $comment->comment_type ) ) return;
771
+
772
  // Logged out users miss out
773
  if ( $comment->user_id == 0 ) return;
774
 
775
  // Check if user should be excluded
776
  if ( $this->core->exclude_user( $comment->user_id ) === true ) return;
777
 
 
 
 
778
  // Check if we are allowed to comment our own comment
779
  if ( $this->prefs['limits']['self_reply'] != 0 && $comment->comment_parent != 0 ) {
780
  $parent = get_comment( $comment->comment_parent );
781
  if ( $parent->user_id == $comment->user_id ) return;
782
  }
783
 
784
+ $reference = '';
 
785
 
786
+ // Approved comments
787
+ if ( $this->prefs['approved'] != 0 && $new_status == 'approved' ) {
788
+ // New approved comment
789
+ if ( $old_status == 'unapproved' || $old_status == 'hold' ) {
790
+ // Enforce limits
791
+ if ( $this->user_exceeds_limit( $comment->user_id, $comment->comment_post_ID ) ) return;
 
 
 
 
792
 
793
+ $reference = 'approved_comment';
794
+ $points = $this->prefs['approved']['creds'];
795
+ $log = $this->prefs['approved']['log'];
796
+ }
 
 
 
 
 
 
 
797
 
798
+ // Marked as "Not Spam"
799
+ elseif ( $this->prefs['spam'] != 0 && $old_status == 'spam' ) {
800
+ $reference = 'approved_comment';
801
 
802
+ // Reverse points
803
+ if ( $this->prefs['spam']['creds'] < 0 )
804
+ $points = abs( $this->prefs['spam']['creds'] );
805
+ else
806
+ $points = $this->prefs['spam']['creds'];
807
 
808
+ $log = $this->prefs['approved']['log'];
809
+ }
810
 
811
+ // Returned comment from trash
812
+ elseif ( $this->prefs['trash'] != 0 && $old_status == 'trash' ) {
813
+ $reference = 'approved_comment';
814
+ // Reverse points
815
+ if ( $this->prefs['trash']['creds'] < 0 )
816
+ $points = abs( $this->prefs['trash']['creds'] );
817
+ else
818
+ $points = $this->prefs['trash']['creds'];
819
+
820
+ $log = $this->prefs['approved']['log'];
821
+ }
822
+ }
823
 
824
+ // Spam comments
825
+ elseif ( $this->prefs['spam'] != 0 && $new_status == 'spam' ) {
826
+ $reference = 'spam_comment';
827
+ $points = $this->prefs['spam']['creds'];
828
+ $log = $this->prefs['spam']['log'];
829
+ }
 
 
 
 
 
830
 
831
+ // Trashed comments
832
+ elseif ( $this->prefs['trash'] != 0 && $new_status == 'trash' ) {
833
+ $reference = 'deleted_comment';
834
+ $points = $this->prefs['trash']['creds'];
835
+ $log = $this->prefs['trash']['log'];
836
+ }
837
 
838
+ // Unapproved comments
839
+ elseif ( $new_status == 'unapproved' && $old_status == 'approved' ) {
840
+ $reference = 'deleted_comment';
841
+ // Reverse points
842
+ if ( $this->prefs['approved']['creds'] < 0 )
843
+ $points = abs( $this->prefs['approved']['creds'] );
844
+ else
845
+ $points = $this->prefs['approved']['creds'];
846
 
847
+ $log = $this->prefs['trash']['log'];
848
+ }
849
+
850
+ if ( empty( $reference ) ) return;
851
 
852
  // Execute
853
  $this->core->add_creds(
854
+ $reference,
855
  $comment->user_id,
856
+ $points,
857
+ $log,
858
  $comment->comment_ID,
859
  array( 'ref_type' => 'comment' )
860
  );
861
  }
862
+
863
  /**
864
  * Check if user exceeds limit
865
  * @since 1.1.1
1119
  * @since 1.1
1120
  * @version 1.0
1121
  */
1122
+ public function has_entry( $action = '', $reference = '', $user_id = '', $data = '' ) {
1123
  global $wpdb;
1124
 
1125
  if ( $this->prefs['limit_by'] == 'url' ) {
modules/mycred-module-plugins.php CHANGED
@@ -509,7 +509,7 @@ if ( !class_exists( 'myCRED_Contact_Form7' ) && function_exists( 'wpcf7' ) ) {
509
  * Queries all Contact Form 7 forms.
510
  * @uses WP_Query()
511
  * @since 0.1
512
- * @version 1.0
513
  */
514
  public function get_forms() {
515
  $forms = new WP_Query( array(
@@ -527,6 +527,8 @@ if ( !class_exists( 'myCRED_Contact_Form7' ) && function_exists( 'wpcf7' ) ) {
527
  endwhile;
528
  }
529
  wp_reset_postdata();
 
 
530
  }
531
 
532
  /**
509
  * Queries all Contact Form 7 forms.
510
  * @uses WP_Query()
511
  * @since 0.1
512
+ * @version 1.1
513
  */
514
  public function get_forms() {
515
  $forms = new WP_Query( array(
527
  endwhile;
528
  }
529
  wp_reset_postdata();
530
+
531
+ return $result;
532
  }
533
 
534
  /**
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.1.1
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.1.1' );
17
  define( 'myCRED_SLUG', 'mycred' );
18
  define( 'myCRED_NAME', '<strong>my</strong>CRED' );
19
 
@@ -104,7 +104,7 @@ if ( !class_exists( 'myCRED_Core' ) ) {
104
  /**
105
  * Plugin Links
106
  * @since 0.1
107
- * @version 1.0
108
  */
109
  function plugin_links( $actions, $plugin_file, $plugin_data, $context ) {
110
  // Link to Setup
@@ -115,8 +115,10 @@ if ( !class_exists( 'myCRED_Core' ) ) {
115
 
116
  // Link to Settings
117
  $mycred = mycred_get_settings();
118
- if ( $mycred->can_edit_plugin() )
119
  $actions['settings'] = '<a href="' . admin_url( 'admin.php?page=myCRED_page_settings' ) . '">' . __( 'Settings', 'mycred' ) . '</a>';
 
 
120
 
121
  return $actions;
122
  }
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.1.2
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.1.2' );
17
  define( 'myCRED_SLUG', 'mycred' );
18
  define( 'myCRED_NAME', '<strong>my</strong>CRED' );
19
 
104
  /**
105
  * Plugin Links
106
  * @since 0.1
107
+ * @version 1.1
108
  */
109
  function plugin_links( $actions, $plugin_file, $plugin_data, $context ) {
110
  // Link to Setup
115
 
116
  // Link to Settings
117
  $mycred = mycred_get_settings();
118
+ if ( $mycred->can_edit_plugin() ) {
119
  $actions['settings'] = '<a href="' . admin_url( 'admin.php?page=myCRED_page_settings' ) . '">' . __( 'Settings', 'mycred' ) . '</a>';
120
+ $actions['donate'] = '<a href="http://mycred.me/donate/" target="_blank">Donate</a>';
121
+ }
122
 
123
  return $actions;
124
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate Link: http://mycred.me/donate/
4
  Tags:points, tokens, credit, management, reward, charge, community, contest, BuddyPress, Jetpack, bbPress
5
  Requires at least: 3.1
6
  Tested up to: 3.5.2
7
- Stable tag: 1.1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -128,18 +128,35 @@ Yes but if one of them is bought, all is shown. The mycred_sell_this shortcode w
128
 
129
  == Upgrade Notice ==
130
 
 
 
 
131
  = 1.1.1 =
132
- This version resolves bugs with the MarketPress add-on and third-party plugins support. You will also have access to the bbPress hooks without the need to use Buddypress.
133
 
134
- * bbPress users should visit the "Hooks" sub-menu and re-enter their hook settings as these will be reset.
135
- * Ranks Add-on users should visit the "Settings" sub-menu and confirm their Rank settings as new settings will be available.
136
 
 
 
137
 
138
  == Changelog ==
139
 
140
- **Updating to 1.1.1** Note that in this version the bbPress hook has been moved from the BuddyPress add-on to the core plugin support. This means that you you no longer require BuddyPress to access the bbPress Hook!
141
-
142
- Once you have updated to 1.1.1, visit the Hooks sub-menu page in the myCRED menu and update your bbPress settings!
 
 
 
 
 
 
 
 
 
 
 
 
143
 
144
  = 1.1.1 =
145
  * Moved the bbPress Hook from BuddyPress add-on to default plugin hooks.
4
  Tags:points, tokens, credit, management, reward, charge, community, contest, BuddyPress, Jetpack, bbPress
5
  Requires at least: 3.1
6
  Tested up to: 3.5.2
7
+ Stable tag: 1.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
128
 
129
  == Upgrade Notice ==
130
 
131
+ = 1.1.2 =
132
+ See: http://mycred.me/download/changelog/
133
+
134
  = 1.1.1 =
135
+ See: http://mycred.me/download/changelog/
136
 
137
+ = 1.1 =
138
+ See: http://mycred.me/download/changelog/
139
 
140
+ = 1.0.9.3 =
141
+ See: http://mycred.me/download/changelog/2/
142
 
143
  == Changelog ==
144
 
145
+ = 1.1.2 =
146
+ * Fixed Bug #35 - Rankings is not displaying in BuddyPress profile header.
147
+ * Fixed Bug #36 - Use of incorrect reference when calling hooks.
148
+ * Fixed Bug #37 - Transferring negative amounts deducts points from recipient.
149
+ * Fixed Bug #38 - Error message if the Transfer widget is used before the Add-on is setup.
150
+ * Adjusted Transfer Autofill to require minimum 2 characters instead of just 1.
151
+ * Improved Rankings with the new myCRED_Query_Rankings class.
152
+ * Removed support for %nickname% in user related template tags.
153
+ * Added Support Forum link to Settings page.
154
+ * Added Donate Link to Plugin Links.
155
+ * Added Ranking update when plugin is re-activated.
156
+ * Added support for custom templates for the mycred_leaderboard shortcode.
157
+ * Improved how the abstract class myCRED_Hook and myCRED_Module handles settings.
158
+ * Added new mycred_apply_defaults function.
159
+ * Improved points for comments allowing points to be awarded when comments get marked as SPAM or Trashed by mistake.
160
 
161
  = 1.1.1 =
162
  * Moved the bbPress Hook from BuddyPress add-on to default plugin hooks.