myCRED - Version 1.2.1

Version Description

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

Download this release

Release Info

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

Code changes from version 1.2 to 1.2.1

addons/sell-content/myCRED-addon-sell-content.php CHANGED
@@ -280,7 +280,7 @@ if ( !class_exists( 'myCRED_Sell_Content' ) ) {
280
  * @since 0.1
281
  * @version 1.0
282
  */
283
- public function after_general_settings( $all ) {
284
  $sell_content = $this->sell_content;
285
  if ( !isset( $sell_content['defaults']['expire'] ) )
286
  $sell_content['defaults']['expire'] = 0;
280
  * @since 0.1
281
  * @version 1.0
282
  */
283
+ public function after_general_settings() {
284
  $sell_content = $this->sell_content;
285
  if ( !isset( $sell_content['defaults']['expire'] ) )
286
  $sell_content['defaults']['expire'] = 0;
includes/mycred-functions.php CHANGED
@@ -237,7 +237,7 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
237
  * General Template Tags
238
  * Replaces the general template tags in a given string.
239
  * @since 0.1
240
- * @version 1.1
241
  */
242
  public function template_tags_general( $content = '' ) {
243
  $content = apply_filters( 'mycred_parse_tags_general', $content );
@@ -259,11 +259,13 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
259
  $content = str_replace( '%logout_url_here%', wp_logout_url( get_permalink() ), $content );
260
 
261
  // Blog Related
262
- $content = str_replace( '%num_members%', $this->count_members(), $content );
263
- $content = str_replace( '%blog_name%', get_bloginfo( 'name' ), $content );
264
- $content = str_replace( '%blog_url%', get_bloginfo( 'url' ), $content );
265
- $content = str_replace( '%blog_info%', get_bloginfo( 'description' ), $content );
266
- $content = str_replace( '%admin_email%', get_bloginfo( 'admin_email' ), $content );
 
 
267
 
268
  //$content = str_replace( '', , $content );
269
  return $content;
@@ -273,9 +275,10 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
273
  * Amount Template Tags
274
  * Replaces the amount template tags in a given string.
275
  * @since 0.1
276
- * @version 1.0.1
277
  */
278
  public function template_tags_amount( $content = '', $amount = 0 ) {
 
279
  $content = apply_filters( 'mycred_parse_tags_amount', $content, $amount );
280
  $content = $this->template_tags_general( $content );
281
  $content = str_replace( '%cred_f%', $this->format_creds( $amount ), $content );
@@ -292,10 +295,11 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
292
  * @param $data (object) Log entry data object
293
  * @return (string) parsed string
294
  * @since 0.1
295
- * @version 1.0.2
296
  */
297
  public function template_tags_post( $content = '', $ref_id = NULL, $data = '' ) {
298
  if ( $ref_id === NULL ) return $content;
 
299
 
300
  // Get Post Object
301
  $post = get_post( $ref_id );
@@ -345,10 +349,11 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
345
  * @param $data (object) Log entry data object
346
  * @return (string) parsed string
347
  * @since 0.1
348
- * @version 1.1
349
  */
350
  public function template_tags_user( $content = '', $ref_id = NULL, $data = '' ) {
351
  if ( $ref_id === NULL ) return $content;
 
352
 
353
  // Get User Object
354
  if ( $ref_id !== false )
@@ -419,10 +424,11 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
419
  * @param $data (object) Log entry data object
420
  * @return (string) parsed string
421
  * @since 0.1
422
- * @version 1.0.2
423
  */
424
  public function template_tags_comment( $content = '', $ref_id = NULL, $data = '' ) {
425
  if ( $ref_id === NULL ) return $content;
 
426
 
427
  // Get Comment Object
428
  $comment = get_comment( $ref_id );
@@ -462,6 +468,26 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
462
  return $content;
463
  }
464
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
  /**
466
  * Allowed Tags
467
  * Strips HTML tags from a given string.
@@ -573,7 +599,6 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
573
  * @version 1.0
574
  */
575
  public function in_exclude_list( $user_id = '' ) {
576
-
577
  // Grab current user id
578
  if ( empty( $user_id ) )
579
  $user_id = get_current_user_id();
@@ -631,7 +656,7 @@ if ( !class_exists( 'myCRED_Settings' ) ) {
631
  */
632
  public function count_members() {
633
  global $wpdb;
634
- return $wpdb->get_var( "SELECT COUNT(ID) FROM $wpdb->users" );
635
  }
636
 
637
  /**
237
  * General Template Tags
238
  * Replaces the general template tags in a given string.
239
  * @since 0.1
240
+ * @version 1.2
241
  */
242
  public function template_tags_general( $content = '' ) {
243
  $content = apply_filters( 'mycred_parse_tags_general', $content );
259
  $content = str_replace( '%logout_url_here%', wp_logout_url( get_permalink() ), $content );
260
 
261
  // Blog Related
262
+ if ( preg_match( '%(num_members|blog_name|blog_url|blog_info|admin_email)%', $content, $matches ) ) {
263
+ $content = str_replace( '%num_members%', $this->count_members(), $content );
264
+ $content = str_replace( '%blog_name%', get_bloginfo( 'name' ), $content );
265
+ $content = str_replace( '%blog_url%', get_bloginfo( 'url' ), $content );
266
+ $content = str_replace( '%blog_info%', get_bloginfo( 'description' ), $content );
267
+ $content = str_replace( '%admin_email%', get_bloginfo( 'admin_email' ), $content );
268
+ }
269
 
270
  //$content = str_replace( '', , $content );
271
  return $content;
275
  * Amount Template Tags
276
  * Replaces the amount template tags in a given string.
277
  * @since 0.1
278
+ * @version 1.0.2
279
  */
280
  public function template_tags_amount( $content = '', $amount = 0 ) {
281
+ if ( !$this->has_tags( 'amount', 'cred|cred_f', $content ) ) return $content;
282
  $content = apply_filters( 'mycred_parse_tags_amount', $content, $amount );
283
  $content = $this->template_tags_general( $content );
284
  $content = str_replace( '%cred_f%', $this->format_creds( $amount ), $content );
295
  * @param $data (object) Log entry data object
296
  * @return (string) parsed string
297
  * @since 0.1
298
+ * @version 1.0.3
299
  */
300
  public function template_tags_post( $content = '', $ref_id = NULL, $data = '' ) {
301
  if ( $ref_id === NULL ) return $content;
302
+ if ( !$this->has_tags( 'post', 'post_title|post_url|link_with_title|post_type', $content ) ) return $content;
303
 
304
  // Get Post Object
305
  $post = get_post( $ref_id );
349
  * @param $data (object) Log entry data object
350
  * @return (string) parsed string
351
  * @since 0.1
352
+ * @version 1.2
353
  */
354
  public function template_tags_user( $content = '', $ref_id = NULL, $data = '' ) {
355
  if ( $ref_id === NULL ) return $content;
356
+ if ( !$this->has_tags( 'user', 'user_id|user_name|user_name_en|display_name|user_profile_url|user_profile_link|user_nicename|user_email|user_url|balance|balance_f', $content ) ) return $content;
357
 
358
  // Get User Object
359
  if ( $ref_id !== false )
424
  * @param $data (object) Log entry data object
425
  * @return (string) parsed string
426
  * @since 0.1
427
+ * @version 1.0.3
428
  */
429
  public function template_tags_comment( $content = '', $ref_id = NULL, $data = '' ) {
430
  if ( $ref_id === NULL ) return $content;
431
+ if ( !$this->has_tags( 'comment', 'comment_id|c_post_id|c_post_title|c_post_url|c_link_with_title', $content ) ) return $content;
432
 
433
  // Get Comment Object
434
  $comment = get_comment( $ref_id );
468
  return $content;
469
  }
470
 
471
+ /**
472
+ * Has Tags
473
+ * Checks if a string has any of the defined template tags.
474
+ *
475
+ * @param $type (string) template tag type
476
+ * @param $tags (string) tags to search for, list with |
477
+ * @param $content (string) content to search
478
+ * @filter 'mycred_has_tags'
479
+ * @filter 'mycred_has_tags_{$type}'
480
+ * @returns (boolean) true or false
481
+ * @since 1.2.2
482
+ * @version 1.0
483
+ */
484
+ public function has_tags( $type = '', $tags = '', $content = '' ) {
485
+ $tags = apply_filters( 'mycred_has_tags', $tags, $content );
486
+ $tags = apply_filters( 'mycred_has_tags_' . $type, $tags, $content );
487
+ if ( !preg_match( '%(' . trim( $tags ) . ')%', $content, $matches ) ) return false;
488
+ return true;
489
+ }
490
+
491
  /**
492
  * Allowed Tags
493
  * Strips HTML tags from a given string.
599
  * @version 1.0
600
  */
601
  public function in_exclude_list( $user_id = '' ) {
 
602
  // Grab current user id
603
  if ( empty( $user_id ) )
604
  $user_id = get_current_user_id();
656
  */
657
  public function count_members() {
658
  global $wpdb;
659
+ return (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->users}" );
660
  }
661
 
662
  /**
includes/mycred-install.php CHANGED
@@ -645,7 +645,7 @@ if ( !class_exists( 'myCRED_Setup' ) ) {
645
  /**
646
  * Install Database
647
  * @since 0.1
648
- * @version 1.0
649
  */
650
  protected function install_database( $decimals = 0 ) {
651
  // If DB is already installed bail pretending that everything is fine
@@ -681,7 +681,7 @@ if ( !class_exists( 'myCRED_Setup' ) ) {
681
 
682
  // Insert table
683
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
684
- dbDelta( "CREATE TABLE IF NOT EXISTS " . $table_name . " ( " . $sql . " ) DEFAULT CHARSET = utf8 COLLATE = utf8_general_ci;" );
685
  add_option( 'mycred_version_db', '1.0', '', 'no' );
686
  return true;
687
  }
645
  /**
646
  * Install Database
647
  * @since 0.1
648
+ * @version 1.1
649
  */
650
  protected function install_database( $decimals = 0 ) {
651
  // If DB is already installed bail pretending that everything is fine
681
 
682
  // Insert table
683
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
684
+ dbDelta( "CREATE TABLE IF NOT EXISTS " . $table_name . " ( " . $sql . " );" );
685
  add_option( 'mycred_version_db', '1.0', '', 'no' );
686
  return true;
687
  }
modules/mycred-module-hooks.php CHANGED
@@ -1314,7 +1314,7 @@ if ( !class_exists( 'myCRED_Hook_Video_Views' ) ) {
1314
  /**
1315
  * AJAX Call Handler
1316
  * @since 1.2
1317
- * @version 1.0
1318
  */
1319
  public function ajax_call_video_points() {
1320
  // We must be logged in
@@ -1422,12 +1422,14 @@ if ( !class_exists( 'myCRED_Hook_Video_Views' ) ) {
1422
  elseif ( $state == 1 && isset( $users_log->creds ) && $users_log->creds+$amount <= $max ) {
1423
  $award = true;
1424
  $this->update_creds( $users_log->id, $user_id, $users_log->creds+$amount );
 
1425
  $amount = $users_log->creds+$amount;
1426
  }
1427
  // Film has ended and we have not reached maximum
1428
  elseif ( $state == 0 && isset( $users_log->creds ) && $users_log->creds+$amount <= $max ) {
1429
  $award = true;
1430
  $this->update_creds( $users_log->id, $user_id, $users_log->creds+$amount );
 
1431
  $amount = $users_log->creds+$amount;
1432
  $status = 'max';
1433
  }
1314
  /**
1315
  * AJAX Call Handler
1316
  * @since 1.2
1317
+ * @version 1.1
1318
  */
1319
  public function ajax_call_video_points() {
1320
  // We must be logged in
1422
  elseif ( $state == 1 && isset( $users_log->creds ) && $users_log->creds+$amount <= $max ) {
1423
  $award = true;
1424
  $this->update_creds( $users_log->id, $user_id, $users_log->creds+$amount );
1425
+ $this->core->update_users_balance( $user_id, $amount );
1426
  $amount = $users_log->creds+$amount;
1427
  }
1428
  // Film has ended and we have not reached maximum
1429
  elseif ( $state == 0 && isset( $users_log->creds ) && $users_log->creds+$amount <= $max ) {
1430
  $award = true;
1431
  $this->update_creds( $users_log->id, $user_id, $users_log->creds+$amount );
1432
+ $this->core->update_users_balance( $user_id, $amount );
1433
  $amount = $users_log->creds+$amount;
1434
  $status = 'max';
1435
  }
modules/mycred-module-log.php CHANGED
@@ -185,14 +185,7 @@ if ( !class_exists( 'myCRED_Log' ) ) {
185
 
186
  // Filter by user
187
  if ( $this->core->can_edit_creds() && !$is_profile && $this->count_records() > 0 ) {
188
- $users = $this->get_users();
189
- echo '<select name="user_id" id="myCRED-user-filter"><option value="">' . __( 'Show all users', 'mycred' ) . '</option>';
190
- foreach ( $users as $user_id => $display_name ) {
191
- echo '<option value="' . $user_id . '"';
192
- if ( isset( $_GET['user_id'] ) && $_GET['user_id'] == $user_id ) echo ' selected="selected"';
193
- echo '>' . $display_name . '</option>';
194
- }
195
- echo '</select>';
196
  $show = true;
197
  }
198
 
185
 
186
  // Filter by user
187
  if ( $this->core->can_edit_creds() && !$is_profile && $this->count_records() > 0 ) {
188
+ echo '<input type="text" name="user_id" id="myCRED-user-filter" size="12" placeholder="' . __( 'Username', 'mycred' ) . '" value="' . ( ( isset( $_GET['user_id'] ) ) ? $_GET['user_id'] : '' ) . '" /> ';
 
 
 
 
 
 
 
189
  $show = true;
190
  }
191
 
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.2
7
  Tags: points, tokens, credit, management, reward, charge
8
  Author: Gabriel S Merovingi
9
  Author URI: http://www.merovingi.com
@@ -15,7 +15,7 @@ Domain Path: /lang
15
  License: GPLv2 or later
16
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
17
  */
18
- define( 'myCRED_VERSION', '1.2' );
19
  define( 'myCRED_SLUG', 'mycred' );
20
  define( 'myCRED_NAME', '<strong>my</strong>CRED' );
21
 
@@ -159,9 +159,14 @@ if ( !class_exists( 'myCRED_Core' ) ) {
159
  /**
160
  * Runs when the plugin is deactivated
161
  * @since 0.1
162
- * @version 1.0
163
  */
164
  function deactivate_mycred() {
 
 
 
 
 
165
  do_action( 'mycred_deactivation' );
166
  }
167
 
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.2.1
7
  Tags: points, tokens, credit, management, reward, charge
8
  Author: Gabriel S Merovingi
9
  Author URI: http://www.merovingi.com
15
  License: GPLv2 or later
16
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
17
  */
18
+ define( 'myCRED_VERSION', '1.2.1' );
19
  define( 'myCRED_SLUG', 'mycred' );
20
  define( 'myCRED_NAME', '<strong>my</strong>CRED' );
21
 
159
  /**
160
  * Runs when the plugin is deactivated
161
  * @since 0.1
162
+ * @version 1.1
163
  */
164
  function deactivate_mycred() {
165
+ // Clear Cron
166
+ wp_clear_scheduled_hook( 'mycred_banking_recurring_payout' );
167
+ wp_clear_scheduled_hook( 'mycred_banking_interest_compound' );
168
+ wp_clear_scheduled_hook( 'mycred_banking_interest_payout' );
169
+
170
  do_action( 'mycred_deactivation' );
171
  }
172
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: designbymerovingi
3
  Tags:points, tokens, credit, management, reward, charge, community, contest, BuddyPress, Jetpack, bbPress
4
  Requires at least: 3.1
5
  Tested up to: 3.6
6
- Stable tag: 1.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -127,6 +127,9 @@ Yes but if one of them is bought, all is shown. The mycred_sell_this shortcode w
127
 
128
  == Upgrade Notice ==
129
 
 
 
 
130
  = 1.2 =
131
  See http://mycred.me/download/changelog/
132
 
@@ -155,6 +158,11 @@ See: http://mycred.me/download/changelog/2/
155
 
156
  == Changelog ==
157
 
 
 
 
 
 
158
  = 1.2 =
159
  * Moved the has_entry() method from myCRED_Hook to myCRED Settings to allow use by other features then just hooks.
160
  * Adjusted Hooks for clicking on links to enforce limits once per user and not once per use.
3
  Tags:points, tokens, credit, management, reward, charge, community, contest, BuddyPress, Jetpack, bbPress
4
  Requires at least: 3.1
5
  Tested up to: 3.6
6
+ Stable tag: 1.2.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
127
 
128
  == Upgrade Notice ==
129
 
130
+ = 1.2.1 =
131
+ See http://mycred.me/download/changelog/
132
+
133
  = 1.2 =
134
  See http://mycred.me/download/changelog/
135
 
158
 
159
  == Changelog ==
160
 
161
+ = 1.2.1 =
162
+ * Fixed Bug #43 - Users are not sorted according to balance in WP admin.
163
+ * Fixed Bug #44 - Incorrect settings are saved by Banking add-on causing Hooks to reset.
164
+ * Fixed Bug #45 - Jetpack subscription causes error when jetpack is updated as there is no check if JETPACK__PLUGIN_DIR is defined.
165
+
166
  = 1.2 =
167
  * Moved the has_entry() method from myCRED_Hook to myCRED Settings to allow use by other features then just hooks.
168
  * Adjusted Hooks for clicking on links to enforce limits once per user and not once per use.