myCRED - Version 1.6.1

Version Description

FIX - Points for viewing content hook causes logged in authors not to see their own content. FIX - Google Chrome form validation issue for settings. FIX - Removed incorrect link on about page in admin area. FIX - Added "transfer" reference to ignore by central bank. When using custom references, this still has to be added by the user. FIX - Added support for multiple point types for the mycred_video shortcode. FIX - Added missing $type variable for the mycred_has_entry filter. FIX - Removed legend template for statistics add-on as the library seems to have issues handling RTL setups.

Download this release

Release Info

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

Code changes from version 1.6 to 1.6.1

abstracts/mycred-abstract-hook.php CHANGED
@@ -193,10 +193,10 @@ if ( ! class_exists( 'myCRED_Hook' ) ) {
193
  $from = $wpdb->prepare( "AND time BETWEEN %d AND %d", mktime( 0, 0, 0, date( 'n', $until ), date( 'j', $until ), date( 'Y', $until ) ), $until );
194
 
195
  elseif ( $period == 'w' )
196
- $from = $wpdb->prepare( "AND time BETWEEN %d AND %d", mktime( 0, 0, 0, date( 'n', $until ), date( 'j', $until ) - date( 'N', $until ) + 1 ), $until );
197
 
198
  elseif ( $period == 'm' )
199
- $from = $wpdb->prepare( "AND time BETWEEN %d AND %d", mktime( 0, 0, 0, date( 'n', $until ), 1, date( 'Y', $until ) ), $until );
200
 
201
  $count = $wpdb->get_var( $wpdb->prepare( "
202
  SELECT COUNT(*)
193
  $from = $wpdb->prepare( "AND time BETWEEN %d AND %d", mktime( 0, 0, 0, date( 'n', $until ), date( 'j', $until ), date( 'Y', $until ) ), $until );
194
 
195
  elseif ( $period == 'w' )
196
+ $from = $wpdb->prepare( "AND time BETWEEN %d AND %d", mktime( 0, 0, 0, date( "n", $until ), date( "j", $until ) - date( "N", $until ) + 1 ), $until );
197
 
198
  elseif ( $period == 'm' )
199
+ $from = $wpdb->prepare( "AND time BETWEEN %d AND %d", mktime( 0, 0, 0, date( "n", $until ), 1, date( 'Y', $until ) ), $until );
200
 
201
  $count = $wpdb->get_var( $wpdb->prepare( "
202
  SELECT COUNT(*)
addons/banking/services/mycred-bank-service-central.php CHANGED
@@ -37,7 +37,7 @@ if ( ! class_exists( 'myCRED_Banking_Service_Central' ) ) :
37
  /**
38
  * Add
39
  * @since 1.5.2
40
- * @version 1.0
41
  */
42
  public function mycred_add( $reply, $request, $mycred ) {
43
  // Make sure we are in the correct point type
@@ -47,7 +47,7 @@ if ( ! class_exists( 'myCRED_Banking_Service_Central' ) ) :
47
  if ( isset( $this->prefs['ignore_manual'] ) && $this->prefs['ignore_manual'] == 0 && $request['ref'] == 'manual' ) return $reply;
48
 
49
  // Instances to ignore
50
- $ignore = apply_filters( 'mycred_central_banking_ignore', array( 'interest', 'recurring_payout' ), $this );
51
  if ( in_array( $request['ref'], $ignore ) ) return $reply;
52
 
53
  extract( $request );
37
  /**
38
  * Add
39
  * @since 1.5.2
40
+ * @version 1.0.1
41
  */
42
  public function mycred_add( $reply, $request, $mycred ) {
43
  // Make sure we are in the correct point type
47
  if ( isset( $this->prefs['ignore_manual'] ) && $this->prefs['ignore_manual'] == 0 && $request['ref'] == 'manual' ) return $reply;
48
 
49
  // Instances to ignore
50
+ $ignore = apply_filters( 'mycred_central_banking_ignore', array( 'interest', 'recurring_payout', 'transfer' ), $this );
51
  if ( in_array( $request['ref'], $ignore ) ) return $reply;
52
 
53
  extract( $request );
addons/email-notices/myCRED-addon-email-notices.php CHANGED
@@ -52,7 +52,7 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) {
52
  /**
53
  * Hook into Init
54
  * @since 1.1
55
- * @version 1.2
56
  */
57
  public function module_init() {
58
  $this->register_post_type();
@@ -68,10 +68,10 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) {
68
  if ( ! isset( $this->emailnotices['send'] ) ) return;
69
 
70
  if ( $this->emailnotices['send'] == 'hourly' && wp_next_scheduled( 'mycred_send_email_notices' ) === false )
71
- wp_schedule_event( date_i18n( 'U' ), 'hourly', 'mycred_send_email_notices' );
72
 
73
  elseif ( $this->emailnotices['send'] == 'daily' && wp_next_scheduled( 'mycred_send_email_notices' ) === false )
74
- wp_schedule_event( date_i18n( 'U' ), 'daily', 'mycred_send_email_notices' );
75
 
76
  elseif ( $this->emailnotices['send'] == '' && wp_next_scheduled( 'mycred_send_email_notices' ) !== false )
77
  wp_clear_scheduled_hook( 'mycred_send_email_notices' );
52
  /**
53
  * Hook into Init
54
  * @since 1.1
55
+ * @version 1.2.1
56
  */
57
  public function module_init() {
58
  $this->register_post_type();
68
  if ( ! isset( $this->emailnotices['send'] ) ) return;
69
 
70
  if ( $this->emailnotices['send'] == 'hourly' && wp_next_scheduled( 'mycred_send_email_notices' ) === false )
71
+ wp_schedule_event( time(), 'hourly', 'mycred_send_email_notices' );
72
 
73
  elseif ( $this->emailnotices['send'] == 'daily' && wp_next_scheduled( 'mycred_send_email_notices' ) === false )
74
+ wp_schedule_event( time(), 'daily', 'mycred_send_email_notices' );
75
 
76
  elseif ( $this->emailnotices['send'] == '' && wp_next_scheduled( 'mycred_send_email_notices' ) !== false )
77
  wp_clear_scheduled_hook( 'mycred_send_email_notices' );
addons/ranks/myCRED-addon-ranks.php CHANGED
@@ -221,13 +221,13 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) {
221
  /**
222
  * Parent File
223
  * @since 1.6
224
- * @version 1.0
225
  */
226
  public function parent_file( $parent = '' ) {
227
 
228
  global $pagenow;
229
 
230
- if ( $pagenow == 'edit.php' || $pagenow == 'post-new.php' ) {
231
 
232
  if ( isset( $_GET['ctype'] ) && $_GET['ctype'] != 'mycred_default' )
233
  return 'myCRED_' . $_GET['ctype'];
@@ -683,7 +683,7 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) {
683
  * Parse Rank
684
  * Parses the %rank% and %rank_logo% template tags.
685
  * @since 1.1
686
- * @version 1.2
687
  */
688
  public function parse_rank( $content, $user = '', $data = '' ) {
689
 
@@ -709,7 +709,7 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) {
709
 
710
  // Loop the point types and replace template tags
711
  foreach ( $this->point_types as $type_id => $label ) {
712
- $rank_id = mycred_get_users_rank_id( $user_id, $type_id );
713
  if ( $rank_id === NULL ) {
714
  if ( $type_id == 'mycred_default' ) {
715
  $content = str_replace( '%rank%', '', $content );
221
  /**
222
  * Parent File
223
  * @since 1.6
224
+ * @version 1.0.1
225
  */
226
  public function parent_file( $parent = '' ) {
227
 
228
  global $pagenow;
229
 
230
+ if ( ( $pagenow == 'edit.php' || $pagenow == 'post-new.php' ) && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'mycred_rank' ) {
231
 
232
  if ( isset( $_GET['ctype'] ) && $_GET['ctype'] != 'mycred_default' )
233
  return 'myCRED_' . $_GET['ctype'];
683
  * Parse Rank
684
  * Parses the %rank% and %rank_logo% template tags.
685
  * @since 1.1
686
+ * @version 1.2.1
687
  */
688
  public function parse_rank( $content, $user = '', $data = '' ) {
689
 
709
 
710
  // Loop the point types and replace template tags
711
  foreach ( $this->point_types as $type_id => $label ) {
712
+ $rank_id = mycred_get_users_rank_id( $user->ID, $type_id );
713
  if ( $rank_id === NULL ) {
714
  if ( $type_id == 'mycred_default' ) {
715
  $content = str_replace( '%rank%', '', $content );
addons/stats/widgets/mycred-stats-widget-daily-gains.php CHANGED
@@ -187,15 +187,7 @@ jQuery(function($) {
187
  },{
188
  bezierCurve: false,
189
  responsive: true,
190
- maintainAspectRatio: false,
191
- legendTemplate : '<ul>'
192
- +'<% for (var i=0; i<datasets.length; i++) { %>'
193
- +'<li>'
194
- +'<span style=\"background-color:<%=datasets[i].fillColor%>\"></span>'
195
- +'<% if (datasets[i].label) { %><%= datasets[i].label %><% } %>'
196
- +'</li>'
197
- +'<% } %>'
198
- +'</ul>'
199
  });
200
 
201
  var <?php echo $this->id; ?>legend = <?php echo $this->id; ?>chart.generateLegend();
187
  },{
188
  bezierCurve: false,
189
  responsive: true,
190
+ maintainAspectRatio: false
 
 
 
 
 
 
 
 
191
  });
192
 
193
  var <?php echo $this->id; ?>legend = <?php echo $this->id; ?>chart.generateLegend();
addons/stats/widgets/mycred-stats-widget-daily-loses.php CHANGED
@@ -187,15 +187,7 @@ jQuery(function($) {
187
  },{
188
  bezierCurve: false,
189
  responsive: true,
190
- maintainAspectRatio: false,
191
- legendTemplate : '<ul>'
192
- +'<% for (var i=0; i<datasets.length; i++) { %>'
193
- +'<li>'
194
- +'<span style=\"background-color:<%=datasets[i].fillColor%>\"></span>'
195
- +'<% if (datasets[i].label) { %><%= datasets[i].label %><% } %>'
196
- +'</li>'
197
- +'<% } %>'
198
- +'</ul>'
199
  });
200
 
201
  var <?php echo $this->id; ?>legend = <?php echo $this->id; ?>chart.generateLegend();
187
  },{
188
  bezierCurve: false,
189
  responsive: true,
190
+ maintainAspectRatio: false
 
 
 
 
 
 
 
 
191
  });
192
 
193
  var <?php echo $this->id; ?>legend = <?php echo $this->id; ?>chart.generateLegend();
addons/transfer/includes/mycred-transfer-shortcodes.php CHANGED
@@ -9,7 +9,7 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
9
  * @attribute $show_balance (bool) set to true to show current users balance, defaults to true
10
  * @attribute $show_limit (bool) set to true to show current users limit. If limit is set to 'none' and $show_limit is set to true nothing will be returned
11
  * @since 0.1
12
- * @version 1.4.2
13
  */
14
  if ( ! function_exists( 'mycred_transfer_render' ) ) :
15
  function mycred_transfer_render( $atts, $content = NULL ) {
@@ -152,7 +152,13 @@ if ( ! function_exists( 'mycred_transfer_render' ) ) :
152
 
153
  }
154
 
155
- if ( count( $clean ) == 1 && array_key_exists( 'mycred_default', $clean ) ) {
 
 
 
 
 
 
156
 
157
  if ( ! empty( $mycred->before ) )
158
  $before = $mycred->before . ' ';
9
  * @attribute $show_balance (bool) set to true to show current users balance, defaults to true
10
  * @attribute $show_limit (bool) set to true to show current users limit. If limit is set to 'none' and $show_limit is set to true nothing will be returned
11
  * @since 0.1
12
+ * @version 1.4.3
13
  */
14
  if ( ! function_exists( 'mycred_transfer_render' ) ) :
15
  function mycred_transfer_render( $atts, $content = NULL ) {
152
 
153
  }
154
 
155
+ // If we only use one type, we might as well reload the myCRED_Settings object
156
+ // since formating might differ
157
+ if ( count( $clean ) == 1 )
158
+ $mycred = mycred( $clean[0] );
159
+
160
+ // Only use prefix / suffix if we have 1 type.
161
+ if ( count( $clean ) == 1 ) {
162
 
163
  if ( ! empty( $mycred->before ) )
164
  $before = $mycred->before . ' ';
assets/js/video.js CHANGED
@@ -16,9 +16,9 @@ var done = {};
16
  /**
17
  * View Handler
18
  * @since 1.2
19
- * @version 1.0
20
  */
21
- function mycred_view_video( id, state, custom_logic, custom_interval, key ) {
22
 
23
  var videoid = id;
24
 
@@ -49,7 +49,7 @@ function mycred_view_video( id, state, custom_logic, custom_interval, key ) {
49
  if ( logic[ id ] == 'play' ) {
50
  // As soon as we start playing we award points
51
  if ( videostate == 1 && done[ id ] === undefined )
52
- mycred_video_call( videoid, key, videostate, '', '' );
53
  }
54
 
55
  // Points first when video has ended
@@ -71,7 +71,7 @@ function mycred_view_video( id, state, custom_logic, custom_interval, key ) {
71
  clearInterval( timer );
72
 
73
  // Notify myCRED
74
- mycred_video_call( videoid, key, videostate, actions[ videoid ], seconds[ videoid ] );
75
 
76
  // Reset
77
  seconds[ id ] = 0;
@@ -97,14 +97,14 @@ function mycred_view_video( id, state, custom_logic, custom_interval, key ) {
97
  var laps = parseInt( interval[ id ] / 1000, 10 );
98
  seconds[ id ] = seconds[ id ] + laps;
99
  // key, state, id, actions, seconds, duration
100
- mycred_video_call( videoid, key, videostate, actions[ videoid ], seconds[ videoid ] );
101
  }, interval[ id ] );
102
  }
103
 
104
  // Video has ended
105
  else if ( state == 0 ) {
106
  clearInterval( timer );
107
- mycred_video_call( videoid, key, videostate, actions[ videoid ], seconds[ videoid ] );
108
 
109
  seconds[ id ] = 0;
110
  actions[ id ] = '';
@@ -116,26 +116,17 @@ function mycred_view_video( id, state, custom_logic, custom_interval, key ) {
116
  clearInterval( timer );
117
  }
118
  }
119
- else {
120
- //console.log( 'Unknown logic request: ' + logic[ id ] );
121
- }
122
- }
123
- else {
124
- //console.log( 'State: ' + videostate );
125
  }
126
  }
127
 
128
  /**
129
  * AJAX call handler
130
  * @since 1.2
131
- * @version 1.0
132
  */
133
- function mycred_video_call( id, key, state, actions, seconds ) {
134
-
135
- //console.log( 'Incoming AJAX request' );
136
 
137
  if ( done[ id ] === undefined ) {
138
- //console.log( 'Connecting' );
139
 
140
  if ( duration[ id ] === undefined )
141
  duration[ id ] = 0;
@@ -149,27 +140,20 @@ function mycred_video_call( id, key, state, actions, seconds ) {
149
  video_a : actions,
150
  video_b : seconds,
151
  video_c : duration[ id ],
152
- video_d : state
 
153
  },
154
  dataType : "JSON",
155
  url : myCRED_Video.ajaxurl,
156
- // Before we start
157
- beforeSend : function() {},
158
- // On Successful Communication
159
  success : function( data ) {
 
160
  console.log( data );
161
 
162
  // Add to done list
163
  if ( data.status === 'max' )
164
  done[ id ] = data.amount;
165
- },
166
- // Error (sent to console)
167
- error : function( jqXHR, textStatus, errorThrown ) {
168
- console.log( jqXHR+':'+textStatus+':'+errorThrown );
169
  }
170
  });
171
  }
172
- else {
173
- //console.log( 'Video marked as done!' );
174
- }
175
  }
16
  /**
17
  * View Handler
18
  * @since 1.2
19
+ * @version 1.1
20
  */
21
+ function mycred_view_video( id, state, custom_logic, custom_interval, key, ctype ) {
22
 
23
  var videoid = id;
24
 
49
  if ( logic[ id ] == 'play' ) {
50
  // As soon as we start playing we award points
51
  if ( videostate == 1 && done[ id ] === undefined )
52
+ mycred_video_call( videoid, key, videostate, '', '', ctype );
53
  }
54
 
55
  // Points first when video has ended
71
  clearInterval( timer );
72
 
73
  // Notify myCRED
74
+ mycred_video_call( videoid, key, videostate, actions[ videoid ], seconds[ videoid ], ctype );
75
 
76
  // Reset
77
  seconds[ id ] = 0;
97
  var laps = parseInt( interval[ id ] / 1000, 10 );
98
  seconds[ id ] = seconds[ id ] + laps;
99
  // key, state, id, actions, seconds, duration
100
+ mycred_video_call( videoid, key, videostate, actions[ videoid ], seconds[ videoid ], ctype );
101
  }, interval[ id ] );
102
  }
103
 
104
  // Video has ended
105
  else if ( state == 0 ) {
106
  clearInterval( timer );
107
+ mycred_video_call( videoid, key, videostate, actions[ videoid ], seconds[ videoid ], ctype );
108
 
109
  seconds[ id ] = 0;
110
  actions[ id ] = '';
116
  clearInterval( timer );
117
  }
118
  }
 
 
 
 
 
 
119
  }
120
  }
121
 
122
  /**
123
  * AJAX call handler
124
  * @since 1.2
125
+ * @version 1.1
126
  */
127
+ function mycred_video_call( id, key, state, actions, seconds, pointtype ) {
 
 
128
 
129
  if ( done[ id ] === undefined ) {
 
130
 
131
  if ( duration[ id ] === undefined )
132
  duration[ id ] = 0;
140
  video_a : actions,
141
  video_b : seconds,
142
  video_c : duration[ id ],
143
+ video_d : state,
144
+ type : pointtype
145
  },
146
  dataType : "JSON",
147
  url : myCRED_Video.ajaxurl,
 
 
 
148
  success : function( data ) {
149
+
150
  console.log( data );
151
 
152
  // Add to done list
153
  if ( data.status === 'max' )
154
  done[ id ] = data.amount;
155
+
 
 
 
156
  }
157
  });
158
  }
 
 
 
159
  }
includes/mycred-about.php CHANGED
@@ -100,7 +100,7 @@ function mycred_about_page() {
100
  <h3>Added Support</h3>
101
  <div class="feature-section col two-col">
102
  <div>
103
- <h4><a href="https://wordpress.org/plugins/share-this/" target="_blank">AffiliateWP</a></h4>
104
  <p>Award points for affiliates referring visitors or store sales. You can also select to use points as your affiliate currency!</p>
105
  </div>
106
  <div class="last-feature">
100
  <h3>Added Support</h3>
101
  <div class="feature-section col two-col">
102
  <div>
103
+ <h4>AffiliateWP</h4>
104
  <p>Award points for affiliates referring visitors or store sales. You can also select to use points as your affiliate currency!</p>
105
  </div>
106
  <div class="last-feature">
includes/mycred-functions.php CHANGED
@@ -1081,7 +1081,7 @@ if ( ! class_exists( 'myCRED_Settings' ) ) :
1081
  * @param $user_id (int) optional user id
1082
  * @param $data (array|string) option data to search
1083
  * @since 0.1
1084
- * @version 1.3
1085
  */
1086
  function has_entry( $reference = '', $ref_id = '', $user_id = '', $data = '', $type = '' ) {
1087
  global $wpdb;
@@ -1123,7 +1123,7 @@ if ( ! class_exists( 'myCRED_Settings' ) ) :
1123
  $has = true;
1124
  }
1125
 
1126
- return apply_filters( 'mycred_has_entry', $has, $reference, $ref_id, $user_id, $data );
1127
  }
1128
  }
1129
  endif;
1081
  * @param $user_id (int) optional user id
1082
  * @param $data (array|string) option data to search
1083
  * @since 0.1
1084
+ * @version 1.3.1
1085
  */
1086
  function has_entry( $reference = '', $ref_id = '', $user_id = '', $data = '', $type = '' ) {
1087
  global $wpdb;
1123
  $has = true;
1124
  }
1125
 
1126
+ return apply_filters( 'mycred_has_entry', $has, $reference, $ref_id, $user_id, $data, $type );
1127
  }
1128
  }
1129
  endif;
includes/mycred-install.php CHANGED
@@ -8,7 +8,7 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
8
  * @since 0.1
9
  * @version 1.1.1
10
  */
11
- if ( ! class_exists( 'myCRED_Install' ) ) {
12
  class myCRED_Install {
13
 
14
  public $core;
@@ -117,7 +117,7 @@ if ( ! class_exists( 'myCRED_Install' ) ) {
117
  * settings and data once the core is gone.
118
  * @filter 'mycred_uninstall_this'
119
  * @since 0.1
120
- * @version 1.4.1
121
  */
122
  public function uninstall() {
123
  // Everyone should use this filter to delete everything else they have created before returning the option ids.
@@ -160,6 +160,7 @@ if ( ! class_exists( 'myCRED_Install' ) ) {
160
  wp_clear_scheduled_hook( 'mycred_banking_do_compound_batch' );
161
  wp_clear_scheduled_hook( 'mycred_banking_interest_payout' );
162
  wp_clear_scheduled_hook( 'mycred_banking_interest_do_batch' );
 
163
 
164
  global $wpdb;
165
 
@@ -184,10 +185,14 @@ if ( ! class_exists( 'myCRED_Install' ) ) {
184
  delete_site_option( 'mycred_network' );
185
 
186
  // Delete custom post types
187
- $post_types = apply_filters( 'mycred_custom_post_types', array( 'mycred_rank', 'mycred_email_notice', 'mycred_badge' ) );
188
  if ( is_array( $post_types ) || ! empty( $post_types ) )
189
  $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ('" . implode( "','", $post_types ) . "');" );
190
-
 
 
 
 
191
  // Delete all point type balances and settings
192
  $mycred_types = mycred_get_types();
193
  foreach ( $mycred_types as $type => $label ) {
@@ -196,10 +201,17 @@ if ( ! class_exists( 'myCRED_Install' ) ) {
196
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s;", $type . '_total' ) );
197
  }
198
 
 
 
 
 
 
 
199
  // Good bye.
200
  }
201
  }
202
- }
 
203
  /**
204
  * myCRED_Setup class
205
  *
@@ -208,7 +220,7 @@ if ( ! class_exists( 'myCRED_Install' ) ) {
208
  * @since 0.1
209
  * @version 1.0
210
  */
211
- if ( ! class_exists( 'myCRED_Setup' ) ) {
212
  class myCRED_Setup {
213
 
214
  public $step;
@@ -616,5 +628,6 @@ if ( ! class_exists( 'myCRED_Setup' ) ) {
616
  <?php
617
  }
618
  }
619
- }
 
620
  ?>
8
  * @since 0.1
9
  * @version 1.1.1
10
  */
11
+ if ( ! class_exists( 'myCRED_Install' ) ) :
12
  class myCRED_Install {
13
 
14
  public $core;
117
  * settings and data once the core is gone.
118
  * @filter 'mycred_uninstall_this'
119
  * @since 0.1
120
+ * @version 1.4.2
121
  */
122
  public function uninstall() {
123
  // Everyone should use this filter to delete everything else they have created before returning the option ids.
160
  wp_clear_scheduled_hook( 'mycred_banking_do_compound_batch' );
161
  wp_clear_scheduled_hook( 'mycred_banking_interest_payout' );
162
  wp_clear_scheduled_hook( 'mycred_banking_interest_do_batch' );
163
+ wp_clear_scheduled_hook( 'mycred_send_email_notices' );
164
 
165
  global $wpdb;
166
 
185
  delete_site_option( 'mycred_network' );
186
 
187
  // Delete custom post types
188
+ $post_types = array( 'mycred_rank', 'mycred_email_notice', 'mycred_badge', 'buycred_payment' );
189
  if ( is_array( $post_types ) || ! empty( $post_types ) )
190
  $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ('" . implode( "','", $post_types ) . "');" );
191
+
192
+ // Delete custom post type meta
193
+ $post_meta = array( 'myCRED_sell_content', 'mycred_rank_min', 'mycred_rank_max', 'badge_requirements', 'mycred_email_instance', 'mycred_email_settings', 'mycred_email_ctype', 'mycred_email_styling', 'ctype' );
194
+ $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key IN ('" . implode( "','", $post_meta ) . "');" );
195
+
196
  // Delete all point type balances and settings
197
  $mycred_types = mycred_get_types();
198
  foreach ( $mycred_types as $type => $label ) {
201
  $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s;", $type . '_total' ) );
202
  }
203
 
204
+ // Delete Badge Connections
205
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE %s;", 'mycred_badge%' ) );
206
+
207
+ // Delete Rank Connections
208
+ $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key IN ( %s, %s );", 'mycred_rank%', 'mycred_rank' ) );
209
+
210
  // Good bye.
211
  }
212
  }
213
+ endif;
214
+
215
  /**
216
  * myCRED_Setup class
217
  *
220
  * @since 0.1
221
  * @version 1.0
222
  */
223
+ if ( ! class_exists( 'myCRED_Setup' ) ) :
224
  class myCRED_Setup {
225
 
226
  public $step;
628
  <?php
629
  }
630
  }
631
+ endif;
632
+
633
  ?>
includes/mycred-shortcodes.php CHANGED
@@ -739,7 +739,7 @@ endif;
739
  * for watchinga YouTube video.
740
  * @see http://codex.mycred.me/shortcodes/mycred_video/
741
  * @since 1.2
742
- * @version 1.1.1
743
  */
744
  if ( ! function_exists( 'mycred_render_shortcode_video' ) ) :
745
  function mycred_render_shortcode_video( $atts ) {
@@ -756,7 +756,8 @@ if ( ! function_exists( 'mycred_render_shortcode_video' ) ) :
756
  'height' => 315,
757
  'amount' => $prefs['creds'],
758
  'logic' => $prefs['logic'],
759
- 'interval' => $prefs['interval']
 
760
  ), $atts ) );
761
 
762
  // ID is required
@@ -802,7 +803,7 @@ if ( ! function_exists( 'mycred_render_shortcode_video' ) ) :
802
  <script type="text/javascript">
803
  function mycred_vvideo_v<?php echo $video_id; ?>( state ) {
804
  duration[ "<?php echo $video_id; ?>" ] = state.target.getDuration();
805
- mycred_view_video( "<?php echo $video_id; ?>", state.data, "<?php echo $logic; ?>", "<?php echo $interval; ?>", "<?php echo $key; ?>" );
806
  }
807
  </script>
808
  </div>
@@ -824,7 +825,7 @@ endif;
824
  * of types.
825
  * @see http://codex.mycred.me/shortcodes/mycred_total_balance/
826
  * @since 1.4.3
827
- * @version 1.2.1
828
  */
829
  if ( ! function_exists( 'mycred_render_shortcode_total' ) ) :
830
  function mycred_render_shortcode_total( $atts, $content = '' ) {
@@ -889,7 +890,7 @@ if ( ! function_exists( 'mycred_render_shortcode_total' ) ) :
889
  if ( $raw == 0 ) {
890
 
891
  $mycred = mycred();
892
- $total_balance = $mycred->number( $total_balance );
893
 
894
  }
895
 
739
  * for watchinga YouTube video.
740
  * @see http://codex.mycred.me/shortcodes/mycred_video/
741
  * @since 1.2
742
+ * @version 1.2
743
  */
744
  if ( ! function_exists( 'mycred_render_shortcode_video' ) ) :
745
  function mycred_render_shortcode_video( $atts ) {
756
  'height' => 315,
757
  'amount' => $prefs['creds'],
758
  'logic' => $prefs['logic'],
759
+ 'interval' => $prefs['interval'],
760
+ 'ctype' => 'mycred_default'
761
  ), $atts ) );
762
 
763
  // ID is required
803
  <script type="text/javascript">
804
  function mycred_vvideo_v<?php echo $video_id; ?>( state ) {
805
  duration[ "<?php echo $video_id; ?>" ] = state.target.getDuration();
806
+ mycred_view_video( "<?php echo $video_id; ?>", state.data, "<?php echo $logic; ?>", "<?php echo $interval; ?>", "<?php echo $key; ?>", "<?php echo $ctype; ?>" );
807
  }
808
  </script>
809
  </div>
825
  * of types.
826
  * @see http://codex.mycred.me/shortcodes/mycred_total_balance/
827
  * @since 1.4.3
828
+ * @version 1.2.2
829
  */
830
  if ( ! function_exists( 'mycred_render_shortcode_total' ) ) :
831
  function mycred_render_shortcode_total( $atts, $content = '' ) {
890
  if ( $raw == 0 ) {
891
 
892
  $mycred = mycred();
893
+ $total_balance = $mycred->format_number( $total_balance );
894
 
895
  }
896
 
modules/mycred-module-hooks.php CHANGED
@@ -970,7 +970,7 @@ if ( ! class_exists( 'myCRED_Hook_Publishing_Content' ) ) {
970
  /**
971
  * Publish Content Hook
972
  * @since 0.1
973
- * @version 1.1
974
  */
975
  public function publishing_content( $new_status, $old_status, $post ) {
976
  $user_id = $post->post_author;
@@ -986,7 +986,7 @@ if ( ! class_exists( 'myCRED_Hook_Publishing_Content' ) ) {
986
  if ( empty( $this->prefs[ $post_type ]['creds'] ) || $this->prefs[ $post_type ]['creds'] == 0 ) return;
987
 
988
  // We want to fire when content get published or when it gets privatly published
989
- $status = apply_filters( 'mycred_publish_hook_old', array( 'new', 'auto-draft', 'draft', 'private', 'pending' ) );
990
  $publish_status = apply_filters( 'mycred_publish_hook_new', array( 'publish', 'private' ) );
991
 
992
  if ( in_array( $old_status, $status ) && in_array( $new_status, $publish_status ) && array_key_exists( $post_type, $this->prefs ) ) {
@@ -1960,11 +1960,11 @@ if ( ! class_exists( 'myCRED_Hook_Video_Views' ) ) {
1960
  /**
1961
  * AJAX Call Handler
1962
  * @since 1.2
1963
- * @version 1.1.1
1964
  */
1965
  public function ajax_call_video_points() {
1966
  // We must be logged in
1967
- if ( ! is_user_logged_in() ) die();
1968
 
1969
  // Security
1970
  check_ajax_referer( 'mycred-video-points', 'token' );
@@ -1972,22 +1972,25 @@ if ( ! class_exists( 'myCRED_Hook_Video_Views' ) ) {
1972
  // Get user id
1973
  $user_id = get_current_user_id();
1974
 
 
 
 
1975
  // Decode the key giving us the video shortcode setup
1976
  // This will prevent users from manipulating the shortcode output
1977
  $setup = mycred_verify_token( $_POST['setup'], 5 );
1978
- if ( $setup === false ) die();
1979
 
1980
  list ( $source, $video_id, $amount, $logic, $interval ) = $setup;
1981
 
1982
  // Required
1983
- if ( empty( $source ) || empty( $video_id ) ) die();
1984
 
1985
  // Prep
1986
  $amount = $this->core->number( $amount );
1987
  $interval = abs( $interval / 1000 );
1988
 
1989
  // Get playback details
1990
- $actions = trim( $_POST['video_a'] );
1991
  $seconds = abs( $_POST['video_b'] );
1992
  $duration = abs( $_POST['video_c'] );
1993
  $state = absint( $_POST['video_d'] );
@@ -2012,7 +2015,7 @@ if ( ! class_exists( 'myCRED_Hook_Video_Views' ) ) {
2012
  $user_id,
2013
  $amount,
2014
  $this->prefs['log'],
2015
- '',
2016
  $video_id,
2017
  $this->mycred_type
2018
  );
@@ -2039,7 +2042,7 @@ if ( ! class_exists( 'myCRED_Hook_Video_Views' ) ) {
2039
  $user_id,
2040
  $amount,
2041
  $this->prefs['log'],
2042
- '',
2043
  $video_id,
2044
  $this->mycred_type
2045
  );
@@ -2072,7 +2075,7 @@ if ( ! class_exists( 'myCRED_Hook_Video_Views' ) ) {
2072
  $user_id,
2073
  $amount,
2074
  $this->prefs['log'],
2075
- '',
2076
  $video_id,
2077
  $this->mycred_type
2078
  );
970
  /**
971
  * Publish Content Hook
972
  * @since 0.1
973
+ * @version 1.1.1
974
  */
975
  public function publishing_content( $new_status, $old_status, $post ) {
976
  $user_id = $post->post_author;
986
  if ( empty( $this->prefs[ $post_type ]['creds'] ) || $this->prefs[ $post_type ]['creds'] == 0 ) return;
987
 
988
  // We want to fire when content get published or when it gets privatly published
989
+ $status = apply_filters( 'mycred_publish_hook_old', array( 'new', 'auto-draft', 'draft', 'private', 'pending', 'future' ) );
990
  $publish_status = apply_filters( 'mycred_publish_hook_new', array( 'publish', 'private' ) );
991
 
992
  if ( in_array( $old_status, $status ) && in_array( $new_status, $publish_status ) && array_key_exists( $post_type, $this->prefs ) ) {
1960
  /**
1961
  * AJAX Call Handler
1962
  * @since 1.2
1963
+ * @version 1.2
1964
  */
1965
  public function ajax_call_video_points() {
1966
  // We must be logged in
1967
+ if ( ! is_user_logged_in() ) die;
1968
 
1969
  // Security
1970
  check_ajax_referer( 'mycred-video-points', 'token' );
1972
  // Get user id
1973
  $user_id = get_current_user_id();
1974
 
1975
+ // We are only interested in handling our own point type
1976
+ if ( ! isset( $_POST['type'] ) || $this->mycred_type != sanitize_text_field( $_POST['type'] ) ) die;
1977
+
1978
  // Decode the key giving us the video shortcode setup
1979
  // This will prevent users from manipulating the shortcode output
1980
  $setup = mycred_verify_token( $_POST['setup'], 5 );
1981
+ if ( $setup === false ) die;
1982
 
1983
  list ( $source, $video_id, $amount, $logic, $interval ) = $setup;
1984
 
1985
  // Required
1986
+ if ( empty( $source ) || empty( $video_id ) ) die;
1987
 
1988
  // Prep
1989
  $amount = $this->core->number( $amount );
1990
  $interval = abs( $interval / 1000 );
1991
 
1992
  // Get playback details
1993
+ $actions = sanitize_text_field( $_POST['video_a'] );
1994
  $seconds = abs( $_POST['video_b'] );
1995
  $duration = abs( $_POST['video_c'] );
1996
  $state = absint( $_POST['video_d'] );
2015
  $user_id,
2016
  $amount,
2017
  $this->prefs['log'],
2018
+ 0,
2019
  $video_id,
2020
  $this->mycred_type
2021
  );
2042
  $user_id,
2043
  $amount,
2044
  $this->prefs['log'],
2045
+ 0,
2046
  $video_id,
2047
  $this->mycred_type
2048
  );
2075
  $user_id,
2076
  $amount,
2077
  $this->prefs['log'],
2078
+ 0,
2079
  $video_id,
2080
  $this->mycred_type
2081
  );
modules/mycred-module-settings.php CHANGED
@@ -746,7 +746,7 @@ if ( ! class_exists( 'myCRED_Settings_Module' ) ) {
746
  * Sanititze Settings
747
  * @filter 'mycred_save_core_prefs'
748
  * @since 0.1
749
- * @version 1.4
750
  */
751
  public function sanitize_settings( $post ) {
752
  $new_data = array();
@@ -843,7 +843,7 @@ if ( ! class_exists( 'myCRED_Settings_Module' ) ) {
843
  if ( $new_data['exclude']['list'] != '' ) {
844
  $excluded_ids = explode( ',', $new_data['exclude']['list'] );
845
  if ( ! empty( $excluded_ids ) ) {
846
- foreach ( $exclude_ids as $user_id ) {
847
  $user_id = absint( trim( $user_id ) );
848
  if ( $user_id == 0 ) continue;
849
  mycred_delete_user_meta( $user_id, $this->mycred_type );
746
  * Sanititze Settings
747
  * @filter 'mycred_save_core_prefs'
748
  * @since 0.1
749
+ * @version 1.4.1
750
  */
751
  public function sanitize_settings( $post ) {
752
  $new_data = array();
843
  if ( $new_data['exclude']['list'] != '' ) {
844
  $excluded_ids = explode( ',', $new_data['exclude']['list'] );
845
  if ( ! empty( $excluded_ids ) ) {
846
+ foreach ( (array) $excluded_ids as $user_id ) {
847
  $user_id = absint( trim( $user_id ) );
848
  if ( $user_id == 0 ) continue;
849
  mycred_delete_user_meta( $user_id, $this->mycred_type );
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.6
7
  * Tags: points, tokens, credit, management, reward, charge, buddypress, bbpress, jetpack, woocommerce, marketpress, wp e-commerce, gravity forms, simplepress
8
  * Author: Gabriel S Merovingi
9
  * Author URI: http://www.merovingi.com
@@ -20,7 +20,7 @@
20
  * BuddyPress Compatible: yes
21
  * Forum URI: http://mycred.me/support/forums/
22
  */
23
- define( 'myCRED_VERSION', '1.6' );
24
  define( 'myCRED_SLUG', 'mycred' );
25
  define( 'myCRED_NAME', '<strong>my</strong>CRED' );
26
 
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.6.1
7
  * Tags: points, tokens, credit, management, reward, charge, buddypress, bbpress, jetpack, woocommerce, marketpress, wp e-commerce, gravity forms, simplepress
8
  * Author: Gabriel S Merovingi
9
  * Author URI: http://www.merovingi.com
20
  * BuddyPress Compatible: yes
21
  * Forum URI: http://mycred.me/support/forums/
22
  */
23
+ define( 'myCRED_VERSION', '1.6.1' );
24
  define( 'myCRED_SLUG', 'mycred' );
25
  define( 'myCRED_NAME', '<strong>my</strong>CRED' );
26
 
plugins/mycred-hook-bbPress.php CHANGED
@@ -329,7 +329,7 @@ if ( defined( 'myCRED_VERSION' ) ) {
329
  /**
330
  * Delete Reply
331
  * @since 1.2
332
- * @version 1.2
333
  */
334
  public function delete_reply( $reply_id ) {
335
  // Get Author
@@ -349,9 +349,6 @@ if ( defined( 'myCRED_VERSION' ) ) {
349
  $this->mycred_type
350
  );
351
 
352
- // Update Limit
353
- $this->update_daily_limit( $reply_author, 'new_reply', true );
354
-
355
  }
356
  }
357
 
329
  /**
330
  * Delete Reply
331
  * @since 1.2
332
+ * @version 1.2.1
333
  */
334
  public function delete_reply( $reply_id ) {
335
  // Get Author
349
  $this->mycred_type
350
  );
351
 
 
 
 
352
  }
353
  }
354
 
plugins/mycred-hook-invite-anyone.php CHANGED
@@ -133,7 +133,7 @@ if ( defined( 'myCRED_VERSION' ) ) {
133
  /**
134
  * Accepting Invites
135
  * @since 0.1
136
- * @version 1.3
137
  */
138
  public function accept_invite( $invited_user_id, $inviters = array() ) {
139
  if ( empty( $inviters ) ) return;
@@ -142,7 +142,7 @@ if ( defined( 'myCRED_VERSION' ) ) {
142
  foreach ( (array) $inviters as $inviter_id ) {
143
 
144
  // Check for exclusion
145
- if ( $this->core->exclude_user( $pending[ $user_id ] ) ) continue;
146
 
147
  // Award Points
148
  $run = true;
133
  /**
134
  * Accepting Invites
135
  * @since 0.1
136
+ * @version 1.3.1
137
  */
138
  public function accept_invite( $invited_user_id, $inviters = array() ) {
139
  if ( empty( $inviters ) ) return;
142
  foreach ( (array) $inviters as $inviter_id ) {
143
 
144
  // Check for exclusion
145
+ if ( $this->core->exclude_user( $inviter_id ) ) continue;
146
 
147
  // Award Points
148
  $run = true;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: designbymerovingi
3
  Tags:points, tokens, credit, management, reward, charge, community, contest, buddypress, jetpack, bbpress, simple press, woocommerce, marketpress, wp e-commerce, gravity forms, share-this
4
  Requires at least: 3.8
5
  Tested up to: 4.1
6
- Stable tag: 1.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -131,54 +131,17 @@ New Features, Big Improvements and Bug Fixes.
131
 
132
  == Changelog ==
133
 
 
 
 
 
 
 
 
 
 
134
  = 1.6 =
135
- * NEW - Added option to change number of decimal places after setup.
136
- * NEW - Statistics Add-on
137
- * NEW - Badges can now have levels.
138
- * NEW - Added manual badge management when editing a user.
139
- * NEW - Built-in hooks have been added optional limits.
140
- * NEW - Added Rewards system for MarketPress allowing you to reward purchases with points.
141
- * NEW - Added new hook for WP Postratings plugin.
142
- * NEW - Added new shortcode: mycred_hook_table to show the amount of points users can earn or lose based on setup.
143
- * NEW - Ranks now support multiple point types.
144
-
145
- * NEW - Added new filter: mycred_run_this for adjusting points before being executed.
146
- * NEW - Added new filter: mycred_add_finished for customizations after points have been awarded / deducted.
147
- * NEW - Added new filters: mycred_wpecom_profit_share, mycred_marketpress_profit_share and mycred_woo_profit_share to allow customizations of the percentage to pay out to store vendors.
148
- * NEW - Added new constants MYCRED_BADGE_WIDTH and MYCRED_BADGE_HEIGHT to set the width and height of badge images in pixels. Defaults to 100x100.
149
- * NEW - Added support for sending email notifications for new badges.
150
- * NEW - Added support for setting which point type an email is to be sent for.
151
- * NEW - Added option to set what ranks for each point type is based on.
152
- * NEW - Added new shortcode [mycred_users_of_ranks] to show all users ranks.
153
- * NEW - Added support for Affiliate WP.
154
- * NEW - Added option to award points to post authors when their post is added to favorites.
155
- * NEW - Added warning when creating custom point types to ensure keys are properly formatted.
156
- * NEW - Added hook for Profile Update removals.
157
- * NEW - Added new constant SHOW_MYCRED_IN_WOOCOMMERCE to always show the myCRED payment gateway in WooCommerce.
158
-
159
- * TWEAK - Moved Email Notifications from mycred_add to mycred_add_finished.
160
- * TWEAK - Moved Ranks check from mycred_add to mycred_add_finished.
161
- * TWEAK - Added option to for BuddyPress and bbPress to select if we should show only earned or all badges in profiles / replies.
162
- * TWEAK - Updated admin styling and available template tags for email notifications.
163
- * TWEAK - When selecting "Set all balances to zero", all ranks are reset as well.
164
- * TWEAK - All rank shortcodes have been updated to support multiple point types.
165
- * TWEAK - Re-organized certain add-on folders by moving js and css items into assets folder.
166
- * TWEAK - Updated HTML code structure on buyCRED Payment Gateways page.
167
- * TWEAK - Added support for user_id and post_id usage for the mycred_affiliate_link shortcode.
168
- * TWEAK - Notifications add-on's "Duration" setting has been changed from using milliseconds to using seconds.
169
- * TWEAK - Moved all custom post type updates from save_post to save_post_{post_type}.
170
- * TWEAK - Added new show_nav="" attribute for the mycred_history shortcode, to set if the navigation should be shown (1) or not (0). Set to show (1) by default.
171
- * TWEAK - Added function check to prevent fatal error when WooCommerce has been used but disabled, while we are viewing log entries for purchases made.
172
- * TWEAK - Added warning to the log page if the Mcrypt library has been disabled after activation.
173
- * TWEAK - Moved Transfer functions, shortcode and widget code to their own files. Re-organized the transfer add-on folder.
174
-
175
- * FIX - Badge requirements show 1 instead of actual value.
176
- * FIX - When points without decimals are purchased, NETbilling required them to have two decimals.
177
- * FIX - Incorrect sorting variable is passed when sorting your points history in BuddyPress.
178
- * FIX - When awarding points for BP Group members on x number of members, points are not awarded.
179
- * FIX - mycred_give limit only works for the default point type.
180
- * FIX - When ranks are not based on total point balance the awarding of a new rank is "one step" behind.
181
- * FIX - Adjusted admin.css stylesheet to force the myCRED layout on myCRED settings page.
182
 
183
  = 1.5.4 =
184
  http://mycred.me/support/changelog/
3
  Tags:points, tokens, credit, management, reward, charge, community, contest, buddypress, jetpack, bbpress, simple press, woocommerce, marketpress, wp e-commerce, gravity forms, share-this
4
  Requires at least: 3.8
5
  Tested up to: 4.1
6
+ Stable tag: 1.6.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
131
 
132
  == Changelog ==
133
 
134
+ = 1.6.1 =
135
+ FIX - Points for viewing content hook causes logged in authors not to see their own content.
136
+ FIX - Google Chrome form validation issue for settings.
137
+ FIX - Removed incorrect link on about page in admin area.
138
+ FIX - Added "transfer" reference to ignore by central bank. When using custom references, this still has to be added by the user.
139
+ FIX - Added support for multiple point types for the mycred_video shortcode.
140
+ FIX - Added missing $type variable for the mycred_has_entry filter.
141
+ FIX - Removed legend template for statistics add-on as the library seems to have issues handling RTL setups.
142
+
143
  = 1.6 =
144
+ http://mycred.me/support/changelog/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
  = 1.5.4 =
147
  http://mycred.me/support/changelog/