Version Description
Bug fixes release.
=
Download this release
Release Info
Developer | wpexpertsio |
Plugin | myCRED |
Version | 1.8.5 |
Comparing to | |
See all releases |
Code changes from version 1.8.4.1 to 1.8.5
- addons/badges/includes/mycred-badge-functions.php +8 -1
- addons/badges/includes/mycred-badge-object.php +40 -28
- addons/buy-creds/modules/buycred-module-pending.php +1 -1
- addons/coupons/includes/mycred-coupon-object.php +4 -4
- addons/coupons/includes/mycred-coupon-shortcodes.php +6 -2
- addons/email-notices/includes/mycred-email-functions.php +29 -1
- addons/email-notices/includes/mycred-email-object.php +8 -2
- addons/email-notices/includes/mycred-email-shortcodes.php +6 -6
- addons/ranks/includes/mycred-rank-functions.php +1 -1
- addons/ranks/includes/mycred-rank-shortcodes.php +1 -1
- addons/ranks/myCRED-addon-ranks.php +4 -4
- addons/transfer/includes/mycred-transfer-functions.php +1 -1
- addons/transfer/includes/mycred-transfer-object.php +4 -3
- includes/classes/class.query-leaderboard.php +12 -2
- includes/classes/class.query-log.php +1 -1
- includes/hooks/external/mycred-hook-buddypress.php +26 -18
- includes/shortcodes/mycred_hook_table.php +8 -2
- includes/shortcodes/mycred_leaderboard.php +2 -1
- includes/widgets/mycred-widget-leaderboard.php +1 -1
- modules/mycred-module-caching.php +2 -2
- modules/mycred-module-hooks.php +3 -3
- mycred.php +3 -3
- plugins/index.php +0 -3
- plugins/mycred-hook-affiliatewp.php +0 -407
- plugins/mycred-hook-badgeOS.php +0 -360
- plugins/mycred-hook-bbPress.php +0 -664
- plugins/mycred-hook-buddypress-gallery.php +0 -116
- plugins/mycred-hook-buddypress-links.php +0 -329
- plugins/mycred-hook-buddypress-media.php +0 -453
- plugins/mycred-hook-buddypress.php +0 -1828
- plugins/mycred-hook-contact-form7.php +0 -216
- plugins/mycred-hook-events-manager-light.php +0 -266
- plugins/mycred-hook-gd-star-rating.php +0 -134
- plugins/mycred-hook-gravityforms.php +0 -210
- plugins/mycred-hook-invite-anyone.php +0 -283
- plugins/mycred-hook-jetpack.php +0 -195
- plugins/mycred-hook-sharethis.php +0 -364
- plugins/mycred-hook-simplepress.php +0 -416
- plugins/mycred-hook-woocommerce.php +0 -569
- plugins/mycred-hook-wp-favorite-posts.php +0 -326
- plugins/mycred-hook-wp-polls.php +0 -190
- plugins/mycred-hook-wp-postratings.php +0 -256
- readme.txt +34 -2
addons/badges/includes/mycred-badge-functions.php
CHANGED
@@ -648,8 +648,15 @@ if ( ! function_exists( 'mycred_display_users_badges' ) ) :
|
|
648 |
$badge->image_width = $width;
|
649 |
$badge->image_height = $height;
|
650 |
|
|
|
|
|
651 |
if ( $badge->level_image !== false )
|
652 |
-
|
|
|
|
|
|
|
|
|
|
|
653 |
|
654 |
}
|
655 |
|
648 |
$badge->image_width = $width;
|
649 |
$badge->image_height = $height;
|
650 |
|
651 |
+
$badge_image = '';
|
652 |
+
|
653 |
if ( $badge->level_image !== false )
|
654 |
+
$badge_image = $badge->get_image( $level );
|
655 |
+
else if( $badge->main_image !== false )
|
656 |
+
$badge_image = $badge->get_image( 'main' );
|
657 |
+
|
658 |
+
if ( !empty( $badge_image ) )
|
659 |
+
echo apply_filters( 'mycred_the_badge', $badge_image, $badge_id, $badge, $user_id );
|
660 |
|
661 |
}
|
662 |
|
addons/badges/includes/mycred-badge-object.php
CHANGED
@@ -385,19 +385,25 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
|
|
385 |
// Make sure we only get points once for each level we reach for each badge
|
386 |
if ( ! $mycred->has_entry( 'badge_reward', $this->post_id, $this->user_id, 0, $reward['type'] ) ) {
|
387 |
|
388 |
-
$
|
389 |
-
'badge_reward',
|
390 |
-
$this->user_id,
|
391 |
-
$reward['amount'],
|
392 |
-
$reward['log'],
|
393 |
-
$this->post_id,
|
394 |
-
0,
|
395 |
-
$reward['type']
|
396 |
-
);
|
397 |
|
398 |
-
|
399 |
|
400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
|
402 |
}
|
403 |
|
@@ -417,19 +423,25 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
|
|
417 |
// Make sure we only get points once for each level we reach for each badge
|
418 |
if ( ! $mycred->has_entry( 'badge_reward', $this->post_id, $this->user_id, $i, $reward['type'] ) ) {
|
419 |
|
420 |
-
$
|
421 |
-
'badge_reward',
|
422 |
-
$this->user_id,
|
423 |
-
$reward['amount'],
|
424 |
-
$reward['log'],
|
425 |
-
$this->post_id,
|
426 |
-
$i,
|
427 |
-
$reward['type']
|
428 |
-
);
|
429 |
|
430 |
-
|
431 |
|
432 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
|
434 |
}
|
435 |
|
@@ -461,7 +473,7 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
|
|
461 |
if ( count( $this->levels[0]['requires'] ) == 1 ) {
|
462 |
|
463 |
$requirement = $this->levels[0]['requires'][0];
|
464 |
-
$having = ( $requirement['by'] != 'count' ) ? 'SUM(
|
465 |
$requirement['type'] = ( $requirement['type'] == '' ) ? MYCRED_DEFAULT_TYPE_KEY : $requirement['type'];
|
466 |
|
467 |
$results = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT user_id, {$having} as total FROM {$mycred_log_table} WHERE ctype = %s AND ref = %s GROUP BY user_id HAVING {$having} >= %f;", $requirement['type'], $requirement['reference'], $requirement['amount'] ) );
|
@@ -470,14 +482,14 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
|
|
470 |
if ( ! empty( $results ) ) {
|
471 |
foreach ( $results as $row ) {
|
472 |
|
473 |
-
$
|
474 |
|
475 |
foreach ( $this->levels as $level_id => $setup ) {
|
476 |
if ( $row->total >= $setup['requires'][0]['amount'] )
|
477 |
-
$
|
478 |
}
|
479 |
|
480 |
-
$
|
481 |
|
482 |
}
|
483 |
}
|
@@ -502,7 +514,7 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
|
|
502 |
if ( ! empty( $level_setup['requires'] ) ) {
|
503 |
foreach ( $level_setup['requires'] as $requirement_id => $requirement ) {
|
504 |
|
505 |
-
$having = ( $requirement['by'] != 'count' ) ? 'SUM(
|
506 |
$requirement['type'] = ( $requirement['type'] == '' ) ? MYCRED_DEFAULT_TYPE_KEY : $requirement['type'];
|
507 |
|
508 |
$level_user_ids[ $requirement_id ] = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT user_id FROM {$mycred_log_table} WHERE ctype = %s AND ref = %s GROUP BY user_id HAVING {$having} >= %f;", $requirement['type'], $requirement['reference'], $requirement['amount'] ) );
|
@@ -571,7 +583,7 @@ if ( ! class_exists( 'myCRED_Badge' ) ) :
|
|
571 |
}
|
572 |
|
573 |
}
|
574 |
-
|
575 |
// Assign results
|
576 |
if ( ! empty( $results ) ) {
|
577 |
|
385 |
// Make sure we only get points once for each level we reach for each badge
|
386 |
if ( ! $mycred->has_entry( 'badge_reward', $this->post_id, $this->user_id, 0, $reward['type'] ) ) {
|
387 |
|
388 |
+
$exec = apply_filters( 'customize_mycred_badge_condition', true, $this->post_id, $this->user_id, $reward['type']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
|
390 |
+
if( $exec ) {
|
391 |
|
392 |
+
$mycred->add_to_log(
|
393 |
+
'badge_reward',
|
394 |
+
$this->user_id,
|
395 |
+
$reward['amount'],
|
396 |
+
$reward['log'],
|
397 |
+
$this->post_id,
|
398 |
+
0,
|
399 |
+
$reward['type']
|
400 |
+
);
|
401 |
+
|
402 |
+
$mycred->update_users_balance( $this->user_id, $reward['amount'], $reward['type'] );
|
403 |
+
|
404 |
+
do_action( 'mycred_badge_rewardes', $this->user_id, $previous_level, $new_level, $reward, $this );
|
405 |
+
|
406 |
+
}
|
407 |
|
408 |
}
|
409 |
|
423 |
// Make sure we only get points once for each level we reach for each badge
|
424 |
if ( ! $mycred->has_entry( 'badge_reward', $this->post_id, $this->user_id, $i, $reward['type'] ) ) {
|
425 |
|
426 |
+
$exec = apply_filters( 'customize_mycred_badge_condition', true, $this->post_id, $this->user_id, $reward['type']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
|
428 |
+
if( $exec ) {
|
429 |
|
430 |
+
$mycred->add_to_log(
|
431 |
+
'badge_reward',
|
432 |
+
$this->user_id,
|
433 |
+
$reward['amount'],
|
434 |
+
$reward['log'],
|
435 |
+
$this->post_id,
|
436 |
+
$i,
|
437 |
+
$reward['type']
|
438 |
+
);
|
439 |
+
|
440 |
+
$mycred->update_users_balance( $this->user_id, $reward['amount'], $reward['type'] );
|
441 |
+
|
442 |
+
do_action( 'mycred_badge_rewardes', $this->user_id, $previous_level, $new_level, $reward, $this );
|
443 |
+
|
444 |
+
}
|
445 |
|
446 |
}
|
447 |
|
473 |
if ( count( $this->levels[0]['requires'] ) == 1 ) {
|
474 |
|
475 |
$requirement = $this->levels[0]['requires'][0];
|
476 |
+
$having = ( $requirement['by'] != 'count' ) ? 'SUM( creds )' : 'COUNT( id )';
|
477 |
$requirement['type'] = ( $requirement['type'] == '' ) ? MYCRED_DEFAULT_TYPE_KEY : $requirement['type'];
|
478 |
|
479 |
$results = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT user_id, {$having} as total FROM {$mycred_log_table} WHERE ctype = %s AND ref = %s GROUP BY user_id HAVING {$having} >= %f;", $requirement['type'], $requirement['reference'], $requirement['amount'] ) );
|
482 |
if ( ! empty( $results ) ) {
|
483 |
foreach ( $results as $row ) {
|
484 |
|
485 |
+
$badge_level_id = 0;
|
486 |
|
487 |
foreach ( $this->levels as $level_id => $setup ) {
|
488 |
if ( $row->total >= $setup['requires'][0]['amount'] )
|
489 |
+
$badge_level_id = $level_id;
|
490 |
}
|
491 |
|
492 |
+
$row->level_id = $badge_level_id;
|
493 |
|
494 |
}
|
495 |
}
|
514 |
if ( ! empty( $level_setup['requires'] ) ) {
|
515 |
foreach ( $level_setup['requires'] as $requirement_id => $requirement ) {
|
516 |
|
517 |
+
$having = ( $requirement['by'] != 'count' ) ? 'SUM( creds )' : 'COUNT( id )';
|
518 |
$requirement['type'] = ( $requirement['type'] == '' ) ? MYCRED_DEFAULT_TYPE_KEY : $requirement['type'];
|
519 |
|
520 |
$level_user_ids[ $requirement_id ] = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT user_id FROM {$mycred_log_table} WHERE ctype = %s AND ref = %s GROUP BY user_id HAVING {$having} >= %f;", $requirement['type'], $requirement['reference'], $requirement['amount'] ) );
|
583 |
}
|
584 |
|
585 |
}
|
586 |
+
|
587 |
// Assign results
|
588 |
if ( ! empty( $results ) ) {
|
589 |
|
addons/buy-creds/modules/buycred-module-pending.php
CHANGED
@@ -247,7 +247,7 @@ if ( ! class_exists( 'buyCRED_Pending_Payments' ) ) :
|
|
247 |
|
248 |
// In case we are using the Master Template feautre on multisites, and this is not the main
|
249 |
// site in the network, bail.
|
250 |
-
if ( mycred_override_settings()
|
251 |
|
252 |
add_submenu_page(
|
253 |
MYCRED_SLUG,
|
247 |
|
248 |
// In case we are using the Master Template feautre on multisites, and this is not the main
|
249 |
// site in the network, bail.
|
250 |
+
if ( mycred_override_settings() ) return;
|
251 |
|
252 |
add_submenu_page(
|
253 |
MYCRED_SLUG,
|
addons/coupons/includes/mycred-coupon-object.php
CHANGED
@@ -262,8 +262,8 @@ if ( ! class_exists( 'myCRED_Coupon' ) ) :
|
|
262 |
// Min balance requirement
|
263 |
if ( $this->requires_min_type != $this->point_type ) {
|
264 |
|
265 |
-
$
|
266 |
-
$users_balance = $
|
267 |
|
268 |
}
|
269 |
|
@@ -275,8 +275,8 @@ if ( ! class_exists( 'myCRED_Coupon' ) ) :
|
|
275 |
|
276 |
if ( $this->requires_max_type != $this->point_type ) {
|
277 |
|
278 |
-
$
|
279 |
-
$users_balance = $
|
280 |
|
281 |
}
|
282 |
|
262 |
// Min balance requirement
|
263 |
if ( $this->requires_min_type != $this->point_type ) {
|
264 |
|
265 |
+
$mycred_min = mycred( $this->requires_min_type );
|
266 |
+
$users_balance = $mycred_min->get_users_balance( $user_id, $this->requires_min_type );
|
267 |
|
268 |
}
|
269 |
|
275 |
|
276 |
if ( $this->requires_max_type != $this->point_type ) {
|
277 |
|
278 |
+
$mycred_max = mycred( $this->requires_max_type );
|
279 |
+
$users_balance = $mycred_max->get_users_balance( $user_id, $this->requires_max_type );
|
280 |
|
281 |
}
|
282 |
|
addons/coupons/includes/mycred-coupon-shortcodes.php
CHANGED
@@ -57,8 +57,12 @@ if ( ! function_exists( 'mycred_render_shortcode_load_coupon' ) ) :
|
|
57 |
// Success!
|
58 |
else {
|
59 |
|
60 |
-
|
61 |
-
$
|
|
|
|
|
|
|
|
|
62 |
$output .= '<div class="alert alert-success">' . $message . '</div>';
|
63 |
|
64 |
}
|
57 |
// Success!
|
58 |
else {
|
59 |
|
60 |
+
//$message = $mycred->template_tags_amount( $mycred->coupons['success'], $coupon->value );
|
61 |
+
$updated_coupon_value=$coupon->value;
|
62 |
+
$updated_coupon_value=apply_filters('mycred_show_custom_coupon_value',$updated_coupon_value);
|
63 |
+
$coupon_settings = mycred_get_addon_settings( 'coupons' , $coupon->point_type );
|
64 |
+
$message = $mycred->template_tags_amount( $coupon_settings['success'], $updated_coupon_value ); // without filter
|
65 |
+
$message = str_replace( '%amount%', $mycred->format_creds( $updated_coupon_value ), $message );
|
66 |
$output .= '<div class="alert alert-success">' . $message . '</div>';
|
67 |
|
68 |
}
|
addons/email-notices/includes/mycred-email-functions.php
CHANGED
@@ -431,7 +431,7 @@ endif;
|
|
431 |
if ( ! function_exists( 'mycred_send_new_email' ) ) :
|
432 |
function mycred_send_new_email( $notice_id = false, $event = array(), $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
433 |
|
434 |
-
if ( $notice_id === false ) return false;
|
435 |
|
436 |
$notice_id = absint( $notice_id );
|
437 |
$email = mycred_get_email_notice( $notice_id );
|
@@ -516,3 +516,31 @@ if ( ! function_exists( 'mycred_email_notice_cron_job' ) ) :
|
|
516 |
|
517 |
}
|
518 |
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
if ( ! function_exists( 'mycred_send_new_email' ) ) :
|
432 |
function mycred_send_new_email( $notice_id = false, $event = array(), $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
433 |
|
434 |
+
if ( $notice_id === false || get_post_status ( $notice_id ) !== 'publish' ) return false;
|
435 |
|
436 |
$notice_id = absint( $notice_id );
|
437 |
$email = mycred_get_email_notice( $notice_id );
|
516 |
|
517 |
}
|
518 |
endif;
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Get Email Settings
|
522 |
+
* @since 1.4
|
523 |
+
* @version 1.0
|
524 |
+
*/
|
525 |
+
if ( ! function_exists( 'mycred_render_email_subscriptions' ) ) :
|
526 |
+
function mycred_get_email_settings( $post_id ) {
|
527 |
+
|
528 |
+
$emailnotices = mycred_get_addon_settings( 'emailnotices' );
|
529 |
+
$settings = (array) mycred_get_post_meta( $post_id, 'mycred_email_settings', true );
|
530 |
+
|
531 |
+
if ( $settings == '' || empty($settings) )
|
532 |
+
$settings = array();
|
533 |
+
|
534 |
+
// Defaults
|
535 |
+
$default = array(
|
536 |
+
'recipient' => 'user',
|
537 |
+
'senders_name' => $emailnotices['from']['name'],
|
538 |
+
'senders_email' => $emailnotices['from']['email'],
|
539 |
+
'reply_to' => $emailnotices['from']['reply_to'],
|
540 |
+
'label' => get_the_title($post_id)
|
541 |
+
);
|
542 |
+
|
543 |
+
$settings = mycred_apply_defaults( $default, $settings );
|
544 |
+
return apply_filters( 'mycred_email_notice_settings', $settings, $post_id );
|
545 |
+
}
|
546 |
+
endif;
|
addons/email-notices/includes/mycred-email-object.php
CHANGED
@@ -374,8 +374,14 @@ if ( ! class_exists( 'myCRED_Email' ) ) :
|
|
374 |
}
|
375 |
|
376 |
// Template tags can only be used if the email triggers for one point type only.
|
|
|
377 |
$content = $mycred->template_tags_amount( $content, $event['amount'] );
|
378 |
-
|
|
|
|
|
|
|
|
|
|
|
379 |
|
380 |
if ( array_key_exists( 'data', $event ) && is_array($event['data']) && ! empty( $event['data'] ) && array_key_exists( 'ref_type', $event['data'] ) && $event['data']['ref_type'] == 'post' )
|
381 |
$content = $mycred->template_tags_post( $content, $event['ref_id'] );
|
@@ -384,7 +390,7 @@ if ( ! class_exists( 'myCRED_Email' ) ) :
|
|
384 |
$content = str_replace( '%new_balance%', $mycred->format_creds( $event['new'] ), $content );
|
385 |
$content = str_replace( '%old_balance%', $mycred->format_creds( $event['old'] ), $content );
|
386 |
|
387 |
-
|
388 |
|
389 |
$content = str_replace( '%blog_name%', get_option( 'blogname' ), $content );
|
390 |
$content = str_replace( '%blog_url%', get_option( 'home' ), $content );
|
374 |
}
|
375 |
|
376 |
// Template tags can only be used if the email triggers for one point type only.
|
377 |
+
$content = str_replace( '%entry%', $event['entry'], $content );
|
378 |
$content = $mycred->template_tags_amount( $content, $event['amount'] );
|
379 |
+
// to display correct user names in transfer email
|
380 |
+
if($event['ref']==='transfer'){
|
381 |
+
$content = $mycred->template_tags_user( $content, $event['ref_id'] );
|
382 |
+
}else{
|
383 |
+
$content = $mycred->template_tags_user( $content, $event['user_id'] );
|
384 |
+
}
|
385 |
|
386 |
if ( array_key_exists( 'data', $event ) && is_array($event['data']) && ! empty( $event['data'] ) && array_key_exists( 'ref_type', $event['data'] ) && $event['data']['ref_type'] == 'post' )
|
387 |
$content = $mycred->template_tags_post( $content, $event['ref_id'] );
|
390 |
$content = str_replace( '%new_balance%', $mycred->format_creds( $event['new'] ), $content );
|
391 |
$content = str_replace( '%old_balance%', $mycred->format_creds( $event['old'] ), $content );
|
392 |
|
393 |
+
|
394 |
|
395 |
$content = str_replace( '%blog_name%', get_option( 'blogname' ), $content );
|
396 |
$content = str_replace( '%blog_url%', get_option( 'home' ), $content );
|
addons/email-notices/includes/mycred-email-shortcodes.php
CHANGED
@@ -13,7 +13,7 @@ if ( ! function_exists( 'mycred_render_email_subscriptions' ) ) :
|
|
13 |
|
14 |
extract( shortcode_atts( array(
|
15 |
'success' => __( 'Settings Updated', 'mycred' )
|
16 |
-
), $
|
17 |
|
18 |
if ( ! is_user_logged_in() ) return $content;
|
19 |
|
@@ -69,10 +69,10 @@ if ( ! function_exists( 'mycred_render_email_subscriptions' ) ) :
|
|
69 |
<tbody>
|
70 |
|
71 |
<?php if ( ! empty( $email_notices ) ) : ?>
|
72 |
-
|
73 |
-
<?php foreach ( $email_notices as $notice ) : $settings = $this->get_email_settings( $notice->ID ); ?>
|
74 |
|
75 |
-
<?php
|
|
|
|
|
76 |
|
77 |
<tr>
|
78 |
<td class="check"><input type="checkbox" name="mycred_email_unsubscribe[]"<?php if ( in_array( $notice->ID, $unsubscriptions ) ) echo ' checked="checked"'; ?> value="<?php echo $notice->ID; ?>" /></td>
|
@@ -98,7 +98,7 @@ if ( ! function_exists( 'mycred_render_email_subscriptions' ) ) :
|
|
98 |
$content = ob_get_contents();
|
99 |
ob_end_clean();
|
100 |
|
101 |
-
return apply_filters( 'mycred_render_email_subscriptions', $content, $
|
102 |
|
103 |
}
|
104 |
-
endif;
|
13 |
|
14 |
extract( shortcode_atts( array(
|
15 |
'success' => __( 'Settings Updated', 'mycred' )
|
16 |
+
), $atts, MYCRED_SLUG . '_email_subscriptions' ) );
|
17 |
|
18 |
if ( ! is_user_logged_in() ) return $content;
|
19 |
|
69 |
<tbody>
|
70 |
|
71 |
<?php if ( ! empty( $email_notices ) ) : ?>
|
|
|
|
|
72 |
|
73 |
+
<?php foreach ( $email_notices as $notice ) : $settings = mycred_get_email_settings( $notice->ID ); ?>
|
74 |
+
|
75 |
+
<?php if ( $settings['recipient'] == 'admin' ) continue; ?>
|
76 |
|
77 |
<tr>
|
78 |
<td class="check"><input type="checkbox" name="mycred_email_unsubscribe[]"<?php if ( in_array( $notice->ID, $unsubscriptions ) ) echo ' checked="checked"'; ?> value="<?php echo $notice->ID; ?>" /></td>
|
98 |
$content = ob_get_contents();
|
99 |
ob_end_clean();
|
100 |
|
101 |
+
return apply_filters( 'mycred_render_email_subscriptions', $content, $atts );
|
102 |
|
103 |
}
|
104 |
+
endif;
|
addons/ranks/includes/mycred-rank-functions.php
CHANGED
@@ -476,11 +476,11 @@ if ( ! function_exists( 'mycred_assign_ranks' ) ) :
|
|
476 |
if ( mycred_manual_ranks() ) return 0;
|
477 |
|
478 |
global $wpdb;
|
479 |
-
|
480 |
$type_object = new myCRED_Point_Type( $point_type );
|
481 |
$rank_key = mycred_get_meta_key( MYCRED_RANK_KEY, ( ( $point_type != MYCRED_DEFAULT_TYPE_KEY ) ? $point_type : '' ) );
|
482 |
|
483 |
$balance_key = mycred_get_meta_key( $point_type );
|
|
|
484 |
if ( isset( $mycred->rank['base'] ) && $mycred->rank['base'] == 'total' )
|
485 |
$balance_key = mycred_get_meta_key( $point_type, '_total' );
|
486 |
|
476 |
if ( mycred_manual_ranks() ) return 0;
|
477 |
|
478 |
global $wpdb;
|
|
|
479 |
$type_object = new myCRED_Point_Type( $point_type );
|
480 |
$rank_key = mycred_get_meta_key( MYCRED_RANK_KEY, ( ( $point_type != MYCRED_DEFAULT_TYPE_KEY ) ? $point_type : '' ) );
|
481 |
|
482 |
$balance_key = mycred_get_meta_key( $point_type );
|
483 |
+
$mycred = mycred( $point_type );
|
484 |
if ( isset( $mycred->rank['base'] ) && $mycred->rank['base'] == 'total' )
|
485 |
$balance_key = mycred_get_meta_key( $point_type, '_total' );
|
486 |
|
addons/ranks/includes/mycred-rank-shortcodes.php
CHANGED
@@ -211,7 +211,7 @@ if ( ! function_exists( 'mycred_render_users_of_all_ranks' ) ) :
|
|
211 |
extract( shortcode_atts( array(
|
212 |
'login' => '',
|
213 |
'number' => 10,
|
214 |
-
'ctype' =>
|
215 |
'show_logo' => 1,
|
216 |
'logo_size' => 'post-thumbnail',
|
217 |
'wrap' => 'div',
|
211 |
extract( shortcode_atts( array(
|
212 |
'login' => '',
|
213 |
'number' => 10,
|
214 |
+
'ctype' => MYCRED_DEFAULT_TYPE_KEY,
|
215 |
'show_logo' => 1,
|
216 |
'logo_size' => 'post-thumbnail',
|
217 |
'wrap' => 'div',
|
addons/ranks/myCRED-addon-ranks.php
CHANGED
@@ -627,7 +627,7 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
|
|
627 |
wp_cache_delete( 'ranks-published-' . $point_type, MYCRED_SLUG );
|
628 |
wp_cache_delete( 'ranks-published-count-' . $point_type, MYCRED_SLUG );
|
629 |
|
630 |
-
mycred_assign_ranks( $
|
631 |
|
632 |
}
|
633 |
|
@@ -1007,8 +1007,8 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
|
|
1007 |
echo '>' . __( 'No rank', 'mycred' ) . '</option>';
|
1008 |
|
1009 |
foreach ( $ranks as $rank ) {
|
1010 |
-
echo '<option value="' . $rank->
|
1011 |
-
if ( $users_rank->
|
1012 |
echo '>' . $rank->title . '</option>';
|
1013 |
}
|
1014 |
|
@@ -1603,7 +1603,7 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
|
|
1603 |
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
|
1604 |
<div class="form-group">
|
1605 |
<div class="radio">
|
1606 |
-
<label for="<?php echo $this->field_id( array( 'base' => 'manual' ) ); ?>"><input type="radio" name="<?php echo $this->field_name( 'base' ); ?>" id="<?php echo $this->field_id( array( 'base' => 'manual' ) ); ?>"<?php checked( $prefs['base'], 'manual' ); ?> value="
|
1607 |
</div>
|
1608 |
<p><span class="description"><?php _e( 'Ranks are assigned manually for each user.', 'mycred' ); ?></span></p>
|
1609 |
</div>
|
627 |
wp_cache_delete( 'ranks-published-' . $point_type, MYCRED_SLUG );
|
628 |
wp_cache_delete( 'ranks-published-count-' . $point_type, MYCRED_SLUG );
|
629 |
|
630 |
+
mycred_assign_ranks( $point_type );
|
631 |
|
632 |
}
|
633 |
|
1007 |
echo '>' . __( 'No rank', 'mycred' ) . '</option>';
|
1008 |
|
1009 |
foreach ( $ranks as $rank ) {
|
1010 |
+
echo '<option value="' . $rank->post_id . '"';
|
1011 |
+
if ( $users_rank->post_id == $rank->post_id ) echo ' selected="selected"';
|
1012 |
echo '>' . $rank->title . '</option>';
|
1013 |
}
|
1014 |
|
1603 |
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
|
1604 |
<div class="form-group">
|
1605 |
<div class="radio">
|
1606 |
+
<label for="<?php echo $this->field_id( array( 'base' => 'manual' ) ); ?>"><input type="radio" name="<?php echo $this->field_name( 'base' ); ?>" id="<?php echo $this->field_id( array( 'base' => 'manual' ) ); ?>"<?php checked( $prefs['base'], 'manual' ); ?> value="manual" /> <?php _e( 'Manual Mode', 'mycred' ); ?></label>
|
1607 |
</div>
|
1608 |
<p><span class="description"><?php _e( 'Ranks are assigned manually for each user.', 'mycred' ); ?></span></p>
|
1609 |
</div>
|
addons/transfer/includes/mycred-transfer-functions.php
CHANGED
@@ -315,7 +315,7 @@ if ( ! function_exists( 'mycred_transfer_render_message' ) ) :
|
|
315 |
if ( empty( $original ) || empty( $data ) ) return $original;
|
316 |
|
317 |
// Default message
|
318 |
-
$message = apply_filters( 'mycred_transfer_default_message',
|
319 |
|
320 |
// Get saved message
|
321 |
if ( ! empty( $data ) && array_key_exists( 'message', $data ) && ! empty( $data['message'] ) )
|
315 |
if ( empty( $original ) || empty( $data ) ) return $original;
|
316 |
|
317 |
// Default message
|
318 |
+
$message = apply_filters( 'mycred_transfer_default_message', $original, $data );
|
319 |
|
320 |
// Get saved message
|
321 |
if ( ! empty( $data ) && array_key_exists( 'message', $data ) && ! empty( $data['message'] ) )
|
addons/transfer/includes/mycred-transfer-object.php
CHANGED
@@ -584,7 +584,7 @@ if ( ! class_exists( 'myCRED_Transfer' ) ) :
|
|
584 |
'ctype' => MYCRED_DEFAULT_TYPE_KEY,
|
585 |
'amount' => NULL,
|
586 |
'reference' => 'transfer',
|
587 |
-
'message' => ''
|
588 |
), $posted ), $request );
|
589 |
|
590 |
// Security
|
@@ -925,8 +925,9 @@ if ( ! class_exists( 'myCRED_Transfer' ) ) :
|
|
925 |
if ( $this->args['recipient_label'] != '' ) $field .= '<label>' . esc_html( $this->args['recipient_label'] ) . '</label>';
|
926 |
|
927 |
// No recipient, one needs to be nominated
|
928 |
-
if ( count( $recipients )
|
929 |
$field .= '<input type="text" name="mycred_new_transfer[recipient_id]" value="" aria-required="true" class="mycred-autofill form-control" data-form="' . esc_attr( $this->reference ) . '" placeholder="' . $placeholder . '" />';
|
|
|
930 |
|
931 |
// One specific recipient is set
|
932 |
elseif ( count( $recipients ) == 1 ) {
|
@@ -996,7 +997,7 @@ if ( ! class_exists( 'myCRED_Transfer' ) ) :
|
|
996 |
$field .= $this->get_transfer_amount_field( true );
|
997 |
$field .= '</div>';
|
998 |
|
999 |
-
$field
|
1000 |
$field .= $this->get_transfer_point_type_field( true );
|
1001 |
$field .= '</div>';
|
1002 |
|
584 |
'ctype' => MYCRED_DEFAULT_TYPE_KEY,
|
585 |
'amount' => NULL,
|
586 |
'reference' => 'transfer',
|
587 |
+
'message' => isset( $posted['message'] ) ? $posted['message'] : ''
|
588 |
), $posted ), $request );
|
589 |
|
590 |
// Security
|
925 |
if ( $this->args['recipient_label'] != '' ) $field .= '<label>' . esc_html( $this->args['recipient_label'] ) . '</label>';
|
926 |
|
927 |
// No recipient, one needs to be nominated
|
928 |
+
if ( count( $recipients ) < 1 ) {
|
929 |
$field .= '<input type="text" name="mycred_new_transfer[recipient_id]" value="" aria-required="true" class="mycred-autofill form-control" data-form="' . esc_attr( $this->reference ) . '" placeholder="' . $placeholder . '" />';
|
930 |
+
}
|
931 |
|
932 |
// One specific recipient is set
|
933 |
elseif ( count( $recipients ) == 1 ) {
|
997 |
$field .= $this->get_transfer_amount_field( true );
|
998 |
$field .= '</div>';
|
999 |
|
1000 |
+
$field .= '<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">';
|
1001 |
$field .= $this->get_transfer_point_type_field( true );
|
1002 |
$field .= '</div>';
|
1003 |
|
includes/classes/class.query-leaderboard.php
CHANGED
@@ -70,6 +70,7 @@ if ( ! class_exists( 'myCRED_Query_Leaderboard' ) ) :
|
|
70 |
'offset' => 0,
|
71 |
'type' => MYCRED_DEFAULT_TYPE_KEY,
|
72 |
'timeframe' => '',
|
|
|
73 |
'now' => $this->now,
|
74 |
'order' => 'DESC',
|
75 |
'total' => 0,
|
@@ -166,6 +167,9 @@ if ( ! class_exists( 'myCRED_Query_Leaderboard' ) ) :
|
|
166 |
|
167 |
// Timeframe
|
168 |
$this->args['timeframe'] = ( MYCRED_ENABLE_LOGGING ) ? sanitize_text_field( $args['timeframe'] ) : '';
|
|
|
|
|
|
|
169 |
$this->args['now'] = ( $args['now'] != '' ) ? absint( $args['now'] ) : $this->now;
|
170 |
|
171 |
// Order
|
@@ -735,8 +739,14 @@ if ( ! class_exists( 'myCRED_Query_Leaderboard' ) ) :
|
|
735 |
else {
|
736 |
|
737 |
$start_from = strtotime( $this->args['timeframe'], $this->now );
|
738 |
-
|
739 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
740 |
|
741 |
}
|
742 |
|
70 |
'offset' => 0,
|
71 |
'type' => MYCRED_DEFAULT_TYPE_KEY,
|
72 |
'timeframe' => '',
|
73 |
+
'to' => '',
|
74 |
'now' => $this->now,
|
75 |
'order' => 'DESC',
|
76 |
'total' => 0,
|
167 |
|
168 |
// Timeframe
|
169 |
$this->args['timeframe'] = ( MYCRED_ENABLE_LOGGING ) ? sanitize_text_field( $args['timeframe'] ) : '';
|
170 |
+
// To
|
171 |
+
|
172 |
+
$this->args['to'] = ( MYCRED_ENABLE_LOGGING ) ? sanitize_text_field( $args['to'] ) : '';
|
173 |
$this->args['now'] = ( $args['now'] != '' ) ? absint( $args['now'] ) : $this->now;
|
174 |
|
175 |
// Order
|
739 |
else {
|
740 |
|
741 |
$start_from = strtotime( $this->args['timeframe'], $this->now );
|
742 |
+
|
743 |
+
if ( $start_from !== false && $start_from > 0 ) {
|
744 |
+
$end_to = $this->args['to'] != '' ? strtotime(date($this->args['to']." 23:59:59")) : 0;
|
745 |
+
if ($end_to === false || $end_to <= 0 ) {
|
746 |
+
$end_to = $this->args['now'];
|
747 |
+
}
|
748 |
+
$query = $wpdb->prepare( "AND l.time BETWEEN %d AND %d", $start_from, $end_to );
|
749 |
+
}
|
750 |
|
751 |
}
|
752 |
|
includes/classes/class.query-log.php
CHANGED
@@ -403,7 +403,7 @@ if ( ! class_exists( 'myCRED_Query_Log' ) ) :
|
|
403 |
|
404 |
// IN or NOT IN comparisons
|
405 |
if ( in_array( $this->args['entry_id']['compare'], array( 'IN', 'NOT IN' ) ) && is_array( $this->args['entry_id']['ids'] ) )
|
406 |
-
$wheres[] = $wpdb->prepare( "id
|
407 |
|
408 |
// All other supported comparisons
|
409 |
elseif ( in_array( $this->args['entry_id']['compare'], array( '=', '!=' ) ) && ! is_array( $this->args['entry_id']['ids'] ) ) {
|
403 |
|
404 |
// IN or NOT IN comparisons
|
405 |
if ( in_array( $this->args['entry_id']['compare'], array( 'IN', 'NOT IN' ) ) && is_array( $this->args['entry_id']['ids'] ) )
|
406 |
+
$wheres[] = $wpdb->prepare( "id ".$this->args['entry_id']['compare']." ( %d" . str_repeat( ", %d", ( count( $this->args['entry_id']['ids'] ) - 1 ) ) . " )", $this->args['entry_id']['ids'] );
|
407 |
|
408 |
// All other supported comparisons
|
409 |
elseif ( in_array( $this->args['entry_id']['compare'], array( '=', '!=' ) ) && ! is_array( $this->args['entry_id']['ids'] ) ) {
|
includes/hooks/external/mycred-hook-buddypress.php
CHANGED
@@ -153,7 +153,7 @@ function mycred_load_buddypress_profile_hook() {
|
|
153 |
add_action( 'bp_activity_comment_posted', array( $this, 'new_comment' ), 10, 2 );
|
154 |
|
155 |
if ( $this->prefs['delete_comment']['creds'] != 0 )
|
156 |
-
add_action( '
|
157 |
|
158 |
if ( $this->prefs['add_favorite']['creds'] != 0 )
|
159 |
add_action( 'bp_activity_add_user_favorite', array( $this, 'add_to_favorites' ), 10, 2 );
|
@@ -465,22 +465,30 @@ function mycred_load_buddypress_profile_hook() {
|
|
465 |
*/
|
466 |
public function delete_comment( $activity_id, $user_id ) {
|
467 |
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
if
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
|
485 |
}
|
486 |
|
@@ -824,7 +832,7 @@ function mycred_load_buddypress_profile_hook() {
|
|
824 |
</div>
|
825 |
</div>
|
826 |
<div class="hook-instance">
|
827 |
-
<h3><?php _e( 'Removing
|
828 |
<div class="row">
|
829 |
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
830 |
<div class="form-group">
|
153 |
add_action( 'bp_activity_comment_posted', array( $this, 'new_comment' ), 10, 2 );
|
154 |
|
155 |
if ( $this->prefs['delete_comment']['creds'] != 0 )
|
156 |
+
add_action( 'bp_activity_before_action_delete_activity', array( $this, 'delete_comment' ), 10, 2 );
|
157 |
|
158 |
if ( $this->prefs['add_favorite']['creds'] != 0 )
|
159 |
add_action( 'bp_activity_add_user_favorite', array( $this, 'add_to_favorites' ), 10, 2 );
|
465 |
*/
|
466 |
public function delete_comment( $activity_id, $user_id ) {
|
467 |
|
468 |
+
global $wpdb, $bp;
|
469 |
+
|
470 |
+
$activity_type = $wpdb->get_var( $wpdb->prepare( "SELECT type FROM {$bp->activity->table_name} WHERE id = %d", $activity_id ) );
|
471 |
+
|
472 |
+
if( $activity_type == 'activity_comment' ) {
|
473 |
+
|
474 |
+
// Check if user is excluded
|
475 |
+
if ( $this->core->exclude_user( $user_id ) ) return;
|
476 |
+
|
477 |
+
// Make sure this is unique event
|
478 |
+
if ( $this->core->has_entry( 'comment_deletion', $activity_id ) ) return;
|
479 |
+
|
480 |
+
// Execute
|
481 |
+
$this->core->add_creds(
|
482 |
+
'comment_deletion',
|
483 |
+
$user_id,
|
484 |
+
$this->prefs['delete_comment']['creds'],
|
485 |
+
$this->prefs['delete_comment']['log'],
|
486 |
+
$activity_id,
|
487 |
+
'bp_comment',
|
488 |
+
$this->mycred_type
|
489 |
+
);
|
490 |
+
|
491 |
+
}
|
492 |
|
493 |
}
|
494 |
|
832 |
</div>
|
833 |
</div>
|
834 |
<div class="hook-instance">
|
835 |
+
<h3><?php _e( 'Removing Favorite Activity', 'mycred' ); ?></h3>
|
836 |
<div class="row">
|
837 |
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
838 |
<div class="form-group">
|
includes/shortcodes/mycred_hook_table.php
CHANGED
@@ -54,8 +54,14 @@ if ( ! function_exists( 'mycred_render_shortcode_hook_table' ) ) :
|
|
54 |
|
55 |
if ( ! isset( $instance_prefs['creds'] ) ) continue;
|
56 |
|
57 |
-
if ( ( $gains == 1 && $instance_prefs['creds'] > 0 ) || ( $gains == 0 && $instance_prefs['creds'] < 0 ) )
|
58 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
}
|
61 |
|
54 |
|
55 |
if ( ! isset( $instance_prefs['creds'] ) ) continue;
|
56 |
|
57 |
+
if ( ( $gains == 1 && $instance_prefs['creds'] > 0 ) || ( $gains == 0 && $instance_prefs['creds'] < 0 ) ){
|
58 |
+
if($active_hook_id==='deleted_content' || $active_hook_id==='publishing_content' || $active_hook_id==='view_contents' ){
|
59 |
+
$applicable[ $active_hook_id."_".$instance_id ] = $instance_prefs;
|
60 |
+
}
|
61 |
+
else{
|
62 |
+
$applicable[ $instance_id ] = $instance_prefs;
|
63 |
+
}
|
64 |
+
}
|
65 |
|
66 |
}
|
67 |
|
includes/shortcodes/mycred_leaderboard.php
CHANGED
@@ -22,7 +22,8 @@ if ( ! function_exists( 'mycred_render_shortcode_leaderboard' ) ) :
|
|
22 |
'nothing' => 'Leaderboard is empty',
|
23 |
'current' => 0,
|
24 |
'exclude_zero' => 1,
|
25 |
-
'timeframe' => ''
|
|
|
26 |
), $atts, MYCRED_SLUG . '_leaderboard' );
|
27 |
|
28 |
// Construct the leaderboard class
|
22 |
'nothing' => 'Leaderboard is empty',
|
23 |
'current' => 0,
|
24 |
'exclude_zero' => 1,
|
25 |
+
'timeframe' => '',
|
26 |
+
'to' => ''
|
27 |
), $atts, MYCRED_SLUG . '_leaderboard' );
|
28 |
|
29 |
// Construct the leaderboard class
|
includes/widgets/mycred-widget-leaderboard.php
CHANGED
@@ -33,7 +33,7 @@ if ( ! class_exists( 'myCRED_Widget_Leaderboard' ) ) :
|
|
33 |
extract( $args, EXTR_SKIP );
|
34 |
|
35 |
// Check if we want to show this to visitors
|
36 |
-
if ( ! $instance['show_visitors'] && ! is_user_logged_in() ) return;
|
37 |
|
38 |
if ( ! isset( $instance['type'] ) || empty( $instance['type'] ) )
|
39 |
$instance['type'] = MYCRED_DEFAULT_TYPE_KEY;
|
33 |
extract( $args, EXTR_SKIP );
|
34 |
|
35 |
// Check if we want to show this to visitors
|
36 |
+
if ( (! isset($instance['show_visitors']) || ! $instance['show_visitors']) && ! is_user_logged_in() ) return;
|
37 |
|
38 |
if ( ! isset( $instance['type'] ) || empty( $instance['type'] ) )
|
39 |
$instance['type'] = MYCRED_DEFAULT_TYPE_KEY;
|
modules/mycred-module-caching.php
CHANGED
@@ -202,7 +202,7 @@ if ( ! class_exists( 'myCRED_Caching_Module' ) ) :
|
|
202 |
$this->clear_cache( $cache );
|
203 |
|
204 |
|
205 |
-
|
206 |
wp_send_json_success( $description );
|
207 |
|
208 |
}
|
@@ -220,7 +220,7 @@ if ( ! class_exists( 'myCRED_Caching_Module' ) ) :
|
|
220 |
$cache_id = apply_filters( 'mycred_get_cache_id', $cache_id, $cache_type, $this );
|
221 |
|
222 |
$cache_keys = mycred_get_option( $cache_id, array() );
|
223 |
-
if ( empty( $cache_keys ) ) {
|
224 |
|
225 |
foreach ( $cache_keys as $key )
|
226 |
wp_cache_delete( $key, MYCRED_SLUG );
|
202 |
$this->clear_cache( $cache );
|
203 |
|
204 |
|
205 |
+
$description =array("success");
|
206 |
wp_send_json_success( $description );
|
207 |
|
208 |
}
|
220 |
$cache_id = apply_filters( 'mycred_get_cache_id', $cache_id, $cache_type, $this );
|
221 |
|
222 |
$cache_keys = mycred_get_option( $cache_id, array() );
|
223 |
+
if ( !empty( $cache_keys ) ) {
|
224 |
|
225 |
foreach ( $cache_keys as $key )
|
226 |
wp_cache_delete( $key, MYCRED_SLUG );
|
modules/mycred-module-hooks.php
CHANGED
@@ -170,7 +170,7 @@ if ( ! class_exists( 'myCRED_Hooks_Module' ) ) :
|
|
170 |
'installed' => $installed,
|
171 |
'hook_prefs' => $this->hook_prefs
|
172 |
);
|
173 |
-
mycred_update_option( $option_id, $new_data );
|
174 |
}
|
175 |
|
176 |
$this->installed = $installed;
|
@@ -553,7 +553,7 @@ jQuery(function($) {
|
|
553 |
$this->active = $active_hooks;
|
554 |
|
555 |
// Update our settings to activate the hook(s)
|
556 |
-
mycred_update_option( $option_id, array(
|
557 |
'active' => $this->active,
|
558 |
'installed' => $installed,
|
559 |
'hook_prefs' => $this->hook_prefs
|
@@ -615,7 +615,7 @@ jQuery(function($) {
|
|
615 |
}
|
616 |
|
617 |
// Update our settings to activate the hook(s)
|
618 |
-
mycred_update_option( $option_id, array(
|
619 |
'active' => $this->active,
|
620 |
'installed' => $installed,
|
621 |
'hook_prefs' => $this->hook_prefs
|
170 |
'installed' => $installed,
|
171 |
'hook_prefs' => $this->hook_prefs
|
172 |
);
|
173 |
+
mycred_update_option( $this->option_id, $new_data );
|
174 |
}
|
175 |
|
176 |
$this->installed = $installed;
|
553 |
$this->active = $active_hooks;
|
554 |
|
555 |
// Update our settings to activate the hook(s)
|
556 |
+
mycred_update_option( $this->option_id, array(
|
557 |
'active' => $this->active,
|
558 |
'installed' => $installed,
|
559 |
'hook_prefs' => $this->hook_prefs
|
615 |
}
|
616 |
|
617 |
// Update our settings to activate the hook(s)
|
618 |
+
mycred_update_option( $this->option_id, array(
|
619 |
'active' => $this->active,
|
620 |
'installed' => $installed,
|
621 |
'hook_prefs' => $this->hook_prefs
|
mycred.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
* Plugin Name: myCRED
|
4 |
* Plugin URI: https://mycred.me
|
5 |
* Description: An adaptive points management system for WordPress powered websites.
|
6 |
-
* Version: 1.8.
|
7 |
* Tags: point, credit, loyalty program, engagement, reward, woocommerce rewards
|
8 |
* Author: myCRED
|
9 |
* Author URI: https://mycred.me
|
10 |
* Author Email: support@mycred.me
|
11 |
* Requires at least: WP 4.8
|
12 |
-
* Tested up to: WP 5.2
|
13 |
* Text Domain: mycred
|
14 |
* Domain Path: /lang
|
15 |
* License: GPLv2 or later
|
@@ -19,7 +19,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
|
|
19 |
final class myCRED_Core {
|
20 |
|
21 |
// Plugin Version
|
22 |
-
public $version = '1.8.
|
23 |
|
24 |
// Instnace
|
25 |
protected static $_instance = NULL;
|
3 |
* Plugin Name: myCRED
|
4 |
* Plugin URI: https://mycred.me
|
5 |
* Description: An adaptive points management system for WordPress powered websites.
|
6 |
+
* Version: 1.8.5
|
7 |
* Tags: point, credit, loyalty program, engagement, reward, woocommerce rewards
|
8 |
* Author: myCRED
|
9 |
* Author URI: https://mycred.me
|
10 |
* Author Email: support@mycred.me
|
11 |
* Requires at least: WP 4.8
|
12 |
+
* Tested up to: WP 5.2.3
|
13 |
* Text Domain: mycred
|
14 |
* Domain Path: /lang
|
15 |
* License: GPLv2 or later
|
19 |
final class myCRED_Core {
|
20 |
|
21 |
// Plugin Version
|
22 |
+
public $version = '1.8.5';
|
23 |
|
24 |
// Instnace
|
25 |
protected static $_instance = NULL;
|
plugins/index.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Silence is golden.
|
3 |
-
?>
|
|
|
|
|
|
plugins/mycred-hook-affiliatewp.php
DELETED
@@ -1,407 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.6
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_affiliatewp_hook', 10 );
|
10 |
-
function mycred_register_affiliatewp_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! class_exists( 'Affiliate_WP' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['affiliatewp'] = array(
|
15 |
-
'title' => __( 'AffiliateWP', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for affiliate signups, referring visitors and store sale referrals.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/affiliatewp-actions/',
|
18 |
-
'callback' => array( 'myCRED_AffiliateWP' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Affiliate WP Hook
|
27 |
-
* @since 1.6
|
28 |
-
* @version 1.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_affiliatewp_hook', 10 );
|
31 |
-
function mycred_load_affiliatewp_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_AffiliateWP' ) || ! class_exists( 'Affiliate_WP' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_AffiliateWP extends myCRED_Hook {
|
37 |
-
|
38 |
-
public $currency;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Construct
|
42 |
-
*/
|
43 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
44 |
-
|
45 |
-
parent::__construct( array(
|
46 |
-
'id' => 'affiliatewp',
|
47 |
-
'defaults' => array(
|
48 |
-
'signup' => array(
|
49 |
-
'creds' => 0,
|
50 |
-
'log' => '%plural% for becoming an affiliate'
|
51 |
-
),
|
52 |
-
'visits' => array(
|
53 |
-
'creds' => 0,
|
54 |
-
'log' => '%plural% for referral of a visitor',
|
55 |
-
'limit' => '0/x'
|
56 |
-
),
|
57 |
-
'referrals' => array(
|
58 |
-
'creds' => 0,
|
59 |
-
'exchange' => 1,
|
60 |
-
'currency' => 'MYC',
|
61 |
-
'log' => '%plural% for store referral',
|
62 |
-
'remove_log' => '%plural% refund for rejected sale',
|
63 |
-
'pay' => 'amount'
|
64 |
-
)
|
65 |
-
)
|
66 |
-
), $hook_prefs, $type );
|
67 |
-
|
68 |
-
$this->currency = affiliate_wp()->settings->get( 'currency', 'USD' );
|
69 |
-
|
70 |
-
// We might want to add a custom currency code
|
71 |
-
add_filter( 'affwp_currencies', array( $this, 'add_currency' ) );
|
72 |
-
|
73 |
-
// A custom currency code has been set and is used in AffiliateWP!
|
74 |
-
// We need to take over the way currencies are shown in AffiliateWP
|
75 |
-
if ( ! empty( $this->prefs['referrals']['currency'] ) && $this->currency == $this->prefs['referrals']['currency'] ) {
|
76 |
-
add_filter( 'affwp_format_amount', array( $this, 'amount' ) );
|
77 |
-
add_filter( 'affwp_sanitize_amount_decimals', array( $this, 'decimals' ) );
|
78 |
-
add_filter( 'affwp_' . $this->currency . '_currency_filter_before', array( $this, 'before' ), 10, 3 );
|
79 |
-
add_filter( 'affwp_' . $this->currency . '_currency_filter_after', array( $this, 'after' ), 10, 3 );
|
80 |
-
}
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
public function add_currency( $currencies ) {
|
85 |
-
|
86 |
-
if ( $this->prefs['referrals']['pay'] == 'currency' && ! empty( $this->prefs['referrals']['currency'] ) && ! array_key_exists( $this->prefs['referrals']['currency'], $currencies ) )
|
87 |
-
$currencies[ $this->prefs['referrals']['currency'] ] = $this->core->plural();
|
88 |
-
|
89 |
-
return $currencies;
|
90 |
-
|
91 |
-
}
|
92 |
-
|
93 |
-
public function amount( $amount ) {
|
94 |
-
|
95 |
-
// Format myCRED way
|
96 |
-
return $this->core->format_number( $amount );
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
public function before( $formatted, $currency, $amount ) {
|
101 |
-
|
102 |
-
// No need to add if empty
|
103 |
-
if ( $this->core->before != '' )
|
104 |
-
$formatted = $this->core->before . ' ' . $amount;
|
105 |
-
|
106 |
-
// Some might have applied adjustments how points are shown, apply them here as well
|
107 |
-
return apply_filters( 'mycred_format_creds', $formatted, $amount, $this->core );
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
public function after( $formatted, $currency, $amount ) {
|
112 |
-
|
113 |
-
// No need to add if empty
|
114 |
-
if ( $this->core->after != '' )
|
115 |
-
$formatted = $amount . ' ' . $this->core->after;
|
116 |
-
|
117 |
-
// Some might have applied adjustments how points are shown, apply them here as well
|
118 |
-
return apply_filters( 'mycred_format_creds', $formatted, $amount, $this->core );
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
public function decimals( $decimals ) {
|
123 |
-
|
124 |
-
// Get decimal setup
|
125 |
-
return absint( $this->core->format['decimals'] );
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Run
|
131 |
-
* @since 1.6
|
132 |
-
* @version 1.0.1
|
133 |
-
*/
|
134 |
-
public function run() {
|
135 |
-
|
136 |
-
// If we reward affiliate signups
|
137 |
-
if ( $this->prefs['signup']['creds'] != 0 )
|
138 |
-
add_action( 'affwp_register_user', array( $this, 'affiliate_signup' ), 10, 3 );
|
139 |
-
|
140 |
-
// If we reward visit referrals
|
141 |
-
if ( $this->prefs['visits']['creds'] != 0 )
|
142 |
-
add_action( 'affwp_post_insert_visit', array( $this, 'new_visit' ), 10, 2 );
|
143 |
-
|
144 |
-
// If we reward referrals
|
145 |
-
add_action( 'affwp_set_referral_status', array( $this, 'referral_payouts' ), 10, 3 );
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Affiliate Signup
|
151 |
-
* @since 1.6
|
152 |
-
* @version 1.0
|
153 |
-
*/
|
154 |
-
public function affiliate_signup( $affiliate_id, $status, $args ) {
|
155 |
-
|
156 |
-
if ( $status == 'pending' ) return;
|
157 |
-
|
158 |
-
// Get user id from affiliate id
|
159 |
-
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
|
160 |
-
|
161 |
-
// Check for exclusion
|
162 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
163 |
-
|
164 |
-
// Execute (if not done so already)
|
165 |
-
if ( ! $this->has_entry( 'affiliate_signup', $affiliate_id, $user_id ) )
|
166 |
-
$this->core->add_creds(
|
167 |
-
'affiliate_signup',
|
168 |
-
$user_id,
|
169 |
-
$this->prefs['signup']['creds'],
|
170 |
-
$this->prefs['signup']['log'],
|
171 |
-
$affiliate_id,
|
172 |
-
'',
|
173 |
-
$this->mycred_type
|
174 |
-
);
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* New Visit
|
180 |
-
* @since 1.6
|
181 |
-
* @version 1.0.1
|
182 |
-
*/
|
183 |
-
public function new_visit( $insert_id, $data ) {
|
184 |
-
|
185 |
-
$affiliate_id = absint( $data['affiliate_id'] );
|
186 |
-
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
|
187 |
-
|
188 |
-
// Check for exclusion
|
189 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
190 |
-
|
191 |
-
// Limit
|
192 |
-
if ( $this->over_hook_limit( 'visits', 'affiliate_visit_referral', $user_id ) ) return;
|
193 |
-
|
194 |
-
// Execute
|
195 |
-
$this->core->add_creds(
|
196 |
-
'affiliate_visit_referral',
|
197 |
-
$user_id,
|
198 |
-
$this->prefs['visits']['creds'],
|
199 |
-
$this->prefs['visits']['log'],
|
200 |
-
$insert_id,
|
201 |
-
$data,
|
202 |
-
$this->mycred_type
|
203 |
-
);
|
204 |
-
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Referral Payout
|
209 |
-
* @since 1.6
|
210 |
-
* @version 1.0
|
211 |
-
*/
|
212 |
-
public function referral_payouts( $referral_id, $new_status, $old_status ) {
|
213 |
-
|
214 |
-
// If the referral id isn't valid
|
215 |
-
if ( ! is_numeric( $referral_id ) ) {
|
216 |
-
return;
|
217 |
-
}
|
218 |
-
|
219 |
-
// Get the referral object
|
220 |
-
$referral = affwp_get_referral( $referral_id );
|
221 |
-
|
222 |
-
// Get the user id
|
223 |
-
$user_id = affwp_get_affiliate_user_id( $referral->affiliate_id );
|
224 |
-
|
225 |
-
// Check for exclusion
|
226 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
227 |
-
|
228 |
-
$amount = false;
|
229 |
-
|
230 |
-
// We are paying a set amount for all referrals
|
231 |
-
if ( $this->prefs['referrals']['pay'] == 'creds' )
|
232 |
-
$amount = $this->prefs['referrals']['creds'];
|
233 |
-
|
234 |
-
// We pay the referral amount (assumes poins are used as the store currency
|
235 |
-
elseif ( $this->prefs['referrals']['pay'] == 'currency' )
|
236 |
-
$amount = $referral->amount;
|
237 |
-
|
238 |
-
// We apply an exchange rate
|
239 |
-
elseif ( $this->prefs['referrals']['pay'] == 'exchange' )
|
240 |
-
$amount = $this->core->number( ( $referral->amount * $this->prefs['referrals']['exchange'] ) );
|
241 |
-
|
242 |
-
$amount = apply_filters( 'mycred_affiliatewp_payout', $amount, $referral, $new_status, $old_status, $this );
|
243 |
-
if ( $amount === false ) return;
|
244 |
-
|
245 |
-
if ( 'paid' === $new_status ) {
|
246 |
-
|
247 |
-
$this->core->add_creds(
|
248 |
-
'affiliate_referral',
|
249 |
-
$user_id,
|
250 |
-
$amount,
|
251 |
-
$this->prefs['referrals']['log'],
|
252 |
-
$referral_id,
|
253 |
-
array( 'ref_type' => 'post' ),
|
254 |
-
$this->mycred_type
|
255 |
-
);
|
256 |
-
|
257 |
-
}
|
258 |
-
|
259 |
-
elseif ( 'paid' === $old_status ) {
|
260 |
-
|
261 |
-
if ( $this->core->has_entry( 'affiliate_referral', $referral_id, $user_id, array( 'ref_type' => 'post' ), $this->mycred_type ) )
|
262 |
-
$this->core->add_creds(
|
263 |
-
'affiliate_referral_refund',
|
264 |
-
$user_id,
|
265 |
-
0 - $amount,
|
266 |
-
$this->prefs['referrals']['remove_log'],
|
267 |
-
$referral_id,
|
268 |
-
array( 'ref_type' => 'post' ),
|
269 |
-
$this->mycred_type
|
270 |
-
);
|
271 |
-
|
272 |
-
}
|
273 |
-
|
274 |
-
}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* Preferences
|
278 |
-
* @since 1.6
|
279 |
-
* @version 1.1
|
280 |
-
*/
|
281 |
-
public function preferences() {
|
282 |
-
|
283 |
-
$prefs = $this->prefs;
|
284 |
-
|
285 |
-
?>
|
286 |
-
<div class="hook-instance">
|
287 |
-
<h3><?php _e( 'Affiliate Signup', 'mycred' ); ?></h3>
|
288 |
-
<div class="row">
|
289 |
-
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
|
290 |
-
<div class="form-group">
|
291 |
-
<label for="<?php echo $this->field_id( array( 'signup', 'creds' ) ); ?>"><?php _e( 'Amount', 'mycred' ); ?></label>
|
292 |
-
<input type="text" name="<?php echo $this->field_name( array( 'signup', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'signup', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['signup']['creds'] ); ?>" class="form-control" />
|
293 |
-
<span class="description"><?php _e( 'Use zero to disable.', 'mycred' ); ?></span>
|
294 |
-
</div>
|
295 |
-
</div>
|
296 |
-
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
|
297 |
-
<div class="form-group">
|
298 |
-
<label for="<?php echo $this->field_id( array( 'signup', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
299 |
-
<input type="text" name="<?php echo $this->field_name( array( 'signup', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'signup', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['signup']['log'] ); ?>" class="form-control" />
|
300 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
301 |
-
</div>
|
302 |
-
</div>
|
303 |
-
</div>
|
304 |
-
</div>
|
305 |
-
<div class="hook-instance">
|
306 |
-
<h3><?php _e( 'Referring Visitors', 'mycred' ); ?></h3>
|
307 |
-
<div class="row">
|
308 |
-
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
|
309 |
-
<div class="form-group">
|
310 |
-
<label for="<?php echo $this->field_id( array( 'visits', 'creds' ) ); ?>"><?php _e( 'Amount', 'mycred' ); ?></label>
|
311 |
-
<input type="text" name="<?php echo $this->field_name( array( 'visits', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'visits', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['visits']['creds'] ); ?>" class="form-control" />
|
312 |
-
<span class="description"><?php _e( 'Use zero to disable.', 'mycred' ); ?></span>
|
313 |
-
</div>
|
314 |
-
</div>
|
315 |
-
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
|
316 |
-
<div class="form-group">
|
317 |
-
<label for="<?php echo $this->field_id( array( 'visits', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
318 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'visits', 'limit' ) ), $this->field_id( array( 'visits', 'limit' ) ), $prefs['visits']['limit'] ); ?>
|
319 |
-
</div>
|
320 |
-
</div>
|
321 |
-
</div>
|
322 |
-
<div class="row">
|
323 |
-
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
324 |
-
<div class="form-group">
|
325 |
-
<label for="<?php echo $this->field_id( array( 'visits', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
326 |
-
<input type="text" name="<?php echo $this->field_name( array( 'visits', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'visits', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['visits']['log'] ); ?>" class="form-control" />
|
327 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
328 |
-
</div>
|
329 |
-
</div>
|
330 |
-
</div>
|
331 |
-
</div>
|
332 |
-
<div class="hook-instance">
|
333 |
-
<h3><?php _e( 'Referring Sales', 'mycred' ); ?></h3>
|
334 |
-
<div class="row">
|
335 |
-
<div class="col-lg-4 col-md-12 col-sm-12 col-xs-12">
|
336 |
-
<div class="form-group">
|
337 |
-
<div class="radio">
|
338 |
-
<label for="<?php echo $this->field_id( array( 'referrals', 'pay-amount' ) ); ?>"><input type="radio" name="<?php echo $this->field_name( array( 'referrals', 'pay' ) ); ?>" id="<?php echo $this->field_id( array( 'referrals', 'pay-amount' ) ); ?>"<?php checked( $this->prefs['referrals']['pay'], 'creds' ); ?> value="creds" /> <?php _e( 'Pay a set amount', 'mycred' ); ?></label>
|
339 |
-
</div>
|
340 |
-
<label for="<?php echo $this->field_id( array( 'referrals', 'creds' ) ); ?>"><?php _e( 'Amount', 'mycred' ); ?></label>
|
341 |
-
<input type="text" name="<?php echo $this->field_name( array( 'referrals', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'referrals', 'creds' ) ); ?>" class="form-control" value="<?php echo $this->core->number( $prefs['referrals']['creds'] ); ?>" />
|
342 |
-
<span class="description"><?php _e( 'All referrals will pay the same amount.', 'mycred' ); ?></span>
|
343 |
-
</div>
|
344 |
-
</div>
|
345 |
-
<div class="col-lg-4 col-md-12 col-sm-12 col-xs-12">
|
346 |
-
<div class="form-group">
|
347 |
-
<div class="radio">
|
348 |
-
<label for="<?php echo $this->field_id( array( 'referrals', 'pay-store' ) ); ?>"><input type="radio" name="<?php echo $this->field_name( array( 'referrals', 'pay' ) ); ?>" id="<?php echo $this->field_id( array( 'referrals', 'pay-store' ) ); ?>"<?php checked( $this->prefs['referrals']['pay'], 'currency' ); ?> value="currency" /> <?php _e( 'Pay the referral amount', 'mycred' ); ?></label>
|
349 |
-
</div>
|
350 |
-
<label for="<?php echo $this->field_id( array( 'referrals', 'currency' ) ); ?>"><?php _e( 'Points Currency Code', 'mycred' ); ?></label>
|
351 |
-
<input type="text" name="<?php echo $this->field_name( array( 'referrals', 'currency' ) ); ?>" id="<?php echo $this->field_id( array( 'referrals', 'currency' ) ); ?>" class="form-control" value="<?php echo esc_attr( $prefs['referrals']['currency'] ); ?>" />
|
352 |
-
<span class="description"><?php _e( 'Requires AffiliateWP and your store to use points as currency.', 'mycred' ); ?></span>
|
353 |
-
</div>
|
354 |
-
</div>
|
355 |
-
<div class="col-lg-4 col-md-12 col-sm-12 col-xs-12">
|
356 |
-
<div class="form-group">
|
357 |
-
<div class="radio">
|
358 |
-
<label for="<?php echo $this->field_id( array( 'referrals', 'pay-ex' ) ); ?>"><input type="radio" name="<?php echo $this->field_name( array( 'referrals', 'pay' ) ); ?>"<?php if ( array_key_exists( $this->currency, $this->point_types ) ) echo ' readonly="readonly"'; ?> id="<?php echo $this->field_id( array( 'referrals', 'pay-ex' ) ); ?>"<?php checked( $this->prefs['referrals']['pay'], 'exchange' ); ?> value="exchange" /> <?php _e( 'Apply an exchange rate', 'mycred' ); ?></label>
|
359 |
-
</div>
|
360 |
-
<label for="<?php echo $this->field_id( array( 'referrals', 'exchange' ) ); ?>"><?php _e( 'Exchange Rate', 'mycred' ); ?></label>
|
361 |
-
<input type="text" name="<?php echo $this->field_name( array( 'referrals', 'exchange' ) ); ?>" id="<?php echo $this->field_id( array( 'referrals', 'exchange' ) ); ?>" class="form-control"<?php if ( array_key_exists( $this->currency, $this->point_types ) ) echo ' readonly="readonly"'; ?> value="<?php echo esc_attr( $prefs['referrals']['exchange'] ); ?>" />
|
362 |
-
<span class="description"><?php if ( ! array_key_exists( $this->currency, $this->point_types ) ) printf( __( 'How much is 1 %s worth in %s', 'mycred' ), $this->core->plural(), $this->currency ); else _e( 'Disabled', 'mycred' ); ?></span>
|
363 |
-
</div>
|
364 |
-
</div>
|
365 |
-
</div>
|
366 |
-
<div class="row">
|
367 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
368 |
-
<div class="form-group">
|
369 |
-
<label for="<?php echo $this->field_id( array( 'referrals', 'log' ) ); ?>"><?php _e( 'Log template - Payout', 'mycred' ); ?></label>
|
370 |
-
<input type="text" name="<?php echo $this->field_name( array( 'referrals', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'referrals', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['referrals']['log'] ); ?>" class="form-control" />
|
371 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
372 |
-
</div>
|
373 |
-
</div>
|
374 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
375 |
-
<div class="form-group">
|
376 |
-
<label for="<?php echo $this->field_id( array( 'referrals', 'remove_log' ) ); ?>"><?php _e( 'Log template - Refund', 'mycred' ); ?></label>
|
377 |
-
<input type="text" name="<?php echo $this->field_name( array( 'referrals', 'remove_log' ) ); ?>" id="<?php echo $this->field_id( array( 'referrals', 'remove_log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['referrals']['remove_log'] ); ?>" class="form-control" />
|
378 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
379 |
-
</div>
|
380 |
-
</div>
|
381 |
-
</div>
|
382 |
-
</div>
|
383 |
-
<?php
|
384 |
-
|
385 |
-
}
|
386 |
-
|
387 |
-
/**
|
388 |
-
* Sanitise Preferences
|
389 |
-
* @since 1.6
|
390 |
-
* @version 1.0
|
391 |
-
*/
|
392 |
-
function sanitise_preferences( $data ) {
|
393 |
-
|
394 |
-
if ( isset( $data['visits']['limit'] ) && isset( $data['visits']['limit_by'] ) ) {
|
395 |
-
$limit = sanitize_text_field( $data['visits']['limit'] );
|
396 |
-
if ( $limit == '' ) $limit = 0;
|
397 |
-
$data['visits']['limit'] = $limit . '/' . $data['visits']['limit_by'];
|
398 |
-
unset( $data['visits']['limit_by'] );
|
399 |
-
}
|
400 |
-
|
401 |
-
return $data;
|
402 |
-
|
403 |
-
}
|
404 |
-
|
405 |
-
}
|
406 |
-
|
407 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-badgeOS.php
DELETED
@@ -1,360 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.0.8
|
7 |
-
* @version 1.3
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_badgeos_hook', 15 );
|
10 |
-
function mycred_register_badgeos_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! class_exists( 'BadgeOS' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['badgeos'] = array(
|
15 |
-
'title' => __( 'BadgeOS', 'mycred' ),
|
16 |
-
'description' => __( 'Default settings for each BadgeOS Achievement type. These settings may be overridden for individual achievement type.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/badgeos-achievements/',
|
18 |
-
'callback' => array( 'myCRED_Hook_BadgeOS' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* BadgeOS Hook
|
27 |
-
* @since 1.0.8
|
28 |
-
* @version 1.1.2
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_badgeos_hook', 15 );
|
31 |
-
function mycred_load_badgeos_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_Hook_BadgeOS' ) || ! class_exists( 'BadgeOS' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_Hook_BadgeOS extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'badgeos',
|
45 |
-
'defaults' => ''
|
46 |
-
), $hook_prefs, $type );
|
47 |
-
|
48 |
-
$key = '_mycred_values';
|
49 |
-
if ( ! $this->is_main_type )
|
50 |
-
$key .= '_' . $this->mycred_type;
|
51 |
-
|
52 |
-
$this->metakey = $key;
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Run
|
58 |
-
* @since 1.0.8
|
59 |
-
* @version 1.0
|
60 |
-
*/
|
61 |
-
public function run() {
|
62 |
-
|
63 |
-
add_filter( 'mycred_post_type_excludes', array( $this, 'exclude_post_type' ) );
|
64 |
-
|
65 |
-
add_action( 'add_meta_boxes', array( $this, 'add_metaboxes' ) );
|
66 |
-
add_action( 'save_post', array( $this, 'save_achivement_data' ) );
|
67 |
-
|
68 |
-
add_action( 'badgeos_award_achievement', array( $this, 'award_achievent' ), 10, 2 );
|
69 |
-
add_action( 'badgeos_revoke_achievement', array( $this, 'revoke_achievement' ), 10, 2 );
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Exclude bbPress Post Types
|
75 |
-
* @since 1.0.8
|
76 |
-
* @version 1.0
|
77 |
-
*/
|
78 |
-
public function exclude_post_type( $excludes ) {
|
79 |
-
|
80 |
-
$excludes = array_merge( $excludes, badgeos_get_achievement_types_slugs() );
|
81 |
-
|
82 |
-
return $excludes;
|
83 |
-
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Add Metaboxes
|
88 |
-
* @since 1.0.8
|
89 |
-
* @version 1.0
|
90 |
-
*/
|
91 |
-
public function add_metaboxes() {
|
92 |
-
|
93 |
-
// Get all Achievement Types
|
94 |
-
$badge_post_types = badgeos_get_achievement_types_slugs();
|
95 |
-
foreach ( $badge_post_types as $post_type ) {
|
96 |
-
|
97 |
-
add_meta_box(
|
98 |
-
'mycred_badgeos_' . $post_type . '_' . $this->mycred_type,
|
99 |
-
$this->core->plural(),
|
100 |
-
array( $this, 'render_meta_box' ),
|
101 |
-
$post_type,
|
102 |
-
'side',
|
103 |
-
'core'
|
104 |
-
);
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Render Meta Box
|
112 |
-
* @since 1.0.8
|
113 |
-
* @version 1.1
|
114 |
-
*/
|
115 |
-
public function render_meta_box( $post ) {
|
116 |
-
|
117 |
-
// Setup is needed
|
118 |
-
if ( ! isset( $this->prefs[ $post->post_type ] ) ) {
|
119 |
-
|
120 |
-
$page = MYCRED_SLUG . '-hooks';
|
121 |
-
if ( ! $this->is_main_type )
|
122 |
-
$page = MYCRED_SLUG . '_' . $this->mycred_type . '-hooks';
|
123 |
-
|
124 |
-
echo '<p>' . sprintf( __( 'Please setup your <a href="%s">default settings</a> before using this feature.', 'mycred' ), admin_url( 'admin.php?page=' . $page ) ) . '</p>';
|
125 |
-
return;
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
$post_key = 'mycred_values' . $this->mycred_type;
|
130 |
-
|
131 |
-
// Prep Achievement Data
|
132 |
-
$prefs = $this->prefs;
|
133 |
-
$achievement_data = get_post_meta( $post->ID, $this->metakey, true );
|
134 |
-
if ( $achievement_data == '' )
|
135 |
-
$achievement_data = $prefs[ $post->post_type ];
|
136 |
-
|
137 |
-
?>
|
138 |
-
<p><strong><?php echo $this->core->template_tags_general( __( '%plural% to Award', 'mycred' ) ); ?></strong></p>
|
139 |
-
<p>
|
140 |
-
<label class="screen-reader-text" for="mycred-values-<?php echo $this->mycred_type; ?>-creds"><?php echo $this->core->template_tags_general( __( '%plural% to Award', 'mycred' ) ); ?></label>
|
141 |
-
<input type="text" name="<?php echo $post_key; ?>[creds]" id="mycred-values-<?php echo $this->mycred_type; ?>-creds" value="<?php echo $this->core->number( $achievement_data['creds'] ); ?>" size="8" />
|
142 |
-
<span class="description"><?php _e( 'Use zero to disable', 'mycred' ); ?></span>
|
143 |
-
</p>
|
144 |
-
<p><strong><?php _e( 'Log Template', 'mycred' ); ?></strong></p>
|
145 |
-
<p>
|
146 |
-
<label class="screen-reader-text" for="mycred-values-<?php echo $this->mycred_type; ?>-log"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
147 |
-
<input type="text" name="<?php echo $post_key; ?>[log]" id="mycred-values-<?php echo $this->mycred_type; ?>-log" value="<?php echo esc_attr( $achievement_data['log'] ); ?>" style="width:99%;" />
|
148 |
-
</p>
|
149 |
-
<?php
|
150 |
-
|
151 |
-
// If deduction is enabled
|
152 |
-
if ( $this->prefs[ $post->post_type ]['deduct'] == 1 ) {
|
153 |
-
|
154 |
-
?>
|
155 |
-
<p><strong><?php _e( 'Deduction Log Template', 'mycred' ); ?></strong></p>
|
156 |
-
<p>
|
157 |
-
<label class="screen-reader-text" for="mycred-values-<?php echo $this->mycred_type; ?>-log"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
158 |
-
<input type="text" name="<?php echo $post_key; ?>[deduct_log]" id="mycred-values-deduct-<?php echo $this->mycred_type; ?>-log" value="<?php echo esc_attr( $achievement_data['deduct_log'] ); ?>" style="width:99%;" />
|
159 |
-
</p>
|
160 |
-
<?php
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* Save Achievement Data
|
168 |
-
* @since 1.0.8
|
169 |
-
* @version 1.2
|
170 |
-
*/
|
171 |
-
public function save_achivement_data( $post_id ) {
|
172 |
-
|
173 |
-
// Post Type
|
174 |
-
$post_type = get_post_type( $post_id );
|
175 |
-
|
176 |
-
// Make sure this is a BadgeOS Object
|
177 |
-
if ( ! in_array( $post_type, badgeos_get_achievement_types_slugs() ) ) return;
|
178 |
-
|
179 |
-
$post_key = 'mycred_values' . $this->mycred_type;
|
180 |
-
|
181 |
-
// Make sure preference is set
|
182 |
-
if ( ! isset( $this->prefs[ $post_type ] ) || ! isset( $_POST[ $post_key ]['creds'] ) || ! isset( $_POST[ $post_key ]['log'] ) )
|
183 |
-
return;
|
184 |
-
|
185 |
-
// Only save if the settings differ, otherwise we default
|
186 |
-
if ( $_POST[ $post_key ]['creds'] == $this->prefs[ $post_type ]['creds'] && $_POST[ $post_key ]['log'] == $this->prefs[ $post_type ]['log'] ) {
|
187 |
-
|
188 |
-
delete_post_meta( $post_id, $this->metakey );
|
189 |
-
return;
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
$data = array();
|
194 |
-
|
195 |
-
// Creds
|
196 |
-
if ( ! empty( $_POST[ $post_key ]['creds'] ) && $_POST[ $post_key ]['creds'] != $this->prefs[ $post_type ]['creds'] )
|
197 |
-
$data['creds'] = $this->core->number( $_POST[ $post_key ]['creds'] );
|
198 |
-
else
|
199 |
-
$data['creds'] = $this->core->number( $this->prefs[ $post_type ]['creds'] );
|
200 |
-
|
201 |
-
// Log template
|
202 |
-
if ( ! empty( $_POST[ $post_key ]['log'] ) && $_POST[ $post_key ]['log'] != $this->prefs[ $post_type ]['log'] )
|
203 |
-
$data['log'] = sanitize_text_field( $_POST[ $post_key ]['log'] );
|
204 |
-
else
|
205 |
-
$data['log'] = sanitize_text_field( $this->prefs[ $post_type ]['log'] );
|
206 |
-
|
207 |
-
// If deduction is enabled save log template
|
208 |
-
if ( $this->prefs[ $post_type ]['deduct'] == 1 ) {
|
209 |
-
if ( ! empty( $_POST[ $post_key ]['deduct_log'] ) && $_POST[ $post_key ]['deduct_log'] != $this->prefs[ $post_type ]['deduct_log'] )
|
210 |
-
$data['deduct_log'] = sanitize_text_field( $_POST[ $post_key ]['deduct_log'] );
|
211 |
-
else
|
212 |
-
$data['deduct_log'] = sanitize_text_field( $this->prefs[ $post_type ]['deduct_log'] );
|
213 |
-
}
|
214 |
-
|
215 |
-
// Update sales values
|
216 |
-
update_post_meta( $post_id, $this->metakey, $data );
|
217 |
-
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Award Achievement
|
222 |
-
* Run by BadgeOS when ever needed, we make sure settings are not zero otherwise
|
223 |
-
* award points whenever this hook fires.
|
224 |
-
* @since 1.0.8
|
225 |
-
* @version 1.1
|
226 |
-
*/
|
227 |
-
public function award_achievent( $user_id, $achievement_id ) {
|
228 |
-
|
229 |
-
$post_type = get_post_type( $achievement_id );
|
230 |
-
|
231 |
-
// Settings are not set
|
232 |
-
if ( ! isset( $this->prefs[ $post_type ]['creds'] ) ) return;
|
233 |
-
|
234 |
-
// Get achievemen data
|
235 |
-
$achievement_data = get_post_meta( $achievement_id, $this->metakey, true );
|
236 |
-
if ( $achievement_data == '' )
|
237 |
-
$achievement_data = $this->prefs[ $post_type ];
|
238 |
-
|
239 |
-
// Make sure its not disabled
|
240 |
-
if ( $achievement_data['creds'] == 0 ) return;
|
241 |
-
|
242 |
-
// Execute
|
243 |
-
$post_type_object = get_post_type_object( $post_type );
|
244 |
-
$this->core->add_creds(
|
245 |
-
$post_type_object->labels->name,
|
246 |
-
$user_id,
|
247 |
-
$achievement_data['creds'],
|
248 |
-
$achievement_data['log'],
|
249 |
-
$achievement_id,
|
250 |
-
array( 'ref_type' => 'post' ),
|
251 |
-
$this->mycred_type
|
252 |
-
);
|
253 |
-
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Revoke Achievement
|
258 |
-
* Run by BadgeOS when a users achievement is revoed.
|
259 |
-
* @since 1.0.8
|
260 |
-
* @version 1.2
|
261 |
-
*/
|
262 |
-
public function revoke_achievement( $user_id, $achievement_id ) {
|
263 |
-
|
264 |
-
$post_type = get_post_type( $achievement_id );
|
265 |
-
|
266 |
-
// Settings are not set
|
267 |
-
if ( ! isset( $this->prefs[ $post_type ]['creds'] ) ) return;
|
268 |
-
|
269 |
-
// Get achievemen data
|
270 |
-
$achievement_data = get_post_meta( $achievement_id, $this->metakey, true );
|
271 |
-
if ( $achievement_data == '' )
|
272 |
-
$achievement_data = $this->prefs[ $post_type ];
|
273 |
-
|
274 |
-
// Make sure its not disabled
|
275 |
-
if ( $achievement_data['creds'] == 0 ) return;
|
276 |
-
|
277 |
-
// Execute
|
278 |
-
$post_type_object = get_post_type_object( $post_type );
|
279 |
-
$this->core->add_creds(
|
280 |
-
$post_type_object->labels->name,
|
281 |
-
$user_id,
|
282 |
-
0 - $achievement_data['creds'],
|
283 |
-
$achievement_data['deduct_log'],
|
284 |
-
$achievement_id,
|
285 |
-
array( 'ref_type' => 'post' ),
|
286 |
-
$this->mycred_type
|
287 |
-
);
|
288 |
-
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Preferences for BadgeOS
|
293 |
-
* @since 1.0.8
|
294 |
-
* @version 1.1
|
295 |
-
*/
|
296 |
-
public function preferences() {
|
297 |
-
|
298 |
-
$prefs = $this->prefs;
|
299 |
-
$badge_post_types = badgeos_get_achievement_types_slugs();
|
300 |
-
|
301 |
-
foreach ( $badge_post_types as $post_type ) {
|
302 |
-
|
303 |
-
if ( in_array( $post_type, apply_filters( 'mycred_badgeos_excludes', array( 'step' ) ) ) ) continue;
|
304 |
-
|
305 |
-
if ( ! isset( $prefs[ $post_type ] ) )
|
306 |
-
$prefs[ $post_type ] = array(
|
307 |
-
'creds' => 10,
|
308 |
-
'log' => '',
|
309 |
-
'deduct' => 1,
|
310 |
-
'deduct_log' => '%plural% for revoked achievement'
|
311 |
-
);
|
312 |
-
|
313 |
-
$post_type_object = get_post_type_object( $post_type );
|
314 |
-
|
315 |
-
?>
|
316 |
-
<div class="hook-instance">
|
317 |
-
<h3><?php printf( __( 'Earning: %s', 'mycred' ), $post_type_object->labels->singular_name ); ?></h3>
|
318 |
-
<div class="row">
|
319 |
-
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
|
320 |
-
<div class="form-group">
|
321 |
-
<label for="<?php echo $this->field_id( array( $post_type, 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
322 |
-
<input type="text" name="<?php echo $this->field_name( array( $post_type, 'creds' ) ); ?>" id="<?php echo $this->field_id( array( $post_type, 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs[ $post_type ]['creds'] ); ?>" class="form-control" />
|
323 |
-
</div>
|
324 |
-
</div>
|
325 |
-
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
|
326 |
-
<div class="form-group">
|
327 |
-
<label for="<?php echo $this->field_id( array( $post_type, 'log' ) ); ?>"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
328 |
-
<input type="text" name="<?php echo $this->field_name( array( $post_type, 'log' ) ); ?>" id="<?php echo $this->field_id( array( $post_type, 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs[ $post_type ]['log'] ); ?>" class="form-control" />
|
329 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
330 |
-
</div>
|
331 |
-
</div>
|
332 |
-
</div>
|
333 |
-
</div>
|
334 |
-
<div class="hook-instance">
|
335 |
-
<h3><?php printf( __( 'Revoked: %s', 'mycred' ), $post_type_object->labels->singular_name ); ?></h3>
|
336 |
-
<div class="row">
|
337 |
-
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
|
338 |
-
<div class="form-group">
|
339 |
-
<label for="<?php echo $this->field_id( array( $post_type, 'deduct' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
340 |
-
<input type="text" name="<?php echo $this->field_name( array( $post_type, 'deduct' ) ); ?>" id="<?php echo $this->field_id( array( $post_type, 'deduct' ) ); ?>" value="<?php echo $this->core->number( $prefs[ $post_type ]['deduct'] ); ?>" class="form-control" />
|
341 |
-
</div>
|
342 |
-
</div>
|
343 |
-
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
|
344 |
-
<div class="form-group">
|
345 |
-
<label for="<?php echo $this->field_id( array( $post_type, 'deduct_log' ) ); ?>"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
346 |
-
<input type="text" name="<?php echo $this->field_name( array( $post_type, 'deduct_log' ) ); ?>" id="<?php echo $this->field_id( array( $post_type, 'deduct_log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs[ $post_type ]['deduct_log'] ); ?>" class="form-control" />
|
347 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
348 |
-
</div>
|
349 |
-
</div>
|
350 |
-
</div>
|
351 |
-
</div>
|
352 |
-
<?php
|
353 |
-
|
354 |
-
}
|
355 |
-
|
356 |
-
}
|
357 |
-
|
358 |
-
}
|
359 |
-
|
360 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-bbPress.php
DELETED
@@ -1,664 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 0.1
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_bbpress_hook', 20 );
|
10 |
-
function mycred_register_bbpress_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! class_exists( 'bbPress' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['hook_bbpress'] = array(
|
15 |
-
'title' => 'bbPress',
|
16 |
-
'description' => __( 'Awards %_plural% for bbPress actions.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/bbpress-actions/',
|
18 |
-
'callback' => array( 'myCRED_bbPress' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* bbPress Hook
|
27 |
-
* @since 0.1
|
28 |
-
* @version 1.4.4
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_bbpress_hook', 20 );
|
31 |
-
function mycred_load_bbpress_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_bbPress' ) || ! class_exists( 'bbPress' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_bbPress extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'hook_bbpress',
|
45 |
-
'defaults' => array(
|
46 |
-
'new_forum' => array(
|
47 |
-
'creds' => 1,
|
48 |
-
'log' => '%plural% for new forum',
|
49 |
-
'limit' => '0/x'
|
50 |
-
),
|
51 |
-
'delete_forum' => array(
|
52 |
-
'creds' => 0,
|
53 |
-
'log' => '%singular% deduction for deleted forum'
|
54 |
-
),
|
55 |
-
'new_topic' => array(
|
56 |
-
'creds' => 1,
|
57 |
-
'log' => '%plural% for new forum topic',
|
58 |
-
'author' => 0,
|
59 |
-
'limit' => '0/x'
|
60 |
-
),
|
61 |
-
'delete_topic' => array(
|
62 |
-
'creds' => 0,
|
63 |
-
'log' => '%singular% deduction for deleted topic'
|
64 |
-
),
|
65 |
-
'fav_topic' => array(
|
66 |
-
'creds' => 1,
|
67 |
-
'log' => '%plural% for someone favorited your forum topic',
|
68 |
-
'limit' => '0/x'
|
69 |
-
),
|
70 |
-
'new_reply' => array(
|
71 |
-
'creds' => 1,
|
72 |
-
'log' => '%plural% for new forum reply',
|
73 |
-
'author' => 0,
|
74 |
-
'limit' => '0/x'
|
75 |
-
),
|
76 |
-
'delete_reply' => array(
|
77 |
-
'creds' => 0,
|
78 |
-
'log' => '%singular% deduction for deleted reply'
|
79 |
-
),
|
80 |
-
'show_points_in_reply' => 0,
|
81 |
-
'show_points_in_profile' => 0
|
82 |
-
)
|
83 |
-
), $hook_prefs, $type );
|
84 |
-
|
85 |
-
add_filter( 'mycred_post_type_excludes', array( $this, 'exclude_post_type' ) );
|
86 |
-
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Run
|
91 |
-
* @since 0.1
|
92 |
-
* @version 1.2.1
|
93 |
-
*/
|
94 |
-
public function run() {
|
95 |
-
|
96 |
-
// Insert Points balance in profile
|
97 |
-
if ( isset( $this->prefs['show_points_in_reply'] ) && $this->prefs['show_points_in_reply'] == 1 )
|
98 |
-
add_action( 'bbp_theme_after_reply_author_details', array( $this, 'insert_balance_reply' ) );
|
99 |
-
|
100 |
-
if ( isset( $this->prefs['show_points_in_profile'] ) && $this->prefs['show_points_in_profile'] == 1 )
|
101 |
-
add_action( 'bbp_template_after_user_profile', array( $this, 'insert_balance_profile' ) );
|
102 |
-
|
103 |
-
// New Forum
|
104 |
-
if ( $this->prefs['new_forum']['creds'] != 0 )
|
105 |
-
add_action( 'bbp_new_forum', array( $this, 'new_forum' ), 20 );
|
106 |
-
|
107 |
-
// Delete Forum
|
108 |
-
if ( $this->prefs['delete_forum']['creds'] != 0 )
|
109 |
-
add_action( 'bbp_delete_forum', array( $this, 'delete_forum' ) );
|
110 |
-
|
111 |
-
// New Topic
|
112 |
-
if ( $this->prefs['new_topic']['creds'] != 0 )
|
113 |
-
add_action( 'bbp_new_topic', array( $this, 'new_topic' ), 20, 4 );
|
114 |
-
|
115 |
-
// Delete Topic
|
116 |
-
if ( $this->prefs['delete_topic']['creds'] != 0 )
|
117 |
-
add_action( 'bbp_delete_topic', array( $this, 'delete_topic' ) );
|
118 |
-
|
119 |
-
// Fave Topic
|
120 |
-
if ( $this->prefs['fav_topic']['creds'] != 0 )
|
121 |
-
add_action( 'bbp_add_user_favorite', array( $this, 'fav_topic' ), 10, 2 );
|
122 |
-
|
123 |
-
// New Reply
|
124 |
-
if ( $this->prefs['new_reply']['creds'] != 0 )
|
125 |
-
add_action( 'bbp_new_reply', array( $this, 'new_reply' ), 20, 5 );
|
126 |
-
|
127 |
-
// Delete Reply
|
128 |
-
if ( $this->prefs['delete_reply']['creds'] != 0 )
|
129 |
-
add_action( 'bbp_delete_reply', array( $this, 'delete_reply' ) );
|
130 |
-
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Exclude bbPress Post Types
|
135 |
-
* @since 0.1
|
136 |
-
* @version 1.0
|
137 |
-
*/
|
138 |
-
public function exclude_post_type( $excludes ) {
|
139 |
-
|
140 |
-
$excludes[] = bbp_get_forum_post_type();
|
141 |
-
$excludes[] = bbp_get_topic_post_type();
|
142 |
-
$excludes[] = bbp_get_reply_post_type();
|
143 |
-
|
144 |
-
return $excludes;
|
145 |
-
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Insert Balance in bbPress Profiles
|
150 |
-
* @since 1.1.1
|
151 |
-
* @version 1.2
|
152 |
-
*/
|
153 |
-
public function insert_balance_profile() {
|
154 |
-
|
155 |
-
$user_id = bbp_get_displayed_user_id();
|
156 |
-
|
157 |
-
if ( $this->core->exclude_user( $user_id ) || $user_id == 0 ) return;
|
158 |
-
|
159 |
-
$balance = $this->core->get_users_balance( $user_id, $this->mycred_type );
|
160 |
-
$layout = $this->core->plural() . ': ' . $this->core->format_creds( $balance );
|
161 |
-
|
162 |
-
echo apply_filters( 'mycred_bbp_profile_balance', '<div class="users-mycred-balance">' . $layout . '</div>', $layout, $user_id, $this );
|
163 |
-
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* Insert Balance
|
168 |
-
* @since 0.1
|
169 |
-
* @version 1.2.1
|
170 |
-
*/
|
171 |
-
public function insert_balance_reply() {
|
172 |
-
|
173 |
-
$reply_id = bbp_get_reply_id();
|
174 |
-
|
175 |
-
// Skip Anonymous replies
|
176 |
-
if ( bbp_is_reply_anonymous( $reply_id ) ) return;
|
177 |
-
|
178 |
-
// Get reply author
|
179 |
-
$user_id = bbp_get_reply_author_id( $reply_id );
|
180 |
-
|
181 |
-
// Check for exclusions and guests
|
182 |
-
if ( $this->core->exclude_user( $user_id ) || $user_id == 0 ) return;
|
183 |
-
|
184 |
-
$balance = $this->core->get_users_balance( $user_id, $this->mycred_type );
|
185 |
-
$layout = $this->core->plural() . ': ' . $this->core->format_creds( $balance );
|
186 |
-
|
187 |
-
echo apply_filters( 'mycred_bbp_reply_balance', '<div class="users-mycred-balance">' . $layout . '</div>', $layout, $user_id, $this );
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* New Forum
|
193 |
-
* @since 1.1.1
|
194 |
-
* @version 1.2
|
195 |
-
*/
|
196 |
-
public function new_forum( $forum ) {
|
197 |
-
|
198 |
-
// Forum id
|
199 |
-
$forum_id = $forum['forum_id'];
|
200 |
-
|
201 |
-
// Forum author
|
202 |
-
$forum_author = $forum['forum_author'];
|
203 |
-
|
204 |
-
// Check if user is excluded
|
205 |
-
if ( $this->core->exclude_user( $forum_author ) ) return;
|
206 |
-
|
207 |
-
// Limit
|
208 |
-
if ( $this->over_hook_limit( 'new_forum', 'new_forum', $forum_author ) ) return;
|
209 |
-
|
210 |
-
// Make sure this is unique event
|
211 |
-
if ( $this->has_entry( 'new_forum', $forum_id, $forum_author ) ) return;
|
212 |
-
|
213 |
-
// Execute
|
214 |
-
$this->core->add_creds(
|
215 |
-
'new_forum',
|
216 |
-
$forum_author,
|
217 |
-
$this->prefs['new_forum']['creds'],
|
218 |
-
$this->prefs['new_forum']['log'],
|
219 |
-
$forum_id,
|
220 |
-
array( 'ref_type' => 'post' ),
|
221 |
-
$this->mycred_type
|
222 |
-
);
|
223 |
-
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Delete Forum
|
228 |
-
* @since 1.2
|
229 |
-
* @version 1.1
|
230 |
-
*/
|
231 |
-
public function delete_forum( $forum_id ) {
|
232 |
-
|
233 |
-
// Get Author
|
234 |
-
$forum_author = bbp_get_forum_author_id( $forum_id );
|
235 |
-
|
236 |
-
// If gained, points, deduct
|
237 |
-
if ( $this->has_entry( 'new_forum', $forum_id, $forum_author ) ) {
|
238 |
-
|
239 |
-
// Execute
|
240 |
-
$this->core->add_creds(
|
241 |
-
'deleted_forum',
|
242 |
-
$forum_author,
|
243 |
-
$this->prefs['delete_forum']['creds'],
|
244 |
-
$this->prefs['delete_forum']['log'],
|
245 |
-
$forum_id,
|
246 |
-
'',
|
247 |
-
$this->mycred_type
|
248 |
-
);
|
249 |
-
|
250 |
-
}
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* New Topic
|
256 |
-
* @since 0.1
|
257 |
-
* @version 1.2
|
258 |
-
*/
|
259 |
-
public function new_topic( $topic_id, $forum_id, $anonymous_data, $topic_author ) {
|
260 |
-
|
261 |
-
// Check if user is excluded
|
262 |
-
if ( $this->core->exclude_user( $topic_author ) ) return;
|
263 |
-
|
264 |
-
// Check if forum author is allowed to get points for their own topics
|
265 |
-
if ( (bool) $this->prefs['new_topic']['author'] == false ) {
|
266 |
-
if ( bbp_get_forum_author_id( $forum_id ) == $topic_author ) return;
|
267 |
-
}
|
268 |
-
|
269 |
-
// Limit
|
270 |
-
if ( $this->over_hook_limit( 'new_topic', 'new_forum_topic', $topic_author ) ) return;
|
271 |
-
|
272 |
-
// Make sure this is unique event
|
273 |
-
if ( $this->has_entry( 'new_forum_topic', $topic_id, $topic_author ) ) return;
|
274 |
-
|
275 |
-
// Execute
|
276 |
-
$this->core->add_creds(
|
277 |
-
'new_forum_topic',
|
278 |
-
$topic_author,
|
279 |
-
$this->prefs['new_topic']['creds'],
|
280 |
-
$this->prefs['new_topic']['log'],
|
281 |
-
$topic_id,
|
282 |
-
array( 'ref_type' => 'post' ),
|
283 |
-
$this->mycred_type
|
284 |
-
);
|
285 |
-
|
286 |
-
}
|
287 |
-
|
288 |
-
/**
|
289 |
-
* Delete Topic
|
290 |
-
* @since 1.2
|
291 |
-
* @version 1.1
|
292 |
-
*/
|
293 |
-
public function delete_topic( $topic_id ) {
|
294 |
-
|
295 |
-
// Get Author
|
296 |
-
$topic_author = bbp_get_topic_author_id( $topic_id );
|
297 |
-
|
298 |
-
// If gained, points, deduct
|
299 |
-
if ( $this->has_entry( 'new_forum_topic', $topic_id, $topic_author ) ) {
|
300 |
-
|
301 |
-
// Execute
|
302 |
-
$this->core->add_creds(
|
303 |
-
'deleted_topic',
|
304 |
-
$topic_author,
|
305 |
-
$this->prefs['delete_topic']['creds'],
|
306 |
-
$this->prefs['delete_topic']['log'],
|
307 |
-
$topic_id,
|
308 |
-
'',
|
309 |
-
$this->mycred_type
|
310 |
-
);
|
311 |
-
|
312 |
-
}
|
313 |
-
|
314 |
-
}
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Topic Added to Favorites
|
318 |
-
* @by Fee (http://wordpress.org/support/profile/wdfee)
|
319 |
-
* @since 1.1.1
|
320 |
-
* @version 1.5
|
321 |
-
*/
|
322 |
-
public function fav_topic( $user_id, $topic_id ) {
|
323 |
-
|
324 |
-
// $user_id is loggedin_user, not author, so get topic author
|
325 |
-
$topic_author = get_post_field( 'post_author', $topic_id );
|
326 |
-
|
327 |
-
// Check if user is excluded (required)
|
328 |
-
if ( $this->core->exclude_user( $topic_author ) || $topic_author == $user_id ) return;
|
329 |
-
|
330 |
-
// Limit
|
331 |
-
if ( $this->over_hook_limit( 'fav_topic', 'topic_favorited', $topic_author ) ) return;
|
332 |
-
|
333 |
-
// Make sure this is a unique event (favorite not from same user)
|
334 |
-
$data = array( 'ref_user' => $user_id, 'ref_type' => 'post' );
|
335 |
-
if ( $this->has_entry( 'topic_favorited', $topic_id, $topic_author, $data ) ) return;
|
336 |
-
|
337 |
-
// Execute
|
338 |
-
$this->core->add_creds(
|
339 |
-
'topic_favorited',
|
340 |
-
$topic_author,
|
341 |
-
$this->prefs['fav_topic']['creds'],
|
342 |
-
$this->prefs['fav_topic']['log'],
|
343 |
-
$topic_id,
|
344 |
-
$data,
|
345 |
-
$this->mycred_type
|
346 |
-
);
|
347 |
-
|
348 |
-
}
|
349 |
-
|
350 |
-
/**
|
351 |
-
* New Reply
|
352 |
-
* @since 0.1
|
353 |
-
* @version 1.5
|
354 |
-
*/
|
355 |
-
public function new_reply( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ) {
|
356 |
-
|
357 |
-
// Check if user is excluded
|
358 |
-
if ( $this->core->exclude_user( $reply_author ) ) return;
|
359 |
-
|
360 |
-
// Check if topic author gets points for their own replies
|
361 |
-
if ( (bool) $this->prefs['new_reply']['author'] === false && bbp_get_topic_author_id( $topic_id ) == $reply_author ) return;
|
362 |
-
|
363 |
-
// Limit
|
364 |
-
if ( $this->over_hook_limit( 'new_reply', 'new_forum_reply', $reply_author ) ) return;
|
365 |
-
|
366 |
-
// Make sure this is unique event
|
367 |
-
if ( $this->has_entry( 'new_forum_reply', $reply_id, $reply_author ) ) return;
|
368 |
-
|
369 |
-
// Execute
|
370 |
-
$this->core->add_creds(
|
371 |
-
'new_forum_reply',
|
372 |
-
$reply_author,
|
373 |
-
$this->prefs['new_reply']['creds'],
|
374 |
-
$this->prefs['new_reply']['log'],
|
375 |
-
$reply_id,
|
376 |
-
array( 'ref_type' => 'post' ),
|
377 |
-
$this->mycred_type
|
378 |
-
);
|
379 |
-
|
380 |
-
}
|
381 |
-
|
382 |
-
/**
|
383 |
-
* Delete Reply
|
384 |
-
* @since 1.2
|
385 |
-
* @version 1.2.1
|
386 |
-
*/
|
387 |
-
public function delete_reply( $reply_id ) {
|
388 |
-
|
389 |
-
// Get Author
|
390 |
-
$reply_author = bbp_get_reply_author_id( $reply_id );
|
391 |
-
|
392 |
-
// If gained, points, deduct
|
393 |
-
if ( $this->has_entry( 'new_forum_reply', $reply_id, $reply_author ) ) {
|
394 |
-
|
395 |
-
// Execute
|
396 |
-
$this->core->add_creds(
|
397 |
-
'deleted_reply',
|
398 |
-
$reply_author,
|
399 |
-
$this->prefs['delete_reply']['creds'],
|
400 |
-
$this->prefs['delete_reply']['log'],
|
401 |
-
$reply_id,
|
402 |
-
'',
|
403 |
-
$this->mycred_type
|
404 |
-
);
|
405 |
-
|
406 |
-
}
|
407 |
-
|
408 |
-
}
|
409 |
-
|
410 |
-
/**
|
411 |
-
* Preferences
|
412 |
-
* @since 0.1
|
413 |
-
* @version 1.3
|
414 |
-
*/
|
415 |
-
public function preferences() {
|
416 |
-
|
417 |
-
$prefs = $this->prefs;
|
418 |
-
|
419 |
-
if ( ! isset( $prefs['new_forum']['limit'] ) )
|
420 |
-
$prefs['new_forum']['limit'] = '0/x';
|
421 |
-
|
422 |
-
if ( ! isset( $prefs['new_topic']['limit'] ) )
|
423 |
-
$prefs['new_topic']['limit'] = '0/x';
|
424 |
-
|
425 |
-
if ( ! isset( $prefs['fav_topic']['limit'] ) )
|
426 |
-
$prefs['fav_topic']['limit'] = '0/x';
|
427 |
-
|
428 |
-
if ( ! isset( $prefs['new_reply']['limit'] ) )
|
429 |
-
$prefs['new_reply']['limit'] = '0/x';
|
430 |
-
|
431 |
-
?>
|
432 |
-
<div class="hook-instance">
|
433 |
-
<h3><?php _e( 'New Forums', 'mycred' ); ?></h3>
|
434 |
-
<div class="row">
|
435 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
436 |
-
<div class="form-group">
|
437 |
-
<label for="<?php echo $this->field_id( array( 'new_forum', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
438 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_forum', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_forum', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_forum']['creds'] ); ?>" class="form-control" />
|
439 |
-
</div>
|
440 |
-
</div>
|
441 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
442 |
-
<div class="form-group">
|
443 |
-
<label for="<?php echo $this->field_id( array( 'new_forum', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
444 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_forum', 'limit' ) ), $this->field_id( array( 'new_forum', 'limit' ) ), $prefs['new_forum']['limit'] ); ?>
|
445 |
-
</div>
|
446 |
-
</div>
|
447 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
448 |
-
<div class="form-group">
|
449 |
-
<label for="<?php echo $this->field_id( array( 'new_forum', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
450 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_forum', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_forum', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_forum']['log'] ); ?>" class="form-control" />
|
451 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
452 |
-
</div>
|
453 |
-
</div>
|
454 |
-
</div>
|
455 |
-
</div>
|
456 |
-
<div class="hook-instance">
|
457 |
-
<h3><?php _e( 'Deleting Forums', 'mycred' ); ?></h3>
|
458 |
-
<div class="row">
|
459 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
460 |
-
<div class="form-group">
|
461 |
-
<label for="<?php echo $this->field_id( array( 'delete_forum', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
462 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_forum', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_forum', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['delete_forum']['creds'] ); ?>" class="form-control" />
|
463 |
-
</div>
|
464 |
-
</div>
|
465 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
466 |
-
<div class="form-group">
|
467 |
-
<label for="<?php echo $this->field_id( array( 'delete_forum', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
468 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_forum', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_forum', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_forum']['log'] ); ?>" class="form-control" />
|
469 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
470 |
-
</div>
|
471 |
-
</div>
|
472 |
-
</div>
|
473 |
-
</div>
|
474 |
-
<div class="hook-instance">
|
475 |
-
<h3><?php _e( 'New Topic', 'mycred' ); ?></h3>
|
476 |
-
<div class="row">
|
477 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
478 |
-
<div class="form-group">
|
479 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
480 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_topic', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_topic', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_topic']['creds'] ); ?>" class="form-control" />
|
481 |
-
</div>
|
482 |
-
</div>
|
483 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
484 |
-
<div class="form-group">
|
485 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
486 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_topic', 'limit' ) ), $this->field_id( array( 'new_topic', 'limit' ) ), $prefs['new_topic']['limit'] ); ?>
|
487 |
-
</div>
|
488 |
-
</div>
|
489 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
490 |
-
<div class="form-group">
|
491 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
492 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_topic', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_topic', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_topic']['log'] ); ?>" class="form-control" />
|
493 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
494 |
-
</div>
|
495 |
-
</div>
|
496 |
-
</div>
|
497 |
-
<div class="row">
|
498 |
-
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
499 |
-
<div class="form-group">
|
500 |
-
<div class="radio">
|
501 |
-
<label for="<?php echo $this->field_id( array( 'new_topic' => 'author' ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'new_topic' => 'author' ) ); ?>" id="<?php echo $this->field_id( array( 'new_topic' => 'author' ) ); ?>" <?php checked( $prefs['new_topic']['author'], 1 ); ?> value="1" /> <?php echo $this->core->template_tags_general( __( 'Forum authors can receive %_plural% for creating new topics.', 'mycred' ) ); ?></label>
|
502 |
-
</div>
|
503 |
-
</div>
|
504 |
-
</div>
|
505 |
-
</div>
|
506 |
-
</div>
|
507 |
-
<div class="hook-instance">
|
508 |
-
<h3><?php _e( 'Deleted Topic', 'mycred' ); ?></h3>
|
509 |
-
<div class="row">
|
510 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
511 |
-
<div class="form-group">
|
512 |
-
<label for="<?php echo $this->field_id( array( 'delete_topic', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
513 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_topic', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_topic', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['delete_topic']['creds'] ); ?>" class="form-control" />
|
514 |
-
</div>
|
515 |
-
</div>
|
516 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
517 |
-
<div class="form-group">
|
518 |
-
<label for="<?php echo $this->field_id( array( 'delete_topic', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
519 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_topic', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_topic', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_topic']['log'] ); ?>" class="form-control" />
|
520 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
521 |
-
</div>
|
522 |
-
</div>
|
523 |
-
</div>
|
524 |
-
</div>
|
525 |
-
<div class="hook-instance">
|
526 |
-
<h3><?php _e( 'Adding Topic to Favorites', 'mycred' ); ?></h3>
|
527 |
-
<div class="row">
|
528 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
529 |
-
<div class="form-group">
|
530 |
-
<label for="<?php echo $this->field_id( array( 'fav_topic', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
531 |
-
<input type="text" name="<?php echo $this->field_name( array( 'fav_topic', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'fav_topic', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['fav_topic']['creds'] ); ?>" class="form-control" />
|
532 |
-
</div>
|
533 |
-
</div>
|
534 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
535 |
-
<div class="form-group">
|
536 |
-
<label for="<?php echo $this->field_id( array( 'fav_topic', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
537 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'fav_topic', 'limit' ) ), $this->field_id( array( 'fav_topic', 'limit' ) ), $prefs['fav_topic']['limit'] ); ?>
|
538 |
-
</div>
|
539 |
-
</div>
|
540 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
541 |
-
<div class="form-group">
|
542 |
-
<label for="<?php echo $this->field_id( array( 'fav_topic', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
543 |
-
<input type="text" name="<?php echo $this->field_name( array( 'fav_topic', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'fav_topic', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['fav_topic']['log'] ); ?>" class="form-control" />
|
544 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
545 |
-
</div>
|
546 |
-
</div>
|
547 |
-
</div>
|
548 |
-
</div>
|
549 |
-
<div class="hook-instance">
|
550 |
-
<h3><?php _e( 'New Topic', 'mycred' ); ?></h3>
|
551 |
-
<div class="row">
|
552 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
553 |
-
<div class="form-group">
|
554 |
-
<label for="<?php echo $this->field_id( array( 'new_reply', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
555 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_reply', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_reply', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_reply']['creds'] ); ?>" class="form-control" />
|
556 |
-
</div>
|
557 |
-
</div>
|
558 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
559 |
-
<div class="form-group">
|
560 |
-
<label for="<?php echo $this->field_id( array( 'new_reply', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
561 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_reply', 'limit' ) ), $this->field_id( array( 'new_reply', 'limit' ) ), $prefs['new_reply']['limit'] ); ?>
|
562 |
-
</div>
|
563 |
-
</div>
|
564 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
565 |
-
<div class="form-group">
|
566 |
-
<label for="<?php echo $this->field_id( array( 'new_reply', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
567 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_reply', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_reply', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_reply']['log'] ); ?>" class="form-control" />
|
568 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
569 |
-
</div>
|
570 |
-
</div>
|
571 |
-
</div>
|
572 |
-
<div class="row">
|
573 |
-
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
574 |
-
<div class="form-group">
|
575 |
-
<div class="radio">
|
576 |
-
<label for="<?php echo $this->field_id( array( 'new_reply' => 'author' ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'new_reply' => 'author' ) ); ?>" id="<?php echo $this->field_id( array( 'new_reply' => 'author' ) ); ?>" <?php checked( $prefs['new_reply']['author'], 1 ); ?> value="1" /> <?php echo $this->core->template_tags_general( __( 'Topic authors can receive %_plural% for replying to their own Topic.', 'mycred' ) ); ?></label>
|
577 |
-
</div>
|
578 |
-
</div>
|
579 |
-
</div>
|
580 |
-
</div>
|
581 |
-
</div>
|
582 |
-
<div class="hook-instance">
|
583 |
-
<h3><?php _e( 'Deleted Reply', 'mycred' ); ?></h3>
|
584 |
-
<div class="row">
|
585 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
586 |
-
<div class="form-group">
|
587 |
-
<label for="<?php echo $this->field_id( array( 'delete_reply', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
588 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_reply', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_reply', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['delete_reply']['creds'] ); ?>" class="form-control" />
|
589 |
-
</div>
|
590 |
-
</div>
|
591 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
592 |
-
<div class="form-group">
|
593 |
-
<label for="<?php echo $this->field_id( array( 'delete_reply', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
594 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_reply', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_reply', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_reply']['log'] ); ?>" class="form-control" />
|
595 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
596 |
-
</div>
|
597 |
-
</div>
|
598 |
-
</div>
|
599 |
-
</div>
|
600 |
-
<div class="hook-instance">
|
601 |
-
<div class="row">
|
602 |
-
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
603 |
-
<div class="form-group">
|
604 |
-
<div class="radio">
|
605 |
-
<label for="<?php echo $this->field_id( 'show_points_in_reply' ); ?>"><input type="checkbox" name="<?php echo $this->field_name( 'show_points_in_reply' ); ?>" id="<?php echo $this->field_id( 'show_points_in_reply' ); ?>" <?php checked( $prefs['show_points_in_reply'], 1 ); ?> value="1" /> <?php echo $this->core->template_tags_general( __( 'Show users %_plural% balance in replies', 'mycred' ) ); ?></label>
|
606 |
-
</div>
|
607 |
-
<div class="radio">
|
608 |
-
<label for="<?php echo $this->field_id( 'show_points_in_profile' ); ?>"><input type="checkbox" name="<?php echo $this->field_name( 'show_points_in_profile' ); ?>" id="<?php echo $this->field_id( 'show_points_in_profile' ); ?>" <?php checked( $prefs['show_points_in_profile'], 1 ); ?> value="1" /> <?php echo $this->core->template_tags_general( __( 'Show users %_plural% balance in their bbPress profiles', 'mycred' ) ); ?></label>
|
609 |
-
</div>
|
610 |
-
</div>
|
611 |
-
</div>
|
612 |
-
</div>
|
613 |
-
</div>
|
614 |
-
<?php
|
615 |
-
|
616 |
-
}
|
617 |
-
|
618 |
-
/**
|
619 |
-
* Sanitise Preference
|
620 |
-
* @since 1.1.1
|
621 |
-
* @version 1.1
|
622 |
-
*/
|
623 |
-
public function sanitise_preferences( $data ) {
|
624 |
-
|
625 |
-
if ( isset( $data['new_forum']['limit'] ) && isset( $data['new_forum']['limit_by'] ) ) {
|
626 |
-
$limit = sanitize_text_field( $data['new_forum']['limit'] );
|
627 |
-
if ( $limit == '' ) $limit = 0;
|
628 |
-
$data['new_forum']['limit'] = $limit . '/' . $data['new_forum']['limit_by'];
|
629 |
-
unset( $data['new_forum']['limit_by'] );
|
630 |
-
}
|
631 |
-
|
632 |
-
if ( isset( $data['new_topic']['limit'] ) && isset( $data['new_topic']['limit_by'] ) ) {
|
633 |
-
$limit = sanitize_text_field( $data['new_topic']['limit'] );
|
634 |
-
if ( $limit == '' ) $limit = 0;
|
635 |
-
$data['new_topic']['limit'] = $limit . '/' . $data['new_topic']['limit_by'];
|
636 |
-
unset( $data['new_topic']['limit_by'] );
|
637 |
-
}
|
638 |
-
|
639 |
-
if ( isset( $data['fav_topic']['limit'] ) && isset( $data['fav_topic']['limit_by'] ) ) {
|
640 |
-
$limit = sanitize_text_field( $data['fav_topic']['limit'] );
|
641 |
-
if ( $limit == '' ) $limit = 0;
|
642 |
-
$data['fav_topic']['limit'] = $limit . '/' . $data['fav_topic']['limit_by'];
|
643 |
-
unset( $data['fav_topic']['limit_by'] );
|
644 |
-
}
|
645 |
-
|
646 |
-
if ( isset( $data['new_reply']['limit'] ) && isset( $data['new_reply']['limit_by'] ) ) {
|
647 |
-
$limit = sanitize_text_field( $data['new_reply']['limit'] );
|
648 |
-
if ( $limit == '' ) $limit = 0;
|
649 |
-
$data['new_reply']['limit'] = $limit . '/' . $data['new_reply']['limit_by'];
|
650 |
-
unset( $data['new_reply']['limit_by'] );
|
651 |
-
}
|
652 |
-
|
653 |
-
$data['new_topic']['author'] = ( isset( $data['new_topic']['author'] ) ) ? 1 : 0;
|
654 |
-
$data['new_reply']['author'] = ( isset( $data['new_reply']['author'] ) ) ? 1 : 0;
|
655 |
-
|
656 |
-
$data['show_points_in_reply'] = ( isset( $data['show_points_in_reply'] ) ) ? 1 : 0;
|
657 |
-
$data['show_points_in_profile'] = ( isset( $data['show_points_in_profile'] ) ) ? 1 : 0;
|
658 |
-
|
659 |
-
return $data;
|
660 |
-
}
|
661 |
-
|
662 |
-
}
|
663 |
-
|
664 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-buddypress-gallery.php
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* BuddyPress Gallery Hook
|
5 |
-
* @since 0.1
|
6 |
-
* @version 1.0.1
|
7 |
-
*/
|
8 |
-
if ( defined( 'myCRED_VERSION' ) ) {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Register Hook
|
12 |
-
* @since 0.1
|
13 |
-
* @version 1.0
|
14 |
-
*/
|
15 |
-
add_filter( 'mycred_setup_hooks', 'BuddyPress_Gallery_myCRED_Hook' );
|
16 |
-
function BuddyPress_Gallery_myCRED_Hook( $installed ) {
|
17 |
-
|
18 |
-
$installed['hook_bp_gallery'] = array(
|
19 |
-
'title' => __( 'BuddyPress: Gallery Actions', 'mycred' ),
|
20 |
-
'description' => __( 'Awards %_plural% for creating a new gallery either using BP Album+ or BP Gallery.', 'mycred' ),
|
21 |
-
'callback' => array( 'myCRED_BuddyPress_Gallery' )
|
22 |
-
);
|
23 |
-
|
24 |
-
return $installed;
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* myCRED_BuddyPress_Gallery class
|
29 |
-
*
|
30 |
-
* Creds for creating a gallery or deleting gallery
|
31 |
-
* @since 0.1
|
32 |
-
* @version 1.0
|
33 |
-
*/
|
34 |
-
if ( ! class_exists( 'myCRED_BuddyPress_Gallery' ) && class_exists( 'myCRED_Hook' ) ) {
|
35 |
-
class myCRED_BuddyPress_Gallery extends myCRED_Hook {
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Construct
|
39 |
-
*/
|
40 |
-
function __construct( $hook_prefs, $type = 'mycred_default' ) {
|
41 |
-
parent::__construct( array(
|
42 |
-
'id' => 'hook_bp_gallery',
|
43 |
-
'defaults' => array(
|
44 |
-
'new_gallery' => array(
|
45 |
-
'creds' => 1,
|
46 |
-
'log' => '%plural% for new gallery'
|
47 |
-
)
|
48 |
-
)
|
49 |
-
), $hook_prefs, $type );
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Run
|
54 |
-
* @since 0.1
|
55 |
-
* @version 1.0
|
56 |
-
*/
|
57 |
-
public function run() {
|
58 |
-
if ( $this->prefs['new_gallery']['creds'] != 0 ) {
|
59 |
-
add_action( 'bp_gallplus_data_after_save', array( $this, 'new_gallery' ) );
|
60 |
-
add_action( 'bp_album_data_after_save', array( $this, 'new_gallery' ) );
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* New Gallery
|
66 |
-
* @since 0.1
|
67 |
-
* @version 1.1
|
68 |
-
*/
|
69 |
-
public function new_gallery( $gallery ) {
|
70 |
-
// Check if user is excluded
|
71 |
-
if ( $this->core->exclude_user( $gallery->owner_id ) ) return;
|
72 |
-
|
73 |
-
// Make sure this is unique event
|
74 |
-
if ( $this->core->has_entry( 'new_buddypress_gallery', $gallery->id ) ) return;
|
75 |
-
|
76 |
-
// Execute
|
77 |
-
$this->core->add_creds(
|
78 |
-
'new_buddypress_gallery',
|
79 |
-
$gallery->owner_id,
|
80 |
-
$this->prefs['new_gallery']['creds'],
|
81 |
-
$this->prefs['new_gallery']['log'],
|
82 |
-
$gallery->id,
|
83 |
-
'bp_gallery',
|
84 |
-
$this->mycred_type
|
85 |
-
);
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Preferences
|
90 |
-
* @since 0.1
|
91 |
-
* @version 1.0
|
92 |
-
*/
|
93 |
-
public function preferences() {
|
94 |
-
$prefs = $this->prefs; ?>
|
95 |
-
|
96 |
-
<!-- Creds for New Gallery -->
|
97 |
-
<label for="<?php echo $this->field_id( array( 'new_gallery', 'creds' ) ); ?>" class="subheader"><?php echo $this->core->template_tags_general( __( '%plural% for New Gallery', 'mycred' ) ); ?></label>
|
98 |
-
<ol>
|
99 |
-
<li>
|
100 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'new_gallery', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_gallery', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_gallery']['creds'] ); ?>" size="8" /></div>
|
101 |
-
</li>
|
102 |
-
<li class="empty"> </li>
|
103 |
-
<li>
|
104 |
-
<label for="<?php echo $this->field_id( array( 'new_gallery', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
105 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'new_gallery', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_gallery', 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['new_gallery']['log'] ); ?>" class="long" /></div>
|
106 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
107 |
-
</li>
|
108 |
-
</ol>
|
109 |
-
<?php
|
110 |
-
}
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
}
|
115 |
-
|
116 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-buddypress-links.php
DELETED
@@ -1,329 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* BuddyPress Links Hook
|
5 |
-
* @since 0.1
|
6 |
-
* @version 1.0
|
7 |
-
*/
|
8 |
-
if ( defined( 'myCRED_VERSION' ) ) {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Register Hook
|
12 |
-
* @since 0.1
|
13 |
-
* @version 1.0
|
14 |
-
*/
|
15 |
-
add_filter( 'mycred_setup_hooks', 'BuddyPress_Links_myCRED_Hook' );
|
16 |
-
function BuddyPress_Links_myCRED_Hook( $installed ) {
|
17 |
-
|
18 |
-
$installed['hook_bp_links'] = array(
|
19 |
-
'title' => __( 'BuddyPress: Links', 'mycred' ),
|
20 |
-
'description' => __( 'Awards %_plural% for link related actions.', 'mycred' ),
|
21 |
-
'callback' => array( 'myCRED_BuddyPress_Links' )
|
22 |
-
);
|
23 |
-
|
24 |
-
return $installed;
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* myCRED_BuddyPress_Links class
|
29 |
-
* Creds for new links, voting on links, updating links and deleting links
|
30 |
-
* @since 0.1
|
31 |
-
* @version 1.1
|
32 |
-
*/
|
33 |
-
if ( ! class_exists( 'myCRED_BuddyPress_Links' ) && class_exists( 'myCRED_Hook' ) ) {
|
34 |
-
class myCRED_BuddyPress_Links extends myCRED_Hook {
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Construct
|
38 |
-
*/
|
39 |
-
function __construct( $hook_prefs, $type = 'mycred_default' ) {
|
40 |
-
parent::__construct( array(
|
41 |
-
'id' => 'hook_bp_links',
|
42 |
-
'defaults' => array(
|
43 |
-
'new_link' => array(
|
44 |
-
'creds' => 1,
|
45 |
-
'log' => '%plural% for new Link'
|
46 |
-
),
|
47 |
-
'vote_link' => array(
|
48 |
-
'creds' => 1,
|
49 |
-
'log' => '%plural% for voting on a link'
|
50 |
-
),
|
51 |
-
'vote_link_up' => array(
|
52 |
-
'creds' => 1,
|
53 |
-
'log' => '%plural% for your link voted up'
|
54 |
-
),
|
55 |
-
'vote_link_down' => array(
|
56 |
-
'creds' => 1,
|
57 |
-
'log' => '%plural% for your link voted down'
|
58 |
-
),
|
59 |
-
'update_link' => array(
|
60 |
-
'creds' => 1,
|
61 |
-
'log' => '%plural% for updating link'
|
62 |
-
),
|
63 |
-
'delete_link' => array(
|
64 |
-
'creds' => '-1',
|
65 |
-
'log' => '%singular% deduction for deleting a link'
|
66 |
-
),
|
67 |
-
)
|
68 |
-
), $hook_prefs, $type );
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Run
|
73 |
-
* @since 0.1
|
74 |
-
* @version 1.1
|
75 |
-
*/
|
76 |
-
public function run() {
|
77 |
-
if ( $this->prefs['new_link']['creds'] != 0 )
|
78 |
-
add_action( 'bp_links_create_complete', array( $this, 'create_link' ) );
|
79 |
-
|
80 |
-
add_action( 'bp_links_cast_vote_success', array( $this, 'vote_link' ) );
|
81 |
-
|
82 |
-
if ( $this->prefs['update_link']['creds'] != 0 )
|
83 |
-
add_action( 'bp_links_posted_update', array( $this, 'update_link' ), 20, 4 );
|
84 |
-
|
85 |
-
if ( $this->prefs['delete_link']['creds'] != 0 )
|
86 |
-
add_action( 'bp_links_delete_link', array( $this, 'delete_link' ) );
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* New Link
|
91 |
-
* @since 0.1
|
92 |
-
* @version 1.0
|
93 |
-
*/
|
94 |
-
public function create_link( $link_id ) {
|
95 |
-
global $bp;
|
96 |
-
|
97 |
-
// Check if user is excluded
|
98 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
99 |
-
|
100 |
-
// Make sure this is unique event
|
101 |
-
if ( $this->core->has_entry( 'new_link', $link_id, $bp->loggedin_user->id ) ) return;
|
102 |
-
|
103 |
-
// Execute
|
104 |
-
$this->core->add_creds(
|
105 |
-
'new_link',
|
106 |
-
$bp->loggedin_user->id,
|
107 |
-
$this->prefs['new_link']['creds'],
|
108 |
-
$this->prefs['new_link']['log'],
|
109 |
-
$link_id,
|
110 |
-
'bp_links',
|
111 |
-
$this->mycred_type
|
112 |
-
);
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Vote on Link
|
117 |
-
* @since 0.1
|
118 |
-
* @version 1.1
|
119 |
-
*/
|
120 |
-
public function vote_link( $link_id ) {
|
121 |
-
global $bp;
|
122 |
-
|
123 |
-
// Check if user is excluded
|
124 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
125 |
-
|
126 |
-
// Make sure this is unique event
|
127 |
-
if ( $this->core->has_entry( 'link_voting', $link_id, $bp->loggedin_user->id ) ) return;
|
128 |
-
|
129 |
-
// Get the vote
|
130 |
-
$vote = '';
|
131 |
-
if ( isset( $_REQUEST['up_or_down'] ) )
|
132 |
-
$vote = substr( $_REQUEST['up_or_down'], 0, 4 );
|
133 |
-
|
134 |
-
// First if we award points for voting, do so now
|
135 |
-
if ( $this->prefs['vote_link']['creds'] != 0 ) {
|
136 |
-
// Execute
|
137 |
-
$this->core->add_creds(
|
138 |
-
'link_voting',
|
139 |
-
$bp->loggedin_user->id,
|
140 |
-
$this->prefs['vote_link']['creds'],
|
141 |
-
$this->prefs['vote_link']['log'],
|
142 |
-
$link_id,
|
143 |
-
'bp_links',
|
144 |
-
$this->mycred_type
|
145 |
-
);
|
146 |
-
}
|
147 |
-
|
148 |
-
// Get link author
|
149 |
-
if ( isset( $bp->links->current_link->user_id ) )
|
150 |
-
$author = $bp->links->current_link->user_id;
|
151 |
-
|
152 |
-
// Link author not found
|
153 |
-
else
|
154 |
-
return;
|
155 |
-
|
156 |
-
// By default we do not allow votes on our own links
|
157 |
-
if ( $author == $bp->loggedin_user->id && apply_filters( 'mycred_bp_link_self_vote', false ) === false ) return;
|
158 |
-
|
159 |
-
// Up Vote
|
160 |
-
if ( $vote == 'up' && $this->prefs['vote_link_up']['creds'] != 0 ) {
|
161 |
-
// Execute
|
162 |
-
$this->core->add_creds(
|
163 |
-
'link_voting',
|
164 |
-
$author,
|
165 |
-
$this->prefs['vote_link_up']['creds'],
|
166 |
-
$this->prefs['vote_link_up']['log'],
|
167 |
-
$link_id,
|
168 |
-
'bp_links',
|
169 |
-
$this->mycred_type
|
170 |
-
);
|
171 |
-
}
|
172 |
-
|
173 |
-
// Down Vote
|
174 |
-
elseif ( $vote == 'down' && $this->prefs['vote_link_down']['creds'] != 0 ) {
|
175 |
-
// Execute
|
176 |
-
$this->core->add_creds(
|
177 |
-
'link_voting',
|
178 |
-
$author,
|
179 |
-
$this->prefs['vote_link_down']['creds'],
|
180 |
-
$this->prefs['vote_link_down']['log'],
|
181 |
-
$link_id,
|
182 |
-
'bp_links',
|
183 |
-
$this->mycred_type
|
184 |
-
);
|
185 |
-
}
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Update Link
|
190 |
-
* @since 0.1
|
191 |
-
* @version 1.0
|
192 |
-
*/
|
193 |
-
public function update_link( $content, $user_id, $link_id, $activity_id ) {
|
194 |
-
// Check if user is excluded
|
195 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
196 |
-
|
197 |
-
// Make sure this is unique event
|
198 |
-
if ( $this->core->has_entry( 'update_link', $activity_id, $user_id ) ) return;
|
199 |
-
|
200 |
-
// Execute
|
201 |
-
$this->core->add_creds(
|
202 |
-
'update_link',
|
203 |
-
$user_id,
|
204 |
-
$this->prefs['update_link']['creds'],
|
205 |
-
$this->prefs['update_link']['log'],
|
206 |
-
$activity_id,
|
207 |
-
'bp_links',
|
208 |
-
$this->mycred_type
|
209 |
-
);
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Delete Link
|
214 |
-
* @since 0.1
|
215 |
-
* @version 1.0
|
216 |
-
*/
|
217 |
-
public function delete_link( $link_id ) {
|
218 |
-
global $bp;
|
219 |
-
|
220 |
-
// Check if user is excluded
|
221 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
222 |
-
|
223 |
-
// Make sure this is unique event
|
224 |
-
if ( $this->core->has_entry( 'link_deletion', $link_id, $bp->loggedin_user->id ) ) return;
|
225 |
-
|
226 |
-
// Execute
|
227 |
-
$this->core->add_creds(
|
228 |
-
'link_deletion',
|
229 |
-
$bp->loggedin_user->id,
|
230 |
-
$this->prefs['delete_link']['creds'],
|
231 |
-
$this->prefs['delete_link']['log'],
|
232 |
-
$link_id,
|
233 |
-
'bp_links',
|
234 |
-
$this->mycred_type
|
235 |
-
);
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Preferences
|
240 |
-
* @since 0.1
|
241 |
-
* @version 1.1
|
242 |
-
*/
|
243 |
-
public function preferences() {
|
244 |
-
$prefs = $this->prefs; ?>
|
245 |
-
|
246 |
-
<!-- Creds for New Link -->
|
247 |
-
<label for="<?php echo $this->field_id( array( 'new_link', 'creds' ) ); ?>" class="subheader"><?php echo $this->core->template_tags_general( __( '%plural% for New Links', 'mycred' ) ); ?></label>
|
248 |
-
<ol>
|
249 |
-
<li>
|
250 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'new_link', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_link', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_link']['creds'] ); ?>" size="8" /></div>
|
251 |
-
</li>
|
252 |
-
<li class="empty"> </li>
|
253 |
-
<li>
|
254 |
-
<label for="<?php echo $this->field_id( array( 'new_link', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
255 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'new_link', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_link', 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['new_link']['log'] ); ?>" class="long" /></div>
|
256 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
257 |
-
</li>
|
258 |
-
</ol>
|
259 |
-
<!-- Creds for Vote Link -->
|
260 |
-
<label for="<?php echo $this->field_id( array( 'vote_link', 'creds' ) ); ?>" class="subheader"><?php echo $this->core->template_tags_general( __( '%plural% for Vote on Link', 'mycred' ) ); ?></label>
|
261 |
-
<ol>
|
262 |
-
<li>
|
263 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'vote_link', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'vote_link', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['vote_link']['creds'] ); ?>" size="8" /></div>
|
264 |
-
</li>
|
265 |
-
<li class="empty"> </li>
|
266 |
-
<li>
|
267 |
-
<label for="<?php echo $this->field_id( array( 'vote_link', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
268 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'vote_link', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'vote_link', 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['vote_link']['log'] ); ?>" class="long" /></div>
|
269 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
270 |
-
</li>
|
271 |
-
</ol>
|
272 |
-
<label for="<?php echo $this->field_id( array( 'vote_link_up', 'creds' ) ); ?>" class="subheader"><?php echo $this->core->template_tags_general( __( '%plural% per received Vote', 'mycred' ) ); ?></label>
|
273 |
-
<ol>
|
274 |
-
<li>
|
275 |
-
<label><?php _e( 'Vote Up', 'mycred' ); ?></label>
|
276 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'vote_link_up', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'vote_link_up', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['vote_link_up']['creds'] ); ?>" size="8" /></div>
|
277 |
-
</li>
|
278 |
-
<li class="empty"> </li>
|
279 |
-
<li>
|
280 |
-
<label for="<?php echo $this->field_id( array( 'vote_link_up', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
281 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'vote_link_up', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'vote_link_up', 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['vote_link_up']['log'] ); ?>" class="long" /></div>
|
282 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
283 |
-
</li>
|
284 |
-
<li class="empty"> </li>
|
285 |
-
<li>
|
286 |
-
<label><?php _e( 'Vote Down', 'mycred' ); ?></label>
|
287 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'vote_link_down', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'vote_link_down', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['vote_link_down']['creds'] ); ?>" size="8" /></div>
|
288 |
-
</li>
|
289 |
-
<li class="empty"> </li>
|
290 |
-
<li>
|
291 |
-
<label for="<?php echo $this->field_id( array( 'vote_link_down', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
292 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'vote_link_down', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'vote_link_down', 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['vote_link_down']['log'] ); ?>" class="long" /></div>
|
293 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
294 |
-
</li>
|
295 |
-
</ol>
|
296 |
-
<!-- Creds for Update Link -->
|
297 |
-
<label for="<?php echo $this->field_id( array( 'update_link', 'creds' ) ); ?>" class="subheader"><?php echo $this->core->template_tags_general( __( '%plural% for Updating Links', 'mycred' ) ); ?></label>
|
298 |
-
<ol>
|
299 |
-
<li>
|
300 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'update_link', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'update_link', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['update_link']['creds'] ); ?>" size="8" /></div>
|
301 |
-
</li>
|
302 |
-
<li class="empty"> </li>
|
303 |
-
<li>
|
304 |
-
<label for="<?php echo $this->field_id( array( 'update_link', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
305 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'update_link', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'update_link', 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['update_link']['log'] ); ?>" class="long" /></div>
|
306 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
307 |
-
</li>
|
308 |
-
</ol>
|
309 |
-
<!-- Creds for Deleting Links -->
|
310 |
-
<label for="<?php echo $this->field_id( array( 'delete_link', 'creds' ) ); ?>" class="subheader"><?php echo $this->core->template_tags_general( __( '%plural% for Deleting Links', 'mycred' ) ); ?></label>
|
311 |
-
<ol>
|
312 |
-
<li>
|
313 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'delete_link', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_link', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['delete_link']['creds'] ); ?>" size="8" /></div>
|
314 |
-
</li>
|
315 |
-
<li class="empty"> </li>
|
316 |
-
<li>
|
317 |
-
<label for="<?php echo $this->field_id( array( 'delete_link', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
318 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'delete_link', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_link', 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['delete_link']['log'] ); ?>" class="long" /></div>
|
319 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
320 |
-
</li>
|
321 |
-
</ol>
|
322 |
-
<?php
|
323 |
-
}
|
324 |
-
}
|
325 |
-
}
|
326 |
-
|
327 |
-
}
|
328 |
-
|
329 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-buddypress-media.php
DELETED
@@ -1,453 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.4
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_buddypress_media_hook', 35 );
|
10 |
-
function mycred_register_buddypress_media_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! function_exists( 'rtmedia_autoloader' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['rtmedia'] = array(
|
15 |
-
'title' => __( 'rtMedia Galleries', 'mycred' ),
|
16 |
-
'description' => __( 'Award / Deduct %_plural% for users creating albums or uploading new photos.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/rtmedia-uploads/',
|
18 |
-
'callback' => array( 'myCRED_rtMedia' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* rtMedia Hook
|
27 |
-
* @since 1.4
|
28 |
-
* @version 1.1.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_buddypress_media_hook', 35 );
|
31 |
-
function mycred_load_buddypress_media_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_rtMedia' ) || ! function_exists( 'rtmedia_autoloader' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_rtMedia extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = 'mycred_default' ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'rtmedia',
|
45 |
-
'defaults' => array(
|
46 |
-
'new_media' => array(
|
47 |
-
'photo' => 0,
|
48 |
-
'photo_log' => '%plural% for new photo',
|
49 |
-
'photo_limit' => '0/x',
|
50 |
-
'video' => 0,
|
51 |
-
'video_log' => '%plural% for new video',
|
52 |
-
'video_limit' => '0/x',
|
53 |
-
'music' => 0,
|
54 |
-
'music_log' => '%plural% for new music',
|
55 |
-
'music_limit' => '0/x',
|
56 |
-
),
|
57 |
-
'delete_media' => array(
|
58 |
-
'photo' => 0,
|
59 |
-
'photo_log' => '%plural% for deleting photo',
|
60 |
-
'video' => 0,
|
61 |
-
'video_log' => '%plural% for deleting video',
|
62 |
-
'music' => 0,
|
63 |
-
'music_log' => '%plural% for deleting music'
|
64 |
-
)
|
65 |
-
)
|
66 |
-
), $hook_prefs, $type );
|
67 |
-
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Run
|
72 |
-
* @since 1.4
|
73 |
-
* @version 1.0.1
|
74 |
-
*/
|
75 |
-
public function run() {
|
76 |
-
|
77 |
-
add_action( 'rtmedia_after_add_media', array( $this, 'new_media' ) );
|
78 |
-
add_action( 'rtmedia_before_delete_media', array( $this, 'delete_media' ) );
|
79 |
-
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* New Media
|
84 |
-
* @since 1.4
|
85 |
-
* @version 1.2.2
|
86 |
-
*/
|
87 |
-
public function new_media( $media_ids ) {
|
88 |
-
|
89 |
-
// Loop through all uploaded files
|
90 |
-
foreach ( $media_ids as $media_id ) {
|
91 |
-
|
92 |
-
// Get media details from id
|
93 |
-
$model = new RTMediaModel();
|
94 |
-
$media = $model->get_media( array( 'id' => $media_id ) );
|
95 |
-
|
96 |
-
if ( ! isset( $media[0]->media_type ) ) continue;
|
97 |
-
|
98 |
-
$reference = $media[0]->media_type . '_upload';
|
99 |
-
$user_id = $media[0]->media_author;
|
100 |
-
|
101 |
-
if ( $this->core->exclude_user( $user_id ) ) continue;
|
102 |
-
|
103 |
-
$points = $this->prefs['new_media'][ $media[0]->media_type ];
|
104 |
-
$log_entry = $this->prefs['new_media'][ $media[0]->media_type . '_log' ];
|
105 |
-
$data = array( 'ref_type' => 'media', 'attachment_id' => $media_id );
|
106 |
-
|
107 |
-
// If this media type awards zero, bail
|
108 |
-
if ( $points == $this->core->zero() ) continue;
|
109 |
-
|
110 |
-
// Limit
|
111 |
-
if ( $this->over_hook_limit( $media[0]->media_type . '_limit', $reference, $user_id ) ) continue;
|
112 |
-
|
113 |
-
// Make sure this is unique
|
114 |
-
if ( ! $this->core->has_entry( $reference, $media_id, $user_id ) )
|
115 |
-
$this->core->add_creds(
|
116 |
-
$reference,
|
117 |
-
$user_id,
|
118 |
-
$points,
|
119 |
-
$log_entry,
|
120 |
-
$media_id,
|
121 |
-
$data,
|
122 |
-
$this->mycred_type
|
123 |
-
);
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Delete Media
|
131 |
-
* @since 1.4
|
132 |
-
* @version 1.1.2
|
133 |
-
*/
|
134 |
-
public function delete_media( $media_id ) {
|
135 |
-
|
136 |
-
// Get media details from id
|
137 |
-
$model = new RTMediaModel();
|
138 |
-
$media = $model->get_media( array( 'id' => $media_id ) );
|
139 |
-
|
140 |
-
if ( ! isset( $media[0]->media_type ) ) return;
|
141 |
-
|
142 |
-
$reference = $media[0]->media_type . '_deletion';
|
143 |
-
$user_id = $media[0]->media_author;
|
144 |
-
$points = $this->prefs['delete_media'][ $media[0]->media_type ];
|
145 |
-
$log_entry = $this->prefs['delete_media'][ $media[0]->media_type . '_log' ];
|
146 |
-
$data = array( 'ref_type' => 'media', 'attachment_id' => $media_id );
|
147 |
-
|
148 |
-
// If this media type awards zero, bail
|
149 |
-
if ( $points == $this->core->zero() ) return;
|
150 |
-
|
151 |
-
// Check for exclusion
|
152 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
153 |
-
|
154 |
-
// Only delete points once
|
155 |
-
if ( ! $this->core->has_entry( $reference, $media_id, $user_id ) )
|
156 |
-
$this->core->add_creds(
|
157 |
-
$reference,
|
158 |
-
$user_id,
|
159 |
-
$points,
|
160 |
-
$log_entry,
|
161 |
-
$media_id,
|
162 |
-
$data,
|
163 |
-
$this->mycred_type
|
164 |
-
);
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Check Limit
|
170 |
-
* @since 1.6
|
171 |
-
* @version 1.1
|
172 |
-
*/
|
173 |
-
function over_hook_limit( $instance = '', $reference = '', $user_id = NULL, $ref_id = NULL ) {
|
174 |
-
|
175 |
-
global $wpdb;
|
176 |
-
|
177 |
-
// Prep
|
178 |
-
$wheres = array();
|
179 |
-
$now = current_time( 'timestamp' );
|
180 |
-
|
181 |
-
// If hook uses multiple instances
|
182 |
-
if ( isset( $this->prefs['new_media'][ $instance ] ) )
|
183 |
-
$prefs = $this->prefs['new_media'][ $instance ];
|
184 |
-
|
185 |
-
// no support for limits
|
186 |
-
else return false;
|
187 |
-
|
188 |
-
if ( count( explode( '/', $prefs ) ) != 2 )
|
189 |
-
$prefs = '0/x';
|
190 |
-
|
191 |
-
// Prep settings
|
192 |
-
list ( $amount, $period ) = explode( '/', $prefs );
|
193 |
-
$amount = (int) $amount;
|
194 |
-
|
195 |
-
// We start constructing the query.
|
196 |
-
$wheres[] = $wpdb->prepare( "user_id = %d", $user_id );
|
197 |
-
$wheres[] = $wpdb->prepare( "ref = %s", $reference );
|
198 |
-
$wheres[] = $wpdb->prepare( "ctype = %s", $this->mycred_type );
|
199 |
-
|
200 |
-
// If check is based on time
|
201 |
-
if ( ! in_array( $period, array( 't', 'x' ) ) ) {
|
202 |
-
|
203 |
-
// Per day
|
204 |
-
if ( $period == 'd' )
|
205 |
-
$from = mktime( 0, 0, 0, date( 'n', $now ), date( 'j', $now ), date( 'Y', $now ) );
|
206 |
-
|
207 |
-
// Per week
|
208 |
-
elseif ( $period == 'w' )
|
209 |
-
$from = mktime( 0, 0, 0, date( "n", $now ), date( "j", $now ) - date( "N", $now ) + 1 );
|
210 |
-
|
211 |
-
// Per Month
|
212 |
-
elseif ( $period == 'm' )
|
213 |
-
$from = mktime( 0, 0, 0, date( "n", $now ), 1, date( 'Y', $now ) );
|
214 |
-
|
215 |
-
$wheres[] = $wpdb->prepare( "time BETWEEN %d AND %d", $from, $now );
|
216 |
-
|
217 |
-
}
|
218 |
-
|
219 |
-
// Put all wheres together into one string
|
220 |
-
$wheres = implode( " AND ", $wheres );
|
221 |
-
|
222 |
-
// Count
|
223 |
-
$count = $wpdb->get_var( "SELECT COUNT(*) FROM {$this->core->log_table} WHERE {$wheres};" );
|
224 |
-
if ( $count === NULL ) $count = 0;
|
225 |
-
|
226 |
-
$over_limit = false;
|
227 |
-
if ( $period != 'x' && $count >= $amount )
|
228 |
-
$over_limit = true;
|
229 |
-
|
230 |
-
return $over_limit;
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* Adjust Limit Name
|
236 |
-
* @since 1.6
|
237 |
-
* @version 1.0
|
238 |
-
*/
|
239 |
-
public function hook_limit_name( $name ) {
|
240 |
-
|
241 |
-
$name = str_replace( '[photo_limit]', '[photo_limit_by]', $name );
|
242 |
-
$name = str_replace( '[video_limit]', '[video_limit_by]', $name );
|
243 |
-
$name = str_replace( '[music_limit]', '[music_limit_by]', $name );
|
244 |
-
return $name;
|
245 |
-
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* Adjust Limit ID
|
250 |
-
* @since 1.6
|
251 |
-
* @version 1.0
|
252 |
-
*/
|
253 |
-
public function hook_limit_id( $id ) {
|
254 |
-
|
255 |
-
$id = str_replace( 'photo-limit', 'photo-limit-by', $id );
|
256 |
-
$id = str_replace( 'video-limit', 'video-limit-by', $id );
|
257 |
-
$id = str_replace( 'music-limit', 'music-limit-by', $id );
|
258 |
-
return $id;
|
259 |
-
|
260 |
-
}
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Preferences for rtMedia Gallery Hook
|
264 |
-
* @since 1.4
|
265 |
-
* @version 1.1
|
266 |
-
*/
|
267 |
-
public function preferences() {
|
268 |
-
|
269 |
-
$prefs = $this->prefs;
|
270 |
-
|
271 |
-
global $rtmedia;
|
272 |
-
|
273 |
-
$photos = ' readonly="readonly"';
|
274 |
-
if ( array_key_exists( 'allowedTypes_photo_enabled', $rtmedia->options ) && $rtmedia->options['allowedTypes_photo_enabled'] == 1 )
|
275 |
-
$photos = '';
|
276 |
-
|
277 |
-
$videos = ' readonly="readonly"';
|
278 |
-
if ( array_key_exists( 'allowedTypes_video_enabled', $rtmedia->options ) && $rtmedia->options['allowedTypes_video_enabled'] == 1 )
|
279 |
-
$videos = '';
|
280 |
-
|
281 |
-
$music = ' readonly="readonly"';
|
282 |
-
if ( array_key_exists( 'allowedTypes_music_enabled', $rtmedia->options ) && $rtmedia->options['allowedTypes_music_enabled'] == 1 )
|
283 |
-
$music = '';
|
284 |
-
|
285 |
-
add_filter( 'mycred_hook_limit_name_by', array( $this, 'hook_limit_name' ) );
|
286 |
-
add_filter( 'mycred_hook_limit_id_by', array( $this, 'hook_limit_id' ) );
|
287 |
-
|
288 |
-
?>
|
289 |
-
<div class="hook-instance">
|
290 |
-
<h3><?php _e( 'Photo Upload', 'mycred' ); ?></h3>
|
291 |
-
<div class="row">
|
292 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
293 |
-
<div class="form-group">
|
294 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'photo' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
295 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_media', 'photo' ) ); ?>" id="<?php echo $this->field_id( array( 'new_media', 'photo' ) ); ?>"<?php echo $photos; ?> value="<?php echo $this->core->number( $prefs['new_media']['photo'] ); ?>" class="form-control" />
|
296 |
-
</div>
|
297 |
-
</div>
|
298 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
299 |
-
<div class="form-group">
|
300 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'photo_limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
301 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_media', 'photo_limit' ) ), $this->field_id( array( 'new_media', 'photo_limit' ) ), $prefs['new_media']['photo_limit'] ); ?>
|
302 |
-
</div>
|
303 |
-
</div>
|
304 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
305 |
-
<div class="form-group">
|
306 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'photo_log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
307 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_media', 'photo_log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_media', 'photo_log' ) ); ?>"<?php echo $photos; ?> placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_media']['photo_log'] ); ?>" class="form-control" />
|
308 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
309 |
-
</div>
|
310 |
-
</div>
|
311 |
-
</div>
|
312 |
-
</div>
|
313 |
-
<div class="hook-instance">
|
314 |
-
<h3><?php _e( 'Video Upload', 'mycred' ); ?></h3>
|
315 |
-
<div class="row">
|
316 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
317 |
-
<div class="form-group">
|
318 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'video' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
319 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_media', 'video' ) ); ?>" id="<?php echo $this->field_id( array( 'new_media', 'video' ) ); ?>"<?php echo $photos; ?> value="<?php echo $this->core->number( $prefs['new_media']['video'] ); ?>" class="form-control" />
|
320 |
-
</div>
|
321 |
-
</div>
|
322 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
323 |
-
<div class="form-group">
|
324 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'video_limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
325 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_media', 'video_limit' ) ), $this->field_id( array( 'new_media', 'video_limit' ) ), $prefs['new_media']['video_limit'] ); ?>
|
326 |
-
</div>
|
327 |
-
</div>
|
328 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
329 |
-
<div class="form-group">
|
330 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'video_log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
331 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_media', 'video_log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_media', 'video_log' ) ); ?>"<?php echo $photos; ?> placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_media']['video_log'] ); ?>" class="form-control" />
|
332 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
333 |
-
</div>
|
334 |
-
</div>
|
335 |
-
</div>
|
336 |
-
</div>
|
337 |
-
<div class="hook-instance">
|
338 |
-
<h3><?php _e( 'Music Upload', 'mycred' ); ?></h3>
|
339 |
-
<div class="row">
|
340 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
341 |
-
<div class="form-group">
|
342 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'music' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
343 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_media', 'music' ) ); ?>" id="<?php echo $this->field_id( array( 'new_media', 'music' ) ); ?>"<?php echo $photos; ?> value="<?php echo $this->core->number( $prefs['new_media']['music'] ); ?>" class="form-control" />
|
344 |
-
</div>
|
345 |
-
</div>
|
346 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
347 |
-
<div class="form-group">
|
348 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'music_limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
349 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_media', 'music_limit' ) ), $this->field_id( array( 'new_media', 'music_limit' ) ), $prefs['new_media']['music_limit'] ); ?>
|
350 |
-
</div>
|
351 |
-
</div>
|
352 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
353 |
-
<div class="form-group">
|
354 |
-
<label for="<?php echo $this->field_id( array( 'new_media', 'music_log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
355 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_media', 'music_log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_media', 'music_log' ) ); ?>"<?php echo $photos; ?> placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_media']['music_log'] ); ?>" class="form-control" />
|
356 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
357 |
-
</div>
|
358 |
-
</div>
|
359 |
-
</div>
|
360 |
-
</div>
|
361 |
-
<div class="hook-instance">
|
362 |
-
<h3><?php _e( 'Photo Deletion', 'mycred' ); ?></h3>
|
363 |
-
<div class="row">
|
364 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
365 |
-
<div class="form-group">
|
366 |
-
<label for="<?php echo $this->field_id( array( 'delete_media', 'photo' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
367 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_media', 'photo' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_media', 'photo' ) ); ?>"<?php echo $photos; ?> value="<?php echo $this->core->number( $prefs['delete_media']['photo'] ); ?>" class="form-control" />
|
368 |
-
</div>
|
369 |
-
</div>
|
370 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
371 |
-
<div class="form-group">
|
372 |
-
<label for="<?php echo $this->field_id( array( 'delete_media', 'photo_log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
373 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_media', 'photo_log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_media', 'photo_log' ) ); ?>"<?php echo $photos; ?> placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_media']['photo_log'] ); ?>" class="form-control" />
|
374 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
375 |
-
</div>
|
376 |
-
</div>
|
377 |
-
</div>
|
378 |
-
</div>
|
379 |
-
<div class="hook-instance">
|
380 |
-
<h3><?php _e( 'Video Deletion', 'mycred' ); ?></h3>
|
381 |
-
<div class="row">
|
382 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
383 |
-
<div class="form-group">
|
384 |
-
<label for="<?php echo $this->field_id( array( 'delete_media', 'video' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
385 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_media', 'video' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_media', 'video' ) ); ?>"<?php echo $photos; ?> value="<?php echo $this->core->number( $prefs['delete_media']['video'] ); ?>" class="form-control" />
|
386 |
-
</div>
|
387 |
-
</div>
|
388 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
389 |
-
<div class="form-group">
|
390 |
-
<label for="<?php echo $this->field_id( array( 'delete_media', 'video_log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
391 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_media', 'video_log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_media', 'video_log' ) ); ?>"<?php echo $photos; ?> placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_media']['video_log'] ); ?>" class="form-control" />
|
392 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
393 |
-
</div>
|
394 |
-
</div>
|
395 |
-
</div>
|
396 |
-
</div>
|
397 |
-
<div class="hook-instance">
|
398 |
-
<h3><?php _e( 'Music Deletion', 'mycred' ); ?></h3>
|
399 |
-
<div class="row">
|
400 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
401 |
-
<div class="form-group">
|
402 |
-
<label for="<?php echo $this->field_id( array( 'delete_media', 'music' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
403 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_media', 'music' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_media', 'music' ) ); ?>"<?php echo $photos; ?> value="<?php echo $this->core->number( $prefs['delete_media']['music'] ); ?>" class="form-control" />
|
404 |
-
</div>
|
405 |
-
</div>
|
406 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
407 |
-
<div class="form-group">
|
408 |
-
<label for="<?php echo $this->field_id( array( 'delete_media', 'music_log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
409 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_media', 'music_log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_media', 'music_log' ) ); ?>"<?php echo $photos; ?> placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_media']['music_log'] ); ?>" class="form-control" />
|
410 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
411 |
-
</div>
|
412 |
-
</div>
|
413 |
-
</div>
|
414 |
-
</div>
|
415 |
-
<?php
|
416 |
-
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* Sanitise Preferences
|
421 |
-
* @since 1.6
|
422 |
-
* @version 1.0.1
|
423 |
-
*/
|
424 |
-
public function sanitise_preferences( $data ) {
|
425 |
-
|
426 |
-
if ( isset( $data['new_media']['photo_limit'] ) && isset( $data['new_media']['photo_limit_by'] ) ) {
|
427 |
-
$limit = sanitize_text_field( $data['new_media']['photo_limit'] );
|
428 |
-
if ( $limit == '' ) $limit = 0;
|
429 |
-
$data['new_media']['photo_limit'] = $limit . '/' . $data['new_media']['photo_limit_by'];
|
430 |
-
unset( $data['new_media']['photo_limit_by'] );
|
431 |
-
}
|
432 |
-
|
433 |
-
if ( isset( $data['new_media']['video_limit'] ) && isset( $data['new_media']['video_limit_by'] ) ) {
|
434 |
-
$limit = sanitize_text_field( $data['new_media']['video_limit'] );
|
435 |
-
if ( $limit == '' ) $limit = 0;
|
436 |
-
$data['new_media']['video_limit'] = $limit . '/' . $data['new_media']['video_limit_by'];
|
437 |
-
unset( $data['new_media']['video_limit_by'] );
|
438 |
-
}
|
439 |
-
|
440 |
-
if ( isset( $data['new_media']['music_limit'] ) && isset( $data['new_media']['music_limit_by'] ) ) {
|
441 |
-
$limit = sanitize_text_field( $data['new_media']['music_limit'] );
|
442 |
-
if ( $limit == '' ) $limit = 0;
|
443 |
-
$data['new_media']['music_limit'] = $limit . '/' . $data['new_media']['music_limit_by'];
|
444 |
-
unset( $data['new_media']['music_limit_by'] );
|
445 |
-
}
|
446 |
-
|
447 |
-
return $data;
|
448 |
-
|
449 |
-
}
|
450 |
-
|
451 |
-
}
|
452 |
-
|
453 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-buddypress.php
DELETED
@@ -1,1828 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 0.1
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_buddypress_hook', 40 );
|
10 |
-
function mycred_register_buddypress_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! class_exists( 'BuddyPress' ) ) return $installed;
|
13 |
-
|
14 |
-
if ( bp_is_active( 'xprofile' ) ) {
|
15 |
-
$installed['hook_bp_profile'] = array(
|
16 |
-
'title' => __( 'BuddyPress: Members', 'mycred' ),
|
17 |
-
'description' => __( 'Awards %_plural% for profile related actions.', 'mycred' ),
|
18 |
-
'documentation' => 'http://codex.mycred.me/hooks/buddypress-profiles/',
|
19 |
-
'callback' => array( 'myCRED_BuddyPress_Profile' )
|
20 |
-
);
|
21 |
-
}
|
22 |
-
|
23 |
-
if ( bp_is_active( 'groups' ) ) {
|
24 |
-
$installed['hook_bp_groups'] = array(
|
25 |
-
'title' => __( 'BuddyPress: Groups', 'mycred' ),
|
26 |
-
'description' => __( 'Awards %_plural% for group related actions. Use minus to deduct %_plural% or zero to disable a specific hook.', 'mycred' ),
|
27 |
-
'documentation' => 'http://codex.mycred.me/hooks/buddypress-groups/',
|
28 |
-
'callback' => array( 'myCRED_BuddyPress_Groups' )
|
29 |
-
);
|
30 |
-
}
|
31 |
-
|
32 |
-
return $installed;
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* myCRED_BuddyPress_Profile class
|
38 |
-
* Creds for profile updates
|
39 |
-
* @since 0.1
|
40 |
-
* @version 1.3
|
41 |
-
*/
|
42 |
-
add_action( 'mycred_load_hooks', 'mycred_load_buddypress_profile_hook', 40 );
|
43 |
-
function mycred_load_buddypress_profile_hook() {
|
44 |
-
|
45 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
46 |
-
if ( class_exists( 'myCRED_BuddyPress_Profile' ) || ! class_exists( 'BuddyPress' ) ) return;
|
47 |
-
|
48 |
-
class myCRED_BuddyPress_Profile extends myCRED_Hook {
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Construct
|
52 |
-
*/
|
53 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
54 |
-
|
55 |
-
parent::__construct( array(
|
56 |
-
'id' => 'hook_bp_profile',
|
57 |
-
'defaults' => array(
|
58 |
-
'update' => array(
|
59 |
-
'creds' => 1,
|
60 |
-
'log' => '%plural% for updating profile',
|
61 |
-
'limit' => '0/x'
|
62 |
-
),
|
63 |
-
'removed_update' => array(
|
64 |
-
'creds' => 1,
|
65 |
-
'log' => '%plural% for removing profile update',
|
66 |
-
'limit' => '0/x'
|
67 |
-
),
|
68 |
-
'avatar' => array(
|
69 |
-
'creds' => 1,
|
70 |
-
'log' => '%plural% for new avatar',
|
71 |
-
'limit' => '0/x'
|
72 |
-
),
|
73 |
-
'cover' => array(
|
74 |
-
'creds' => 1,
|
75 |
-
'log' => '%plural% for new cover photo',
|
76 |
-
'limit' => '0/x'
|
77 |
-
),
|
78 |
-
'new_friend' => array(
|
79 |
-
'creds' => 1,
|
80 |
-
'log' => '%plural% for new friendship',
|
81 |
-
'block' => 0,
|
82 |
-
'limit' => '0/x'
|
83 |
-
),
|
84 |
-
'leave_friend' => array(
|
85 |
-
'creds' => '-1',
|
86 |
-
'log' => '%singular% deduction for loosing a friend',
|
87 |
-
'limit' => '0/x'
|
88 |
-
),
|
89 |
-
'new_comment' => array(
|
90 |
-
'creds' => 1,
|
91 |
-
'log' => '%plural% for new comment',
|
92 |
-
'limit' => '0/x'
|
93 |
-
),
|
94 |
-
'delete_comment' => array(
|
95 |
-
'creds' => '-1',
|
96 |
-
'log' => '%singular% deduction for comment removal'
|
97 |
-
),
|
98 |
-
'add_favorite' => array(
|
99 |
-
'creds' => 1,
|
100 |
-
'log' => '%plural% for adding an activity to favorites',
|
101 |
-
'limit' => '0/x'
|
102 |
-
),
|
103 |
-
'remove_favorite' => array(
|
104 |
-
'creds' => '-1',
|
105 |
-
'log' => '%singular% deduction for removing favorite activity'
|
106 |
-
),
|
107 |
-
'message' => array(
|
108 |
-
'creds' => 1,
|
109 |
-
'log' => '%plural% for sending a message',
|
110 |
-
'limit' => '0/x'
|
111 |
-
),
|
112 |
-
'send_gift' => array(
|
113 |
-
'creds' => 1,
|
114 |
-
'log' => '%plural% for sending a gift',
|
115 |
-
'limit' => '0/x'
|
116 |
-
)
|
117 |
-
)
|
118 |
-
), $hook_prefs, $type );
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Run
|
124 |
-
* @since 0.1
|
125 |
-
* @version 1.0
|
126 |
-
*/
|
127 |
-
public function run() {
|
128 |
-
|
129 |
-
if ( $this->prefs['update']['creds'] != 0 )
|
130 |
-
add_action( 'bp_activity_posted_update', array( $this, 'new_update' ), 10, 3 );
|
131 |
-
|
132 |
-
if ( $this->prefs['removed_update']['creds'] != 0 )
|
133 |
-
add_action( 'bp_activity_delete', array( $this, 'remove_update' ), 10, 3 );
|
134 |
-
|
135 |
-
if ( $this->prefs['avatar']['creds'] != 0 )
|
136 |
-
add_action( 'xprofile_avatar_uploaded', array( $this, 'avatar_upload' ) );
|
137 |
-
|
138 |
-
if ( $this->prefs['cover']['creds'] != 0 )
|
139 |
-
add_action( 'xprofile_cover_image_uploaded', array( $this, 'cover_change' ) );
|
140 |
-
|
141 |
-
if ( $this->prefs['new_friend']['creds'] < 0 && isset( $this->prefs['new_friend']['block'] ) && $this->prefs['new_friend']['block'] == 1 ) {
|
142 |
-
add_action( 'wp_ajax_addremove_friend', array( $this, 'ajax_addremove_friend' ), 0 );
|
143 |
-
add_filter( 'bp_get_add_friend_button', array( $this, 'disable_friendship' ) );
|
144 |
-
}
|
145 |
-
|
146 |
-
if ( $this->prefs['new_friend']['creds'] != 0 )
|
147 |
-
add_action( 'friends_friendship_accepted', array( $this, 'friendship_join' ), 10, 3 );
|
148 |
-
|
149 |
-
if ( $this->prefs['leave_friend']['creds'] != 0 )
|
150 |
-
add_action( 'friends_friendship_deleted', array( $this, 'friendship_leave' ), 10, 3 );
|
151 |
-
|
152 |
-
if ( $this->prefs['new_comment']['creds'] != 0 )
|
153 |
-
add_action( 'bp_activity_comment_posted', array( $this, 'new_comment' ), 10, 2 );
|
154 |
-
|
155 |
-
if ( $this->prefs['delete_comment']['creds'] != 0 )
|
156 |
-
add_action( 'bp_activity_action_delete_activity', array( $this, 'delete_comment' ), 10, 2 );
|
157 |
-
|
158 |
-
if ( $this->prefs['add_favorite']['creds'] != 0 )
|
159 |
-
add_action( 'bp_activity_add_user_favorite', array( $this, 'add_to_favorites' ), 10, 2 );
|
160 |
-
|
161 |
-
if ( $this->prefs['remove_favorite']['creds'] != 0 )
|
162 |
-
add_action( 'bp_activity_remove_user_favorite', array( $this, 'removed_from_favorites' ), 10, 2 );
|
163 |
-
|
164 |
-
if ( $this->prefs['message']['creds'] != 0 )
|
165 |
-
add_action( 'messages_message_sent', array( $this, 'messages' ) );
|
166 |
-
|
167 |
-
if ( $this->prefs['send_gift']['creds'] != 0 )
|
168 |
-
add_action( 'bp_gifts_send_gifts', array( $this, 'send_gifts' ), 10, 2 );
|
169 |
-
|
170 |
-
}
|
171 |
-
|
172 |
-
/**
|
173 |
-
* New Profile Update
|
174 |
-
* @since 0.1
|
175 |
-
* @version 1.2
|
176 |
-
*/
|
177 |
-
public function new_update( $content, $user_id, $activity_id ) {
|
178 |
-
|
179 |
-
// Check if user is excluded
|
180 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
181 |
-
|
182 |
-
// Limit
|
183 |
-
if ( $this->over_hook_limit( 'update', 'new_profile_update', $user_id ) ) return;
|
184 |
-
|
185 |
-
// Make sure this is unique event
|
186 |
-
if ( $this->core->has_entry( 'new_profile_update', $activity_id, $user_id ) ) return;
|
187 |
-
|
188 |
-
// Execute
|
189 |
-
$this->core->add_creds(
|
190 |
-
'new_profile_update',
|
191 |
-
$user_id,
|
192 |
-
$this->prefs['update']['creds'],
|
193 |
-
$this->prefs['update']['log'],
|
194 |
-
$activity_id,
|
195 |
-
'bp_activity',
|
196 |
-
$this->mycred_type
|
197 |
-
);
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Removing Profile Update
|
203 |
-
* @since 1.6
|
204 |
-
* @version 1.0
|
205 |
-
*/
|
206 |
-
public function remove_update( $args ) {
|
207 |
-
|
208 |
-
if ( ! isset( $args['user_id'] ) || $args['user_id'] === false ) return;
|
209 |
-
|
210 |
-
$user_id = absint( $args['user_id'] );
|
211 |
-
|
212 |
-
// Check if user is excluded
|
213 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
214 |
-
|
215 |
-
// Limit
|
216 |
-
if ( $this->over_hook_limit( 'removed_update', 'deleted_profile_update', $user_id ) ) return;
|
217 |
-
|
218 |
-
// Execute
|
219 |
-
$this->core->add_creds(
|
220 |
-
'deleted_profile_update',
|
221 |
-
$user_id,
|
222 |
-
$this->prefs['removed_update']['creds'],
|
223 |
-
$this->prefs['removed_update']['log'],
|
224 |
-
0,
|
225 |
-
$args,
|
226 |
-
$this->mycred_type
|
227 |
-
);
|
228 |
-
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Avatar Upload
|
233 |
-
* @since 0.1
|
234 |
-
* @version 1.2
|
235 |
-
*/
|
236 |
-
public function avatar_upload() {
|
237 |
-
|
238 |
-
$user_id = apply_filters( 'bp_xprofile_new_avatar_user_id', bp_displayed_user_id() );
|
239 |
-
|
240 |
-
// Check if user is excluded
|
241 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
242 |
-
|
243 |
-
// Limit
|
244 |
-
if ( $this->over_hook_limit( 'avatar', 'upload_avatar', $user_id ) ) return;
|
245 |
-
|
246 |
-
// Execute
|
247 |
-
$this->core->add_creds(
|
248 |
-
'upload_avatar',
|
249 |
-
$user_id,
|
250 |
-
$this->prefs['avatar']['creds'],
|
251 |
-
$this->prefs['avatar']['log'],
|
252 |
-
0,
|
253 |
-
'',
|
254 |
-
$this->mycred_type
|
255 |
-
);
|
256 |
-
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
* Cover Upload
|
261 |
-
* @since 1.7
|
262 |
-
* @version 1.0
|
263 |
-
*/
|
264 |
-
public function cover_change( $user_id = NULL ) {
|
265 |
-
|
266 |
-
// Check if user is excluded
|
267 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
268 |
-
|
269 |
-
// Limit
|
270 |
-
if ( $this->over_hook_limit( 'cover', 'upload_cover', $user_id ) ) return;
|
271 |
-
|
272 |
-
// Execute
|
273 |
-
$this->core->add_creds(
|
274 |
-
'upload_cover',
|
275 |
-
$user_id,
|
276 |
-
$this->prefs['cover']['creds'],
|
277 |
-
$this->prefs['cover']['log'],
|
278 |
-
0,
|
279 |
-
'',
|
280 |
-
$this->mycred_type
|
281 |
-
);
|
282 |
-
|
283 |
-
}
|
284 |
-
|
285 |
-
/**
|
286 |
-
* AJAX: Add/Remove Friend
|
287 |
-
* Intercept addremovefriend ajax call and block
|
288 |
-
* action if the user can not afford new friendship.
|
289 |
-
* @since 1.5.4
|
290 |
-
* @version 1.0
|
291 |
-
*/
|
292 |
-
public function ajax_addremove_friend() {
|
293 |
-
|
294 |
-
// Bail if not a POST action
|
295 |
-
if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
|
296 |
-
return;
|
297 |
-
|
298 |
-
$user_id = bp_loggedin_user_id();
|
299 |
-
$balance = $this->core->get_users_balance( $user_id, $this->mycred_type );
|
300 |
-
$cost = abs( $this->prefs['new_friend']['creds'] );
|
301 |
-
|
302 |
-
// Take into account any existing requests which will be charged when the new
|
303 |
-
// friend approves it. Prevents users from requesting more then they can afford.
|
304 |
-
$pending_requests = $this->count_pending_requests( $user_id );
|
305 |
-
if ( $pending_requests > 0 )
|
306 |
-
$cost = $cost + ( $cost * $pending_requests );
|
307 |
-
|
308 |
-
// Prevent BP from running this ajax call
|
309 |
-
if ( $balance < $cost ) {
|
310 |
-
echo apply_filters( 'mycred_bp_declined_addfriend', __( 'Insufficient Funds', 'mycred' ), $this );
|
311 |
-
exit;
|
312 |
-
}
|
313 |
-
|
314 |
-
}
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Disable Friendship
|
318 |
-
* If we deduct points from a user for new friendships
|
319 |
-
* we disable the friendship button if the user ca not afford it.
|
320 |
-
* @since 1.5.4
|
321 |
-
* @version 1.0
|
322 |
-
*/
|
323 |
-
public function disable_friendship( $button ) {
|
324 |
-
|
325 |
-
// Only applicable for Add Friend button
|
326 |
-
if ( $button['id'] == 'not_friends' ) {
|
327 |
-
|
328 |
-
$user_id = bp_loggedin_user_id();
|
329 |
-
$balance = $this->core->get_users_balance( $user_id, $this->mycred_type );
|
330 |
-
$cost = abs( $this->prefs['new_friend']['creds'] );
|
331 |
-
|
332 |
-
// Take into account any existing requests which will be charged when the new
|
333 |
-
// friend approves it. Prevents users from requesting more then they can afford.
|
334 |
-
$pending_requests = $this->count_pending_requests( $user_id );
|
335 |
-
if ( $pending_requests > 0 )
|
336 |
-
$cost = $cost + ( $cost * $pending_requests );
|
337 |
-
|
338 |
-
if ( $balance < $cost )
|
339 |
-
return array();
|
340 |
-
|
341 |
-
}
|
342 |
-
|
343 |
-
return $button;
|
344 |
-
|
345 |
-
}
|
346 |
-
|
347 |
-
/**
|
348 |
-
* Count Pending Friendship Requests
|
349 |
-
* Counts the given users pending friendship requests sent to
|
350 |
-
* other users.
|
351 |
-
* @since 1.5.4
|
352 |
-
* @version 1.0
|
353 |
-
*/
|
354 |
-
protected function count_pending_requests( $user_id ) {
|
355 |
-
|
356 |
-
global $wpdb, $bp;
|
357 |
-
|
358 |
-
return $wpdb->get_var( $wpdb->prepare( "
|
359 |
-
SELECT COUNT(*)
|
360 |
-
FROM {$bp->friends->table_name}
|
361 |
-
WHERE initiator_user_id = %d
|
362 |
-
AND is_confirmed = 0;", $user_id ) );
|
363 |
-
|
364 |
-
}
|
365 |
-
|
366 |
-
/**
|
367 |
-
* New Friendship
|
368 |
-
* @since 0.1
|
369 |
-
* @version 1.3.1
|
370 |
-
*/
|
371 |
-
public function friendship_join( $friendship_id, $initiator_user_id, $friend_user_id ) {
|
372 |
-
|
373 |
-
// Make sure this is unique event
|
374 |
-
if ( ! $this->core->exclude_user( $initiator_user_id ) && ! $this->core->has_entry( 'new_friendship', $friend_user_id, $initiator_user_id ) && ! $this->over_hook_limit( 'new_friend', 'new_friendship', $initiator_user_id ) )
|
375 |
-
$this->core->add_creds(
|
376 |
-
'new_friendship',
|
377 |
-
$initiator_user_id,
|
378 |
-
$this->prefs['new_friend']['creds'],
|
379 |
-
$this->prefs['new_friend']['log'],
|
380 |
-
$friend_user_id,
|
381 |
-
array( 'ref_type' => 'user' ),
|
382 |
-
$this->mycred_type
|
383 |
-
);
|
384 |
-
|
385 |
-
// Points to friend (ignored if we are deducting points for new friendships)
|
386 |
-
if ( $this->prefs['new_friend']['creds'] > 0 && ! $this->core->exclude_user( $friend_user_id ) && ! $this->over_hook_limit( 'new_friend', 'new_friendship', $friend_user_id ) )
|
387 |
-
$this->core->add_creds(
|
388 |
-
'new_friendship',
|
389 |
-
$friend_user_id,
|
390 |
-
$this->prefs['new_friend']['creds'],
|
391 |
-
$this->prefs['new_friend']['log'],
|
392 |
-
$initiator_user_id,
|
393 |
-
array( 'ref_type' => 'user' ),
|
394 |
-
$this->mycred_type
|
395 |
-
);
|
396 |
-
|
397 |
-
}
|
398 |
-
|
399 |
-
/**
|
400 |
-
* Ending Friendship
|
401 |
-
* @since 0.1
|
402 |
-
* @version 1.2
|
403 |
-
*/
|
404 |
-
public function friendship_leave( $friendship_id, $initiator_user_id, $friend_user_id ) {
|
405 |
-
|
406 |
-
if ( ! $this->core->exclude_user( $initiator_user_id ) && ! $this->core->has_entry( 'ended_friendship', $friend_user_id, $initiator_user_id ) )
|
407 |
-
$this->core->add_creds(
|
408 |
-
'ended_friendship',
|
409 |
-
$initiator_user_id,
|
410 |
-
$this->prefs['leave_friend']['creds'],
|
411 |
-
$this->prefs['leave_friend']['log'],
|
412 |
-
$friend_user_id,
|
413 |
-
array( 'ref_type' => 'user' ),
|
414 |
-
$this->mycred_type
|
415 |
-
);
|
416 |
-
|
417 |
-
if ( ! $this->core->exclude_user( $friend_user_id ) )
|
418 |
-
$this->core->add_creds(
|
419 |
-
'ended_friendship',
|
420 |
-
$friend_user_id,
|
421 |
-
$this->prefs['leave_friend']['creds'],
|
422 |
-
$this->prefs['leave_friend']['log'],
|
423 |
-
$initiator_user_id,
|
424 |
-
array( 'ref_type' => 'user' ),
|
425 |
-
$this->mycred_type
|
426 |
-
);
|
427 |
-
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
* New Comment
|
432 |
-
* @since 0.1
|
433 |
-
* @version 1.2
|
434 |
-
*/
|
435 |
-
public function new_comment( $comment_id, $params ) {
|
436 |
-
|
437 |
-
$user_id = bp_loggedin_user_id();
|
438 |
-
|
439 |
-
// Check if user is excluded
|
440 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
441 |
-
|
442 |
-
// Limit
|
443 |
-
if ( $this->over_hook_limit( 'new_comment', 'new_comment' ) ) return;
|
444 |
-
|
445 |
-
// Make sure this is unique event
|
446 |
-
if ( $this->core->has_entry( 'new_comment', $comment_id ) ) return;
|
447 |
-
|
448 |
-
// Execute
|
449 |
-
$this->core->add_creds(
|
450 |
-
'new_comment',
|
451 |
-
$user_id,
|
452 |
-
$this->prefs['new_comment']['creds'],
|
453 |
-
$this->prefs['new_comment']['log'],
|
454 |
-
$comment_id,
|
455 |
-
'bp_comment',
|
456 |
-
$this->mycred_type
|
457 |
-
);
|
458 |
-
|
459 |
-
}
|
460 |
-
|
461 |
-
/**
|
462 |
-
* Comment Deletion
|
463 |
-
* @since 0.1
|
464 |
-
* @version 1.0
|
465 |
-
*/
|
466 |
-
public function delete_comment( $activity_id, $user_id ) {
|
467 |
-
|
468 |
-
// Check if user is excluded
|
469 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
470 |
-
|
471 |
-
// Make sure this is unique event
|
472 |
-
if ( $this->core->has_entry( 'comment_deletion', $activity_id ) ) return;
|
473 |
-
|
474 |
-
// Execute
|
475 |
-
$this->core->add_creds(
|
476 |
-
'comment_deletion',
|
477 |
-
$user_id,
|
478 |
-
$this->prefs['delete_comment']['creds'],
|
479 |
-
$this->prefs['delete_comment']['log'],
|
480 |
-
$activity_id,
|
481 |
-
'bp_comment',
|
482 |
-
$this->mycred_type
|
483 |
-
);
|
484 |
-
|
485 |
-
}
|
486 |
-
|
487 |
-
/**
|
488 |
-
* Add to Favorites
|
489 |
-
* @since 1.7
|
490 |
-
* @version 1.0
|
491 |
-
*/
|
492 |
-
public function add_to_favorites( $activity_id, $user_id ) {
|
493 |
-
|
494 |
-
// Check if user is excluded
|
495 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
496 |
-
|
497 |
-
// Make sure this is unique event
|
498 |
-
if ( $this->core->has_entry( 'fave_activity', $activity_id ) ) return;
|
499 |
-
|
500 |
-
// Execute
|
501 |
-
$this->core->add_creds(
|
502 |
-
'fave_activity',
|
503 |
-
$user_id,
|
504 |
-
$this->prefs['add_favorite']['creds'],
|
505 |
-
$this->prefs['add_favorite']['log'],
|
506 |
-
$activity_id,
|
507 |
-
'bp_comment',
|
508 |
-
$this->mycred_type
|
509 |
-
);
|
510 |
-
|
511 |
-
}
|
512 |
-
|
513 |
-
/**
|
514 |
-
* Remove from Favorites
|
515 |
-
* @since 1.7
|
516 |
-
* @version 1.0
|
517 |
-
*/
|
518 |
-
public function removed_from_favorites( $activity_id, $user_id ) {
|
519 |
-
|
520 |
-
// Check if user is excluded
|
521 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
522 |
-
|
523 |
-
// Make sure this is unique event
|
524 |
-
if ( $this->core->has_entry( 'unfave_activity', $activity_id ) ) return;
|
525 |
-
|
526 |
-
// Execute
|
527 |
-
$this->core->add_creds(
|
528 |
-
'unfave_activity',
|
529 |
-
$user_id,
|
530 |
-
$this->prefs['remove_favorite']['creds'],
|
531 |
-
$this->prefs['remove_favorite']['log'],
|
532 |
-
$activity_id,
|
533 |
-
'bp_comment',
|
534 |
-
$this->mycred_type
|
535 |
-
);
|
536 |
-
|
537 |
-
}
|
538 |
-
|
539 |
-
/**
|
540 |
-
* New Message
|
541 |
-
* @since 0.1
|
542 |
-
* @version 1.1
|
543 |
-
*/
|
544 |
-
public function messages( $message ) {
|
545 |
-
|
546 |
-
// Check if user is excluded
|
547 |
-
if ( $this->core->exclude_user( $message->sender_id ) ) return;
|
548 |
-
|
549 |
-
// Limit
|
550 |
-
if ( $this->over_hook_limit( 'message', 'new_message', $message->sender_id ) ) return;
|
551 |
-
|
552 |
-
// Make sure this is unique event
|
553 |
-
if ( $this->core->has_entry( 'new_message', $message->thread_id ) ) return;
|
554 |
-
|
555 |
-
// Execute
|
556 |
-
$this->core->add_creds(
|
557 |
-
'new_message',
|
558 |
-
$message->sender_id,
|
559 |
-
$this->prefs['message']['creds'],
|
560 |
-
$this->prefs['message']['log'],
|
561 |
-
$message->thread_id,
|
562 |
-
'bp_message',
|
563 |
-
$this->mycred_type
|
564 |
-
);
|
565 |
-
|
566 |
-
}
|
567 |
-
|
568 |
-
/**
|
569 |
-
* Send Gift
|
570 |
-
* @since 0.1
|
571 |
-
* @version 1.1
|
572 |
-
*/
|
573 |
-
public function send_gifts( $to_user_id, $from_user_id ) {
|
574 |
-
|
575 |
-
// Check if sender is excluded
|
576 |
-
if ( $this->core->exclude_user( $from_user_id ) ) return;
|
577 |
-
|
578 |
-
// Check if recipient is excluded
|
579 |
-
if ( $this->core->exclude_user( $to_user_id ) ) return;
|
580 |
-
|
581 |
-
// Limit
|
582 |
-
if ( ! $this->over_hook_limit( 'send_gift', 'sending_gift', $from_user_id ) )
|
583 |
-
$this->core->add_creds(
|
584 |
-
'sending_gift',
|
585 |
-
$from_user_id,
|
586 |
-
$this->prefs['send_gift']['creds'],
|
587 |
-
$this->prefs['send_gift']['log'],
|
588 |
-
$to_user_id,
|
589 |
-
'bp_gifts',
|
590 |
-
$this->mycred_type
|
591 |
-
);
|
592 |
-
|
593 |
-
}
|
594 |
-
|
595 |
-
/**
|
596 |
-
* Preferences
|
597 |
-
* @since 0.1
|
598 |
-
* @version 1.2
|
599 |
-
*/
|
600 |
-
public function preferences() {
|
601 |
-
|
602 |
-
$prefs = $this->prefs;
|
603 |
-
|
604 |
-
if ( ! isset( $prefs['removed_update'] ) )
|
605 |
-
$prefs['removed_update'] = array( 'creds' => 0, 'limit' => '0/x', 'log' => '%plural% deduction for removing profile update' );
|
606 |
-
|
607 |
-
$friend_block = 0;
|
608 |
-
if ( isset( $prefs['new_friend']['block'] ) )
|
609 |
-
$friend_block = $prefs['new_friend']['block'];
|
610 |
-
|
611 |
-
?>
|
612 |
-
<div class="hook-instance">
|
613 |
-
<h3><?php _e( 'New Profile Activity', 'mycred' ); ?></h3>
|
614 |
-
<div class="row">
|
615 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
616 |
-
<div class="form-group">
|
617 |
-
<label for="<?php echo $this->field_id( array( 'update', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
618 |
-
<input type="text" name="<?php echo $this->field_name( array( 'update', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'update', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['update']['creds'] ); ?>" class="form-control" />
|
619 |
-
</div>
|
620 |
-
</div>
|
621 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
622 |
-
<div class="form-group">
|
623 |
-
<label for="<?php echo $this->field_id( array( 'update', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
624 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'update', 'limit' ) ), $this->field_id( array( 'update', 'limit' ) ), $prefs['update']['limit'] ); ?>
|
625 |
-
</div>
|
626 |
-
</div>
|
627 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
628 |
-
<div class="form-group">
|
629 |
-
<label for="<?php echo $this->field_id( array( 'update', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
630 |
-
<input type="text" name="<?php echo $this->field_name( array( 'update', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'update', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['update']['log'] ); ?>" class="form-control" />
|
631 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
632 |
-
</div>
|
633 |
-
</div>
|
634 |
-
</div>
|
635 |
-
</div>
|
636 |
-
<div class="hook-instance">
|
637 |
-
<h3><?php _e( 'Deleted Profile Activity', 'mycred' ); ?></h3>
|
638 |
-
<div class="row">
|
639 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
640 |
-
<div class="form-group">
|
641 |
-
<label for="<?php echo $this->field_id( array( 'removed_update', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
642 |
-
<input type="text" name="<?php echo $this->field_name( array( 'removed_update', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'removed_update', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['removed_update']['creds'] ); ?>" class="form-control" />
|
643 |
-
</div>
|
644 |
-
</div>
|
645 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
646 |
-
<div class="form-group">
|
647 |
-
<label for="<?php echo $this->field_id( array( 'removed_update', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
648 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'removed_update', 'limit' ) ), $this->field_id( array( 'removed_update', 'limit' ) ), $prefs['removed_update']['limit'] ); ?>
|
649 |
-
</div>
|
650 |
-
</div>
|
651 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
652 |
-
<div class="form-group">
|
653 |
-
<label for="<?php echo $this->field_id( array( 'removed_update', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
654 |
-
<input type="text" name="<?php echo $this->field_name( array( 'removed_update', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'removed_update', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['removed_update']['log'] ); ?>" class="form-control" />
|
655 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
656 |
-
</div>
|
657 |
-
</div>
|
658 |
-
</div>
|
659 |
-
</div>
|
660 |
-
<div class="hook-instance">
|
661 |
-
<h3><?php _e( 'New Profile Avatar Upload', 'mycred' ); ?></h3>
|
662 |
-
<div class="row">
|
663 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
664 |
-
<div class="form-group">
|
665 |
-
<label for="<?php echo $this->field_id( array( 'avatar', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
666 |
-
<input type="text" name="<?php echo $this->field_name( array( 'avatar', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'avatar', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['avatar']['creds'] ); ?>" class="form-control" />
|
667 |
-
</div>
|
668 |
-
</div>
|
669 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
670 |
-
<div class="form-group">
|
671 |
-
<label for="<?php echo $this->field_id( array( 'avatar', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
672 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'avatar', 'limit' ) ), $this->field_id( array( 'avatar', 'limit' ) ), $prefs['avatar']['limit'] ); ?>
|
673 |
-
</div>
|
674 |
-
</div>
|
675 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
676 |
-
<div class="form-group">
|
677 |
-
<label for="<?php echo $this->field_id( array( 'avatar', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
678 |
-
<input type="text" name="<?php echo $this->field_name( array( 'avatar', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'avatar', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['avatar']['log'] ); ?>" class="form-control" />
|
679 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
680 |
-
</div>
|
681 |
-
</div>
|
682 |
-
</div>
|
683 |
-
</div>
|
684 |
-
<div class="hook-instance">
|
685 |
-
<h3><?php _e( 'New Profile Cover Upload', 'mycred' ); ?></h3>
|
686 |
-
<div class="row">
|
687 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
688 |
-
<div class="form-group">
|
689 |
-
<label for="<?php echo $this->field_id( array( 'cover', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
690 |
-
<input type="text" name="<?php echo $this->field_name( array( 'cover', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'cover', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['cover']['creds'] ); ?>" class="form-control" />
|
691 |
-
</div>
|
692 |
-
</div>
|
693 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
694 |
-
<div class="form-group">
|
695 |
-
<label for="<?php echo $this->field_id( array( 'cover', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
696 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'cover', 'limit' ) ), $this->field_id( array( 'cover', 'limit' ) ), $prefs['cover']['limit'] ); ?>
|
697 |
-
</div>
|
698 |
-
</div>
|
699 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
700 |
-
<div class="form-group">
|
701 |
-
<label for="<?php echo $this->field_id( array( 'cover', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
702 |
-
<input type="text" name="<?php echo $this->field_name( array( 'cover', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'cover', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['cover']['log'] ); ?>" class="form-control" />
|
703 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
704 |
-
</div>
|
705 |
-
</div>
|
706 |
-
</div>
|
707 |
-
</div>
|
708 |
-
<div class="hook-instance">
|
709 |
-
<h3><?php _e( 'New Friendships', 'mycred' ); ?></h3>
|
710 |
-
<div class="row">
|
711 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
712 |
-
<div class="form-group">
|
713 |
-
<label for="<?php echo $this->field_id( array( 'new_friend', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
714 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_friend', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_friend', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_friend']['creds'] ); ?>" class="form-control" />
|
715 |
-
</div>
|
716 |
-
</div>
|
717 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
718 |
-
<div class="form-group">
|
719 |
-
<label for="<?php echo $this->field_id( array( 'new_friend', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
720 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_friend', 'limit' ) ), $this->field_id( array( 'new_friend', 'limit' ) ), $prefs['new_friend']['limit'] ); ?>
|
721 |
-
</div>
|
722 |
-
</div>
|
723 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
724 |
-
<div class="form-group">
|
725 |
-
<label for="<?php echo $this->field_id( array( 'new_friend', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
726 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_friend', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_friend', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_friend']['log'] ); ?>" class="form-control" />
|
727 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
728 |
-
</div>
|
729 |
-
</div>
|
730 |
-
</div>
|
731 |
-
<div class="row">
|
732 |
-
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
733 |
-
<div class="form-group">
|
734 |
-
<div class="radio">
|
735 |
-
<label for="<?php echo $this->field_id( array( 'new_friend', 'block' ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'new_friend', 'block' ) ); ?>"<?php checked( $friend_block, 1 ); ?> id="<?php echo $this->field_id( array( 'new_friend', 'block' ) ); ?>" value="1" /> <?php echo $this->core->template_tags_general( __( 'Users with zero balance can not add friends. Requires that you deduct %_plural% for adding a new friend.', 'mycred' ) ); ?></label>
|
736 |
-
</div>
|
737 |
-
</div>
|
738 |
-
</div>
|
739 |
-
</div>
|
740 |
-
</div>
|
741 |
-
<div class="hook-instance">
|
742 |
-
<h3><?php _e( 'Ending Friendships', 'mycred' ); ?></h3>
|
743 |
-
<div class="row">
|
744 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
745 |
-
<div class="form-group">
|
746 |
-
<label for="<?php echo $this->field_id( array( 'leave_friend', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
747 |
-
<input type="text" name="<?php echo $this->field_name( array( 'leave_friend', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'leave_friend', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['leave_friend']['creds'] ); ?>" class="form-control" />
|
748 |
-
</div>
|
749 |
-
</div>
|
750 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
751 |
-
<div class="form-group">
|
752 |
-
<label for="<?php echo $this->field_id( array( 'leave_friend', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
753 |
-
<input type="text" name="<?php echo $this->field_name( array( 'leave_friend', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'leave_friend', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['leave_friend']['log'] ); ?>" class="form-control" />
|
754 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
755 |
-
</div>
|
756 |
-
</div>
|
757 |
-
</div>
|
758 |
-
</div>
|
759 |
-
<div class="hook-instance">
|
760 |
-
<h3><?php _e( 'New Comment', 'mycred' ); ?></h3>
|
761 |
-
<div class="row">
|
762 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
763 |
-
<div class="form-group">
|
764 |
-
<label for="<?php echo $this->field_id( array( 'new_comment', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
765 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_comment', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_comment', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_comment']['creds'] ); ?>" class="form-control" />
|
766 |
-
</div>
|
767 |
-
</div>
|
768 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
769 |
-
<div class="form-group">
|
770 |
-
<label for="<?php echo $this->field_id( array( 'new_comment', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
771 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_comment', 'limit' ) ), $this->field_id( array( 'new_comment', 'limit' ) ), $prefs['new_comment']['limit'] ); ?>
|
772 |
-
</div>
|
773 |
-
</div>
|
774 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
775 |
-
<div class="form-group">
|
776 |
-
<label for="<?php echo $this->field_id( array( 'new_comment', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
777 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_comment', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_comment', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_comment']['log'] ); ?>" class="form-control" />
|
778 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
779 |
-
</div>
|
780 |
-
</div>
|
781 |
-
</div>
|
782 |
-
</div>
|
783 |
-
<div class="hook-instance">
|
784 |
-
<h3><?php _e( 'Deleted Comment', 'mycred' ); ?></h3>
|
785 |
-
<div class="row">
|
786 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
787 |
-
<div class="form-group">
|
788 |
-
<label for="<?php echo $this->field_id( array( 'delete_comment', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
789 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_comment', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_comment', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['delete_comment']['creds'] ); ?>" class="form-control" />
|
790 |
-
</div>
|
791 |
-
</div>
|
792 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
793 |
-
<div class="form-group">
|
794 |
-
<label for="<?php echo $this->field_id( array( 'delete_comment', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
795 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_comment', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_comment', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_comment']['log'] ); ?>" class="form-control" />
|
796 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
797 |
-
</div>
|
798 |
-
</div>
|
799 |
-
</div>
|
800 |
-
</div>
|
801 |
-
<div class="hook-instance">
|
802 |
-
<h3><?php _e( 'Favorite Activity', 'mycred' ); ?></h3>
|
803 |
-
<div class="row">
|
804 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
805 |
-
<div class="form-group">
|
806 |
-
<label for="<?php echo $this->field_id( array( 'add_favorite', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
807 |
-
<input type="text" name="<?php echo $this->field_name( array( 'add_favorite', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'add_favorite', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['add_favorite']['creds'] ); ?>" class="form-control" />
|
808 |
-
</div>
|
809 |
-
</div>
|
810 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
811 |
-
<div class="form-group">
|
812 |
-
<label for="<?php echo $this->field_id( array( 'add_favorite', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
813 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'add_favorite', 'limit' ) ), $this->field_id( array( 'add_favorite', 'limit' ) ), $prefs['add_favorite']['limit'] ); ?>
|
814 |
-
</div>
|
815 |
-
</div>
|
816 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
817 |
-
<div class="form-group">
|
818 |
-
<label for="<?php echo $this->field_id( array( 'add_favorite', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
819 |
-
<input type="text" name="<?php echo $this->field_name( array( 'add_favorite', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'add_favorite', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['add_favorite']['log'] ); ?>" class="form-control" />
|
820 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
821 |
-
</div>
|
822 |
-
</div>
|
823 |
-
</div>
|
824 |
-
</div>
|
825 |
-
<div class="hook-instance">
|
826 |
-
<h3><?php _e( 'Removing Favorit Activity', 'mycred' ); ?></h3>
|
827 |
-
<div class="row">
|
828 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
829 |
-
<div class="form-group">
|
830 |
-
<label for="<?php echo $this->field_id( array( 'remove_favorite', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
831 |
-
<input type="text" name="<?php echo $this->field_name( array( 'remove_favorite', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'remove_favorite', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['remove_favorite']['creds'] ); ?>" class="form-control" />
|
832 |
-
</div>
|
833 |
-
</div>
|
834 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
835 |
-
<div class="form-group">
|
836 |
-
<label for="<?php echo $this->field_id( array( 'remove_favorite', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
837 |
-
<input type="text" name="<?php echo $this->field_name( array( 'remove_favorite', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'remove_favorite', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['remove_favorite']['log'] ); ?>" class="form-control" />
|
838 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
839 |
-
</div>
|
840 |
-
</div>
|
841 |
-
</div>
|
842 |
-
</div>
|
843 |
-
<div class="hook-instance">
|
844 |
-
<h3><?php _e( 'New Private Message', 'mycred' ); ?></h3>
|
845 |
-
<div class="row">
|
846 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
847 |
-
<div class="form-group">
|
848 |
-
<label for="<?php echo $this->field_id( array( 'message', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
849 |
-
<input type="text" name="<?php echo $this->field_name( array( 'message', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'message', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['message']['creds'] ); ?>" class="form-control" />
|
850 |
-
</div>
|
851 |
-
</div>
|
852 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
853 |
-
<div class="form-group">
|
854 |
-
<label for="<?php echo $this->field_id( array( 'message', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
855 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'message', 'limit' ) ), $this->field_id( array( 'message', 'limit' ) ), $prefs['message']['limit'] ); ?>
|
856 |
-
</div>
|
857 |
-
</div>
|
858 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
859 |
-
<div class="form-group">
|
860 |
-
<label for="<?php echo $this->field_id( array( 'message', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
861 |
-
<input type="text" name="<?php echo $this->field_name( array( 'message', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'message', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['message']['log'] ); ?>" class="form-control" />
|
862 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
863 |
-
</div>
|
864 |
-
</div>
|
865 |
-
</div>
|
866 |
-
</div>
|
867 |
-
<div class="hook-instance">
|
868 |
-
<h3><?php _e( 'Sending Gift', 'mycred' ); ?></h3>
|
869 |
-
<div class="row">
|
870 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
871 |
-
<div class="form-group">
|
872 |
-
<label for="<?php echo $this->field_id( array( 'send_gift', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
873 |
-
<input type="text" name="<?php echo $this->field_name( array( 'send_gift', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'send_gift', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['send_gift']['creds'] ); ?>" class="form-control" />
|
874 |
-
</div>
|
875 |
-
</div>
|
876 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
877 |
-
<div class="form-group">
|
878 |
-
<label for="<?php echo $this->field_id( array( 'send_gift', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
879 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'send_gift', 'limit' ) ), $this->field_id( array( 'send_gift', 'limit' ) ), $prefs['send_gift']['limit'] ); ?>
|
880 |
-
</div>
|
881 |
-
</div>
|
882 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
883 |
-
<div class="form-group">
|
884 |
-
<label for="<?php echo $this->field_id( array( 'send_gift', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
885 |
-
<input type="text" name="<?php echo $this->field_name( array( 'send_gift', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'send_gift', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['send_gift']['log'] ); ?>" class="form-control" />
|
886 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
887 |
-
</div>
|
888 |
-
</div>
|
889 |
-
</div>
|
890 |
-
</div>
|
891 |
-
<?php
|
892 |
-
|
893 |
-
}
|
894 |
-
|
895 |
-
/**
|
896 |
-
* Sanitise Preferences
|
897 |
-
* @since 1.6
|
898 |
-
* @version 1.1
|
899 |
-
*/
|
900 |
-
public function sanitise_preferences( $data ) {
|
901 |
-
|
902 |
-
if ( isset( $data['update']['limit'] ) && isset( $data['update']['limit_by'] ) ) {
|
903 |
-
$limit = sanitize_text_field( $data['update']['limit'] );
|
904 |
-
if ( $limit == '' ) $limit = 0;
|
905 |
-
$data['update']['limit'] = $limit . '/' . $data['update']['limit_by'];
|
906 |
-
unset( $data['update']['limit_by'] );
|
907 |
-
}
|
908 |
-
|
909 |
-
if ( isset( $data['removed_update']['limit'] ) && isset( $data['removed_update']['limit_by'] ) ) {
|
910 |
-
$limit = sanitize_text_field( $data['removed_update']['limit'] );
|
911 |
-
if ( $limit == '' ) $limit = 0;
|
912 |
-
$data['removed_update']['limit'] = $limit . '/' . $data['removed_update']['limit_by'];
|
913 |
-
unset( $data['removed_update']['limit_by'] );
|
914 |
-
}
|
915 |
-
|
916 |
-
if ( isset( $data['avatar']['limit'] ) && isset( $data['avatar']['limit_by'] ) ) {
|
917 |
-
$limit = sanitize_text_field( $data['avatar']['limit'] );
|
918 |
-
if ( $limit == '' ) $limit = 0;
|
919 |
-
$data['avatar']['limit'] = $limit . '/' . $data['avatar']['limit_by'];
|
920 |
-
unset( $data['avatar']['limit_by'] );
|
921 |
-
}
|
922 |
-
|
923 |
-
if ( isset( $data['cover']['limit'] ) && isset( $data['cover']['limit_by'] ) ) {
|
924 |
-
$limit = sanitize_text_field( $data['cover']['limit'] );
|
925 |
-
if ( $limit == '' ) $limit = 0;
|
926 |
-
$data['cover']['limit'] = $limit . '/' . $data['cover']['limit_by'];
|
927 |
-
unset( $data['cover']['limit_by'] );
|
928 |
-
}
|
929 |
-
|
930 |
-
if ( isset( $data['new_friend']['limit'] ) && isset( $data['new_friend']['limit_by'] ) ) {
|
931 |
-
$limit = sanitize_text_field( $data['new_friend']['limit'] );
|
932 |
-
if ( $limit == '' ) $limit = 0;
|
933 |
-
$data['new_friend']['limit'] = $limit . '/' . $data['new_friend']['limit_by'];
|
934 |
-
unset( $data['new_friend']['limit_by'] );
|
935 |
-
}
|
936 |
-
|
937 |
-
$data['new_friend']['block'] = ( isset( $data['new_friend']['block'] ) ) ? absint( $data['new_friend']['block'] ) : 0;
|
938 |
-
|
939 |
-
if ( isset( $data['new_comment']['limit'] ) && isset( $data['new_comment']['limit_by'] ) ) {
|
940 |
-
$limit = sanitize_text_field( $data['new_comment']['limit'] );
|
941 |
-
if ( $limit == '' ) $limit = 0;
|
942 |
-
$data['new_comment']['limit'] = $limit . '/' . $data['new_comment']['limit_by'];
|
943 |
-
unset( $data['new_comment']['limit_by'] );
|
944 |
-
}
|
945 |
-
|
946 |
-
if ( isset( $data['add_favorite']['limit'] ) && isset( $data['add_favorite']['limit_by'] ) ) {
|
947 |
-
$limit = sanitize_text_field( $data['add_favorite']['limit'] );
|
948 |
-
if ( $limit == '' ) $limit = 0;
|
949 |
-
$data['add_favorite']['limit'] = $limit . '/' . $data['add_favorite']['limit_by'];
|
950 |
-
unset( $data['add_favorite']['limit_by'] );
|
951 |
-
}
|
952 |
-
|
953 |
-
if ( isset( $data['message']['limit'] ) && isset( $data['message']['limit_by'] ) ) {
|
954 |
-
$limit = sanitize_text_field( $data['message']['limit'] );
|
955 |
-
if ( $limit == '' ) $limit = 0;
|
956 |
-
$data['message']['limit'] = $limit . '/' . $data['message']['limit_by'];
|
957 |
-
unset( $data['message']['limit_by'] );
|
958 |
-
}
|
959 |
-
|
960 |
-
if ( isset( $data['send_gift']['limit'] ) && isset( $data['send_gift']['limit_by'] ) ) {
|
961 |
-
$limit = sanitize_text_field( $data['send_gift']['limit'] );
|
962 |
-
if ( $limit == '' ) $limit = 0;
|
963 |
-
$data['send_gift']['limit'] = $limit . '/' . $data['send_gift']['limit_by'];
|
964 |
-
unset( $data['send_gift']['limit_by'] );
|
965 |
-
}
|
966 |
-
|
967 |
-
return $data;
|
968 |
-
|
969 |
-
}
|
970 |
-
|
971 |
-
}
|
972 |
-
|
973 |
-
}
|
974 |
-
|
975 |
-
/**
|
976 |
-
* myCRED_BuddyPress_Groups class
|
977 |
-
* Creds for groups actions such as joining / leaving, creating / deleting, new topics / edit topics or new posts / edit posts
|
978 |
-
* @since 0.1
|
979 |
-
* @version 1.1
|
980 |
-
*/
|
981 |
-
add_action( 'mycred_load_hooks', 'mycred_load_buddypress_groups_hook', 45 );
|
982 |
-
function mycred_load_buddypress_groups_hook() {
|
983 |
-
|
984 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
985 |
-
if ( class_exists( 'myCRED_BuddyPress_Groups' ) || ! class_exists( 'BuddyPress' ) ) return;
|
986 |
-
|
987 |
-
class myCRED_BuddyPress_Groups extends myCRED_Hook {
|
988 |
-
|
989 |
-
/**
|
990 |
-
* Construct
|
991 |
-
*/
|
992 |
-
function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
993 |
-
|
994 |
-
parent::__construct( array(
|
995 |
-
'id' => 'hook_bp_groups',
|
996 |
-
'defaults' => array(
|
997 |
-
'create' => array(
|
998 |
-
'creds' => 10,
|
999 |
-
'log' => '%plural% for creating a new group',
|
1000 |
-
'min' => 0
|
1001 |
-
),
|
1002 |
-
'delete' => array(
|
1003 |
-
'creds' => '-10',
|
1004 |
-
'log' => '%singular% deduction for deleting a group'
|
1005 |
-
),
|
1006 |
-
'new_topic' => array(
|
1007 |
-
'creds' => 1,
|
1008 |
-
'log' => '%plural% for new group topic',
|
1009 |
-
'limit' => '0/x'
|
1010 |
-
),
|
1011 |
-
'edit_topic' => array(
|
1012 |
-
'creds' => 1,
|
1013 |
-
'log' => '%plural% for updating group topic',
|
1014 |
-
'limit' => '0/x'
|
1015 |
-
),
|
1016 |
-
'new_post' => array(
|
1017 |
-
'creds' => 1,
|
1018 |
-
'log' => '%plural% for new group post',
|
1019 |
-
'limit' => '0/x'
|
1020 |
-
),
|
1021 |
-
'edit_post' => array(
|
1022 |
-
'creds' => 1,
|
1023 |
-
'log' => '%plural% for updating group post',
|
1024 |
-
'limit' => '0/x'
|
1025 |
-
),
|
1026 |
-
'join' => array(
|
1027 |
-
'creds' => 1,
|
1028 |
-
'log' => '%plural% for joining new group',
|
1029 |
-
'limit' => '0/x'
|
1030 |
-
),
|
1031 |
-
'leave' => array(
|
1032 |
-
'creds' => '-5',
|
1033 |
-
'log' => '%singular% deduction for leaving group'
|
1034 |
-
),
|
1035 |
-
'avatar' => array(
|
1036 |
-
'creds' => 1,
|
1037 |
-
'log' => '%plural% for new group avatar',
|
1038 |
-
'limit' => '0/x'
|
1039 |
-
),
|
1040 |
-
'cover' => array(
|
1041 |
-
'creds' => 1,
|
1042 |
-
'log' => '%plural% for new cover photo',
|
1043 |
-
'limit' => '0/x'
|
1044 |
-
),
|
1045 |
-
'comments' => array(
|
1046 |
-
'creds' => 1,
|
1047 |
-
'log' => '%plural% for new group comment',
|
1048 |
-
'limit' => '0/x'
|
1049 |
-
)
|
1050 |
-
)
|
1051 |
-
), $hook_prefs, $type );
|
1052 |
-
|
1053 |
-
}
|
1054 |
-
|
1055 |
-
/**
|
1056 |
-
* Run
|
1057 |
-
* @since 0.1
|
1058 |
-
* @version 1.0
|
1059 |
-
*/
|
1060 |
-
public function run() {
|
1061 |
-
|
1062 |
-
if ( $this->prefs['create']['creds'] != 0 && $this->prefs['create']['min'] == 0 )
|
1063 |
-
add_action( 'groups_group_create_complete', array( $this, 'create_group' ) );
|
1064 |
-
|
1065 |
-
if ( $this->prefs['create']['creds'] < 0 )
|
1066 |
-
add_filter( 'bp_user_can_create_groups', array( $this, 'restrict_group_creation' ), 99, 2 );
|
1067 |
-
|
1068 |
-
if ( $this->prefs['delete']['creds'] != 0 )
|
1069 |
-
add_action( 'groups_group_deleted', array( $this, 'delete_group' ) );
|
1070 |
-
|
1071 |
-
if ( $this->prefs['new_topic']['creds'] != 0 )
|
1072 |
-
add_action( 'bp_forums_new_topic', array( $this, 'new_topic' ) );
|
1073 |
-
|
1074 |
-
if ( $this->prefs['edit_topic']['creds'] != 0 )
|
1075 |
-
add_action( 'groups_edit_forum_topic', array( $this, 'edit_topic' ) );
|
1076 |
-
|
1077 |
-
if ( $this->prefs['new_post']['creds'] != 0 )
|
1078 |
-
add_action( 'bp_forums_new_post', array( $this, 'new_post' ) );
|
1079 |
-
|
1080 |
-
if ( $this->prefs['edit_post']['creds'] != 0 )
|
1081 |
-
add_action( 'groups_edit_forum_post', array( $this, 'edit_post' ) );
|
1082 |
-
|
1083 |
-
if ( $this->prefs['join']['creds'] != 0 || ( $this->prefs['create']['creds'] != 0 && $this->prefs['create']['min'] != 0 ) )
|
1084 |
-
add_action( 'groups_join_group', array( $this, 'join_group' ), 20, 2 );
|
1085 |
-
|
1086 |
-
if ( $this->prefs['join']['creds'] < 0 )
|
1087 |
-
add_filter( 'bp_get_group_join_button', array( $this, 'restrict_joining_group' ) );
|
1088 |
-
|
1089 |
-
if ( $this->prefs['leave']['creds'] != 0 )
|
1090 |
-
add_action( 'groups_leave_group', array( $this, 'leave_group' ), 20, 2 );
|
1091 |
-
|
1092 |
-
if ( $this->prefs['avatar']['creds'] != 0 )
|
1093 |
-
add_action( 'groups_screen_group_admin_avatar', array( $this, 'avatar_upload_group' ) );
|
1094 |
-
|
1095 |
-
if ( $this->prefs['cover']['creds'] != 0 )
|
1096 |
-
add_action( 'group_cover_image_uploaded', array( $this, 'cover_change' ) );
|
1097 |
-
|
1098 |
-
if ( $this->prefs['comments']['creds'] != 0 )
|
1099 |
-
add_action( 'bp_groups_posted_update', array( $this, 'new_group_comment' ), 20, 4 );
|
1100 |
-
|
1101 |
-
}
|
1102 |
-
|
1103 |
-
/**
|
1104 |
-
* Creating Group
|
1105 |
-
* @since 0.1
|
1106 |
-
* @version 1.0
|
1107 |
-
*/
|
1108 |
-
public function create_group( $group_id ) {
|
1109 |
-
|
1110 |
-
global $bp;
|
1111 |
-
|
1112 |
-
// Check if user should be excluded
|
1113 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
1114 |
-
|
1115 |
-
// Execute
|
1116 |
-
$this->core->add_creds(
|
1117 |
-
'creation_of_new_group',
|
1118 |
-
$bp->loggedin_user->id,
|
1119 |
-
$this->prefs['create']['creds'],
|
1120 |
-
$this->prefs['create']['log'],
|
1121 |
-
$group_id,
|
1122 |
-
'bp_group',
|
1123 |
-
$this->mycred_type
|
1124 |
-
);
|
1125 |
-
|
1126 |
-
}
|
1127 |
-
|
1128 |
-
/**
|
1129 |
-
* Restrict Group Creation
|
1130 |
-
* If creating a group costs and the user does not have enough points, we restrict creations.
|
1131 |
-
* @since 0.1
|
1132 |
-
* @version 1.0
|
1133 |
-
*/
|
1134 |
-
public function restrict_group_creation( $can_create, $restricted ) {
|
1135 |
-
|
1136 |
-
global $bp;
|
1137 |
-
|
1138 |
-
// Check if user should be excluded
|
1139 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return $can_create;
|
1140 |
-
|
1141 |
-
// Check if user has enough to create a group
|
1142 |
-
$cost = abs( $this->prefs['create']['creds'] );
|
1143 |
-
$balance = $this->core->get_users_balance( $bp->loggedin_user->id, $this->mycred_type );
|
1144 |
-
if ( $cost > $balance ) return false;
|
1145 |
-
|
1146 |
-
return $can_create;
|
1147 |
-
|
1148 |
-
}
|
1149 |
-
|
1150 |
-
/**
|
1151 |
-
* Restrict Group Join
|
1152 |
-
* If joining a group costs and the user does not have enough points, we restrict joining of groups.
|
1153 |
-
* @since 0.1
|
1154 |
-
* @version 1.0
|
1155 |
-
*/
|
1156 |
-
public function restrict_joining_group( $button ) {
|
1157 |
-
|
1158 |
-
global $bp;
|
1159 |
-
|
1160 |
-
// Check if user should be excluded
|
1161 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return $button;
|
1162 |
-
|
1163 |
-
// Check if user has enough to join group
|
1164 |
-
$cost = abs( $this->prefs['join']['creds'] );
|
1165 |
-
$balance = $this->core->get_users_balance( $bp->loggedin_user->id, $this->mycred_type );
|
1166 |
-
if ( $cost > $balance ) return false;
|
1167 |
-
|
1168 |
-
return $button;
|
1169 |
-
|
1170 |
-
}
|
1171 |
-
|
1172 |
-
/**
|
1173 |
-
* Deleting Group
|
1174 |
-
* @since 0.1
|
1175 |
-
* @version 1.0
|
1176 |
-
*/
|
1177 |
-
public function delete_group( $group_id ) {
|
1178 |
-
|
1179 |
-
global $bp;
|
1180 |
-
|
1181 |
-
// If admin is removing deduct from creator
|
1182 |
-
if ( $bp->loggedin_user->is_super_admin )
|
1183 |
-
$user_id = $bp->groups->current_group->creator_id;
|
1184 |
-
|
1185 |
-
// Else if admin but not the creator is removing
|
1186 |
-
elseif ( $bp->loggedin_user->id != $bp->groups->current_group->creator_id )
|
1187 |
-
$user_id = $bp->groups->current_group->creator_id;
|
1188 |
-
|
1189 |
-
// Else deduct from current user
|
1190 |
-
else
|
1191 |
-
$user_id = $bp->loggedin_user->id;
|
1192 |
-
|
1193 |
-
// Check if user should be excluded
|
1194 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
1195 |
-
|
1196 |
-
// Execute
|
1197 |
-
$this->core->add_creds(
|
1198 |
-
'deletion_of_group',
|
1199 |
-
$user_id,
|
1200 |
-
$this->prefs['delete']['creds'],
|
1201 |
-
$this->prefs['delete']['log'],
|
1202 |
-
$group_id,
|
1203 |
-
'bp_group',
|
1204 |
-
$this->mycred_type
|
1205 |
-
);
|
1206 |
-
|
1207 |
-
}
|
1208 |
-
|
1209 |
-
/**
|
1210 |
-
* New Group Forum Topic
|
1211 |
-
* @since 0.1
|
1212 |
-
* @version 1.1
|
1213 |
-
*/
|
1214 |
-
public function new_topic( $topic_id ) {
|
1215 |
-
|
1216 |
-
global $bp;
|
1217 |
-
|
1218 |
-
// Check if user should be excluded
|
1219 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
1220 |
-
|
1221 |
-
// Limit
|
1222 |
-
if ( $this->over_hook_limit( 'new_topic', 'new_group_forum_topic' ) ) return;
|
1223 |
-
|
1224 |
-
// Make sure this is unique event
|
1225 |
-
if ( $this->core->has_entry( 'new_group_forum_topic', $topic_id, $bp->loggedin_user->id ) ) return;
|
1226 |
-
|
1227 |
-
// Execute
|
1228 |
-
$this->core->add_creds(
|
1229 |
-
'new_group_forum_topic',
|
1230 |
-
$bp->loggedin_user->id,
|
1231 |
-
$this->prefs['new_topic']['creds'],
|
1232 |
-
$this->prefs['new_topic']['log'],
|
1233 |
-
$topic_id,
|
1234 |
-
'bp_ftopic',
|
1235 |
-
$this->mycred_type
|
1236 |
-
);
|
1237 |
-
|
1238 |
-
}
|
1239 |
-
|
1240 |
-
/**
|
1241 |
-
* Edit Group Forum Topic
|
1242 |
-
* @since 0.1
|
1243 |
-
* @version 1.0
|
1244 |
-
*/
|
1245 |
-
public function edit_topic( $topic_id ) {
|
1246 |
-
|
1247 |
-
global $bp;
|
1248 |
-
|
1249 |
-
// Check if user should be excluded
|
1250 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
1251 |
-
|
1252 |
-
// Limit
|
1253 |
-
if ( $this->over_hook_limit( 'edit_topic', 'edit_group_forum_topic' ) ) return;
|
1254 |
-
|
1255 |
-
// Execute
|
1256 |
-
$this->core->add_creds(
|
1257 |
-
'edit_group_forum_topic',
|
1258 |
-
$bp->loggedin_user->id,
|
1259 |
-
$this->prefs['edit_topic']['creds'],
|
1260 |
-
$this->prefs['edit_topic']['log'],
|
1261 |
-
$topic_id,
|
1262 |
-
'bp_ftopic',
|
1263 |
-
$this->mycred_type
|
1264 |
-
);
|
1265 |
-
|
1266 |
-
}
|
1267 |
-
|
1268 |
-
/**
|
1269 |
-
* New Group Forum Post
|
1270 |
-
* @since 0.1
|
1271 |
-
* @version 1.1
|
1272 |
-
*/
|
1273 |
-
public function new_post( $post_id ) {
|
1274 |
-
|
1275 |
-
global $bp;
|
1276 |
-
|
1277 |
-
// Check if user should be excluded
|
1278 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
1279 |
-
|
1280 |
-
// Limit
|
1281 |
-
if ( $this->over_hook_limit( 'new_post', 'new_group_forum_post' ) ) return;
|
1282 |
-
|
1283 |
-
// Make sure this is unique event
|
1284 |
-
if ( $this->core->has_entry( 'new_group_forum_post', $post_id, $bp->loggedin_user->id ) ) return;
|
1285 |
-
|
1286 |
-
// Execute
|
1287 |
-
$this->core->add_creds(
|
1288 |
-
'new_group_forum_post',
|
1289 |
-
$bp->loggedin_user->id,
|
1290 |
-
$this->prefs['new_post']['creds'],
|
1291 |
-
$this->prefs['new_post']['log'],
|
1292 |
-
$post_id,
|
1293 |
-
'bp_fpost',
|
1294 |
-
$this->mycred_type
|
1295 |
-
);
|
1296 |
-
|
1297 |
-
}
|
1298 |
-
|
1299 |
-
/**
|
1300 |
-
* Edit Group Forum Post
|
1301 |
-
* @since 0.1
|
1302 |
-
* @version 1.0
|
1303 |
-
*/
|
1304 |
-
public function edit_post( $post_id ) {
|
1305 |
-
|
1306 |
-
global $bp;
|
1307 |
-
|
1308 |
-
// Check if user should be excluded
|
1309 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
1310 |
-
|
1311 |
-
// Limit
|
1312 |
-
if ( $this->over_hook_limit( 'edit_post', 'edit_group_forum_post' ) ) return;
|
1313 |
-
|
1314 |
-
// Execute
|
1315 |
-
$this->core->add_creds(
|
1316 |
-
'edit_group_forum_post',
|
1317 |
-
$bp->loggedin_user->id,
|
1318 |
-
$this->prefs['edit_post']['creds'],
|
1319 |
-
$this->prefs['edit_post']['log'],
|
1320 |
-
$post_id,
|
1321 |
-
'bp_fpost',
|
1322 |
-
$this->mycred_type
|
1323 |
-
);
|
1324 |
-
|
1325 |
-
}
|
1326 |
-
|
1327 |
-
/**
|
1328 |
-
* Joining Group
|
1329 |
-
* @since 0.1
|
1330 |
-
* @version 1.1
|
1331 |
-
*/
|
1332 |
-
public function join_group( $group_id, $user_id ) {
|
1333 |
-
|
1334 |
-
// Minimum members limit
|
1335 |
-
if ( $this->prefs['create']['min'] != 0 ) {
|
1336 |
-
$group = groups_get_group( array( 'group_id' => $group_id ) );
|
1337 |
-
|
1338 |
-
// Award creator if we have reached the minimum number of members and we have not yet been awarded
|
1339 |
-
if ( $group->total_member_count >= (int) $this->prefs['create']['min'] && ! $this->core->has_entry( 'creation_of_new_group', $group_id, $group->creator_id ) )
|
1340 |
-
$this->core->add_creds(
|
1341 |
-
'creation_of_new_group',
|
1342 |
-
$group->creator_id,
|
1343 |
-
$this->prefs['create']['creds'],
|
1344 |
-
$this->prefs['create']['log'],
|
1345 |
-
$group_id,
|
1346 |
-
'bp_group',
|
1347 |
-
$this->mycred_type
|
1348 |
-
);
|
1349 |
-
|
1350 |
-
// Clean up
|
1351 |
-
unset( $group );
|
1352 |
-
|
1353 |
-
}
|
1354 |
-
|
1355 |
-
// Check if user should be excluded
|
1356 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
1357 |
-
|
1358 |
-
// Limit
|
1359 |
-
if ( $this->over_hook_limit( 'join', 'joining_group' ) ) return;
|
1360 |
-
|
1361 |
-
// Make sure this is unique event
|
1362 |
-
if ( $this->core->has_entry( 'joining_group', $group_id, $user_id ) ) return;
|
1363 |
-
|
1364 |
-
// Execute
|
1365 |
-
$this->core->add_creds(
|
1366 |
-
'joining_group',
|
1367 |
-
$user_id,
|
1368 |
-
$this->prefs['join']['creds'],
|
1369 |
-
$this->prefs['join']['log'],
|
1370 |
-
$group_id,
|
1371 |
-
'bp_group',
|
1372 |
-
$this->mycred_type
|
1373 |
-
);
|
1374 |
-
|
1375 |
-
}
|
1376 |
-
|
1377 |
-
/**
|
1378 |
-
* Leaving Group
|
1379 |
-
* @since 0.1
|
1380 |
-
* @version 1.0
|
1381 |
-
*/
|
1382 |
-
public function leave_group( $group_id, $user_id ) {
|
1383 |
-
|
1384 |
-
// Check if user should be excluded
|
1385 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
1386 |
-
|
1387 |
-
// Make sure this is unique event
|
1388 |
-
if ( $this->core->has_entry( 'leaving_group', $group_id, $user_id ) ) return;
|
1389 |
-
|
1390 |
-
// Execute
|
1391 |
-
$this->core->add_creds(
|
1392 |
-
'leaving_group',
|
1393 |
-
$user_id,
|
1394 |
-
$this->prefs['leave']['creds'],
|
1395 |
-
$this->prefs['leave']['log'],
|
1396 |
-
$group_id,
|
1397 |
-
'bp_group',
|
1398 |
-
$this->mycred_type
|
1399 |
-
);
|
1400 |
-
|
1401 |
-
}
|
1402 |
-
|
1403 |
-
/**
|
1404 |
-
* Avatar Upload for Group
|
1405 |
-
* @since 0.1
|
1406 |
-
* @version 1.1
|
1407 |
-
*/
|
1408 |
-
public function avatar_upload_group( $group_id ) {
|
1409 |
-
|
1410 |
-
global $bp;
|
1411 |
-
|
1412 |
-
// Check if user should be excluded
|
1413 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
1414 |
-
|
1415 |
-
// Limit
|
1416 |
-
if ( $this->over_hook_limit( 'avatar', 'upload_group_avatar' ) ) return;
|
1417 |
-
|
1418 |
-
// Make sure this is unique event
|
1419 |
-
if ( $this->core->has_entry( 'upload_group_avatar', $group_id ) ) return;
|
1420 |
-
|
1421 |
-
// Execute
|
1422 |
-
$this->core->add_creds(
|
1423 |
-
'upload_group_avatar',
|
1424 |
-
$bp->loggedin_user->id,
|
1425 |
-
$this->prefs['avatar']['creds'],
|
1426 |
-
$this->prefs['avatar']['log'],
|
1427 |
-
$group_id,
|
1428 |
-
'bp_group',
|
1429 |
-
$this->mycred_type
|
1430 |
-
);
|
1431 |
-
|
1432 |
-
}
|
1433 |
-
|
1434 |
-
/**
|
1435 |
-
* Group Cover Upload
|
1436 |
-
* @since 1.7
|
1437 |
-
* @version 1.0
|
1438 |
-
*/
|
1439 |
-
public function cover_change( $group_id ) {
|
1440 |
-
|
1441 |
-
global $bp;
|
1442 |
-
|
1443 |
-
// Check if user is excluded
|
1444 |
-
if ( $this->core->exclude_user( $bp->loggedin_user->id ) ) return;
|
1445 |
-
|
1446 |
-
// Limit
|
1447 |
-
if ( $this->over_hook_limit( 'cover', 'upload_group_cover', $bp->loggedin_user->id ) ) return;
|
1448 |
-
|
1449 |
-
// Execute
|
1450 |
-
$this->core->add_creds(
|
1451 |
-
'upload_group_cover',
|
1452 |
-
$bp->loggedin_user->id,
|
1453 |
-
$this->prefs['cover']['creds'],
|
1454 |
-
$this->prefs['cover']['log'],
|
1455 |
-
$group_id,
|
1456 |
-
'bp_group',
|
1457 |
-
$this->mycred_type
|
1458 |
-
);
|
1459 |
-
|
1460 |
-
}
|
1461 |
-
|
1462 |
-
/**
|
1463 |
-
* New Group Comment
|
1464 |
-
* @since 0.1
|
1465 |
-
* @version 1.1
|
1466 |
-
*/
|
1467 |
-
public function new_group_comment( $content, $user_id, $group_id, $activity_id ) {
|
1468 |
-
|
1469 |
-
// Check if user should be excluded
|
1470 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
1471 |
-
|
1472 |
-
// Limit
|
1473 |
-
if ( $this->over_hook_limit( 'comments', 'new_group_comment', $user_id ) ) return;
|
1474 |
-
|
1475 |
-
// Make sure this is unique event
|
1476 |
-
if ( $this->core->has_entry( 'new_group_comment', $activity_id, $user_id ) ) return;
|
1477 |
-
|
1478 |
-
// Execute
|
1479 |
-
$this->core->add_creds(
|
1480 |
-
'new_group_comment',
|
1481 |
-
$user_id,
|
1482 |
-
$this->prefs['comments']['creds'],
|
1483 |
-
$this->prefs['comments']['log'],
|
1484 |
-
$activity_id,
|
1485 |
-
'bp_activity',
|
1486 |
-
$this->mycred_type
|
1487 |
-
);
|
1488 |
-
|
1489 |
-
}
|
1490 |
-
|
1491 |
-
/**
|
1492 |
-
* Preferences
|
1493 |
-
* @since 0.1
|
1494 |
-
* @version 1.3
|
1495 |
-
*/
|
1496 |
-
public function preferences() {
|
1497 |
-
|
1498 |
-
$prefs = $this->prefs;
|
1499 |
-
|
1500 |
-
?>
|
1501 |
-
<div class="hook-instance">
|
1502 |
-
<h3><?php _e( 'Group Creation', 'mycred' ); ?></h3>
|
1503 |
-
<div class="row">
|
1504 |
-
<div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
|
1505 |
-
<div class="form-group">
|
1506 |
-
<label for="<?php echo $this->field_id( array( 'create', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1507 |
-
<input type="text" name="<?php echo $this->field_name( array( 'create', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'create', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['create']['creds'] ); ?>" class="form-control" />
|
1508 |
-
<span class="description"><?php echo $this->core->template_tags_general( __( 'If you use a negative value and the user does not have enough %_plural%, the "Create Group" button will be disabled.', 'mycred' ) ); ?></span>
|
1509 |
-
</div>
|
1510 |
-
</div>
|
1511 |
-
<div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
|
1512 |
-
<div class="form-group">
|
1513 |
-
<label for="<?php echo $this->field_id( array( 'create', 'min' ) ); ?>"><?php _e( 'No. of Members', 'mycred' ); ?></label>
|
1514 |
-
<input type="text" name="<?php echo $this->field_name( array( 'create', 'min' ) ); ?>" id="<?php echo $this->field_id( array( 'create', 'min' ) ); ?>" value="<?php echo esc_attr( $prefs['create']['min'] ); ?>" class="form-control" />
|
1515 |
-
<span class="description"><?php echo $this->core->template_tags_general( __( 'The number of members a group must gain before awarding %_plural%. Use zero to award as soon as the group is created.', 'mycred' ) ); ?></span>
|
1516 |
-
</div>
|
1517 |
-
</div>
|
1518 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1519 |
-
<div class="form-group">
|
1520 |
-
<label for="<?php echo $this->field_id( array( 'create', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1521 |
-
<input type="text" name="<?php echo $this->field_name( array( 'create', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'create', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['create']['log'] ); ?>" class="form-control" />
|
1522 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1523 |
-
</div>
|
1524 |
-
</div>
|
1525 |
-
</div>
|
1526 |
-
</div>
|
1527 |
-
<div class="hook-instance">
|
1528 |
-
<h3><?php _e( 'Group Deletions', 'mycred' ); ?></h3>
|
1529 |
-
<div class="row">
|
1530 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1531 |
-
<div class="form-group">
|
1532 |
-
<label for="<?php echo $this->field_id( array( 'delete', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1533 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'delete', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['delete']['creds'] ); ?>" class="form-control" />
|
1534 |
-
</div>
|
1535 |
-
</div>
|
1536 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
1537 |
-
<div class="form-group">
|
1538 |
-
<label for="<?php echo $this->field_id( array( 'delete', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1539 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete']['log'] ); ?>" class="form-control" />
|
1540 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1541 |
-
</div>
|
1542 |
-
</div>
|
1543 |
-
</div>
|
1544 |
-
</div>
|
1545 |
-
<div class="hook-instance">
|
1546 |
-
<h3><?php _e( 'New Group Avatar Upload', 'mycred' ); ?></h3>
|
1547 |
-
<div class="row">
|
1548 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
1549 |
-
<div class="form-group">
|
1550 |
-
<label for="<?php echo $this->field_id( array( 'avatar', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1551 |
-
<input type="text" name="<?php echo $this->field_name( array( 'avatar', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'avatar', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['avatar']['creds'] ); ?>" class="form-control" />
|
1552 |
-
</div>
|
1553 |
-
</div>
|
1554 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1555 |
-
<div class="form-group">
|
1556 |
-
<label for="<?php echo $this->field_id( array( 'avatar', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
1557 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'avatar', 'limit' ) ), $this->field_id( array( 'avatar', 'limit' ) ), $prefs['avatar']['limit'] ); ?>
|
1558 |
-
</div>
|
1559 |
-
</div>
|
1560 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1561 |
-
<div class="form-group">
|
1562 |
-
<label for="<?php echo $this->field_id( array( 'avatar', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1563 |
-
<input type="text" name="<?php echo $this->field_name( array( 'avatar', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'avatar', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['avatar']['log'] ); ?>" class="form-control" />
|
1564 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1565 |
-
</div>
|
1566 |
-
</div>
|
1567 |
-
</div>
|
1568 |
-
</div>
|
1569 |
-
<div class="hook-instance">
|
1570 |
-
<h3><?php _e( 'New Group Cover Upload', 'mycred' ); ?></h3>
|
1571 |
-
<div class="row">
|
1572 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
1573 |
-
<div class="form-group">
|
1574 |
-
<label for="<?php echo $this->field_id( array( 'cover', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1575 |
-
<input type="text" name="<?php echo $this->field_name( array( 'cover', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'cover', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['cover']['creds'] ); ?>" class="form-control" />
|
1576 |
-
</div>
|
1577 |
-
</div>
|
1578 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1579 |
-
<div class="form-group">
|
1580 |
-
<label for="<?php echo $this->field_id( array( 'cover', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
1581 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'cover', 'limit' ) ), $this->field_id( array( 'cover', 'limit' ) ), $prefs['cover']['limit'] ); ?>
|
1582 |
-
</div>
|
1583 |
-
</div>
|
1584 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1585 |
-
<div class="form-group">
|
1586 |
-
<label for="<?php echo $this->field_id( array( 'cover', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1587 |
-
<input type="text" name="<?php echo $this->field_name( array( 'cover', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'cover', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['cover']['log'] ); ?>" class="form-control" />
|
1588 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1589 |
-
</div>
|
1590 |
-
</div>
|
1591 |
-
</div>
|
1592 |
-
</div>
|
1593 |
-
<div class="hook-instance">
|
1594 |
-
<h3><?php _e( 'New Forum Topics', 'mycred' ); ?></h3>
|
1595 |
-
<div class="row">
|
1596 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
1597 |
-
<div class="form-group">
|
1598 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1599 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_topic', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_topic', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_topic']['creds'] ); ?>" class="form-control" />
|
1600 |
-
</div>
|
1601 |
-
</div>
|
1602 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1603 |
-
<div class="form-group">
|
1604 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
1605 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_topic', 'limit' ) ), $this->field_id( array( 'new_topic', 'limit' ) ), $prefs['new_topic']['limit'] ); ?>
|
1606 |
-
</div>
|
1607 |
-
</div>
|
1608 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1609 |
-
<div class="form-group">
|
1610 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1611 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_topic', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_topic', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_topic']['log'] ); ?>" class="form-control" />
|
1612 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1613 |
-
</div>
|
1614 |
-
</div>
|
1615 |
-
</div>
|
1616 |
-
</div>
|
1617 |
-
<div class="hook-instance">
|
1618 |
-
<h3><?php _e( 'Editing Forum Topics', 'mycred' ); ?></h3>
|
1619 |
-
<div class="row">
|
1620 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
1621 |
-
<div class="form-group">
|
1622 |
-
<label for="<?php echo $this->field_id( array( 'edit_topic', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1623 |
-
<input type="text" name="<?php echo $this->field_name( array( 'edit_topic', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'edit_topic', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['edit_topic']['creds'] ); ?>" class="form-control" />
|
1624 |
-
</div>
|
1625 |
-
</div>
|
1626 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1627 |
-
<div class="form-group">
|
1628 |
-
<label for="<?php echo $this->field_id( array( 'edit_topic', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
1629 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'edit_topic', 'limit' ) ), $this->field_id( array( 'edit_topic', 'limit' ) ), $prefs['edit_topic']['limit'] ); ?>
|
1630 |
-
</div>
|
1631 |
-
</div>
|
1632 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1633 |
-
<div class="form-group">
|
1634 |
-
<label for="<?php echo $this->field_id( array( 'edit_topic', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1635 |
-
<input type="text" name="<?php echo $this->field_name( array( 'edit_topic', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'edit_topic', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['edit_topic']['log'] ); ?>" class="form-control" />
|
1636 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1637 |
-
</div>
|
1638 |
-
</div>
|
1639 |
-
</div>
|
1640 |
-
</div>
|
1641 |
-
<div class="hook-instance">
|
1642 |
-
<h3><?php _e( 'New Forum Posts', 'mycred' ); ?></h3>
|
1643 |
-
<div class="row">
|
1644 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
1645 |
-
<div class="form-group">
|
1646 |
-
<label for="<?php echo $this->field_id( array( 'new_post', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1647 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_post', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_post', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_post']['creds'] ); ?>" class="form-control" />
|
1648 |
-
</div>
|
1649 |
-
</div>
|
1650 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1651 |
-
<div class="form-group">
|
1652 |
-
<label for="<?php echo $this->field_id( array( 'new_post', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
1653 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_post', 'limit' ) ), $this->field_id( array( 'new_post', 'limit' ) ), $prefs['new_post']['limit'] ); ?>
|
1654 |
-
</div>
|
1655 |
-
</div>
|
1656 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1657 |
-
<div class="form-group">
|
1658 |
-
<label for="<?php echo $this->field_id( array( 'new_post', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1659 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_post', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_post', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_post']['log'] ); ?>" class="form-control" />
|
1660 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1661 |
-
</div>
|
1662 |
-
</div>
|
1663 |
-
</div>
|
1664 |
-
</div>
|
1665 |
-
<div class="hook-instance">
|
1666 |
-
<h3><?php _e( 'Editing Forum Posts', 'mycred' ); ?></h3>
|
1667 |
-
<div class="row">
|
1668 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
1669 |
-
<div class="form-group">
|
1670 |
-
<label for="<?php echo $this->field_id( array( 'edit_post', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1671 |
-
<input type="text" name="<?php echo $this->field_name( array( 'edit_post', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'edit_post', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['edit_post']['creds'] ); ?>" class="form-control" />
|
1672 |
-
</div>
|
1673 |
-
</div>
|
1674 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1675 |
-
<div class="form-group">
|
1676 |
-
<label for="<?php echo $this->field_id( array( 'edit_post', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
1677 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'edit_post', 'limit' ) ), $this->field_id( array( 'edit_post', 'limit' ) ), $prefs['edit_post']['limit'] ); ?>
|
1678 |
-
</div>
|
1679 |
-
</div>
|
1680 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1681 |
-
<div class="form-group">
|
1682 |
-
<label for="<?php echo $this->field_id( array( 'edit_post', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1683 |
-
<input type="text" name="<?php echo $this->field_name( array( 'edit_post', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'edit_post', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['edit_post']['log'] ); ?>" class="form-control" />
|
1684 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1685 |
-
</div>
|
1686 |
-
</div>
|
1687 |
-
</div>
|
1688 |
-
</div>
|
1689 |
-
<div class="hook-instance">
|
1690 |
-
<h3><?php _e( 'Joining Groups', 'mycred' ); ?></h3>
|
1691 |
-
<div class="row">
|
1692 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
1693 |
-
<div class="form-group">
|
1694 |
-
<label for="<?php echo $this->field_id( array( 'join', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1695 |
-
<input type="text" name="<?php echo $this->field_name( array( 'join', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'join', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['join']['creds'] ); ?>" class="form-control" />
|
1696 |
-
</div>
|
1697 |
-
</div>
|
1698 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1699 |
-
<div class="form-group">
|
1700 |
-
<label for="<?php echo $this->field_id( array( 'join', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
1701 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'join', 'limit' ) ), $this->field_id( array( 'join', 'limit' ) ), $prefs['join']['limit'] ); ?>
|
1702 |
-
</div>
|
1703 |
-
</div>
|
1704 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1705 |
-
<div class="form-group">
|
1706 |
-
<label for="<?php echo $this->field_id( array( 'join', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1707 |
-
<input type="text" name="<?php echo $this->field_name( array( 'join', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'join', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['join']['log'] ); ?>" class="form-control" />
|
1708 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1709 |
-
</div>
|
1710 |
-
</div>
|
1711 |
-
</div>
|
1712 |
-
</div>
|
1713 |
-
<div class="hook-instance">
|
1714 |
-
<h3><?php _e( 'Leaving Groups', 'mycred' ); ?></h3>
|
1715 |
-
<div class="row">
|
1716 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1717 |
-
<div class="form-group">
|
1718 |
-
<label for="<?php echo $this->field_id( array( 'leave', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1719 |
-
<input type="text" name="<?php echo $this->field_name( array( 'leave', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'leave', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['leave']['creds'] ); ?>" class="form-control" />
|
1720 |
-
</div>
|
1721 |
-
</div>
|
1722 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
1723 |
-
<div class="form-group">
|
1724 |
-
<label for="<?php echo $this->field_id( array( 'leave', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1725 |
-
<input type="text" name="<?php echo $this->field_name( array( 'leave', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'leave', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['leave']['log'] ); ?>" class="form-control" />
|
1726 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1727 |
-
</div>
|
1728 |
-
</div>
|
1729 |
-
</div>
|
1730 |
-
</div>
|
1731 |
-
<div class="hook-instance">
|
1732 |
-
<h3><?php _e( 'New Group Comments', 'mycred' ); ?></h3>
|
1733 |
-
<div class="row">
|
1734 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
1735 |
-
<div class="form-group">
|
1736 |
-
<label for="<?php echo $this->field_id( array( 'comments', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
1737 |
-
<input type="text" name="<?php echo $this->field_name( array( 'comments', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'comments', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['comments']['creds'] ); ?>" class="form-control" />
|
1738 |
-
</div>
|
1739 |
-
</div>
|
1740 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
1741 |
-
<div class="form-group">
|
1742 |
-
<label for="<?php echo $this->field_id( array( 'comments', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
1743 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'comments', 'limit' ) ), $this->field_id( array( 'comments', 'limit' ) ), $prefs['comments']['limit'] ); ?>
|
1744 |
-
</div>
|
1745 |
-
</div>
|
1746 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
1747 |
-
<div class="form-group">
|
1748 |
-
<label for="<?php echo $this->field_id( array( 'comments', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
1749 |
-
<input type="text" name="<?php echo $this->field_name( array( 'comments', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'comments', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['comments']['log'] ); ?>" class="form-control" />
|
1750 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
1751 |
-
</div>
|
1752 |
-
</div>
|
1753 |
-
</div>
|
1754 |
-
</div>
|
1755 |
-
<?php
|
1756 |
-
|
1757 |
-
}
|
1758 |
-
|
1759 |
-
/**
|
1760 |
-
* Sanitise Preferences
|
1761 |
-
* @since 1.6
|
1762 |
-
* @version 1.1
|
1763 |
-
*/
|
1764 |
-
public function sanitise_preferences( $data ) {
|
1765 |
-
|
1766 |
-
if ( isset( $data['new_topic']['limit'] ) && isset( $data['new_topic']['limit_by'] ) ) {
|
1767 |
-
$limit = sanitize_text_field( $data['new_topic']['limit'] );
|
1768 |
-
if ( $limit == '' ) $limit = 0;
|
1769 |
-
$data['new_topic']['limit'] = $limit . '/' . $data['new_topic']['limit_by'];
|
1770 |
-
unset( $data['new_topic']['limit_by'] );
|
1771 |
-
}
|
1772 |
-
|
1773 |
-
if ( isset( $data['edit_topic']['limit'] ) && isset( $data['edit_topic']['limit_by'] ) ) {
|
1774 |
-
$limit = sanitize_text_field( $data['edit_topic']['limit'] );
|
1775 |
-
if ( $limit == '' ) $limit = 0;
|
1776 |
-
$data['edit_topic']['limit'] = $limit . '/' . $data['edit_topic']['limit_by'];
|
1777 |
-
unset( $data['edit_topic']['limit_by'] );
|
1778 |
-
}
|
1779 |
-
|
1780 |
-
if ( isset( $data['new_post']['limit'] ) && isset( $data['new_post']['limit_by'] ) ) {
|
1781 |
-
$limit = sanitize_text_field( $data['new_post']['limit'] );
|
1782 |
-
if ( $limit == '' ) $limit = 0;
|
1783 |
-
$data['new_post']['limit'] = $limit . '/' . $data['new_post']['limit_by'];
|
1784 |
-
unset( $data['new_post']['limit_by'] );
|
1785 |
-
}
|
1786 |
-
|
1787 |
-
if ( isset( $data['edit_post']['limit'] ) && isset( $data['edit_post']['limit_by'] ) ) {
|
1788 |
-
$limit = sanitize_text_field( $data['edit_post']['limit'] );
|
1789 |
-
if ( $limit == '' ) $limit = 0;
|
1790 |
-
$data['edit_post']['limit'] = $limit . '/' . $data['edit_post']['limit_by'];
|
1791 |
-
unset( $data['edit_post']['limit_by'] );
|
1792 |
-
}
|
1793 |
-
|
1794 |
-
if ( isset( $data['join']['limit'] ) && isset( $data['join']['limit_by'] ) ) {
|
1795 |
-
$limit = sanitize_text_field( $data['join']['limit'] );
|
1796 |
-
if ( $limit == '' ) $limit = 0;
|
1797 |
-
$data['join']['limit'] = $limit . '/' . $data['join']['limit_by'];
|
1798 |
-
unset( $data['join']['limit_by'] );
|
1799 |
-
}
|
1800 |
-
|
1801 |
-
if ( isset( $data['avatar']['limit'] ) && isset( $data['avatar']['limit_by'] ) ) {
|
1802 |
-
$limit = sanitize_text_field( $data['avatar']['limit'] );
|
1803 |
-
if ( $limit == '' ) $limit = 0;
|
1804 |
-
$data['avatar']['limit'] = $limit . '/' . $data['avatar']['limit_by'];
|
1805 |
-
unset( $data['avatar']['limit_by'] );
|
1806 |
-
}
|
1807 |
-
|
1808 |
-
if ( isset( $data['cover']['limit'] ) && isset( $data['cover']['limit_by'] ) ) {
|
1809 |
-
$limit = sanitize_text_field( $data['cover']['limit'] );
|
1810 |
-
if ( $limit == '' ) $limit = 0;
|
1811 |
-
$data['cover']['limit'] = $limit . '/' . $data['cover']['limit_by'];
|
1812 |
-
unset( $data['cover']['limit_by'] );
|
1813 |
-
}
|
1814 |
-
|
1815 |
-
if ( isset( $data['comments']['limit'] ) && isset( $data['comments']['limit_by'] ) ) {
|
1816 |
-
$limit = sanitize_text_field( $data['comments']['limit'] );
|
1817 |
-
if ( $limit == '' ) $limit = 0;
|
1818 |
-
$data['comments']['limit'] = $limit . '/' . $data['comments']['limit_by'];
|
1819 |
-
unset( $data['comments']['limit_by'] );
|
1820 |
-
}
|
1821 |
-
|
1822 |
-
return $data;
|
1823 |
-
|
1824 |
-
}
|
1825 |
-
|
1826 |
-
}
|
1827 |
-
|
1828 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-contact-form7.php
DELETED
@@ -1,216 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 0.1
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_contact_form_seven_hook', 50 );
|
10 |
-
function mycred_register_contact_form_seven_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! function_exists( 'wpcf7' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['contact_form7'] = array(
|
15 |
-
'title' => __( 'Contact Form 7 Form Submissions', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for successful form submissions (by logged in users).', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/submitting-contact-form-7-forms/',
|
18 |
-
'callback' => array( 'myCRED_Contact_Form7' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Contact Form 7 Hook
|
27 |
-
* @since 0.1
|
28 |
-
* @version 1.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_contact_form_seven_hook', 50 );
|
31 |
-
function mycred_load_contact_form_seven_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_Contact_Form7' ) || ! function_exists( 'wpcf7' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_Contact_Form7 extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'contact_form7',
|
45 |
-
'defaults' => array()
|
46 |
-
), $hook_prefs, $type );
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Run
|
52 |
-
* @since 0.1
|
53 |
-
* @version 1.0
|
54 |
-
*/
|
55 |
-
public function run() {
|
56 |
-
|
57 |
-
add_action( 'wpcf7_mail_sent', array( $this, 'form_submission' ) );
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Get Forms
|
63 |
-
* Queries all Contact Form 7 forms.
|
64 |
-
* @since 0.1
|
65 |
-
* @version 1.2
|
66 |
-
*/
|
67 |
-
public function get_forms() {
|
68 |
-
|
69 |
-
global $wpdb;
|
70 |
-
|
71 |
-
$restuls = array();
|
72 |
-
$forms = $wpdb->get_results( $wpdb->prepare( "
|
73 |
-
SELECT ID, post_title
|
74 |
-
FROM {$wpdb->posts}
|
75 |
-
WHERE post_type = %s
|
76 |
-
ORDER BY ID ASC;", 'wpcf7_contact_form' ) );
|
77 |
-
|
78 |
-
if ( $forms ) {
|
79 |
-
foreach ( $forms as $form )
|
80 |
-
$restuls[ $form->ID ] = $form->post_title;
|
81 |
-
}
|
82 |
-
|
83 |
-
return $restuls;
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Successful Form Submission
|
89 |
-
* @since 0.1
|
90 |
-
* @version 1.4.1
|
91 |
-
*/
|
92 |
-
public function form_submission( $form_object ) {
|
93 |
-
|
94 |
-
// Login is required
|
95 |
-
if ( ! is_user_logged_in() ) return;
|
96 |
-
|
97 |
-
$form_id = ( version_compare( WPCF7_VERSION, '4.8', '<' ) ) ? $form_object->id : $form_object->id();
|
98 |
-
|
99 |
-
if ( ! isset( $this->prefs[ $form_id ] ) || ! $this->prefs[ $form_id ]['creds'] != 0 ) return;
|
100 |
-
|
101 |
-
// Check for exclusions
|
102 |
-
$user_id = get_current_user_id();
|
103 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
104 |
-
|
105 |
-
// Limit
|
106 |
-
if ( $this->over_hook_limit( $form_id, 'contact_form_submission' ) ) return;
|
107 |
-
|
108 |
-
$this->core->add_creds(
|
109 |
-
'contact_form_submission',
|
110 |
-
$user_id,
|
111 |
-
$this->prefs[ $form_id ]['creds'],
|
112 |
-
$this->prefs[ $form_id ]['log'],
|
113 |
-
$form_id,
|
114 |
-
array( 'ref_type' => 'post' ),
|
115 |
-
$this->mycred_type
|
116 |
-
);
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Preferences for Contact Form 7 Hook
|
122 |
-
* @since 0.1
|
123 |
-
* @version 1.2.1
|
124 |
-
*/
|
125 |
-
public function preferences() {
|
126 |
-
|
127 |
-
$prefs = $this->prefs;
|
128 |
-
if ( $prefs === false ) $prefs = array();
|
129 |
-
|
130 |
-
$forms = $this->get_forms();
|
131 |
-
|
132 |
-
// No forms found
|
133 |
-
if ( empty( $forms ) ) {
|
134 |
-
echo '<p>' . __( 'No forms found.', 'mycred' ) . '</p>';
|
135 |
-
return;
|
136 |
-
}
|
137 |
-
|
138 |
-
// Loop though prefs to make sure we always have a default settings (happens when a new form has been created)
|
139 |
-
foreach ( $forms as $form_id => $form_title ) {
|
140 |
-
|
141 |
-
if ( ! array_key_exists( $form_id, $prefs ) ) {
|
142 |
-
$prefs[ $form_id ] = array(
|
143 |
-
'creds' => 0,
|
144 |
-
'log' => '%plural% for submitting form',
|
145 |
-
'limit' => '0/x'
|
146 |
-
);
|
147 |
-
}
|
148 |
-
|
149 |
-
if ( ! isset( $prefs[ $form_id ]['limit'] ) )
|
150 |
-
$prefs[ $form_id ]['limit'] = '0/x';
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
// Set pref if empty
|
155 |
-
if ( empty( $prefs ) ) $this->prefs = $prefs;
|
156 |
-
|
157 |
-
// Loop for settings
|
158 |
-
foreach ( $forms as $form_id => $form_title ) {
|
159 |
-
|
160 |
-
?>
|
161 |
-
<div class="hook-instance">
|
162 |
-
<h3><?php printf( __( 'Form: %s', 'mycred' ), $form_title ); ?></h3>
|
163 |
-
<div class="row">
|
164 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
165 |
-
<div class="form-group">
|
166 |
-
<label for="<?php echo $this->field_id( array( $form_id, 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
167 |
-
<input type="text" name="<?php echo $this->field_name( array( $form_id, 'creds' ) ); ?>" id="<?php echo $this->field_id( array( $form_id, 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs[ $form_id ]['creds'] ); ?>" class="form-control" />
|
168 |
-
</div>
|
169 |
-
</div>
|
170 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
171 |
-
<div class="form-group">
|
172 |
-
<label for="<?php echo $this->field_id( array( $form_id, 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
173 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( $form_id, 'limit' ) ), $this->field_id( array( $form_id, 'limit' ) ), $prefs[ $form_id ]['limit'] ); ?>
|
174 |
-
</div>
|
175 |
-
</div>
|
176 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
177 |
-
<div class="form-group">
|
178 |
-
<label for="<?php echo $this->field_id( array( $form_id, 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
179 |
-
<input type="text" name="<?php echo $this->field_name( array( $form_id, 'log' ) ); ?>" id="<?php echo $this->field_id( array( $form_id, 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs[ $form_id ]['log'] ); ?>" class="form-control" />
|
180 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
181 |
-
</div>
|
182 |
-
</div>
|
183 |
-
</div>
|
184 |
-
</div>
|
185 |
-
<?php
|
186 |
-
|
187 |
-
}
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Sanitise Preferences
|
193 |
-
* @since 1.6
|
194 |
-
* @version 1.0
|
195 |
-
*/
|
196 |
-
public function sanitise_preferences( $data ) {
|
197 |
-
|
198 |
-
$forms = $this->get_forms();
|
199 |
-
foreach ( $forms as $form_id => $form_title ) {
|
200 |
-
|
201 |
-
if ( isset( $data[ $form_id ]['limit'] ) && isset( $data[ $form_id ]['limit_by'] ) ) {
|
202 |
-
$limit = sanitize_text_field( $data[ $form_id ]['limit'] );
|
203 |
-
if ( $limit == '' ) $limit = 0;
|
204 |
-
$data[ $form_id ]['limit'] = $limit . '/' . $data[ $form_id ]['limit_by'];
|
205 |
-
unset( $data[ $form_id ]['limit_by'] );
|
206 |
-
}
|
207 |
-
|
208 |
-
}
|
209 |
-
|
210 |
-
return $data;
|
211 |
-
|
212 |
-
}
|
213 |
-
|
214 |
-
}
|
215 |
-
|
216 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-events-manager-light.php
DELETED
@@ -1,266 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.1
|
7 |
-
* @version 1.0.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_events_manager_light_hook', 55 );
|
10 |
-
function mycred_register_events_manager_light_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! function_exists( 'bp_em_init' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['eventsmanager'] = array(
|
15 |
-
'title' => __( 'Events Manager', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for users attending events.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/event-attendance/',
|
18 |
-
'callback' => array( 'myCRED_Hook_Events_Manager' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Events Manager Hook
|
27 |
-
* @since 1.1
|
28 |
-
* @version 1.3.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_events_manager_light_hook', 55 );
|
31 |
-
function mycred_load_events_manager_light_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_Hook_Events_Manager' ) || ! function_exists( 'bp_em_init' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_Hook_Events_Manager extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'eventsmanager',
|
45 |
-
'defaults' => array(
|
46 |
-
'attend' => array(
|
47 |
-
'creds' => 1,
|
48 |
-
'log' => '%plural% for attending an event',
|
49 |
-
'limit' => '0/x'
|
50 |
-
),
|
51 |
-
'cancel' => array(
|
52 |
-
'creds' => 1,
|
53 |
-
'log' => '%plural% for cancelled attendance an event'
|
54 |
-
)
|
55 |
-
)
|
56 |
-
), $hook_prefs, $type );
|
57 |
-
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Run
|
62 |
-
* @since 1.1
|
63 |
-
* @version 1.2
|
64 |
-
*/
|
65 |
-
public function run() {
|
66 |
-
|
67 |
-
if ( get_option( 'dbem_multiple_bookings' ) )
|
68 |
-
add_action( 'em_bookings_added', array( $this, 'multiple_bookings' ) );
|
69 |
-
|
70 |
-
else
|
71 |
-
add_filter( 'em_bookings_add', array( $this, 'new_booking' ), 10, 2 );
|
72 |
-
|
73 |
-
add_filter( 'em_booking_set_status', array( $this, 'adjust_booking' ), 10, 2 );
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* New Booking
|
79 |
-
* When users can make their own bookings.
|
80 |
-
* @since 1.1
|
81 |
-
* @version 1.3
|
82 |
-
*/
|
83 |
-
public function new_booking( $result, $booking ) {
|
84 |
-
|
85 |
-
// If bookings get automatically approved and booking was successfully added, add points
|
86 |
-
if ( get_option( 'dbem_bookings_approval' ) == 0 && $result === true ) {
|
87 |
-
|
88 |
-
// Check for exclusion
|
89 |
-
if ( $this->core->exclude_user( $booking->person_id ) ) return $result;
|
90 |
-
|
91 |
-
// Limit
|
92 |
-
if ( ! $this->over_hook_limit( 'attend', 'event_booking', $booking->person_id ) )
|
93 |
-
$this->core->add_creds(
|
94 |
-
'event_booking',
|
95 |
-
$booking->person_id,
|
96 |
-
$this->prefs['attend']['creds'],
|
97 |
-
$this->prefs['attend']['log'],
|
98 |
-
$booking->event->post_id,
|
99 |
-
array( 'ref_type' => 'post' ),
|
100 |
-
$this->mycred_type
|
101 |
-
);
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
return $result;
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* New Multiple Bookings
|
111 |
-
* @since 1.5.4
|
112 |
-
* @version 1.1
|
113 |
-
*/
|
114 |
-
public function multiple_bookings( $bookings ) {
|
115 |
-
|
116 |
-
foreach ( $bookings->get_bookings() as $EM_Booking ) {
|
117 |
-
|
118 |
-
// Check for exclusion
|
119 |
-
if ( $this->core->exclude_user( $EM_Booking->person_id ) ) continue;
|
120 |
-
|
121 |
-
// Limit
|
122 |
-
if ( ! $this->over_hook_limit( 'attend', 'event_booking', $EM_Booking->person_id ) )
|
123 |
-
$this->core->add_creds(
|
124 |
-
'event_booking',
|
125 |
-
$EM_Booking->person_id,
|
126 |
-
$this->prefs['attend']['creds'],
|
127 |
-
$this->prefs['attend']['log'],
|
128 |
-
$EM_Booking->event->post_id,
|
129 |
-
array( 'ref_type' => 'post' ),
|
130 |
-
$this->mycred_type
|
131 |
-
);
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Adjust Booking
|
139 |
-
* Incase an administrator needs to approve bookings first or if booking gets
|
140 |
-
* cancelled.
|
141 |
-
* @since 1.1
|
142 |
-
* @version 1.3
|
143 |
-
*/
|
144 |
-
public function adjust_booking( $result, $booking ) {
|
145 |
-
|
146 |
-
// Check for exclusion
|
147 |
-
if ( $this->core->exclude_user( $booking->person_id ) ) return $result;
|
148 |
-
|
149 |
-
// If the new status is 'approved', add points
|
150 |
-
if ( $booking->booking_status == 1 && $booking->previous_status != 1 ) {
|
151 |
-
|
152 |
-
// If we do not award points for attending an event bail now
|
153 |
-
if ( $this->prefs['attend']['creds'] == 0 ) return $result;
|
154 |
-
|
155 |
-
// Limit
|
156 |
-
if ( ! $this->over_hook_limit( 'attend', 'event_attendance', $booking->person_id ) )
|
157 |
-
$this->core->add_creds(
|
158 |
-
'event_attendance',
|
159 |
-
$booking->person_id,
|
160 |
-
$this->prefs['attend']['creds'],
|
161 |
-
$this->prefs['attend']['log'],
|
162 |
-
$booking->event->post_id,
|
163 |
-
array( 'ref_type' => 'post' ),
|
164 |
-
$this->mycred_type
|
165 |
-
);
|
166 |
-
}
|
167 |
-
|
168 |
-
// Else if status got changed from previously 'approved', remove points given
|
169 |
-
elseif ( $booking->booking_status != 1 && $booking->previous_status == 1 ) {
|
170 |
-
|
171 |
-
// If we do not deduct points for cancellation bail now
|
172 |
-
if ( $this->prefs['cancel']['creds'] == 0 ) return $result;
|
173 |
-
|
174 |
-
// Execute
|
175 |
-
$this->core->add_creds(
|
176 |
-
'cancelled_event_attendance',
|
177 |
-
$booking->person_id,
|
178 |
-
$this->prefs['cancel']['creds'],
|
179 |
-
$this->prefs['cancel']['log'],
|
180 |
-
$booking->event->post_id,
|
181 |
-
array( 'ref_type' => 'post' ),
|
182 |
-
$this->mycred_type
|
183 |
-
);
|
184 |
-
}
|
185 |
-
|
186 |
-
return $result;
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Preferences for Events Manager
|
192 |
-
* @since 1.1
|
193 |
-
* @version 1.1
|
194 |
-
*/
|
195 |
-
public function preferences() {
|
196 |
-
|
197 |
-
$prefs = $this->prefs;
|
198 |
-
|
199 |
-
?>
|
200 |
-
<div class="hook-instance">
|
201 |
-
<h3><?php _e( 'Attending Event', 'mycred' ); ?></h3>
|
202 |
-
<div class="row">
|
203 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
204 |
-
<div class="form-group">
|
205 |
-
<label for="<?php echo $this->field_id( array( 'attend' => 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
206 |
-
<input type="text" name="<?php echo $this->field_name( array( 'attend' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'attend' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['attend']['creds'] ); ?>" class="form-control" />
|
207 |
-
</div>
|
208 |
-
</div>
|
209 |
-
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
210 |
-
<div class="form-group">
|
211 |
-
<label for="<?php echo $this->field_id( array( 'attend' => 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
212 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'attend' => 'limit' ) ), $this->field_id( array( 'attend' => 'limit' ) ), $prefs['attend']['limit'] ); ?>
|
213 |
-
</div>
|
214 |
-
</div>
|
215 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
216 |
-
<div class="form-group">
|
217 |
-
<label for="<?php echo $this->field_id( array( 'attend' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
218 |
-
<input type="text" name="<?php echo $this->field_name( array( 'attend' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'attend' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['attend']['log'] ); ?>" class="form-control" />
|
219 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
220 |
-
</div>
|
221 |
-
</div>
|
222 |
-
</div>
|
223 |
-
</div>
|
224 |
-
<div class="hook-instance">
|
225 |
-
<h3><?php _e( 'Cancelling Attendance', 'mycred' ); ?></h3>
|
226 |
-
<div class="row">
|
227 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
228 |
-
<div class="form-group">
|
229 |
-
<label for="<?php echo $this->field_id( array( 'cancel' => 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
230 |
-
<input type="text" name="<?php echo $this->field_name( array( 'cancel' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'cancel' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['cancel']['creds'] ); ?>" class="form-control" />
|
231 |
-
</div>
|
232 |
-
</div>
|
233 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
234 |
-
<div class="form-group">
|
235 |
-
<label for="<?php echo $this->field_id( array( 'cancel' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
236 |
-
<input type="text" name="<?php echo $this->field_name( array( 'cancel' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'cancel' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['cancel']['log'] ); ?>" class="form-control" />
|
237 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
238 |
-
</div>
|
239 |
-
</div>
|
240 |
-
</div>
|
241 |
-
</div>
|
242 |
-
<?php
|
243 |
-
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* Sanitise Preferences
|
248 |
-
* @since 1.6
|
249 |
-
* @version 1.0
|
250 |
-
*/
|
251 |
-
public function sanitise_preferences( $data ) {
|
252 |
-
|
253 |
-
if ( isset( $data['attend']['limit'] ) && isset( $data['attend']['limit_by'] ) ) {
|
254 |
-
$limit = sanitize_text_field( $data['attend']['limit'] );
|
255 |
-
if ( $limit == '' ) $limit = 0;
|
256 |
-
$data['attend']['limit'] = $limit . '/' . $data['attend']['limit_by'];
|
257 |
-
unset( $data['attend']['limit_by'] );
|
258 |
-
}
|
259 |
-
|
260 |
-
return $data;
|
261 |
-
|
262 |
-
}
|
263 |
-
|
264 |
-
}
|
265 |
-
|
266 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-gd-star-rating.php
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* GD Star Rating
|
5 |
-
* @since 1.2
|
6 |
-
* @version 1.0
|
7 |
-
*/
|
8 |
-
if ( defined( 'myCRED_VERSION' ) ) {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Register Hook
|
12 |
-
* @since 1.2
|
13 |
-
* @version 1.0
|
14 |
-
*/
|
15 |
-
add_filter( 'mycred_setup_hooks', 'GD_Star_myCRED_Hook' );
|
16 |
-
function GD_Star_myCRED_Hook( $installed ) {
|
17 |
-
$installed['gdstars'] = array(
|
18 |
-
'title' => __( 'GD Star Rating', 'mycred' ),
|
19 |
-
'description' => __( 'Awards %_plural% for users rate items using the GD Star Rating plugin.', 'mycred' ),
|
20 |
-
'callback' => array( 'myCRED_Hook_GD_Star_Rating' )
|
21 |
-
);
|
22 |
-
return $installed;
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* GD Star Rating Hook
|
27 |
-
* @since 1.2
|
28 |
-
* @version 1.0
|
29 |
-
*/
|
30 |
-
if ( ! class_exists( 'myCRED_Hook_GD_Star_Rating' ) && class_exists( 'myCRED_Hook' ) ) {
|
31 |
-
class myCRED_Hook_GD_Star_Rating extends myCRED_Hook {
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Construct
|
35 |
-
*/
|
36 |
-
function __construct( $hook_prefs, $type = 'mycred_default' ) {
|
37 |
-
parent::__construct( array(
|
38 |
-
'id' => 'gdstars',
|
39 |
-
'defaults' => array(
|
40 |
-
'star_rating' => array(
|
41 |
-
'creds' => 1,
|
42 |
-
'log' => '%plural% for rating'
|
43 |
-
),
|
44 |
-
'up_down' => array(
|
45 |
-
'creds' => 1,
|
46 |
-
'log' => '%plural% for rating'
|
47 |
-
)
|
48 |
-
)
|
49 |
-
), $hook_prefs, $type );
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Run
|
54 |
-
* @since 1.2
|
55 |
-
* @version 1.0
|
56 |
-
*/
|
57 |
-
public function run() {
|
58 |
-
add_action( 'gdsr_vote', array( $this, 'vote' ), 10, 4 );
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Vote
|
63 |
-
* @since 1.2
|
64 |
-
* @version 1.0
|
65 |
-
*/
|
66 |
-
public function vote( $vote_value, $post_id, $vote_tpl, $vote_size ) {
|
67 |
-
if ( ! is_user_logged_in() ) return;
|
68 |
-
|
69 |
-
if ( is_string( $vote_value ) && $this->prefs['up_down']['creds'] == 0 ) return;
|
70 |
-
elseif ( ! is_string( $vote_value ) && $this->prefs['star_rating']['creds'] == 0 ) return;
|
71 |
-
|
72 |
-
if ( is_string( $vote_value ) ) {
|
73 |
-
$vote = 'up_down';
|
74 |
-
$star = false;
|
75 |
-
} else {
|
76 |
-
$vote = 'star_rating';
|
77 |
-
$star = true;
|
78 |
-
}
|
79 |
-
$user_id = get_current_user_id();
|
80 |
-
|
81 |
-
if ( $this->core->has_entry( 'rating', $post_id, $user_id, $vote ) ) return;
|
82 |
-
|
83 |
-
// Execute
|
84 |
-
$this->core->add_creds(
|
85 |
-
'rating',
|
86 |
-
$user_id,
|
87 |
-
( $star ) ? $this->prefs['star_rating']['creds'] : $this->prefs['up_down']['creds'],
|
88 |
-
( $star ) ? $this->prefs['star_rating']['log'] : $this->prefs['up_down']['log'],
|
89 |
-
$post_id,
|
90 |
-
$vote,
|
91 |
-
$this->mycred_type
|
92 |
-
);
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Preferences for GD Star Rating
|
97 |
-
* @since 1.2
|
98 |
-
* @version 1.0.1
|
99 |
-
*/
|
100 |
-
public function preferences() {
|
101 |
-
$prefs = $this->prefs; ?>
|
102 |
-
|
103 |
-
<label class="subheader" for="<?php echo $this->field_id( array( 'star_rating' => 'creds' ) ); ?>"><?php _e( 'Rating', 'mycred' ); ?></label>
|
104 |
-
<ol>
|
105 |
-
<li>
|
106 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'star_rating' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'star_rating' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['star_rating']['creds'] ); ?>" size="8" /></div>
|
107 |
-
</li>
|
108 |
-
</ol>
|
109 |
-
<label class="subheader" for="<?php echo $this->field_id( array( 'star_rating' => 'log' ) ); ?>"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
110 |
-
<ol>
|
111 |
-
<li>
|
112 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'star_rating' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'star_rating' => 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['star_rating']['log'] ); ?>" class="long" /></div>
|
113 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
114 |
-
</li>
|
115 |
-
</ol>
|
116 |
-
<label class="subheader" for="<?php echo $this->field_id( array( 'up_down' => 'creds' ) ); ?>"><?php _e( 'Up / Down Vote', 'mycred' ); ?></label>
|
117 |
-
<ol>
|
118 |
-
<li>
|
119 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'up_down' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'up_down' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['up_down']['creds'] ); ?>" size="8" /></div>
|
120 |
-
</li>
|
121 |
-
</ol>
|
122 |
-
<label class="subheader" for="<?php echo $this->field_id( array( 'up_down' => 'log' ) ); ?>"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
123 |
-
<ol>
|
124 |
-
<li>
|
125 |
-
<div class="h2"><input type="text" name="<?php echo $this->field_name( array( 'up_down' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'up_down' => 'log' ) ); ?>" value="<?php echo esc_attr( $prefs['up_down']['log'] ); ?>" class="long" /></div>
|
126 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
127 |
-
</li>
|
128 |
-
</ol>
|
129 |
-
<?php
|
130 |
-
}
|
131 |
-
}
|
132 |
-
}
|
133 |
-
}
|
134 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-gravityforms.php
DELETED
@@ -1,210 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.4
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_gravity_forms_hook', 65 );
|
10 |
-
function mycred_register_gravity_forms_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! class_exists( 'GFForms' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['gravityform'] = array(
|
15 |
-
'title' => __( 'Gravityform Submissions', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for successful form submissions.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/submitting-gravity-forms/',
|
18 |
-
'callback' => array( 'myCRED_Gravity_Forms' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Gravity Forms Hook
|
27 |
-
* @since 1.4
|
28 |
-
* @version 1.1.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_gravity_forms_hook', 65 );
|
31 |
-
function mycred_load_gravity_forms_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_Gravity_Forms' ) || ! class_exists( 'GFForms' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_Gravity_Forms extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'gravityform',
|
45 |
-
'defaults' => array()
|
46 |
-
), $hook_prefs, $type );
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Run
|
52 |
-
* @since 1.4
|
53 |
-
* @version 1.0
|
54 |
-
*/
|
55 |
-
public function run() {
|
56 |
-
|
57 |
-
add_action( 'gform_after_submission', array( $this, 'form_submission' ), 10, 2 );
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Successful Form Submission
|
63 |
-
* @since 1.4
|
64 |
-
* @version 1.1
|
65 |
-
*/
|
66 |
-
public function form_submission( $lead, $form ) {
|
67 |
-
|
68 |
-
// Login is required
|
69 |
-
if ( ! is_user_logged_in() || ! isset( $lead['form_id'] ) ) return;
|
70 |
-
|
71 |
-
// Prep
|
72 |
-
$user_id = absint( $lead['created_by'] );
|
73 |
-
$form_id = absint( $lead['form_id'] );
|
74 |
-
|
75 |
-
// Make sure form is setup and user is not excluded
|
76 |
-
if ( ! isset( $this->prefs[ $form_id ] ) || $this->core->exclude_user( $user_id ) ) return;
|
77 |
-
|
78 |
-
// Limit
|
79 |
-
if ( $this->over_hook_limit( $form_id, 'gravity_form_submission' ) ) return;
|
80 |
-
|
81 |
-
// Default values
|
82 |
-
$amount = $this->prefs[ $form_id ]['creds'];
|
83 |
-
$entry = $this->prefs[ $form_id ]['log'];
|
84 |
-
|
85 |
-
// See if the form contains myCRED fields that override these defaults
|
86 |
-
if ( isset( $form['fields'] ) && ! empty( $form['fields'] ) ) {
|
87 |
-
foreach ( $form['fields'] as $field ) {
|
88 |
-
|
89 |
-
// Amount override
|
90 |
-
if ( $field->label == 'mycred_amount' ) {
|
91 |
-
$amount = $this->core->number( $field->defaultValue );
|
92 |
-
}
|
93 |
-
|
94 |
-
// Entry override
|
95 |
-
if ( $field->label == 'mycred_entry' ) {
|
96 |
-
$entry = sanitize_text_field( $field->defaultValue );
|
97 |
-
}
|
98 |
-
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
// Amount can not be zero
|
103 |
-
if ( $amount == 0 ) return;
|
104 |
-
|
105 |
-
// Execute
|
106 |
-
$this->core->add_creds(
|
107 |
-
'gravity_form_submission',
|
108 |
-
$user_id,
|
109 |
-
$amount,
|
110 |
-
$entry,
|
111 |
-
$form_id,
|
112 |
-
'',
|
113 |
-
$this->mycred_type
|
114 |
-
);
|
115 |
-
|
116 |
-
}
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Preferences for Gravityforms Hook
|
120 |
-
* @since 1.4
|
121 |
-
* @version 1.1
|
122 |
-
*/
|
123 |
-
public function preferences() {
|
124 |
-
|
125 |
-
$prefs = $this->prefs;
|
126 |
-
$forms = RGFormsModel::get_forms();
|
127 |
-
|
128 |
-
// No forms found
|
129 |
-
if ( empty( $forms ) ) {
|
130 |
-
echo '<p>' . __( 'No forms found.', 'mycred' ) . '</p>';
|
131 |
-
return;
|
132 |
-
}
|
133 |
-
|
134 |
-
// Loop though prefs to make sure we always have a default setting
|
135 |
-
foreach ( $forms as $form ) {
|
136 |
-
if ( ! isset( $prefs[ $form->id ] ) ) {
|
137 |
-
$prefs[ $form->id ] = array(
|
138 |
-
'creds' => 1,
|
139 |
-
'log' => '',
|
140 |
-
'limit' => '0/x'
|
141 |
-
);
|
142 |
-
}
|
143 |
-
|
144 |
-
if ( ! isset( $prefs[ $form->id ]['limit'] ) )
|
145 |
-
$prefs[ $form->id ]['limit'] = '0/x';
|
146 |
-
}
|
147 |
-
|
148 |
-
// Set pref if empty
|
149 |
-
if ( empty( $prefs ) ) $this->prefs = $prefs;
|
150 |
-
|
151 |
-
// Loop for settings
|
152 |
-
foreach ( $forms as $form ) {
|
153 |
-
|
154 |
-
?>
|
155 |
-
<div class="hook-instance">
|
156 |
-
<h3><?php printf( __( 'Form: %s', 'mycred' ), $form->title ); ?></h3>
|
157 |
-
<div class="row">
|
158 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
159 |
-
<div class="form-group">
|
160 |
-
<label for="<?php echo $this->field_id( array( $form->id, 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
161 |
-
<input type="text" name="<?php echo $this->field_name( array( $form->id, 'creds' ) ); ?>" id="<?php echo $this->field_id( array( $form->id, 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs[ $form->id ]['creds'] ); ?>" class="form-control" />
|
162 |
-
</div>
|
163 |
-
</div>
|
164 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
165 |
-
<div class="form-group">
|
166 |
-
<label for="<?php echo $this->field_id( array( $form->id, 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
167 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( $form->id, 'limit' ) ), $this->field_id( array( $form->id, 'limit' ) ), $prefs[ $form->id ]['limit'] ); ?>
|
168 |
-
</div>
|
169 |
-
</div>
|
170 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
171 |
-
<div class="form-group">
|
172 |
-
<label for="<?php echo $this->field_id( array( $form->id, 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
173 |
-
<input type="text" name="<?php echo $this->field_name( array( $form->id, 'log' ) ); ?>" id="<?php echo $this->field_id( array( $form->id, 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs[ $form->id ]['log'] ); ?>" class="form-control" />
|
174 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
175 |
-
</div>
|
176 |
-
</div>
|
177 |
-
</div>
|
178 |
-
</div>
|
179 |
-
<?php
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Sanitise Preferences
|
187 |
-
* @since 1.6
|
188 |
-
* @version 1.0
|
189 |
-
*/
|
190 |
-
public function sanitise_preferences( $data ) {
|
191 |
-
|
192 |
-
$forms = RGFormsModel::get_forms();
|
193 |
-
foreach ( $forms as $form ) {
|
194 |
-
|
195 |
-
if ( isset( $data[ $form->id ]['limit'] ) && isset( $data[ $form->id ]['limit_by'] ) ) {
|
196 |
-
$limit = sanitize_text_field( $data[ $form->id ]['limit'] );
|
197 |
-
if ( $limit == '' ) $limit = 0;
|
198 |
-
$data[ $form->id ]['limit'] = $limit . '/' . $data[ $form->id ]['limit_by'];
|
199 |
-
unset( $data[ $form->id ]['limit_by'] );
|
200 |
-
}
|
201 |
-
|
202 |
-
}
|
203 |
-
|
204 |
-
return $data;
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
}
|
209 |
-
|
210 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-invite-anyone.php
DELETED
@@ -1,283 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 0.1
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_invite_anyone_hook', 70 );
|
10 |
-
function mycred_register_invite_anyone_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! function_exists( 'invite_anyone_init' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['invite_anyone'] = array(
|
15 |
-
'title' => __( 'Invite Anyone Plugin', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for sending invitations and/or %_plural% if the invite is accepted.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/inviting-users/',
|
18 |
-
'callback' => array( 'myCRED_Invite_Anyone' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Invite Anyone Hook
|
27 |
-
* @since 0.1
|
28 |
-
* @version 1.4.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_invite_anyone_hook', 70 );
|
31 |
-
function mycred_load_invite_anyone_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_Invite_Anyone' ) || ! function_exists( 'invite_anyone_init' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_Invite_Anyone extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'invite_anyone',
|
45 |
-
'defaults' => array(
|
46 |
-
'send_invite' => array(
|
47 |
-
'creds' => 1,
|
48 |
-
'log' => '%plural% for sending an invitation',
|
49 |
-
'limit' => '0/x'
|
50 |
-
),
|
51 |
-
'accept_invite' => array(
|
52 |
-
'creds' => 1,
|
53 |
-
'log' => '%plural% for accepted invitation',
|
54 |
-
'limit' => '0/x'
|
55 |
-
)
|
56 |
-
)
|
57 |
-
), $hook_prefs, $type );
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Run
|
63 |
-
* @since 0.1
|
64 |
-
* @version 1.1
|
65 |
-
*/
|
66 |
-
public function run() {
|
67 |
-
|
68 |
-
if ( $this->prefs['send_invite']['creds'] != 0 )
|
69 |
-
add_action( 'sent_email_invite', array( $this, 'send_invite' ), 10, 3 );
|
70 |
-
|
71 |
-
if ( $this->prefs['accept_invite']['creds'] != 0 ) {
|
72 |
-
|
73 |
-
// Hook into user activation
|
74 |
-
if ( function_exists( 'buddypress' ) && apply_filters( 'bp_core_signup_send_activation_key', true ) )
|
75 |
-
add_action( 'bp_core_activated_user', array( $this, 'verified_signup' ) );
|
76 |
-
|
77 |
-
add_action( 'accepted_email_invite', array( $this, 'accept_invite' ), 10, 2 );
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Sending Invites
|
85 |
-
* @since 0.1
|
86 |
-
* @version 1.2
|
87 |
-
*/
|
88 |
-
public function send_invite( $user_id, $email, $group ) {
|
89 |
-
|
90 |
-
// Check for exclusion
|
91 |
-
if ( $this->core->exclude_user( $user_id ) ) return;
|
92 |
-
|
93 |
-
// Limit
|
94 |
-
if ( $this->over_hook_limit( 'send_invite', 'sending_an_invite', $user_id ) ) return;
|
95 |
-
|
96 |
-
// Award Points
|
97 |
-
$this->core->add_creds(
|
98 |
-
'sending_an_invite',
|
99 |
-
$user_id,
|
100 |
-
$this->prefs['send_invite']['creds'],
|
101 |
-
$this->prefs['send_invite']['log'],
|
102 |
-
0,
|
103 |
-
'',
|
104 |
-
$this->mycred_type
|
105 |
-
);
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Verified Signup
|
111 |
-
* If signups needs to be verified, award points first when they are.
|
112 |
-
* @since 1.4.6
|
113 |
-
* @version 1.1
|
114 |
-
*/
|
115 |
-
public function verified_signup( $user_id ) {
|
116 |
-
|
117 |
-
// Get Pending List
|
118 |
-
$pending = get_transient( 'mycred-pending-bp-signups' );
|
119 |
-
if ( $pending === false || ! isset( $pending[ $user_id ] ) ) return;
|
120 |
-
|
121 |
-
// Check for exclusion
|
122 |
-
if ( ! $this->core->exclude_user( $pending[ $user_id ] ) && ! $this->over_hook_limit( 'accept_invite', 'accepting_an_invite', $pending[ $user_id ] ) )
|
123 |
-
$this->core->add_creds(
|
124 |
-
'accepting_an_invite',
|
125 |
-
$pending[ $user_id ],
|
126 |
-
$this->prefs['accept_invite']['creds'],
|
127 |
-
$this->prefs['accept_invite']['log'],
|
128 |
-
$user_id,
|
129 |
-
array( 'ref_type' => 'user' ),
|
130 |
-
$this->mycred_type
|
131 |
-
);
|
132 |
-
|
133 |
-
// Remove from list
|
134 |
-
unset( $pending[ $user_id ] );
|
135 |
-
|
136 |
-
// Update pending list
|
137 |
-
delete_transient( 'mycred-pending-bp-signups' );
|
138 |
-
set_transient( 'mycred-pending-bp-signups', $pending, 7 * DAY_IN_SECONDS );
|
139 |
-
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Accepting Invites
|
144 |
-
* @since 0.1
|
145 |
-
* @version 1.3.1
|
146 |
-
*/
|
147 |
-
public function accept_invite( $invited_user_id, $inviters = array() ) {
|
148 |
-
|
149 |
-
if ( empty( $inviters ) ) return;
|
150 |
-
|
151 |
-
// Invite Anyone will pass on an array of user IDs of those who have invited this user which we need to loop though
|
152 |
-
foreach ( (array) $inviters as $inviter_id ) {
|
153 |
-
|
154 |
-
// Check for exclusion
|
155 |
-
if ( $this->core->exclude_user( $inviter_id ) ) continue;
|
156 |
-
|
157 |
-
// Award Points
|
158 |
-
$run = true;
|
159 |
-
|
160 |
-
if ( function_exists( 'buddypress' ) && apply_filters( 'bp_core_signup_send_activation_key', true ) ) {
|
161 |
-
|
162 |
-
$run = false;
|
163 |
-
|
164 |
-
// Get pending list
|
165 |
-
$pending = get_transient( 'mycred-pending-bp-signups' );
|
166 |
-
if ( $pending === false )
|
167 |
-
$pending = array();
|
168 |
-
|
169 |
-
// Add to pending list if not there already
|
170 |
-
if ( ! isset( $pending[ $invited_user_id ] ) ) {
|
171 |
-
$pending[ $invited_user_id ] = $inviter_id;
|
172 |
-
|
173 |
-
delete_transient( 'mycred-pending-bp-signups' );
|
174 |
-
set_transient( 'mycred-pending-bp-signups', $pending, 7 * DAY_IN_SECONDS );
|
175 |
-
}
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
if ( $run && ! $this->over_hook_limit( 'accept_invite', 'accepting_an_invite', $inviter_id ) )
|
180 |
-
$this->core->add_creds(
|
181 |
-
'accepting_an_invite',
|
182 |
-
$inviter_id,
|
183 |
-
$this->prefs['accept_invite']['creds'],
|
184 |
-
$this->prefs['accept_invite']['log'],
|
185 |
-
$invited_user_id,
|
186 |
-
array( 'ref_type' => 'user' ),
|
187 |
-
$this->mycred_type
|
188 |
-
);
|
189 |
-
|
190 |
-
}
|
191 |
-
|
192 |
-
}
|
193 |
-
|
194 |
-
/**
|
195 |
-
* Preferences
|
196 |
-
* @since 0.1
|
197 |
-
* @version 1.2
|
198 |
-
*/
|
199 |
-
public function preferences() {
|
200 |
-
|
201 |
-
$prefs = $this->prefs;
|
202 |
-
|
203 |
-
?>
|
204 |
-
<div class="hook-instance">
|
205 |
-
<h3><?php _e( 'Sending Invites', 'mycred' ); ?></h3>
|
206 |
-
<div class="row">
|
207 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
208 |
-
<div class="form-group">
|
209 |
-
<label for="<?php echo $this->field_id( array( 'send_invite' => 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
210 |
-
<input type="text" name="<?php echo $this->field_name( array( 'send_invite' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'send_invite' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['send_invite']['creds'] ); ?>" class="form-control" />
|
211 |
-
</div>
|
212 |
-
</div>
|
213 |
-
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
214 |
-
<div class="form-group">
|
215 |
-
<label for="<?php echo $this->field_id( array( 'send_invite' => 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
216 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'send_invite' => 'limit' ) ), $this->field_id( array( 'send_invite' => 'limit' ) ), $prefs['send_invite']['limit'] ); ?>
|
217 |
-
</div>
|
218 |
-
</div>
|
219 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
220 |
-
<div class="form-group">
|
221 |
-
<label for="<?php echo $this->field_id( array( 'send_invite' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
222 |
-
<input type="text" name="<?php echo $this->field_name( array( 'send_invite' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'send_invite' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['send_invite']['log'] ); ?>" class="form-control" />
|
223 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
224 |
-
</div>
|
225 |
-
</div>
|
226 |
-
</div>
|
227 |
-
</div>
|
228 |
-
<div class="hook-instance">
|
229 |
-
<h3><?php _e( 'Accepted Invites', 'mycred' ); ?></h3>
|
230 |
-
<div class="row">
|
231 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
232 |
-
<div class="form-group">
|
233 |
-
<label for="<?php echo $this->field_id( array( 'accept_invite' => 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
234 |
-
<input type="text" name="<?php echo $this->field_name( array( 'accept_invite' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'accept_invite' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['accept_invite']['creds'] ); ?>" class="form-control" />
|
235 |
-
</div>
|
236 |
-
</div>
|
237 |
-
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
238 |
-
<div class="form-group">
|
239 |
-
<label for="<?php echo $this->field_id( array( 'accept_invite' => 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
240 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'accept_invite' => 'limit' ) ), $this->field_id( array( 'accept_invite' => 'limit' ) ), $prefs['accept_invite']['limit'] ); ?>
|
241 |
-
</div>
|
242 |
-
</div>
|
243 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
244 |
-
<div class="form-group">
|
245 |
-
<label for="<?php echo $this->field_id( array( 'accept_invite' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
246 |
-
<input type="text" name="<?php echo $this->field_name( array( 'accept_invite' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'accept_invite' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['accept_invite']['log'] ); ?>" class="form-control" />
|
247 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
248 |
-
</div>
|
249 |
-
</div>
|
250 |
-
</div>
|
251 |
-
</div>
|
252 |
-
<?php
|
253 |
-
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* Sanitise Preferences
|
258 |
-
* @since 1.6
|
259 |
-
* @version 1.0
|
260 |
-
*/
|
261 |
-
public function sanitise_preferences( $data ) {
|
262 |
-
|
263 |
-
if ( isset( $data['send_invite']['limit'] ) && isset( $data['send_invite']['limit_by'] ) ) {
|
264 |
-
$limit = sanitize_text_field( $data['send_invite']['limit'] );
|
265 |
-
if ( $limit == '' ) $limit = 0;
|
266 |
-
$data['send_invite']['limit'] = $limit . '/' . $data['send_invite']['limit_by'];
|
267 |
-
unset( $data['send_invite']['limit_by'] );
|
268 |
-
}
|
269 |
-
|
270 |
-
if ( isset( $data['accept_invite']['limit'] ) && isset( $data['accept_invite']['limit_by'] ) ) {
|
271 |
-
$limit = sanitize_text_field( $data['accept_invite']['limit'] );
|
272 |
-
if ( $limit == '' ) $limit = 0;
|
273 |
-
$data['accept_invite']['limit'] = $limit . '/' . $data['accept_invite']['limit_by'];
|
274 |
-
unset( $data['accept_invite']['limit_by'] );
|
275 |
-
}
|
276 |
-
|
277 |
-
return $data;
|
278 |
-
|
279 |
-
}
|
280 |
-
|
281 |
-
}
|
282 |
-
|
283 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-jetpack.php
DELETED
@@ -1,195 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.0.5
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_jetpack_hook', 75 );
|
10 |
-
function mycred_register_jetpack_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! defined( 'JETPACK__PLUGIN_DIR' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['jetpack'] = array(
|
15 |
-
'title' => __( 'Jetpack Subscriptions', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for users signing up for site or comment updates using Jetpack.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/jetpack-subscriptions/',
|
18 |
-
'callback' => array( 'myCRED_Hook_Jetpack' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Jetpack Hook
|
27 |
-
* @since 1.0.5
|
28 |
-
* @version 1.2
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_jetpack_hook', 75 );
|
31 |
-
function mycred_load_jetpack_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_Hook_Jetpack' ) || ! defined( 'JETPACK__PLUGIN_DIR' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_Hook_Jetpack extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'jetpack',
|
45 |
-
'defaults' => array(
|
46 |
-
'subscribe_site' => array(
|
47 |
-
'creds' => 1,
|
48 |
-
'log' => '%plural% for site subscription'
|
49 |
-
),
|
50 |
-
'subscribe_comment' => array(
|
51 |
-
'creds' => 1,
|
52 |
-
'log' => '%plural% for comment subscription'
|
53 |
-
)
|
54 |
-
)
|
55 |
-
), $hook_prefs, $type );
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Run
|
61 |
-
* @since 1.0.5
|
62 |
-
* @version 1.1
|
63 |
-
*/
|
64 |
-
public function run() {
|
65 |
-
|
66 |
-
// Site Subscriptions
|
67 |
-
if ( $this->prefs['subscribe_site']['creds'] != 0 )
|
68 |
-
add_filter( 'jetpack_subscriptions_form_submission', array( $this, 'subscriptions_submit' ) );
|
69 |
-
|
70 |
-
// Comment Subscriptions
|
71 |
-
if ( $this->prefs['subscribe_comment']['creds'] != 0 )
|
72 |
-
add_action( 'jetpack_subscriptions_comment_form_submission', array( $this, 'comment_submit' ), 99, 2 );
|
73 |
-
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Site Subscriptions
|
78 |
-
* @since 1.0.5
|
79 |
-
* @version 1.0
|
80 |
-
*/
|
81 |
-
public function subscriptions_submit( $result = '' ) {
|
82 |
-
|
83 |
-
if ( ! is_user_logged_in() || $result !== 'success' ) return;
|
84 |
-
|
85 |
-
$user_id = get_current_user_id();
|
86 |
-
|
87 |
-
// Check for exclusion
|
88 |
-
if ( $this->core->exclude_user( $user_id ) === true ) return;
|
89 |
-
|
90 |
-
// Ensure we only get points once
|
91 |
-
if ( $this->core->has_entry( 'site_subscription', 0, $user_id ) ) return;
|
92 |
-
|
93 |
-
$this->core->add_creds(
|
94 |
-
'site_subscription',
|
95 |
-
$user_id,
|
96 |
-
$this->prefs['subscribe_site']['creds'],
|
97 |
-
$this->prefs['subscribe_site']['log'],
|
98 |
-
0,
|
99 |
-
'',
|
100 |
-
$this->mycred_type
|
101 |
-
);
|
102 |
-
|
103 |
-
do_action( 'mycred_jetpack_site', $user_id );
|
104 |
-
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Comment Subscription
|
109 |
-
* @since 1.0.5
|
110 |
-
* @version 1.1
|
111 |
-
*/
|
112 |
-
public function comment_submit( $result, $post_ids ) {
|
113 |
-
|
114 |
-
if ( ! is_user_logged_in() || $result !== 'success' || empty( $post_ids ) ) return;
|
115 |
-
|
116 |
-
$user_id = get_current_user_id();
|
117 |
-
|
118 |
-
// Check for exclusion
|
119 |
-
if ( $this->core->exclude_user( $user_id ) === true ) return;
|
120 |
-
|
121 |
-
// Award each post
|
122 |
-
foreach ( $post_ids as $post_id ) {
|
123 |
-
|
124 |
-
// We can only get points once per post ID
|
125 |
-
if ( $this->core->has_entry( 'comment_subscription', $post_id, $user_id ) ) continue;
|
126 |
-
|
127 |
-
$this->core->add_creds(
|
128 |
-
'comment_subscription',
|
129 |
-
$user_id,
|
130 |
-
$this->prefs['subscribe_comment']['creds'],
|
131 |
-
$this->prefs['subscribe_comment']['log'],
|
132 |
-
$post_id,
|
133 |
-
array( 'ref_type' => 'post' ),
|
134 |
-
$this->mycred_type
|
135 |
-
);
|
136 |
-
|
137 |
-
do_action( 'mycred_jetpack_comment', $user_id, $post_id );
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Preferences
|
145 |
-
* @since 1.0.5
|
146 |
-
* @version 1.1
|
147 |
-
*/
|
148 |
-
public function preferences() {
|
149 |
-
|
150 |
-
$prefs = $this->prefs;
|
151 |
-
|
152 |
-
?>
|
153 |
-
<div class="hook-instance">
|
154 |
-
<h3><?php _e( 'Site Subscriptions', 'mycred' ); ?></h3>
|
155 |
-
<div class="row">
|
156 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
157 |
-
<div class="form-group">
|
158 |
-
<label for="<?php echo $this->field_id( array( 'subscribe_site' => 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
159 |
-
<input type="text" name="<?php echo $this->field_name( array( 'subscribe_site' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'subscribe_site' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['subscribe_site']['creds'] ); ?>" class="form-control" />
|
160 |
-
</div>
|
161 |
-
</div>
|
162 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
163 |
-
<div class="form-group">
|
164 |
-
<label for="<?php echo $this->field_id( array( 'subscribe_site' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
165 |
-
<input type="text" name="<?php echo $this->field_name( array( 'subscribe_site' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'subscribe_site' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['subscribe_site']['log'] ); ?>" class="form-control" />
|
166 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
167 |
-
</div>
|
168 |
-
</div>
|
169 |
-
</div>
|
170 |
-
</div>
|
171 |
-
<div class="hook-instance">
|
172 |
-
<h3><?php _e( 'Comment Subscriptions', 'mycred' ); ?></h3>
|
173 |
-
<div class="row">
|
174 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
175 |
-
<div class="form-group">
|
176 |
-
<label for="<?php echo $this->field_id( array( 'subscribe_comment' => 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
177 |
-
<input type="text" name="<?php echo $this->field_name( array( 'subscribe_comment' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'subscribe_comment' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['subscribe_comment']['creds'] ); ?>" class="form-control" />
|
178 |
-
</div>
|
179 |
-
</div>
|
180 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
181 |
-
<div class="form-group">
|
182 |
-
<label for="<?php echo $this->field_id( array( 'subscribe_comment' => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
183 |
-
<input type="text" name="<?php echo $this->field_name( array( 'subscribe_comment' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'subscribe_comment' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['subscribe_comment']['log'] ); ?>" class="form-control" />
|
184 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
185 |
-
</div>
|
186 |
-
</div>
|
187 |
-
</div>
|
188 |
-
</div>
|
189 |
-
<?php
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-sharethis.php
DELETED
@@ -1,364 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.5
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_sharethis_hook', 80 );
|
10 |
-
function mycred_register_sharethis_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! function_exists( 'install_ShareThis' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['sharethis'] = array(
|
15 |
-
'title' => __( '%plural% for Sharing', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for users sharing / liking your website content to popular social media sites.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/sharethis-actions/',
|
18 |
-
'callback' => array( 'myCRED_ShareThis' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* ShareThis Hook
|
27 |
-
* @since 1.5
|
28 |
-
* @version 1.0.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_sharethis_hook', 80 );
|
31 |
-
function mycred_load_sharethis_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_ShareThis' ) || ! function_exists( 'install_ShareThis' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_ShareThis extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'sharethis',
|
45 |
-
'defaults' => array()
|
46 |
-
), $hook_prefs, $type );
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Run
|
52 |
-
* @since 1.5
|
53 |
-
* @version 1.0
|
54 |
-
*/
|
55 |
-
public function run() {
|
56 |
-
|
57 |
-
add_filter( 'mycred_parse_log_entry', array( $this, 'parse_tags' ), 10, 2 );
|
58 |
-
add_action( 'wp_footer', array( $this, 'detect_shares' ), 80 );
|
59 |
-
add_action( 'wp_ajax_mycred-share-this-' . $this->mycred_type, array( $this, 'ajax' ) );
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Parse ShareThis Tags
|
65 |
-
* @since 1.5
|
66 |
-
* @version 1.0
|
67 |
-
*/
|
68 |
-
public function parse_tags( $content, $log ) {
|
69 |
-
|
70 |
-
// Only applicable to this hook
|
71 |
-
if ( $log->ref != 'share' ) return $content;
|
72 |
-
|
73 |
-
$data = maybe_unserialize( $log->data );
|
74 |
-
$names = mycred_get_share_service_names();
|
75 |
-
|
76 |
-
if ( isset( $names[ $data['service'] ] ) )
|
77 |
-
$service = $names[ $data['service'] ];
|
78 |
-
else
|
79 |
-
$service = ucfirst( $data['service'] );
|
80 |
-
|
81 |
-
$content = str_replace( '%service%', $service, $content );
|
82 |
-
|
83 |
-
return $content;
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Detect Shares
|
89 |
-
* @since 1.5
|
90 |
-
* @version 1.2
|
91 |
-
*/
|
92 |
-
public function detect_shares() {
|
93 |
-
|
94 |
-
if ( ! is_user_logged_in() ) return;
|
95 |
-
|
96 |
-
if ( is_singular() && apply_filters( 'mycred_load_share_this', true, $this ) ) {
|
97 |
-
|
98 |
-
// Get post / page ID from outside the loop
|
99 |
-
if ( ! in_the_loop() ) {
|
100 |
-
|
101 |
-
if ( is_ssl() )
|
102 |
-
$actual_link = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
103 |
-
else
|
104 |
-
$actual_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
105 |
-
|
106 |
-
$post_id = url_to_postid( $actual_link );
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
-
// Get post / page ID from inside the loop
|
111 |
-
else {
|
112 |
-
|
113 |
-
global $post;
|
114 |
-
|
115 |
-
$post_id = $post->ID;
|
116 |
-
|
117 |
-
}
|
118 |
-
|
119 |
-
$post_id = apply_filters( 'mycred_shared_post_id', $post_id, $this );
|
120 |
-
|
121 |
-
?>
|
122 |
-
<script type="text/javascript">
|
123 |
-
jQuery(function($) {
|
124 |
-
|
125 |
-
function mycred_detect_share_<?php echo sanitize_key( $this->mycred_type ); ?>( event,service ) {
|
126 |
-
|
127 |
-
console.log( 'Event: ' + event );
|
128 |
-
console.log( 'Service: ' + service );
|
129 |
-
|
130 |
-
$.ajax({
|
131 |
-
type : "POST",
|
132 |
-
data : {
|
133 |
-
action : 'mycred-share-this-<?php echo $this->mycred_type; ?>',
|
134 |
-
token : '<?php echo wp_create_nonce( 'mycred-share-this' . $this->mycred_type ); ?>',
|
135 |
-
post_id : <?php echo $post_id; ?>,
|
136 |
-
via : service
|
137 |
-
},
|
138 |
-
dataType : "JSON",
|
139 |
-
url : '<?php echo admin_url( 'admin-ajax.php' ); ?>',
|
140 |
-
success : function( response ) {
|
141 |
-
console.log( response );
|
142 |
-
}
|
143 |
-
});
|
144 |
-
|
145 |
-
};
|
146 |
-
|
147 |
-
stLight.options({ publisher : '<?php echo get_option( 'st_pubid' ); ?>' });
|
148 |
-
stLight.subscribe( 'click', mycred_detect_share_<?php echo sanitize_key( $this->mycred_type ); ?> );
|
149 |
-
|
150 |
-
});
|
151 |
-
</script>
|
152 |
-
<?php
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* Ajax Handler
|
160 |
-
* @since 1.5
|
161 |
-
* @version 1.0
|
162 |
-
*/
|
163 |
-
public function ajax() {
|
164 |
-
|
165 |
-
check_ajax_referer( 'mycred-share-this' . $this->mycred_type, 'token' );
|
166 |
-
|
167 |
-
if ( ! isset( $_POST['post_id'] ) || ! isset( $_POST['via'] ) ) wp_send_json( 'ERROR' );
|
168 |
-
|
169 |
-
$post_id = absint( $_POST['post_id'] );
|
170 |
-
$service = sanitize_key( $_POST['via'] );
|
171 |
-
if ( $service == 'sharethis' ) wp_send_json( '' );
|
172 |
-
|
173 |
-
// Make sure this instance is enabled
|
174 |
-
if ( ! isset( $this->prefs[ $service ] ) || $this->prefs[ $service ]['creds'] == 0 ) wp_send_json( '' );
|
175 |
-
|
176 |
-
$user_id = get_current_user_id();
|
177 |
-
|
178 |
-
// Check for exclusion
|
179 |
-
if ( $this->core->exclude_user( $user_id ) ) wp_send_json( '' );
|
180 |
-
|
181 |
-
// Make sure this share is unique
|
182 |
-
$data = array( 'ref_type' => 'post', 'service' => $service );
|
183 |
-
if ( $this->core->has_entry( 'share', $post_id, $user_id, $data, $this->mycred_type ) ) wp_send_json( 'HAS ENTRY' );
|
184 |
-
|
185 |
-
// Limit
|
186 |
-
if ( $this->over_hook_limit( $service, 'share' ) ) wp_send_json( 'LIMIT' );
|
187 |
-
|
188 |
-
// Execute
|
189 |
-
$this->core->add_creds(
|
190 |
-
'share',
|
191 |
-
$user_id,
|
192 |
-
$this->prefs[ $service ]['creds'],
|
193 |
-
$this->prefs[ $service ]['log'],
|
194 |
-
$post_id,
|
195 |
-
$data,
|
196 |
-
$this->mycred_type
|
197 |
-
);
|
198 |
-
|
199 |
-
wp_send_json( 'DONE' );
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Preferences for ShareThis Hook
|
205 |
-
* @since 0.1
|
206 |
-
* @version 1.1
|
207 |
-
*/
|
208 |
-
public function preferences() {
|
209 |
-
|
210 |
-
$st_public_key = get_option( 'st_pubid', false );
|
211 |
-
$st_services = get_option( 'st_services', false );
|
212 |
-
|
213 |
-
// Public key is not yet setup
|
214 |
-
if ( $st_public_key === false ) :
|
215 |
-
|
216 |
-
echo '<p>' . __( 'Your ShareThis public key is not set.', 'mycred' ) . '</p>';
|
217 |
-
|
218 |
-
// Services is not yet setup
|
219 |
-
elseif ( $st_services === false ) :
|
220 |
-
|
221 |
-
echo '<p>' . __( 'No ShareThis services detected. Please check your installation.', 'mycred' ) . '</p>';
|
222 |
-
|
223 |
-
// All is well!
|
224 |
-
else :
|
225 |
-
|
226 |
-
$names = mycred_get_share_service_names();
|
227 |
-
|
228 |
-
// Loop though selected services
|
229 |
-
$services = explode( ',', $st_services );
|
230 |
-
|
231 |
-
// Add facebook unlike to facebook like.
|
232 |
-
if ( in_array( 'fblike', $services ) )
|
233 |
-
$services[] = 'fbunlike';
|
234 |
-
|
235 |
-
foreach ( $services as $service ) {
|
236 |
-
|
237 |
-
$service = str_replace( ' ', '', $service );
|
238 |
-
if ( $service == '' || $service == 'sharethis' ) continue;
|
239 |
-
|
240 |
-
if ( ! isset( $this->prefs[ $service ] ) )
|
241 |
-
$this->prefs[ $service ] = array(
|
242 |
-
'creds' => 0,
|
243 |
-
'log' => '%plural% for sharing %link_with_title% on %service%',
|
244 |
-
'limit' => '0/x'
|
245 |
-
);
|
246 |
-
|
247 |
-
if ( ! isset( $this->prefs[ $service ]['limit'] ) )
|
248 |
-
$this->prefs[ $service ]['limit'] = '0/x';
|
249 |
-
|
250 |
-
if ( isset( $names[ $service ] ) )
|
251 |
-
$service_name = $names[ $service ];
|
252 |
-
else
|
253 |
-
$service_name = ucfirst( $service );
|
254 |
-
|
255 |
-
?>
|
256 |
-
<div class="hook-instance">
|
257 |
-
<h3><?php _e( 'Publishing Posts', 'mycred' ); ?></h3>
|
258 |
-
<div class="row">
|
259 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
260 |
-
<div class="form-group">
|
261 |
-
<label for="<?php echo $this->field_id( array( $service => 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
262 |
-
<input type="text" name="<?php echo $this->field_name( array( $service => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( $service => 'creds' ) ); ?>" value="<?php echo $this->core->number( $this->prefs[ $service ]['creds'] ); ?>" class="form-control" />
|
263 |
-
</div>
|
264 |
-
</div>
|
265 |
-
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
266 |
-
<div class="form-group">
|
267 |
-
<label for="<?php echo $this->field_id( array( $service => 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
268 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( $service => 'limit' ) ), $this->field_id( array( $service => 'limit' ) ), $this->prefs[ $service ]['limit'] ); ?>
|
269 |
-
</div>
|
270 |
-
</div>
|
271 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
272 |
-
<div class="form-group">
|
273 |
-
<label for="<?php echo $this->field_id( array( $service => 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
274 |
-
<input type="text" name="<?php echo $this->field_name( array( $service => 'log' ) ); ?>" id="<?php echo $this->field_id( array( $service => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $this->prefs[ $service ]['log'] ); ?>" class="form-control" />
|
275 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ), '%service%' ); ?></span>
|
276 |
-
</div>
|
277 |
-
</div>
|
278 |
-
</div>
|
279 |
-
</div>
|
280 |
-
<?php
|
281 |
-
}
|
282 |
-
|
283 |
-
endif;
|
284 |
-
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Sanitise Preferences
|
289 |
-
* @since 1.6
|
290 |
-
* @version 1.0.1
|
291 |
-
*/
|
292 |
-
public function sanitise_preferences( $data ) {
|
293 |
-
|
294 |
-
$st_services = get_option( 'st_services', false );
|
295 |
-
|
296 |
-
// Loop though selected services
|
297 |
-
$services = explode( ',', $st_services );
|
298 |
-
|
299 |
-
// Add facebook unlike to facebook like.
|
300 |
-
if ( in_array( 'fblike', $services ) )
|
301 |
-
$services[] = 'fbunlike';
|
302 |
-
|
303 |
-
foreach ( $services as $service ) {
|
304 |
-
|
305 |
-
$service = str_replace( ' ', '', $service );
|
306 |
-
|
307 |
-
if ( isset( $data[ $service ]['limit'] ) && isset( $data[ $service ]['limit_by'] ) ) {
|
308 |
-
$limit = sanitize_text_field( $data[ $service ]['limit'] );
|
309 |
-
if ( $limit == '' ) $limit = 0;
|
310 |
-
$data[ $service ]['limit'] = $limit . '/' . $data[ $service ]['limit_by'];
|
311 |
-
unset( $data[ $service ]['limit_by'] );
|
312 |
-
}
|
313 |
-
|
314 |
-
}
|
315 |
-
|
316 |
-
return $data;
|
317 |
-
|
318 |
-
}
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
}
|
323 |
-
|
324 |
-
/**
|
325 |
-
* ShareThis Service Names
|
326 |
-
* @since 1.7.4
|
327 |
-
* @version 1.0
|
328 |
-
*/
|
329 |
-
if ( ! function_exists( 'mycred_get_share_service_names' ) ) :
|
330 |
-
function mycred_get_share_service_names() {
|
331 |
-
|
332 |
-
return apply_filters( 'mycred_get_sharethis_service_name', array(
|
333 |
-
'facebook' => 'Facebook',
|
334 |
-
'fblike' => 'Facebook Like',
|
335 |
-
'fbunlike' => 'Facebook Unlike',
|
336 |
-
'fbsub' => 'Facebook Subscribe',
|
337 |
-
'fbsend' => 'Facebook Send',
|
338 |
-
'fbrec' => 'Facebook Recommend',
|
339 |
-
'wordpress' => 'WordPress',
|
340 |
-
'google_bmarks' => 'Google Bookmarks',
|
341 |
-
'youtube' => 'YouTube',
|
342 |
-
'twitterfollow' => 'Twitter Follow',
|
343 |
-
'pinterestfollow' => 'Pinterest Follow',
|
344 |
-
'plusone' => 'Google +1',
|
345 |
-
'instagram' => 'Instagram Badge',
|
346 |
-
'foursquarefollow' => 'Foursquare Follow',
|
347 |
-
'foursquaresave' => 'Foursquare Save',
|
348 |
-
'blogger' => 'Blogger',
|
349 |
-
'twitter' => 'Tweet',
|
350 |
-
'linkedin' => 'LinkedIn',
|
351 |
-
'pinterest' => 'Pinterest',
|
352 |
-
'email' => 'Email',
|
353 |
-
'googleplus' => 'Google+',
|
354 |
-
'amazon_wishlist' => 'Amazon Wishlist',
|
355 |
-
'bebo' => 'Bebo',
|
356 |
-
'delicious' => 'Delicious',
|
357 |
-
'myspace' => 'MySpace',
|
358 |
-
'reddit' => 'Reddit',
|
359 |
-
'slashdot' => 'Slashdot',
|
360 |
-
'tumblr' => 'Tumblr'
|
361 |
-
) );
|
362 |
-
|
363 |
-
}
|
364 |
-
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-simplepress.php
DELETED
@@ -1,416 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.3.3
|
7 |
-
* @version 1.2
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_simplepress_hook', 85 );
|
10 |
-
function mycred_register_simplepress_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! defined( 'SFTOPICS' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['hook_simplepress'] = array(
|
15 |
-
'title' => 'Simple:Press',
|
16 |
-
'description' => __( 'Awards %_plural% for Simple:Press actions.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/simplepress-actions/',
|
18 |
-
'callback' => array( 'myCRED_SimplePress' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Simple:Press Hook
|
27 |
-
* @since 1.3.3
|
28 |
-
* @version 1.2.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_simplepress_hook', 85 );
|
31 |
-
function mycred_load_simplepress_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_SimplePress' ) || ! defined( 'SFTOPICS' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_SimplePress extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'hook_simplepress',
|
45 |
-
'defaults' => array(
|
46 |
-
'new_topic' => array(
|
47 |
-
'creds' => 1,
|
48 |
-
'log' => '%plural% for new forum topic',
|
49 |
-
'limit' => '0/x'
|
50 |
-
),
|
51 |
-
'delete_topic' => array(
|
52 |
-
'creds' => 0-1,
|
53 |
-
'log' => '%singular% deduction for deleted topic'
|
54 |
-
),
|
55 |
-
'new_post' => array(
|
56 |
-
'creds' => 1,
|
57 |
-
'log' => '%plural% for new topic post',
|
58 |
-
'author' => 0,
|
59 |
-
'limit' => '0/x'
|
60 |
-
),
|
61 |
-
'delete_post' => array(
|
62 |
-
'creds' => 0-1,
|
63 |
-
'log' => '%singular% deduction for deleted topic reply'
|
64 |
-
)
|
65 |
-
)
|
66 |
-
), $hook_prefs, $type );
|
67 |
-
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Run
|
72 |
-
* @since 1.3.3
|
73 |
-
* @version 1.0
|
74 |
-
*/
|
75 |
-
public function run() {
|
76 |
-
|
77 |
-
// New Topic
|
78 |
-
if ( $this->prefs['new_topic']['creds'] != 0 )
|
79 |
-
add_action( 'sph_post_create', array( $this, 'new_topic' ) );
|
80 |
-
|
81 |
-
// Delete Topic
|
82 |
-
if ( $this->prefs['delete_topic']['creds'] != 0 )
|
83 |
-
add_action( 'sph_topic_delete', array( $this, 'delete_topic' ) );
|
84 |
-
|
85 |
-
// New Reply
|
86 |
-
if ( $this->prefs['new_post']['creds'] != 0 )
|
87 |
-
add_action( 'sph_post_create', array( $this, 'new_post' ) );
|
88 |
-
|
89 |
-
// Delete Reply
|
90 |
-
if ( $this->prefs['delete_post']['creds'] != 0 )
|
91 |
-
add_action( 'sph_post_delete', array( $this, 'delete_post' ) );
|
92 |
-
|
93 |
-
add_filter( 'mycred_parse_log_entry', array( $this, 'adjust_log_templates' ), 10, 2 );
|
94 |
-
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Custom Template Tags
|
99 |
-
* @since 1.3.3
|
100 |
-
* @version 1.1
|
101 |
-
*/
|
102 |
-
public function adjust_log_templates( $content, $log_entry ) {
|
103 |
-
|
104 |
-
if ( ! isset( $log_entry->ref ) || $log_entry->data != 'simplepress' ) return $content;
|
105 |
-
|
106 |
-
switch ( $log_entry->ref ) {
|
107 |
-
case 'new_forum_topic' :
|
108 |
-
|
109 |
-
global $wpdb;
|
110 |
-
|
111 |
-
$db = SFTOPICS;
|
112 |
-
$topic = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$db} WHERE user_id = %d AND topic_id = %d;", $log_entry->user_id, $log_entry->ref_id ) );
|
113 |
-
$topic_name = '';
|
114 |
-
|
115 |
-
if ( isset( $topic->topic_name ) )
|
116 |
-
$topic_name = $topic->topic_name;
|
117 |
-
|
118 |
-
$content = str_replace( '%topic_name%', $topic_name, $content );
|
119 |
-
|
120 |
-
break;
|
121 |
-
}
|
122 |
-
|
123 |
-
return $content;
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* New Topic
|
129 |
-
* @since 1.3.3
|
130 |
-
* @version 1.2
|
131 |
-
*/
|
132 |
-
public function new_topic( $post ) {
|
133 |
-
|
134 |
-
if ( $post['action'] != 'topic' ) return;
|
135 |
-
|
136 |
-
// Topic details
|
137 |
-
$topic_author = $post['userid'];
|
138 |
-
|
139 |
-
$forum_id = $post['forumid'];
|
140 |
-
$topic_id = $post['topicid'];
|
141 |
-
|
142 |
-
// Check if user is excluded
|
143 |
-
if ( $this->core->exclude_user( $topic_author ) ) return;
|
144 |
-
|
145 |
-
// Limit
|
146 |
-
if ( $this->over_hook_limit( 'new_topic', 'new_forum_topic', $topic_author ) ) return;
|
147 |
-
|
148 |
-
// Make sure this is unique event
|
149 |
-
if ( $this->has_entry( 'new_forum_topic', $topic_id, $topic_author ) ) return;
|
150 |
-
|
151 |
-
// Execute
|
152 |
-
$this->core->add_creds(
|
153 |
-
'new_forum_topic',
|
154 |
-
$topic_author,
|
155 |
-
$this->prefs['new_topic']['creds'],
|
156 |
-
$this->prefs['new_topic']['log'],
|
157 |
-
$topic_id,
|
158 |
-
'simplepress',
|
159 |
-
$this->mycred_type
|
160 |
-
);
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Delete Topic
|
166 |
-
* @since 1.3.3
|
167 |
-
* @version 1.1
|
168 |
-
*/
|
169 |
-
public function delete_topic( $topic ) {
|
170 |
-
|
171 |
-
if ( $topic->user_id == 0 ) return;
|
172 |
-
|
173 |
-
// Topic details
|
174 |
-
$topic_author = $topic->user_id;
|
175 |
-
$topic_id = $topic->topic_id;
|
176 |
-
|
177 |
-
// If gained, points, deduct
|
178 |
-
if ( $this->has_entry( 'new_forum_topic', $topic_id, $topic_author ) ) {
|
179 |
-
|
180 |
-
// Execute
|
181 |
-
$this->core->add_creds(
|
182 |
-
'deleted_topic',
|
183 |
-
$topic_author,
|
184 |
-
$this->prefs['delete_topic']['creds'],
|
185 |
-
$this->prefs['delete_topic']['log'],
|
186 |
-
$topic_id,
|
187 |
-
'simplepress',
|
188 |
-
$this->mycred_type
|
189 |
-
);
|
190 |
-
|
191 |
-
}
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* New Post
|
197 |
-
* @since 1.3.3
|
198 |
-
* @version 1.2
|
199 |
-
*/
|
200 |
-
public function new_post( $post ) {
|
201 |
-
|
202 |
-
if ( $post['action'] != 'post' ) return;
|
203 |
-
|
204 |
-
// Post details
|
205 |
-
$post_author = $post['userid'];
|
206 |
-
$post_id = $post['postid'];
|
207 |
-
$topic_id = $post['topicid'];
|
208 |
-
|
209 |
-
// Check if user is excluded
|
210 |
-
if ( $this->core->exclude_user( $post_author ) ) return;
|
211 |
-
|
212 |
-
// Check if topic author gets points for their own replies
|
213 |
-
if ( (bool) $this->prefs['new_post']['author'] === false && $this->get_topic_author( $topic_id ) == $post_author ) return;
|
214 |
-
|
215 |
-
// Limit
|
216 |
-
if ( $this->over_hook_limit( 'new_post', 'new_topic_post', $post_author ) ) return;
|
217 |
-
|
218 |
-
// Make sure this is unique event
|
219 |
-
if ( $this->has_entry( 'new_topic_post', $post_id, $post_author ) ) return;
|
220 |
-
|
221 |
-
// Execute
|
222 |
-
$this->core->add_creds(
|
223 |
-
'new_topic_post',
|
224 |
-
$post_author,
|
225 |
-
$this->prefs['new_post']['creds'],
|
226 |
-
$this->prefs['new_post']['log'],
|
227 |
-
$post_id,
|
228 |
-
'simplepress',
|
229 |
-
$this->mycred_type
|
230 |
-
);
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* Delete Post
|
236 |
-
* @since 1.3.3
|
237 |
-
* @version 1.0
|
238 |
-
*/
|
239 |
-
public function delete_post( $target ) {
|
240 |
-
|
241 |
-
if ( $target->user_id == 0 ) return;
|
242 |
-
|
243 |
-
// Post details
|
244 |
-
$post_author = $target->user_id;
|
245 |
-
$post_id = $target->post_id;
|
246 |
-
|
247 |
-
// If gained, points, deduct
|
248 |
-
if ( $this->has_entry( 'new_topic_post', $post_id, $post_author ) ) {
|
249 |
-
|
250 |
-
// Execute
|
251 |
-
$this->core->add_creds(
|
252 |
-
'deleted_topic_post',
|
253 |
-
$post_author,
|
254 |
-
$this->prefs['delete_post']['creds'],
|
255 |
-
$this->prefs['delete_post']['log'],
|
256 |
-
$post_id,
|
257 |
-
'simplepress',
|
258 |
-
$this->mycred_type
|
259 |
-
);
|
260 |
-
|
261 |
-
}
|
262 |
-
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Get SimplePress Topic Author ID
|
267 |
-
* @since 1.3.3
|
268 |
-
* @version 1.0
|
269 |
-
*/
|
270 |
-
public function get_topic_author( $topic_id = '' ) {
|
271 |
-
|
272 |
-
global $wpdb;
|
273 |
-
|
274 |
-
$db = SFTOPICS;
|
275 |
-
|
276 |
-
return $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM {$db} WHERE topic_id = %d;", $topic_id ) );
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Preferences
|
282 |
-
* @since 1.3.3
|
283 |
-
* @version 1.1
|
284 |
-
*/
|
285 |
-
public function preferences() {
|
286 |
-
|
287 |
-
$prefs = $this->prefs;
|
288 |
-
|
289 |
-
?>
|
290 |
-
<div class="hook-instance">
|
291 |
-
<h3><?php _e( 'New Topic', 'mycred' ); ?></h3>
|
292 |
-
<div class="row">
|
293 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
294 |
-
<div class="form-group">
|
295 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
296 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_topic', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_topic', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_topic']['creds'] ); ?>" class="form-control" />
|
297 |
-
</div>
|
298 |
-
</div>
|
299 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
300 |
-
<div class="form-group">
|
301 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
302 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_topic', 'limit' ) ), $this->field_id( array( 'new_topic', 'limit' ) ), $prefs['new_topic']['limit'] ); ?>
|
303 |
-
</div>
|
304 |
-
</div>
|
305 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
306 |
-
<div class="form-group">
|
307 |
-
<label for="<?php echo $this->field_id( array( 'new_topic', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
308 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_topic', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_topic', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_topic']['log'] ); ?>" class="form-control" />
|
309 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ), '%topic_name%' ); ?></span>
|
310 |
-
</div>
|
311 |
-
</div>
|
312 |
-
</div>
|
313 |
-
</div>
|
314 |
-
<div class="hook-instance">
|
315 |
-
<h3><?php _e( 'Deleted Topic', 'mycred' ); ?></h3>
|
316 |
-
<div class="row">
|
317 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
318 |
-
<div class="form-group">
|
319 |
-
<label for="<?php echo $this->field_id( array( 'delete_topic', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
320 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_topic', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_topic', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['delete_topic']['creds'] ); ?>" class="form-control" />
|
321 |
-
</div>
|
322 |
-
</div>
|
323 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
324 |
-
<div class="form-group">
|
325 |
-
<label for="<?php echo $this->field_id( array( 'delete_topic', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
326 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_topic', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_topic', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_topic']['log'] ); ?>" class="form-control" />
|
327 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
328 |
-
</div>
|
329 |
-
</div>
|
330 |
-
</div>
|
331 |
-
</div>
|
332 |
-
<div class="hook-instance">
|
333 |
-
<h3><?php _e( 'New Topic Post', 'mycred' ); ?></h3>
|
334 |
-
<div class="row">
|
335 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
336 |
-
<div class="form-group">
|
337 |
-
<label for="<?php echo $this->field_id( array( 'new_post', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
338 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_post', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'new_post', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['new_post']['creds'] ); ?>" class="form-control" />
|
339 |
-
</div>
|
340 |
-
</div>
|
341 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
342 |
-
<div class="form-group">
|
343 |
-
<label for="<?php echo $this->field_id( array( 'new_post', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
344 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'new_post', 'limit' ) ), $this->field_id( array( 'new_post', 'limit' ) ), $prefs['new_post']['limit'] ); ?>
|
345 |
-
</div>
|
346 |
-
</div>
|
347 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
348 |
-
<div class="form-group">
|
349 |
-
<label for="<?php echo $this->field_id( array( 'new_post', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
350 |
-
<input type="text" name="<?php echo $this->field_name( array( 'new_post', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'new_post', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['new_post']['log'] ); ?>" class="form-control" />
|
351 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
352 |
-
</div>
|
353 |
-
</div>
|
354 |
-
</div>
|
355 |
-
<div class="row">
|
356 |
-
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
357 |
-
<div class="form-group">
|
358 |
-
<div class="radio">
|
359 |
-
<label for="<?php echo $this->field_id( array( 'new_post' => 'author' ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'new_post' => 'author' ) ); ?>" id="<?php echo $this->field_id( array( 'new_post' => 'author' ) ); ?>" <?php checked( $prefs['new_post']['author'], 1 ); ?> value="1" /> <?php echo $this->core->template_tags_general( __( 'Topic authors can receive %_plural% for posting on their own Topic.', 'mycred' ) ); ?></label>
|
360 |
-
</div>
|
361 |
-
</div>
|
362 |
-
</div>
|
363 |
-
</div>
|
364 |
-
</div>
|
365 |
-
<div class="hook-instance">
|
366 |
-
<h3><?php _e( 'Deleted Topic Post', 'mycred' ); ?></h3>
|
367 |
-
<div class="row">
|
368 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
369 |
-
<div class="form-group">
|
370 |
-
<label for="<?php echo $this->field_id( array( 'delete_post', 'creds' ) ); ?>"><?php echo $this->core->plural(); ?></label>
|
371 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_post', 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_post', 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['delete_post']['creds'] ); ?>" class="form-control" />
|
372 |
-
</div>
|
373 |
-
</div>
|
374 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
375 |
-
<div class="form-group">
|
376 |
-
<label for="<?php echo $this->field_id( array( 'delete_post', 'log' ) ); ?>"><?php _e( 'Log template', 'mycred' ); ?></label>
|
377 |
-
<input type="text" name="<?php echo $this->field_name( array( 'delete_post', 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'delete_post', 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['delete_post']['log'] ); ?>" class="form-control" />
|
378 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
379 |
-
</div>
|
380 |
-
</div>
|
381 |
-
</div>
|
382 |
-
</div>
|
383 |
-
<?php
|
384 |
-
|
385 |
-
}
|
386 |
-
|
387 |
-
/**
|
388 |
-
* Sanitise Preference
|
389 |
-
* @since 1.3.3
|
390 |
-
* @version 1.1
|
391 |
-
*/
|
392 |
-
public function sanitise_preferences( $data ) {
|
393 |
-
|
394 |
-
if ( isset( $data['new_topic']['limit'] ) && isset( $data['new_topic']['limit_by'] ) ) {
|
395 |
-
$limit = sanitize_text_field( $data['new_topic']['limit'] );
|
396 |
-
if ( $limit == '' ) $limit = 0;
|
397 |
-
$data['new_topic']['limit'] = $limit . '/' . $data['new_topic']['limit_by'];
|
398 |
-
unset( $data['new_topic']['limit_by'] );
|
399 |
-
}
|
400 |
-
|
401 |
-
if ( isset( $data['new_post']['limit'] ) && isset( $data['new_post']['limit_by'] ) ) {
|
402 |
-
$limit = sanitize_text_field( $data['new_post']['limit'] );
|
403 |
-
if ( $limit == '' ) $limit = 0;
|
404 |
-
$data['new_post']['limit'] = $limit . '/' . $data['new_post']['limit_by'];
|
405 |
-
unset( $data['new_post']['limit_by'] );
|
406 |
-
}
|
407 |
-
|
408 |
-
$data['new_post']['author'] = ( isset( $data['new_post']['author'] ) ) ? 1 : 0;
|
409 |
-
|
410 |
-
return $data;
|
411 |
-
|
412 |
-
}
|
413 |
-
|
414 |
-
}
|
415 |
-
|
416 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-woocommerce.php
DELETED
@@ -1,569 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* WooCommerce Setup
|
6 |
-
* @since 1.5
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
if ( ! function_exists( 'mycred_load_woocommerce_reward' ) ) :
|
10 |
-
function mycred_load_woocommerce_reward() {
|
11 |
-
|
12 |
-
if ( ! class_exists( 'WooCommerce' ) ) return;
|
13 |
-
|
14 |
-
add_filter( 'mycred_comment_gets_cred', 'mycred_woo_remove_review_from_comments', 10, 2 );
|
15 |
-
add_action( 'add_meta_boxes_product', 'mycred_woo_add_product_metabox' );
|
16 |
-
add_action( 'save_post_product', 'mycred_woo_save_reward_settings' );
|
17 |
-
add_action( 'woocommerce_payment_complete', 'mycred_woo_payout_rewards' );
|
18 |
-
add_action( 'woocommerce_order_status_completed', 'mycred_woo_payout_rewards' );
|
19 |
-
add_action( 'woocommerce_product_after_variable_attributes', 'mycred_woo_add_product_variation_detail', 10, 3 );
|
20 |
-
add_action( 'woocommerce_save_product_variation', 'mycred_woo_save_product_variation_detail' );
|
21 |
-
add_filter( 'mycred_run_this', 'mycred_woo_refund_points' );
|
22 |
-
|
23 |
-
}
|
24 |
-
endif;
|
25 |
-
add_action( 'mycred_load_hooks', 'mycred_load_woocommerce_reward', 90 );
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Remove Reviews from Comment Hook
|
29 |
-
* Prevents the comment hook from granting points twice for a review.
|
30 |
-
* @since 1.6.3
|
31 |
-
* @version 1.0
|
32 |
-
*/
|
33 |
-
if ( ! function_exists( 'mycred_woo_remove_review_from_comments' ) ) :
|
34 |
-
function mycred_woo_remove_review_from_comments( $reply, $comment ) {
|
35 |
-
|
36 |
-
if ( get_post_type( $comment->comment_post_ID ) == 'product' ) return false;
|
37 |
-
|
38 |
-
return $reply;
|
39 |
-
|
40 |
-
}
|
41 |
-
endif;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Add Reward Metabox
|
45 |
-
* @since 1.5
|
46 |
-
* @version 1.0.1
|
47 |
-
*/
|
48 |
-
if ( ! function_exists( 'mycred_woo_add_product_metabox' ) ) :
|
49 |
-
function mycred_woo_add_product_metabox() {
|
50 |
-
|
51 |
-
add_meta_box(
|
52 |
-
'mycred_woo_sales_setup',
|
53 |
-
mycred_label(),
|
54 |
-
'mycred_woo_product_metabox',
|
55 |
-
'product',
|
56 |
-
'side',
|
57 |
-
'high'
|
58 |
-
);
|
59 |
-
|
60 |
-
}
|
61 |
-
endif;
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Product Metabox
|
65 |
-
* @since 1.5
|
66 |
-
* @version 1.1
|
67 |
-
*/
|
68 |
-
if ( ! function_exists( 'mycred_woo_product_metabox' ) ) :
|
69 |
-
function mycred_woo_product_metabox( $post ) {
|
70 |
-
|
71 |
-
if ( ! current_user_can( apply_filters( 'mycred_woo_reward_cap', 'edit_others_posts' ) ) ) return;
|
72 |
-
|
73 |
-
$types = mycred_get_types();
|
74 |
-
$prefs = (array) get_post_meta( $post->ID, 'mycred_reward', true );
|
75 |
-
|
76 |
-
foreach ( $types as $point_type => $point_type_label ) {
|
77 |
-
if ( ! array_key_exists( $point_type, $prefs ) )
|
78 |
-
$prefs[ $point_type ] = '';
|
79 |
-
}
|
80 |
-
|
81 |
-
$count = 0;
|
82 |
-
$cui = get_current_user_id();
|
83 |
-
foreach ( $types as $point_type => $point_type_label ) {
|
84 |
-
|
85 |
-
$count ++;
|
86 |
-
$mycred = mycred( $point_type );
|
87 |
-
|
88 |
-
if ( ! $mycred->can_edit_creds( $cui ) ) continue;
|
89 |
-
|
90 |
-
$setup = $prefs[ $point_type ];
|
91 |
-
|
92 |
-
?>
|
93 |
-
<p class="<?php if ( $count == 1 ) echo 'first'; ?>"><label for="mycred-reward-purchase-with-<?php echo $point_type; ?>"><input class="toggle-mycred-reward" data-id="<?php echo $point_type; ?>" <?php if ( $setup != '' ) echo 'checked="checked"'; ?> type="checkbox" name="mycred_reward[<?php echo $point_type; ?>][use]" id="mycred-reward-purchase-with-<?php echo $point_type; ?>" value="1" /> <?php echo $mycred->template_tags_general( __( 'Reward with %plural%', 'mycred' ) ); ?></label></p>
|
94 |
-
<div class="mycred-woo-wrap" id="reward-<?php echo $point_type; ?>" style="display:<?php if ( $setup == '' ) echo 'none'; else echo 'block'; ?>">
|
95 |
-
<label><?php echo $mycred->plural(); ?></label> <input type="text" size="8" name="mycred_reward[<?php echo $point_type; ?>][amount]" value="<?php echo esc_attr( $setup ); ?>" placeholder="<?php echo $mycred->zero(); ?>" />
|
96 |
-
</div>
|
97 |
-
<?php
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
?>
|
102 |
-
<script type="text/javascript">
|
103 |
-
jQuery(function($) {
|
104 |
-
|
105 |
-
$( '.toggle-mycred-reward' ).click(function(){
|
106 |
-
var target = $(this).attr( 'data-id' );
|
107 |
-
$( '#reward-' + target ).toggle();
|
108 |
-
});
|
109 |
-
|
110 |
-
});
|
111 |
-
</script>
|
112 |
-
<style type="text/css">
|
113 |
-
#mycred_woo_sales_setup .inside { margin: 0; padding: 0; }
|
114 |
-
#mycred_woo_sales_setup .inside > p { padding: 12px; margin: 0; border-top: 1px solid #ddd; }
|
115 |
-
#mycred_woo_sales_setup .inside > p.first { border-top: none; }
|
116 |
-
#mycred_woo_sales_setup .inside .mycred-woo-wrap { padding: 6px 12px; line-height: 27px; text-align: right; border-top: 1px solid #ddd; background-color: #F5F5F5; }
|
117 |
-
#mycred_woo_sales_setup .inside .mycred-woo-wrap label { display: block; font-weight: bold; float: left; }
|
118 |
-
#mycred_woo_sales_setup .inside .mycred-woo-wrap input { width: 50%; }
|
119 |
-
#mycred_woo_sales_setup .inside .mycred-woo-wrap p { margin: 0; padding: 0 12px; font-style: italic; text-align: center; }
|
120 |
-
#mycred_woo_vaiation .box { display: block; float: left; width: 49%; margin-right: 1%; margin-bottom: 12px; }
|
121 |
-
#mycred_woo_vaiation .box input { display: block; width: 100%; }
|
122 |
-
</style>
|
123 |
-
<?php
|
124 |
-
|
125 |
-
}
|
126 |
-
endif;
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Add Reward details for Variations
|
130 |
-
* @since 1.7.6
|
131 |
-
* @version 1.0
|
132 |
-
*/
|
133 |
-
if ( ! function_exists( 'mycred_woo_add_product_variation_detail' ) ) :
|
134 |
-
function mycred_woo_add_product_variation_detail( $loop, $variation_data, $variation ) {
|
135 |
-
|
136 |
-
$types = mycred_get_types();
|
137 |
-
$user_id = get_current_user_id();
|
138 |
-
$prefs = (array) get_post_meta( $variation->ID, '_mycred_reward', true );
|
139 |
-
|
140 |
-
foreach ( $types as $point_type => $point_type_label ) {
|
141 |
-
if ( ! array_key_exists( $point_type, $prefs ) )
|
142 |
-
$prefs[ $point_type ] = '';
|
143 |
-
}
|
144 |
-
|
145 |
-
?>
|
146 |
-
<div class="" id="mycred_woo_vaiation">
|
147 |
-
<?php
|
148 |
-
|
149 |
-
foreach ( $types as $point_type => $point_type_label ) {
|
150 |
-
|
151 |
-
$mycred = mycred( $point_type );
|
152 |
-
|
153 |
-
if ( ! $mycred->can_edit_creds( $user_id ) ) continue;
|
154 |
-
|
155 |
-
$id = 'mycred-rewards-variation-' . $variation->ID . str_replace( '_', '-', $point_type );
|
156 |
-
|
157 |
-
?>
|
158 |
-
<div class="box">
|
159 |
-
<label for="<?php echo $id; ?>"><?php echo $mycred->template_tags_general( __( 'Reward with %plural%', 'mycred' ) ); ?></label>
|
160 |
-
<input type="text" name="_mycred_reward[<?php echo $variation->ID; ?>][<?php echo $point_type; ?>]" id="<?php echo $id; ?>" class="input-text" placeholder="<?php _e( 'Leave empty for no rewards', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs[ $point_type ] ); ?>" />
|
161 |
-
</div>
|
162 |
-
<?php
|
163 |
-
|
164 |
-
}
|
165 |
-
|
166 |
-
?>
|
167 |
-
</div>
|
168 |
-
<?php
|
169 |
-
|
170 |
-
}
|
171 |
-
endif;
|
172 |
-
|
173 |
-
|
174 |
-
/**
|
175 |
-
* WooCommerce Points Refund
|
176 |
-
* @since 1.7.9.8
|
177 |
-
* @version 1.0
|
178 |
-
*/
|
179 |
-
if ( ! function_exists( 'mycred_woo_refund_points' ) ) :
|
180 |
-
function mycred_woo_refund_points( $request ) {
|
181 |
-
|
182 |
-
if( $request['ref'] == 'woocommerce_refund' )
|
183 |
-
$request['amount'] = abs($request['amount']);
|
184 |
-
|
185 |
-
return $request;
|
186 |
-
}
|
187 |
-
endif;
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Save Reward Setup
|
191 |
-
* @since 1.5
|
192 |
-
* @version 1.0.1
|
193 |
-
*/
|
194 |
-
if ( ! function_exists( 'mycred_woo_save_reward_settings' ) ) :
|
195 |
-
function mycred_woo_save_reward_settings( $post_id ) {
|
196 |
-
|
197 |
-
if ( ! isset( $_POST['mycred_reward'] ) || empty( $_POST['mycred_reward'] ) || get_post_type( $post_id ) != 'product' ) return;
|
198 |
-
|
199 |
-
$new_setup = array();
|
200 |
-
foreach ( $_POST['mycred_reward'] as $point_type => $setup ) {
|
201 |
-
|
202 |
-
if ( empty( $setup ) ) continue;
|
203 |
-
|
204 |
-
$mycred = mycred( $point_type );
|
205 |
-
if ( array_key_exists( 'use', $setup ) && $setup['use'] == 1 )
|
206 |
-
$new_setup[ $point_type ] = $mycred->number( $setup['amount'] );
|
207 |
-
|
208 |
-
}
|
209 |
-
|
210 |
-
if ( empty( $new_setup ) )
|
211 |
-
delete_post_meta( $post_id, 'mycred_reward' );
|
212 |
-
else
|
213 |
-
update_post_meta( $post_id, 'mycred_reward', $new_setup );
|
214 |
-
|
215 |
-
}
|
216 |
-
endif;
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Save Reward for Variations
|
220 |
-
* @since 1.7.6
|
221 |
-
* @version 1.0
|
222 |
-
*/
|
223 |
-
if ( ! function_exists( 'mycred_woo_save_product_variation_detail' ) ) :
|
224 |
-
function mycred_woo_save_product_variation_detail( $post_id ) {
|
225 |
-
|
226 |
-
if ( ! isset( $_POST['_mycred_reward'] ) || empty( $_POST['_mycred_reward'] ) || ! array_key_exists( $post_id, $_POST['_mycred_reward'] ) ) return;
|
227 |
-
|
228 |
-
$new_setup = array();
|
229 |
-
foreach ( $_POST['_mycred_reward'][ $post_id ] as $point_type => $value ) {
|
230 |
-
|
231 |
-
$value = sanitize_text_field( $value );
|
232 |
-
if ( empty( $value ) ) continue;
|
233 |
-
|
234 |
-
$mycred = mycred( $point_type );
|
235 |
-
$value = $mycred->number( $value );
|
236 |
-
if ( $value === $mycred->zero() ) continue;
|
237 |
-
|
238 |
-
$new_setup[ $point_type ] = $value;
|
239 |
-
|
240 |
-
}
|
241 |
-
|
242 |
-
if ( empty( $new_setup ) )
|
243 |
-
delete_post_meta( $post_id, '_mycred_reward' );
|
244 |
-
else
|
245 |
-
update_post_meta( $post_id, '_mycred_reward', $new_setup );
|
246 |
-
|
247 |
-
}
|
248 |
-
endif;
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Payout Rewards
|
252 |
-
* @since 1.5
|
253 |
-
* @version 1.2
|
254 |
-
*/
|
255 |
-
if ( ! function_exists( 'mycred_woo_payout_rewards' ) ) :
|
256 |
-
function mycred_woo_payout_rewards( $order_id ) {
|
257 |
-
|
258 |
-
// Get Order
|
259 |
-
$order = wc_get_order( $order_id );
|
260 |
-
|
261 |
-
global $woocommerce;
|
262 |
-
|
263 |
-
$paid_with = ( version_compare( $woocommerce->version, '3.0', '>=' ) ) ? $order->get_payment_method() : $order->payment_method;
|
264 |
-
$buyer_id = ( version_compare( $woocommerce->version, '3.0', '>=' ) ) ? $order->get_user_id() : $order->user_id;
|
265 |
-
|
266 |
-
// If we paid with myCRED we do not award points by default
|
267 |
-
if ( $paid_with == 'mycred' && apply_filters( 'mycred_woo_reward_mycred_payment', false, $order ) === false )
|
268 |
-
return;
|
269 |
-
|
270 |
-
// Get items
|
271 |
-
$items = $order->get_items();
|
272 |
-
$types = mycred_get_types();
|
273 |
-
|
274 |
-
// Loop through each point type
|
275 |
-
foreach ( $types as $point_type => $point_type_label ) {
|
276 |
-
|
277 |
-
// Load type
|
278 |
-
$mycred = mycred( $point_type );
|
279 |
-
|
280 |
-
// Check for exclusions
|
281 |
-
if ( $mycred->exclude_user( $buyer_id ) ) continue;
|
282 |
-
|
283 |
-
// Calculate reward
|
284 |
-
$payout = $mycred->zero();
|
285 |
-
foreach ( $items as $item ) {
|
286 |
-
|
287 |
-
// Get the product ID or the variation ID
|
288 |
-
$product_id = absint( $item['product_id'] );
|
289 |
-
$variation_id = absint( $item['variation_id'] );
|
290 |
-
$reward_amount = mycred_get_woo_product_reward( $product_id, $variation_id, $point_type );
|
291 |
-
|
292 |
-
// Reward can not be empty or zero
|
293 |
-
if ( $reward_amount != '' && $reward_amount != 0 )
|
294 |
-
$payout = ( $payout + ( $mycred->number( $reward_amount ) * $item['qty'] ) );
|
295 |
-
|
296 |
-
}
|
297 |
-
|
298 |
-
// We can not payout zero points
|
299 |
-
if ( $payout === $mycred->zero() ) continue;
|
300 |
-
|
301 |
-
// Let others play with the reference and log entry
|
302 |
-
$reference = apply_filters( 'mycred_woo_reward_reference', 'reward', $order_id, $point_type );
|
303 |
-
$log = apply_filters( 'mycred_woo_reward_log', '%plural% reward for store purchase', $order_id, $point_type );
|
304 |
-
|
305 |
-
// Make sure we only get points once per order
|
306 |
-
if ( ! $mycred->has_entry( $reference, $order_id, $buyer_id ) ) {
|
307 |
-
|
308 |
-
// Execute
|
309 |
-
$mycred->add_creds(
|
310 |
-
$reference,
|
311 |
-
$buyer_id,
|
312 |
-
$payout,
|
313 |
-
$log,
|
314 |
-
$order_id,
|
315 |
-
array( 'ref_type' => 'post' ),
|
316 |
-
$point_type
|
317 |
-
);
|
318 |
-
|
319 |
-
}
|
320 |
-
|
321 |
-
}
|
322 |
-
|
323 |
-
}
|
324 |
-
endif;
|
325 |
-
|
326 |
-
/**
|
327 |
-
* Get Product Reward
|
328 |
-
* Returns either an array of point types and the reward value set for each or
|
329 |
-
* the value set for a given point type. Will check for variable product rewards as well.
|
330 |
-
* @since 1.7.6
|
331 |
-
* @version 1.0
|
332 |
-
*/
|
333 |
-
if ( ! function_exists( 'mycred_get_woo_product_reward' ) ) :
|
334 |
-
function mycred_get_woo_product_reward( $product_id = NULL, $variation_id = NULL, $requested_type = false ) {
|
335 |
-
|
336 |
-
$product_id = absint( $product_id );
|
337 |
-
$types = mycred_get_types();
|
338 |
-
$meta_key = 'mycred_reward';
|
339 |
-
$is_variable = false;
|
340 |
-
if ( $product_id === 0 ) return false;
|
341 |
-
|
342 |
-
if ( function_exists( 'wc_get_product' ) ) {
|
343 |
-
|
344 |
-
$product = wc_get_product( $product_id );
|
345 |
-
|
346 |
-
// For variations, we need a variation ID
|
347 |
-
if ( $product->is_type( 'variable' ) && $variation_id !== NULL && $variation_id > 0 ) {
|
348 |
-
$parent_product_id = $product->get_parent();
|
349 |
-
$reward_setup = (array) get_post_meta( $variation_id, '_mycred_reward', true );
|
350 |
-
$parent_reward_setup = (array) get_post_meta( $parent_product_id, 'mycred_reward', true );
|
351 |
-
}
|
352 |
-
else {
|
353 |
-
$reward_setup = (array) get_post_meta( $product_id, 'mycred_reward', true );
|
354 |
-
$parent_reward_setup = array();
|
355 |
-
}
|
356 |
-
|
357 |
-
}
|
358 |
-
|
359 |
-
// Make sure all point types are populated in a reward setup
|
360 |
-
foreach ( $types as $point_type => $point_type_label ) {
|
361 |
-
|
362 |
-
if ( empty( $reward_setup ) || ! array_key_exists( $point_type, $reward_setup ) )
|
363 |
-
$reward_setup[ $point_type ] = '';
|
364 |
-
|
365 |
-
if ( empty( $parent_reward_setup ) || ! array_key_exists( $point_type, $parent_reward_setup ) )
|
366 |
-
$parent_reward_setup[ $point_type ] = '';
|
367 |
-
|
368 |
-
}
|
369 |
-
|
370 |
-
// We might want to enforce the parent value for variations
|
371 |
-
foreach ( $reward_setup as $point_type => $value ) {
|
372 |
-
|
373 |
-
// If the variation has no value set, but the parent box has a value set, enforce the parent value
|
374 |
-
// If the variation is set to zero however, it indicates we do not want to reward that variation
|
375 |
-
if ( $value == '' && $parent_reward_setup[ $point_type ] != '' && $parent_reward_setup[ $point_type ] != 0 )
|
376 |
-
$reward_setup[ $point_type ] = $parent_reward_setup[ $point_type ];
|
377 |
-
|
378 |
-
}
|
379 |
-
|
380 |
-
// If we are requesting one particular types reward
|
381 |
-
if ( $requested_type !== false ) {
|
382 |
-
|
383 |
-
$value = '';
|
384 |
-
if ( array_key_exists( $requested_type, $reward_setup ) )
|
385 |
-
$value = $reward_setup[ $requested_type ];
|
386 |
-
|
387 |
-
return $value;
|
388 |
-
|
389 |
-
}
|
390 |
-
|
391 |
-
return $reward_setup;
|
392 |
-
|
393 |
-
}
|
394 |
-
endif;
|
395 |
-
|
396 |
-
/**
|
397 |
-
* Register Hook
|
398 |
-
* @since 1.5
|
399 |
-
* @version 1.1
|
400 |
-
*/
|
401 |
-
function mycred_register_woocommerce_hook( $installed ) {
|
402 |
-
|
403 |
-
if ( ! class_exists( 'WooCommerce' ) ) return $installed;
|
404 |
-
|
405 |
-
$installed['wooreview'] = array(
|
406 |
-
'title' => __( 'WooCommerce Product Reviews', 'mycred' ),
|
407 |
-
'description' => __( 'Awards %_plural% for users leaving reviews on your WooCommerce products.', 'mycred' ),
|
408 |
-
'documentation' => 'http://codex.mycred.me/hooks/product-reviews/',
|
409 |
-
'callback' => array( 'myCRED_Hook_WooCommerce_Reviews' )
|
410 |
-
);
|
411 |
-
|
412 |
-
return $installed;
|
413 |
-
|
414 |
-
}
|
415 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_woocommerce_hook', 95 );
|
416 |
-
|
417 |
-
/**
|
418 |
-
* WooCommerce Product Review Hook
|
419 |
-
* @since 1.5
|
420 |
-
* @version 1.1.1
|
421 |
-
*/
|
422 |
-
add_action( 'mycred_load_hooks', 'mycred_load_woocommerce_hook', 95 );
|
423 |
-
function mycred_load_woocommerce_hook() {
|
424 |
-
|
425 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
426 |
-
if ( class_exists( 'myCRED_Hook_WooCommerce_Reviews' ) || ! class_exists( 'WooCommerce' ) ) return;
|
427 |
-
|
428 |
-
class myCRED_Hook_WooCommerce_Reviews extends myCRED_Hook {
|
429 |
-
|
430 |
-
/**
|
431 |
-
* Construct
|
432 |
-
*/
|
433 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
434 |
-
|
435 |
-
parent::__construct( array(
|
436 |
-
'id' => 'wooreview',
|
437 |
-
'defaults' => array(
|
438 |
-
'creds' => 1,
|
439 |
-
'log' => '%plural% for product review',
|
440 |
-
'limit' => '0/x'
|
441 |
-
)
|
442 |
-
), $hook_prefs, $type );
|
443 |
-
|
444 |
-
}
|
445 |
-
|
446 |
-
/**
|
447 |
-
* Run
|
448 |
-
* @since 1.5
|
449 |
-
* @version 1.0
|
450 |
-
*/
|
451 |
-
public function run() {
|
452 |
-
|
453 |
-
add_action( 'comment_post', array( $this, 'new_review' ), 99, 2 );
|
454 |
-
add_action( 'transition_comment_status', array( $this, 'review_transitions' ), 99, 3 );
|
455 |
-
|
456 |
-
}
|
457 |
-
|
458 |
-
/**
|
459 |
-
* New Review
|
460 |
-
* @since 1.5
|
461 |
-
* @version 1.0
|
462 |
-
*/
|
463 |
-
public function new_review( $comment_id, $comment_status ) {
|
464 |
-
|
465 |
-
// Approved comment
|
466 |
-
if ( $comment_status == '1' )
|
467 |
-
$this->review_transitions( 'approved', 'unapproved', $comment_id );
|
468 |
-
|
469 |
-
}
|
470 |
-
|
471 |
-
/**
|
472 |
-
* Review Transitions
|
473 |
-
* @since 1.5
|
474 |
-
* @version 1.2
|
475 |
-
*/
|
476 |
-
public function review_transitions( $new_status, $old_status, $comment ) {
|
477 |
-
|
478 |
-
// Only approved reviews give points
|
479 |
-
if ( $new_status != 'approved' ) return;
|
480 |
-
|
481 |
-
// Passing an integer instead of an object means we need to grab the comment object ourselves
|
482 |
-
if ( ! is_object( $comment ) )
|
483 |
-
$comment = get_comment( $comment );
|
484 |
-
|
485 |
-
// No comment object so lets bail
|
486 |
-
if ( $comment === NULL ) return;
|
487 |
-
|
488 |
-
// Only applicable for reviews
|
489 |
-
if ( get_post_type( $comment->comment_post_ID ) != 'product' ) return;
|
490 |
-
|
491 |
-
// Check for exclusions
|
492 |
-
if ( $this->core->exclude_user( $comment->user_id ) ) return;
|
493 |
-
|
494 |
-
// Limit
|
495 |
-
if ( $this->over_hook_limit( '', 'product_review', $comment->user_id ) ) return;
|
496 |
-
|
497 |
-
// Execute
|
498 |
-
$data = array( 'ref_type' => 'post' );
|
499 |
-
if ( ! $this->core->has_entry( 'product_review', $comment->comment_post_ID, $comment->user_id, $data, $this->mycred_type ) )
|
500 |
-
$this->core->add_creds(
|
501 |
-
'product_review',
|
502 |
-
$comment->user_id,
|
503 |
-
$this->prefs['creds'],
|
504 |
-
$this->prefs['log'],
|
505 |
-
$comment->comment_post_ID,
|
506 |
-
$data,
|
507 |
-
$this->mycred_type
|
508 |
-
);
|
509 |
-
|
510 |
-
}
|
511 |
-
|
512 |
-
/**
|
513 |
-
* Preferences for WooCommerce Product Reviews
|
514 |
-
* @since 1.5
|
515 |
-
* @version 1.1
|
516 |
-
*/
|
517 |
-
public function preferences() {
|
518 |
-
|
519 |
-
$prefs = $this->prefs;
|
520 |
-
|
521 |
-
?>
|
522 |
-
<div class="hook-instance">
|
523 |
-
<div class="row">
|
524 |
-
<div class="col-lg-2 col-md-6 col-sm-6 col-xs-12">
|
525 |
-
<div class="form-group">
|
526 |
-
<label for="<?php echo $this->field_id( 'creds' ); ?>"><?php echo $this->core->plural(); ?></label>
|
527 |
-
<input type="text" name="<?php echo $this->field_name( 'creds' ); ?>" id="<?php echo $this->field_id( 'creds' ); ?>" value="<?php echo $this->core->number( $prefs['creds'] ); ?>" class="form-control" />
|
528 |
-
</div>
|
529 |
-
</div>
|
530 |
-
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
|
531 |
-
<div class="form-group">
|
532 |
-
<label for="<?php echo $this->field_id( 'limit' ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
533 |
-
<?php echo $this->hook_limit_setting( $this->field_name( 'limit' ), $this->field_id( 'limit' ), $prefs['limit'] ); ?>
|
534 |
-
</div>
|
535 |
-
</div>
|
536 |
-
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
|
537 |
-
<div class="form-group">
|
538 |
-
<label for="<?php echo $this->field_id( 'log' ); ?>"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
539 |
-
<input type="text" name="<?php echo $this->field_name( 'log' ); ?>" id="<?php echo $this->field_id( 'log' ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['log'] ); ?>" class="form-control" />
|
540 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
541 |
-
</div>
|
542 |
-
</div>
|
543 |
-
</div>
|
544 |
-
</div>
|
545 |
-
<?php
|
546 |
-
|
547 |
-
}
|
548 |
-
|
549 |
-
/**
|
550 |
-
* Sanitise Preferences
|
551 |
-
* @since 1.6
|
552 |
-
* @version 1.0
|
553 |
-
*/
|
554 |
-
public function sanitise_preferences( $data ) {
|
555 |
-
|
556 |
-
if ( isset( $data['limit'] ) && isset( $data['limit_by'] ) ) {
|
557 |
-
$limit = sanitize_text_field( $data['limit'] );
|
558 |
-
if ( $limit == '' ) $limit = 0;
|
559 |
-
$data['limit'] = $limit . '/' . $data['limit_by'];
|
560 |
-
unset( $data['limit_by'] );
|
561 |
-
}
|
562 |
-
|
563 |
-
return $data;
|
564 |
-
|
565 |
-
}
|
566 |
-
|
567 |
-
}
|
568 |
-
|
569 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-wp-favorite-posts.php
DELETED
@@ -1,326 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.1
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_wp_favorite_posts_hook', 100 );
|
10 |
-
function mycred_register_wp_favorite_posts_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! function_exists( 'wp_favorite_posts' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['wpfavorite'] = array(
|
15 |
-
'title' => __( 'WP Favorite Posts', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for users adding posts to their favorites.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/wp-favorite-posts-actions/',
|
18 |
-
'callback' => array( 'myCRED_Hook_WPFavorite' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* WP Favorite Hook
|
27 |
-
* @since 1.1
|
28 |
-
* @version 1.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_wp_favorite_posts_hook', 100 );
|
31 |
-
function mycred_load_wp_favorite_posts_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_Hook_WPFavorite' ) || ! function_exists( 'wp_favorite_posts' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_Hook_WPFavorite extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'wpfavorite',
|
45 |
-
'defaults' => array(
|
46 |
-
'add' => array(
|
47 |
-
'creds' => 1,
|
48 |
-
'log' => '%plural% for adding a post as favorite',
|
49 |
-
'limit' => '0/x'
|
50 |
-
),
|
51 |
-
'added' => array(
|
52 |
-
'creds' => 1,
|
53 |
-
'log' => '%plural% for your post being added to favorite',
|
54 |
-
'limit' => '0/x'
|
55 |
-
),
|
56 |
-
'remove' => array(
|
57 |
-
'creds' => 1,
|
58 |
-
'log' => '%plural% deduction for removing a post from favorites'
|
59 |
-
),
|
60 |
-
'removed' => array(
|
61 |
-
'creds' => 1,
|
62 |
-
'log' => '%plural% deduction for post removed from favorites'
|
63 |
-
)
|
64 |
-
)
|
65 |
-
), $hook_prefs, $type );
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Run
|
71 |
-
* @since 1.1
|
72 |
-
* @version 1.0.1
|
73 |
-
*/
|
74 |
-
public function run() {
|
75 |
-
|
76 |
-
add_action( 'wpfp_after_add', array( $this, 'add_favorite' ) );
|
77 |
-
add_action( 'wpfp_after_remove', array( $this, 'remove_favorite' ) );
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Add Favorite
|
83 |
-
* @since 1.1
|
84 |
-
* @version 1.2
|
85 |
-
*/
|
86 |
-
public function add_favorite( $post_id ) {
|
87 |
-
|
88 |
-
// Must be logged in
|
89 |
-
if ( ! is_user_logged_in() ) return;
|
90 |
-
|
91 |
-
$post = get_post( $post_id );
|
92 |
-
$user_id = get_current_user_id();
|
93 |
-
|
94 |
-
if ( $user_id != $post->post_author ) {
|
95 |
-
|
96 |
-
// Award the user adding to favorite
|
97 |
-
if ( $this->prefs['add']['creds'] != 0 && ! $this->core->exclude_user( $user_id ) ) {
|
98 |
-
|
99 |
-
// Limit
|
100 |
-
if ( ! $this->over_hook_limit( 'add', 'add_favorite_post', $user_id ) ) {
|
101 |
-
|
102 |
-
// Make sure this is unique event
|
103 |
-
if ( ! $this->core->has_entry( 'add_favorite_post', $post_id, $user_id ) ) {
|
104 |
-
|
105 |
-
// Execute
|
106 |
-
$this->core->add_creds(
|
107 |
-
'add_favorite_post',
|
108 |
-
$user_id,
|
109 |
-
$this->prefs['add']['creds'],
|
110 |
-
$this->prefs['add']['log'],
|
111 |
-
$post_id,
|
112 |
-
array( 'ref_type' => 'post' ),
|
113 |
-
$this->mycred_type
|
114 |
-
);
|
115 |
-
|
116 |
-
}
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
// Award post author for being added to favorite
|
123 |
-
if ( $this->prefs['added']['creds'] != 0 && ! $this->core->exclude_user( $post->post_author ) ) {
|
124 |
-
|
125 |
-
// Limit
|
126 |
-
if ( ! $this->over_hook_limit( 'added', 'add_favorite_post', $post->post_author ) ) {
|
127 |
-
|
128 |
-
// Make sure this is unique event
|
129 |
-
if ( ! $this->core->has_entry( 'favorited_post', $post_id, $post->post_author ) ) {
|
130 |
-
|
131 |
-
// Execute
|
132 |
-
$this->core->add_creds(
|
133 |
-
'favorited_post',
|
134 |
-
$post->post_author,
|
135 |
-
$this->prefs['added']['creds'],
|
136 |
-
$this->prefs['added']['log'],
|
137 |
-
$post_id,
|
138 |
-
array( 'ref_type' => 'post', 'by' => $user_id ),
|
139 |
-
$this->mycred_type
|
140 |
-
);
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
}
|
145 |
-
|
146 |
-
}
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Remove Favorite
|
154 |
-
* @since 1.1
|
155 |
-
* @version 1.2
|
156 |
-
*/
|
157 |
-
public function remove_favorite( $post_id ) {
|
158 |
-
|
159 |
-
// Must be logged in
|
160 |
-
if ( ! is_user_logged_in() ) return;
|
161 |
-
|
162 |
-
$post = get_post( $post_id );
|
163 |
-
$user_id = get_current_user_id();
|
164 |
-
|
165 |
-
if ( $user_id != $post->post_author ) {
|
166 |
-
|
167 |
-
if ( $this->prefs['remove']['creds'] != 0 && ! $this->core->exclude_user( $user_id ) ) {
|
168 |
-
|
169 |
-
if ( ! $this->core->has_entry( 'favorite_post_removed', $post_id, $user_id ) ) {
|
170 |
-
|
171 |
-
$this->core->add_creds(
|
172 |
-
'favorite_post_removed',
|
173 |
-
$user_id,
|
174 |
-
$this->prefs['remove']['creds'],
|
175 |
-
$this->prefs['remove']['log'],
|
176 |
-
$post_id,
|
177 |
-
array( 'ref_type' => 'post' ),
|
178 |
-
$this->mycred_type
|
179 |
-
);
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
if ( $this->prefs['removed']['creds'] != 0 && ! $this->core->exclude_user( $post->post_author ) ) {
|
186 |
-
|
187 |
-
if ( ! $this->core->has_entry( 'favorite_post_removal', $post_id, $post->post_author ) ) {
|
188 |
-
|
189 |
-
$this->core->add_creds(
|
190 |
-
'favorite_post_removal',
|
191 |
-
$post->post_author,
|
192 |
-
$this->prefs['removed']['creds'],
|
193 |
-
$this->prefs['removed']['log'],
|
194 |
-
$post_id,
|
195 |
-
array( 'ref_type' => 'post', 'by' => $user_id ),
|
196 |
-
$this->mycred_type
|
197 |
-
);
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Preferences for WP-Polls
|
209 |
-
* @since 1.1
|
210 |
-
* @version 1.1
|
211 |
-
*/
|
212 |
-
public function preferences() {
|
213 |
-
|
214 |
-
$prefs = $this->prefs;
|
215 |
-
|
216 |
-
?>
|
217 |
-
<div class="hook-instance">
|
218 |
-
<h3><?php _e( 'Adding Content to Favorites', 'mycred' ); ?></h3>
|
219 |
-
<div class="row">
|
220 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
221 |
-
<div class="form-group">
|
222 |
-
<label for="<?php echo $this->field_id( array( 'add' => 'creds' ) ); ?>"><?php _e( 'Member', 'mycred' ); ?></label>
|
223 |
-
<input type="text" name="<?php echo $this->field_name( array( 'add' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'add' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['add']['creds'] ); ?>" class="form-control" />
|
224 |
-
</div>
|
225 |
-
</div>
|
226 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
227 |
-
<div class="form-group">
|
228 |
-
<label for="<?php echo $this->field_id( array( 'add', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
229 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'add', 'limit' ) ), $this->field_id( array( 'add', 'limit' ) ), $prefs['add']['limit'] ); ?>
|
230 |
-
</div>
|
231 |
-
</div>
|
232 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
233 |
-
<div class="form-group">
|
234 |
-
<label for="<?php echo $this->field_id( array( 'added' => 'creds' ) ); ?>"><?php _e( 'Content Author', 'mycred' ); ?></label>
|
235 |
-
<input type="text" name="<?php echo $this->field_name( array( 'added' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'added' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['added']['creds'] ); ?>" class="form-control" />
|
236 |
-
</div>
|
237 |
-
</div>
|
238 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
239 |
-
<div class="form-group">
|
240 |
-
<label for="<?php echo $this->field_id( array( 'added', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
241 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'added', 'limit' ) ), $this->field_id( array( 'added', 'limit' ) ), $prefs['added']['limit'] ); ?>
|
242 |
-
</div>
|
243 |
-
</div>
|
244 |
-
</div>
|
245 |
-
<div class="row">
|
246 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
247 |
-
<div class="form-group">
|
248 |
-
<label for="<?php echo $this->field_id( array( 'add' => 'log' ) ); ?>"><?php _e( 'Member Log Template', 'mycred' ); ?></label>
|
249 |
-
<input type="text" name="<?php echo $this->field_name( array( 'add' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'add' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['add']['log'] ); ?>" class="form-control" />
|
250 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
251 |
-
</div>
|
252 |
-
</div>
|
253 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
254 |
-
<div class="form-group">
|
255 |
-
<label for="<?php echo $this->field_id( array( 'added' => 'log' ) ); ?>"><?php _e( 'Content Author Log Template', 'mycred' ); ?></label>
|
256 |
-
<input type="text" name="<?php echo $this->field_name( array( 'added' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'added' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['added']['log'] ); ?>" class="form-control" />
|
257 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
258 |
-
</div>
|
259 |
-
</div>
|
260 |
-
</div>
|
261 |
-
</div>
|
262 |
-
<div class="hook-instance">
|
263 |
-
<h3><?php _e( 'Removing Content from Favorites', 'mycred' ); ?></h3>
|
264 |
-
<div class="row">
|
265 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
266 |
-
<div class="form-group">
|
267 |
-
<label for="<?php echo $this->field_id( array( 'remove' => 'creds' ) ); ?>"><?php _e( 'Member', 'mycred' ); ?></label>
|
268 |
-
<input type="text" name="<?php echo $this->field_name( array( 'remove' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'remove' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['remove']['creds'] ); ?>" class="form-control" />
|
269 |
-
</div>
|
270 |
-
</div>
|
271 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
272 |
-
<div class="form-group">
|
273 |
-
<label for="<?php echo $this->field_id( array( 'remove' => 'log' ) ); ?>"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
274 |
-
<input type="text" name="<?php echo $this->field_name( array( 'remove' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'remove' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['remove']['log'] ); ?>" class="form-control" />
|
275 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
276 |
-
</div>
|
277 |
-
</div>
|
278 |
-
</div>
|
279 |
-
<div class="row">
|
280 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
281 |
-
<div class="form-group">
|
282 |
-
<label for="<?php echo $this->field_id( array( 'removed' => 'creds' ) ); ?>"><?php _e( 'Content Author', 'mycred' ); ?></label>
|
283 |
-
<input type="text" name="<?php echo $this->field_name( array( 'removed' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'removed' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['removed']['creds'] ); ?>" class="form-control" />
|
284 |
-
</div>
|
285 |
-
</div>
|
286 |
-
<div class="col-lg-8 col-md-6 col-sm-12 col-xs-12">
|
287 |
-
<div class="form-group">
|
288 |
-
<label for="<?php echo $this->field_id( array( 'removed' => 'log' ) ); ?>"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
289 |
-
<input type="text" name="<?php echo $this->field_name( array( 'removed' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'removed' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['removed']['log'] ); ?>" class="form-control" />
|
290 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
291 |
-
</div>
|
292 |
-
</div>
|
293 |
-
</div>
|
294 |
-
</div>
|
295 |
-
<?php
|
296 |
-
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* Sanitise Preferences
|
301 |
-
* @since 1.6
|
302 |
-
* @version 1.0
|
303 |
-
*/
|
304 |
-
public function sanitise_preferences( $data ) {
|
305 |
-
|
306 |
-
if ( isset( $data['add']['limit'] ) && isset( $data['add']['limit_by'] ) ) {
|
307 |
-
$limit = sanitize_text_field( $data['add']['limit'] );
|
308 |
-
if ( $limit == '' ) $limit = 0;
|
309 |
-
$data['add']['limit'] = $limit . '/' . $data['add']['limit_by'];
|
310 |
-
unset( $data['add']['limit_by'] );
|
311 |
-
}
|
312 |
-
|
313 |
-
if ( isset( $data['added']['limit'] ) && isset( $data['added']['limit_by'] ) ) {
|
314 |
-
$limit = sanitize_text_field( $data['added']['limit'] );
|
315 |
-
if ( $limit == '' ) $limit = 0;
|
316 |
-
$data['added']['limit'] = $limit . '/' . $data['added']['limit_by'];
|
317 |
-
unset( $data['added']['limit_by'] );
|
318 |
-
}
|
319 |
-
|
320 |
-
return $data;
|
321 |
-
|
322 |
-
}
|
323 |
-
|
324 |
-
}
|
325 |
-
|
326 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-wp-polls.php
DELETED
@@ -1,190 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.1
|
7 |
-
* @version 1.1
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_wp_polls_hook', 105 );
|
10 |
-
function mycred_register_wp_polls_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! function_exists( 'vote_poll' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['wppolls'] = array(
|
15 |
-
'title' => __( 'WP-Polls', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for users voting in polls.', 'mycred' ),
|
17 |
-
'documentation' => '',
|
18 |
-
'callback' => array( 'myCRED_Hook_WPPolls' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* WP-Polls Hook
|
27 |
-
* @since 1.1
|
28 |
-
* @version 1.1
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_wp_polls_hook', 105 );
|
31 |
-
function mycred_load_wp_polls_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_Hook_WPPolls' ) || ! function_exists( 'vote_poll' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_Hook_WPPolls extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'wppolls',
|
45 |
-
'defaults' => array(
|
46 |
-
'creds' => 1,
|
47 |
-
'log' => '%plural% for voting'
|
48 |
-
)
|
49 |
-
), $hook_prefs, $type );
|
50 |
-
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Run
|
55 |
-
* @since 1.1
|
56 |
-
* @version 1.0
|
57 |
-
*/
|
58 |
-
public function run() {
|
59 |
-
|
60 |
-
add_action( 'wp_ajax_polls', array( $this, 'vote_poll' ), 1 );
|
61 |
-
add_filter( 'mycred_parse_tags_poll', array( $this, 'parse_custom_tags' ), 10, 2 );
|
62 |
-
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Poll Voting
|
67 |
-
* @since 1.1
|
68 |
-
* @version 1.1
|
69 |
-
*/
|
70 |
-
public function vote_poll() {
|
71 |
-
|
72 |
-
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'polls' && is_user_logged_in() ) {
|
73 |
-
|
74 |
-
// Get Poll ID
|
75 |
-
$poll_id = ( isset( $_REQUEST['poll_id'] ) ? intval( $_REQUEST['poll_id'] ) : 0 );
|
76 |
-
|
77 |
-
// Ensure Poll ID Is Valid
|
78 |
-
if ( $poll_id != 0 ) {
|
79 |
-
|
80 |
-
// Verify Referer
|
81 |
-
if ( check_ajax_referer( 'poll_' . $poll_id . '-nonce', 'poll_' . $poll_id . '_nonce', false ) ) {
|
82 |
-
|
83 |
-
// Which View
|
84 |
-
switch ( $_REQUEST['view'] ) {
|
85 |
-
|
86 |
-
case 'process':
|
87 |
-
|
88 |
-
$poll_aid = $_POST["poll_$poll_id"];
|
89 |
-
$poll_aid_array = array_unique( array_map( 'intval', explode( ',', $poll_aid ) ) );
|
90 |
-
|
91 |
-
if ( $poll_id > 0 && ! empty( $poll_aid_array ) && check_allowtovote() ) {
|
92 |
-
|
93 |
-
$check_voted = check_voted( $poll_id );
|
94 |
-
|
95 |
-
if ( $check_voted == 0 ) {
|
96 |
-
|
97 |
-
$user_id = get_current_user_id();
|
98 |
-
|
99 |
-
// Make sure we are not excluded
|
100 |
-
if ( ! $this->core->exclude_user( $user_id ) ) {
|
101 |
-
$this->core->add_creds(
|
102 |
-
'poll_voting',
|
103 |
-
$user_id,
|
104 |
-
$this->prefs['creds'],
|
105 |
-
$this->prefs['log'],
|
106 |
-
$poll_id,
|
107 |
-
array( 'ref_type' => 'poll' ),
|
108 |
-
$this->mycred_type
|
109 |
-
);
|
110 |
-
}
|
111 |
-
|
112 |
-
}
|
113 |
-
|
114 |
-
}
|
115 |
-
|
116 |
-
break;
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Parse Custom Tags in Log
|
130 |
-
* @since 1.1
|
131 |
-
* @version 1.0
|
132 |
-
*/
|
133 |
-
public function parse_custom_tags( $content, $log_entry ) {
|
134 |
-
|
135 |
-
$poll_id = $log_entry->ref_id;
|
136 |
-
$content = str_replace( '%poll_id%', $poll_id, $content );
|
137 |
-
$content = str_replace( '%poll_question%', $this->get_poll_name( $poll_id ), $content );
|
138 |
-
|
139 |
-
return $content;
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Get Poll Name (Question)
|
145 |
-
* @since 1.1
|
146 |
-
* @version 1.0
|
147 |
-
*/
|
148 |
-
protected function get_poll_name( $poll_id ) {
|
149 |
-
|
150 |
-
global $wpdb;
|
151 |
-
$sql = "SELECT pollq_question FROM {$wpdb->pollsq} WHERE pollq_id = %d ";
|
152 |
-
|
153 |
-
return $wpdb->get_var( $wpdb->prepare( $sql, $poll_id ) );
|
154 |
-
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Preferences for WP-Polls
|
159 |
-
* @since 1.1
|
160 |
-
* @version 1.0
|
161 |
-
*/
|
162 |
-
public function preferences() {
|
163 |
-
|
164 |
-
$prefs = $this->prefs;
|
165 |
-
|
166 |
-
?>
|
167 |
-
<div class="hook-instance">
|
168 |
-
<div class="row">
|
169 |
-
<div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
|
170 |
-
<div class="form-group">
|
171 |
-
<label for="<?php echo $this->field_id( 'creds' ); ?>"><?php echo $this->core->plural(); ?></label>
|
172 |
-
<input type="text" name="<?php echo $this->field_name( 'creds' ); ?>" id="<?php echo $this->field_id( 'creds' ); ?>" value="<?php echo $this->core->number( $prefs['creds'] ); ?>" class="form-control" />
|
173 |
-
</div>
|
174 |
-
</div>
|
175 |
-
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
|
176 |
-
<div class="form-group">
|
177 |
-
<label for="<?php echo $this->field_id( 'log' ); ?>"><?php _e( 'Log Template', 'mycred' ); ?></label>
|
178 |
-
<input type="text" name="<?php echo $this->field_name( 'log' ); ?>" id="<?php echo $this->field_id( 'log' ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['log'] ); ?>" class="form-control" />
|
179 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general' ) ); ?></span>
|
180 |
-
</div>
|
181 |
-
</div>
|
182 |
-
</div>
|
183 |
-
</div>
|
184 |
-
<?php
|
185 |
-
|
186 |
-
}
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins/mycred-hook-wp-postratings.php
DELETED
@@ -1,256 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Register Hook
|
6 |
-
* @since 1.6
|
7 |
-
* @version 1.0
|
8 |
-
*/
|
9 |
-
add_filter( 'mycred_setup_hooks', 'mycred_register_wp_postratings_hook', 110 );
|
10 |
-
function mycred_register_wp_postratings_hook( $installed ) {
|
11 |
-
|
12 |
-
if ( ! defined( 'WP_POSTRATINGS_VERSION' ) ) return $installed;
|
13 |
-
|
14 |
-
$installed['wp_postratings'] = array(
|
15 |
-
'title' => __( 'Post Ratings', 'mycred' ),
|
16 |
-
'description' => __( 'Awards %_plural% for post ratings. Supports awarding %_plural% both to post author and the user rating.', 'mycred' ),
|
17 |
-
'documentation' => 'http://codex.mycred.me/hooks/wp-postratings-actions/',
|
18 |
-
'callback' => array( 'myCRED_WP_Postratings' )
|
19 |
-
);
|
20 |
-
|
21 |
-
return $installed;
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* WP Postratings Hook
|
27 |
-
* @since 1.6
|
28 |
-
* @version 1.0
|
29 |
-
*/
|
30 |
-
add_action( 'mycred_load_hooks', 'mycred_load_wp_postratings_hook', 110 );
|
31 |
-
function mycred_load_wp_postratings_hook() {
|
32 |
-
|
33 |
-
// If the hook has been replaced or if plugin is not installed, exit now
|
34 |
-
if ( class_exists( 'myCRED_WP_Postratings' ) || ! defined( 'WP_POSTRATINGS_VERSION' ) ) return;
|
35 |
-
|
36 |
-
class myCRED_WP_Postratings extends myCRED_Hook {
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Construct
|
40 |
-
*/
|
41 |
-
public function __construct( $hook_prefs, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
42 |
-
|
43 |
-
parent::__construct( array(
|
44 |
-
'id' => 'wp_postratings',
|
45 |
-
'defaults' => array(
|
46 |
-
'rating' => array(
|
47 |
-
'creds' => 0,
|
48 |
-
'log' => '%plural% for rating',
|
49 |
-
'limit' => '0/x',
|
50 |
-
'value' => 0
|
51 |
-
),
|
52 |
-
'rated' => array(
|
53 |
-
'creds' => 0,
|
54 |
-
'log' => '%plural% for getting a rating',
|
55 |
-
'limit' => '0/x',
|
56 |
-
'value' => 0
|
57 |
-
)
|
58 |
-
)
|
59 |
-
), $hook_prefs, $type );
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Run
|
65 |
-
* @since 1.6
|
66 |
-
* @version 1.0
|
67 |
-
*/
|
68 |
-
public function run() {
|
69 |
-
|
70 |
-
add_action( 'rate_post', array( $this, 'new_rating' ), 10, 3 );
|
71 |
-
add_filter( 'mycred_hook_table_creds', array( $this, 'table_amount' ), 10, 3 );
|
72 |
-
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Table Amount
|
77 |
-
* @since 1.6
|
78 |
-
* @version 1.0
|
79 |
-
*/
|
80 |
-
public function table_amount( $amount, $id, $prefs ) {
|
81 |
-
|
82 |
-
if ( ! in_array( $id, array( 'rating', 'rated' ) ) || ! isset( $prefs['value'] ) ) return $amount;
|
83 |
-
|
84 |
-
if ( $prefs['value'] == 1 )
|
85 |
-
return __( 'Based on rating', 'mycred' );
|
86 |
-
|
87 |
-
return $amount;
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Successful Form Submission
|
93 |
-
* @since 1.6
|
94 |
-
* @version 1.0
|
95 |
-
*/
|
96 |
-
public function new_rating( $user_id, $post_id, $rating_value ) {
|
97 |
-
|
98 |
-
// Get post
|
99 |
-
$post = get_post( $post_id );
|
100 |
-
|
101 |
-
// Authors can not get points for rating their own stuff
|
102 |
-
if ( ! isset( $post->post_author ) && $post->post_author == $user_id ) return;
|
103 |
-
|
104 |
-
// Determen the amount to award
|
105 |
-
$amount = $this->prefs['rating']['creds'];
|
106 |
-
if ( $this->prefs['rating']['value'] == 1 )
|
107 |
-
$amount = $rating_value;
|
108 |
-
|
109 |
-
// If enabled - award the rater
|
110 |
-
if ( $amount != 0 ) {
|
111 |
-
|
112 |
-
// Only award if the user is not excluded and not over their limit
|
113 |
-
if ( ! $this->core->exclude_user( $user_id ) && ! $this->over_hook_limit( 'rating', 'post_rating', $user_id ) )
|
114 |
-
$this->core->add_creds(
|
115 |
-
'post_rating',
|
116 |
-
$user_id,
|
117 |
-
$amount,
|
118 |
-
$this->prefs['rating']['log'],
|
119 |
-
$post_id,
|
120 |
-
array( 'ref_type' => 'post', 'value' => $rating_value ),
|
121 |
-
$this->mycred_type
|
122 |
-
);
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
// Determen the amount to award for author
|
127 |
-
$amount = $this->prefs['rated']['creds'];
|
128 |
-
if ( $this->prefs['rated']['value'] == 1 )
|
129 |
-
$amount = $rating_value;
|
130 |
-
|
131 |
-
// If enabled - award the rater
|
132 |
-
if ( $amount != 0 ) {
|
133 |
-
|
134 |
-
// Only award if the author is not excluded and not over their limit
|
135 |
-
if ( ! $this->core->exclude_user( $post->post_author ) && ! $this->over_hook_limit( 'rated', 'post_rating_author', $post->post_author ) )
|
136 |
-
$this->core->add_creds(
|
137 |
-
'post_rating_author',
|
138 |
-
$post->post_author,
|
139 |
-
$amount,
|
140 |
-
$this->prefs['rated']['log'],
|
141 |
-
$post_id,
|
142 |
-
array( 'ref_type' => 'post', 'value' => $rating_value ),
|
143 |
-
$this->mycred_type
|
144 |
-
);
|
145 |
-
|
146 |
-
}
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Preferences for WP Postratings Hook
|
152 |
-
* @since 1.6
|
153 |
-
* @version 1.1
|
154 |
-
*/
|
155 |
-
public function preferences() {
|
156 |
-
|
157 |
-
$prefs = $this->prefs;
|
158 |
-
|
159 |
-
?>
|
160 |
-
<div class="hook-instance">
|
161 |
-
<h3><?php _e( 'Content Rating', 'mycred' ); ?></h3>
|
162 |
-
<div class="row">
|
163 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
164 |
-
<div class="form-group">
|
165 |
-
<label for="<?php echo $this->field_id( array( 'rating' => 'creds' ) ); ?>"><?php _e( 'Member', 'mycred' ); ?></label>
|
166 |
-
<input type="text" name="<?php echo $this->field_name( array( 'rating' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'rating' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['rating']['creds'] ); ?>" class="form-control" />
|
167 |
-
</div>
|
168 |
-
</div>
|
169 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
170 |
-
<div class="form-group">
|
171 |
-
<label for="<?php echo $this->field_id( array( 'rating', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
172 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'rating', 'limit' ) ), $this->field_id( array( 'rating', 'limit' ) ), $prefs['rating']['limit'] ); ?>
|
173 |
-
</div>
|
174 |
-
</div>
|
175 |
-
<div class="col-lg-2 col-md-6 col-sm-12 col-xs-12">
|
176 |
-
<div class="form-group">
|
177 |
-
<label for="<?php echo $this->field_id( array( 'rated' => 'creds' ) ); ?>"><?php _e( 'Content Author', 'mycred' ); ?></label>
|
178 |
-
<input type="text" name="<?php echo $this->field_name( array( 'rated' => 'creds' ) ); ?>" id="<?php echo $this->field_id( array( 'rated' => 'creds' ) ); ?>" value="<?php echo $this->core->number( $prefs['rated']['creds'] ); ?>" class="form-control" />
|
179 |
-
</div>
|
180 |
-
</div>
|
181 |
-
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
|
182 |
-
<div class="form-group">
|
183 |
-
<label for="<?php echo $this->field_id( array( 'rated', 'limit' ) ); ?>"><?php _e( 'Limit', 'mycred' ); ?></label>
|
184 |
-
<?php echo $this->hook_limit_setting( $this->field_name( array( 'rated', 'limit' ) ), $this->field_id( array( 'rated', 'limit' ) ), $prefs['rated']['limit'] ); ?>
|
185 |
-
</div>
|
186 |
-
</div>
|
187 |
-
</div>
|
188 |
-
<div class="row">
|
189 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
190 |
-
<div class="form-group">
|
191 |
-
<div class="checkbox">
|
192 |
-
<label for="<?php echo $this->field_id( array( 'rating', 'value' ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'rating', 'value' ) ); ?>" id="<?php echo $this->field_id( array( 'rating', 'value' ) ); ?>" <?php checked( $prefs['rating']['value'], 1 ); ?> value="1" /> <?php _e( 'Use the Rating Value instead of the amount set here.', 'mycred' ); ?></label>
|
193 |
-
</div>
|
194 |
-
</div>
|
195 |
-
</div>
|
196 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
197 |
-
<div class="form-group">
|
198 |
-
<div class="checkbox">
|
199 |
-
<label for="<?php echo $this->field_id( array( 'rated', 'value' ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'rated', 'value' ) ); ?>" id="<?php echo $this->field_id( array( 'rated', 'value' ) ); ?>" <?php checked( $prefs['rated']['value'], 1 ); ?> value="1" /> <?php _e( 'Use the Rating Value instead of the amount set here.', 'mycred' ); ?></label>
|
200 |
-
</div>
|
201 |
-
</div>
|
202 |
-
</div>
|
203 |
-
</div>
|
204 |
-
<div class="row">
|
205 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
206 |
-
<div class="form-group">
|
207 |
-
<label for="<?php echo $this->field_id( array( 'rating' => 'log' ) ); ?>"><?php _e( 'Member Log Template', 'mycred' ); ?></label>
|
208 |
-
<input type="text" name="<?php echo $this->field_name( array( 'rating' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'rating' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['rating']['log'] ); ?>" class="form-control" />
|
209 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
210 |
-
</div>
|
211 |
-
</div>
|
212 |
-
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
|
213 |
-
<div class="form-group">
|
214 |
-
<label for="<?php echo $this->field_id( array( 'rated' => 'log' ) ); ?>"><?php _e( 'Content Author Log Template', 'mycred' ); ?></label>
|
215 |
-
<input type="text" name="<?php echo $this->field_name( array( 'rated' => 'log' ) ); ?>" id="<?php echo $this->field_id( array( 'rated' => 'log' ) ); ?>" placeholder="<?php _e( 'required', 'mycred' ); ?>" value="<?php echo esc_attr( $prefs['rated']['log'] ); ?>" class="form-control" />
|
216 |
-
<span class="description"><?php echo $this->available_template_tags( array( 'general', 'post' ) ); ?></span>
|
217 |
-
</div>
|
218 |
-
</div>
|
219 |
-
</div>
|
220 |
-
</div>
|
221 |
-
<?php
|
222 |
-
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Sanitise Preferences
|
227 |
-
* @since 1.6
|
228 |
-
* @version 1.0
|
229 |
-
*/
|
230 |
-
public function sanitise_preferences( $data ) {
|
231 |
-
|
232 |
-
$data['rating']['value'] = ( isset( $data['rating']['value'] ) ) ? 1 : 0;
|
233 |
-
|
234 |
-
if ( isset( $data['rating']['limit'] ) && isset( $data['rating']['limit_by'] ) ) {
|
235 |
-
$limit = sanitize_text_field( $data['rating']['limit'] );
|
236 |
-
if ( $limit == '' ) $limit = 0;
|
237 |
-
$data['rating']['limit'] = $limit . '/' . $data['rating']['limit_by'];
|
238 |
-
unset( $data['rating']['limit_by'] );
|
239 |
-
}
|
240 |
-
|
241 |
-
$data['rated']['value'] = ( isset( $data['rated']['value'] ) ) ? 1 : 0;
|
242 |
-
|
243 |
-
if ( isset( $data['rated']['limit'] ) && isset( $data['rated']['limit_by'] ) ) {
|
244 |
-
$limit = sanitize_text_field( $data['rated']['limit'] );
|
245 |
-
if ( $limit == '' ) $limit = 0;
|
246 |
-
$data['rated']['limit'] = $limit . '/' . $data['rated']['limit_by'];
|
247 |
-
unset( $data['rated']['limit_by'] );
|
248 |
-
}
|
249 |
-
|
250 |
-
return $data;
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
}
|
255 |
-
|
256 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: mycred,wpexpertsio
|
3 |
Tags: point, credit, loyalty program, engagement, reward
|
4 |
Requires at least: 4.8
|
5 |
-
Tested up to: 5.2
|
6 |
-
Stable tag: 1.8.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -109,6 +109,12 @@ Bug fixes release.
|
|
109 |
= 1.8.4.1 =
|
110 |
Bug fixes release.
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
== Other Notes ==
|
114 |
|
@@ -131,6 +137,32 @@ Bug fixes release.
|
|
131 |
|
132 |
== Changelog ==
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
= 1.8.4.1 =
|
135 |
FIX - myCRED hooks not saving.
|
136 |
FIX - setCookie function error when adding new hook.
|
2 |
Contributors: mycred,wpexpertsio
|
3 |
Tags: point, credit, loyalty program, engagement, reward
|
4 |
Requires at least: 4.8
|
5 |
+
Tested up to: 5.2.3
|
6 |
+
Stable tag: 1.8.5
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
109 |
= 1.8.4.1 =
|
110 |
Bug fixes release.
|
111 |
|
112 |
+
= 1.8.4.2 =
|
113 |
+
Bug fixes release.
|
114 |
+
|
115 |
+
= 1.8.5 =
|
116 |
+
Bug fixes release.
|
117 |
+
|
118 |
|
119 |
== Other Notes ==
|
120 |
|
137 |
|
138 |
== Changelog ==
|
139 |
|
140 |
+
= 1.8.5 =
|
141 |
+
NEW - Added "to" attribute in Leaderboard shortcode.
|
142 |
+
NEW - Added filter "mycred_show_custom_coupon_value" for coupon value.
|
143 |
+
FIX - myCRED Leaderboard widget notices.
|
144 |
+
FIX - Typo fix in BuddyPress hook.
|
145 |
+
FIX - Coupon success message not showing in custom point types.
|
146 |
+
FIX - Incorrect point type in coupon notification.
|
147 |
+
FIX - Ranks not being assigned based on Total Balance.
|
148 |
+
FIX - Set default point type in ctype attribute in [mycred_users_of_all_ranks] shortcode.
|
149 |
+
FIX - [mycred_hook_table] this shortcode showing only 1 content hook at a time.
|
150 |
+
FIX - Emails that are stored in draft are also being sent.
|
151 |
+
FIX - Template tags are not being rendered in email Notices.
|
152 |
+
FIX - Admin not able to select ranks "manual mode" from settings.
|
153 |
+
FIX - Admin not able to assign ranks when "manual mode" is enabled.
|
154 |
+
FIX - Errors in [mycred_email_subscriptions] shortcode.
|
155 |
+
FIX - Transfer Message showing as "-" in log.
|
156 |
+
FIX - myCRED Cache not deleting.
|
157 |
+
FIX - When deleting a BuddyPress Activity adds a "Profile Comment Delete" log.
|
158 |
+
FIX - Assign users badge from badge edit page.
|
159 |
+
FIX - "Not in" operator not passing in query_log.
|
160 |
+
FIX - Show main image in [mycred_my_badges] shortcode if level image is not set.
|
161 |
+
|
162 |
+
= 1.8.4.2 =
|
163 |
+
FIX - myCRED hooks not adding on other point types.
|
164 |
+
FIX - option_id name not calling for other point types.
|
165 |
+
|
166 |
= 1.8.4.1 =
|
167 |
FIX - myCRED hooks not saving.
|
168 |
FIX - setCookie function error when adding new hook.
|