Version Description
Bug fixes for 1.7
=
Download this release
Release Info
Developer | designbymerovingi |
Plugin | myCRED |
Version | 1.7.3 |
Comparing to | |
See all releases |
Code changes from version 1.7.2 to 1.7.3
- addons/buy-creds/modules/buycred-module-core.php +133 -61
- addons/email-notices/myCRED-addon-email-notices.php +11 -3
- addons/ranks/includes/mycred-rank-functions.php +12 -9
- addons/ranks/includes/mycred-rank-shortcodes.php +1 -12
- addons/ranks/myCRED-addon-ranks.php +58 -27
- addons/sell-content/myCRED-addon-sell-content.php +84 -12
- addons/transfer/assets/js/mycred-transfer.js +8 -2
- addons/transfer/includes/mycred-transfer-shortcodes.php +14 -12
- addons/transfer/myCRED-addon-transfer.php +6 -5
- assets/css/mycred-edit-balance.css +42 -6
- assets/js/links.js +2 -1
- assets/js/mycred-edit-log.js +1 -5
- includes/classes/class.query-log.php +29 -33
- includes/mycred-functions.php +53 -0
- includes/mycred-widgets.php +6 -2
- includes/shortcodes/mycred_link.php +4 -1
- modules/mycred-module-buddypress.php +15 -28
- modules/mycred-module-hooks.php +5 -2
- modules/mycred-module-log.php +9 -5
- modules/mycred-module-management.php +155 -33
- mycred.php +2 -2
- readme.txt +23 -12
addons/buy-creds/modules/buycred-module-core.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'MYCRED_PURCHASE' ) ) exit;
|
|
4 |
/**
|
5 |
* myCRED_buyCRED_Module class
|
6 |
* @since 0.1
|
7 |
-
* @version 1.4
|
8 |
*/
|
9 |
if ( ! class_exists( 'myCRED_buyCRED_Module' ) ) :
|
10 |
class myCRED_buyCRED_Module extends myCRED_Module {
|
@@ -82,7 +82,7 @@ if ( ! class_exists( 'myCRED_buyCRED_Module' ) ) :
|
|
82 |
* Get Payment Gateways
|
83 |
* Retreivs all available payment gateways that can be used to buy CREDs.
|
84 |
* @since 0.1
|
85 |
-
* @version 1.1
|
86 |
*/
|
87 |
public function get() {
|
88 |
|
@@ -90,50 +90,56 @@ if ( ! class_exists( 'myCRED_buyCRED_Module' ) ) :
|
|
90 |
|
91 |
// PayPal Standard
|
92 |
$installed['paypal-standard'] = array(
|
93 |
-
'title'
|
94 |
-
'callback'
|
95 |
-
'icon'
|
96 |
-
'external'
|
|
|
97 |
);
|
98 |
|
99 |
// BitPay
|
100 |
$installed['bitpay'] = array(
|
101 |
-
'title'
|
102 |
-
'callback'
|
103 |
-
'icon'
|
104 |
-
'external'
|
|
|
105 |
);
|
106 |
|
107 |
// NetBilling
|
108 |
$installed['netbilling'] = array(
|
109 |
-
'title'
|
110 |
-
'callback'
|
111 |
-
'icon'
|
112 |
-
'external'
|
|
|
113 |
);
|
114 |
|
115 |
// Skrill
|
116 |
$installed['skrill'] = array(
|
117 |
-
'title'
|
118 |
-
'callback'
|
119 |
-
'icon'
|
120 |
-
'external'
|
|
|
121 |
);
|
122 |
|
123 |
// Zombaio
|
124 |
$installed['zombaio'] = array(
|
125 |
-
'title'
|
126 |
-
'callback'
|
127 |
-
'icon'
|
128 |
-
'external'
|
|
|
129 |
);
|
130 |
|
131 |
// Bank Transfers
|
132 |
$installed['bank'] = array(
|
133 |
-
'title'
|
134 |
-
'callback'
|
135 |
-
'icon'
|
136 |
-
'external'
|
|
|
137 |
);
|
138 |
|
139 |
$installed = apply_filters( 'mycred_setup_gateways', $installed );
|
@@ -141,8 +147,13 @@ if ( ! class_exists( 'myCRED_buyCRED_Module' ) ) :
|
|
141 |
// Untill all custom gateways have been updated, make sure all gateways have an external setting
|
142 |
if ( ! empty( $installed ) ) {
|
143 |
foreach ( $installed as $id => $settings ) {
|
|
|
144 |
if ( ! array_key_exists( 'external', $settings ) )
|
145 |
$installed[ $id ]['external'] = true;
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
}
|
148 |
|
@@ -1013,74 +1024,134 @@ jQuery(function($) {
|
|
1013 |
*/
|
1014 |
public function exchange_rates_user_screen( $user ) {
|
1015 |
|
|
|
|
|
|
|
1016 |
// Only visible to admins
|
1017 |
if ( ! mycred_is_admin() ) return;
|
1018 |
|
1019 |
-
$
|
|
|
|
|
|
|
1020 |
|
1021 |
-
$types = array( MYCRED_DEFAULT_TYPE_KEY );
|
1022 |
-
if ( isset( $this->core->buy_creds['types'] ) )
|
1023 |
-
$types = $this->core->buy_creds['types'];
|
1024 |
-
|
1025 |
-
$users_saved_overrides = (array) mycred_get_user_meta( $user->ID, 'mycred_buycred_rates_' . $type, '', true );
|
1026 |
-
$installed = $this->get();
|
1027 |
-
|
1028 |
-
$usable = array();
|
1029 |
foreach ( $installed as $gateway_id => $prefs ) {
|
1030 |
|
1031 |
-
|
|
|
1032 |
|
1033 |
$gateway_prefs = $this->gateway_prefs[ $gateway_id ];
|
1034 |
|
1035 |
-
|
|
|
|
|
|
|
|
|
1036 |
|
1037 |
-
$
|
1038 |
-
$usable[ $gateway_id ]['title'] = $prefs['title'];
|
1039 |
|
1040 |
-
|
1041 |
-
$users_saved_overrides[ $gateway_id ] = '';
|
1042 |
|
1043 |
-
|
|
|
|
|
1044 |
|
1045 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1046 |
|
1047 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1048 |
|
1049 |
?>
|
1050 |
-
<
|
1051 |
-
<table class="form-table
|
1052 |
<?php
|
1053 |
|
1054 |
-
foreach ( $
|
1055 |
-
|
1056 |
-
if ( ! isset( $gateway_prefs['currency'] ) )
|
1057 |
-
$gateway_prefs['currency'] = 'USD';
|
1058 |
|
1059 |
?>
|
1060 |
<tr>
|
1061 |
-
<th scope="row"><?php echo esc_attr( $
|
1062 |
<td>
|
1063 |
<fieldset id="mycred-buycred-list" class="buycred-list">
|
1064 |
<legend class="screen-reader-text"><span><?php _e( 'buyCRED Exchange Rates', 'mycred' ); ?></span></legend>
|
1065 |
<?php
|
1066 |
|
1067 |
-
foreach ( $types as $type_id ) {
|
1068 |
|
1069 |
-
|
1070 |
-
if (
|
1071 |
-
$placeholder = $this->gateway_prefs[ $gateway_id ]['exchange'][ $type_id ];
|
1072 |
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1076 |
|
1077 |
?>
|
1078 |
-
<div class="buycred-wrapper color-option
|
1079 |
-
<
|
1080 |
-
<
|
|
|
|
|
|
|
1081 |
</div>
|
1082 |
<?php
|
1083 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1084 |
}
|
1085 |
|
1086 |
?>
|
@@ -1093,6 +1164,7 @@ jQuery(function($) {
|
|
1093 |
|
1094 |
?>
|
1095 |
</table>
|
|
|
1096 |
<script type="text/javascript">
|
1097 |
jQuery(function($) {
|
1098 |
|
4 |
/**
|
5 |
* myCRED_buyCRED_Module class
|
6 |
* @since 0.1
|
7 |
+
* @version 1.4.1
|
8 |
*/
|
9 |
if ( ! class_exists( 'myCRED_buyCRED_Module' ) ) :
|
10 |
class myCRED_buyCRED_Module extends myCRED_Module {
|
82 |
* Get Payment Gateways
|
83 |
* Retreivs all available payment gateways that can be used to buy CREDs.
|
84 |
* @since 0.1
|
85 |
+
* @version 1.1.1
|
86 |
*/
|
87 |
public function get() {
|
88 |
|
90 |
|
91 |
// PayPal Standard
|
92 |
$installed['paypal-standard'] = array(
|
93 |
+
'title' => 'PayPal Payments Standard',
|
94 |
+
'callback' => array( 'myCRED_PayPal_Standard' ),
|
95 |
+
'icon' => 'dashicons-admin-generic',
|
96 |
+
'external' => true,
|
97 |
+
'custom_rate' => true
|
98 |
);
|
99 |
|
100 |
// BitPay
|
101 |
$installed['bitpay'] = array(
|
102 |
+
'title' => 'BitPay (Bitcoins)',
|
103 |
+
'callback' => array( 'myCRED_Bitpay' ),
|
104 |
+
'icon' => 'dashicons-admin-generic',
|
105 |
+
'external' => true,
|
106 |
+
'custom_rate' => true
|
107 |
);
|
108 |
|
109 |
// NetBilling
|
110 |
$installed['netbilling'] = array(
|
111 |
+
'title' => 'NETBilling',
|
112 |
+
'callback' => array( 'myCRED_NETbilling' ),
|
113 |
+
'icon' => 'dashicons-admin-generic',
|
114 |
+
'external' => true,
|
115 |
+
'custom_rate' => true
|
116 |
);
|
117 |
|
118 |
// Skrill
|
119 |
$installed['skrill'] = array(
|
120 |
+
'title' => 'Skrill (Moneybookers)',
|
121 |
+
'callback' => array( 'myCRED_Skrill' ),
|
122 |
+
'icon' => 'dashicons-admin-generic',
|
123 |
+
'external' => true,
|
124 |
+
'custom_rate' => true
|
125 |
);
|
126 |
|
127 |
// Zombaio
|
128 |
$installed['zombaio'] = array(
|
129 |
+
'title' => 'Zombaio',
|
130 |
+
'callback' => array( 'myCRED_Zombaio' ),
|
131 |
+
'icon' => 'dashicons-admin-generic',
|
132 |
+
'external' => true,
|
133 |
+
'custom_rate' => false
|
134 |
);
|
135 |
|
136 |
// Bank Transfers
|
137 |
$installed['bank'] = array(
|
138 |
+
'title' => __( 'Bank Transfer', 'mycred' ),
|
139 |
+
'callback' => array( 'myCRED_Bank_Transfer' ),
|
140 |
+
'icon' => 'dashicons-admin-generic',
|
141 |
+
'external' => false,
|
142 |
+
'custom_rate' => true
|
143 |
);
|
144 |
|
145 |
$installed = apply_filters( 'mycred_setup_gateways', $installed );
|
147 |
// Untill all custom gateways have been updated, make sure all gateways have an external setting
|
148 |
if ( ! empty( $installed ) ) {
|
149 |
foreach ( $installed as $id => $settings ) {
|
150 |
+
|
151 |
if ( ! array_key_exists( 'external', $settings ) )
|
152 |
$installed[ $id ]['external'] = true;
|
153 |
+
|
154 |
+
if ( ! array_key_exists( 'custom_rate', $settings ) )
|
155 |
+
$installed[ $id ]['custom_rate'] = false;
|
156 |
+
|
157 |
}
|
158 |
}
|
159 |
|
1024 |
*/
|
1025 |
public function exchange_rates_user_screen( $user ) {
|
1026 |
|
1027 |
+
// Make sure buyCRED is setup
|
1028 |
+
if ( ! isset( $this->core->buy_creds['types'] ) || empty( $this->core->buy_creds['types'] ) ) return;
|
1029 |
+
|
1030 |
// Only visible to admins
|
1031 |
if ( ! mycred_is_admin() ) return;
|
1032 |
|
1033 |
+
$mycred_types = mycred_get_types( true );
|
1034 |
+
$point_types_for_sale = $this->core->buy_creds['types'];
|
1035 |
+
$installed = $this->get();
|
1036 |
+
$available_options = array();
|
1037 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1038 |
foreach ( $installed as $gateway_id => $prefs ) {
|
1039 |
|
1040 |
+
// Gateway is not active or settings have not yet been saved
|
1041 |
+
if ( ! $this->is_active( $gateway_id ) || ! array_key_exists( $gateway_id, $this->gateway_prefs ) || ! $prefs['custom_rate'] ) continue;
|
1042 |
|
1043 |
$gateway_prefs = $this->gateway_prefs[ $gateway_id ];
|
1044 |
|
1045 |
+
// Need a currency
|
1046 |
+
if ( array_key_exists( 'currency', $gateway_prefs ) && $gateway_prefs['currency'] == '' ) continue;
|
1047 |
+
|
1048 |
+
if ( ! array_key_exists( 'currency', $gateway_prefs ) )
|
1049 |
+
$gateway_prefs['currency'] = 'USD';
|
1050 |
|
1051 |
+
$setup = array( 'name' => $prefs['title'], 'currency' => $gateway_prefs['currency'], 'types' => array() );
|
|
|
1052 |
|
1053 |
+
foreach ( $mycred_types as $point_type_key => $label ) {
|
|
|
1054 |
|
1055 |
+
$row = array( 'name' => $label, 'enabled' => false, 'excluded' => true, 'default' => 0, 'override' => false, 'custom' => '', 'before' => '' );
|
1056 |
+
|
1057 |
+
if ( in_array( $point_type_key, $point_types_for_sale ) && array_key_exists( $point_type_key, $gateway_prefs['exchange'] ) ) {
|
1058 |
|
1059 |
+
$row['enabled'] = true;
|
1060 |
+
|
1061 |
+
$mycred = mycred( $point_type_key );
|
1062 |
+
|
1063 |
+
if ( ! $mycred->exclude_user( $user->ID ) ) {
|
1064 |
+
|
1065 |
+
$row['excluded'] = false;
|
1066 |
+
$row['default'] = $gateway_prefs['exchange'][ $point_type_key ];
|
1067 |
+
|
1068 |
+
$row['before'] = $mycred->format_creds( 1 ) . ' = ';
|
1069 |
+
|
1070 |
+
$saved_overrides = (array) mycred_get_user_meta( $user->ID, 'mycred_buycred_rates_' . $point_type_key, '', true );
|
1071 |
+
|
1072 |
+
if ( ! empty( $saved_overrides ) && array_key_exists( $gateway_id, $saved_overrides ) ) {
|
1073 |
+
|
1074 |
+
$row['override'] = true;
|
1075 |
+
$row['custom'] = $saved_overrides[ $gateway_id ];
|
1076 |
+
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
}
|
1082 |
|
1083 |
+
$setup['types'][ $point_type_key ] = $row;
|
1084 |
+
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
$available_options[ $gateway_id ] = $setup;
|
1088 |
+
|
1089 |
+
}
|
1090 |
+
|
1091 |
+
if ( empty( $available_options ) ) return;
|
1092 |
|
1093 |
?>
|
1094 |
+
<p class="mycred-p"><?php _e( 'Users exchange rate when buying points.', 'mycred' ); ?></p>
|
1095 |
+
<table class="form-table mycred-inline-table">
|
1096 |
<?php
|
1097 |
|
1098 |
+
foreach ( $available_options as $gateway_id => $setup ) :
|
|
|
|
|
|
|
1099 |
|
1100 |
?>
|
1101 |
<tr>
|
1102 |
+
<th scope="row"><?php echo esc_attr( $setup['name'] ); ?></th>
|
1103 |
<td>
|
1104 |
<fieldset id="mycred-buycred-list" class="buycred-list">
|
1105 |
<legend class="screen-reader-text"><span><?php _e( 'buyCRED Exchange Rates', 'mycred' ); ?></span></legend>
|
1106 |
<?php
|
1107 |
|
1108 |
+
foreach ( $setup['types'] as $type_id => $data ) {
|
1109 |
|
1110 |
+
// This point type is not for sale
|
1111 |
+
if ( ! $data['enabled'] ) {
|
|
|
1112 |
|
1113 |
+
?>
|
1114 |
+
<div class="mycred-wrapper buycred-wrapper disabled-option color-option">
|
1115 |
+
<div><?php printf( _x( 'Buying %s', 'Points Name', 'mycred' ), $data['name'] ); ?></div>
|
1116 |
+
<div class="balance-row">
|
1117 |
+
<div class="balance-view"><?php _e( 'Disabled', 'mycred' ); ?></div>
|
1118 |
+
<div class="balance-desc"><em><?php _e( 'This point type is not for sale.', 'mycred' ); ?></em></div>
|
1119 |
+
</div>
|
1120 |
+
</div>
|
1121 |
+
<?php
|
1122 |
+
|
1123 |
+
}
|
1124 |
+
|
1125 |
+
// This user is excluded from this point type
|
1126 |
+
elseif ( $data['excluded'] ) {
|
1127 |
|
1128 |
?>
|
1129 |
+
<div class="mycred-wrapper buycred-wrapper excluded-option color-option">
|
1130 |
+
<div><?php printf( _x( 'Buying %s', 'Buying Points', 'mycred' ), $data['name'] ); ?></div>
|
1131 |
+
<div class="balance-row">
|
1132 |
+
<div class="balance-view"><?php _e( 'Excluded', 'mycred' ); ?></div>
|
1133 |
+
<div class="balance-desc"><em><?php printf( _x( 'User can not buy %s', 'Points Name', 'mycred' ), $data['name'] ); ?></em></div>
|
1134 |
+
</div>
|
1135 |
</div>
|
1136 |
<?php
|
1137 |
|
1138 |
+
}
|
1139 |
+
|
1140 |
+
// Eligeble user
|
1141 |
+
else {
|
1142 |
+
|
1143 |
+
?>
|
1144 |
+
<div class="mycred-wrapper buycred-wrapper color-option selected">
|
1145 |
+
<div><?php printf( _x( 'Buying %s', 'Buying Points', 'mycred' ), $data['name'] ); ?></div>
|
1146 |
+
<div class="balance-row">
|
1147 |
+
<div class="balance-view"><?php echo $data['before']; ?><input type="text" name="mycred_adjust_users_buyrates[<?php echo $type_id; ?>][<?php echo $gateway_id; ?>]" placeholder="<?php echo $data['default']; ?>" value="<?php if ( $data['override'] ) echo esc_attr( $data['custom'] ); ?>" class="short" size="8" /><?php echo ' ' . $setup['currency']; ?></div>
|
1148 |
+
<div class="balance-desc"><em><?php _e( 'Leave empty to use the default rate.', 'mycred' ); ?></em></div>
|
1149 |
+
</div>
|
1150 |
+
</div>
|
1151 |
+
<?php
|
1152 |
+
|
1153 |
+
}
|
1154 |
+
|
1155 |
}
|
1156 |
|
1157 |
?>
|
1164 |
|
1165 |
?>
|
1166 |
</table>
|
1167 |
+
<hr />
|
1168 |
<script type="text/javascript">
|
1169 |
jQuery(function($) {
|
1170 |
|
addons/email-notices/myCRED-addon-email-notices.php
CHANGED
@@ -1174,7 +1174,7 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) :
|
|
1174 |
/**
|
1175 |
* WP Mail
|
1176 |
* @since 1.1
|
1177 |
-
* @version 1.3.
|
1178 |
*/
|
1179 |
public function wp_mail( $to, $subject, $message, $headers, $attachments, $request, $email_id ) {
|
1180 |
|
@@ -1198,15 +1198,23 @@ if ( ! class_exists( 'myCRED_Email_Notice_Module' ) ) :
|
|
1198 |
$subject = $mycred->parse_template_tags( $subject, $entry );
|
1199 |
$message = $mycred->parse_template_tags( $message, $entry );
|
1200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1201 |
// Construct HTML Content
|
1202 |
if ( $this->emailnotices['use_html'] === true ) {
|
1203 |
$styling = $this->get_email_styling( $email_id );
|
1204 |
-
$message = '<html><head><title>' . $subject . '</title><style type="text/css" media="all"> ' . trim( $styling ) . '</style></head><body>' .
|
1205 |
}
|
1206 |
|
|
|
|
|
1207 |
// Send Email
|
1208 |
add_filter( 'wp_mail_content_type', array( $this, 'get_email_format' ) );
|
1209 |
-
$result
|
1210 |
remove_filter( 'wp_mail_content_type', array( $this, 'get_email_format' ) );
|
1211 |
|
1212 |
// Let others play
|
1174 |
/**
|
1175 |
* WP Mail
|
1176 |
* @since 1.1
|
1177 |
+
* @version 1.3.3
|
1178 |
*/
|
1179 |
public function wp_mail( $to, $subject, $message, $headers, $attachments, $request, $email_id ) {
|
1180 |
|
1198 |
$subject = $mycred->parse_template_tags( $subject, $entry );
|
1199 |
$message = $mycred->parse_template_tags( $message, $entry );
|
1200 |
|
1201 |
+
if ( $this->emailnotices['use_html'] === true )
|
1202 |
+
$message = wptexturize( $message );
|
1203 |
+
|
1204 |
+
$subject = apply_filters( 'mycred_email_subject_body', $subject, $filtered, $this );
|
1205 |
+
$message = apply_filters( 'mycred_email_message_body', $message, $filtered, $this );
|
1206 |
+
|
1207 |
// Construct HTML Content
|
1208 |
if ( $this->emailnotices['use_html'] === true ) {
|
1209 |
$styling = $this->get_email_styling( $email_id );
|
1210 |
+
$message = '<html><head><title>' . $subject . '</title><style type="text/css" media="all"> ' . trim( $styling ) . '</style></head><body>' . $message . '</body></html>';
|
1211 |
}
|
1212 |
|
1213 |
+
$body = apply_filters( 'mycred_email_content_body', $message, $filtered, $this );
|
1214 |
+
|
1215 |
// Send Email
|
1216 |
add_filter( 'wp_mail_content_type', array( $this, 'get_email_format' ) );
|
1217 |
+
$result = wp_mail( $filtered['to'], $subject, $body, $filtered['headers'], $filtered['attachments'] );
|
1218 |
remove_filter( 'wp_mail_content_type', array( $this, 'get_email_format' ) );
|
1219 |
|
1220 |
// Let others play
|
addons/ranks/includes/mycred-rank-functions.php
CHANGED
@@ -509,7 +509,7 @@ endif;
|
|
509 |
* @param $type (string) optional point type
|
510 |
* @returns (array) empty if no ranks are found or associative array with post ID as key and title as value
|
511 |
* @since 1.1
|
512 |
-
* @version 1.5
|
513 |
*/
|
514 |
if ( ! function_exists( 'mycred_get_ranks' ) ) :
|
515 |
function mycred_get_ranks( $status = 'publish', $number = '-1', $order = 'DESC', $point_type = NULL ) {
|
@@ -535,20 +535,23 @@ if ( ! function_exists( 'mycred_get_ranks' ) ) :
|
|
535 |
$postmeta = $wpdb->base_prefix . 'postmeta';
|
536 |
}
|
537 |
|
|
|
538 |
$type_filter = '';
|
539 |
-
if ( $point_type !== NULL && mycred_point_type_exists( sanitize_key( $point_type ) ) )
|
540 |
-
$
|
|
|
|
|
541 |
|
542 |
// Get ranks
|
543 |
$results = array();
|
544 |
$rank_ids = $wpdb->get_col( $wpdb->prepare( "
|
545 |
SELECT ranks.ID
|
546 |
FROM {$posts} ranks
|
547 |
-
{$
|
548 |
LEFT JOIN {$postmeta} min ON ( ranks.ID = min.post_id AND min.meta_key = 'mycred_rank_min' )
|
549 |
WHERE ranks.post_type = 'mycred_rank'
|
550 |
AND ranks.post_status = %s
|
551 |
-
|
552 |
ORDER BY min.meta_value+0 {$order} {$limit};", $status ) );
|
553 |
|
554 |
if ( ! empty( $rank_ids ) ) {
|
@@ -569,7 +572,7 @@ endif;
|
|
569 |
* @param $number (int) number of users to return
|
570 |
* @returns (array) empty if no users were found or associative array with user ID as key and display name as value
|
571 |
* @since 1.1
|
572 |
-
* @version 1.5
|
573 |
*/
|
574 |
if ( ! function_exists( 'mycred_get_users_of_rank' ) ) :
|
575 |
function mycred_get_users_of_rank( $rank_identifier = NULL, $number = NULL, $order = 'DESC', $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
@@ -610,10 +613,10 @@ if ( ! function_exists( 'mycred_get_users_of_rank' ) ) :
|
|
610 |
$users = $wpdb->get_results( $wpdb->prepare( "
|
611 |
SELECT users.*, creds.meta_value AS balance
|
612 |
FROM {$wpdb->users} users
|
613 |
-
LEFT JOIN {$wpdb->usermeta} rank ON ( users.ID = rank.user_id AND rank.meta_key = %s
|
614 |
-
LEFT JOIN {$wpdb->usermeta} creds ON ( users.ID = creds.user_id AND creds.meta_key = %s
|
615 |
WHERE rank.meta_value = %d
|
616 |
-
ORDER BY creds.meta_value+0 {$order} {$limit}", $rank_meta_key, $balance_key ) );
|
617 |
|
618 |
return apply_filters( 'mycred_get_users_of_rank', $users, $rank_id, $number, $order, $point_type );
|
619 |
|
509 |
* @param $type (string) optional point type
|
510 |
* @returns (array) empty if no ranks are found or associative array with post ID as key and title as value
|
511 |
* @since 1.1
|
512 |
+
* @version 1.5.2
|
513 |
*/
|
514 |
if ( ! function_exists( 'mycred_get_ranks' ) ) :
|
515 |
function mycred_get_ranks( $status = 'publish', $number = '-1', $order = 'DESC', $point_type = NULL ) {
|
535 |
$postmeta = $wpdb->base_prefix . 'postmeta';
|
536 |
}
|
537 |
|
538 |
+
$type_join = '';
|
539 |
$type_filter = '';
|
540 |
+
if ( $point_type !== NULL && mycred_point_type_exists( sanitize_key( $point_type ) ) ) {
|
541 |
+
$type_join = "LEFT JOIN {$postmeta} ctype ON ( ranks.ID = ctype.post_id AND ctype.meta_key = 'ctype' )";
|
542 |
+
$type_filter = $wpdb->prepare( "AND ctype.meta_value = %s", $point_type );
|
543 |
+
}
|
544 |
|
545 |
// Get ranks
|
546 |
$results = array();
|
547 |
$rank_ids = $wpdb->get_col( $wpdb->prepare( "
|
548 |
SELECT ranks.ID
|
549 |
FROM {$posts} ranks
|
550 |
+
{$type_join}
|
551 |
LEFT JOIN {$postmeta} min ON ( ranks.ID = min.post_id AND min.meta_key = 'mycred_rank_min' )
|
552 |
WHERE ranks.post_type = 'mycred_rank'
|
553 |
AND ranks.post_status = %s
|
554 |
+
{$type_filter}
|
555 |
ORDER BY min.meta_value+0 {$order} {$limit};", $status ) );
|
556 |
|
557 |
if ( ! empty( $rank_ids ) ) {
|
572 |
* @param $number (int) number of users to return
|
573 |
* @returns (array) empty if no users were found or associative array with user ID as key and display name as value
|
574 |
* @since 1.1
|
575 |
+
* @version 1.5.1
|
576 |
*/
|
577 |
if ( ! function_exists( 'mycred_get_users_of_rank' ) ) :
|
578 |
function mycred_get_users_of_rank( $rank_identifier = NULL, $number = NULL, $order = 'DESC', $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
|
613 |
$users = $wpdb->get_results( $wpdb->prepare( "
|
614 |
SELECT users.*, creds.meta_value AS balance
|
615 |
FROM {$wpdb->users} users
|
616 |
+
LEFT JOIN {$wpdb->usermeta} rank ON ( users.ID = rank.user_id AND rank.meta_key = %s )
|
617 |
+
LEFT JOIN {$wpdb->usermeta} creds ON ( users.ID = creds.user_id AND creds.meta_key = %s )
|
618 |
WHERE rank.meta_value = %d
|
619 |
+
ORDER BY creds.meta_value+0 {$order} {$limit}", $rank_meta_key, $balance_key, $rank_id ) );
|
620 |
|
621 |
return apply_filters( 'mycred_get_users_of_rank', $users, $rank_id, $number, $order, $point_type );
|
622 |
|
addons/ranks/includes/mycred-rank-shortcodes.php
CHANGED
@@ -114,7 +114,7 @@ endif;
|
|
114 |
* Returns all users who have the given rank with the option to show the rank logo and optional content.
|
115 |
* @see http://mycred.me/shortcodes/mycred_users_of_rank/
|
116 |
* @since 1.1
|
117 |
-
* @version 1.1.
|
118 |
*/
|
119 |
if ( ! function_exists( 'mycred_render_users_of_rank' ) ) :
|
120 |
function mycred_render_users_of_rank( $atts, $row_template = NULL ) {
|
@@ -143,19 +143,8 @@ if ( ! function_exists( 'mycred_render_users_of_rank' ) ) :
|
|
143 |
if ( ! is_user_logged_in() && $login != '' )
|
144 |
return $mycred->template_tags_general( $login );
|
145 |
|
146 |
-
// Get rank by title
|
147 |
-
if ( ! is_numeric( $rank_id ) )
|
148 |
-
$rank = get_page_by_title( $rank_id, OBJECT, 'mycred_rank' );
|
149 |
-
|
150 |
-
// Else get rank by post ID
|
151 |
-
else
|
152 |
-
$rank = get_post( $rank_id );
|
153 |
-
|
154 |
$output = '';
|
155 |
|
156 |
-
// Make sure rank exist
|
157 |
-
if ( ! isset( $rank->ID ) ) return;
|
158 |
-
|
159 |
if ( $row_template === NULL || empty( $row_template ) )
|
160 |
$row_template = '<p class="user-row">%user_profile_link% with %balance% %_plural%</p>';
|
161 |
|
114 |
* Returns all users who have the given rank with the option to show the rank logo and optional content.
|
115 |
* @see http://mycred.me/shortcodes/mycred_users_of_rank/
|
116 |
* @since 1.1
|
117 |
+
* @version 1.1.2
|
118 |
*/
|
119 |
if ( ! function_exists( 'mycred_render_users_of_rank' ) ) :
|
120 |
function mycred_render_users_of_rank( $atts, $row_template = NULL ) {
|
143 |
if ( ! is_user_logged_in() && $login != '' )
|
144 |
return $mycred->template_tags_general( $login );
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
$output = '';
|
147 |
|
|
|
|
|
|
|
148 |
if ( $row_template === NULL || empty( $row_template ) )
|
149 |
$row_template = '<p class="user-row">%user_profile_link% with %balance% %_plural%</p>';
|
150 |
|
addons/ranks/myCRED-addon-ranks.php
CHANGED
@@ -299,12 +299,21 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
|
|
299 |
/**
|
300 |
* Replace Add New Rank URL
|
301 |
* @since 1.7
|
302 |
-
* @version 1.0
|
303 |
*/
|
304 |
public function replace_add_new_rank_url( $url, $path, $blog_id ) {
|
305 |
|
306 |
-
|
307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
return $url;
|
310 |
|
@@ -336,27 +345,35 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
|
|
336 |
/**
|
337 |
* Parent File
|
338 |
* @since 1.6
|
339 |
-
* @version 1.0.
|
340 |
*/
|
341 |
public function parent_file( $parent = '' ) {
|
342 |
|
343 |
global $pagenow;
|
344 |
|
|
|
345 |
if ( ( $pagenow == 'edit.php' || $pagenow == 'post-new.php' ) && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'mycred_rank' ) {
|
346 |
|
347 |
-
if ( isset( $_GET['ctype'] ) && $_GET['ctype'] != MYCRED_DEFAULT_TYPE_KEY )
|
348 |
-
return 'mycred_' . $_GET['ctype'];
|
349 |
-
|
350 |
-
|
351 |
|
352 |
}
|
353 |
|
|
|
354 |
elseif ( $pagenow == 'post.php' && isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == 'mycred_rank' ) {
|
355 |
|
356 |
if ( isset( $_GET['ctype'] ) && $_GET['ctype'] != MYCRED_DEFAULT_TYPE_KEY )
|
357 |
-
return 'mycred_' . $_GET['ctype'];
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
|
361 |
}
|
362 |
|
@@ -367,27 +384,35 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
|
|
367 |
/**
|
368 |
* Sub Parent File
|
369 |
* @since 1.7
|
370 |
-
* @version 1.0
|
371 |
*/
|
372 |
public function subparent_file( $subparent = '', $parent = '' ) {
|
373 |
|
374 |
global $pagenow;
|
375 |
|
|
|
376 |
if ( ( $pagenow == 'edit.php' || $pagenow == 'post-new.php' ) && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'mycred_rank' ) {
|
377 |
|
378 |
if ( isset( $_GET['ctype'] ) )
|
379 |
return 'edit.php?post_type=mycred_rank&ctype=' . $_GET['ctype'];
|
380 |
-
|
381 |
-
|
382 |
|
383 |
}
|
384 |
|
|
|
385 |
elseif ( $pagenow == 'post.php' && isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == 'mycred_rank' ) {
|
386 |
|
387 |
if ( isset( $_GET['ctype'] ) )
|
388 |
return 'edit.php?post_type=mycred_rank&ctype=' . $_GET['ctype'];
|
389 |
-
|
390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
}
|
393 |
|
@@ -857,16 +882,26 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
|
|
857 |
/**
|
858 |
* Show Rank in User Editor
|
859 |
* @since 1.7
|
860 |
-
* @version 1.
|
861 |
*/
|
862 |
-
public function show_rank_in_user_editor( $point_type, $user, $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
863 |
|
864 |
$rank = mycred_get_users_rank( $user->ID, $point_type );
|
865 |
$rank_title = '-';
|
866 |
if ( isset( $rank->title ) )
|
867 |
$rank_title = $rank->title;
|
868 |
|
869 |
-
echo '<div class="current-rank">' . sprintf( '<strong>%s:</strong> %s', __( 'Rank', 'mycred' ), $rank_title ) . '</div>';
|
870 |
|
871 |
}
|
872 |
|
@@ -875,11 +910,7 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
|
|
875 |
* @since 1.7
|
876 |
* @version 1.0
|
877 |
*/
|
878 |
-
public function scripts_and_styles() {
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
}
|
883 |
|
884 |
/**
|
885 |
* Enqueue Scripts & Styles
|
@@ -1568,7 +1599,7 @@ jQuery(function($){
|
|
1568 |
/**
|
1569 |
* Save Settings
|
1570 |
* @since 1.1
|
1571 |
-
* @version 1.3
|
1572 |
*/
|
1573 |
public function sanitize_extra_settings( $new_data, $data, $core ) {
|
1574 |
|
@@ -1580,8 +1611,8 @@ jQuery(function($){
|
|
1580 |
|
1581 |
$new_data['rank']['base'] = sanitize_text_field( $data['rank']['base'] );
|
1582 |
$new_data['rank']['public'] = ( isset( $data['rank']['public'] ) ) ? true : false;
|
1583 |
-
$new_data['rank']['slug'] = sanitize_text_field( $data['rank']['slug'] );
|
1584 |
-
$new_data['rank']['order'] = sanitize_text_field( $data['rank']['order'] );
|
1585 |
|
1586 |
$allowed_tags = $this->core->allowed_html_tags();
|
1587 |
$new_data['rank']['bb_location'] = sanitize_text_field( $data['rank']['bb_location'] );
|
299 |
/**
|
300 |
* Replace Add New Rank URL
|
301 |
* @since 1.7
|
302 |
+
* @version 1.0.1
|
303 |
*/
|
304 |
public function replace_add_new_rank_url( $url, $path, $blog_id ) {
|
305 |
|
306 |
+
global $post;
|
307 |
+
|
308 |
+
if ( $path == 'post-new.php?post_type=mycred_rank' ) {
|
309 |
+
|
310 |
+
if ( isset( $_GET['ctype'] ) )
|
311 |
+
return get_site_url( $blog_id, 'wp-admin/', 'admin' ) . 'post-new.php?post_type=mycred_rank&ctype=' . ( ( isset( $_GET['ctype'] ) ) ? $_GET['ctype'] : MYCRED_DEFAULT_TYPE_KEY );
|
312 |
+
|
313 |
+
elseif ( isset( $post->post_type ) && $post->post_type == 'mycred_rank' && get_post_meta( $post->ID, 'ctype', true ) != '' )
|
314 |
+
return get_site_url( $blog_id, 'wp-admin/', 'admin' ) . 'post-new.php?post_type=mycred_rank&ctype=' . get_post_meta( $post->ID, 'ctype', true );
|
315 |
+
|
316 |
+
}
|
317 |
|
318 |
return $url;
|
319 |
|
345 |
/**
|
346 |
* Parent File
|
347 |
* @since 1.6
|
348 |
+
* @version 1.0.2
|
349 |
*/
|
350 |
public function parent_file( $parent = '' ) {
|
351 |
|
352 |
global $pagenow;
|
353 |
|
354 |
+
// When listing ranks, we need to indicate that we are under the appropriate point type menu
|
355 |
if ( ( $pagenow == 'edit.php' || $pagenow == 'post-new.php' ) && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'mycred_rank' ) {
|
356 |
|
357 |
+
if ( isset( $_GET['ctype'] ) && sanitize_key( $_GET['ctype'] ) != MYCRED_DEFAULT_TYPE_KEY )
|
358 |
+
return 'mycred_' . sanitize_key( $_GET['ctype'] );
|
359 |
+
|
360 |
+
return 'mycred';
|
361 |
|
362 |
}
|
363 |
|
364 |
+
// When editing a rank, we need to indicate that we are under the appropriate point type menu
|
365 |
elseif ( $pagenow == 'post.php' && isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == 'mycred_rank' ) {
|
366 |
|
367 |
if ( isset( $_GET['ctype'] ) && $_GET['ctype'] != MYCRED_DEFAULT_TYPE_KEY )
|
368 |
+
return 'mycred_' . sanitize_key( $_GET['ctype'] );
|
369 |
+
|
370 |
+
$point_type = get_post_meta( $_GET['post'], 'ctype', true );
|
371 |
+
$point_type = sanitize_key( $point_type );
|
372 |
+
|
373 |
+
if ( $point_type != MYCRED_DEFAULT_TYPE_KEY )
|
374 |
+
return 'mycred_' . $point_type;
|
375 |
+
|
376 |
+
return 'mycred';
|
377 |
|
378 |
}
|
379 |
|
384 |
/**
|
385 |
* Sub Parent File
|
386 |
* @since 1.7
|
387 |
+
* @version 1.0.1
|
388 |
*/
|
389 |
public function subparent_file( $subparent = '', $parent = '' ) {
|
390 |
|
391 |
global $pagenow;
|
392 |
|
393 |
+
// When listing ranks, we need to highlight the "Ranks" submenu to indicate where we are
|
394 |
if ( ( $pagenow == 'edit.php' || $pagenow == 'post-new.php' ) && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'mycred_rank' ) {
|
395 |
|
396 |
if ( isset( $_GET['ctype'] ) )
|
397 |
return 'edit.php?post_type=mycred_rank&ctype=' . $_GET['ctype'];
|
398 |
+
|
399 |
+
return 'edit.php?post_type=mycred_rank&ctype=' . MYCRED_DEFAULT_TYPE_KEY;
|
400 |
|
401 |
}
|
402 |
|
403 |
+
// When editing a rank, we need to highlight the "Ranks" submenu to indicate where we are
|
404 |
elseif ( $pagenow == 'post.php' && isset( $_GET['post'] ) && get_post_type( $_GET['post'] ) == 'mycred_rank' ) {
|
405 |
|
406 |
if ( isset( $_GET['ctype'] ) )
|
407 |
return 'edit.php?post_type=mycred_rank&ctype=' . $_GET['ctype'];
|
408 |
+
|
409 |
+
$point_type = get_post_meta( $_GET['post'], 'ctype', true );
|
410 |
+
$point_type = sanitize_key( $point_type );
|
411 |
+
|
412 |
+
if ( $point_type != MYCRED_DEFAULT_TYPE_KEY )
|
413 |
+
return 'edit.php?post_type=mycred_rank&ctype=' . $point_type;
|
414 |
+
|
415 |
+
return 'edit.php?post_type=mycred_rank&ctype=' . MYCRED_DEFAULT_TYPE_KEY;
|
416 |
|
417 |
}
|
418 |
|
882 |
/**
|
883 |
* Show Rank in User Editor
|
884 |
* @since 1.7
|
885 |
+
* @version 1.2
|
886 |
*/
|
887 |
+
public function show_rank_in_user_editor( $point_type, $user, $data ) {
|
888 |
+
|
889 |
+
if ( $data['excluded'] ) {
|
890 |
+
echo '<div class="balance-desc current-rank">-</div>';
|
891 |
+
return;
|
892 |
+
}
|
893 |
+
|
894 |
+
if ( ! mycred_have_ranks( $point_type ) ) {
|
895 |
+
echo '<div class="balance-desc current-rank"><em>' . __( 'No ranks exists.', 'mycred' ) . '</em></div>';
|
896 |
+
return;
|
897 |
+
}
|
898 |
|
899 |
$rank = mycred_get_users_rank( $user->ID, $point_type );
|
900 |
$rank_title = '-';
|
901 |
if ( isset( $rank->title ) )
|
902 |
$rank_title = $rank->title;
|
903 |
|
904 |
+
echo '<div class="balance-desc current-rank">' . sprintf( '<strong>%s:</strong> %s', __( 'Rank', 'mycred' ), $rank_title ) . '</div>';
|
905 |
|
906 |
}
|
907 |
|
910 |
* @since 1.7
|
911 |
* @version 1.0
|
912 |
*/
|
913 |
+
public function scripts_and_styles() { }
|
|
|
|
|
|
|
|
|
914 |
|
915 |
/**
|
916 |
* Enqueue Scripts & Styles
|
1599 |
/**
|
1600 |
* Save Settings
|
1601 |
* @since 1.1
|
1602 |
+
* @version 1.3.1
|
1603 |
*/
|
1604 |
public function sanitize_extra_settings( $new_data, $data, $core ) {
|
1605 |
|
1611 |
|
1612 |
$new_data['rank']['base'] = sanitize_text_field( $data['rank']['base'] );
|
1613 |
$new_data['rank']['public'] = ( isset( $data['rank']['public'] ) ) ? true : false;
|
1614 |
+
$new_data['rank']['slug'] = ( isset( $data['rank']['slug'] ) ) ? sanitize_text_field( $data['rank']['slug'] ) : '';
|
1615 |
+
$new_data['rank']['order'] = ( isset( $data['rank']['order'] ) ) ? sanitize_text_field( $data['rank']['order'] ) : '';
|
1616 |
|
1617 |
$allowed_tags = $this->core->allowed_html_tags();
|
1618 |
$new_data['rank']['bb_location'] = sanitize_text_field( $data['rank']['bb_location'] );
|
addons/sell-content/myCRED-addon-sell-content.php
CHANGED
@@ -186,37 +186,108 @@ if ( ! class_exists( 'myCRED_Sell_Content_Module' ) ) :
|
|
186 |
/**
|
187 |
* User Level Override
|
188 |
* @since 1.5
|
189 |
-
* @version 1.
|
190 |
*/
|
191 |
public function sell_content_user_screen( $user ) {
|
192 |
|
193 |
// Only visible to admins
|
194 |
if ( ! mycred_is_admin() ) return;
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
?>
|
197 |
-
<
|
|
|
198 |
<tr>
|
199 |
-
<th scope="row"><?php _e( '
|
200 |
<td>
|
201 |
<fieldset id="mycred-badge-list" class="badge-list">
|
202 |
-
<legend class="screen-reader-text"><span><?php _e( '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
<?php
|
204 |
|
205 |
-
|
206 |
-
foreach ( $this->sell_content['type'] as $point_type ) {
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
$users_share = mycred_get_user_meta( $user->ID, 'mycred_sell_content_share_' . $point_type, '', true );
|
211 |
|
212 |
?>
|
213 |
-
<div class="
|
214 |
-
<
|
215 |
-
<
|
|
|
|
|
|
|
216 |
</div>
|
217 |
<?php
|
218 |
|
219 |
}
|
|
|
220 |
}
|
221 |
|
222 |
?>
|
@@ -224,6 +295,7 @@ if ( ! class_exists( 'myCRED_Sell_Content_Module' ) ) :
|
|
224 |
</td>
|
225 |
</tr>
|
226 |
</table>
|
|
|
227 |
<?php
|
228 |
|
229 |
}
|
186 |
/**
|
187 |
* User Level Override
|
188 |
* @since 1.5
|
189 |
+
* @version 1.3.1
|
190 |
*/
|
191 |
public function sell_content_user_screen( $user ) {
|
192 |
|
193 |
// Only visible to admins
|
194 |
if ( ! mycred_is_admin() ) return;
|
195 |
|
196 |
+
$mycred_types = mycred_get_types( true );
|
197 |
+
$available_options = array();
|
198 |
+
|
199 |
+
foreach ( $mycred_types as $point_type_key => $label ) {
|
200 |
+
|
201 |
+
$setup = array( 'name' => $label, 'enabled' => false, 'default' => 0, 'excluded' => true, 'override' => false, 'custom' => 0 );
|
202 |
+
|
203 |
+
if ( ! empty( $this->sell_content['type'] ) && in_array( $point_type_key, $this->sell_content['type'] ) ) {
|
204 |
+
|
205 |
+
$setup['enabled'] = true;
|
206 |
+
$mycred = mycred( $point_type_key );
|
207 |
+
|
208 |
+
if ( ! $mycred->exclude_user( $user->ID ) ) {
|
209 |
+
|
210 |
+
$setup['excluded'] = false;
|
211 |
+
|
212 |
+
$settings = mycred_get_option( 'mycred_sell_this_' . $point_type_key );
|
213 |
+
|
214 |
+
$setup['default'] = $settings['profit_share'];
|
215 |
+
|
216 |
+
$users_share = mycred_get_user_meta( $user->ID, 'mycred_sell_content_share_' . $point_type_key, '', true );
|
217 |
+
if ( strlen( $users_share ) > 0 ) {
|
218 |
+
|
219 |
+
$setup['override'] = true;
|
220 |
+
$setup['custom'] = $users_share;
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
}
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
$available_options[ $point_type_key ] = $setup;
|
229 |
+
|
230 |
+
}
|
231 |
+
|
232 |
+
if ( empty( $available_options ) ) return;
|
233 |
+
|
234 |
?>
|
235 |
+
<p class="mycred-p"><?php _e( 'Users profit share when their content is purchased.', 'mycred' ); ?></p>
|
236 |
+
<table class="form-table mycred-inline-table">
|
237 |
<tr>
|
238 |
+
<th scope="row"><?php _e( 'Profit Share', 'mycred' ); ?></th>
|
239 |
<td>
|
240 |
<fieldset id="mycred-badge-list" class="badge-list">
|
241 |
+
<legend class="screen-reader-text"><span><?php _e( 'Profit Share', 'mycred' ); ?></span></legend>
|
242 |
+
<?php
|
243 |
+
|
244 |
+
foreach ( $available_options as $point_type => $data ) {
|
245 |
+
|
246 |
+
// This point type is not for sale
|
247 |
+
if ( ! $data['enabled'] ) {
|
248 |
+
|
249 |
+
?>
|
250 |
+
<div class="mycred-wrapper buycred-wrapper disabled-option color-option">
|
251 |
+
<div><?php printf( _x( '%s Profit Share', 'Points Name', 'mycred' ), $data['name'] ); ?></div>
|
252 |
+
<div class="balance-row">
|
253 |
+
<div class="balance-view"><?php _e( 'Disabled', 'mycred' ); ?></div>
|
254 |
+
<div class="balance-desc"><em><?php _e( 'Not accepted as payment.', 'mycred' ); ?></em></div>
|
255 |
+
</div>
|
256 |
+
</div>
|
257 |
+
<?php
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
// This user is excluded from this point type
|
262 |
+
elseif ( $data['excluded'] ) {
|
263 |
+
|
264 |
+
?>
|
265 |
+
<div class="mycred-wrapper buycred-wrapper disabled-option color-option">
|
266 |
+
<div><?php printf( _x( '%s Profit Share', 'Points Name', 'mycred' ), $data['name'] ); ?></div>
|
267 |
+
<div class="balance-row">
|
268 |
+
<div class="balance-view"><?php _e( 'Excluded', 'mycred' ); ?></div>
|
269 |
+
<div class="balance-desc"><em><?php printf( _x( 'User can not pay using %s', 'Points Name', 'mycred' ), $data['name'] ); ?></em></div>
|
270 |
+
</div>
|
271 |
+
</div>
|
272 |
<?php
|
273 |
|
274 |
+
}
|
|
|
275 |
|
276 |
+
// Eligeble user
|
277 |
+
else {
|
|
|
278 |
|
279 |
?>
|
280 |
+
<div class="mycred-wrapper buycred-wrapper color-option selected">
|
281 |
+
<div><?php printf( _x( '%s Profit Share', 'Buying Points', 'mycred' ), $data['name'] ); ?></div>
|
282 |
+
<div class="balance-row">
|
283 |
+
<div class="balance-view"><input type="text" size="8" name="mycred_sell_this[<?php echo $point_type; ?>]" class="half" placeholder="<?php echo esc_attr( $data['default'] ); ?>" value="<?php if ( $data['override'] ) echo esc_attr( $data['custom'] ); ?>" /> %</div>
|
284 |
+
<div class="balance-desc"><em><?php _e( 'Leave empty to use the default.', 'mycred' ); ?></em></div>
|
285 |
+
</div>
|
286 |
</div>
|
287 |
<?php
|
288 |
|
289 |
}
|
290 |
+
|
291 |
}
|
292 |
|
293 |
?>
|
295 |
</td>
|
296 |
</tr>
|
297 |
</table>
|
298 |
+
<hr />
|
299 |
<?php
|
300 |
|
301 |
}
|
addons/transfer/assets/js/mycred-transfer.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* @requires jQuery UI
|
7 |
* @requires jQuery Autocomplete
|
8 |
* @since 0.1
|
9 |
-
* @version 1.5
|
10 |
*/
|
11 |
(function($) {
|
12 |
|
@@ -98,11 +98,16 @@
|
|
98 |
|
99 |
if ( response.success ) {
|
100 |
|
101 |
-
|
|
|
|
|
|
|
|
|
102 |
|
103 |
if ( $( response.data.css ) !== undefined )
|
104 |
$( response.data.css ).empty().html( response.data.balance );
|
105 |
|
|
|
106 |
$( formid + ' input.form-control' ).each(function(index){
|
107 |
$(this).val( '' );
|
108 |
});
|
@@ -113,6 +118,7 @@
|
|
113 |
selecteditem.removeAttr( 'selected' );
|
114 |
});
|
115 |
|
|
|
116 |
if ( myCREDTransfer.reload == '1' ) location.reload();
|
117 |
|
118 |
}
|
6 |
* @requires jQuery UI
|
7 |
* @requires jQuery Autocomplete
|
8 |
* @since 0.1
|
9 |
+
* @version 1.5.1
|
10 |
*/
|
11 |
(function($) {
|
12 |
|
98 |
|
99 |
if ( response.success ) {
|
100 |
|
101 |
+
// Allow customizations to present custom success messages
|
102 |
+
if ( response.data.message !== undefined && response.data.message != '' )
|
103 |
+
alert( response.data.message );
|
104 |
+
else
|
105 |
+
alert( myCREDTransfer.completed );
|
106 |
|
107 |
if ( $( response.data.css ) !== undefined )
|
108 |
$( response.data.css ).empty().html( response.data.balance );
|
109 |
|
110 |
+
// Reset form
|
111 |
$( formid + ' input.form-control' ).each(function(index){
|
112 |
$(this).val( '' );
|
113 |
});
|
118 |
selecteditem.removeAttr( 'selected' );
|
119 |
});
|
120 |
|
121 |
+
// If we require reload after submission, do so now
|
122 |
if ( myCREDTransfer.reload == '1' ) location.reload();
|
123 |
|
124 |
}
|
addons/transfer/includes/mycred-transfer-shortcodes.php
CHANGED
@@ -6,7 +6,7 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
|
6 |
* Renders a transfer form that allows users to send points to other users.
|
7 |
* @see http://mycred.me/functions/mycred_transfer_render/
|
8 |
* @since 0.1
|
9 |
-
* @version 1.6.
|
10 |
*/
|
11 |
if ( ! function_exists( 'mycred_transfer_render' ) ) :
|
12 |
function mycred_transfer_render( $atts, $content = NULL ) {
|
@@ -69,7 +69,11 @@ if ( ! function_exists( 'mycred_transfer_render' ) ) :
|
|
69 |
$available_balances = array();
|
70 |
|
71 |
// Default
|
72 |
-
if ( count( $clean ) == 1
|
|
|
|
|
|
|
|
|
73 |
|
74 |
// Make sure user is not excluded
|
75 |
if ( $mycred->exclude_user( $charge_from ) ) return '<div class="row"><div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"><p>' . $excluded . '</p></div></div>';
|
@@ -106,10 +110,10 @@ if ( ! function_exists( 'mycred_transfer_render' ) ) :
|
|
106 |
|
107 |
}
|
108 |
|
109 |
-
$available_types[ MYCRED_DEFAULT_TYPE_KEY ]
|
110 |
-
$balance_template
|
111 |
-
$balance_template
|
112 |
-
$balance_template
|
113 |
$available_balances[ MYCRED_DEFAULT_TYPE_KEY ] = $mycred->template_tags_general( $balance_template );
|
114 |
|
115 |
}
|
@@ -126,7 +130,7 @@ if ( ! function_exists( 'mycred_transfer_render' ) ) :
|
|
126 |
$status = mycred_user_can_transfer( $charge_from, $points->get_lowest_value(), $point_type, $ref );
|
127 |
if ( $status === 'low' || $status === 'limit' ) continue;
|
128 |
|
129 |
-
$balance
|
130 |
|
131 |
$available_types[ $point_type ] = $points->plural();
|
132 |
$balance_template = $pref['templates']['balance'];
|
@@ -178,11 +182,6 @@ if ( ! function_exists( 'mycred_transfer_render' ) ) :
|
|
178 |
|
179 |
}
|
180 |
|
181 |
-
// If we only use one type, we might as well reload the myCRED_Settings object
|
182 |
-
// since formating might differ
|
183 |
-
if ( count( $clean ) == 1 )
|
184 |
-
$mycred = mycred( $clean[0] );
|
185 |
-
|
186 |
// Show Balance
|
187 |
$extras = array();
|
188 |
if ( (bool) $show_balance && ! empty( $pref['templates']['balance'] ) ) {
|
@@ -239,8 +238,10 @@ if ( ! function_exists( 'mycred_transfer_render' ) ) :
|
|
239 |
<?php if ( $amount == '' ) : ?>
|
240 |
<input type="text" name="mycred_new_transfer[amount]" placeholder="<?php echo $mycred->zero(); ?>" class="form-control" value="" />
|
241 |
<?php else : ?>
|
|
|
242 |
<p class="form-control-static"><?php echo $mycred->format_creds( $amount ); ?></p>
|
243 |
<?php endif; ?>
|
|
|
244 |
</div>
|
245 |
<?php do_action( 'mycred_transfer_form_amount', $atts, $pref ); ?>
|
246 |
</div>
|
@@ -257,6 +258,7 @@ if ( ! function_exists( 'mycred_transfer_render' ) ) :
|
|
257 |
<?php if ( $amount == '' ) : ?>
|
258 |
<input type="text" name="mycred_new_transfer[amount]" placeholder="<?php echo $mycred->zero(); ?>" class="form-control" value="" />
|
259 |
<?php else : ?>
|
|
|
260 |
<p class="form-control-static"><?php echo $mycred->format_creds( $amount ); ?></p>
|
261 |
<?php endif; ?>
|
262 |
</div>
|
6 |
* Renders a transfer form that allows users to send points to other users.
|
7 |
* @see http://mycred.me/functions/mycred_transfer_render/
|
8 |
* @since 0.1
|
9 |
+
* @version 1.6.2
|
10 |
*/
|
11 |
if ( ! function_exists( 'mycred_transfer_render' ) ) :
|
12 |
function mycred_transfer_render( $atts, $content = NULL ) {
|
69 |
$available_balances = array();
|
70 |
|
71 |
// Default
|
72 |
+
if ( count( $clean ) == 1 ) {
|
73 |
+
|
74 |
+
$point_type = $clean[0];
|
75 |
+
if ( $point_type != MYCRED_DEFAULT_TYPE_KEY )
|
76 |
+
$mycred = mycred( $point_type );
|
77 |
|
78 |
// Make sure user is not excluded
|
79 |
if ( $mycred->exclude_user( $charge_from ) ) return '<div class="row"><div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"><p>' . $excluded . '</p></div></div>';
|
110 |
|
111 |
}
|
112 |
|
113 |
+
$available_types[ MYCRED_DEFAULT_TYPE_KEY ] = $mycred->plural();
|
114 |
+
$balance_template = $pref['templates']['balance'];
|
115 |
+
$balance_template = str_replace( '%cred%', '<span class="mycred-balance-' . MYCRED_DEFAULT_TYPE_KEY . '">' . $balance . '</span>', $balance_template );
|
116 |
+
$balance_template = str_replace( array( '%cred_f%', '%balance%' ), '<span class="mycred-balance-' . MYCRED_DEFAULT_TYPE_KEY . '">' . $mycred->format_creds( $balance ) . '</span>', $balance_template );
|
117 |
$available_balances[ MYCRED_DEFAULT_TYPE_KEY ] = $mycred->template_tags_general( $balance_template );
|
118 |
|
119 |
}
|
130 |
$status = mycred_user_can_transfer( $charge_from, $points->get_lowest_value(), $point_type, $ref );
|
131 |
if ( $status === 'low' || $status === 'limit' ) continue;
|
132 |
|
133 |
+
$balance = $points->get_users_balance( $charge_from );
|
134 |
|
135 |
$available_types[ $point_type ] = $points->plural();
|
136 |
$balance_template = $pref['templates']['balance'];
|
182 |
|
183 |
}
|
184 |
|
|
|
|
|
|
|
|
|
|
|
185 |
// Show Balance
|
186 |
$extras = array();
|
187 |
if ( (bool) $show_balance && ! empty( $pref['templates']['balance'] ) ) {
|
238 |
<?php if ( $amount == '' ) : ?>
|
239 |
<input type="text" name="mycred_new_transfer[amount]" placeholder="<?php echo $mycred->zero(); ?>" class="form-control" value="" />
|
240 |
<?php else : ?>
|
241 |
+
<input type="hidden" name="mycred_new_transfer[amount]" value="<?php echo $amount; ?>" />
|
242 |
<p class="form-control-static"><?php echo $mycred->format_creds( $amount ); ?></p>
|
243 |
<?php endif; ?>
|
244 |
+
<input type="hidden" name="mycred_new_transfer[ctype]" value="<?php echo $clean[0]; ?>" />
|
245 |
</div>
|
246 |
<?php do_action( 'mycred_transfer_form_amount', $atts, $pref ); ?>
|
247 |
</div>
|
258 |
<?php if ( $amount == '' ) : ?>
|
259 |
<input type="text" name="mycred_new_transfer[amount]" placeholder="<?php echo $mycred->zero(); ?>" class="form-control" value="" />
|
260 |
<?php else : ?>
|
261 |
+
<input type="hidden" name="mycred_new_transfer[amount]" value="<?php echo $amount; ?>" />
|
262 |
<p class="form-control-static"><?php echo $mycred->format_creds( $amount ); ?></p>
|
263 |
<?php endif; ?>
|
264 |
</div>
|
addons/transfer/myCRED-addon-transfer.php
CHANGED
@@ -122,7 +122,7 @@ if ( ! class_exists( 'myCRED_Transfer_Module' ) ) :
|
|
122 |
* Front Footer
|
123 |
* @filter 'mycred_transfer_messages'
|
124 |
* @since 0.1
|
125 |
-
* @version 1.2
|
126 |
*/
|
127 |
public function maybe_load_script() {
|
128 |
|
@@ -153,7 +153,8 @@ if ( ! class_exists( 'myCRED_Transfer_Module' ) ) :
|
|
153 |
'error_6' => esc_attr__( 'This myCRED Add-on has not yet been setup! No transfers are allowed until this has been done!', 'mycred' ),
|
154 |
'error_7' => esc_attr__( 'Insufficient Funds. Please try a lower amount.', 'mycred' ),
|
155 |
'error_8' => esc_attr__( 'Transfer Limit exceeded.', 'mycred' ),
|
156 |
-
'error_9' => esc_attr__( 'Communications error. Please try again later.', 'mycred' )
|
|
|
157 |
) );
|
158 |
|
159 |
wp_localize_script(
|
@@ -213,7 +214,7 @@ if ( ! class_exists( 'myCRED_Transfer_Module' ) ) :
|
|
213 |
/**
|
214 |
* AJAX Transfer Creds
|
215 |
* @since 0.1
|
216 |
-
* @version 1.6
|
217 |
*/
|
218 |
public function ajax_call_transfer() {
|
219 |
|
@@ -244,8 +245,8 @@ if ( ! class_exists( 'myCRED_Transfer_Module' ) ) :
|
|
244 |
wp_send_json_error( 'error_6' );
|
245 |
|
246 |
// Make sure we are transfering an existing point type
|
247 |
-
if ( ! mycred_point_type_exists( $request['ctype'] ) )
|
248 |
-
|
249 |
|
250 |
// Make sure we have a reference
|
251 |
if ( $request['reference'] == '' )
|
122 |
* Front Footer
|
123 |
* @filter 'mycred_transfer_messages'
|
124 |
* @since 0.1
|
125 |
+
* @version 1.2.1
|
126 |
*/
|
127 |
public function maybe_load_script() {
|
128 |
|
153 |
'error_6' => esc_attr__( 'This myCRED Add-on has not yet been setup! No transfers are allowed until this has been done!', 'mycred' ),
|
154 |
'error_7' => esc_attr__( 'Insufficient Funds. Please try a lower amount.', 'mycred' ),
|
155 |
'error_8' => esc_attr__( 'Transfer Limit exceeded.', 'mycred' ),
|
156 |
+
'error_9' => esc_attr__( 'Communications error. Please try again later.', 'mycred' ),
|
157 |
+
'error_10' => esc_attr__( 'The selected point type can not be transferred.', 'mycred' )
|
158 |
) );
|
159 |
|
160 |
wp_localize_script(
|
214 |
/**
|
215 |
* AJAX Transfer Creds
|
216 |
* @since 0.1
|
217 |
+
* @version 1.6.1
|
218 |
*/
|
219 |
public function ajax_call_transfer() {
|
220 |
|
245 |
wp_send_json_error( 'error_6' );
|
246 |
|
247 |
// Make sure we are transfering an existing point type
|
248 |
+
if ( ! mycred_point_type_exists( $request['ctype'] ) || ! in_array( $request['ctype'], $this->transfers['types'] ) )
|
249 |
+
wp_send_json_error( 'error_10' );
|
250 |
|
251 |
// Make sure we have a reference
|
252 |
if ( $request['reference'] == '' )
|
assets/css/mycred-edit-balance.css
CHANGED
@@ -32,18 +32,54 @@ body.users-php .ui-widget-overlay { position: fixed; top: 0; left: 0; width: 100
|
|
32 |
#mycred-users-mini-ledger .border { border-top: 1px solid #ddd; padding: 12px; margin: 0 0 0 0; background-color: #e8e8e8; }
|
33 |
#mycred-processing { text-align: center; min-height: 4px; width: 100%; }
|
34 |
img#mycred-token-sitting { display: none; }
|
|
|
35 |
fieldset#mycred-badge-list .badge-wrapper img { margin: 0 auto; max-width: 100px; height: auto; width: 100px; }
|
36 |
fieldset#mycred-badge-list .badge-wrapper .no-badge-image { margin: 0 auto; max-width: 100px; height: auto; width: 100px;line-height: 100px; }
|
37 |
fieldset#mycred-badge-list .badge-wrapper label { display: block; }
|
38 |
fieldset#mycred-badge-list .badge-image-wrap { text-align: center; }
|
39 |
fieldset#mycred-badge-list .badge-image-wrap h4 { margin: 0 0 0 0; }
|
40 |
fieldset#mycred-badge-list .badge-actions { text-align: center; }
|
41 |
-
.buycred-table td, .mycred-inline-table td { padding-bottom: 0; }
|
42 |
-
|
43 |
-
.balance-wrapper.color-option.selected { padding: 15px 15px 15px 15px; cursor: default; }
|
44 |
-
.balance-wrapper h2 { margin: 0 0 0 0; padding-bottom: 0; border-bottom: none; }
|
45 |
-
.balance-wrapper h4 { margin: 0 0 0 0; }
|
46 |
|
47 |
.loading-indicator { height: 5px; width: 100%; position: relative; overflow: hidden; background-color: white; }
|
48 |
.loading-indicator:before { display: block; position: absolute; content: ""; left: -200px; width: 200px; height: 5px; background-color: #c5d93d; animation: loading 2s linear infinite; }
|
49 |
-
@keyframes loading { from { left: -200px; width: 30%; } 25% { width: 50%; } 50% { width: 50%; } 70% { width: 50%; } 80% { left: 75%; } 95% { left: 100%; } to { left: 100%; } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
#mycred-users-mini-ledger .border { border-top: 1px solid #ddd; padding: 12px; margin: 0 0 0 0; background-color: #e8e8e8; }
|
33 |
#mycred-processing { text-align: center; min-height: 4px; width: 100%; }
|
34 |
img#mycred-token-sitting { display: none; }
|
35 |
+
|
36 |
fieldset#mycred-badge-list .badge-wrapper img { margin: 0 auto; max-width: 100px; height: auto; width: 100px; }
|
37 |
fieldset#mycred-badge-list .badge-wrapper .no-badge-image { margin: 0 auto; max-width: 100px; height: auto; width: 100px;line-height: 100px; }
|
38 |
fieldset#mycred-badge-list .badge-wrapper label { display: block; }
|
39 |
fieldset#mycred-badge-list .badge-image-wrap { text-align: center; }
|
40 |
fieldset#mycred-badge-list .badge-image-wrap h4 { margin: 0 0 0 0; }
|
41 |
fieldset#mycred-badge-list .badge-actions { text-align: center; }
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
.loading-indicator { height: 5px; width: 100%; position: relative; overflow: hidden; background-color: white; }
|
44 |
.loading-indicator:before { display: block; position: absolute; content: ""; left: -200px; width: 200px; height: 5px; background-color: #c5d93d; animation: loading 2s linear infinite; }
|
45 |
+
@keyframes loading { from { left: -200px; width: 30%; } 25% { width: 50%; } 50% { width: 50%; } 70% { width: 50%; } 80% { left: 75%; } 95% { left: 100%; } to { left: 100%; } }
|
46 |
+
|
47 |
+
.mycred-wrapper.color-option { width: 48%; }
|
48 |
+
p.mycred-p { margin: 12px 0 0 0; }
|
49 |
+
.mycred-inline-table { margin: 0 0 18px 0; }
|
50 |
+
.mycred-wrapper { min-height: 100px; padding: 15px !important; border: 1px solid #ddd; }
|
51 |
+
.mycred-wrapper:hover { cursor: default; }
|
52 |
+
.mycred-wrapper.disabled-option { color: #949494; }
|
53 |
+
.mycred-wrapper.disabled-option:hover { background-color: transparent; }
|
54 |
+
.mycred-wrapper .toggle-mycred-balance-editor { float: right; }
|
55 |
+
.mycred-wrapper .balance-desc { font-size: 12px; line-height: 15px; color: #949494; }
|
56 |
+
.balance-row { display: block; height: 32px; line-height: 32px; font-size: 18px; }
|
57 |
+
.balance-row > div { height: 32px; line-height: inherit; font-size: inherit; vertical-align: top; }
|
58 |
+
.balance-row .balance-edit { display: none; }
|
59 |
+
.balance-row.edit .balance-view { display: none; }
|
60 |
+
.balance-row.edit .balance-edit { display: block; }
|
61 |
+
.balance-row input { width: 100%; margin: 0 12px 0 0; }
|
62 |
+
.balance-row input.half { width: 60% !important; display: inline-block !important; margin-right: 6px; }
|
63 |
+
.balance-row input.short { width: 30% !important; display: inline-block !important; margin: 0 3px; }
|
64 |
+
#mycred-edit-user-wrapper h2 { margin: 12px 0 6px 0; }
|
65 |
+
|
66 |
+
@media screen and (max-width: 782px) {
|
67 |
+
|
68 |
+
.balance-row { display: block; height: auto; line-height: 1.5em; font-size: 18px; }
|
69 |
+
.balance-row > div { height: auto; line-height: 42px; font-size: inherit; vertical-align: top; }
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
@media screen and (max-width: 520px) {
|
74 |
+
|
75 |
+
.mycred-wrapper.color-option { width: 100%; }
|
76 |
+
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
@media screen and (min-width: 1400px) {
|
81 |
+
|
82 |
+
.mycred-wrapper.color-option { width: 24% !important; }
|
83 |
+
|
84 |
+
|
85 |
+
}
|
assets/js/links.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
* myCRED Points for Link Clicks jQuery Scripts
|
3 |
* @contributors Kevin Reeves
|
4 |
* @since 0.1
|
5 |
-
* @version 1.7
|
6 |
*/
|
7 |
jQuery(function($) {
|
8 |
|
@@ -22,6 +22,7 @@ jQuery(function($) {
|
|
22 |
url : linkdestination,
|
23 |
token : myCREDlink.token,
|
24 |
etitle : mycredlink.text(),
|
|
|
25 |
key : mycredlink.attr( 'data-token' )
|
26 |
},
|
27 |
dataType : "JSON",
|
2 |
* myCRED Points for Link Clicks jQuery Scripts
|
3 |
* @contributors Kevin Reeves
|
4 |
* @since 0.1
|
5 |
+
* @version 1.7.1
|
6 |
*/
|
7 |
jQuery(function($) {
|
8 |
|
22 |
url : linkdestination,
|
23 |
token : myCREDlink.token,
|
24 |
etitle : mycredlink.text(),
|
25 |
+
ctype : mycredlink.attr( 'data-type' ),
|
26 |
key : mycredlink.attr( 'data-token' )
|
27 |
},
|
28 |
dataType : "JSON",
|
assets/js/mycred-edit-log.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* These scripts are used to edit or delete entries
|
4 |
* in the myCRED Log.
|
5 |
* @since 1.4
|
6 |
-
* @version 1.2
|
7 |
*/
|
8 |
jQuery(function($) {
|
9 |
|
@@ -119,8 +119,6 @@ jQuery(function($) {
|
|
119 |
},
|
120 |
success : function( response ) {
|
121 |
|
122 |
-
console.log( response );
|
123 |
-
|
124 |
// Remove indicator
|
125 |
$( '#mycred-editor-indicator' ).removeClass( 'is-active' );
|
126 |
|
@@ -157,8 +155,6 @@ jQuery(function($) {
|
|
157 |
*/
|
158 |
function mycred_delete_entry( entryid ) {
|
159 |
|
160 |
-
console.log( 'Row to delete: ' + entryid );
|
161 |
-
|
162 |
var ismodalopen = myCREDEditorModal.dialog( "isOpen" );
|
163 |
var deletebutton = $( '#mycred-delete-entry-in-editor' );
|
164 |
var deletelabel = deletebutton.text();
|
3 |
* These scripts are used to edit or delete entries
|
4 |
* in the myCRED Log.
|
5 |
* @since 1.4
|
6 |
+
* @version 1.2.1
|
7 |
*/
|
8 |
jQuery(function($) {
|
9 |
|
119 |
},
|
120 |
success : function( response ) {
|
121 |
|
|
|
|
|
122 |
// Remove indicator
|
123 |
$( '#mycred-editor-indicator' ).removeClass( 'is-active' );
|
124 |
|
155 |
*/
|
156 |
function mycred_delete_entry( entryid ) {
|
157 |
|
|
|
|
|
158 |
var ismodalopen = myCREDEditorModal.dialog( "isOpen" );
|
159 |
var deletebutton = $( '#mycred-delete-entry-in-editor' );
|
160 |
var deletelabel = deletebutton.text();
|
includes/classes/class.query-log.php
CHANGED
@@ -356,7 +356,7 @@ $this->timestamps = $timestamps;
|
|
356 |
* Returns all table column headers.
|
357 |
* @filter mycred_log_column_headers
|
358 |
* @since 0.1
|
359 |
-
* @version 1.1
|
360 |
*/
|
361 |
public function table_headers() {
|
362 |
|
@@ -386,10 +386,7 @@ $this->timestamps = $timestamps;
|
|
386 |
if ( empty( $this->headers ) )
|
387 |
$headers = $columns;
|
388 |
|
389 |
-
$this->headers = apply_filters( 'mycred_log_column_headers', $headers, $this,
|
390 |
-
|
391 |
-
if ( array_key_exists( 'username', $this->headers ) && $this->args['user_id'] !== NULL )
|
392 |
-
unset( $this->headers['username'] );
|
393 |
|
394 |
}
|
395 |
|
@@ -513,7 +510,7 @@ $this->timestamps = $timestamps;
|
|
513 |
/**
|
514 |
* Filter Log options
|
515 |
* @since 0.1
|
516 |
-
* @version 1.3
|
517 |
*/
|
518 |
public function filter_options( $is_profile = false, $refs = array() ) {
|
519 |
|
@@ -541,7 +538,7 @@ $this->timestamps = $timestamps;
|
|
541 |
// Filter by user
|
542 |
if ( $this->core->can_edit_creds() && ! $is_profile && $this->num_rows > 0 ) {
|
543 |
|
544 |
-
echo '<input type="text" class="form-control" name="user" id="myCRED-user-filter" size="
|
545 |
$show = true;
|
546 |
|
547 |
}
|
@@ -550,8 +547,7 @@ $this->timestamps = $timestamps;
|
|
550 |
if ( $this->num_rows > 0 ) {
|
551 |
|
552 |
echo '<select name="order" id="myCRED-order-filter"><option value="">' . __( 'Show in order', 'mycred' ) . '</option>';
|
553 |
-
|
554 |
-
foreach ( $options as $value => $label ) {
|
555 |
|
556 |
echo '<option value="' . $value . '"';
|
557 |
if ( ! isset( $_GET['order'] ) && $value == 'DESC' ) echo ' selected="selected"';
|
@@ -621,18 +617,18 @@ $this->timestamps = $timestamps;
|
|
621 |
/**
|
622 |
* Front Pagination
|
623 |
* @since 1.7
|
624 |
-
* @version 1.0
|
625 |
*/
|
626 |
public function front_pagination( $pages_to_show = 5 ) {
|
627 |
|
628 |
if ( ! $this->have_entries() ) return;
|
629 |
|
630 |
-
$page_links
|
631 |
-
$total_pages
|
632 |
-
$current
|
633 |
|
634 |
-
$current_url
|
635 |
-
$current_url
|
636 |
|
637 |
$pages_to_show = absint( $pages_to_show );
|
638 |
if ( $pages_to_show === 0 ) $pages_to_show = 5;
|
@@ -668,7 +664,7 @@ $this->timestamps = $timestamps;
|
|
668 |
);
|
669 |
}
|
670 |
|
671 |
-
$start_from
|
672 |
if ( $current > $pages_to_show ) {
|
673 |
$diff = (int) ( $current / $pages_to_show );
|
674 |
$start_from = $pages_to_show * $diff;
|
@@ -841,7 +837,7 @@ $this->timestamps = $timestamps;
|
|
841 |
* Get Display
|
842 |
* Generates a table for our results.
|
843 |
* @since 0.1
|
844 |
-
* @version 1.1
|
845 |
*/
|
846 |
public function get_display() {
|
847 |
|
@@ -861,7 +857,7 @@ $this->timestamps = $timestamps;
|
|
861 |
foreach ( $this->headers as $col_id => $col_title ) {
|
862 |
|
863 |
$class = '';
|
864 |
-
if ( in_array( $col_id, $this->hidden_headers ) )
|
865 |
$class = ' hidden';
|
866 |
|
867 |
if ( $col_id == 'cb' )
|
@@ -882,7 +878,7 @@ $this->timestamps = $timestamps;
|
|
882 |
foreach ( $this->headers as $col_id => $col_title ) {
|
883 |
|
884 |
$class = '';
|
885 |
-
if ( in_array( $col_id, $this->hidden_headers ) )
|
886 |
$class = ' hidden';
|
887 |
|
888 |
if ( $col_id == 'cb' )
|
@@ -947,7 +943,7 @@ $this->timestamps = $timestamps;
|
|
947 |
* Generated a single entry row depending on the columns used / requested.
|
948 |
* @filter mycred_log_date
|
949 |
* @since 0.1
|
950 |
-
* @version 1.4
|
951 |
*/
|
952 |
public function get_the_entry( $log_entry, $wrap = 'td' ) {
|
953 |
|
@@ -958,7 +954,7 @@ $this->timestamps = $timestamps;
|
|
958 |
foreach ( $this->headers as $column_id => $column_name ) {
|
959 |
|
960 |
$hidden = '';
|
961 |
-
if ( in_array( $column_id, $this->hidden_headers ) )
|
962 |
$hidden = ' hidden';
|
963 |
|
964 |
$content = false;
|
@@ -1165,7 +1161,7 @@ jQuery(function($) {
|
|
1165 |
/**
|
1166 |
* Log Search
|
1167 |
* @since 0.1
|
1168 |
-
* @version 1.0.
|
1169 |
*/
|
1170 |
public function search() {
|
1171 |
|
@@ -1175,11 +1171,11 @@ jQuery(function($) {
|
|
1175 |
$serarch_string = '';
|
1176 |
|
1177 |
?>
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
<?php
|
1184 |
|
1185 |
}
|
@@ -1374,7 +1370,7 @@ endif;
|
|
1374 |
* @param $type (string) point type to filer by.
|
1375 |
* @returns total points (int|float) or error message (string)
|
1376 |
* @since 1.1.1
|
1377 |
-
* @version 1.4
|
1378 |
*/
|
1379 |
if ( ! function_exists( 'mycred_get_total_by_time' ) ) :
|
1380 |
function mycred_get_total_by_time( $from = 'today', $to = 'now', $ref = NULL, $user_id = NULL, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
@@ -1404,13 +1400,13 @@ if ( ! function_exists( 'mycred_get_total_by_time' ) ) :
|
|
1404 |
|
1405 |
// Default from start of today
|
1406 |
if ( $from == 'today' )
|
1407 |
-
$from = $now;
|
1408 |
|
1409 |
// From
|
1410 |
else {
|
1411 |
|
1412 |
$_from = strtotime( $from, $now );
|
1413 |
-
if ( $_from === false ) return 'Invalid Time ($from)';
|
1414 |
|
1415 |
$from = $_from;
|
1416 |
|
@@ -1426,9 +1422,9 @@ if ( ! function_exists( 'mycred_get_total_by_time' ) ) :
|
|
1426 |
else {
|
1427 |
|
1428 |
$_to = strtotime( $to );
|
1429 |
-
if ( $_to === false ) return 'Invalid Time ($to)';
|
1430 |
|
1431 |
-
$
|
1432 |
|
1433 |
}
|
1434 |
|
@@ -1925,7 +1921,7 @@ if ( ! function_exists( 'mycred_get_users_reference_count' ) ) :
|
|
1925 |
endif;
|
1926 |
|
1927 |
/**
|
1928 |
-
* Get Users Reference
|
1929 |
* @since 1.7
|
1930 |
* @version 1.0
|
1931 |
*/
|
356 |
* Returns all table column headers.
|
357 |
* @filter mycred_log_column_headers
|
358 |
* @since 0.1
|
359 |
+
* @version 1.1.1
|
360 |
*/
|
361 |
public function table_headers() {
|
362 |
|
386 |
if ( empty( $this->headers ) )
|
387 |
$headers = $columns;
|
388 |
|
389 |
+
$this->headers = apply_filters( 'mycred_log_column_headers', $headers, $this, $this->is_admin );
|
|
|
|
|
|
|
390 |
|
391 |
}
|
392 |
|
510 |
/**
|
511 |
* Filter Log options
|
512 |
* @since 0.1
|
513 |
+
* @version 1.3.1
|
514 |
*/
|
515 |
public function filter_options( $is_profile = false, $refs = array() ) {
|
516 |
|
538 |
// Filter by user
|
539 |
if ( $this->core->can_edit_creds() && ! $is_profile && $this->num_rows > 0 ) {
|
540 |
|
541 |
+
echo '<input type="text" class="form-control" name="user" id="myCRED-user-filter" size="22" placeholder="' . __( 'User ID, Username, Email or Nicename', 'mycred' ) . '" value="' . ( ( isset( $_GET['user'] ) ) ? $_GET['user'] : '' ) . '" /> ';
|
542 |
$show = true;
|
543 |
|
544 |
}
|
547 |
if ( $this->num_rows > 0 ) {
|
548 |
|
549 |
echo '<select name="order" id="myCRED-order-filter"><option value="">' . __( 'Show in order', 'mycred' ) . '</option>';
|
550 |
+
foreach ( array( 'ASC' => __( 'Ascending', 'mycred' ), 'DESC' => __( 'Descending', 'mycred' ) ) as $value => $label ) {
|
|
|
551 |
|
552 |
echo '<option value="' . $value . '"';
|
553 |
if ( ! isset( $_GET['order'] ) && $value == 'DESC' ) echo ' selected="selected"';
|
617 |
/**
|
618 |
* Front Pagination
|
619 |
* @since 1.7
|
620 |
+
* @version 1.0.1
|
621 |
*/
|
622 |
public function front_pagination( $pages_to_show = 5 ) {
|
623 |
|
624 |
if ( ! $this->have_entries() ) return;
|
625 |
|
626 |
+
$page_links = array();
|
627 |
+
$total_pages = $this->max_num_pages;
|
628 |
+
$current = $this->get_pagenum();
|
629 |
|
630 |
+
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
631 |
+
$current_url = str_replace( '/page/' . $current . '/', '/', $current_url );
|
632 |
|
633 |
$pages_to_show = absint( $pages_to_show );
|
634 |
if ( $pages_to_show === 0 ) $pages_to_show = 5;
|
664 |
);
|
665 |
}
|
666 |
|
667 |
+
$start_from = 1;
|
668 |
if ( $current > $pages_to_show ) {
|
669 |
$diff = (int) ( $current / $pages_to_show );
|
670 |
$start_from = $pages_to_show * $diff;
|
837 |
* Get Display
|
838 |
* Generates a table for our results.
|
839 |
* @since 0.1
|
840 |
+
* @version 1.1.1
|
841 |
*/
|
842 |
public function get_display() {
|
843 |
|
857 |
foreach ( $this->headers as $col_id => $col_title ) {
|
858 |
|
859 |
$class = '';
|
860 |
+
if ( $col_id != 'username' && in_array( $col_id, $this->hidden_headers ) )
|
861 |
$class = ' hidden';
|
862 |
|
863 |
if ( $col_id == 'cb' )
|
878 |
foreach ( $this->headers as $col_id => $col_title ) {
|
879 |
|
880 |
$class = '';
|
881 |
+
if ( $col_id != 'username' && in_array( $col_id, $this->hidden_headers ) )
|
882 |
$class = ' hidden';
|
883 |
|
884 |
if ( $col_id == 'cb' )
|
943 |
* Generated a single entry row depending on the columns used / requested.
|
944 |
* @filter mycred_log_date
|
945 |
* @since 0.1
|
946 |
+
* @version 1.4.1
|
947 |
*/
|
948 |
public function get_the_entry( $log_entry, $wrap = 'td' ) {
|
949 |
|
954 |
foreach ( $this->headers as $column_id => $column_name ) {
|
955 |
|
956 |
$hidden = '';
|
957 |
+
if ( $column_id != 'username' && in_array( $column_id, $this->hidden_headers ) )
|
958 |
$hidden = ' hidden';
|
959 |
|
960 |
$content = false;
|
1161 |
/**
|
1162 |
* Log Search
|
1163 |
* @since 0.1
|
1164 |
+
* @version 1.0.4
|
1165 |
*/
|
1166 |
public function search() {
|
1167 |
|
1171 |
$serarch_string = '';
|
1172 |
|
1173 |
?>
|
1174 |
+
<p class="search-box">
|
1175 |
+
<label class="screen-reader-text"><?php _e( 'Search Log', 'mycred' ); ?>:</label>
|
1176 |
+
<input type="search" name="s" value="<?php echo esc_attr( $serarch_string ); ?>" placeholder="<?php _e( 'search log entries', 'mycred' ); ?>" />
|
1177 |
+
<input type="submit" id="search-submit" class="button button-medium button-secondary" value="<?php _e( 'Search Log', 'mycred' ); ?>" />
|
1178 |
+
</p>
|
1179 |
<?php
|
1180 |
|
1181 |
}
|
1370 |
* @param $type (string) point type to filer by.
|
1371 |
* @returns total points (int|float) or error message (string)
|
1372 |
* @since 1.1.1
|
1373 |
+
* @version 1.4.1
|
1374 |
*/
|
1375 |
if ( ! function_exists( 'mycred_get_total_by_time' ) ) :
|
1376 |
function mycred_get_total_by_time( $from = 'today', $to = 'now', $ref = NULL, $user_id = NULL, $type = MYCRED_DEFAULT_TYPE_KEY ) {
|
1400 |
|
1401 |
// Default from start of today
|
1402 |
if ( $from == 'today' )
|
1403 |
+
$from = strtotime( 'today midnight', $now );
|
1404 |
|
1405 |
// From
|
1406 |
else {
|
1407 |
|
1408 |
$_from = strtotime( $from, $now );
|
1409 |
+
if ( $_from === false || $_from < 0 ) return 'Invalid Time ($from)';
|
1410 |
|
1411 |
$from = $_from;
|
1412 |
|
1422 |
else {
|
1423 |
|
1424 |
$_to = strtotime( $to );
|
1425 |
+
if ( $_to === false || $_to < 0 ) return 'Invalid Time ($to)';
|
1426 |
|
1427 |
+
$to = $_to;
|
1428 |
|
1429 |
}
|
1430 |
|
1921 |
endif;
|
1922 |
|
1923 |
/**
|
1924 |
+
* Get Users Reference Sum
|
1925 |
* @since 1.7
|
1926 |
* @version 1.0
|
1927 |
*/
|
includes/mycred-functions.php
CHANGED
@@ -1032,6 +1032,7 @@ if ( ! class_exists( 'myCRED_Settings' ) ) :
|
|
1032 |
*
|
1033 |
* @param $user_id (int), required user id
|
1034 |
* @param $amount (int|float), amount to add/deduct from users balance. This value must be pre-formated.
|
|
|
1035 |
* @returns the new balance.
|
1036 |
* @since 0.1
|
1037 |
* @version 1.4.2
|
@@ -1077,6 +1078,37 @@ if ( ! class_exists( 'myCRED_Settings' ) ) :
|
|
1077 |
|
1078 |
}
|
1079 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1080 |
/**
|
1081 |
* Add Creds
|
1082 |
* Adds creds to a given user. A refernece ID, user id and number of creds must be given.
|
@@ -1364,6 +1396,27 @@ if ( ! function_exists( 'mycred' ) ) :
|
|
1364 |
}
|
1365 |
endif;
|
1366 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1367 |
/**
|
1368 |
* Get Post Types
|
1369 |
* Returns an array of post types that myCRED uses.
|
1032 |
*
|
1033 |
* @param $user_id (int), required user id
|
1034 |
* @param $amount (int|float), amount to add/deduct from users balance. This value must be pre-formated.
|
1035 |
+
* @param $type (string), optional point type key to adjust instead of the current one.
|
1036 |
* @returns the new balance.
|
1037 |
* @since 0.1
|
1038 |
* @version 1.4.2
|
1078 |
|
1079 |
}
|
1080 |
|
1081 |
+
/**
|
1082 |
+
* Set users balance
|
1083 |
+
* Changes a users balance to the amount given.
|
1084 |
+
*
|
1085 |
+
* @param $user_id (int), required user id
|
1086 |
+
* @param $new_balance (int|float), amount to add/deduct from users balance. This value must be pre-formated.
|
1087 |
+
* @returns (bool) true on success or false on fail.
|
1088 |
+
* @since 1.7.3
|
1089 |
+
* @version 1.0
|
1090 |
+
*/
|
1091 |
+
public function set_users_balance( $user_id = NULL, $new_balance = NULL ) {
|
1092 |
+
|
1093 |
+
// Minimum Requirements: User id and amount can not be null
|
1094 |
+
if ( $user_id === NULL || $new_balance === NULL ) return false;
|
1095 |
+
|
1096 |
+
$type = $this->get_cred_id();
|
1097 |
+
$new_balance = $this->number( $new_balance );
|
1098 |
+
|
1099 |
+
// Update balance
|
1100 |
+
mycred_update_user_meta( $user_id, $type, '', $new_balance );
|
1101 |
+
|
1102 |
+
// Clear caches
|
1103 |
+
mycred_delete_option( 'mycred-cache-total-' . $type );
|
1104 |
+
|
1105 |
+
// Let others play
|
1106 |
+
do_action( 'mycred_set_user_balance', $user_id, $new_balance, $this );
|
1107 |
+
|
1108 |
+
return true;
|
1109 |
+
|
1110 |
+
}
|
1111 |
+
|
1112 |
/**
|
1113 |
* Add Creds
|
1114 |
* Adds creds to a given user. A refernece ID, user id and number of creds must be given.
|
1396 |
}
|
1397 |
endif;
|
1398 |
|
1399 |
+
/**
|
1400 |
+
* Get Module
|
1401 |
+
* @since 1.7.3
|
1402 |
+
* @version 1.0
|
1403 |
+
*/
|
1404 |
+
if ( ! function_exists( 'mycred_get_module' ) ) :
|
1405 |
+
function mycred_get_module( $module = '', $type = 'solo' ) {
|
1406 |
+
|
1407 |
+
global $mycred_modules;
|
1408 |
+
|
1409 |
+
if ( ! array_key_exists( $type, $mycred_modules ) )
|
1410 |
+
return false;
|
1411 |
+
|
1412 |
+
if ( ! array_key_exists( $module, $mycred_modules[ $type ] ) )
|
1413 |
+
return false;
|
1414 |
+
|
1415 |
+
return $mycred_modules[ $type ][ $module ];
|
1416 |
+
|
1417 |
+
}
|
1418 |
+
endif;
|
1419 |
+
|
1420 |
/**
|
1421 |
* Get Post Types
|
1422 |
* Returns an array of post types that myCRED uses.
|
includes/mycred-widgets.php
CHANGED
@@ -60,6 +60,7 @@ if ( ! class_exists( 'myCRED_Widget_Balance' ) ) :
|
|
60 |
echo $before_title . $instance['title'] . $after_title;
|
61 |
|
62 |
$layout = $mycred->template_tags_amount( $instance['cred_format'], $balance->current );
|
|
|
63 |
|
64 |
echo '<div class="myCRED-balance ' . esc_attr( $instance['type'] ) . '">' . $layout . '</div>';
|
65 |
|
@@ -203,7 +204,7 @@ if ( ! class_exists( 'myCRED_Widget_Balance' ) ) :
|
|
203 |
<p class="myCRED-widget-field">
|
204 |
<label for="<?php echo esc_attr( $this->get_field_id( 'cred_format' ) ); ?>"><?php _e( 'Layout', 'mycred' ); ?>:</label>
|
205 |
<input id="<?php echo esc_attr( $this->get_field_id( 'cred_format' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'cred_format' ) ); ?>" type="text" value="<?php echo esc_attr( $cred_format ); ?>" class="widefat" /><br />
|
206 |
-
<small><?php echo $mycred->available_template_tags( array( 'general', 'amount' ) ); ?></small>
|
207 |
</p>
|
208 |
|
209 |
<!-- History -->
|
@@ -474,7 +475,7 @@ endif;
|
|
474 |
/**
|
475 |
* Widget: myCRED Wallet
|
476 |
* @since 1.4
|
477 |
-
* @version 1.1
|
478 |
*/
|
479 |
if ( ! class_exists( 'myCRED_Widget_Wallet' ) ) :
|
480 |
class myCRED_Widget_Wallet extends WP_Widget {
|
@@ -519,6 +520,8 @@ if ( ! class_exists( 'myCRED_Widget_Wallet' ) ) :
|
|
519 |
// Excluded users have no balance(s)
|
520 |
if ( empty( $account->balance ) || empty( $instance['types'] ) ) return;
|
521 |
|
|
|
|
|
522 |
// Start
|
523 |
echo $before_widget;
|
524 |
|
@@ -535,6 +538,7 @@ if ( ! class_exists( 'myCRED_Widget_Wallet' ) ) :
|
|
535 |
|
536 |
$layout = $instance['row'];
|
537 |
$layout = $point_type->template_tags_amount( $layout, $balance->current );
|
|
|
538 |
$layout = str_replace( '%label%', $account->point_types[ $point_type_id ], $layout );
|
539 |
|
540 |
echo '<div class="myCRED-balance ' . esc_attr( $point_type_id ) . '">' . $layout . '</div>';
|
60 |
echo $before_title . $instance['title'] . $after_title;
|
61 |
|
62 |
$layout = $mycred->template_tags_amount( $instance['cred_format'], $balance->current );
|
63 |
+
$layout = $mycred->template_tags_user( $layout, false, wp_get_current_user() );
|
64 |
|
65 |
echo '<div class="myCRED-balance ' . esc_attr( $instance['type'] ) . '">' . $layout . '</div>';
|
66 |
|
204 |
<p class="myCRED-widget-field">
|
205 |
<label for="<?php echo esc_attr( $this->get_field_id( 'cred_format' ) ); ?>"><?php _e( 'Layout', 'mycred' ); ?>:</label>
|
206 |
<input id="<?php echo esc_attr( $this->get_field_id( 'cred_format' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'cred_format' ) ); ?>" type="text" value="<?php echo esc_attr( $cred_format ); ?>" class="widefat" /><br />
|
207 |
+
<small><?php echo $mycred->available_template_tags( array( 'general', 'amount', 'user' ) ); ?></small>
|
208 |
</p>
|
209 |
|
210 |
<!-- History -->
|
475 |
/**
|
476 |
* Widget: myCRED Wallet
|
477 |
* @since 1.4
|
478 |
+
* @version 1.1.1
|
479 |
*/
|
480 |
if ( ! class_exists( 'myCRED_Widget_Wallet' ) ) :
|
481 |
class myCRED_Widget_Wallet extends WP_Widget {
|
520 |
// Excluded users have no balance(s)
|
521 |
if ( empty( $account->balance ) || empty( $instance['types'] ) ) return;
|
522 |
|
523 |
+
$current_user = wp_get_current_user();
|
524 |
+
|
525 |
// Start
|
526 |
echo $before_widget;
|
527 |
|
538 |
|
539 |
$layout = $instance['row'];
|
540 |
$layout = $point_type->template_tags_amount( $layout, $balance->current );
|
541 |
+
$layout = $point_type->template_tags_user( $layout, false, $current_user );
|
542 |
$layout = str_replace( '%label%', $account->point_types[ $point_type_id ], $layout );
|
543 |
|
544 |
echo '<div class="myCRED-balance ' . esc_attr( $point_type_id ) . '">' . $layout . '</div>';
|
includes/shortcodes/mycred_link.php
CHANGED
@@ -12,7 +12,7 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
|
12 |
*
|
13 |
* @see http://codex.mycred.me/shortcodes/mycred_link/
|
14 |
* @since 1.1
|
15 |
-
* @version 1.2
|
16 |
*/
|
17 |
if ( ! function_exists( 'mycred_render_shortcode_link' ) ) :
|
18 |
function mycred_render_shortcode_link( $atts, $link_title = '' ) {
|
@@ -64,6 +64,9 @@ if ( ! function_exists( 'mycred_render_shortcode_link' ) ) :
|
|
64 |
}
|
65 |
}
|
66 |
|
|
|
|
|
|
|
67 |
// Only usable for members
|
68 |
if ( is_user_logged_in() ) {
|
69 |
|
12 |
*
|
13 |
* @see http://codex.mycred.me/shortcodes/mycred_link/
|
14 |
* @since 1.1
|
15 |
+
* @version 1.2.1
|
16 |
*/
|
17 |
if ( ! function_exists( 'mycred_render_shortcode_link' ) ) :
|
18 |
function mycred_render_shortcode_link( $atts, $link_title = '' ) {
|
64 |
}
|
65 |
}
|
66 |
|
67 |
+
// Add point type as a data attribute
|
68 |
+
$attr[] = 'data-type="' . $atts['ctype'] . '"';
|
69 |
+
|
70 |
// Only usable for members
|
71 |
if ( is_user_logged_in() ) {
|
72 |
|
modules/mycred-module-buddypress.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
|
4 |
/**
|
5 |
* myCRED_BuddyPress_Module class
|
6 |
* @since 0.1
|
7 |
-
* @version 1.3.
|
8 |
*/
|
9 |
if ( ! class_exists( 'myCRED_BuddyPress_Module' ) ) :
|
10 |
class myCRED_BuddyPress_Module extends myCRED_Module {
|
@@ -273,13 +273,12 @@ if ( ! class_exists( 'myCRED_BuddyPress_Module' ) ) :
|
|
273 |
/**
|
274 |
* Construct My History Page
|
275 |
* @since 0.1
|
276 |
-
* @version 1.0.
|
277 |
*/
|
278 |
public function my_history() {
|
279 |
|
280 |
add_action( 'bp_template_title', array( $this, 'my_history_title' ) );
|
281 |
add_action( 'bp_template_content', array( $this, 'my_history_screen' ) );
|
282 |
-
add_filter( 'mycred_log_column_headers', array( $this, 'columns' ), 10 );
|
283 |
add_filter( 'mycred_log_paginate_class', array( $this, 'paginate_class' ) );
|
284 |
|
285 |
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
@@ -297,18 +296,6 @@ if ( ! class_exists( 'myCRED_BuddyPress_Module' ) ) :
|
|
297 |
|
298 |
}
|
299 |
|
300 |
-
/**
|
301 |
-
* Adjust Log Columns
|
302 |
-
* @since 0.1
|
303 |
-
* @version 1.0
|
304 |
-
*/
|
305 |
-
public function columns( $columns ) {
|
306 |
-
|
307 |
-
unset( $columns['column-username'] );
|
308 |
-
return $columns;
|
309 |
-
|
310 |
-
}
|
311 |
-
|
312 |
/**
|
313 |
* My History Title
|
314 |
* @since 0.1
|
@@ -328,7 +315,7 @@ if ( ! class_exists( 'myCRED_BuddyPress_Module' ) ) :
|
|
328 |
/**
|
329 |
* My History Content
|
330 |
* @since 0.1
|
331 |
-
* @version 1.2.
|
332 |
*/
|
333 |
public function my_history_screen() {
|
334 |
|
@@ -352,14 +339,15 @@ if ( ! class_exists( 'myCRED_BuddyPress_Module' ) ) :
|
|
352 |
$args['time'] = $bp->canonical_stack['action'];
|
353 |
|
354 |
$log = new myCRED_Query_Log( $args );
|
355 |
-
|
|
|
356 |
|
357 |
ob_start();
|
358 |
|
359 |
if ( count( $mycred_types ) > 1 ) :
|
360 |
|
361 |
?>
|
362 |
-
<form action="" id="mycred-sort-cred-history-form" method="get"
|
363 |
<?php
|
364 |
|
365 |
endif;
|
@@ -526,25 +514,24 @@ if ( ! class_exists( 'myCRED_BuddyPress_Module' ) ) :
|
|
526 |
/**
|
527 |
* Sanitize Core Settings
|
528 |
* @since 0.1
|
529 |
-
* @version 1.2
|
530 |
*/
|
531 |
public function sanitize_extra_settings( $new_data, $data, $core ) {
|
532 |
|
533 |
-
$new_data['buddypress']['balance_location']
|
534 |
-
$new_data['buddypress']['visibility']['balance']
|
535 |
|
536 |
-
$new_data['buddypress']['history_location']
|
537 |
-
$new_data['buddypress']['balance_template']
|
538 |
|
539 |
$new_data['buddypress']['history_menu_title']['me'] = sanitize_text_field( $data['buddypress']['history_menu_title']['me'] );
|
540 |
$new_data['buddypress']['history_menu_title']['others'] = sanitize_text_field( $data['buddypress']['history_menu_title']['others'] );
|
541 |
-
$new_data['buddypress']['history_menu_pos'] =
|
542 |
|
543 |
-
$
|
544 |
-
$new_data['buddypress']['
|
545 |
-
$new_data['buddypress']['history_num'] = abs( $data['buddypress']['history_num'] );
|
546 |
|
547 |
-
$new_data['buddypress']['visibility']['history']
|
548 |
|
549 |
return apply_filters( 'mycred_bp_sanitize_settings', $new_data, $data, $core );
|
550 |
|
4 |
/**
|
5 |
* myCRED_BuddyPress_Module class
|
6 |
* @since 0.1
|
7 |
+
* @version 1.3.2
|
8 |
*/
|
9 |
if ( ! class_exists( 'myCRED_BuddyPress_Module' ) ) :
|
10 |
class myCRED_BuddyPress_Module extends myCRED_Module {
|
273 |
/**
|
274 |
* Construct My History Page
|
275 |
* @since 0.1
|
276 |
+
* @version 1.0.2
|
277 |
*/
|
278 |
public function my_history() {
|
279 |
|
280 |
add_action( 'bp_template_title', array( $this, 'my_history_title' ) );
|
281 |
add_action( 'bp_template_content', array( $this, 'my_history_screen' ) );
|
|
|
282 |
add_filter( 'mycred_log_paginate_class', array( $this, 'paginate_class' ) );
|
283 |
|
284 |
bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
|
296 |
|
297 |
}
|
298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
/**
|
300 |
* My History Title
|
301 |
* @since 0.1
|
315 |
/**
|
316 |
* My History Content
|
317 |
* @since 0.1
|
318 |
+
* @version 1.2.3
|
319 |
*/
|
320 |
public function my_history_screen() {
|
321 |
|
339 |
$args['time'] = $bp->canonical_stack['action'];
|
340 |
|
341 |
$log = new myCRED_Query_Log( $args );
|
342 |
+
$log->table_headers();
|
343 |
+
unset( $log->headers['username'] );
|
344 |
|
345 |
ob_start();
|
346 |
|
347 |
if ( count( $mycred_types ) > 1 ) :
|
348 |
|
349 |
?>
|
350 |
+
<form action="" id="mycred-sort-cred-history-form" method="get"><label><?php _e( 'Show:', 'mycred' ); ?></label> <?php mycred_types_select_from_dropdown( 'show-ctype', 'mycred-select-type', $type ); ?> <input type="submit" class="btn btn-large btn-primary button button-large button-primary" value="<?php _e( 'Go', 'mycred' ); ?>" /></form>
|
351 |
<?php
|
352 |
|
353 |
endif;
|
514 |
/**
|
515 |
* Sanitize Core Settings
|
516 |
* @since 0.1
|
517 |
+
* @version 1.2.1
|
518 |
*/
|
519 |
public function sanitize_extra_settings( $new_data, $data, $core ) {
|
520 |
|
521 |
+
$new_data['buddypress']['balance_location'] = sanitize_text_field( $data['buddypress']['balance_location'] );
|
522 |
+
$new_data['buddypress']['visibility']['balance'] = ( isset( $data['buddypress']['visibility']['balance'] ) ) ? true : false;
|
523 |
|
524 |
+
$new_data['buddypress']['history_location'] = sanitize_text_field( $data['buddypress']['history_location'] );
|
525 |
+
$new_data['buddypress']['balance_template'] = sanitize_text_field( $data['buddypress']['balance_template'] );
|
526 |
|
527 |
$new_data['buddypress']['history_menu_title']['me'] = sanitize_text_field( $data['buddypress']['history_menu_title']['me'] );
|
528 |
$new_data['buddypress']['history_menu_title']['others'] = sanitize_text_field( $data['buddypress']['history_menu_title']['others'] );
|
529 |
+
$new_data['buddypress']['history_menu_pos'] = absint( $data['buddypress']['history_menu_pos'] );
|
530 |
|
531 |
+
$new_data['buddypress']['history_url'] = urlencode( sanitize_text_field( $data['buddypress']['history_url'] ) );
|
532 |
+
$new_data['buddypress']['history_num'] = absint( $data['buddypress']['history_num'] );
|
|
|
533 |
|
534 |
+
$new_data['buddypress']['visibility']['history'] = ( isset( $data['buddypress']['visibility']['history'] ) ) ? true : false;
|
535 |
|
536 |
return apply_filters( 'mycred_bp_sanitize_settings', $new_data, $data, $core );
|
537 |
|
modules/mycred-module-hooks.php
CHANGED
@@ -2485,12 +2485,15 @@ if ( ! class_exists( 'myCRED_Hook_Click_Links' ) ) :
|
|
2485 |
/**
|
2486 |
* AJAX Call Handler
|
2487 |
* @since 1.1
|
2488 |
-
* @version 1.4.
|
2489 |
*/
|
2490 |
public function ajax_call_link_points() {
|
2491 |
|
2492 |
// We must be logged in
|
2493 |
-
if ( ! is_user_logged_in() )
|
|
|
|
|
|
|
2494 |
|
2495 |
// Security
|
2496 |
check_ajax_referer( 'mycred-link-points', 'token' );
|
2485 |
/**
|
2486 |
* AJAX Call Handler
|
2487 |
* @since 1.1
|
2488 |
+
* @version 1.4.2
|
2489 |
*/
|
2490 |
public function ajax_call_link_points() {
|
2491 |
|
2492 |
// We must be logged in
|
2493 |
+
if ( ! is_user_logged_in() ) return;
|
2494 |
+
|
2495 |
+
// Make sure we only handle our own point type
|
2496 |
+
if ( ! isset( $_POST['ctype'] ) || $_POST['ctype'] != $this->mycred_type ) return;
|
2497 |
|
2498 |
// Security
|
2499 |
check_ajax_referer( 'mycred-link-points', 'token' );
|
modules/mycred-module-log.php
CHANGED
@@ -4,7 +4,7 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
|
4 |
/**
|
5 |
* myCRED_Log_Module class
|
6 |
* @since 0.1
|
7 |
-
* @version 1.1.
|
8 |
*/
|
9 |
if ( ! class_exists( 'myCRED_Log_Module' ) ) :
|
10 |
class myCRED_Log_Module extends myCRED_Module {
|
@@ -177,7 +177,7 @@ if ( ! class_exists( 'myCRED_Log_Module' ) ) :
|
|
177 |
/**
|
178 |
* Update Log Entry Action
|
179 |
* @since 1.4
|
180 |
-
* @version 1.0
|
181 |
*/
|
182 |
public function action_update_log_entry() {
|
183 |
|
@@ -227,7 +227,7 @@ if ( ! class_exists( 'myCRED_Log_Module' ) ) :
|
|
227 |
global $wpdb;
|
228 |
|
229 |
// Get the current version of the entry
|
230 |
-
$log_entry = $wpdb->get_row( $wpdb->prepare( "SELECT
|
231 |
if ( ! isset( $log_entry->ref ) )
|
232 |
wp_send_json_error( array( 'message' => esc_attr__( 'Log entry not found', 'mycred' ) ) );
|
233 |
|
@@ -633,7 +633,7 @@ if ( ! class_exists( 'myCRED_Log_Module' ) ) :
|
|
633 |
/**
|
634 |
* My History Page
|
635 |
* @since 0.1
|
636 |
-
* @version 1.3
|
637 |
*/
|
638 |
public function my_history_page() {
|
639 |
|
@@ -659,7 +659,11 @@ if ( ! class_exists( 'myCRED_Log_Module' ) ) :
|
|
659 |
// Only entries for the current user
|
660 |
$search_args['user_id'] = $this->current_user_id;
|
661 |
|
662 |
-
$log
|
|
|
|
|
|
|
|
|
663 |
|
664 |
?>
|
665 |
<div class="wrap" id="myCRED-wrap">
|
4 |
/**
|
5 |
* myCRED_Log_Module class
|
6 |
* @since 0.1
|
7 |
+
* @version 1.1.2
|
8 |
*/
|
9 |
if ( ! class_exists( 'myCRED_Log_Module' ) ) :
|
10 |
class myCRED_Log_Module extends myCRED_Module {
|
177 |
/**
|
178 |
* Update Log Entry Action
|
179 |
* @since 1.4
|
180 |
+
* @version 1.0.1
|
181 |
*/
|
182 |
public function action_update_log_entry() {
|
183 |
|
227 |
global $wpdb;
|
228 |
|
229 |
// Get the current version of the entry
|
230 |
+
$log_entry = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$this->core->log_table} WHERE id = %d;", $entry_id ) );
|
231 |
if ( ! isset( $log_entry->ref ) )
|
232 |
wp_send_json_error( array( 'message' => esc_attr__( 'Log entry not found', 'mycred' ) ) );
|
233 |
|
633 |
/**
|
634 |
* My History Page
|
635 |
* @since 0.1
|
636 |
+
* @version 1.3.1
|
637 |
*/
|
638 |
public function my_history_page() {
|
639 |
|
659 |
// Only entries for the current user
|
660 |
$search_args['user_id'] = $this->current_user_id;
|
661 |
|
662 |
+
$log = new myCRED_Query_Log( $search_args );
|
663 |
+
|
664 |
+
$log->is_admin = true;
|
665 |
+
$log->table_headers();
|
666 |
+
unset( $log->headers['username'] );
|
667 |
|
668 |
?>
|
669 |
<div class="wrap" id="myCRED-wrap">
|
modules/mycred-module-management.php
CHANGED
@@ -6,7 +6,7 @@ if ( ! defined( 'myCRED_VERSION' ) ) exit;
|
|
6 |
* This module is responsible for all point management in the WordPress admin areas Users section.
|
7 |
* Replaces the mycred-admin.php file.
|
8 |
* @since 1.7
|
9 |
-
* @version 1.0
|
10 |
*/
|
11 |
if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
12 |
class myCRED_Management_Module extends myCRED_Module {
|
@@ -28,7 +28,7 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
28 |
/**
|
29 |
* Module Init
|
30 |
* @since 1.0
|
31 |
-
* @version 1.0
|
32 |
*/
|
33 |
public function module_init() {
|
34 |
|
@@ -37,7 +37,7 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
37 |
|
38 |
// Custom Columns
|
39 |
add_filter( 'manage_users_columns', array( $this, 'custom_user_column' ) );
|
40 |
-
|
41 |
|
42 |
// Sortable Column
|
43 |
add_filter( 'manage_users_sortable_columns', array( $this, 'sortable_points_column' ) );
|
@@ -45,6 +45,8 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
45 |
|
46 |
// Edit User
|
47 |
add_action( 'personal_options', array( $this, 'show_my_balance' ) );
|
|
|
|
|
48 |
|
49 |
// Editor
|
50 |
add_action( 'wp_ajax_mycred-admin-editor', array( $this, 'ajax_editor_balance_update' ) );
|
@@ -435,7 +437,7 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
435 |
* Customize User Columns Content
|
436 |
* @filter 'mycred_user_row_actions'
|
437 |
* @since 0.1
|
438 |
-
* @version 1.3.
|
439 |
*/
|
440 |
public function custom_user_column_content( $value, $column_name, $user_id ) {
|
441 |
|
@@ -443,12 +445,12 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
443 |
|
444 |
if ( ! array_key_exists( $column_name, $mycred_types ) ) return $value;
|
445 |
|
446 |
-
$mycred
|
447 |
|
448 |
// User is excluded
|
449 |
if ( $mycred->exclude_user( $user_id ) === true ) return __( 'Excluded', 'mycred' );
|
450 |
|
451 |
-
$user
|
452 |
|
453 |
// Show balance
|
454 |
$ubalance = $mycred->get_users_balance( $user_id, $column_name );
|
@@ -460,7 +462,7 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
460 |
|
461 |
$balance = apply_filters( 'mycred_users_balance_column', $balance, $user_id, $column_name );
|
462 |
|
463 |
-
$page
|
464 |
if ( $column_name != MYCRED_DEFAULT_TYPE_KEY )
|
465 |
$page .= '_' . $column_name;
|
466 |
|
@@ -469,7 +471,7 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
469 |
$row['history'] = '<a href="' . esc_url( admin_url( 'admin.php?page=' . $page . '&user=' . $user_id ) ) . '">' . __( 'History', 'mycred' ) . '</a>';
|
470 |
$row['adjust'] = '<a href="javascript:void(0)" class="mycred-open-points-editor" data-userid="' . $user_id . '" data-current="' . $mycred->format_number( $ubalance ) . '" data-total="' . $mycred->format_number( $total ) . '" data-type="' . $column_name . '" data-username="' . $user->display_name . '" data-zero="' . $mycred->zero() . '">' . __( 'Adjust', 'mycred' ) . '</a>';
|
471 |
|
472 |
-
$rows
|
473 |
$balance .= $this->row_actions( $rows );
|
474 |
|
475 |
return $balance;
|
@@ -484,12 +486,12 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
484 |
public function row_actions( $actions, $always_visible = false ) {
|
485 |
|
486 |
$action_count = count( $actions );
|
487 |
-
$i
|
488 |
|
489 |
if ( ! $action_count )
|
490 |
return '';
|
491 |
|
492 |
-
$out
|
493 |
foreach ( $actions as $action => $link ) {
|
494 |
++$i;
|
495 |
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
@@ -504,55 +506,90 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
504 |
/**
|
505 |
* Insert Ballance into Profile
|
506 |
* @since 0.1
|
507 |
-
* @version 1.
|
508 |
*/
|
509 |
public function show_my_balance( $user ) {
|
510 |
|
511 |
$user_id = $user->ID;
|
|
|
512 |
$mycred_types = mycred_get_types( true );
|
|
|
|
|
513 |
|
514 |
-
$
|
515 |
-
foreach ( $mycred_types as $type => $label ) {
|
516 |
|
517 |
-
$mycred
|
|
|
|
|
518 |
|
519 |
-
|
520 |
|
521 |
-
|
522 |
-
|
523 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
524 |
|
525 |
}
|
526 |
|
527 |
-
if (
|
528 |
|
529 |
?>
|
530 |
</table>
|
|
|
531 |
<div id="mycred-edit-user-wrapper">
|
532 |
-
<h2><?php echo mycred_label(); ?></h2>
|
533 |
<table class="form-table mycred-inline-table">
|
534 |
<tr>
|
535 |
-
<th scope="row"><?php _e( '
|
536 |
<td>
|
537 |
<fieldset id="mycred-badge-list" class="badge-list">
|
538 |
<legend class="screen-reader-text"><span><?php _e( 'Balance', 'mycred' ); ?></span></legend>
|
539 |
<?php
|
540 |
|
541 |
-
|
|
|
542 |
|
543 |
-
|
|
|
544 |
|
545 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
|
547 |
-
|
548 |
-
|
549 |
|
550 |
?>
|
551 |
-
<div class="balance-wrapper color-option selected">
|
552 |
-
|
553 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
|
555 |
-
|
|
|
556 |
|
557 |
</div>
|
558 |
<?php
|
@@ -564,19 +601,104 @@ if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
|
564 |
</td>
|
565 |
</tr>
|
566 |
</table>
|
|
|
567 |
<?php
|
568 |
|
569 |
-
foreach ( $
|
570 |
-
do_action( 'mycred_user_edit_after_' . $
|
571 |
|
572 |
do_action( 'mycred_user_edit_after_balances', $user );
|
573 |
|
|
|
|
|
|
|
574 |
?>
|
575 |
</div>
|
576 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
<table class="form-table">
|
578 |
<?php
|
579 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
}
|
581 |
|
582 |
}
|
6 |
* This module is responsible for all point management in the WordPress admin areas Users section.
|
7 |
* Replaces the mycred-admin.php file.
|
8 |
* @since 1.7
|
9 |
+
* @version 1.0.1
|
10 |
*/
|
11 |
if ( ! class_exists( 'myCRED_Management_Module' ) ) :
|
12 |
class myCRED_Management_Module extends myCRED_Module {
|
28 |
/**
|
29 |
* Module Init
|
30 |
* @since 1.0
|
31 |
+
* @version 1.0.1
|
32 |
*/
|
33 |
public function module_init() {
|
34 |
|
37 |
|
38 |
// Custom Columns
|
39 |
add_filter( 'manage_users_columns', array( $this, 'custom_user_column' ) );
|
40 |
+
add_filter( 'manage_users_custom_column', array( $this, 'custom_user_column_content' ), 10, 3 );
|
41 |
|
42 |
// Sortable Column
|
43 |
add_filter( 'manage_users_sortable_columns', array( $this, 'sortable_points_column' ) );
|
45 |
|
46 |
// Edit User
|
47 |
add_action( 'personal_options', array( $this, 'show_my_balance' ) );
|
48 |
+
add_action( 'personal_options_update', array( $this, 'save_balance_adjustments' ), 40 );
|
49 |
+
add_action( 'edit_user_profile_update', array( $this, 'save_balance_adjustments' ), 40 );
|
50 |
|
51 |
// Editor
|
52 |
add_action( 'wp_ajax_mycred-admin-editor', array( $this, 'ajax_editor_balance_update' ) );
|
437 |
* Customize User Columns Content
|
438 |
* @filter 'mycred_user_row_actions'
|
439 |
* @since 0.1
|
440 |
+
* @version 1.3.4
|
441 |
*/
|
442 |
public function custom_user_column_content( $value, $column_name, $user_id ) {
|
443 |
|
445 |
|
446 |
if ( ! array_key_exists( $column_name, $mycred_types ) ) return $value;
|
447 |
|
448 |
+
$mycred = mycred( $column_name );
|
449 |
|
450 |
// User is excluded
|
451 |
if ( $mycred->exclude_user( $user_id ) === true ) return __( 'Excluded', 'mycred' );
|
452 |
|
453 |
+
$user = get_userdata( $user_id );
|
454 |
|
455 |
// Show balance
|
456 |
$ubalance = $mycred->get_users_balance( $user_id, $column_name );
|
462 |
|
463 |
$balance = apply_filters( 'mycred_users_balance_column', $balance, $user_id, $column_name );
|
464 |
|
465 |
+
$page = MYCRED_SLUG;
|
466 |
if ( $column_name != MYCRED_DEFAULT_TYPE_KEY )
|
467 |
$page .= '_' . $column_name;
|
468 |
|
471 |
$row['history'] = '<a href="' . esc_url( admin_url( 'admin.php?page=' . $page . '&user=' . $user_id ) ) . '">' . __( 'History', 'mycred' ) . '</a>';
|
472 |
$row['adjust'] = '<a href="javascript:void(0)" class="mycred-open-points-editor" data-userid="' . $user_id . '" data-current="' . $mycred->format_number( $ubalance ) . '" data-total="' . $mycred->format_number( $total ) . '" data-type="' . $column_name . '" data-username="' . $user->display_name . '" data-zero="' . $mycred->zero() . '">' . __( 'Adjust', 'mycred' ) . '</a>';
|
473 |
|
474 |
+
$rows = apply_filters( 'mycred_user_row_actions', $row, $user_id, $mycred );
|
475 |
$balance .= $this->row_actions( $rows );
|
476 |
|
477 |
return $balance;
|
486 |
public function row_actions( $actions, $always_visible = false ) {
|
487 |
|
488 |
$action_count = count( $actions );
|
489 |
+
$i = 0;
|
490 |
|
491 |
if ( ! $action_count )
|
492 |
return '';
|
493 |
|
494 |
+
$out = '<div class="' . ( $always_visible ? 'row-actions-visible' : 'row-actions' ) . '">';
|
495 |
foreach ( $actions as $action => $link ) {
|
496 |
++$i;
|
497 |
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
506 |
/**
|
507 |
* Insert Ballance into Profile
|
508 |
* @since 0.1
|
509 |
+
* @version 1.2
|
510 |
*/
|
511 |
public function show_my_balance( $user ) {
|
512 |
|
513 |
$user_id = $user->ID;
|
514 |
+
$editor_id = get_current_user_id();
|
515 |
$mycred_types = mycred_get_types( true );
|
516 |
+
$balances = array();
|
517 |
+
$load_script = false;
|
518 |
|
519 |
+
foreach ( $mycred_types as $point_type_key => $label ) {
|
|
|
520 |
|
521 |
+
$mycred = mycred( $point_type_key );
|
522 |
+
|
523 |
+
$row = array( 'name' => '', 'excluded' => true, 'raw' => '', 'formatted' => '', 'can_edit' => false );
|
524 |
|
525 |
+
$row['name'] = $mycred->plural();
|
526 |
|
527 |
+
if ( ! $mycred->exclude_user( $user_id ) ) {
|
528 |
+
|
529 |
+
$balance = $mycred->get_users_balance( $user_id );
|
530 |
+
|
531 |
+
$row['excluded'] = false;
|
532 |
+
$row['raw'] = $balance;
|
533 |
+
$row['formatted'] = $mycred->format_creds( $balance );
|
534 |
+
$row['can_edit'] = ( ( $mycred->can_edit_creds( $editor_id ) ) ? true : false );
|
535 |
+
|
536 |
+
if ( $row['can_edit'] === true && $load_script === false )
|
537 |
+
$load_script = true;
|
538 |
+
|
539 |
+
}
|
540 |
+
|
541 |
+
$balances[ $point_type_key ] = $row;
|
542 |
|
543 |
}
|
544 |
|
545 |
+
if ( empty( $balances ) ) return;
|
546 |
|
547 |
?>
|
548 |
</table>
|
549 |
+
<hr />
|
550 |
<div id="mycred-edit-user-wrapper">
|
|
|
551 |
<table class="form-table mycred-inline-table">
|
552 |
<tr>
|
553 |
+
<th scope="row"><?php _e( 'Balances', 'mycred' ); ?></th>
|
554 |
<td>
|
555 |
<fieldset id="mycred-badge-list" class="badge-list">
|
556 |
<legend class="screen-reader-text"><span><?php _e( 'Balance', 'mycred' ); ?></span></legend>
|
557 |
<?php
|
558 |
|
559 |
+
// Loop through each point type
|
560 |
+
foreach ( $balances as $point_type => $data ) {
|
561 |
|
562 |
+
// This user is excluded from this point type
|
563 |
+
if ( $data['excluded'] ) {
|
564 |
|
565 |
+
?>
|
566 |
+
<div class="mycred-wrapper balance-wrapper disabled-option color-option">
|
567 |
+
<div><?php echo $data['name']; ?></div>
|
568 |
+
<div class="balance-row">
|
569 |
+
<div class="balance-view"><?php _e( 'Excluded', 'mycred' ); ?></div>
|
570 |
+
<div class="balance-edit"> </div>
|
571 |
+
</div>
|
572 |
+
<?php
|
573 |
+
|
574 |
+
}
|
575 |
|
576 |
+
// Eligeble user
|
577 |
+
else {
|
578 |
|
579 |
?>
|
580 |
+
<div class="mycred-wrapper balance-wrapper color-option selected">
|
581 |
+
<?php if ( $data['can_edit'] ) : ?><div class="toggle-mycred-balance-editor"><a href="javascript:void(0);" data-type="<?php echo $point_type; ?>" data-view="<?php _e( 'Edit', 'mycred' ); ?>" data-edit="<?php _e( 'Cancel', 'mycred' ); ?>"><?php _e( 'Edit', 'mycred' ); ?></a></div><?php endif; ?>
|
582 |
+
<div><?php echo $data['name']; ?></div>
|
583 |
+
<div class="balance-row" id="mycred-balance-<?php echo $point_type; ?>">
|
584 |
+
<div class="balance-view"><?php echo $data['formatted']; ?></div>
|
585 |
+
<?php if ( $data['can_edit'] ) : ?><div class="balance-edit"><input type="text" name="mycred_new_balance[<?php echo $point_type; ?>]" value="" placeholder="<?php echo $data['raw']; ?>" size="12" /></div><?php endif; ?>
|
586 |
+
</div>
|
587 |
+
<?php
|
588 |
+
|
589 |
+
}
|
590 |
|
591 |
+
?>
|
592 |
+
<?php do_action( 'mycred_user_edit_after_balance', $point_type, $user, $data ); ?>
|
593 |
|
594 |
</div>
|
595 |
<?php
|
601 |
</td>
|
602 |
</tr>
|
603 |
</table>
|
604 |
+
<hr />
|
605 |
<?php
|
606 |
|
607 |
+
foreach ( $balances as $point_type => $data )
|
608 |
+
do_action( 'mycred_user_edit_after_' . $point_type, $user );
|
609 |
|
610 |
do_action( 'mycred_user_edit_after_balances', $user );
|
611 |
|
612 |
+
// No need to load the script if we can't edit balances
|
613 |
+
if ( $load_script ) {
|
614 |
+
|
615 |
?>
|
616 |
</div>
|
617 |
+
<script type="text/javascript">
|
618 |
+
jQuery(function($){
|
619 |
+
|
620 |
+
$( '.toggle-mycred-balance-editor a' ).click(function(e){
|
621 |
+
|
622 |
+
e.preventDefault();
|
623 |
+
$(this).blur();
|
624 |
+
|
625 |
+
var togglebutton = $(this);
|
626 |
+
var pointtype = togglebutton.data( 'type' );
|
627 |
+
var balancebox = $( '#mycred-balance-' + pointtype );
|
628 |
+
|
629 |
+
|
630 |
+
|
631 |
+
// View mode > Edit Mode
|
632 |
+
if ( ! balancebox.hasClass( 'edit' ) ) {
|
633 |
+
|
634 |
+
togglebutton.text( togglebutton.data( 'edit' ) );
|
635 |
+
|
636 |
+
$( '#mycred-balance-' + pointtype + ' .balance-view' ).hide();
|
637 |
+
$( '#mycred-balance-' + pointtype + ' .balance-edit' ).show();
|
638 |
+
|
639 |
+
balancebox.addClass( 'edit' );
|
640 |
+
|
641 |
+
}
|
642 |
+
|
643 |
+
// Edit mode > View mode
|
644 |
+
else {
|
645 |
+
|
646 |
+
togglebutton.text( togglebutton.data( 'view' ) );
|
647 |
+
|
648 |
+
$( '#mycred-balance-' + pointtype + ' .balance-view' ).show();
|
649 |
+
$( '#mycred-balance-' + pointtype + ' .balance-edit' ).hide();
|
650 |
+
$( '#mycred-balance-' + pointtype + ' .balance-edit input' ).val( '' );
|
651 |
+
|
652 |
+
balancebox.removeClass( 'edit' );
|
653 |
+
|
654 |
+
}
|
655 |
+
|
656 |
+
});
|
657 |
+
|
658 |
+
});
|
659 |
+
</script>
|
660 |
+
<?php
|
661 |
+
|
662 |
+
}
|
663 |
+
|
664 |
+
?>
|
665 |
<table class="form-table">
|
666 |
<?php
|
667 |
|
668 |
+
}
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Save Balance Changes
|
672 |
+
* @since 1.7.3
|
673 |
+
* @version 1.0
|
674 |
+
*/
|
675 |
+
public function save_balance_adjustments( $user_id ) {
|
676 |
+
|
677 |
+
$editor_id = get_current_user_id();
|
678 |
+
|
679 |
+
if ( isset( $_POST['mycred_new_balance'] ) && is_array( $_POST['mycred_new_balance'] ) && ! empty( $_POST['mycred_new_balance'] ) ) {
|
680 |
+
|
681 |
+
foreach ( $_POST['mycred_new_balance'] as $point_type => $balance ) {
|
682 |
+
|
683 |
+
$point_type = sanitize_key( $point_type );
|
684 |
+
if ( ! mycred_point_type_exists( $point_type ) ) continue;
|
685 |
+
|
686 |
+
$mycred = mycred( $point_type );
|
687 |
+
|
688 |
+
// User can not be excluded and we must be allowed to change balances
|
689 |
+
if ( ! $mycred->exclude_user( $user_id ) && $mycred->can_edit_creds( $editor_id ) ) {
|
690 |
+
|
691 |
+
$balance = sanitize_text_field( $balance );
|
692 |
+
|
693 |
+
// Empty = no changes
|
694 |
+
if ( strlen( $balance ) > 0 ) {
|
695 |
+
$mycred->set_users_balance( $user_id, $balance );
|
696 |
+
}
|
697 |
+
|
698 |
+
}
|
699 |
+
|
700 |
+
}
|
701 |
+
|
702 |
}
|
703 |
|
704 |
}
|
mycred.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: myCRED
|
4 |
* Plugin URI: http://mycred.me
|
5 |
* Description: An adaptive points management system for WordPress powered websites.
|
6 |
-
* Version: 1.7.
|
7 |
* Tags: points, tokens, credit, management, reward, charge, buddypress, bbpress, jetpack, woocommerce, marketpress, wp e-commerce, gravity forms, simplepress
|
8 |
* Author: Gabriel S Merovingi
|
9 |
* Author URI: http://www.merovingi.com
|
@@ -20,7 +20,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
|
|
20 |
final class myCRED_Core {
|
21 |
|
22 |
// Plugin Version
|
23 |
-
public $version = '1.7.
|
24 |
|
25 |
// Instnace
|
26 |
protected static $_instance = NULL;
|
3 |
* Plugin Name: myCRED
|
4 |
* Plugin URI: http://mycred.me
|
5 |
* Description: An adaptive points management system for WordPress powered websites.
|
6 |
+
* Version: 1.7.3
|
7 |
* Tags: points, tokens, credit, management, reward, charge, buddypress, bbpress, jetpack, woocommerce, marketpress, wp e-commerce, gravity forms, simplepress
|
8 |
* Author: Gabriel S Merovingi
|
9 |
* Author URI: http://www.merovingi.com
|
20 |
final class myCRED_Core {
|
21 |
|
22 |
// Plugin Version
|
23 |
+
public $version = '1.7.3';
|
24 |
|
25 |
// Instnace
|
26 |
protected static $_instance = NULL;
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: designbymerovingi
|
3 |
Tags: point, points, tokens, credit, management, reward, charge, community, contest, buddypress, jetpack, bbpress, simple press, woocommerce, wp e-commerce, contact-form-7
|
4 |
Requires at least: 4.0
|
5 |
-
Tested up to: 4.6
|
6 |
-
Stable tag: 1.7.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -16,7 +16,7 @@ An adaptive and powerful points management system for WordPress powered websites
|
|
16 |
|
17 |
|
18 |
> #### Plugin Support
|
19 |
-
> Free support is offered via the [myCRED
|
20 |
|
21 |
|
22 |
myCRED is an adaptive points management system that lets you build a broad range of point related applications for your WordPress powered website.
|
@@ -65,7 +65,7 @@ The most commonly asked customizations for myCRED are available as code snippets
|
|
65 |
|
66 |
= Support =
|
67 |
|
68 |
-
I provide free support
|
69 |
|
70 |
|
71 |
== Installation ==
|
@@ -100,8 +100,8 @@ You can find a list of [frequently asked questions](https://mycred.me/about/faq/
|
|
100 |
|
101 |
== Upgrade Notice ==
|
102 |
|
103 |
-
= 1.7.
|
104 |
-
Bug fixes
|
105 |
|
106 |
|
107 |
== Other Notes ==
|
@@ -125,12 +125,23 @@ Bug fixes and improvements for 1.7.
|
|
125 |
|
126 |
== Changelog ==
|
127 |
|
128 |
-
= 1.7.
|
129 |
-
*
|
130 |
-
* FIX -
|
131 |
-
* FIX -
|
132 |
-
* FIX -
|
133 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
= Previous Versions =
|
136 |
https://mycred.me/support/changelog/
|
2 |
Contributors: designbymerovingi
|
3 |
Tags: point, points, tokens, credit, management, reward, charge, community, contest, buddypress, jetpack, bbpress, simple press, woocommerce, wp e-commerce, contact-form-7
|
4 |
Requires at least: 4.0
|
5 |
+
Tested up to: 4.6.1
|
6 |
+
Stable tag: 1.7.3
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
16 |
|
17 |
|
18 |
> #### Plugin Support
|
19 |
+
> Free support is offered via the [myCRED website](https://mycred.me/support/). No support is provided here on the wordpress.org support forum.
|
20 |
|
21 |
|
22 |
myCRED is an adaptive points management system that lets you build a broad range of point related applications for your WordPress powered website.
|
65 |
|
66 |
= Support =
|
67 |
|
68 |
+
I provide [free support](https://mycred.me/support/) if you can not get myCRED to work as described in the documentation, and pay myCRED Store Tokens as a reward for reporting bugs and/or bug fixes. There is also a [community forum](https://mycred.me/support/forums/) where you can post your questions or [contact me directly](https://mycred.me/contact/).
|
69 |
|
70 |
|
71 |
== Installation ==
|
100 |
|
101 |
== Upgrade Notice ==
|
102 |
|
103 |
+
= 1.7.3 =
|
104 |
+
Bug fixes for 1.7
|
105 |
|
106 |
|
107 |
== Other Notes ==
|
125 |
|
126 |
== Changelog ==
|
127 |
|
128 |
+
= 1.7.3 =
|
129 |
+
* FIX - buyCRED add-on not running during template_redirect.
|
130 |
+
* FIX - Template tags are rendering incorrect values in email notifications.
|
131 |
+
* FIX - Removed %plural% from default template in the transfer widget.
|
132 |
+
* FIX - Fixed PHP notice in the buyCRED add-on.
|
133 |
+
* FIX - BuddyPress module causes columns to be hidden in all logs.
|
134 |
+
* FIX - When editing a log entry and changing the point value, the cached results are not reset.
|
135 |
+
* FIX - Transfers of custom point type is not being honoured.
|
136 |
+
* FIX - mycred_get_total_by_time() uses the wrong variables, causing results to always be zero.
|
137 |
+
* NEW - Added option for gateways to customize the first pending payment comment via a new first_comment() class method.
|
138 |
+
* NEW - Added in option to edit balances when editing a user in the wp-admin area.
|
139 |
+
* NEW - Added new set_users_balance() method in the myCRED_Settings class.
|
140 |
+
* TWEAK - Adjusted styling of the balance editor and add-on override section with support for mobile devices.
|
141 |
+
* TWEAK - Adjusted the language the Zombaio gateway uses for pending payment comments.
|
142 |
+
* TWEAK - Email notifications add-on can use a method to convert a request array into a log entry object instead of doing it self.
|
143 |
+
* TWEAK - Removed allowed html tag request from Transfer widget when saving as there is no use for it.
|
144 |
+
|
145 |
|
146 |
= Previous Versions =
|
147 |
https://mycred.me/support/changelog/
|