Version Description
- Adjusted plugin URLs in files that were missed previously.
Fixed Bug #16 - PHP Notice when using the
mycred_history
shortcode.Request #9 - Remove paragraph element for not logged in users if the login message is set to blank.
Request #10 - Added new
mycred_my_balance
shortcode to display current users balance.Request #11 - Added new
mycred_sales_history
shortcode to the Sell Content Add-on to show all content purchased by the current user.Request #12 - Add reference search to the
mycred_history
shortcode.
Download this release
Release Info
Developer | designbymerovingi |
Plugin | myCRED |
Version | 1.0.9 |
Comparing to | |
See all releases |
Code changes from version 1.0.8 to 1.0.9
- addons/buddypress/myCRED-addon-buddypress.php +1 -1
- addons/buy-creds/myCRED-addon-buy-creds.php +2 -2
- addons/gateway/myCRED-addon-gateway.php +1 -1
- addons/import/myCRED-addon-import.php +1 -1
- addons/sell-content/myCRED-addon-sell-content.php +87 -13
- addons/transfer/myCRED-addon-transfer.php +11 -8
- includes/mycred-functions.php +48 -3
- modules/mycred-module-hooks.php +19 -36
- modules/mycred-module-log.php +3 -4
- mycred.php +5 -4
- readme.txt +10 -1
addons/buddypress/myCRED-addon-buddypress.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Addon: BuddyPress
|
4 |
-
* Addon URI: http://mycred.
|
5 |
* Version: 1.0
|
6 |
* Description: The BuddyPress add-on extends <strong>my</strong>CRED to work with BuddyPress allowing you to hook into most BuddyPress related actions.
|
7 |
* Author: Gabriel S Merovingi
|
1 |
<?php
|
2 |
/**
|
3 |
* Addon: BuddyPress
|
4 |
+
* Addon URI: http://mycred.me/add-ons/buddypress/
|
5 |
* Version: 1.0
|
6 |
* Description: The BuddyPress add-on extends <strong>my</strong>CRED to work with BuddyPress allowing you to hook into most BuddyPress related actions.
|
7 |
* Author: Gabriel S Merovingi
|
addons/buy-creds/myCRED-addon-buy-creds.php
CHANGED
@@ -745,8 +745,8 @@ if ( !class_exists( 'myCRED_Buy_CREDs' ) ) {
|
|
745 |
<p><strong>' . __( 'Usage', 'mycred' ) . '</strong></p>
|
746 |
<p>' . __( 'Purchases can be made using one of the following shortcodes:', 'mycred' ) . '</p>
|
747 |
<ul>
|
748 |
-
<li><code>mycred_buy</code> ' . __( 'When you want to sell a pre-set amount, sell to a specific user or use a specific gateway.<br />For more information on how to use the shortcode, please visit the', 'mycred' ) . ' <a href="http://mycred.
|
749 |
-
<li><code>mycred_buy_form</code> ' . __( 'When you want to give your users the option to select an amount, gateway or recipient.<br />For more information on how to use the shortcode, please visit the', 'mycred' ) . ' <a href="http://mycred.
|
750 |
</ul>'
|
751 |
) );
|
752 |
}
|
745 |
<p><strong>' . __( 'Usage', 'mycred' ) . '</strong></p>
|
746 |
<p>' . __( 'Purchases can be made using one of the following shortcodes:', 'mycred' ) . '</p>
|
747 |
<ul>
|
748 |
+
<li><code>mycred_buy</code> ' . __( 'When you want to sell a pre-set amount, sell to a specific user or use a specific gateway.<br />For more information on how to use the shortcode, please visit the', 'mycred' ) . ' <a href="http://mycred.me/shortcodes/mycred_buy/" target="_blank">myCRED Codex</a>.</li>
|
749 |
+
<li><code>mycred_buy_form</code> ' . __( 'When you want to give your users the option to select an amount, gateway or recipient.<br />For more information on how to use the shortcode, please visit the', 'mycred' ) . ' <a href="http://mycred.me/shortcodes/mycred_buy_form/" target="_blank">myCRED Codex</a>.</li>
|
750 |
</ul>'
|
751 |
) );
|
752 |
}
|
addons/gateway/myCRED-addon-gateway.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Addon: Gateway
|
4 |
-
* Addon URI: http://mycred.
|
5 |
* Version: 1.0
|
6 |
* Description: Let your users pay using their <strong>my</strong>CRED points balance. Supported Carts: WooCommerce.
|
7 |
* Author: Gabriel S Merovingi
|
1 |
<?php
|
2 |
/**
|
3 |
* Addon: Gateway
|
4 |
+
* Addon URI: http://mycred.me/add-ons/gateway/
|
5 |
* Version: 1.0
|
6 |
* Description: Let your users pay using their <strong>my</strong>CRED points balance. Supported Carts: WooCommerce.
|
7 |
* Author: Gabriel S Merovingi
|
addons/import/myCRED-addon-import.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Addon: Import
|
4 |
-
* Addon URI: http://mycred.
|
5 |
* Version: 1.0
|
6 |
* Description: With the Import add-on you can import CSV files, CubePoints or existing points under any custom user meta values.
|
7 |
* Author: Gabriel S Merovingi
|
1 |
<?php
|
2 |
/**
|
3 |
* Addon: Import
|
4 |
+
* Addon URI: http://mycred.me/add-ons/import/
|
5 |
* Version: 1.0
|
6 |
* Description: With the Import add-on you can import CSV files, CubePoints or existing points under any custom user meta values.
|
7 |
* Author: Gabriel S Merovingi
|
addons/sell-content/myCRED-addon-sell-content.php
CHANGED
@@ -56,18 +56,20 @@ if ( !class_exists( 'myCRED_Sell_Content' ) ) {
|
|
56 |
/**
|
57 |
* Load
|
58 |
* @since 0.1
|
59 |
-
* @version 1.
|
60 |
*/
|
61 |
public function module_init() {
|
62 |
$this->make_purchase();
|
63 |
|
64 |
-
add_filter( 'the_content',
|
65 |
-
|
|
|
|
|
66 |
|
67 |
-
add_action( 'add_meta_boxes',
|
68 |
-
add_action( 'save_post',
|
69 |
|
70 |
-
add_action( 'mycred_admin_enqueue',
|
71 |
}
|
72 |
|
73 |
/**
|
@@ -651,12 +653,12 @@ if ( !class_exists( 'myCRED_Sell_Content' ) ) {
|
|
651 |
unset( $content );
|
652 |
return '
|
653 |
<form action="" method="post">
|
654 |
-
<input type="hidden" name="mycred_purchase[post_id]"
|
655 |
-
<input type="hidden" name="mycred_purchase[post_type]"
|
656 |
-
<input type="hidden" name="mycred_purchase[user_id]"
|
657 |
-
<input type="hidden" name="mycred_purchase[author]"
|
658 |
-
<input type="hidden" name="mycred_purchase_token"
|
659 |
-
<input type="hidden" name="mycred_purchase[action]"
|
660 |
<div class="mycred-content-forsale">' . $template . '</div>
|
661 |
</form>';
|
662 |
}
|
@@ -677,6 +679,78 @@ if ( !class_exists( 'myCRED_Sell_Content' ) ) {
|
|
677 |
|
678 |
return $content;
|
679 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
|
681 |
/**
|
682 |
* Contextual Help
|
@@ -694,7 +768,7 @@ if ( !class_exists( 'myCRED_Sell_Content' ) ) {
|
|
694 |
<p><strong>' . __( 'Defaults', 'mycred' ) . '</strong></p>
|
695 |
<p>' . __( 'The default price and button label is applied to all content that is set for sale. You can select if you want to enforce these settings or let the content authors set their own.', 'mycred' ) . '</p>
|
696 |
<p><strong>' . __( 'Usage', 'mycred' ) . '</strong></p>
|
697 |
-
<p>' . __( 'You can either sell entire posts via the Sell Content Meta Box or by using the <code>mycred_sell_this</code> shortcode.<br />For more information on how to use the shortcode, please visit the', 'mycred' ) . ' <a href="http://mycred.
|
698 |
) );
|
699 |
}
|
700 |
}
|
56 |
/**
|
57 |
* Load
|
58 |
* @since 0.1
|
59 |
+
* @version 1.1
|
60 |
*/
|
61 |
public function module_init() {
|
62 |
$this->make_purchase();
|
63 |
|
64 |
+
add_filter( 'the_content', array( $this, 'the_content' ), 30 );
|
65 |
+
|
66 |
+
add_shortcode( 'mycred_sell_this', array( $this, 'render_shortcode' ) );
|
67 |
+
add_shortcode( 'mycred_sales_history', array( $this, 'render_sales_history' ) );
|
68 |
|
69 |
+
add_action( 'add_meta_boxes', array( $this, 'add_metabox' ) );
|
70 |
+
add_action( 'save_post', array( $this, 'save_metabox' ) );
|
71 |
|
72 |
+
add_action( 'mycred_admin_enqueue', array( $this, 'admin_enqueue' ) );
|
73 |
}
|
74 |
|
75 |
/**
|
653 |
unset( $content );
|
654 |
return '
|
655 |
<form action="" method="post">
|
656 |
+
<input type="hidden" name="mycred_purchase[post_id]" value="' . $post_id . '" />
|
657 |
+
<input type="hidden" name="mycred_purchase[post_type]" value="' . $GLOBALS['post']->post_type . '" />
|
658 |
+
<input type="hidden" name="mycred_purchase[user_id]" value="' . get_current_user_id() . '" />
|
659 |
+
<input type="hidden" name="mycred_purchase[author]" value="' . $GLOBALS['post']->post_author . '" />
|
660 |
+
<input type="hidden" name="mycred_purchase_token" value="' . wp_create_nonce( 'buy-content' ) . '" />
|
661 |
+
<input type="hidden" name="mycred_purchase[action]" value="buy" />
|
662 |
<div class="mycred-content-forsale">' . $template . '</div>
|
663 |
</form>';
|
664 |
}
|
679 |
|
680 |
return $content;
|
681 |
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Render Sales History Shortcode
|
685 |
+
* @see http://mycred.me/shortcodes/mycred_sales_history/
|
686 |
+
* @since 1.0.9
|
687 |
+
* @version 1.0
|
688 |
+
*/
|
689 |
+
public function render_sales_history( $atts ) {
|
690 |
+
extract( shortcode_atts( array(
|
691 |
+
'login' => NULL,
|
692 |
+
'title' => '',
|
693 |
+
'title_el' => 'h1',
|
694 |
+
'title_class' => '',
|
695 |
+
'include_date' => true,
|
696 |
+
'no_result' => __( 'No purchases found', 'mycred' )
|
697 |
+
), $atts ) );
|
698 |
+
|
699 |
+
// Not logged in
|
700 |
+
if ( !is_user_logged_in() ) {
|
701 |
+
if ( $login != NULL )
|
702 |
+
return '<div class="mycred-not-logged-in">' . $login . '</div>';
|
703 |
+
|
704 |
+
return;
|
705 |
+
}
|
706 |
+
|
707 |
+
// Prep
|
708 |
+
$output = '<div class="mycred-sales-history-wrapper">';
|
709 |
+
$user_id = get_current_user_id();
|
710 |
+
|
711 |
+
global $wpdb;
|
712 |
+
|
713 |
+
// Title
|
714 |
+
if ( !empty( $title ) ) {
|
715 |
+
if ( !empty( $title_class ) )
|
716 |
+
$title_class = ' class="' . $title_class . '"';
|
717 |
+
$output .= '<' . $title_el . $title_class . '>' . $title . '</' . $title_el . '>';
|
718 |
+
}
|
719 |
+
|
720 |
+
// Query
|
721 |
+
$sql = "SELECT * FROM " . $wpdb->prefix . 'myCRED_log' . " WHERE user_id = %d AND ref = %s ORDER BY time ";
|
722 |
+
$results = $wpdb->get_results( $wpdb->prepare( $sql, $user_id, 'buy_content' ) );
|
723 |
+
$rows = array();
|
724 |
+
|
725 |
+
// Results
|
726 |
+
if ( $wpdb->num_rows > 0 ) {
|
727 |
+
foreach ( $results as $item ) {
|
728 |
+
// Row
|
729 |
+
$row = '<span class="item-link"><a href="' . get_permalink( $item->ref_id ) . '">' . get_the_title( $item->ref_id ) . '</a></span>';
|
730 |
+
|
731 |
+
// Add Date to row
|
732 |
+
if ( $include_date )
|
733 |
+
$row .= '<span class="purchased">' . __( 'Purchased', 'mycred' ) . ' ' . date_i18n( get_option( 'date_format' ), $item->time ) . '</span>';
|
734 |
+
|
735 |
+
// Construct row (and let others play)
|
736 |
+
$rows[] = apply_filters( 'mycred_sale_history_row', $row, $item );
|
737 |
+
}
|
738 |
+
}
|
739 |
+
|
740 |
+
// Implode rows if there are any
|
741 |
+
if ( !empty( $rows ) ) {
|
742 |
+
$output .= '<ul class="mycred-purchase-history"><li>' . implode( '</li><li>', $rows ) . '</li></ul>';
|
743 |
+
}
|
744 |
+
// No results
|
745 |
+
else {
|
746 |
+
if ( !empty( $no_result ) )
|
747 |
+
$output .= '<p>' . $no_result . '</p>';
|
748 |
+
}
|
749 |
+
|
750 |
+
$output .= '</div>';
|
751 |
+
|
752 |
+
return $output;
|
753 |
+
}
|
754 |
|
755 |
/**
|
756 |
* Contextual Help
|
768 |
<p><strong>' . __( 'Defaults', 'mycred' ) . '</strong></p>
|
769 |
<p>' . __( 'The default price and button label is applied to all content that is set for sale. You can select if you want to enforce these settings or let the content authors set their own.', 'mycred' ) . '</p>
|
770 |
<p><strong>' . __( 'Usage', 'mycred' ) . '</strong></p>
|
771 |
+
<p>' . __( 'You can either sell entire posts via the Sell Content Meta Box or by using the <code>mycred_sell_this</code> shortcode.<br />For more information on how to use the shortcode, please visit the', 'mycred' ) . ' <a href="http://mycred.me/shortcodes/mycred_sell_this/" target="_blank">myCRED Codex</a>.</p>'
|
772 |
) );
|
773 |
}
|
774 |
}
|
addons/transfer/myCRED-addon-transfer.php
CHANGED
@@ -466,7 +466,7 @@ if ( !class_exists( 'myCRED_Transfer_Creds' ) ) {
|
|
466 |
<p><strong>' . __( 'Transfer Limit', 'mycred' ) . '</strong></p>
|
467 |
<p>' . __( 'You can impose a daily-, weekly- or monthly transfer limit for each user. Note, that this transfer limit is imposed on everyone who are not excluded from using myCRED.', 'mycred' ) . '</p>
|
468 |
<p><strong>' . __( 'Usage', 'mycred' ) . '</strong></p>
|
469 |
-
<p>' . __( 'Transfers can be made by either using the <code>mycred_transfer</code> shortcode or via the myCRED Transfer Widget.<br />For more information on how to use the shortcode, please visit the', 'mycred' ) . ' <a href="http://mycred.
|
470 |
) );
|
471 |
}
|
472 |
}
|
@@ -475,7 +475,7 @@ if ( !class_exists( 'myCRED_Transfer_Creds' ) ) {
|
|
475 |
}
|
476 |
|
477 |
/**
|
478 |
-
* Widget: myCRED
|
479 |
* @since 0.1
|
480 |
* @version 1.0
|
481 |
*/
|
@@ -595,7 +595,7 @@ if ( !class_exists( 'myCRED_Widget_Transfer' ) ) {
|
|
595 |
|
596 |
/**
|
597 |
* Transfer Shortcode Render
|
598 |
-
* @see http://mycred.
|
599 |
* @attribute $charge_from (int) optional user ID from whom the points to be deducted, defaults to current user
|
600 |
* @attribute $pay_to (int) optional user ID to whom the transfer is made, if left empty the user will be able to search for a user
|
601 |
* @attribute $show_balance (bool) set to true to show current users balance, defaults to true
|
@@ -732,7 +732,7 @@ if ( !function_exists( 'mycred_transfer_render' ) ) {
|
|
732 |
|
733 |
/**
|
734 |
* User Can Transfer
|
735 |
-
* @see http://mycred.
|
736 |
* @param $user_id (int) requred user id
|
737 |
* @param $amount (int) optional amount to check against balance
|
738 |
* @returns true if no limit is set, 'limit' (string) if user is over limit else the amount of creds left
|
@@ -742,7 +742,7 @@ if ( !function_exists( 'mycred_transfer_render' ) ) {
|
|
742 |
* @version 1.1
|
743 |
*/
|
744 |
if ( !function_exists( 'mycred_user_can_transfer' ) ) {
|
745 |
-
function mycred_user_can_transfer( $user_id, $amount =
|
746 |
{
|
747 |
if ( $user_id === NULL ) $user_id = get_current_user_id();
|
748 |
|
@@ -753,9 +753,12 @@ if ( !function_exists( 'mycred_user_can_transfer' ) ) {
|
|
753 |
$balance = $mycred->get_users_cred( $user_id );
|
754 |
|
755 |
// To low balance
|
756 |
-
$account_limit = apply_filters( 'mycred_transfer_acc_limit', 0 );
|
757 |
-
if ( $amount
|
758 |
-
|
|
|
|
|
|
|
759 |
|
760 |
// No limits imposed
|
761 |
if ( $set_limit == 'none' ) return true;
|
466 |
<p><strong>' . __( 'Transfer Limit', 'mycred' ) . '</strong></p>
|
467 |
<p>' . __( 'You can impose a daily-, weekly- or monthly transfer limit for each user. Note, that this transfer limit is imposed on everyone who are not excluded from using myCRED.', 'mycred' ) . '</p>
|
468 |
<p><strong>' . __( 'Usage', 'mycred' ) . '</strong></p>
|
469 |
+
<p>' . __( 'Transfers can be made by either using the <code>mycred_transfer</code> shortcode or via the myCRED Transfer Widget.<br />For more information on how to use the shortcode, please visit the', 'mycred' ) . ' <a href="http://mycred.me/shortcodes/mycred_transfer/" target="_blank">myCRED Codex</a>.</p>'
|
470 |
) );
|
471 |
}
|
472 |
}
|
475 |
}
|
476 |
|
477 |
/**
|
478 |
+
* Widget: myCRED Transfer
|
479 |
* @since 0.1
|
480 |
* @version 1.0
|
481 |
*/
|
595 |
|
596 |
/**
|
597 |
* Transfer Shortcode Render
|
598 |
+
* @see http://mycred.me/functions/mycred_transfer_render/
|
599 |
* @attribute $charge_from (int) optional user ID from whom the points to be deducted, defaults to current user
|
600 |
* @attribute $pay_to (int) optional user ID to whom the transfer is made, if left empty the user will be able to search for a user
|
601 |
* @attribute $show_balance (bool) set to true to show current users balance, defaults to true
|
732 |
|
733 |
/**
|
734 |
* User Can Transfer
|
735 |
+
* @see http://mycred.me/functions/mycred_user_can_transfer/
|
736 |
* @param $user_id (int) requred user id
|
737 |
* @param $amount (int) optional amount to check against balance
|
738 |
* @returns true if no limit is set, 'limit' (string) if user is over limit else the amount of creds left
|
742 |
* @version 1.1
|
743 |
*/
|
744 |
if ( !function_exists( 'mycred_user_can_transfer' ) ) {
|
745 |
+
function mycred_user_can_transfer( $user_id, $amount = NULL )
|
746 |
{
|
747 |
if ( $user_id === NULL ) $user_id = get_current_user_id();
|
748 |
|
753 |
$balance = $mycred->get_users_cred( $user_id );
|
754 |
|
755 |
// To low balance
|
756 |
+
$account_limit = (int) apply_filters( 'mycred_transfer_acc_limit', 0 );
|
757 |
+
if ( $amount !== NULL ) {
|
758 |
+
if ( $balance-$amount < $account_limit ) return 'low';
|
759 |
+
} else {
|
760 |
+
if ( $balance <= $account_limit ) return 'low';
|
761 |
+
}
|
762 |
|
763 |
// No limits imposed
|
764 |
if ( $set_limit == 'none' ) return true;
|
includes/mycred-functions.php
CHANGED
@@ -848,7 +848,7 @@ if ( !function_exists( 'mycred_is_admin' ) ) {
|
|
848 |
* Exclude User
|
849 |
* Checks if a given user is excluded from using myCRED.
|
850 |
*
|
851 |
-
* @see http://mycred.
|
852 |
* @param $user_id (int), optional user to check, defaults to current user
|
853 |
* @since 0.1
|
854 |
* @version 1.0
|
@@ -909,7 +909,7 @@ if ( !function_exists( 'mycred_get_users_fcred' ) ) {
|
|
909 |
* Important! This function will not check if the user should be excluded from gaining points, this must
|
910 |
* be done before calling this function!
|
911 |
*
|
912 |
-
* @see http://mycred.
|
913 |
* @param $ref (string), required reference id
|
914 |
* @param $user_id (int), required id of the user who will get these points
|
915 |
* @param $amount (int|float), required number of creds to give or deduct from the given user.
|
@@ -936,7 +936,7 @@ if ( !function_exists( 'mycred_add' ) ) {
|
|
936 |
/**
|
937 |
* Subtract Creds
|
938 |
* Subtracts creds from a given user. Works just as mycred_add() but the creds are converted into a negative value.
|
939 |
-
* @see http://mycred.
|
940 |
* @uses mycred_add()
|
941 |
* @since 0.1
|
942 |
* @version 1.0
|
@@ -949,4 +949,49 @@ if ( !function_exists( 'mycred_subtract' ) ) {
|
|
949 |
return mycred_add( $ref, $user_id, $amount, $entry, $ref_id, $data, $type );
|
950 |
}
|
951 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
952 |
?>
|
848 |
* Exclude User
|
849 |
* Checks if a given user is excluded from using myCRED.
|
850 |
*
|
851 |
+
* @see http://mycred.me/functions/mycred_exclude_user/
|
852 |
* @param $user_id (int), optional user to check, defaults to current user
|
853 |
* @since 0.1
|
854 |
* @version 1.0
|
909 |
* Important! This function will not check if the user should be excluded from gaining points, this must
|
910 |
* be done before calling this function!
|
911 |
*
|
912 |
+
* @see http://mycred.me/functions/mycred_add/
|
913 |
* @param $ref (string), required reference id
|
914 |
* @param $user_id (int), required id of the user who will get these points
|
915 |
* @param $amount (int|float), required number of creds to give or deduct from the given user.
|
936 |
/**
|
937 |
* Subtract Creds
|
938 |
* Subtracts creds from a given user. Works just as mycred_add() but the creds are converted into a negative value.
|
939 |
+
* @see http://mycred.me/functions/mycred_subtract/
|
940 |
* @uses mycred_add()
|
941 |
* @since 0.1
|
942 |
* @version 1.0
|
949 |
return mycred_add( $ref, $user_id, $amount, $entry, $ref_id, $data, $type );
|
950 |
}
|
951 |
}
|
952 |
+
|
953 |
+
/**
|
954 |
+
* My Balance Shortcode
|
955 |
+
* Returns the current users balance.
|
956 |
+
* @see http://mycred.me/shortcodes/mycred_my_balance/
|
957 |
+
* @since 1.0.9
|
958 |
+
* @version 1.0
|
959 |
+
*/
|
960 |
+
if ( !function_exists( 'mycred_render_my_balance' ) ) {
|
961 |
+
function mycred_render_my_balance( $atts )
|
962 |
+
{
|
963 |
+
extract( shortcode_atts( array(
|
964 |
+
'login' => NULL,
|
965 |
+
'title' => '',
|
966 |
+
'title_el' => 'h1',
|
967 |
+
'balance_el' => 'div'
|
968 |
+
), $atts ) );
|
969 |
+
|
970 |
+
// Not logged in
|
971 |
+
if ( !is_user_logged_in() ) {
|
972 |
+
if ( $login != NULL )
|
973 |
+
return '<div class="mycred-not-logged-in">' . $login . '</div>';
|
974 |
+
|
975 |
+
return;
|
976 |
+
}
|
977 |
+
|
978 |
+
$user_id = get_current_user_id();
|
979 |
+
$mycred = mycred_get_settings();
|
980 |
+
if ( $mycred->exclude_user( $user_id ) ) return;
|
981 |
+
|
982 |
+
$output = '<div class="mycred-my-balance-wrapper">';
|
983 |
+
|
984 |
+
// Title
|
985 |
+
if ( !empty( $title ) ) {
|
986 |
+
$output .= '<' . $title_el . '>' . $title . '</' . $title_el . '>';
|
987 |
+
}
|
988 |
+
|
989 |
+
// Balance
|
990 |
+
$balance = $mycred->get_users_cred( $user_id );
|
991 |
+
$output .= '<' . $balance_el . '>' . $mycred->format_creds( $balance ) . '</' . $balance_el . '>';
|
992 |
+
$output .= '</div>';
|
993 |
+
|
994 |
+
return $output;
|
995 |
+
}
|
996 |
+
}
|
997 |
?>
|
modules/mycred-module-hooks.php
CHANGED
@@ -1199,13 +1199,14 @@ if ( !class_exists( 'myCRED_Hook_BadgeOS' ) && class_exists( 'BadgeOS' ) ) {
|
|
1199 |
|
1200 |
// Prep Achievement Data
|
1201 |
$prefs = $this->prefs;
|
|
|
1202 |
$achievement_data = get_post_meta( $post->ID, '_mycred_values', true );
|
1203 |
if ( empty( $achievement_data ) )
|
1204 |
$achievement_data = $prefs[$post->post_type]; ?>
|
1205 |
|
1206 |
-
<p><strong><?php
|
1207 |
<p>
|
1208 |
-
<label class="screen-reader-text" for="mycred-values-creds"><?php
|
1209 |
<input type="text" name="mycred_values[creds]" id="mycred-values-creds" value="<?php echo $achievement_data['creds']; ?>" size="8" />
|
1210 |
<span class="description"><?php _e( 'Use zero to disable', 'mycred' ); ?></span>
|
1211 |
</p>
|
@@ -1284,30 +1285,21 @@ if ( !class_exists( 'myCRED_Hook_BadgeOS' ) && class_exists( 'BadgeOS' ) ) {
|
|
1284 |
// Settings are not set
|
1285 |
if ( !isset( $this->prefs[$post_type]['creds'] ) ) return;
|
1286 |
|
1287 |
-
//
|
1288 |
$achievement_data = get_post_meta( $achievement_id, '_mycred_values', true );
|
1289 |
-
if ( empty( $achievement_data )
|
1290 |
-
|
1291 |
|
1292 |
-
//
|
1293 |
-
if ( $
|
1294 |
-
$creds = $this->prefs[$post_type]['creds'];
|
1295 |
-
else
|
1296 |
-
$creds = $achievement_data['creds'];
|
1297 |
-
|
1298 |
-
// Log Template
|
1299 |
-
if ( $this->prefs[$post_type]['log'] == $achievement_data['log'] )
|
1300 |
-
$entry = $this->prefs[$post_type]['log'];
|
1301 |
-
else
|
1302 |
-
$entry = $achievement_data['log'];
|
1303 |
|
1304 |
// Execute
|
1305 |
$post_type_object = get_post_type_object( $post_type );
|
1306 |
$this->core->add_creds(
|
1307 |
$post_type_object->labels->name,
|
1308 |
$user_id,
|
1309 |
-
$creds,
|
1310 |
-
$
|
1311 |
$post_type,
|
1312 |
array( 'ref_type' => 'post' )
|
1313 |
);
|
@@ -1321,33 +1313,24 @@ if ( !class_exists( 'myCRED_Hook_BadgeOS' ) && class_exists( 'BadgeOS' ) ) {
|
|
1321 |
*/
|
1322 |
public function revoke_achievement( $user_id, $achievement_id ) {
|
1323 |
$post_type = get_post_type( $achievement_id );
|
1324 |
-
//
|
1325 |
-
if ( !isset( $this->prefs[$post_type]['
|
1326 |
|
1327 |
-
//
|
1328 |
$achievement_data = get_post_meta( $achievement_id, '_mycred_values', true );
|
1329 |
-
if ( empty( $achievement_data )
|
1330 |
-
|
1331 |
-
|
1332 |
-
// Creds
|
1333 |
-
if ( $this->prefs[$post_type]['creds'] == $achievement_data['creds'] )
|
1334 |
-
$creds = 0-$this->prefs[$post_type]['creds'];
|
1335 |
-
else
|
1336 |
-
$creds = 0-$achievement_data['creds'];
|
1337 |
|
1338 |
-
//
|
1339 |
-
if ( $
|
1340 |
-
$entry = $this->prefs[$post_type]['deduct_log'];
|
1341 |
-
else
|
1342 |
-
$entry = $achievement_data['deduct_log'];
|
1343 |
|
1344 |
// Execute
|
1345 |
$post_type_object = get_post_type_object( $post_type );
|
1346 |
$this->core->add_creds(
|
1347 |
$post_type_object->labels->name,
|
1348 |
$user_id,
|
1349 |
-
|
1350 |
-
$
|
1351 |
$post_type,
|
1352 |
array( 'ref_type' => 'post' )
|
1353 |
);
|
1199 |
|
1200 |
// Prep Achievement Data
|
1201 |
$prefs = $this->prefs;
|
1202 |
+
$mycred = mycred_get_settings();
|
1203 |
$achievement_data = get_post_meta( $post->ID, '_mycred_values', true );
|
1204 |
if ( empty( $achievement_data ) )
|
1205 |
$achievement_data = $prefs[$post->post_type]; ?>
|
1206 |
|
1207 |
+
<p><strong><?php echo $mycred->template_tags_general( __( '%plural% to Award', 'mycred' ) ); ?></strong></p>
|
1208 |
<p>
|
1209 |
+
<label class="screen-reader-text" for="mycred-values-creds"><?php echo $mycred->template_tags_general( __( '%plural% to Award', 'mycred' ) ); ?></label>
|
1210 |
<input type="text" name="mycred_values[creds]" id="mycred-values-creds" value="<?php echo $achievement_data['creds']; ?>" size="8" />
|
1211 |
<span class="description"><?php _e( 'Use zero to disable', 'mycred' ); ?></span>
|
1212 |
</p>
|
1285 |
// Settings are not set
|
1286 |
if ( !isset( $this->prefs[$post_type]['creds'] ) ) return;
|
1287 |
|
1288 |
+
// Get achievemen data
|
1289 |
$achievement_data = get_post_meta( $achievement_id, '_mycred_values', true );
|
1290 |
+
if ( empty( $achievement_data ) )
|
1291 |
+
$achievement_data = $this->prefs[$post_type];
|
1292 |
|
1293 |
+
// Make sure its not disabled
|
1294 |
+
if ( $achievement_data['creds'] == 0 ) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1295 |
|
1296 |
// Execute
|
1297 |
$post_type_object = get_post_type_object( $post_type );
|
1298 |
$this->core->add_creds(
|
1299 |
$post_type_object->labels->name,
|
1300 |
$user_id,
|
1301 |
+
$achievement_data['creds'],
|
1302 |
+
$achievement_data['log'],
|
1303 |
$post_type,
|
1304 |
array( 'ref_type' => 'post' )
|
1305 |
);
|
1313 |
*/
|
1314 |
public function revoke_achievement( $user_id, $achievement_id ) {
|
1315 |
$post_type = get_post_type( $achievement_id );
|
1316 |
+
// Settings are not set
|
1317 |
+
if ( !isset( $this->prefs[$post_type]['creds'] ) ) return;
|
1318 |
|
1319 |
+
// Get achievemen data
|
1320 |
$achievement_data = get_post_meta( $achievement_id, '_mycred_values', true );
|
1321 |
+
if ( empty( $achievement_data ) )
|
1322 |
+
$achievement_data = $this->prefs[$post_type];
|
|
|
|
|
|
|
|
|
|
|
|
|
1323 |
|
1324 |
+
// Make sure its not disabled
|
1325 |
+
if ( $achievement_data['creds'] == 0 ) return;
|
|
|
|
|
|
|
1326 |
|
1327 |
// Execute
|
1328 |
$post_type_object = get_post_type_object( $post_type );
|
1329 |
$this->core->add_creds(
|
1330 |
$post_type_object->labels->name,
|
1331 |
$user_id,
|
1332 |
+
0-$achievement_data['creds'],
|
1333 |
+
$achievement_data['log'],
|
1334 |
$post_type,
|
1335 |
array( 'ref_type' => 'post' )
|
1336 |
);
|
modules/mycred-module-log.php
CHANGED
@@ -457,12 +457,13 @@ if ( !class_exists( 'myCRED_Log' ) ) {
|
|
457 |
'user_id' => NULL,
|
458 |
'number' => NULL,
|
459 |
'time' => NULL,
|
|
|
460 |
'show_user' => false,
|
461 |
'login' => ''
|
462 |
), $atts ) );
|
463 |
|
464 |
// If we are not logged in
|
465 |
-
if ( !is_user_logged_in() ) return '<p class="mycred-history login">' . $login . '</p>';
|
466 |
|
467 |
if ( $user_id === NULL )
|
468 |
$user_id = get_current_user_id();
|
@@ -485,9 +486,7 @@ if ( !class_exists( 'myCRED_Log' ) ) {
|
|
485 |
if ( $show_user !== true )
|
486 |
unset( $log->headers['column-username'] );
|
487 |
|
488 |
-
|
489 |
-
|
490 |
-
return $output;
|
491 |
}
|
492 |
}
|
493 |
}
|
457 |
'user_id' => NULL,
|
458 |
'number' => NULL,
|
459 |
'time' => NULL,
|
460 |
+
'ref' => NULL,
|
461 |
'show_user' => false,
|
462 |
'login' => ''
|
463 |
), $atts ) );
|
464 |
|
465 |
// If we are not logged in
|
466 |
+
if ( !is_user_logged_in() && !empty( $login ) ) return '<p class="mycred-history login">' . $login . '</p>';
|
467 |
|
468 |
if ( $user_id === NULL )
|
469 |
$user_id = get_current_user_id();
|
486 |
if ( $show_user !== true )
|
487 |
unset( $log->headers['column-username'] );
|
488 |
|
489 |
+
return $log->get_display();
|
|
|
|
|
490 |
}
|
491 |
}
|
492 |
}
|
mycred.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: myCRED
|
4 |
-
Plugin URI: http://mycred.
|
5 |
Description: <strong>my</strong>CRED is an adaptive points management system for WordPress powered websites, giving you full control on how points are gained, used, traded, managed, logged or presented.
|
6 |
-
Version: 1.0.
|
7 |
Tags: points, tokens, credit, management, reward, charge
|
8 |
Author: Gabriel S Merovingi
|
9 |
Author URI: http://www.merovingi.com
|
@@ -13,7 +13,7 @@ Tested up to: WP 3.5.1
|
|
13 |
License: GPLv2 or later
|
14 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
15 |
*/
|
16 |
-
define( 'myCRED_VERSION', '1.0.
|
17 |
define( 'myCRED_SLUG', 'mycred' );
|
18 |
|
19 |
define( 'myCRED_THIS', __FILE__ );
|
@@ -27,7 +27,7 @@ define( 'myCRED_MODULES_DIR', myCRED_ROOT_DIR . 'modules/' );
|
|
27 |
|
28 |
/**
|
29 |
* myCRED_Core class
|
30 |
-
* @see http://mycred.
|
31 |
* @since 0.1
|
32 |
* @version 1.0
|
33 |
*/
|
@@ -284,6 +284,7 @@ if ( !class_exists( 'myCRED_Core' ) ) {
|
|
284 |
|
285 |
// Ranking shortcode
|
286 |
add_shortcode( 'mycred_leaderboard', 'mycred_render_leaderboard' );
|
|
|
287 |
|
288 |
// Let others play
|
289 |
do_action( 'mycred_init' );
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: myCRED
|
4 |
+
Plugin URI: http://mycred.me
|
5 |
Description: <strong>my</strong>CRED is an adaptive points management system for WordPress powered websites, giving you full control on how points are gained, used, traded, managed, logged or presented.
|
6 |
+
Version: 1.0.9
|
7 |
Tags: points, tokens, credit, management, reward, charge
|
8 |
Author: Gabriel S Merovingi
|
9 |
Author URI: http://www.merovingi.com
|
13 |
License: GPLv2 or later
|
14 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
15 |
*/
|
16 |
+
define( 'myCRED_VERSION', '1.0.9' );
|
17 |
define( 'myCRED_SLUG', 'mycred' );
|
18 |
|
19 |
define( 'myCRED_THIS', __FILE__ );
|
27 |
|
28 |
/**
|
29 |
* myCRED_Core class
|
30 |
+
* @see http://mycred.me/classes/mycred_core/
|
31 |
* @since 0.1
|
32 |
* @version 1.0
|
33 |
*/
|
284 |
|
285 |
// Ranking shortcode
|
286 |
add_shortcode( 'mycred_leaderboard', 'mycred_render_leaderboard' );
|
287 |
+
add_shortcode( 'mycred_my_balance', 'mycred_render_my_balance' );
|
288 |
|
289 |
// Let others play
|
290 |
do_action( 'mycred_init' );
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate Link: http://mycred.me/donate/
|
|
4 |
Tags:points, tokens, credit, management, reward, charge, community, BuddyPress, Jetpack
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -122,6 +122,15 @@ Yes but if one of them is bought, all is shown. The mycred_sell_this shortcode w
|
|
122 |
|
123 |
== Changelog ==
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
= 1.0.8 =
|
126 |
* Added BuddyPress tag to description
|
127 |
* Adjusted plugin for new website mycred.me
|
4 |
Tags:points, tokens, credit, management, reward, charge, community, BuddyPress, Jetpack
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 1.0.9
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
122 |
|
123 |
== Changelog ==
|
124 |
|
125 |
+
= 1.0.9 =
|
126 |
+
* Adjusted plugin URLs in files that were missed previously.
|
127 |
+
* Fixed Bug #16 - PHP Notice when using the `mycred_history` shortcode.
|
128 |
+
|
129 |
+
* Request #9 - Remove paragraph element for not logged in users if the login message is set to blank.
|
130 |
+
* Request #10 - Added new `mycred_my_balance` shortcode to display current users balance.
|
131 |
+
* Request #11 - Added new `mycred_sales_history` shortcode to the Sell Content Add-on to show all content purchased by the current user.
|
132 |
+
* Request #12 - Add reference search to the `mycred_history` shortcode.
|
133 |
+
|
134 |
= 1.0.8 =
|
135 |
* Added BuddyPress tag to description
|
136 |
* Adjusted plugin for new website mycred.me
|