myCRED - Version beta-2.4.4

Version Description

= 2.4.4 = New features and Bug fixes.

= 2.4.3 = Code improvement.

= 2.4.2 = Code improvement.

= 2.4.1 = New features and Bug fixes.

= 2.4 = New features and Bug fixes.

= 2.3.2 = Code improvement.

= 2.3.1 = Improve license system.

= 2.3 = New features and Bug fixes.

= 2.2 = New features and Bug fixes.

= 2.1.1 = New features and Bug fixes.

= 2.1 = New features and Bug fixes.

= 2.0 = The banking module have been replaced by Central deposite module, and interest related functionality has been removed. If you are using simple interest or compound interest related functionality, you will fine the respective functionalities missing after the update.

Download this release

Release Info

Developer wpexpertsio
Plugin Icon 128x128 myCRED
Version beta-2.4.4
Comparing to
See all releases

Code changes from version 2.4.3.1 to beta-2.4.4

Files changed (110) hide show
  1. addons/badges/assets/css/front.css +28 -0
  2. addons/badges/includes/mycred-badge-shortcodes.php +83 -6
  3. addons/buddypress/index.php +0 -3
  4. addons/buy-creds/abstracts/mycred-abstract-payment-gateway.php +4 -4
  5. addons/buy-creds/assets/images/zombaio.png +0 -0
  6. addons/buy-creds/gateways/zombaio.php +0 -559
  7. addons/cash-creds/assets/css/withdraw.css +23 -18
  8. addons/cash-creds/assets/js/admin-script.js +41 -0
  9. addons/cash-creds/assets/js/withdraw.js +71 -1
  10. addons/cash-creds/gateways/bank-transfer.php +1 -3
  11. addons/cash-creds/includes/cashcred-functions.php +14 -1
  12. addons/cash-creds/includes/cashcred-shortcodes.php +146 -17
  13. addons/cash-creds/modules/cashcred-module-core.php +198 -13
  14. addons/cash-creds/modules/cashcred-module-withdrawal.php +41 -3
  15. addons/email-notices/includes/mycred-email-object.php +10 -18
  16. addons/gateway/carts/mycred-marketpress.php +0 -579
  17. addons/gateway/event-booking/mycred-eventsmanager-pro.php +0 -641
  18. addons/gateway/membership/index.php +0 -3
  19. addons/import/includes/File-CSV-DataSource.php +0 -834
  20. addons/import/includes/index.php +0 -3
  21. addons/import/index.php +0 -3
  22. addons/import/myCRED-addon-import.php +0 -782
  23. addons/notifications/css/index.php +0 -3
  24. addons/notifications/css/notify.css +0 -40
  25. addons/notifications/js/index.php +0 -3
  26. addons/notifications/js/notify.js +0 -80
  27. addons/ranks/includes/mycred-rank-functions.php +1 -1
  28. addons/ranks/myCRED-addon-ranks.php +7 -7
  29. addons/sell-content/myCRED-addon-sell-content.php +12 -8
  30. addons/stats/includes/mycred-stats-functions.php +1 -0
  31. addons/stats/includes/mycred-stats-object.php +1 -1
  32. assets/css/admin-subscription.css +7 -2
  33. assets/css/bootstrap-grid.css +7 -2
  34. assets/css/inline-edit.css +0 -5
  35. assets/css/overview.css +0 -34
  36. assets/css/widget.css +0 -1
  37. assets/images/about/badge.png +0 -0
  38. assets/js/edit-log.js +0 -278
  39. assets/js/management.js +0 -202
  40. assets/js/mycred-tools.js +19 -19
  41. assets/js/mycred-type-management.js +1 -0
  42. assets/screenshot-5.png +0 -0
  43. includes/classes/class.query-log.php +8 -0
  44. includes/hooks/mycred-hook-referrals.php +23 -26
  45. includes/mycred-admin.php +0 -788
  46. includes/mycred-blocks/blocks/mycred-affiliate-id/index.js +5 -3
  47. includes/mycred-blocks/blocks/mycred-affiliate-link/index.js +6 -4
  48. includes/mycred-blocks/blocks/mycred-badges-list/index.js +45 -0
  49. includes/mycred-blocks/blocks/mycred-badges-list/mycred-badges-list.php +43 -0
  50. includes/mycred-blocks/blocks/mycred-badges/index.js +6 -4
  51. includes/mycred-blocks/blocks/mycred-best-user/index.js +6 -5
  52. includes/mycred-blocks/blocks/mycred-buy-form/index.js +6 -4
  53. includes/mycred-blocks/blocks/mycred-buy-pending/index.js +76 -0
  54. includes/mycred-blocks/blocks/mycred-buy-pending/mycred-buy-pending.php +43 -0
  55. includes/mycred-blocks/blocks/mycred-buy/index.js +5 -4
  56. includes/mycred-blocks/blocks/mycred-cashcred/index.js +124 -0
  57. includes/mycred-blocks/blocks/mycred-cashcred/mycred-cashcred.php +60 -0
  58. includes/mycred-blocks/blocks/mycred-chart-balance-history/index.js +228 -0
  59. includes/mycred-blocks/blocks/mycred-chart-balance-history/mycred-chart-balance-history.php +43 -0
  60. includes/mycred-blocks/blocks/mycred-chart-circu/index.js +148 -0
  61. includes/mycred-blocks/blocks/mycred-chart-circu/mycred-chart-circu.php +43 -0
  62. includes/mycred-blocks/blocks/mycred-chart-gain-loss/index.js +192 -0
  63. includes/mycred-blocks/blocks/mycred-chart-gain-loss/mycred-chart-gain-loss.php +43 -0
  64. includes/mycred-blocks/blocks/mycred-chart-history/index.js +211 -0
  65. includes/mycred-blocks/blocks/mycred-chart-history/mycred-chart-history.php +43 -0
  66. includes/mycred-blocks/blocks/mycred-chart-instance-history/index.js +227 -0
  67. includes/mycred-blocks/blocks/mycred-chart-instance-history/mycred-chart-instance-history.php +43 -0
  68. includes/mycred-blocks/blocks/mycred-chart-top-balance/index.js +195 -0
  69. includes/mycred-blocks/blocks/mycred-chart-top-balance/mycred-chart-top-balance.php +43 -0
  70. includes/mycred-blocks/blocks/mycred-chart-top-instance/index.js +195 -0
  71. includes/mycred-blocks/blocks/mycred-chart-top-instance/mycred-chart-top-instance.php +43 -0
  72. includes/mycred-blocks/blocks/mycred-email-subsc/index.js +6 -5
  73. includes/mycred-blocks/blocks/mycred-exchange/index.js +5 -3
  74. includes/mycred-blocks/blocks/mycred-give/index.js +6 -4
  75. includes/mycred-blocks/blocks/mycred-history/index.js +5 -3
  76. includes/mycred-blocks/blocks/mycred-hook-table/index.js +5 -3
  77. includes/mycred-blocks/blocks/mycred-leaderboard/index.js +5 -3
  78. includes/mycred-blocks/blocks/mycred-link/index.js +6 -5
  79. includes/mycred-blocks/blocks/mycred-list-ranks/index.js +5 -3
  80. includes/mycred-blocks/blocks/mycred-load-coupon/index.js +6 -5
  81. includes/mycred-blocks/blocks/mycred-my-badges/index.js +5 -3
  82. includes/mycred-blocks/blocks/mycred-my-balance-converted/index.js +6 -4
  83. includes/mycred-blocks/blocks/mycred-my-balance/index.js +6 -4
  84. includes/mycred-blocks/blocks/mycred-my-rank/index.js +5 -3
  85. includes/mycred-blocks/blocks/mycred-my-ranks/index.js +5 -3
  86. includes/mycred-blocks/blocks/mycred-total-balance/index.js +5 -4
  87. includes/mycred-blocks/blocks/mycred-total-pts/index.js +5 -3
  88. includes/mycred-blocks/blocks/mycred-total-since/index.js +5 -3
  89. includes/mycred-blocks/blocks/mycred-transfer/index.js +5 -4
  90. includes/mycred-blocks/blocks/mycred-users-of-all-ranks/index.js +5 -3
  91. includes/mycred-blocks/blocks/mycred-users-of-rank/index.js +5 -3
  92. includes/mycred-blocks/blocks/mycred-video/index.js +6 -4
  93. includes/mycred-blocks/blocks/mycred-video/mycred-video.php +4 -1
  94. includes/mycred-blocks/mycred-blocks.php +16 -0
  95. includes/mycred-depreciated.php +0 -356
  96. includes/mycred-functions.php +2 -2
  97. includes/mycred-importer.php +0 -107
  98. includes/mycred-leaderboard.php +0 -320
  99. includes/mycred-log.php +0 -902
  100. includes/mycred-referrals.php +0 -72
  101. includes/mycred-shortcodes.php +0 -1056
  102. includes/mycred-tools-import-export.php +13 -0
  103. includes/mycred-tools.php +213 -158
  104. includes/mycred-update.php +0 -2
  105. includes/mycred-widgets.php +0 -634
  106. membership/mycred-connect-membership.php +16 -2
  107. modules/mycred-module-buddypress.php +1 -1
  108. modules/mycred-module-settings.php +3 -1
  109. mycred.php +7 -7
  110. readme.txt +12 -6
addons/badges/assets/css/front.css ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .the-badge {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: space-between;
5
+ }
6
+
7
+ hr.badge-line {
8
+
9
+ margin-top: 10px !important;
10
+ }
11
+
12
+ .page-excerpt {
13
+
14
+ width: 100%;
15
+ margin-left:10px;
16
+ }
17
+
18
+
19
+ .page-excerpt {
20
+
21
+ width: 100%;
22
+ margin-left:10px;
23
+ }
24
+
25
+ .demo-badge-title {
26
+ margin-left: 20px;
27
+ width: 100%;
28
+ }
addons/badges/includes/mycred-badge-shortcodes.php CHANGED
@@ -14,7 +14,9 @@ if ( ! function_exists( 'mycred_render_my_badges' ) ) :
14
  'show' => 'earned',
15
  'width' => MYCRED_BADGE_WIDTH,
16
  'height' => MYCRED_BADGE_HEIGHT,
17
- 'user_id' => 'current'
 
 
18
  ), $atts, MYCRED_SLUG . '_my_badges' ) );
19
 
20
  if ( ! is_user_logged_in() && $user_id == 'current' )
@@ -47,11 +49,45 @@ if ( ! function_exists( 'mycred_render_my_badges' ) ) :
47
  if ( ! array_key_exists( $badge_id, $users_badges ) ) {
48
 
49
  $badge = mycred_get_badge( $badge_id );
 
 
 
 
50
  $badge->image_width = $width;
51
  $badge->image_height = $height;
52
 
53
- if ( $badge->main_image !== false )
54
- echo $badge->get_image( 'main' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  }
57
 
@@ -63,13 +99,48 @@ if ( ! function_exists( 'mycred_render_my_badges' ) ) :
63
  $badge->image_width = $width;
64
  $badge->image_height = $height;
65
 
66
- if ( $badge->level_image !== false )
67
- echo $badge->get_image( $level );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  }
70
 
71
  echo '</div>';
72
 
 
 
 
 
 
 
 
73
  }
74
 
75
  }
@@ -284,4 +355,10 @@ if ( !function_exists( 'mycred_render_badge_evidence' ) ) :
284
 
285
  return $content;
286
  }
287
- endif;
 
 
 
 
 
 
14
  'show' => 'earned',
15
  'width' => MYCRED_BADGE_WIDTH,
16
  'height' => MYCRED_BADGE_HEIGHT,
17
+ 'user_id' => 'current',
18
+ 'title' => '',
19
+ 'post_excerpt' => ''
20
  ), $atts, MYCRED_SLUG . '_my_badges' ) );
21
 
22
  if ( ! is_user_logged_in() && $user_id == 'current' )
49
  if ( ! array_key_exists( $badge_id, $users_badges ) ) {
50
 
51
  $badge = mycred_get_badge( $badge_id );
52
+
53
+ $page_id = get_page( $badge_id);
54
+
55
+
56
  $badge->image_width = $width;
57
  $badge->image_height = $height;
58
 
59
+ $badge_title = $badge->title;
60
+ $badge_img = $badge->main_image;
61
+
62
+
63
+
64
+ if ( $badge->main_image !== false ) {
65
+
66
+
67
+
68
+ echo '<div class="demo-badge-image">' . $badge_img . '</div>';
69
+
70
+ if($title == 'show'){
71
+
72
+
73
+
74
+ echo '<div class="demo-badge-title">' . $badge_title . ' '.'</div>';
75
+
76
+ } else {
77
+
78
+ echo '<div class="demo-badge-title" style="display:none;">' . $badge_title . ' '.'</div>';
79
+
80
+ }
81
+
82
+ if($post_excerpt == 'show') {
83
+
84
+ echo '<div class="page-excerpt">' . $page_id->post_excerpt . ' '.'</div>';
85
+
86
+ } else {
87
+ echo '<div class="page-excerpt" style="display:none;">' . $page_id->post_excerpt . ' '.'</div>';;
88
+ }
89
+
90
+ }
91
 
92
  }
93
 
99
  $badge->image_width = $width;
100
  $badge->image_height = $height;
101
 
102
+ $badge_page_id = get_page( $badge_id);
103
+
104
+
105
+
106
+ if ( $badge->level_image !== false ) {
107
+
108
+
109
+ echo '<div class="demo-badge-image">' . $badge->get_image( $level ) . '</div>';
110
+
111
+ if($title == 'show'){
112
+
113
+ echo '<div class="demo-badge-title">' . $badge->title . ' '.'</div>';
114
+
115
+ }
116
+
117
+ else {
118
+
119
+ echo '<div class="demo-badge-title" style="display:none;">' . $badge->title . ' '.'</div>';
120
+
121
+ }
122
+
123
+ if($post_excerpt == 'show') {
124
+
125
+ echo '<div class="page-excerpt">' . $badge_page_id->post_excerpt . ' '.'</div>';
126
+
127
+ } else {
128
+ echo '<div class="page-excerpt" style="display:none;">' . $badge_page_id->post_excerpt . ' '.'</div>';;
129
+ }
130
+
131
+ }
132
 
133
  }
134
 
135
  echo '</div>';
136
 
137
+ if($title == 'show' || $post_excerpt == 'show') {
138
+
139
+ echo '<hr class="badge-line">';
140
+ }
141
+ else {
142
+ echo '';
143
+ }
144
  }
145
 
146
  }
355
 
356
  return $content;
357
  }
358
+ endif;
359
+
360
+ add_action( 'wp_enqueue_scripts', 'enqueue_badge_front_shortcode_scripts' );
361
+
362
+ function enqueue_badge_front_shortcode_scripts() {
363
+ wp_enqueue_style( 'mycred-badge-front-style', plugins_url( 'assets/css/front.css', myCRED_BADGE ), array(), myCRED_BADGE_VERSION , 'all');
364
+ }
addons/buddypress/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- ?>
 
 
 
addons/buy-creds/abstracts/mycred-abstract-payment-gateway.php CHANGED
@@ -491,14 +491,14 @@ if ( ! class_exists( 'myCRED_Payment_Gateway' ) ) :
491
  $table_rows = array();
492
  $point_type_name = apply_filters( 'mycred_buycred_checkout_order', $this->core->plural(), $this );
493
  $table_rows[] = '<tr><td class="item">' . esc_html( $point_type_name ) . '</td><td class="cost right">' . $this->amount . '</td></tr>';
494
-
495
  $item_label = apply_filters( 'mycred_buycred_checkout_order', __('Item', 'mycred'), $this );
496
  $amount_label = apply_filters( 'mycred_buycred_checkout_order', __('Amount', 'mycred'), $this );
497
-
 
498
  if ( $this->gifting )
499
- $table_rows[] = '<tr><td colspan="2"><strong>' . esc_js( esc_attr( __( 'Recipient', 'mycred' ) ) ) . ':</strong> ' . esc_html( get_userdata( $this->recipient_id )->display_name ) . '</td></tr>';
500
 
501
- $table_rows[] = '<tr class="total"><td class="item right">' . esc_js( esc_attr( __( 'Cost', 'mycred' ) ) ) . '</td><td class="cost right">' . sprintf( '%s %s', $this->cost, $this->prefs['currency'] ) . '</td></tr>';
502
 
503
  $table_rows = apply_filters( 'mycred_buycred_order_table_rows', $table_rows, $this );
504
 
491
  $table_rows = array();
492
  $point_type_name = apply_filters( 'mycred_buycred_checkout_order', $this->core->plural(), $this );
493
  $table_rows[] = '<tr><td class="item">' . esc_html( $point_type_name ) . '</td><td class="cost right">' . $this->amount . '</td></tr>';
 
494
  $item_label = apply_filters( 'mycred_buycred_checkout_order', __('Item', 'mycred'), $this );
495
  $amount_label = apply_filters( 'mycred_buycred_checkout_order', __('Amount', 'mycred'), $this );
496
+ $cost_label = apply_filters( 'mycred_buycred_checkout_order', __('Cost', 'mycred'), $this );
497
+
498
  if ( $this->gifting )
499
+ $table_rows[] = '<tr><td colspan="2"><strong>' . esc_js( esc_attr($cost_label ) ) . ':</strong> ' . esc_html( get_userdata( $this->recipient_id )->display_name ) . '</td></tr>';
500
 
501
+ $table_rows[] = '<tr class="total"><td class="item right">' . esc_js( esc_attr( __( 'Cost', 'mycred' ) ) ) . '</td><td class="cost right">' . sprintf( '%s %s', apply_filters( 'mycred_buycred_display_user_amount', $this->cost ), $this->prefs['currency'] ) . '</td></tr>';
502
 
503
  $table_rows = apply_filters( 'mycred_buycred_order_table_rows', $table_rows, $this );
504
 
addons/buy-creds/assets/images/zombaio.png DELETED
Binary file
addons/buy-creds/gateways/zombaio.php DELETED
@@ -1,559 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * myCRED_Zombaio class
6
- * Zombaio Payment Gateway
7
- * @since 1.1
8
- * @version 1.2
9
- */
10
- if ( ! class_exists( 'myCRED_Zombaio' ) ) :
11
- class myCRED_Zombaio extends myCRED_Payment_Gateway {
12
-
13
- /**
14
- * Construct
15
- */
16
- public function __construct( $gateway_prefs ) {
17
-
18
- $types = mycred_get_types();
19
- $default_exchange = array();
20
- foreach ( $types as $type => $label )
21
- $default_exchange[ $type ] = 1;
22
-
23
- parent::__construct( array(
24
- 'id' => 'zombaio',
25
- 'label' => 'Zombaio',
26
- 'gateway_logo_url' => plugins_url( 'assets/images/zombaio.png', MYCRED_PURCHASE ),
27
- 'defaults' => array(
28
- 'sandbox' => 0,
29
- 'site_id' => '',
30
- 'pricing_id' => '',
31
- 'dynamic' => 0,
32
- 'currency' => 'USD',
33
- 'gwpass' => '',
34
- 'logo_url' => '',
35
- 'lang' => 'ZOM',
36
- 'exchange' => $default_exchange,
37
- 'bypass_ipn' => 0
38
- )
39
- ), $gateway_prefs );
40
-
41
- }
42
-
43
- /**
44
- * Verify Z-script
45
- * @since 1.8
46
- * @version 1.0
47
- */
48
- public function returning() {
49
-
50
- // ZOA Validation
51
- if ( isset( $_REQUEST['wp_zombaio_ips'] ) || isset( $_REQUEST['ZombaioGWPass'] ) && isset( $_GET['username'] ) && substr( $_GET['username'], 0, 4 ) == 'Test' ) {
52
-
53
- if ( ! headers_sent() )
54
- header( 'HTTP/1.1 200 OK' );
55
-
56
- echo 'OK';
57
- die;
58
-
59
- }
60
-
61
- }
62
-
63
- /**
64
- * Process
65
- * @since 1.1
66
- * @version 1.0
67
- */
68
- public function process() {
69
-
70
- if ( isset( $_GET['wp_zombaio_ips'] ) && $_GET['wp_zombaio_ips'] == 1 ) {
71
-
72
- if ( isset( $_GET['csv'] ) && $_GET['csv'] == 1 ) {
73
- echo '<textarea style="width: 270px;" rows="10" readonly="readonly">' . implode( ',', $this->get_zombaio_ips() ) . '</textarea>';
74
- exit;
75
- }
76
-
77
- echo '<ul>';
78
- foreach ( $ips as $ip ) {
79
- echo '<li><input type="text" readonly="readonly" value="' . $ip . '" size="15" /></li>';
80
- }
81
- echo '</ul>';
82
-
83
- exit;
84
-
85
- }
86
-
87
- $this->handle_call();
88
-
89
- }
90
-
91
- /**
92
- * Verify IPN IP
93
- * @since 1.1
94
- * @version 1.1
95
- */
96
- public function verify_zombaio_call() {
97
-
98
- if ( $this->prefs['bypass_ipn'] ) return true;
99
-
100
- $zombaio_ips = $this->get_zombaio_ips();
101
- if ( empty( $zombaio_ips ) ) return true;
102
-
103
- if ( $_SERVER['REMOTE_ADDR'] != '' ) {
104
-
105
- $remote_addr = explode( '.', $_SERVER['REMOTE_ADDR'] );
106
- $remote_addr = $remote_addr[0] . '.' . $remote_addr[1] . '.' . $remote_addr[2] . '.';
107
-
108
- if ( in_array( $remote_addr, $zombaio_ips ) ) return true;
109
-
110
- }
111
-
112
- return false;
113
-
114
- }
115
-
116
- /**
117
- * IPN - Is Valid Call
118
- * Replaces the default check
119
- * @since 1.4
120
- * @version 1.1
121
- */
122
- public function IPN_is_valid_call() {
123
-
124
- $result = true;
125
-
126
- // Check password
127
- if ( $_GET['ZombaioGWPass'] != $this->prefs['gwpass'] )
128
- $result = false;
129
-
130
- // Check IPN
131
- if ( $result === true && $this->prefs['bypass_ipn'] == 0 ) {
132
-
133
- $zombaio_ips = $this->get_zombaio_ips();
134
- if ( ! empty( $zombaio_ips ) ) {
135
-
136
- if ( $_SERVER['REMOTE_ADDR'] != '' ) {
137
-
138
- $remote_addr = explode( '.', $_SERVER['REMOTE_ADDR'] );
139
- $remote_addr = $remote_addr[0] . '.' . $remote_addr[1] . '.' . $remote_addr[2] . '.';
140
-
141
- if ( ! in_array( $remote_addr, $zombaio_ips ) )
142
- $result = false;
143
-
144
- }
145
-
146
- }
147
-
148
- }
149
-
150
- // Check Site ID
151
- if ( $result === true && $_GET['SiteID'] != $this->prefs['site_id'] )
152
- $result = false;
153
-
154
- return $result;
155
-
156
- }
157
-
158
- /**
159
- * Handle IPN Call
160
- * @since 1.1
161
- * @version 1.2.1
162
- */
163
- public function handle_call() {
164
-
165
- $outcome = 'FAILED';
166
-
167
- // ZOA Validation
168
- if ( isset( $_GET['username'] ) && substr( $_GET['username'], 0, 4 ) == 'Test' ) {
169
- if ( ! headers_sent() )
170
- header( 'HTTP/1.1 200 OK' );
171
-
172
- echo 'OK';
173
- die;
174
- }
175
-
176
- // Required fields
177
- if ( isset( $_GET['ZombaioGWPass'] ) && isset( $_GET['SiteID'] ) && isset( $_GET['Action'] ) && isset( $_GET['Credits'] ) && isset( $_GET['TransactionID'] ) && isset( $_GET['Identifier'] ) ) {
178
-
179
- // In case this is a true Zombaio call but for other actions, return now
180
- // to allow other plugins to take over.
181
- if ( $_GET['Action'] != 'user.addcredits' )
182
- return;
183
-
184
- // Get Pending Payment
185
- $pending_post_id = sanitize_key( $_GET['Identifier'] );
186
- $pending_payment = $this->get_pending_payment( $pending_post_id );
187
- if ( $pending_payment !== false ) {
188
-
189
- // Validate call
190
- if ( $this->IPN_is_valid_call() ) {
191
-
192
- $errors = false;
193
- $new_call = array();
194
- $transaction_id = sanitize_text_field( $_GET['TransactionID'] );
195
-
196
- // Make sure transaction is unique
197
- if ( ! $this->transaction_id_is_unique( $transaction_id ) ) {
198
- $new_call[] = sprintf( __( 'Duplicate transaction. Received: %s', 'mycred' ), $transaction_id );
199
- $errors = true;
200
- }
201
-
202
- // Live transaction during testing
203
- if ( $this->sandbox_mode && $transaction_id != '0000' ) {
204
- $new_call[] = sprintf( __( 'Live transaction while debug mode is enabled! Received: %s', 'mycred' ), $transaction_id );
205
- $errors = true;
206
- }
207
-
208
- // Credit payment
209
- if ( $errors === false ) {
210
-
211
- if ( $this->prefs['dynamic'] == 1 ) {
212
- $amount = $pending_payment->amount;
213
- $cost = $pending_payment->cost;
214
- }
215
-
216
- else {
217
- $amount = sanitize_text_field( $_GET['Credits'] );
218
- $cost = 0;
219
- }
220
-
221
- if ( is_numeric( $amount ) && $amount > 0 ) {
222
-
223
- // Type
224
- $point_type = $pending_payment->point_type;
225
- $mycred = mycred( $point_type );
226
-
227
- $pending_payment->amount = $mycred->number( $amount );
228
- $pending_payment->cost = $cost;
229
-
230
- // If account is credited, delete the post and it's comments.
231
- if ( $this->complete_payment( $pending_payment, $transaction_id ) ) {
232
- $this->trash_pending_payment( $pending_post_id );
233
- $outcome = 'COMPLETED';
234
- }
235
- else
236
- $new_call[] = __( 'Failed to credit users account.', 'mycred' );
237
-
238
- }
239
-
240
- }
241
-
242
- // Log Call
243
- if ( ! empty( $new_call ) )
244
- $this->log_call( $pending_post_id, $new_call );
245
-
246
- }
247
-
248
- }
249
-
250
- }
251
-
252
- if ( $outcome == 'COMPLETED' )
253
- die( 'OK' );
254
- else
255
- die( 'ERROR' );
256
-
257
- }
258
-
259
- /**
260
- * Prep Sale
261
- * @since 1.8
262
- * @version 1.0
263
- */
264
- public function prep_sale( $new_transaction = false ) {
265
-
266
- // Set currency
267
- $this->currency = ( $this->currency == '' ) ? $this->prefs['currency'] : $this->currency;
268
-
269
- // Item Name
270
- $item_name = str_replace( '%number%', $this->amount, $this->prefs['item_name'] );
271
- $item_name = $this->core->template_tags_general( $item_name );
272
-
273
- $this->redirect_to = 'https://secure.zombaio.com/?' . $this->prefs['site_id'] . '.' . $this->prefs['pricing_id'] . '.' . $this->prefs['lang'];
274
-
275
- $redirect_fields = array();
276
- $redirect_fields['identifier'] = $this->post_id;
277
- $redirect_fields['approve_url'] = $this->get_thankyou();
278
- $redirect_fields['decline_url'] = $this->callback_url();
279
-
280
- if ( $this->prefs['dynamic'] ) {
281
- $redirect_fields['DynAmount_Value'] = $this->cost;
282
- $redirect_fields['DynAmount_Hash'] = md5( $this->prefs['gwpass'] . $this->cost );
283
- }
284
-
285
- $this->redirect_fields = $redirect_fields;
286
-
287
- }
288
-
289
- /**
290
- * AJAX Buy Handler
291
- * @since 1.8
292
- * @version 1.0
293
- */
294
- public function ajax_buy() {
295
-
296
- // Construct the checkout box content
297
- $content = $this->checkout_header();
298
- $content .= $this->checkout_logo();
299
- $content .= $this->checkout_order();
300
- $content .= $this->checkout_cancel();
301
- $content .= $this->checkout_footer();
302
-
303
- // Return a JSON response
304
- $this->send_json( $content );
305
-
306
- }
307
-
308
- /**
309
- * Checkout Page Body
310
- * This gateway only uses the checkout body.
311
- * @since 1.8
312
- * @version 1.0
313
- */
314
- public function checkout_page_body() {
315
-
316
- echo $this->checkout_header();
317
- echo $this->checkout_logo( false );
318
-
319
- echo $this->checkout_order();
320
- echo $this->checkout_cancel();
321
-
322
- echo $this->checkout_footer();
323
-
324
- }
325
-
326
- /**
327
- * Preferences
328
- * @since 1.1
329
- * @version 1.0.1
330
- */
331
- function preferences() {
332
-
333
- $prefs = $this->prefs;
334
-
335
- ?>
336
- <div class="row">
337
- <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
338
- <h3><?php _e( 'Details', 'mycred' ); ?></h3>
339
- <div class="form-group">
340
- <label for="<?php echo $this->field_id( 'site_id' ); ?>"><?php _e( 'Site ID', 'mycred' ); ?></label>
341
- <input type="text" name="<?php echo $this->field_name( 'site_id' ); ?>" id="<?php echo $this->field_id( 'site_id' ); ?>" value="<?php echo esc_attr( $prefs['site_id'] ); ?>" class="form-control" />
342
- </div>
343
- <div class="form-group">
344
- <label for="<?php echo $this->field_id( 'gwpass' ); ?>"><?php _e( 'GW Password', 'mycred' ); ?></label>
345
- <input type="text" name="<?php echo $this->field_name( 'gwpass' ); ?>" id="<?php echo $this->field_id( 'gwpass' ); ?>" value="<?php echo esc_attr( $prefs['gwpass'] ); ?>" class="form-control" />
346
- </div>
347
- <div class="form-group">
348
- <label for="<?php echo $this->field_id( 'logo_url' ); ?>"><?php _e( 'Logo URL', 'mycred' ); ?></label>
349
- <input type="text" name="<?php echo $this->field_name( 'logo_url' ); ?>" id="<?php echo $this->field_id( 'logo_url' ); ?>" value="<?php echo esc_attr( $prefs['logo_url'] ); ?>" class="form-control" />
350
- </div>
351
- <div class="row">
352
- <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
353
- <div class="form-group">
354
- <label for="<?php echo $this->field_id( 'bypass_ipn' ); ?>"><?php _e( 'IP Verification', 'mycred' ); ?></label>
355
- <select name="<?php echo $this->field_name( 'bypass_ipn' ); ?>" id="<?php echo $this->field_id( 'bypass_ipn' ); ?>" class="form-control">
356
- <?php
357
-
358
- $options = array(
359
- 0 => __( 'No', 'mycred' ),
360
- 1 => __( 'Yes', 'mycred' )
361
- );
362
- foreach ( $options as $value => $label ) {
363
- echo '<option value="' . $value . '"';
364
- if ( $prefs['bypass_ipn'] == $value ) echo ' selected="selected"';
365
- echo '>' . $label . '</option>';
366
- }
367
-
368
- ?>
369
- </select>
370
- </div>
371
- </div>
372
- <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
373
- <div class="form-group">
374
- <label for="<?php echo $this->field_id( 'lang' ); ?>"><?php _e( 'Language', 'mycred' ); ?></label>
375
-
376
- <?php $this->lang_dropdown( 'lang' ); ?>
377
-
378
- </div>
379
- </div>
380
- </div>
381
- </div>
382
- <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
383
- <h3><?php _e( 'Setup', 'mycred' ); ?></h3>
384
- <div class="form-group">
385
- <label for="<?php echo $this->field_id( 'pricing_id' ); ?>"><?php _e( 'Pricing ID', 'mycred' ); ?></label>
386
- <input type="text" name="<?php echo $this->field_name( 'pricing_id' ); ?>" id="<?php echo $this->field_id( 'pricing_id' ); ?>" value="<?php echo esc_attr( $prefs['pricing_id'] ); ?>" class="form-control" />
387
- </div>
388
- <div class="form-group">
389
- <div class="checkbox">
390
- <label for="<?php echo $this->field_id( 'dynamic' ); ?>"><input type="checkbox" name="<?php echo $this->field_name( 'dynamic' ); ?>" id="<?php echo $this->field_id( 'dynamic' ); ?>"<?php checked( $prefs['dynamic'], 1 ); ?> value="1" /> <?php _e( 'This pricing ID is a "Dynamic Credits Purchase" in Zombaio.', 'mycred' ); ?></label>
391
- </div>
392
- </div>
393
- <div id="zombaio-dynamic-wrapper" style="display: <?php if ( $prefs['dynamic'] == 1 ) echo 'block'; else echo 'none'; ?>;">
394
- <div class="form-group">
395
- <label for="<?php echo $this->field_id( 'currency' ); ?>"><?php _e( 'Currency', 'mycred' ); ?></label>
396
-
397
- <?php $this->currencies_dropdown( 'currency', 'mycred-gateway-zombaio-currency' ); ?>
398
-
399
- </div>
400
- <div class="form-group">
401
- <label><?php _e( 'Exchange Rates', 'mycred' ); ?></label>
402
-
403
- <?php $this->exchange_rate_setup(); ?>
404
-
405
- </div>
406
- </div>
407
- </div>
408
- </div>
409
- <div class="row">
410
- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
411
- <h3><?php _e( 'Postback URL (ZScript)', 'mycred' ); ?></h3>
412
- <code style="padding: 12px;display:block;"><?php echo get_bloginfo( 'url' ); ?></code>
413
- <p><?php _e( 'For this gateway to work, login to ZOA and set the Postback URL to the above address and click validate.', 'mycred' ); ?></p>
414
- </div>
415
- </div>
416
- <script type="text/javascript">
417
- jQuery(function($){
418
-
419
- $( '#<?php echo $this->field_id( 'dynamic' ); ?>' ).click(function(){
420
-
421
- if ( $(this).is( ':checked' ) )
422
- $( '#zombaio-dynamic-wrapper' ).show();
423
- else
424
- $( '#zombaio-dynamic-wrapper' ).hide();
425
-
426
- });
427
-
428
- });
429
- </script>
430
- <?php
431
-
432
- }
433
-
434
- /**
435
- * Sanatize Prefs
436
- * @since 1.1
437
- * @version 1.2
438
- */
439
- public function sanitise_preferences( $data ) {
440
-
441
- $new_data = array();
442
-
443
- $new_data['sandbox'] = ( array_key_exists( 'sandbox', $data ) ) ? 1 : 0;
444
- $new_data['site_id'] = sanitize_text_field( $data['site_id'] );
445
- $new_data['gwpass'] = sanitize_text_field( $data['gwpass'] );
446
- $new_data['pricing_id'] = sanitize_text_field( $data['pricing_id'] );
447
- $new_data['dynamic'] = ( array_key_exists( 'dynamic', $data ) ) ? 1 : 0;
448
- $new_data['currency'] = sanitize_text_field( $data['currency'] );
449
- $new_data['logo_url'] = sanitize_text_field( $data['logo_url'] );
450
- $new_data['bypass_ipn'] = ( array_key_exists( 'bypass_ipn', $data ) ) ? 1 : 0;
451
- $new_data['lang'] = sanitize_text_field( $data['lang'] );
452
-
453
- // If exchange is less then 1 we must start with a zero
454
- if ( isset( $data['exchange'] ) ) {
455
- foreach ( (array) $data['exchange'] as $type => $rate ) {
456
- if ( $rate != 1 && in_array( substr( $rate, 0, 1 ), array( '.', ',' ) ) )
457
- $data['exchange'][ $type ] = (float) '0' . $rate;
458
- }
459
- }
460
- $new_data['exchange'] = $data['exchange'];
461
-
462
- return $new_data;
463
-
464
- }
465
-
466
- /**
467
- * Currency Dropdown
468
- * @since 1.8
469
- * @version 1.0
470
- */
471
- public function currencies_dropdown( $name = '', $js = '' ) {
472
-
473
- $currencies = array(
474
- 'USD' => 'US Dollars'
475
- );
476
- $currencies = apply_filters( 'mycred_dropdown_currencies_' . $this->id, $currencies );
477
-
478
- if ( $js != '' )
479
- $js = ' data-update="' . $js . '"';
480
-
481
- echo '<select name="' . $this->field_name( $name ) . '" id="' . $this->field_id( $name ) . '" class="currency form-control"' . $js . '>';
482
- echo '<option value="">' . __( 'Select', 'mycred' ) . '</option>';
483
- foreach ( $currencies as $code => $cname ) {
484
- echo '<option value="' . $code . '"';
485
- if ( isset( $this->prefs[ $name ] ) && $this->prefs[ $name ] == $code ) echo ' selected="selected"';
486
- echo '>' . $cname . '</option>';
487
- }
488
- echo '</select>';
489
-
490
- }
491
-
492
- /**
493
- * Language Dropdown
494
- * @since 1.1
495
- * @version 1.0
496
- */
497
- public function lang_dropdown( $name ) {
498
-
499
- $languages = array(
500
- 'ZOM' => 'Let Zombaio Detect Language',
501
- 'US' => 'English',
502
- 'FR' => 'French',
503
- 'DE' => 'German',
504
- 'IT' => 'Italian',
505
- 'JP' => 'Japanese',
506
- 'ES' => 'Spanish',
507
- 'SE' => 'Swedish',
508
- 'KR' => 'Korean',
509
- 'CH' => 'Traditional Chinese',
510
- 'HK' => 'Simplified Chinese'
511
- );
512
-
513
- echo '<select name="' . $this->field_name( $name ) . '" id="' . $this->field_id( $name ) . '" class="form-control">';
514
- echo '<option value="">' . __( 'Select', 'mycred' ) . '</option>';
515
- foreach ( $languages as $code => $cname ) {
516
- echo '<option value="' . $code . '"';
517
- if ( isset( $this->prefs[ $name ] ) && $this->prefs[ $name ] == $code ) echo ' selected="selected"';
518
- echo '>' . $cname . '</option>';
519
- }
520
- echo '</select>';
521
-
522
- }
523
-
524
- /**
525
- * First Comment
526
- * @since 1.7.3
527
- * @version 1.0.1
528
- */
529
- public function first_comment( $comment ) {
530
-
531
- return 'New Zombaio purchase confirmation.';
532
-
533
- }
534
-
535
- /**
536
- * Load IPN IP List
537
- * @since 1.1
538
- * @version 1.1
539
- */
540
- public function get_zombaio_ips() {
541
-
542
- $request = new WP_Http();
543
- $data = $request->request( 'http://www.zombaio.com/ip_list.txt' );
544
- $data = explode( '|', $data['body'] );
545
-
546
- $zombaio_ips = array();
547
- if ( ! empty( $data ) ) {
548
- foreach ( $data as $ip_range ) {
549
- if ( $ip_range != '' )
550
- $zombaio_ips[] = $ip_range;
551
- }
552
- }
553
-
554
- return $zombaio_ips;
555
-
556
- }
557
-
558
- }
559
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/cash-creds/assets/css/withdraw.css CHANGED
@@ -1,28 +1,32 @@
 
 
 
 
 
 
 
 
1
  #cashcred ul.cashcred-nav-tabs li {
2
- float: left;
3
  padding: 10px;
4
  position: relative;
5
- display: block;
6
  border: 1px solid #e9e9e9;
7
  margin-right: 5px;
8
  margin-bottom: 5px;
9
  }
 
10
  #cashcred ul.cashcred-nav-tabs li.active {
11
  background-color: #efefef;
12
  }
13
 
14
-
15
  #cashcred ul.cashcred-nav-tabs {
16
- margin: 0px;
 
17
  list-style: none;
18
- }
19
- #cashcred {
20
- float: left;
21
- width: 100%;
22
  }
23
 
24
  #cashcred #cashcred_tab_content .cashcred-tab {
25
- float: left;
26
  border: 1px solid #e9e9e9;
27
  padding: 5px;
28
  width: 100%;
@@ -31,7 +35,6 @@
31
  padding-left: 10px;
32
  }
33
 
34
-
35
  #cashcred .form-group label {
36
  min-width: 184px;
37
  }
@@ -50,8 +53,6 @@
50
  }
51
 
52
  #cashcred input[type=submit] {
53
-
54
-
55
  margin-top: 10px;
56
  margin-bottom: 5px;
57
  }
@@ -59,6 +60,10 @@
59
  #cashcred input[type=submit]:hover {
60
  background-color: #c8c8c8;
61
  }
 
 
 
 
62
 
63
  #cashcred_total{
64
  text-align: right;
@@ -70,16 +75,15 @@
70
  min-width: 140px;
71
  float: right;
72
  }
73
-
74
- div#submit_button {
75
- float: left;
76
- }
77
- .amount_label{
78
  float: left;
79
  }
 
80
  .cashcred-tab{
81
  display:none;
82
  }
 
83
  .cashcred-min {
84
  font-style: italic;
85
  }
@@ -88,4 +92,5 @@ div#submit_button {
88
  display: none;
89
  color: red;
90
  font-size: smaller;
91
- }
 
1
+ #cashcred {
2
+ width: 100%;
3
+ }
4
+
5
+ #cashcred * {
6
+ box-sizing: border-box;
7
+ }
8
+
9
  #cashcred ul.cashcred-nav-tabs li {
10
+ display: inline-block;
11
  padding: 10px;
12
  position: relative;
 
13
  border: 1px solid #e9e9e9;
14
  margin-right: 5px;
15
  margin-bottom: 5px;
16
  }
17
+
18
  #cashcred ul.cashcred-nav-tabs li.active {
19
  background-color: #efefef;
20
  }
21
 
 
22
  #cashcred ul.cashcred-nav-tabs {
23
+ margin: 0;
24
+ padding: 0;
25
  list-style: none;
26
+ cursor: pointer;
 
 
 
27
  }
28
 
29
  #cashcred #cashcred_tab_content .cashcred-tab {
 
30
  border: 1px solid #e9e9e9;
31
  padding: 5px;
32
  width: 100%;
35
  padding-left: 10px;
36
  }
37
 
 
38
  #cashcred .form-group label {
39
  min-width: 184px;
40
  }
53
  }
54
 
55
  #cashcred input[type=submit] {
 
 
56
  margin-top: 10px;
57
  margin-bottom: 5px;
58
  }
60
  #cashcred input[type=submit]:hover {
61
  background-color: #c8c8c8;
62
  }
63
+
64
+ #cashcred select {
65
+ cursor: pointer;
66
+ }
67
 
68
  #cashcred_total{
69
  text-align: right;
75
  min-width: 140px;
76
  float: right;
77
  }
78
+
79
+ div#submit_button, .amount_label{
 
 
 
80
  float: left;
81
  }
82
+
83
  .cashcred-tab{
84
  display:none;
85
  }
86
+
87
  .cashcred-min {
88
  font-style: italic;
89
  }
92
  display: none;
93
  color: red;
94
  font-size: smaller;
95
+ }
96
+
addons/cash-creds/assets/js/admin-script.js CHANGED
@@ -3,6 +3,47 @@ jQuery(function($){
3
  $(document).ready(function(){
4
  $( 'h1 .page-title-action, .wrap .page-title-action' ).remove();
5
  $( '#titlewrap #title' ).attr( 'readonly', 'readonly' ).addClass( 'readonly' );
 
 
 
 
 
 
 
 
 
6
  });
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  });
3
  $(document).ready(function(){
4
  $( 'h1 .page-title-action, .wrap .page-title-action' ).remove();
5
  $( '#titlewrap #title' ).attr( 'readonly', 'readonly' ).addClass( 'readonly' );
6
+
7
+ //fee
8
+ $('#cashcred-pending-payment-points').keyup( function(){
9
+ var cashcred_point_type = $( "#cashcred-pending-payment-point_type" ).val();
10
+ var amount = $(this).val();
11
+
12
+ cashcred_fee_setting( cashcred_point_type, amount )
13
+
14
+ });
15
  });
16
 
17
+ function cashcred_fee_setting( point_type, withdraw_points ) {
18
+
19
+ if ( cashcred_data.use == 1 ) {
20
+ var fee = 0;
21
+ var ctype = cashcred_data.types[point_type];
22
+ var by = cashcred_data.types[point_type].by;
23
+ var fee_amount = cashcred_data.types[point_type].amount;
24
+ var max_cap = cashcred_data.types[point_type].max_cap;
25
+ var min_cap = cashcred_data.types[point_type].min_cap;
26
+
27
+ if( withdraw_points > 0 ) {
28
+
29
+ fee = fee_amount;
30
+ if( by == 'percent' ){
31
+ fee = ( ( fee_amount / 100 ) * withdraw_points );
32
+ fee_amount = fee_amount + '%';
33
+ }
34
+
35
+ if( min_cap != 0 )
36
+ fee = ( parseInt(fee) + parseInt(min_cap) );
37
+
38
+
39
+ if ( max_cap != 0 && fee > max_cap )
40
+ fee = max_cap;
41
+
42
+ $( '#cashcred-pending-payment-fee' ).val( fee );
43
+ }
44
+
45
+ }
46
+
47
+ }
48
+
49
  });
addons/cash-creds/assets/js/withdraw.js CHANGED
@@ -72,7 +72,7 @@ jQuery(function($){
72
  cashcred_point_type = $( "#cashcred_point_type" ).val();
73
  cashcred_pay_method = $( "#cashcred_pay_method" ).val();
74
  withdraw_points = $( "#withdraw_points" ).val();
75
-
76
  currency_code = cashcred.exchange[cashcred_pay_method].currency;
77
  conversion_rate = cashcred.exchange[cashcred_pay_method].point_type[cashcred_point_type];
78
 
@@ -105,8 +105,78 @@ jQuery(function($){
105
 
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
 
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
 
112
  });
72
  cashcred_point_type = $( "#cashcred_point_type" ).val();
73
  cashcred_pay_method = $( "#cashcred_pay_method" ).val();
74
  withdraw_points = $( "#withdraw_points" ).val();
75
+ cashcred_fee = cashcred_fee_setting( cashcred_point_type, withdraw_points );
76
  currency_code = cashcred.exchange[cashcred_pay_method].currency;
77
  conversion_rate = cashcred.exchange[cashcred_pay_method].point_type[cashcred_point_type];
78
 
105
 
106
  }
107
 
108
+ function cashcred_fee_setting( point_type, withdraw_points ) {
109
+
110
+ if ( cashcred_data.cashcred_setting.use == 1 ) {
111
+ var fee = 0;
112
+ var ctype = cashcred_data.cashcred_setting.types[point_type];
113
+ var by = cashcred_data.cashcred_setting.types[point_type].by;
114
+ var fee_amount = cashcred_data.cashcred_setting.types[point_type].amount;
115
+ var max_cap = cashcred_data.cashcred_setting.types[point_type].max_cap;
116
+ var min_cap = cashcred_data.cashcred_setting.types[point_type].min_cap;
117
+ var presentation = cashcred_data.cashcred_setting.types[point_type].presentation;
118
+
119
+ //formats
120
+ decimals = cashcred_data.format[point_type].decimals;
121
+ decimal_sep = cashcred_data.format[point_type].separators.decimal;
122
+ thousand_sep = cashcred_data.format[point_type].separators.thousand;
123
+ if( withdraw_points > 0 ) {
124
+ fee = fee_amount;
125
+ if( by == 'percent' ){
126
+ fee = ( ( fee_amount / 100 ) * withdraw_points );
127
+ fee_amount = fee_amount + '%';
128
+ }
129
+
130
+ if( min_cap != 0 )
131
+ fee = ( parseInt(fee) + parseInt(min_cap) );
132
+
133
+
134
+ if ( max_cap != 0 && fee > max_cap )
135
+ fee = max_cap;
136
+
137
+ presentation = presentation.replace( "%fee%", fee_amount );
138
+ presentation = presentation.replace( "%min%", min_cap );
139
+ presentation = presentation.replace( "%max%", max_cap );
140
+ presentation = presentation.replace( "%total%", mycred_number_format( fee, decimals, decimal_sep, thousand_sep ) );
141
+
142
+ $('.cashcred-fee').show();
143
+ $( '.cashcred-fee span' ).html( presentation );
144
+ }
145
+
146
+ }
147
+ else {
148
 
149
+ $('.cashcred-fee').hide();
150
 
151
+ }
152
+ }
153
+
154
+ function mycred_number_format ( number, decimals, dec_point, thousands_sep ) {
155
+
156
+ // Strip all characters but numerical ones.
157
+ number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
158
+ var n = !isFinite(+number) ? 0 : +number,
159
+ prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
160
+ sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
161
+ dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
162
+ s = '',
163
+ toFixedFix = function (n, prec) {
164
+ var k = Math.pow(10, prec);
165
+ return '' + Math.round(n * k) / k;
166
+ };
167
+
168
+ // Fix for IE parseFloat(0.55).toFixed(0) = 0;
169
+ s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
170
+ if (s[0].length > 3) {
171
+ s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
172
+ }
173
+ if ((s[1] || '').length < prec) {
174
+ s[1] = s[1] || '';
175
+ s[1] += new Array(prec - s[1].length + 1).join('0');
176
+ }
177
+
178
+ return s.join(dec) ;
179
+ }
180
 
181
 
182
  });
addons/cash-creds/gateways/bank-transfer.php CHANGED
@@ -195,9 +195,7 @@ if ( ! class_exists( 'myCRED_cashcred_Bank_Transfer' ) ) :
195
  ?>
196
  <div id="panel_<?php echo $data;?>" class="cashcred_panel">
197
 
198
- <div class="form-group">
199
- <label><h3><?php echo apply_filters( 'mycred_cashcred_bank_transfer_title', __( 'Bank account details', 'mycred' ) ); ?></h3></label>
200
- </div>
201
 
202
  <?php if( isset( $mycred_pref_cashcreds["gateway_prefs"]["bank"]["enable_additional_notes"] ) ): ?>
203
  <div class="form-group">
195
  ?>
196
  <div id="panel_<?php echo $data;?>" class="cashcred_panel">
197
 
198
+ <h3><?php echo apply_filters( 'mycred_cashcred_bank_transfer_title', __( 'Bank account details', 'mycred' ) ); ?></h3>
 
 
199
 
200
  <?php if( isset( $mycred_pref_cashcreds["gateway_prefs"]["bank"]["enable_additional_notes"] ) ): ?>
201
  <div class="form-group">
addons/cash-creds/includes/cashcred-functions.php CHANGED
@@ -456,7 +456,20 @@ if ( ! function_exists( 'mycred_get_cashcred_settings' ) ) :
456
  function mycred_get_cashcred_settings() {
457
 
458
  $defaults = array(
459
- 'debugging' => 'disable'
 
 
 
 
 
 
 
 
 
 
 
 
 
460
  );
461
 
462
  $settings = mycred_get_addon_settings( 'cashcreds' );
456
  function mycred_get_cashcred_settings() {
457
 
458
  $defaults = array(
459
+ 'debugging' => 'disable',
460
+ 'fees' => array(
461
+ 'use' => 0,
462
+ 'account' => 0,
463
+ 'types' => array(
464
+ 'mycred_default' => array(
465
+ 'by' => 'percent',
466
+ 'amount' => 0,
467
+ 'min_cap' => 0,
468
+ 'max_cap' => 0,
469
+ 'presentation' => '( %fee% + %min% ) max. %max% = %total%'
470
+ )
471
+ )
472
+ )
473
  );
474
 
475
  $settings = mycred_get_addon_settings( 'cashcreds' );
addons/cash-creds/includes/cashcred-shortcodes.php CHANGED
@@ -34,7 +34,7 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
34
  if ( empty( $gateways ) ) return __( 'No gateway available.', 'mycred' );
35
 
36
  $point_types = cashcred_get_point_types( $types, $user_id );
37
-
38
  //We are excluded
39
  if ( empty( $point_types ) ) return $excluded;
40
 
@@ -49,16 +49,18 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
49
  // Button Label
50
  $button_label = $point_types[ current(array_keys($point_types)) ]->template_tags_general( $button );
51
 
 
 
52
  ob_start();
53
 
54
  $pending_withdrawal = cashcred_get_withdraw_requests('Pending');
55
  ?>
56
- <div id="cashcred" class="container">
57
  <ul class="cashcred-nav-tabs">
58
- <li id="tab1" class="active"><a href="javascript:void(0);"><?php _e( 'Withdraw Request', 'mycred' ); ?></a></li>
59
- <li id="tab2"><a href="javascript:void(0);"><?php _e( 'Approved Requests', 'mycred' ); ?></a></li>
60
- <li id="tab3"><a href="javascript:void(0);"><?php _e( 'Cancelled Requests', 'mycred' ); ?></a></li>
61
- <li id="tab4"><a href="javascript:void(0);"><?php _e( 'Payment Settings', 'mycred' ); ?></a></li>
62
  </ul>
63
  <div id="cashcred_tab_content">
64
  <!--------First tab--------->
@@ -72,6 +74,12 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
72
  <tr>
73
  <th><span class="nobr">ID</span></th>
74
  <th><span class="nobr">Points</span></th>
 
 
 
 
 
 
75
  <th><span class="nobr">Amount</span></th>
76
  <th><span class="nobr">Point Type</span></th>
77
  <th><span class="nobr">Gateway</span></th>
@@ -83,6 +91,32 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
83
  <tr>
84
  <td><?php echo $post->post_name; ?></td>
85
  <td><?php echo get_post_meta($post->ID,'points',true);?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  <td>
87
  <?php echo get_post_meta($post->ID,'currency',true). " " .get_post_meta($post->ID,'points',true) * get_post_meta($post->ID,'cost',true); ?>
88
  </td>
@@ -149,16 +183,48 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
149
  ?>
150
  <input type="number" id="withdraw_points" name="points" class="form-control" placeholder="0" value="<?php echo ! empty($amount) ? $amount : 0; ?>" required />
151
  <p class="cashcred-min"><?php echo __('Minimum Amount: ');?><span></span></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  </div>
153
- <div id="cashcred_total" class="form-group">
154
- <strong>
155
- <span class="amount_label">Amount:&nbsp;</span>
156
- <span id="cashcred_currency_symbol"></span>
157
- <span id="cashcred_total_amount"></span>
158
- </strong>
159
- </div>
160
- <div id="submit_button" class="form-group">
161
- <input type="submit" class="button btn btn-block btn-lg" value="<?php echo $button_label; ?>" />
 
 
 
162
  </div>
163
  </form>
164
  <?php } ?>
@@ -176,6 +242,12 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
176
  <tr>
177
  <th><span class="nobr">ID</span></th>
178
  <th><span class="nobr">Points</span></th>
 
 
 
 
 
 
179
  <th><span class="nobr">Amount</span></th>
180
  <th><span class="nobr">Point Type</span></th>
181
  <th><span class="nobr">Gateway</span></th>
@@ -187,6 +259,32 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
187
  <tr>
188
  <td><?php echo $post->post_name; ?></td>
189
  <td><?php echo get_post_meta($post->ID,'points',true);?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  <td>
191
  <?php echo get_post_meta($post->ID,'currency',true). " " .get_post_meta($post->ID,'points',true) * get_post_meta($post->ID,'cost',true);?>
192
  </td>
@@ -220,6 +318,12 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
220
  <tr>
221
  <th><span class="nobr">ID</span></th>
222
  <th><span class="nobr">Points</span></th>
 
 
 
 
 
 
223
  <th><span class="nobr">Amount</span></th>
224
  <th><span class="nobr">Point Type</span></th>
225
  <th><span class="nobr">Gateway</span></th>
@@ -232,6 +336,32 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
232
  <td><?php echo $post->post_name; ?></td>
233
 
234
  <td><?php echo get_post_meta($post->ID,'points',true);?></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  <td>
236
  <?php echo get_post_meta($post->ID,'currency',true). " " .get_post_meta($post->ID,'points',true) * get_post_meta($post->ID,'cost',true);?>
237
  </td>
@@ -279,12 +409,11 @@ if ( ! function_exists( 'mycred_render_cashcred' ) ) :
279
  }
280
  ?>
281
  <div id="cashcred_save_settings" class="form-group">
282
- <input type="submit" class="button btn btn-block btn-lg" value="Save" />
283
  </div>
284
  </form>
285
  </div>
286
  <!--------End Fourth tab--------->
287
-
288
  </div>
289
  </div>
290
  <?php
34
  if ( empty( $gateways ) ) return __( 'No gateway available.', 'mycred' );
35
 
36
  $point_types = cashcred_get_point_types( $types, $user_id );
37
+
38
  //We are excluded
39
  if ( empty( $point_types ) ) return $excluded;
40
 
49
  // Button Label
50
  $button_label = $point_types[ current(array_keys($point_types)) ]->template_tags_general( $button );
51
 
52
+ $cashcred_setting = mycred_get_cashcred_settings();
53
+
54
  ob_start();
55
 
56
  $pending_withdrawal = cashcred_get_withdraw_requests('Pending');
57
  ?>
58
+ <div id="cashcred">
59
  <ul class="cashcred-nav-tabs">
60
+ <li id="tab1" class="active"><?php _e( 'Withdraw Request', 'mycred' ); ?></li>
61
+ <li id="tab2"><?php _e( 'Approved Requests', 'mycred' ); ?></li>
62
+ <li id="tab3"><?php _e( 'Cancelled Requests', 'mycred' ); ?></li>
63
+ <li id="tab4"><?php _e( 'Payment Settings', 'mycred' ); ?></li>
64
  </ul>
65
  <div id="cashcred_tab_content">
66
  <!--------First tab--------->
74
  <tr>
75
  <th><span class="nobr">ID</span></th>
76
  <th><span class="nobr">Points</span></th>
77
+ <?php
78
+ if ( ! empty( $cashcred_setting['fees']['types'] ) ) {
79
+ if ( $cashcred_setting['fees']['use'] == 1 ) { ?>
80
+ <th><span class="nobr">Fee</span></th><?php
81
+ }
82
+ }?>
83
  <th><span class="nobr">Amount</span></th>
84
  <th><span class="nobr">Point Type</span></th>
85
  <th><span class="nobr">Gateway</span></th>
91
  <tr>
92
  <td><?php echo $post->post_name; ?></td>
93
  <td><?php echo get_post_meta($post->ID,'points',true);?></td>
94
+ <?php
95
+ if ( ! empty( $cashcred_setting['fees']['types'] ) ) {
96
+
97
+ if ( $cashcred_setting['fees']['use'] == 1 ) { ?>
98
+
99
+ <td><?php
100
+
101
+ $type_data = $cashcred_setting['fees']['types'][get_post_meta($post->ID,'point_type',true)];
102
+
103
+ if ( $type_data['by'] == 'percent' ) {
104
+ $fee = ( ( $type_data['amount'] / 100 ) * (int)get_post_meta($post->ID,'points',true) );
105
+ }
106
+ else{
107
+ $fee = $type_data['amount'];
108
+ }
109
+
110
+ if( $type_data['min_cap'] != 0 )
111
+ $fee = $fee + $type_data['min_cap'];
112
+
113
+ if( $type_data['max_cap'] != 0 && $fee > $type_data['max_cap'] )
114
+ $fee = $type_data['max_cap'];
115
+
116
+ echo $fee; ?>
117
+ </td><?php
118
+ }
119
+ }?>
120
  <td>
121
  <?php echo get_post_meta($post->ID,'currency',true). " " .get_post_meta($post->ID,'points',true) * get_post_meta($post->ID,'cost',true); ?>
122
  </td>
183
  ?>
184
  <input type="number" id="withdraw_points" name="points" class="form-control" placeholder="0" value="<?php echo ! empty($amount) ? $amount : 0; ?>" required />
185
  <p class="cashcred-min"><?php echo __('Minimum Amount: ');?><span></span></p>
186
+
187
+ <?php
188
+
189
+ if ( ! empty( $cashcred_setting['fees'] ) ){
190
+
191
+ if( $cashcred_setting['fees']['use'] == 1 ) { ?>
192
+
193
+ <p class="cashcred-fee" ><?php echo __('Fee : '); ?>
194
+
195
+ <span></span>
196
+
197
+ </p> <?php
198
+ }
199
+
200
+ $format = array();
201
+ foreach ($point_types as $key => $value) {
202
+ $format[$key] = $point_types[$key]->core['format'];
203
+
204
+ }
205
+
206
+ wp_localize_script( 'cashcred-withdraw', 'cashcred_data',
207
+ array(
208
+ 'cashcred_setting' => $cashcred_setting['fees'],
209
+ 'format' => $format,
210
+ )
211
+ );
212
+
213
+ }
214
+ ?>
215
  </div>
216
+ <div class="mycred-cashcred-withdraw-form-footer">
217
+ <div id="cashcred_total" class="form-group">
218
+ <strong>
219
+ <span class="amount_label">Amount:&nbsp;</span>
220
+ <span id="cashcred_currency_symbol"></span>
221
+ <span id="cashcred_total_amount"></span>
222
+ </strong>
223
+ </div>
224
+ <div id="submit_button" class="form-group">
225
+ <input type="submit" class="button" value="<?php echo $button_label; ?>" />
226
+ </div>
227
+ <div class="mycred-clearfix"></div>
228
  </div>
229
  </form>
230
  <?php } ?>
242
  <tr>
243
  <th><span class="nobr">ID</span></th>
244
  <th><span class="nobr">Points</span></th>
245
+ <?php
246
+ if ( ! empty( $cashcred_setting['fees']['types'] ) ) {
247
+ if ( $cashcred_setting['fees']['use'] == 1 ) { ?>
248
+ <th><span class="nobr">Fee</span></th><?php
249
+ }
250
+ }?>
251
  <th><span class="nobr">Amount</span></th>
252
  <th><span class="nobr">Point Type</span></th>
253
  <th><span class="nobr">Gateway</span></th>
259
  <tr>
260
  <td><?php echo $post->post_name; ?></td>
261
  <td><?php echo get_post_meta($post->ID,'points',true);?></td>
262
+ <?php
263
+ if ( ! empty( $cashcred_setting['fees']['types'] ) ) {
264
+
265
+ if ( $cashcred_setting['fees']['use'] == 1 ) { ?>
266
+
267
+ <td><?php
268
+
269
+ $type_data = $cashcred_setting['fees']['types'][get_post_meta($post->ID,'point_type',true)];
270
+
271
+ if ( $type_data['by'] == 'percent' ) {
272
+ $fee = ( ( $type_data['amount'] / 100 ) * (int)get_post_meta($post->ID,'points',true) );
273
+ }
274
+ else{
275
+ $fee = $type_data['amount'];
276
+ }
277
+
278
+ if( $type_data['min_cap'] != 0 )
279
+ $fee = $fee + $type_data['min_cap'];
280
+
281
+ if( $type_data['max_cap'] != 0 && $fee > $type_data['max_cap'] )
282
+ $fee = $type_data['max_cap'];
283
+
284
+ echo $fee; ?>
285
+ </td><?php
286
+ }
287
+ }?>
288
  <td>
289
  <?php echo get_post_meta($post->ID,'currency',true). " " .get_post_meta($post->ID,'points',true) * get_post_meta($post->ID,'cost',true);?>
290
  </td>
318
  <tr>
319
  <th><span class="nobr">ID</span></th>
320
  <th><span class="nobr">Points</span></th>
321
+ <?php
322
+ if ( ! empty( $cashcred_setting['fees']['types'] ) ) {
323
+ if ( $cashcred_setting['fees']['use'] == 1 ) { ?>
324
+ <th><span class="nobr">Fee</span></th><?php
325
+ }
326
+ }?>
327
  <th><span class="nobr">Amount</span></th>
328
  <th><span class="nobr">Point Type</span></th>
329
  <th><span class="nobr">Gateway</span></th>
336
  <td><?php echo $post->post_name; ?></td>
337
 
338
  <td><?php echo get_post_meta($post->ID,'points',true);?></td>
339
+ <?php
340
+ if ( ! empty( $cashcred_setting['fees']['types'] ) ) {
341
+
342
+ if ( $cashcred_setting['fees']['use'] == 1 ) { ?>
343
+
344
+ <td><?php
345
+
346
+ $type_data = $cashcred_setting['fees']['types'][get_post_meta($post->ID,'point_type',true)];
347
+
348
+ if ( $type_data['by'] == 'percent' ) {
349
+ $fee = ( ( $type_data['amount'] / 100 ) * (int)get_post_meta($post->ID,'points',true) );
350
+ }
351
+ else{
352
+ $fee = $type_data['amount'];
353
+ }
354
+
355
+ if( $type_data['min_cap'] != 0 )
356
+ $fee = $fee + $type_data['min_cap'];
357
+
358
+ if( $type_data['max_cap'] != 0 && $fee > $type_data['max_cap'] )
359
+ $fee = $type_data['max_cap'];
360
+
361
+ echo $fee; ?>
362
+ </td><?php
363
+ }
364
+ }?>
365
  <td>
366
  <?php echo get_post_meta($post->ID,'currency',true). " " .get_post_meta($post->ID,'points',true) * get_post_meta($post->ID,'cost',true);?>
367
  </td>
409
  }
410
  ?>
411
  <div id="cashcred_save_settings" class="form-group">
412
+ <input type="submit" class="button" value="Save" />
413
  </div>
414
  </form>
415
  </div>
416
  <!--------End Fourth tab--------->
 
417
  </div>
418
  </div>
419
  <?php
addons/cash-creds/modules/cashcred-module-core.php CHANGED
@@ -246,7 +246,9 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
246
  $point_type = get_post_meta( $post_id, 'point_type', true );
247
  $points = get_post_meta( $post_id, 'points', true );
248
  $gateway = get_post_meta( $post_id, 'gateway', true );
249
-
 
 
250
  $response_send = array();
251
 
252
  //Add comments in history section
@@ -254,13 +256,71 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
254
  $author = 'cashCRED';
255
  $author_email = apply_filters( 'mycred_cashcred_comment_email', 'cashcred-service@mycred.me' );
256
  $get_payment_settings = cashcred_get_payment_settings( $post_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  $currency = $get_payment_settings->currency;
258
  $amount = $get_payment_settings->points * $get_payment_settings->cost;
259
  $amount_set = $currency .' '.$amount;
260
  $comment = 'Withdrawal payment request processed by %s with the amount %s.' ;
261
  $comment = apply_filters( 'mycred_cashcred_comment_text' , $comment );
262
  $comment = sprintf( $comment , $user->user_login ,$amount_set);
263
- $user_id = get_post_meta( $post_id, 'from', true );
264
 
265
  /* set user total balance */
266
  $cashcred_total = get_user_meta( $user_id, 'cashcred_total', true );
@@ -344,7 +404,7 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
344
 
345
  /**
346
  * Get Payment Gateways
347
- * Retreivs all available payment gateways that can be used to buyCRED
348
  * @since 0.1
349
  * @version 1.1.1
350
  */
@@ -402,10 +462,41 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
402
 
403
  $user_balance = mycred_get_users_balance( get_current_user_id() , $point_type );
404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
405
  if( $user_balance < $points ){
406
 
407
  $format = __('Insufficient funds your point is %s');
408
- $notice = sprintf($format, mycred_display_users_balance( get_current_user_id() , $point_type ));
409
 
410
  $this->notification_message( $notice, $requested_url );
411
 
@@ -430,6 +521,7 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
430
  check_site_add_post_meta( $post_id, 'point_type', $point_type, true );
431
  check_site_add_post_meta( $post_id, 'gateway', $cashcred_pay_method , true );
432
  check_site_add_post_meta( $post_id, 'points', $points, true );
 
433
  check_site_add_post_meta( $post_id, 'cost', $cost, true );
434
  check_site_add_post_meta( $post_id, 'currency', $currency, true );
435
  check_site_add_post_meta( $post_id, 'from', get_current_user_id(), true );
@@ -670,7 +762,7 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
670
 
671
  <?php settings_fields( $this->settings_name ); ?>
672
 
673
- <?php do_action( 'mycred_before_buycreds_page', $this ); ?>
674
 
675
  <div class="list-items expandable-li" id="accordion">
676
  <?php
@@ -699,14 +791,14 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
699
  <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
700
  <div class="form-group">
701
  <div>&nbsp;</div>
702
- <label for="buycred-gateway-<?php echo $key; ?>"><input type="checkbox" name="mycred_pref_cashcreds[active][]" id="cashcred-gateway-<?php echo $key; ?>" value="<?php echo $key; ?>"<?php if ( $this->is_active( $key ) ) echo ' checked="checked"'; ?> /> <?php _e( 'Enable', 'mycred' ); ?></label>
703
  </div>
704
  </div>
705
  <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
706
  <?php if ( $has_test_mode ) : ?>
707
  <div class="form-group">
708
  <div>&nbsp;</div>
709
- <label for="buycred-gateway-<?php echo $key; ?>-sandbox"><input type="checkbox" name="mycred_pref_cashcreds[gateway_prefs][<?php echo $key; ?>][sandbox]" id="cashcred-gateway-<?php echo $key; ?>-sandbox" value="<?php echo $key; ?>"<?php if ( $sandbox_mode ) echo ' checked="checked"'; ?> /> <?php _e( 'Sandbox Mode', 'mycred' ); ?></label>
710
  </div>
711
  <?php endif; ?>
712
  </div>
@@ -827,7 +919,7 @@ jQuery(function($) {
827
  */
828
  public function sanitize_settings( $data ) {
829
 
830
- $data = apply_filters( 'mycred_buycred_save_prefs', $data );
831
  $installed = $this->get();
832
 
833
  if ( empty( $installed ) ) return $data;
@@ -855,7 +947,7 @@ jQuery(function($) {
855
  public function after_general_settings( $mycred = NULL ) {
856
 
857
  $cashcred_prefs = mycred_get_cashcred_settings();
858
-
859
  ?>
860
  <h4><span class="dashicons dashicons-admin-plugins static"></span><strong>cash</strong>CRED</h4>
861
  <div class="body" style="display:none;">
@@ -873,9 +965,90 @@ jQuery(function($) {
873
  </div>
874
 
875
  </div>
876
- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"></div>
877
  </div>
878
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
879
  </div>
880
  <?php
881
 
@@ -887,10 +1060,22 @@ jQuery(function($) {
887
  * @version 1.0
888
  */
889
  public function sanitize_extra_settings( $new_data, $data, $general ) {
890
-
 
 
891
  $new_data['cashcreds']['debugging'] = sanitize_text_field( $data['cashcreds']['debugging'] );
 
 
 
 
 
 
 
 
 
 
892
 
893
- //var_dump( $new_data, $data );die;
894
 
895
  return $new_data;
896
 
@@ -901,7 +1086,7 @@ jQuery(function($) {
901
  endif;
902
 
903
  /**
904
- * Load buyCRED Module
905
  * @since 1.7
906
  * @version 1.0
907
  */
246
  $point_type = get_post_meta( $post_id, 'point_type', true );
247
  $points = get_post_meta( $post_id, 'points', true );
248
  $gateway = get_post_meta( $post_id, 'gateway', true );
249
+ $user_id = get_post_meta( $post_id, 'from', true );
250
+ // $fee_points = get_post_meta( $post_id, 'fee_points', true );
251
+
252
  $response_send = array();
253
 
254
  //Add comments in history section
256
  $author = 'cashCRED';
257
  $author_email = apply_filters( 'mycred_cashcred_comment_email', 'cashcred-service@mycred.me' );
258
  $get_payment_settings = cashcred_get_payment_settings( $post_id );
259
+
260
+ //adding fees attribute in cashcred 2.4
261
+ $cashcred_setting = mycred_get_cashcred_settings();
262
+ if( !empty( $cashcred_setting ) ){
263
+
264
+ if( $cashcred_setting['fees']['use'] == 1 ) {
265
+
266
+ $fee = $cashcred_setting['fees']['types'][$point_type]['amount'];
267
+
268
+ if( $cashcred_setting['fees']['types'][$point_type]['by'] == 'percent' )
269
+ $fee = ( ( $fee / 100 ) * $points );
270
+
271
+ if( $cashcred_setting['fees']['types'][$point_type]['min_cap'] != 0 )
272
+ $fee = $fee + $cashcred_setting['fees']['types'][$point_type]['min_cap'];
273
+
274
+ if( $cashcred_setting['fees']['types'][$point_type]['max_cap'] != 0 && $fee > $cashcred_setting['fees']['types'][$point_type]['max_cap'] )
275
+ $fee = $cashcred_setting['fees']['types'][$point_type]['max_cap'];
276
+
277
+
278
+ if( $cashcred_setting['fees']['account'] != 0){
279
+
280
+ $log_data = array(
281
+ 'post_id' => $post_id,
282
+ 'fees_setting' => $cashcred_setting['fees'],
283
+ 'transfer_fee_user' => $cashcred_setting['fees']['account']
284
+ );
285
+
286
+ $mycred = mycred( $point_type );
287
+
288
+ if( ! empty( get_userdata( $cashcred_setting['fees']['account'] )->user_login) )
289
+ $mycred->add_creds(
290
+ 'fee_transfer',
291
+ $cashcred_setting['fees']['account'],
292
+ $fee,
293
+ 'fee transfer to ' . get_userdata( $cashcred_setting['fees']['account'] )->user_login,
294
+ $post_id ,
295
+ $log_data,
296
+ $point_type
297
+ );
298
+ }
299
+
300
+ $log_data = array(
301
+ 'post_id' => $post_id ,
302
+ 'fees_setting' => $cashcred_setting['fees']
303
+ );
304
+
305
+ mycred_subtract(
306
+ 'cashcred_withdrawal_fee',
307
+ $user_id,
308
+ -$fee,
309
+ 'fee deduct',
310
+ $post_id ,
311
+ $log_data,
312
+ $point_type
313
+ );
314
+
315
+ }
316
+ }
317
+
318
  $currency = $get_payment_settings->currency;
319
  $amount = $get_payment_settings->points * $get_payment_settings->cost;
320
  $amount_set = $currency .' '.$amount;
321
  $comment = 'Withdrawal payment request processed by %s with the amount %s.' ;
322
  $comment = apply_filters( 'mycred_cashcred_comment_text' , $comment );
323
  $comment = sprintf( $comment , $user->user_login ,$amount_set);
 
324
 
325
  /* set user total balance */
326
  $cashcred_total = get_user_meta( $user_id, 'cashcred_total', true );
404
 
405
  /**
406
  * Get Payment Gateways
407
+ * Retreivs all available payment gateways that can be used to cashCred
408
  * @since 0.1
409
  * @version 1.1.1
410
  */
462
 
463
  $user_balance = mycred_get_users_balance( get_current_user_id() , $point_type );
464
 
465
+
466
+ //adding fees attribute in cashcred 2.4
467
+ $cashcred_setting = mycred_get_cashcred_settings();
468
+ if( ! empty( $cashcred_setting['fees'] ) ){
469
+
470
+ $fee = 0;
471
+ if( $cashcred_setting['fees']['use'] == 1 ) {
472
+
473
+ $fee_amount = $cashcred_setting['fees']['types'][$point_type]['amount'];
474
+ $fee = $fee_amount;
475
+ if( $cashcred_setting['fees']['types'][$point_type]['by'] == 'percent' )
476
+ $fee = ( ( $fee_amount / 100 ) * $points );
477
+
478
+ if( $cashcred_setting['fees']['types'][$point_type]['min_cap'] != 0 )
479
+ $fee = $fee + $cashcred_setting['fees']['types'][$point_type]['min_cap'];
480
+
481
+ if( $cashcred_setting['fees']['types'][$point_type]['max_cap'] != 0 && $fee > $cashcred_setting['fees']['types'][$point_type]['max_cap'] )
482
+ $fee = $cashcred_setting['fees']['types'][$point_type]['max_cap'];
483
+
484
+ $fee_points = $points + $fee;
485
+
486
+ if( $user_balance < $fee_points ){
487
+
488
+ $notice = __('Insufficient funds after adding fee');
489
+ $this->notification_message( $notice, $requested_url );
490
+
491
+ }
492
+ }
493
+ }
494
+
495
+
496
  if( $user_balance < $points ){
497
 
498
  $format = __('Insufficient funds your point is %s');
499
+ $notice = sprintf($format, mycred_display_users_balance( get_current_user_id() , $point_type ));
500
 
501
  $this->notification_message( $notice, $requested_url );
502
 
521
  check_site_add_post_meta( $post_id, 'point_type', $point_type, true );
522
  check_site_add_post_meta( $post_id, 'gateway', $cashcred_pay_method , true );
523
  check_site_add_post_meta( $post_id, 'points', $points, true );
524
+ check_site_add_post_meta( $post_id, 'fee_points', $fee, true );
525
  check_site_add_post_meta( $post_id, 'cost', $cost, true );
526
  check_site_add_post_meta( $post_id, 'currency', $currency, true );
527
  check_site_add_post_meta( $post_id, 'from', get_current_user_id(), true );
762
 
763
  <?php settings_fields( $this->settings_name ); ?>
764
 
765
+ <?php do_action( 'mycred_before_cashcred_page', $this ); ?>
766
 
767
  <div class="list-items expandable-li" id="accordion">
768
  <?php
791
  <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
792
  <div class="form-group">
793
  <div>&nbsp;</div>
794
+ <label for="cashcred-gateway-<?php echo $key; ?>"><input type="checkbox" name="mycred_pref_cashcreds[active][]" id="cashcred-gateway-<?php echo $key; ?>" value="<?php echo $key; ?>"<?php if ( $this->is_active( $key ) ) echo ' checked="checked"'; ?> /> <?php _e( 'Enable', 'mycred' ); ?></label>
795
  </div>
796
  </div>
797
  <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
798
  <?php if ( $has_test_mode ) : ?>
799
  <div class="form-group">
800
  <div>&nbsp;</div>
801
+ <label for="cashcred-gateway-<?php echo $key; ?>-sandbox"><input type="checkbox" name="mycred_pref_cashcreds[gateway_prefs][<?php echo $key; ?>][sandbox]" id="cashcred-gateway-<?php echo $key; ?>-sandbox" value="<?php echo $key; ?>"<?php if ( $sandbox_mode ) echo ' checked="checked"'; ?> /> <?php _e( 'Sandbox Mode', 'mycred' ); ?></label>
802
  </div>
803
  <?php endif; ?>
804
  </div>
919
  */
920
  public function sanitize_settings( $data ) {
921
 
922
+ $data = apply_filters( 'mycred_cashcred_save_prefs', $data );
923
  $installed = $this->get();
924
 
925
  if ( empty( $installed ) ) return $data;
947
  public function after_general_settings( $mycred = NULL ) {
948
 
949
  $cashcred_prefs = mycred_get_cashcred_settings();
950
+ $point_types = $mycred->point_types;
951
  ?>
952
  <h4><span class="dashicons dashicons-admin-plugins static"></span><strong>cash</strong>CRED</h4>
953
  <div class="body" style="display:none;">
965
  </div>
966
 
967
  </div>
 
968
  </div>
969
 
970
+ <h3><?php _e( 'Setup', 'mycred' ); ?></h3>
971
+ <div class="row">
972
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
973
+ <div class="form-group">
974
+ <label for="<?php echo $this->field_id( array( 'fees' => 'use' ) ); ?>"><input type="checkbox" name="mycred_pref_core[cashcreds][fees][use]" id="<?php echo $this->field_id( array( 'fees' => 'use' ) ); ?>"<?php checked( $cashcred_prefs['fees']['use'], 1 ); ?> value="1" /> <?php _e( 'Enable this feature', 'mycred' ); ?></label>
975
+ </div>
976
+ </div>
977
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
978
+ <div class="form-group">
979
+ <label for="<?php echo $this->field_id( array( 'fees' => 'account' ) ); ?>"><?php _e( 'Fee Account', 'mycred' ); ?></label>
980
+ <input type="text" class="form-control" name="mycred_pref_core[cashcreds][fees][account]" id="<?php echo $this->field_id( array( 'fees' => 'account' ) ); ?>" value="<?php echo esc_attr( $cashcred_prefs['fees']['account'] ); ?>" />
981
+ <p><span class="description"><?php _e( 'Option to deposit transfer fees into a specific users account. Use zero to disable.', 'mycred' ); ?></span></p>
982
+ </div>
983
+ </div>
984
+ </div>
985
+ <?php
986
+
987
+ foreach ( $point_types as $key => $key ) {
988
+
989
+ $mycred = mycred( $key );
990
+ if ( ! array_key_exists( $key, $cashcred_prefs['fees']['types'] ) )
991
+ $cashcred_prefs['fees']['types'][ $key ] = array(
992
+ 'amount' => 0,
993
+ 'by' => 'percent',
994
+ 'min_cap' => 0,
995
+ 'max_cap' => 0,
996
+ 'presentation' => '( %fee% + %min% ) max. %max% = %total%'
997
+ );
998
+
999
+ ?>
1000
+ <div class="row">
1001
+ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
1002
+ <h3><?php printf( __( '%s Transfer Fee', 'mycred' ), $mycred->plural() ); ?></h3>
1003
+ </div>
1004
+ </div>
1005
+ <div class="row">
1006
+ <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
1007
+ <div class="form-group">
1008
+ <label for="<?php echo $this->field_id( array( 'fees', 'types', $key, 'amount' ) ); ?>"><?php _e( 'The Fee', 'mycred' ); ?></label>
1009
+ <div>
1010
+ <input type="text" size="8" name="mycred_pref_core[cashcreds][fees][types][<?php echo $key; ?>][amount]" id="<?php echo $this->field_id( array( 'fees', 'types', $key, 'amount' ) ); ?>" value="<?php echo esc_attr( $cashcred_prefs['fees']['types'][ $key ]['amount'] ); ?>" />
1011
+ <select name="mycred_pref_core[cashcreds][fees][types][<?php echo $key; ?>][by]" id="<?php echo $this->field_id( array( 'fees', 'types', $key, 'by' ) ); ?>"><?php
1012
+
1013
+ $options = array( 'percent' => __( 'Percent', 'mycred' ), 'sum' => $mycred->plural() );
1014
+ foreach ( $options as $value => $label ) {
1015
+ echo '<option value="' . $value . '"';
1016
+ if ( $cashcred_prefs['fees']['types'][ $key ]['by'] == $value ) echo ' selected="selected"';
1017
+ echo '>' . $label . '</option>';
1018
+ }
1019
+
1020
+ ?></select>
1021
+ </div>
1022
+ <p><span class="description"><?php _e( 'Use zero for no fee.', 'mycred' ); ?></span></p>
1023
+ </div>
1024
+ </div>
1025
+ <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
1026
+ <div class="form-group">
1027
+ <label for="<?php echo $this->field_id( array( 'fees', 'types', $key, 'min_cap' ) ); ?>"><?php _e( 'Minimum Charge', 'mycred' ); ?></label>
1028
+ <div><input type="text" size="8" name="mycred_pref_core[cashcreds][fees][types][<?php echo $key; ?>][min_cap]" id="<?php echo $this->field_id( array( 'fees', 'types', $key, 'min_cap' ) ); ?>" value="<?php echo esc_attr( $cashcred_prefs['fees']['types'][ $key ]['min_cap'] ); ?>" /> <?php echo $mycred->plural(); ?></div>
1029
+ <p><span class="description"><?php _e( 'Option to set a minimum charge. If set, this amount is added on top of the fee. Example 2% fee + 1.30 points. Use zero to disable.', 'mycred' ); ?></span></p>
1030
+ </div>
1031
+ </div>
1032
+ <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
1033
+ <div class="form-group">
1034
+ <label for="<?php echo $this->field_id( array( 'fees', 'types', $key, 'max_cap' ) ); ?>"><?php _e( 'Maximum Cap', 'mycred' ); ?></label>
1035
+ <div><input type="text" size="8" name="mycred_pref_core[cashcreds][fees][types][<?php echo $key; ?>][max_cap]" id="<?php echo $this->field_id( array( 'fees', 'types', $key, 'max_cap' ) ); ?>" value="<?php echo esc_attr( $cashcred_prefs['fees']['types'][ $key ]['max_cap'] ); ?>" /> <?php echo $mycred->plural(); ?></div>
1036
+ <p><span class="description"><?php _e( 'Optional maximum cap for transfer fees. Use zero to disable.', 'mycred' ); ?></span></p>
1037
+ </div>
1038
+ </div>
1039
+ </div>
1040
+ <div class="row">
1041
+ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
1042
+ <div class="form-group">
1043
+ <label for="<?php echo $this->field_id( array( 'fees', 'types', $key, 'presentation' ) ); ?>"><?php _e( 'Presentation', 'mycred' ); ?></label>
1044
+ <input type="text" class="form-control" name="mycred_pref_core[cashcreds][fees][types][<?php echo $key; ?>][presentation]" id="<?php echo $this->field_id( array( 'fees', 'types', $key, 'presentation' ) ); ?>" value="<?php echo esc_attr( $cashcred_prefs['fees']['types'][ $key ]['presentation'] ); ?>" />
1045
+ <p><span class="description"><?php _e( 'Option to set how fees are displayed to your users. Available template tags are: %fee%, %min% and %max% = %total%', 'mycred' ); ?></span></p>
1046
+ </div>
1047
+ </div>
1048
+ </div>
1049
+ <?php
1050
+ }
1051
+ ?>
1052
  </div>
1053
  <?php
1054
 
1060
  * @version 1.0
1061
  */
1062
  public function sanitize_extra_settings( $new_data, $data, $general ) {
1063
+
1064
+ $point_types = $general->point_types;
1065
+
1066
  $new_data['cashcreds']['debugging'] = sanitize_text_field( $data['cashcreds']['debugging'] );
1067
+ $new_data['cashcreds']['fees']['use'] = isset( $data['cashcreds']['fees']['use'] ) ? 1 : 0;
1068
+ $new_data['cashcreds']['fees']['account'] = intval( $data['cashcreds']['fees']['account'] );
1069
+ $new_data['cashcreds']['fees']['types'] = array();
1070
+ foreach ( $point_types as $key => $type ) {
1071
+
1072
+ $new_data['cashcreds']['fees']['types'][$key]['amount'] = sanitize_text_field( $data['cashcreds']['fees']['types'][$key]['amount'] );
1073
+ $new_data['cashcreds']['fees']['types'][$key]['by'] = sanitize_text_field( $data['cashcreds']['fees']['types'][$key]['by'] );
1074
+ $new_data['cashcreds']['fees']['types'][$key]['min_cap'] = sanitize_text_field( $data['cashcreds']['fees']['types'][$key]['min_cap'] );
1075
+ $new_data['cashcreds']['fees']['types'][$key]['max_cap'] = sanitize_text_field( $data['cashcreds']['fees']['types'][$key]['max_cap'] );
1076
+ $new_data['cashcreds']['fees']['types'][$key]['presentation'] = wp_filter_post_kses( $data['cashcreds']['fees']['types'][$key]['presentation'] );
1077
 
1078
+ }
1079
 
1080
  return $new_data;
1081
 
1086
  endif;
1087
 
1088
  /**
1089
+ * Load cashCred Module
1090
  * @since 1.7
1091
  * @version 1.0
1092
  */
addons/cash-creds/modules/cashcred-module-withdrawal.php CHANGED
@@ -972,7 +972,32 @@ if ( ! class_exists( 'cashCRED_Pending_Payments' ) ) :
972
  $payment_status = get_post_meta( get_the_ID(), 'status', true );
973
 
974
  $user_id = mycred_get_post_meta( get_the_ID(), 'from', true );
 
 
 
 
 
 
 
975
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
976
  if($payment_status == 'Approved' || $this->is_paid_request( $user_id, get_the_ID() ) )
977
  $readonly = 'readonly';
978
 
@@ -1027,19 +1052,32 @@ if ( ! class_exists( 'cashCRED_Pending_Payments' ) ) :
1027
  </select>
1028
  </div>
1029
  </div>
1030
- <div class="col-md-2 col-sm-6">
1031
  <div class="form-group">
1032
  <label for="cashcred-pending-payment-points"><?php _e( 'Points', 'mycred' ); ?></label>
1033
  <input type="text" <?php echo $readonly; ?> name="cashcred_pending_payment[points]" id="cashcred-pending-payment-points" class="form-control readonly_fields" value="<?php echo $mycred->number( $pending_payment->points ); ?>" />
1034
  </div>
1035
  </div>
1036
- <div class="col-md-2 col-sm-6">
 
 
 
 
 
 
 
 
 
 
 
 
 
1037
  <div class="form-group">
1038
  <label for="cashcred-pending-payment-cost"><?php _e( 'Cost', 'mycred' ); ?></label>
1039
  <input type="text" <?php echo $readonly; ?> name="cashcred_pending_payment[cost]" id="cashcred-pending-payment-cost" class="form-control readonly_fields" value="<?php echo esc_attr( $pending_payment->cost ); ?>" />
1040
  </div>
1041
  </div>
1042
- <div class="col-md-2 col-sm-6">
1043
  <div class="form-group">
1044
  <label for="cashcred-pending-payment-currency"><?php _e( 'Currency', 'mycred' ); ?></label>
1045
  <input type="text" <?php echo $readonly; ?> name="cashcred_pending_payment[currency]" id="cashcred-pending-payment-currency" class="form-control readonly_fields" value="<?php echo esc_attr( $pending_payment->currency ); ?>" />
972
  $payment_status = get_post_meta( get_the_ID(), 'status', true );
973
 
974
  $user_id = mycred_get_post_meta( get_the_ID(), 'from', true );
975
+
976
+ //adding fees attribute in cashcred 2.4
977
+ $cashcred_setting = mycred_get_cashcred_settings();
978
+
979
+ if( ! empty( $cashcred_setting['fees'] ) ) {
980
+
981
+ if( $cashcred_setting['fees']['use'] == 1 ) {
982
 
983
+ $type_data = $cashcred_setting['fees']['types'][get_post_meta($post->ID,'point_type',true)];
984
+
985
+ if ( $type_data['by'] == 'percent' ) {
986
+ $fee = ( ( $type_data['amount'] / 100 ) * (int)get_post_meta($post->ID,'points',true) );
987
+ }
988
+ else{
989
+ $fee = $type_data['amount'];
990
+ }
991
+
992
+ if( $type_data['min_cap'] != 0 )
993
+ $fee = $fee + $type_data['min_cap'];
994
+
995
+ if( $type_data['max_cap'] != 0 && $fee > $type_data['max_cap'] )
996
+ $fee = $type_data['max_cap'];
997
+ }
998
+ wp_localize_script( 'cashcred-admin-script', 'cashcred_data', $cashcred_setting['fees'] );
999
+ }
1000
+
1001
  if($payment_status == 'Approved' || $this->is_paid_request( $user_id, get_the_ID() ) )
1002
  $readonly = 'readonly';
1003
 
1052
  </select>
1053
  </div>
1054
  </div>
1055
+ <div class="<?php echo $cashcred_setting['fees']['use'] == 1 ? 'col-md-1 col-sm-5' : 'col-md-2 col-sm-6' ?>">
1056
  <div class="form-group">
1057
  <label for="cashcred-pending-payment-points"><?php _e( 'Points', 'mycred' ); ?></label>
1058
  <input type="text" <?php echo $readonly; ?> name="cashcred_pending_payment[points]" id="cashcred-pending-payment-points" class="form-control readonly_fields" value="<?php echo $mycred->number( $pending_payment->points ); ?>" />
1059
  </div>
1060
  </div>
1061
+ <?php
1062
+ //adding fees attribute in cashcred 2.4
1063
+ if( ! empty( $cashcred_setting['fees'] ) ) {
1064
+ if( $cashcred_setting['fees']['use'] == 1 ) { ?>
1065
+ <div class="col-md-1 col-sm-5">
1066
+ <div class="form-group">
1067
+ <label for="cashcred-pending-payment-fee"><?php _e( 'Fee', 'mycred' ); ?></label>
1068
+ <input type="text" <?php echo $readonly; ?> name="cashcred_pending_payment[fee]" id="cashcred-pending-payment-fee" class="form-control readonly_fields" value="<?php echo esc_attr( $fee ); ?>" readonly/>
1069
+ </div>
1070
+ </div><?php
1071
+ }
1072
+ }
1073
+ ?>
1074
+ <div class="<?php echo $cashcred_setting['fees']['use'] == 1 ? 'col-md-1 col-sm-5' : 'col-md-2 col-sm-6'; ?>">
1075
  <div class="form-group">
1076
  <label for="cashcred-pending-payment-cost"><?php _e( 'Cost', 'mycred' ); ?></label>
1077
  <input type="text" <?php echo $readonly; ?> name="cashcred_pending_payment[cost]" id="cashcred-pending-payment-cost" class="form-control readonly_fields" value="<?php echo esc_attr( $pending_payment->cost ); ?>" />
1078
  </div>
1079
  </div>
1080
+ <div class="<?php echo $cashcred_setting['fees']['use'] == 1 ? 'col-md-1 col-sm-5' : 'col-md-2 col-sm-6'; ?>">
1081
  <div class="form-group">
1082
  <label for="cashcred-pending-payment-currency"><?php _e( 'Currency', 'mycred' ); ?></label>
1083
  <input type="text" <?php echo $readonly; ?> name="cashcred_pending_payment[currency]" id="cashcred-pending-payment-currency" class="form-control readonly_fields" value="<?php echo esc_attr( $pending_payment->currency ); ?>" />
addons/email-notices/includes/mycred-email-object.php CHANGED
@@ -361,35 +361,27 @@ if ( ! class_exists( 'myCRED_Email' ) ) :
361
 
362
  if ( ! empty( $content ) ) {
363
 
364
- if ( class_exists( 'myCRED_Ranks_Module' ) ) {
365
- //rank-title
366
- if ( is_array( $event ) && array_key_exists( 'ref_id', $event ) ) {
367
 
368
  $rank = mycred_get_rank( $event['ref_id'] );
369
 
370
  if ( is_object( $rank ) ) {
371
 
 
372
  $rank_title = $rank->title;
373
- $content = str_replace( '%rank_title%', $rank_title, $content );
 
 
 
 
374
 
375
  }
376
 
377
  }
378
 
379
- //rank-image
380
- if ( is_array( $event ) && array_key_exists( 'ref_id', $event ) ) {
381
-
382
- $rank = mycred_get_rank( $event['ref_id'] );
383
-
384
- if ( is_object( $rank ) ) {
385
-
386
- $rank_image = '<img src = '.$rank->logo_url. '>';
387
- $content = str_replace( '%rank_image%', $rank_image, $content );
388
-
389
- }
390
-
391
- }
392
- }
393
 
394
  $mycred = mycred( $point_type );
395
 
361
 
362
  if ( ! empty( $content ) ) {
363
 
364
+ if ( class_exists( 'myCRED_Ranks_Module' ) && ( strpos( $content, '%rank_title%' ) !== false || strpos( $content, '%rank_image%' ) !== false ) ) {
365
+
366
+ if ( is_array( $event ) && array_key_exists( 'ref_id', $event ) ) {
367
 
368
  $rank = mycred_get_rank( $event['ref_id'] );
369
 
370
  if ( is_object( $rank ) ) {
371
 
372
+ //rank-title
373
  $rank_title = $rank->title;
374
+ $content = str_replace( '%rank_title%', $rank_title, $content );
375
+
376
+ //rank-image
377
+ $rank_image = "<img src='" . esc_url( $rank->logo_url ) . "'>";
378
+ $content = str_replace( '%rank_image%', $rank_image, $content );
379
 
380
  }
381
 
382
  }
383
 
384
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
385
 
386
  $mycred = mycred( $point_type );
387
 
addons/gateway/carts/mycred-marketpress.php DELETED
@@ -1,579 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * MarketPress Payment Gateway
6
- * @since 1.1
7
- * @version 1.3
8
- */
9
- if ( ! function_exists( 'mycred_init_marketpress_gateway' ) ) {
10
- add_action( 'mp_load_gateway_plugins', 'mycred_init_marketpress_gateway' );
11
- function mycred_init_marketpress_gateway()
12
- {
13
- if ( ! class_exists( 'MP_Gateway_API' ) ) return;
14
-
15
- class MP_Gateway_myCRED extends MP_Gateway_API {
16
-
17
- var $plugin_name = 'mycred';
18
- var $admin_name = 'myCRED';
19
- var $public_name = 'myCRED';
20
- var $mycred_type = 'mycred_default';
21
- var $method_img_url = '';
22
- var $method_button_img_url = '';
23
- var $force_ssl = false;
24
- var $ipn_url;
25
- var $skip_form = false;
26
-
27
- /**
28
- * Runs when your class is instantiated. Use to setup your plugin instead of __construct()
29
- */
30
- function on_creation() {
31
- global $mp;
32
- $settings = get_option( 'mp_settings' );
33
-
34
- //set names here to be able to translate
35
- $this->admin_name = 'myCRED';
36
-
37
- $this->public_name = mycred_label( true );
38
- if ( isset( $settings['gateways']['mycred']['name'] ) && ! empty( $settings['gateways']['mycred']['name'] ) )
39
- $this->public_name = $settings['gateways']['mycred']['name'];
40
-
41
- $this->method_img_url = plugins_url( 'assets/images/cred-icon32.png', myCRED_THIS );
42
- if ( isset( $settings['gateways']['mycred']['logo'] ) && ! empty( $settings['gateways']['mycred']['logo'] ) )
43
- $this->method_img_url = $settings['gateways']['mycred']['logo'];
44
-
45
- $this->method_button_img_url = $this->public_name;
46
-
47
- if ( ! isset( $settings['gateways']['mycred']['type'] ) )
48
- $this->mycred_type = 'mycred_default';
49
- else
50
- $this->mycred_type = $settings['gateways']['mycred']['type'];
51
-
52
- $this->mycred = mycred( $this->mycred_type );
53
- }
54
-
55
- /**
56
- * Use Exchange
57
- * Checks to see if exchange is needed.
58
- * @since 1.1
59
- * @version 1.0
60
- */
61
- function use_exchange() {
62
- global $mp;
63
-
64
- $settings = get_option( 'mp_settings' );
65
- if ( $settings['currency'] == 'POINTS' ) return false;
66
- return true;
67
- }
68
-
69
- /**
70
- * Returns the current carts total.
71
- * @since 1.2
72
- * @version 1.0
73
- */
74
- function get_cart_total( $cart = NULL ) {
75
- global $mp;
76
-
77
- // Get total
78
- $totals = array();
79
- foreach ( $cart as $product_id => $variations ) {
80
- foreach ( $variations as $data ) {
81
- $totals[] = $mp->before_tax_price( $data['price'], $product_id ) * $data['quantity'];
82
- }
83
- }
84
- $total = array_sum( $totals );
85
-
86
- // Apply Coupons
87
- if ( $coupon = $mp->coupon_value( $mp->get_coupon_code(), $total ) ) {
88
- $total = $coupon['new_total'];
89
- }
90
-
91
- // Shipping Cost
92
- if ( ( $shipping_price = $mp->shipping_price() ) !== false ) {
93
- $total = $total + $shipping_price;
94
- }
95
-
96
- // Tax
97
- if ( ( $tax_price = $mp->tax_price() ) !== false ) {
98
- $total = $total + $tax_price;
99
- }
100
-
101
- $settings = get_option( 'mp_settings' );
102
- if ( $this->use_exchange() )
103
- return $this->mycred->apply_exchange_rate( $total, $settings['gateways']['mycred']['exchange'] );
104
- else
105
- return $this->mycred->number( $total );
106
- }
107
-
108
- /**
109
- * Return fields you need to add to the payment screen, like your credit card info fields
110
- *
111
- * @param array $cart. Contains the cart contents for the current blog, global cart if $mp->global_cart is true
112
- * @param array $shipping_info. Contains shipping info and email in case you need it
113
- * @since 1.1
114
- * @version 1.1
115
- */
116
- function payment_form( $cart, $shipping_info ) {
117
- global $mp;
118
-
119
- $settings = get_option( 'mp_settings' );
120
-
121
- if ( ! is_user_logged_in() ) {
122
- $message = str_replace( '%login_url_here%', wp_login_url( mp_checkout_step_url( 'checkout' ) ), $settings['gateways']['mycred']['visitors'] );
123
- $message = $this->mycred->template_tags_general( $message );
124
- return '<div id="mp-mycred-balance">' . $message . '</div>';
125
- }
126
-
127
- $balance = $this->mycred->get_users_cred( get_current_user_id(), $this->mycred_type );
128
- $total = $this->get_cart_total( $cart );
129
-
130
- // Low balance
131
- if ( $balance-$total < 0 ) {
132
- $message = $this->mycred->template_tags_user( $settings['gateways']['mycred']['lowfunds'], false, wp_get_current_user() );
133
- $instructions = '<div id="mp-mycred-balance">' . $message . '</div>';
134
- $red = ' style="color: red;"';
135
- }
136
- else {
137
- $instructions = $this->mycred->template_tags_general( $settings['gateways']['mycred']['instructions'] );
138
- $red = '';
139
- }
140
-
141
- // Return Cost
142
- return '
143
- <div id="mp-mycred-balance">' . $instructions . '</div>
144
- <div id="mp-mycred-cost">
145
- <table style="width:100%;">
146
- <tr>
147
- <td class="info">' . __( 'Current Balance', 'mycred' ) . '</td>
148
- <td class="amount">' . $this->mycred->format_creds( $balance ) . '</td>
149
- </tr>
150
- <tr>
151
- <td class="info">' . __( 'Total Cost', 'mycred' ) . '</td>
152
- <td class="amount">' . $this->mycred->format_creds( $total ) . '</td>
153
- </tr>
154
- <tr>
155
- <td class="info">' . __( 'Balance After Purchase', 'mycred' ) . '</td>
156
- <td class="amount"' . $red . '>' . $this->mycred->format_creds( $balance-$total ) . '</td>
157
- </tr>
158
- </table>
159
- </div>';
160
- }
161
-
162
- /**
163
- * Return the chosen payment details here for final confirmation. You probably don't need
164
- * to post anything in the form as it should be in your $_SESSION var already.
165
- *
166
- * @param array $cart. Contains the cart contents for the current blog, global cart if $mp->global_cart is true
167
- * @param array $shipping_info. Contains shipping info and email in case you need it
168
- * @since 1.1
169
- * @version 1.1
170
- */
171
- function confirm_payment_form( $cart, $shipping_info ) {
172
- global $mp;
173
-
174
- $settings = get_option( 'mp_settings' );
175
- $user_id = get_current_user_id();
176
- $balance = $this->mycred->get_users_cred( get_current_user_id(), $this->mycred_type );
177
- $total = $this->get_cart_total( $cart );
178
-
179
- $table = '<table class="mycred-cart-cost"><thead><tr><th>' . __( 'Payment', 'mycred' ) . '</th></tr></thead>';
180
- if ( $balance-$total < 0 ) {
181
- $message = $this->mycred->template_tags_user( $settings['gateways']['mycred']['lowfunds'], false, wp_get_current_user() );
182
- $table .= '<tr><td id="mp-mycred-cost" style="color: red; font-weight: bold;"><p>' . $message . ' <a href="' . mp_checkout_step_url( 'checkout' ) . '">' . __( 'Go Back', 'mycred' ) . '</a></td></tr>';
183
- }
184
- else
185
- $table .= '<tr><td id="mp-mycred-cost" class="mycred-ok">' . $this->mycred->format_creds( $total ) . ' ' . __( 'will be deducted from your account.', 'mycred' ) . '</td></tr>';
186
-
187
- return $table . '</table>';
188
- }
189
-
190
- function process_payment_form( $cart, $shipping_info ) { }
191
-
192
- /**
193
- * Use this to do the final payment. Create the order then process the payment. If
194
- * you know the payment is successful right away go ahead and change the order status
195
- * as well.
196
- * Call $mp->cart_checkout_error($msg, $context); to handle errors. If no errors
197
- * it will redirect to the next step.
198
- *
199
- * @param array $cart. Contains the cart contents for the current blog, global cart if $mp->global_cart is true
200
- * @param array $shipping_info. Contains shipping info and email in case you need it
201
- * @since 1.1
202
- * @version 1.2.1
203
- */
204
- function process_payment( $cart, $shipping_info ) {
205
- global $mp;
206
-
207
- $settings = get_option('mp_settings');
208
- $user_id = get_current_user_id();
209
- $insolvent = $this->mycred->template_tags_user( $settings['gateways']['mycred']['lowfunds'], false, wp_get_current_user() );
210
- $timestamp = time();
211
-
212
- // This gateway requires buyer to be logged in
213
- if ( ! is_user_logged_in() ) {
214
- $message = str_replace( '%login_url_here%', wp_login_url( mp_checkout_step_url( 'checkout' ) ), $settings['gateways']['mycred']['visitors'] );
215
- $mp->cart_checkout_error( $this->mycred->template_tags_general( $message ) );
216
- }
217
-
218
- // Make sure current user is not excluded from using myCRED
219
- if ( $this->mycred->exclude_user( $user_id ) )
220
- $mp->cart_checkout_error(
221
- sprintf( __( 'Sorry, but you can not use this gateway as your account is excluded. Please <a href="%s">select a different payment method</a>.', 'mycred' ), mp_checkout_step_url( 'checkout' ) )
222
- );
223
-
224
- // Get users balance
225
- $balance = $this->mycred->get_users_cred( $user_id, $this->mycred_type );
226
- $total = $this->get_cart_total( $cart );
227
-
228
- // Low balance or Insolvent
229
- if ( $balance <= $this->mycred->zero() || $balance-$total < $this->mycred->zero() ) {
230
- $mp->cart_checkout_error(
231
- $insolvent . ' <a href="' . mp_checkout_step_url( 'checkout' ) . '">' . __( 'Go Back', 'mycred' ) . '</a>'
232
- );
233
- return;
234
- }
235
-
236
- // Let others decline a store order
237
- $decline = apply_filters( 'mycred_decline_store_purchase', false, $cart, $this );
238
- if ( $decline !== false ) {
239
- $mp->cart_checkout_error( $decline );
240
- return;
241
- }
242
-
243
- // Create MarketPress order
244
- $order_id = $mp->generate_order_id();
245
- $payment_info['gateway_public_name'] = $this->public_name;
246
- $payment_info['gateway_private_name'] = $this->admin_name;
247
- $payment_info['status'][ $timestamp ] = __( 'Paid', 'mycred' );
248
- $payment_info['total'] = $total;
249
- $payment_info['currency'] = $settings['currency'];
250
- $payment_info['method'] = __( 'myCRED', 'mycred' );
251
- $payment_info['transaction_id'] = $order_id;
252
- $paid = true;
253
- $result = $mp->create_order( $order_id, $cart, $shipping_info, $payment_info, $paid );
254
-
255
- $order = get_page_by_title( $result, 'OBJECT', 'mp_order' );
256
-
257
- // Deduct cost
258
- $this->mycred->add_creds(
259
- 'marketpress_payment',
260
- $user_id,
261
- 0-$total,
262
- $settings['gateways']['mycred']['log_template'],
263
- $order->ID,
264
- array( 'ref_type' => 'post' ),
265
- $this->mycred_type
266
- );
267
-
268
- // Profit Sharing
269
- if ( $settings['gateways']['mycred']['profit_share_percent'] > 0 ) {
270
- foreach ( $cart as $product_id => $variations ) {
271
- // Get Product
272
- $product = get_post( (int) $product_id );
273
-
274
- // Continue if product has just been deleted or owner is buyer
275
- if ( $product === NULL || $product->post_author == $cui ) continue;
276
-
277
- foreach ( $variations as $data ) {
278
- $price = $data['price'];
279
- $quantity = $data['quantity'];
280
- $cost = $price*$quantity;
281
-
282
- // Calculate Share
283
- $share = ( $settings['gateways']['mycred']['profit_share_percent'] / 100 ) * $cost;
284
-
285
- // Payout
286
- $this->mycred->add_creds(
287
- 'store_sale',
288
- $product->post_author,
289
- $share,
290
- $settings['gateways']['mycred']['profit_share_log'],
291
- $product->ID,
292
- array( 'ref_type' => 'post' ),
293
- $this->mycred_type
294
- );
295
- }
296
- }
297
- }
298
- }
299
-
300
- function order_confirmation( $order ) { }
301
-
302
- /**
303
- * Filters the order confirmation email message body. You may want to append something to
304
- * the message. Optional
305
- * @since 1.1
306
- * @version 1.0
307
- */
308
- function order_confirmation_email( $msg, $order ) {
309
- global $mp;
310
- $settings = get_option('mp_settings');
311
-
312
- if ( isset( $settings['gateways']['mycred']['email'] ) )
313
- $msg = $mp->filter_email( $order, $settings['gateways']['mycred']['email'] );
314
- else
315
- $msg = $settings['email']['new_order_txt'];
316
-
317
- return $msg;
318
- }
319
-
320
- /**
321
- * Return any html you want to show on the confirmation screen after checkout. This
322
- * should be a payment details box and message.
323
- * @since 1.1
324
- * @version 1.1
325
- */
326
- function order_confirmation_msg( $content, $order ) {
327
- global $mp;
328
- $settings = get_option('mp_settings');
329
-
330
- $mycred = mycred();
331
- $user_id = get_current_user_id();
332
-
333
- return $content . str_replace(
334
- 'TOTAL',
335
- $mp->format_currency( $order->mp_payment_info['currency'], $order->mp_payment_info['total'] ),
336
- $mycred->template_tags_user( $settings['gateways']['mycred']['confirmation'], false, wp_get_current_user() )
337
- );
338
- }
339
-
340
- /**
341
- * myCRED Gateway Settings
342
- * @since 1.1
343
- * @version 1.3
344
- */
345
- function gateway_settings_box( $settings ) {
346
- global $mp;
347
- $settings = get_option( 'mp_settings' );
348
- $mycred = mycred();
349
-
350
- $name = mycred_label( true );
351
- $settings['gateways']['mycred'] = shortcode_atts( array(
352
- 'name' => $name . ' ' . $mycred->template_tags_general( __( '%_singular% Balance', 'mycred' ) ),
353
- 'logo' => $this->method_button_img_url,
354
- 'type' => 'mycred_default',
355
- 'log_template' => __( 'Payment for Order: #%order_id%', 'mycred' ),
356
- 'exchange' => 1,
357
- 'profit_share_percent' => 0,
358
- 'profit_share_log' => __( 'Product Sale: %post_title%', 'mycred' ),
359
- 'instructions' => __( 'Pay using your account balance.', 'mycred' ),
360
- 'confirmation' => __( 'TOTAL amount has been deducted from your account. Your current balance is: %balance_f%', 'mycred' ),
361
- 'lowfunds' => __( 'Insufficient funds.', 'mycred' ),
362
- 'visitors' => __( 'You must be logged in to pay with %_plural%. Please <a href="%login_url_here%">login</a>.', 'mycred' ),
363
- 'email' => $settings['email']['new_order_txt']
364
- ), ( isset( $settings['gateways']['mycred'] ) ) ? $settings['gateways']['mycred'] : array() ); ?>
365
-
366
- <div id="mp_mycred_payments" class="postbox mp-pages-msgs">
367
- <h3 class="handle"><span><?php echo $name . ' ' . __( 'Settings', 'mycred' ); ?></span></h3>
368
- <div class="inside">
369
- <span class="description"><?php echo sprintf( __( 'Let your users pay for items in their shopping cart using their %s Account. Note! This gateway requires your users to be logged in when making a purchase!', 'mycred' ), $name ); ?></span>
370
- <table class="form-table">
371
- <tr>
372
- <th scope="row"><label for="mycred-method-name"><?php _e( 'Method Name', 'mycred' ); ?></label></th>
373
- <td>
374
- <span class="description"><?php _e( 'Enter a public name for this payment method that is displayed to users - No HTML', 'mycred' ); ?></span>
375
- <p><input value="<?php echo esc_attr( $settings['gateways']['mycred']['name'] ); ?>" style="width: 100%;" name="mp[gateways][mycred][name]" id="mycred-method-name" type="text" /></p>
376
- </td>
377
- </tr>
378
- <tr>
379
- <th scope="row"><label for="mycred-method-logo"><?php _e( 'Gateway Logo URL', 'mycred' ); ?></label></th>
380
- <td>
381
- <p><input value="<?php echo esc_attr( $settings['gateways']['mycred']['logo'] ); ?>" style="width: 100%;" name="mp[gateways][mycred][logo]" id="mycred-method-logo" type="text" /></p>
382
- </td>
383
- </tr>
384
- <tr>
385
- <th scope="row"><label for="mycred-method-type"><?php _e( 'Point Type', 'mycred' ); ?></label></th>
386
- <td>
387
- <?php mycred_types_select_from_dropdown( 'mp[gateways][mycred][type]', 'mycred-method-type', $settings['gateways']['mycred']['type'] ); ?>
388
- </td>
389
- </tr>
390
- <tr>
391
- <th scope="row"><label for="mycred-log-template"><?php _e( 'Log Template', 'mycred' ); ?></label></th>
392
- <td>
393
- <span class="description"><?php echo $mycred->available_template_tags( array( 'general' ), '%order_id%, %order_link%' ); ?></span>
394
- <p><input value="<?php echo esc_attr( $settings['gateways']['mycred']['log_template'] ); ?>" style="width: 100%;" name="mp[gateways][mycred][log_template]" id="mycred-log-template" type="text" /></p>
395
- </td>
396
- </tr>
397
- <?php
398
- // Exchange rate
399
- if ( $this->use_exchange() ) :
400
- $exchange_desc = __( 'How much is 1 %_singular% worth in %currency%?', 'mycred' );
401
- $exchange_desc = $mycred->template_tags_general( $exchange_desc );
402
- $exchange_desc = str_replace( '%currency%', $settings['currency'], $exchange_desc ); ?>
403
-
404
- <tr>
405
- <th scope="row"><label for="mycred-exchange-rate"><?php _e( 'Exchange Rate', 'mycred' ); ?></label></th>
406
- <td>
407
- <span class="description"><?php echo $exchange_desc; ?></span>
408
- <p><input value="<?php echo esc_attr( $settings['gateways']['mycred']['exchange'] ); ?>" size="8" name="mp[gateways][mycred][exchange]" id="mycred-exchange-rate" type="text" /></p>
409
- </td>
410
- </tr>
411
- <?php endif; ?>
412
-
413
- <tr>
414
- <td colspan="2"><h4><?php _e( 'Profit Sharing', 'mycred' ); ?></h4></td>
415
- </tr>
416
- <tr>
417
- <th scope="row"><label for="mycred-profit-sharing"><?php _e( 'Percentage', 'mycred' ); ?></label></th>
418
- <td>
419
- <span class="description"><?php _e( 'Option to share sales with the product owner. Use zero to disable.', 'mycred' ); ?></span>
420
- <p><input value="<?php echo esc_attr( $settings['gateways']['mycred']['profit_share_percent'] ); ?>" size="8" name="mp[gateways][mycred][profit_share_percent]" id="mycred-profit-sharing" type="text" /> %</p>
421
- </td>
422
- </tr>
423
- <tr>
424
- <th scope="row"><label for="mycred-profit-sharing-log"><?php _e( 'Log Template', 'mycred' ); ?></label></th>
425
- <td>
426
- <span class="description"><?php echo $mycred->available_template_tags( array( 'general', 'post' ) ); ?></span>
427
- <p><input value="<?php echo esc_attr( $settings['gateways']['mycred']['profit_share_log'] ); ?>" style="width: 100%;" name="mp[gateways][mycred][profit_share_log]" id="mycred-profit-sharing-log" type="text" /></p>
428
- </td>
429
- </tr>
430
- <tr>
431
- <td colspan="2"><h4><?php _e( 'Messages', 'mycred' ); ?></h4></td>
432
- </tr>
433
- <tr>
434
- <th scope="row"><label for="mycred-lowfunds"><?php _e( 'Insufficient Funds', 'mycred' ); ?></label></th>
435
- <td>
436
- <span class="description"><?php _e( 'Message to show when the user can not use this gateway.', 'mycred' ); ?></span>
437
- <p><input type="text" name="mp[gateways][mycred][lowfunds]" id="mycred-lowfunds" style="width: 100%;" value="<?php echo esc_attr( $settings['gateways']['mycred']['lowfunds'] ); ?>"><br />
438
- <span class="description"><?php echo $mycred->available_template_tags( array( 'general' ) ); ?></span></p>
439
- </td>
440
- </tr>
441
- <tr>
442
- <th scope="row"><label for="mycred-visitors"><?php _e( 'Visitors', 'mycred' ); ?></label></th>
443
- <td>
444
- <span class="description"><?php _e( 'Message to show to buyers that are not logged in.', 'mycred' ); ?></span>
445
- <p><input type="text" name="mp[gateways][mycred][visitors]" id="mycred-visitors" style="width: 100%;" value="<?php echo esc_attr( $settings['gateways']['mycred']['visitors'] ); ?>"><br />
446
- <span class="description"><?php echo $mycred->available_template_tags( array( 'general' ) ); ?></span></p>
447
- </td>
448
- </tr>
449
- <tr>
450
- <th scope="row"><label for="mycred-instructions"><?php _e( 'User Instructions', 'mycred' ); ?></label></th>
451
- <td>
452
- <span class="description"><?php _e( 'Information to show users before payment.', 'mycred' ); ?></span>
453
- <p><?php wp_editor( $settings['gateways']['mycred']['instructions'] , 'mycred-instructions', array( 'textarea_name' => 'mp[gateways][mycred][instructions]' ) ); ?><br />
454
- <span class="description"><?php echo $mycred->available_template_tags( array( 'general' ), '%balance% or %balance_f%' ); ?></span></p>
455
- </td>
456
- </tr>
457
- <tr>
458
- <th scope="row"><label for="mycred-confirmation"><?php _e( 'Confirmation Information', 'mycred' ); ?></label></th>
459
- <td>
460
- <span class="description"><?php _e( 'Information to display on the order confirmation page. - HTML allowed', 'mycred' ); ?></span>
461
- <p><?php wp_editor( $settings['gateways']['mycred']['confirmation'], 'mycred-confirmation', array( 'textarea_name' => 'mp[gateways][mycred][confirmation]' ) ); ?><br />
462
- <span class="description"><?php echo $mycred->available_template_tags( array( 'general' ), '%balance% or %balance_f%' ); ?></span></p>
463
- </td>
464
- </tr>
465
- <tr>
466
- <th scope="row"><label for="mycred-email"><?php _e( 'Order Confirmation Email', 'mycred' ); ?></label></th>
467
- <td>
468
- <span class="description"><?php echo sprintf( __( 'This is the email text to send to those who have made %s checkouts. It overrides the default order checkout email. These codes will be replaced with order details: CUSTOMERNAME, ORDERID, ORDERINFO, SHIPPINGINFO, PAYMENTINFO, TOTAL, TRACKINGURL. No HTML allowed.', 'mycred' ), $name ); ?></span>
469
- <p><textarea id="mycred-email" name="mp[gateways][mycred][email]" class="mp_emails_txt"><?php echo esc_textarea( $settings['gateways']['mycred']['email'] ); ?></textarea></p>
470
- <span class="description"><?php echo $mycred->available_template_tags( array( 'general' ), '%balance% or %balance_f%' ); ?></span>
471
- </td>
472
- </tr>
473
- </table>
474
- </div>
475
- </div>
476
- <?php
477
- }
478
-
479
- /**
480
- * Filter Gateway Settings
481
- * @since 1.1
482
- * @version 1.3
483
- */
484
- function process_gateway_settings( $settings ) {
485
- // Name (no html)
486
- $settings['gateways']['mycred']['name'] = stripslashes( wp_filter_nohtml_kses( $settings['gateways']['mycred']['name'] ) );
487
-
488
- // Log Template (no html)
489
- $settings['gateways']['mycred']['log_template'] = stripslashes( wp_filter_nohtml_kses( $settings['gateways']['mycred']['log_template'] ) );
490
- $settings['gateways']['mycred']['type'] = sanitize_text_field( $settings['gateways']['mycred']['type'] );
491
- $settings['gateways']['mycred']['logo'] = stripslashes( wp_filter_nohtml_kses( $settings['gateways']['mycred']['logo'] ) );
492
-
493
- // Exchange rate (if used)
494
- if ( $this->use_exchange() ) {
495
- // Decimals must start with a zero
496
- if ( $settings['gateways']['mycred']['exchange'] != 1 && substr( $settings['gateways']['mycred']['exchange'], 0, 1 ) != '0' ) {
497
- $settings['gateways']['mycred']['exchange'] = (float) '0' . $settings['gateways']['mycred']['exchange'];
498
- }
499
- // Decimal seperator must be punctuation and not comma
500
- $settings['gateways']['mycred']['exchange'] = str_replace( ',', '.', $settings['gateways']['mycred']['exchange'] );
501
- }
502
- else
503
- $settings['gateways']['mycred']['exchange'] = 1;
504
-
505
- $settings['gateways']['mycred']['profit_share_percent'] = stripslashes( trim( $settings['gateways']['mycred']['profit_share_percent'] ) );
506
- $settings['gateways']['mycred']['profit_share_log'] = stripslashes( wp_filter_nohtml_kses( $settings['gateways']['mycred']['profit_share_log'] ) );
507
-
508
- $settings['gateways']['mycred']['lowfunds'] = stripslashes( wp_filter_post_kses( $settings['gateways']['mycred']['lowfunds'] ) );
509
- $settings['gateways']['mycred']['visitors'] = stripslashes( wp_filter_post_kses( $settings['gateways']['mycred']['visitors'] ) );
510
- $settings['gateways']['mycred']['instructions'] = stripslashes( wp_filter_post_kses( $settings['gateways']['mycred']['instructions'] ) );
511
- $settings['gateways']['mycred']['confirmation'] = stripslashes( wp_filter_post_kses( $settings['gateways']['mycred']['confirmation'] ) );
512
-
513
- // Email (no html)
514
- $settings['gateways']['mycred']['email'] = stripslashes( wp_filter_nohtml_kses( $settings['gateways']['mycred']['email'] ) );
515
-
516
- return $settings;
517
- }
518
- }
519
- mp_register_gateway_plugin( 'MP_Gateway_myCRED', 'mycred', 'myCRED' );
520
- }
521
- }
522
-
523
-
524
-
525
- /**
526
- * Filter the myCRED Log
527
- * Parses the %order_id% and %order_link% template tags.
528
- * @since 1.1
529
- * @version 1.1
530
- */
531
- if ( ! function_exists( 'mycred_marketpress_parse_log' ) ) {
532
- add_filter( 'mycred_parse_log_entry_marketpress_payment', 'mycred_marketpress_parse_log', 90, 2 );
533
- function mycred_marketpress_parse_log( $content, $log_entry )
534
- {
535
- // Prep
536
- global $mp;
537
- $mycred = mycred( $log_entry->ctype );
538
- $order = get_post( $log_entry->ref_id );
539
- $order_id = $order->post_title;
540
- $user_id = get_current_user_id();
541
-
542
- // Order ID
543
- $content = str_replace( '%order_id%', $order->post_title, $content );
544
-
545
- // Link to order if we can edit plugin or are the user who made the order
546
- if ( $user_id == $log_entry->user_id || $mycred->can_edit_plugin( $user_id ) ) {
547
- $track_link = '<a href="' . mp_orderstatus_link( false, true ) . $order_id . '/' . '">#' . $order->post_title . '/' . '</a>';
548
- $content = str_replace( '%order_link%', $track_link, $content );
549
- }
550
- else {
551
- $content = str_replace( '%order_link%', '#' . $order_id, $content );
552
- }
553
-
554
- return $content;
555
- }
556
- }
557
-
558
- /**
559
- * Parse Email Notice
560
- * @since 1.2.2
561
- * @version 1.0
562
- */
563
- if ( ! function_exists( 'mycred_market_parse_email' ) ) {
564
- add_filter( 'mycred_email_before_send', 'mycred_market_parse_email' );
565
- function mycred_market_parse_email( $email )
566
- {
567
- if ( $email['request']['ref'] == 'marketpress_payment' ) {
568
- $order = get_post( (int) $email['request']['ref_id'] );
569
- if ( isset( $order->id ) ) {
570
- $track_link = '<a href="' . mp_orderstatus_link( false, true ) . $order_id . '/' . '">#' . $order->post_title . '/' . '</a>';
571
-
572
- $content = str_replace( '%order_id%', $order->post_title, $email['request']['entry'] );
573
- $email['request']['entry'] = str_replace( '%order_link%', $track_link, $content );
574
- }
575
- }
576
- return $email;
577
- }
578
- }
579
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/gateway/event-booking/mycred-eventsmanager-pro.php DELETED
@@ -1,641 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * Events Manager Pro Gateway
6
- * @since 1.3
7
- * @version 1.1
8
- */
9
- if ( ! class_exists( 'EM_Gateway_myCRED' ) ) {
10
- class EM_Gateway_myCRED extends EM_Gateway {
11
-
12
- public $gateway = 'mycred';
13
- public $title = '';
14
- public $status = 1;
15
- public $status_txt = '';
16
- public $mycred_type = 'mycred_default';
17
- public $button_enabled = true;
18
- public $supports_multiple_bookings = true;
19
-
20
- public $registered_timer = 0;
21
-
22
- /**
23
- * Construct
24
- */
25
- function __construct() {
26
- // Default settings
27
- $defaults = array(
28
- 'setup' => 'off',
29
- 'type' => 'mycred_default',
30
- 'rate' => 100,
31
- 'share' => 0,
32
- 'log' => array(
33
- 'purchase' => __( 'Payment for tickets to %link_with_title%', 'mycred' ),
34
- 'refund' => __( 'Ticket refund for %link_with_title%', 'mycred' )
35
- ),
36
- 'refund' => 0,
37
- 'labels' => array(
38
- 'header' => __( 'Pay using your %_plural% balance', 'mycred' ),
39
- 'button' => __( 'Pay Now', 'mycred' ),
40
- 'link' => __( 'Pay', 'mycred' )
41
- ),
42
- 'messages' => array(
43
- 'success' => __( 'Thank you for your payment!', 'mycred' ),
44
- 'error' => __( "I'm sorry but you can not pay for these tickets using %_plural%", 'mycred' )
45
- )
46
- );
47
-
48
- // Settings
49
- $settings = get_option( 'mycred_eventsmanager_gateway_prefs' );
50
- $this->prefs = mycred_apply_defaults( $defaults, $settings );
51
-
52
- $this->mycred_type = $this->prefs['type'];
53
-
54
- // Load myCRED
55
- $this->core = mycred( $this->mycred_type );
56
-
57
- // Apply Whitelabeling
58
- $this->label = mycred_label();
59
- $this->title = strip_tags( $this->label );
60
- $this->status_txt = 'Paid using ' . strip_tags( $this->label );
61
-
62
- parent::__construct();
63
-
64
- if ( !$this->is_active() ) return;
65
-
66
- // Currency
67
- add_filter( 'em_get_currencies', array( $this, 'add_currency' ) );
68
- if ( $this->single_currency() )
69
- add_filter( 'em_get_currency_formatted', array( $this, 'format_price' ), 10, 4 );
70
-
71
- // Adjust Ticket Columns
72
- add_filter( 'em_booking_form_tickets_cols', array( $this, 'ticket_columns' ), 10, 2 );
73
- add_action( 'em_booking_form_tickets_col_mycred', array( $this, 'ticket_col' ), 10, 2 );
74
- add_filter( 'em_bookings_table_cols_col_action', array( $this, 'bookings_table_actions' ), 10, 2 );
75
-
76
- // Refund
77
- if ( $this->prefs['refund'] != 0 )
78
- add_filter( 'em_booking_set_status', array( $this, 'refunds' ), 10, 2 );
79
- }
80
-
81
- /**
82
- * Add Currency
83
- * Adds "Points" as a form of currency
84
- * @since 1.3
85
- * @version 1.0
86
- */
87
- public function add_currency( $currencies ) {
88
- $currencies->names['XMY'] = $this->core->plural();
89
- if ( empty( $this->core->before ) && !empty( $this->core->after ) ) {
90
- $currencies->symbols['XMY'] = $this->core->after;
91
- $currencies->symbols['XMY'] = $this->core->after;
92
- }
93
- elseif ( !empty( $this->core->before ) && empty( $this->core->after ) ) {
94
- $currencies->true_symbols['XMY'] = $this->core->before;
95
- $currencies->true_symbols['XMY'] = $this->core->after;
96
- }
97
-
98
- return $currencies;
99
- }
100
-
101
- /**
102
- * Check if using Single Currency
103
- * @since 1.3
104
- * @version 1.0
105
- */
106
- public function single_currency() {
107
- if ( $this->prefs['setup'] == 'single' ) return true;
108
- return false;
109
- }
110
-
111
- /**
112
- * Format Price
113
- * @since 1.3
114
- * @version 1.0
115
- */
116
- public function format_price( $formatted_price, $price, $currency, $format ) {
117
- if ( $currency == 'XMY' )
118
- return $this->core->format_creds( $price );
119
- else
120
- return $formatted_price;
121
- }
122
-
123
- /**
124
- * Adjust Ticket Columns
125
- * @since 1.3
126
- * @version 1.0
127
- */
128
- public function ticket_columns( $columns, $EM_Event ) {
129
- if ( ! $EM_Event->is_free() ) {
130
- unset( $columns['price'] );
131
- unset( $columns['type'] );
132
- unset( $columns['spaces'] );
133
-
134
- $columns['type'] = __( 'Ticket Type', 'mycred' );
135
-
136
- if ( $this->single_currency() ) {
137
- $columns['mycred'] = __( 'Price', 'mycred' );
138
- }
139
- else {
140
- $columns['price'] = __( 'Price', 'mycred' );
141
- $columns['mycred'] = $this->core->plural();
142
- }
143
- $columns['spaces'] = __( 'Spaces', 'mycred' );
144
- }
145
-
146
- $this->booking_cols = count( $columns );
147
- return $columns;
148
- }
149
-
150
- /**
151
- * Adjust Ticket Column Content
152
- * @since 1.3
153
- * @version 1.0
154
- */
155
- public function ticket_col( $EM_Ticket, $EM_Event ) {
156
- $ticket_price = $EM_Ticket->get_price( false );
157
- if ( $this->single_currency() )
158
- $price = $ticket_price;
159
- else
160
- $price = $this->prefs['rate']*$ticket_price;
161
-
162
- if ( empty( $ticket_price ) )
163
- $price = 0; ?>
164
-
165
- <td class="em-bookings-ticket-table-points"><?php echo $this->core->format_creds( $price ); ?></td>
166
- <?php
167
- }
168
-
169
- /**
170
- * Shows button, not needed if using the new form display
171
- * @since 1.3
172
- * @version 1.0
173
- */
174
- function booking_form_button() {
175
- if ( ! is_user_logged_in() ) return;
176
- $user_id = get_current_user_id();
177
-
178
- // Check for exclusion
179
- if ( $this->core->exclude_user( $user_id ) ) return;
180
-
181
- // Make sure we have points
182
- if ( $this->core->get_users_cred( $user_id, $this->mycred_type ) <= $this->core->format_number( 0 ) ) return;
183
-
184
- $button = get_option( 'em_'. $this->gateway . '_button', $this->title );
185
- ob_start();
186
- if ( preg_match( '/https?:\/\//', $button ) ) { ?>
187
- <input type="image" class="em-booking-submit em-gateway-button" id="em-gateway-button-<?php echo $this->gateway; ?>" src="<?php echo $button; ?>" alt="<?php echo $this->title; ?>" />
188
- <?php } else { ?>
189
- <input type="submit" class="em-booking-submit em-gateway-button" id="em-gateway-button-<?php echo $this->gateway; ?>" value="<?php echo $button; ?>" />
190
- <?php }
191
- $output = ob_get_contents();
192
- ob_end_clean();
193
-
194
- return $output;
195
- }
196
-
197
- /**
198
- * Add Booking
199
- * @since 1.3
200
- * @version 1.0
201
- */
202
- function booking_add( $EM_Event, $EM_Booking, $post_validation = false ) {
203
- parent::booking_add( $EM_Event, $EM_Booking, $post_validation );
204
- if ( $post_validation && empty( $EM_Booking->booking_id ) ) {
205
- if ( get_option( 'dbem_multiple_bookings' ) && get_class( $EM_Booking ) == 'EM_Multiple_Booking' ) {
206
- add_filter( 'em_multiple_booking_save', array( &$this, 'booking_payment' ), 2, 2 );
207
- } else {
208
- add_filter( 'em_booking_save', array( &$this, 'booking_payment' ), 2, 2 );
209
- }
210
- }
211
- }
212
-
213
- /**
214
- * Booking Payment
215
- * @since 1.3
216
- * @version 1.1
217
- */
218
- function booking_payment( $result, $EM_Booking ) {
219
- global $wpdb, $wp_rewrite, $EM_Notices;
220
- //make sure booking save was successful before we try anything
221
- if ( $result ) {
222
- // Event is not free
223
- if ( $EM_Booking->get_price() > 0 ) {
224
- $ok = true;
225
-
226
- // User is excluded from using this gateway
227
- if ( $this->core->exclude_user( $EM_Booking->person->ID ) ) {
228
- $EM_Booking->add_error( __( 'You can not pay using this gateway.', 'mycred' ) );
229
- $ok = false;
230
- }
231
- // User can not afford to pay
232
- elseif ( ! $this->can_pay( $EM_Booking ) ) {
233
- $EM_Booking->add_error( $this->core->template_tags_general( $this->prefs['messages']['error'] ) );
234
- $ok = false;
235
- }
236
- // User has not yet paid (prefered)
237
- elseif ( ! $this->has_paid( $EM_Booking ) ) {
238
- // Price
239
- $price = $this->core->number( $EM_Booking->booking_price );
240
- if ( ! $this->single_currency() ) {
241
- $exchange_rate = $this->prefs['rate'];
242
- $price = $this->core->number( $exchange_rate*$price );
243
- }
244
-
245
- // Charge
246
- $this->core->add_creds(
247
- 'ticket_purchase',
248
- $EM_Booking->person->ID,
249
- 0-$price,
250
- $this->prefs['log']['purchase'],
251
- $EM_Booking->event->post_id,
252
- array( 'ref_type' => 'post', 'bid' => (int) $EM_Booking->booking_id ),
253
- $this->mycred_type
254
- );
255
-
256
- // Log transaction with EM
257
- $transaction_id = time() . $EM_Booking->person->ID;
258
- $EM_Booking->booking_meta[ $this->gateway ] = array( 'txn_id' => $transaction_id, 'amount' => $price );
259
- $this->record_transaction( $EM_Booking, $EM_Booking->get_price( false, false, true ), get_option( 'dbem_bookings_currency' ), current_time( 'mysql' ), $transaction_id, 'Completed', '' );
260
-
261
- // Profit sharing
262
- if ( $this->prefs['share'] != 0 ) {
263
- $event_post = get_post( (int) $EM_Booking->event->post_id );
264
- if ( $event_post !== NULL ) {
265
- $share = ( $this->prefs['share']/100 ) * $price;
266
- $this->core->add_creds(
267
- 'ticket_sale',
268
- $event_post->post_author,
269
- $share,
270
- $this->prefs['log']['purchase'],
271
- $event_post->ID,
272
- array( 'ref_type' => 'post', 'bid' => (int) $EM_Booking->booking_id ),
273
- $this->mycred_type
274
- );
275
- }
276
- }
277
- }
278
- // Something went horribly wrong
279
- else {
280
- $ok = false;
281
- }
282
-
283
- // Successfull Payment
284
- if ( $ok ) {
285
- if ( ! get_option( 'em_' . $this->gateway . '_manual_approval', false ) || ! get_option( 'dbem_bookings_approval' ) ) {
286
- $EM_Booking->set_status( 1, false ); //Approve
287
- } else {
288
- $EM_Booking->set_status( 0, false ); //Set back to normal "pending"
289
- }
290
- }
291
- // Error in payment - delete booking
292
- else {
293
- // Delete any user that got registered for this event
294
- if ( ! is_user_logged_in() && get_option( 'dbem_bookings_anonymous' ) && !get_option( 'dbem_bookings_registration_disable' ) && ! empty( $EM_Booking->person_id ) ) {
295
- $EM_Person = $EM_Booking->get_person();
296
- if ( strtotime( $EM_Person->data->user_registered ) >= $this->registered_timer ) {
297
- if ( is_multisite() ) {
298
- include_once( ABSPATH . '/wp-admin/includes/ms.php' );
299
- wpmu_delete_user( $EM_Person->ID );
300
- } else {
301
- include_once( ABSPATH . '/wp-admin/includes/user.php' );
302
- wp_delete_user( $EM_Person->ID );
303
- }
304
-
305
- // remove email confirmation
306
- global $EM_Notices;
307
- $EM_Notices->notices['confirms'] = array();
308
- }
309
- }
310
-
311
- // Delete booking
312
- $EM_Booking->delete();
313
- return false;
314
- }
315
- }
316
- }
317
- return $result;
318
- }
319
-
320
- /**
321
- * Refunds
322
- * @since 1.3
323
- * @version 1.1
324
- */
325
- public function refunds( $result, $EM_Booking ) {
326
- // Cancellation = refund
327
- if ( $EM_Booking->booking_status == 3 && $EM_Booking->previous_status == 1 && $this->prefs['refund'] > 0 ) {
328
-
329
- // Make sure user has paid for this to refund
330
- if ( $this->has_paid( $EM_Booking ) ) {
331
-
332
- // Price
333
- if ( $this->single_currency() )
334
- $price = $this->core->number( $EM_Booking->booking_price );
335
- else
336
- $price = $this->core->number( $this->prefs['rate']*$EM_Booking->booking_price );
337
-
338
- // Refund
339
- if ( $this->prefs['refund'] != 100 )
340
- $refund = ( $this->prefs['refund'] / 100 ) * $price;
341
- else
342
- $refund = $price;
343
-
344
- // Charge
345
- $this->core->add_creds(
346
- 'ticket_purchase_refund',
347
- $EM_Booking->person->ID,
348
- $refund,
349
- $this->prefs['log']['refund'],
350
- $EM_Booking->event->post_id,
351
- array( 'ref_type' => 'post', 'bid' => (int) $booking_id ),
352
- $this->mycred_type
353
- );
354
- }
355
- }
356
- return $result;
357
- }
358
-
359
- /**
360
- * Customize Booking Table Actions
361
- * @since 1.3
362
- * @version 1.0
363
- */
364
- function bookings_table_actions( $actions, $EM_Booking ) {
365
- if ( $EM_Booking->booking_status == 1 && $this->uses_gateway( $EM_Booking ) ) {
366
- return array(
367
- 'reject' => '<a class="em-bookings-reject" href="' . em_add_get_params( $url, array(
368
- 'action' => 'bookings_reject',
369
- 'booking_id' => $EM_Booking->booking_id
370
- ) ) . '">' . __( 'Reject', 'mycred' ) . '</a>',
371
- 'delete' => '<span class="trash"><a class="em-bookings-delete" href="' . em_add_get_params( $url, array(
372
- 'action' => 'bookings_delete',
373
- 'booking_id' => $EM_Booking->booking_id
374
- ) ) . '">' . __( 'Delete', 'mycred' ) . '</a></span>',
375
- 'edit' => '<a class="em-bookings-edit" href="' . em_add_get_params( $EM_Booking->get_event()->get_bookings_url(), array(
376
- 'booking_id' => $EM_Booking->booking_id,
377
- 'em_ajax' => null,
378
- 'em_obj' => null
379
- ) ) . '">' . __( 'Edit/View', 'mycred' ) . '</a>'
380
- );
381
- }
382
-
383
- return $actions;
384
- }
385
-
386
- /**
387
- * Can Pay Check
388
- * Checks if the user can pay for their booking.
389
- * @since 1.2
390
- * @version 1.1
391
- */
392
- public function can_pay( $EM_Booking ) {
393
- $EM_Event = $EM_Booking->get_event();
394
- // You cant pay for free events
395
- if ( $EM_Event->is_free() ) return false;
396
-
397
- $balance = $this->core->get_users_cred( $EM_Booking->person->ID, $this->mycred_type );
398
- if ( $balance <= $this->core->zero() ) return false;
399
-
400
- $price = $this->core->number( $EM_Booking->booking_price );
401
- if ( $price == $this->core->zero() ) return true;
402
- if ( ! $this->single_currency() ) {
403
- $exchange_rate = $this->prefs['rate'];
404
- $price = $this->core->number( $exchange_rate*$price );
405
- }
406
-
407
- if ( $balance-$price < $this->core->zero() ) return false;
408
-
409
- return true;
410
- }
411
-
412
- /**
413
- * Has Paid
414
- * Checks if the user has paid for booking
415
- * @since 1.3
416
- * @version 1.2
417
- */
418
- public function has_paid( $EM_Booking ) {
419
- if ( $this->core->has_entry(
420
- 'ticket_purchase',
421
- $EM_Booking->event->post_id,
422
- $EM_Booking->person->ID,
423
- array(
424
- 'ref_type' => 'post',
425
- 'bid' => (int) $EM_Booking->booking_id
426
- ),
427
- $this->mycred_type
428
- ) )
429
- return true;
430
-
431
- return false;
432
- }
433
-
434
- /**
435
- * Getway Settings
436
- * @since 1.3
437
- * @version 1.2
438
- */
439
- function mysettings() {
440
- global $page, $action;
441
- $gateway_link = admin_url( 'edit.php?post_type=' . EM_POST_TYPE_EVENT . '&page=events-manager-options#bookings' );
442
-
443
- if ( $this->prefs['setup'] == 'multi' )
444
- $box = 'display: block;';
445
- else
446
- $box = 'display: none;';
447
-
448
- $exchange_message = sprintf(
449
- __( 'How many %s is 1 %s worth?', 'mycred' ),
450
- $this->core->plural(),
451
- em_get_currency_symbol()
452
- );
453
-
454
- $mycred_types = mycred_get_types();
455
-
456
- do_action( 'mycred_em_before_settings', $this ); ?>
457
-
458
- <h4><?php _e( 'Setup', 'mycred' ); ?></h4>
459
- <table class="form-table">
460
- <?php if ( count( $mycred_types ) > 1 ) : ?>
461
-
462
- <tr>
463
- <th scope="row"><?php _e( 'Point Type', 'mycred' ); ?></th>
464
- <td>
465
- <?php mycred_types_select_from_dropdown( 'mycred_gateway[type]', 'mycred-gateway-type', $this->prefs['type'] ); ?>
466
-
467
- </td>
468
- </tr>
469
- <?php else : ?>
470
-
471
- <input type="hidden" name="mycred_gateway[type]" value="mycred_default" />
472
- <?php endif; ?>
473
-
474
- <tr>
475
- <th scope="row"><?php _e( 'Payments', 'mycred' ); ?></th>
476
- <td>
477
- <input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-off" value="off"<?php checked( $this->prefs['setup'], 'off' ); ?> /> <label for="mycred-gateway-setup-off"><?php echo $this->core->template_tags_general( __( 'Disabled - Users CAN NOT pay for tickets using %plural%.', 'mycred' ) ); ?></label><br />
478
- <input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-single" value="single"<?php checked( $this->prefs['setup'], 'single' ); ?> /> <label for="mycred-gateway-setup-single"><?php echo $this->core->template_tags_general( __( 'Single - Users can ONLY pay for tickets using %plural%.', 'mycred' ) ); ?></label><br />
479
- <input type="radio" name="mycred_gateway[setup]" id="mycred-gateway-setup-multi" value="multi"<?php checked( $this->prefs['setup'], 'multi' ); ?> /> <label for="mycred-gateway-setup-multi"><?php echo $this->core->template_tags_general( __( 'Multi - Users can pay for tickets using other gateways or %plural%.', 'mycred' ) ); ?></label>
480
- </td>
481
- </tr>
482
- <tr>
483
- <th scope="row"><?php _e( 'Refunds', 'mycred' ); ?></th>
484
- <td>
485
- <input name="mycred_gateway[refund]" type="text" id="mycred-gateway-log-refund" value="<?php echo $this->prefs['refund']; ?>" size="5" /> %<br />
486
- <span class="description"><?php _e( 'The percentage of the paid amount to refund if a user cancels their booking. Use zero for no refunds. No refunds are given to "Rejected" bookings!', 'mycred' ); ?></span>
487
- </td>
488
- </tr>
489
- <tr>
490
- <th scope="row"><?php _e( 'Profit Sharing', 'mycred' ); ?></th>
491
- <td>
492
- <input name="mycred_gateway[share]" type="text" id="mycred-gateway-profit-sharing" value="<?php echo $this->prefs['share']; ?>" size="5" /> %<br />
493
- <span class="description"><?php _e( 'Option to share sales with the product owner. Use zero to disable.', 'mycred' ); ?></span>
494
- </td>
495
- </tr>
496
- </table>
497
- <table class="form-table" id="mycred-exchange-rate" style="<?php echo $box; ?>">
498
- <tr>
499
- <th scope="row"><?php _e( 'Exchange Rate', 'mycred' ); ?></th>
500
- <td>
501
- <input name="mycred_gateway[rate]" type="text" id="mycred-gateway-rate" size="6" value="<?php echo $this->prefs['rate']; ?>" /><br />
502
- <span class="description"><?php echo $exchange_message; ?></span>
503
- </td>
504
- </tr>
505
- </table>
506
- <h4><?php _e( 'Log Templates', 'mycred' ); ?></h4>
507
- <table class="form-table">
508
- <tr>
509
- <th scope="row"><?php _e( 'Purchases', 'mycred' ); ?></th>
510
- <td>
511
- <input name="mycred_gateway[log][purchase]" type="text" id="mycred-gateway-log-purchase" style="width: 95%;" value="<?php echo $this->prefs['log']['purchase']; ?>" size="45" /><br />
512
- <span class="description"><?php echo $this->core->available_template_tags( array( 'general', 'post' ) ); ?>></span>
513
- </td>
514
- </tr>
515
- <tr>
516
- <th scope="row"><?php _e( 'Refunds', 'mycred' ); ?></th>
517
- <td>
518
- <input name="mycred_gateway[log][refund]" type="text" id="mycred-gateway-log-refund" style="width: 95%;" value="<?php echo $this->prefs['log']['refund']; ?>" size="45" /><br />
519
- <span class="description"><?php echo $this->core->available_template_tags( array( 'general', 'post' ) ); ?></span>
520
- </td>
521
- </tr>
522
- </table>
523
- <script type="text/javascript">
524
- jQuery(function($){
525
- $('input[name="mycred_gateway[setup]"]').change(function(){
526
- if ( $(this).val() == 'multi' ) {
527
- $('#mycred-exchange-rate').show();
528
- }
529
- else {
530
- $('#mycred-exchange-rate').hide();
531
- }
532
- });
533
- });
534
- </script>
535
- <h4><?php _e( 'Labels', 'mycred' ); ?></h4>
536
- <table class="form-table">
537
- <tr valign="top">
538
- <th scope="row"><?php _e( 'Payment Link Label', 'mycred' ); ?></th>
539
- <td>
540
- <input name="mycred_gateway[labels][link]" type="text" id="mycred-gateway-labels-link" style="width: 95%" value="<?php echo $this->prefs['labels']['link']; ?>" size="45" /><br />
541
- <span class="description"><?php _e( 'The payment link shows / hides the payment form under "My Bookings". No HTML allowed.', 'mycred' ); ?></span>
542
- </td>
543
- </tr>
544
- <tr valign="top">
545
- <th scope="row"><?php _e( 'Payment Header', 'mycred' ); ?></th>
546
- <td>
547
- <input name="mycred_gateway[labels][header]" type="text" id="mycred-gateway-labels-header" style="width: 95%" value="<?php echo $this->prefs['labels']['header']; ?>" size="45" /><br />
548
- <span class="description"><?php _e( 'Shown on top of the payment form. No HTML allowed.', 'mycred' ); ?></span>
549
- </td>
550
- </tr>
551
- <tr valign="top">
552
- <th scope="row"><?php _e( 'Button Label', 'mycred' ); ?></th>
553
- <td>
554
- <input name="mycred_gateway[labels][button]" type="text" id="mycred-gateway-labels-button" style="width: 95%" value="<?php echo $this->prefs['labels']['button']; ?>" size="45" /><br />
555
- <span class="description"><?php _e( 'The button label for payments. No HTML allowed!', 'mycred' ); ?></span>
556
- </td>
557
- </tr>
558
- </table>
559
- <h4><?php _e( 'Messages', 'mycred' ); ?></h4>
560
- <table class='form-table'>
561
- <tr valign="top">
562
- <th scope="row"><?php _e( 'Successful Payments', 'mycred' ); ?></th>
563
- <td>
564
- <input type="text" name="mycred_gateway[messages][success]" id="mycred-gateway-messages-success" style="width: 95%;" value="<?php echo stripslashes( $this->prefs['messages']['success'] ); ?>" /><br />
565
- <span class="description"><?php _e( 'No HTML allowed!', 'mycred' ); ?><br /><?php echo $this->core->available_template_tags( array( 'general' ) ); ?></span>
566
- </td>
567
- </tr>
568
- <tr valign="top">
569
- <th scope="row"><?php _e( 'Insufficient Funds', 'mycred' ); ?></th>
570
- <td>
571
- <input type="text" name="mycred_gateway[messages][error]" id="mycred-gateway-messages-error" style="width: 95%;" value="<?php echo stripslashes( $this->prefs['messages']['error'] ); ?>" /><br />
572
- <span class="description"><?php _e( 'No HTML allowed!', 'mycred' ); ?><br /><?php echo $this->core->available_template_tags( array( 'general' ) ); ?></span>
573
- </td>
574
- </tr>
575
- </table>
576
- <?php do_action( 'mycred_em_after_settings', $this );
577
- }
578
-
579
- /**
580
- * Update Getway Settings
581
- * @since 1.3
582
- * @version 1.1
583
- */
584
- function update() {
585
- parent::update();
586
- if ( ! isset( $_POST['mycred_gateway'] ) || ! is_array( $_POST['mycred_gateway'] ) ) return;
587
-
588
- // Prep
589
- $data = $_POST['mycred_gateway'];
590
- $new_settings = array();
591
-
592
- // Setup
593
- $new_settings['setup'] = $data['setup'];
594
- $new_settings['type'] = sanitize_text_field( $data['type'] );
595
- $new_settings['refund'] = abs( $data['refund'] );
596
- $new_settings['share'] = abs( $data['share'] );
597
-
598
- // Logs
599
- $new_settings['log']['purchase'] = trim( stripslashes( $data['log']['purchase'] ) );
600
- $new_settings['log']['refund'] = trim( stripslashes( $data['log']['refund'] ) );
601
-
602
- if ( $new_settings['setup'] == 'multi' )
603
- $new_settings['rate'] = sanitize_text_field( $data['rate'] );
604
- else
605
- $new_settings['rate'] = $this->prefs['rate'];
606
-
607
- // Override Pricing Options
608
- if ( $new_settings['setup'] == 'single' ) {
609
- update_option( 'dbem_bookings_currency_decimal_point', $this->core->format['separators']['decimal'] );
610
- update_option( 'dbem_bookings_currency_thousands_sep', $this->core->format['separators']['thousand'] );
611
- update_option( 'dbem_bookings_currency', 'XMY' );
612
- if ( empty( $this->core->before ) && !empty( $this->core->after ) )
613
- $format = '@ #';
614
- elseif ( !empty( $this->core->before ) && empty( $this->core->after ) )
615
- $format = '# @';
616
- update_option( 'dbem_bookings_currency_format', $format );
617
- }
618
-
619
- // Labels
620
- $new_settings['labels']['link'] = sanitize_text_field( stripslashes( $data['labels']['link'] ) );
621
- $new_settings['labels']['header'] = sanitize_text_field( stripslashes( $data['labels']['header'] ) );
622
- $new_settings['labels']['button'] = sanitize_text_field( stripslashes( $data['labels']['button'] ) );
623
-
624
- // Messages
625
- $new_settings['messages']['success'] = sanitize_text_field( stripslashes( $data['messages']['success'] ) );
626
- $new_settings['messages']['error'] = sanitize_text_field( stripslashes( $data['messages']['error'] ) );
627
-
628
- // Save Settings
629
- $current = $this->prefs;
630
- $this->prefs = mycred_apply_defaults( $current, $new_settings );
631
- update_option( 'mycred_eventsmanager_gateway_prefs', $this->prefs );
632
-
633
- // Let others play
634
- do_action( 'mycred_em_save_settings', $this );
635
-
636
- //default action is to return true
637
- return true;
638
- }
639
- }
640
- }
641
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/gateway/membership/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- ?>
 
 
 
addons/import/includes/File-CSV-DataSource.php DELETED
@@ -1,834 +0,0 @@
1
- <?php
2
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
- if ( !defined( 'myCRED_VERSION' ) ) exit;
4
- /**
5
- * CSV Import Class
6
- *
7
- * LICENSE: The MIT License
8
- *
9
- * Copyright (c) <2008> <Kazuyoshi Tlacaelel>
10
- *
11
- * Permission is hereby granted, free of charge, to any person obtaining a copy
12
- * of this software and associated documentation files (the "Software"), to deal
13
- * in the Software without restriction, including without limitation the rights
14
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- * copies of the Software, and to permit persons to whom the Software is
16
- * furnished to do so, subject to the following conditions:
17
- *
18
- * The above copyright notice and this permission notice shall be included in
19
- * all copies or substantial portions of the Software.
20
- *
21
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
- * THE SOFTWARE.
28
- *
29
- * @author Kazuyoshi Tlacaelel <kazu.dev@gmail.com>
30
- * @edited Gabriel Sebastian Merovingi
31
- * @copyright 2008 Kazuyoshi Tlacaelel
32
- * @license The MIT License
33
- * @version 1.0.1
34
- * @link http://code.google.com/p/php-csv-parser/
35
- */
36
- if ( !class_exists( 'File_CSV_DataSource' ) ) {
37
- class File_CSV_DataSource {
38
-
39
- /**
40
- * CSV Parsing Default-settings
41
- * @var array
42
- * @access public
43
- */
44
- public $settings = array(
45
- 'delimiter' => ',',
46
- 'eol' => ";",
47
- 'length' => 999999,
48
- 'escape' => '"'
49
- );
50
-
51
- /**
52
- * Imported Data from CSV
53
- * @var array
54
- * @access protected
55
- */
56
- protected $rows = array();
57
-
58
- /**
59
- * CSV File to parse
60
- * @var string
61
- * @access protected
62
- */
63
- protected $_filename = '';
64
-
65
- /**
66
- * CSV Headers to parse
67
- * @var array
68
- * @access protected
69
- */
70
- protected $headers = array();
71
-
72
- /**
73
- * Data Load Initialize
74
- * @param mixed $filename please look at the load() method
75
- * @access public
76
- * @see load()
77
- * @return void
78
- */
79
- public function __construct( $filename = null ) {
80
- $this->load( $filename );
81
- }
82
-
83
- /**
84
- * CSV File Loader
85
- * Indicates the object which file is to be loaded
86
- *
87
- * @param string $filename the csv filename to load
88
- * @access public
89
- * @return boolean true if file was loaded successfully
90
- * @see isSymmetric(), getAsymmetricRows(), symmetrize()
91
- */
92
- public function load( $filename ) {
93
- $this->_filename = $filename;
94
- $this->flush();
95
- return $this->parse();
96
- }
97
-
98
- /**
99
- * Settings Alterator
100
- * Lets you define different settings for scanning given array will override the internal settings
101
- *
102
- * @param mixed $array containing settings to use
103
- * @access public
104
- * @return boolean true if changes where applyed successfully
105
- * @see $settings
106
- */
107
- public function settings( $array ) {
108
- $this->settings = array_merge( $this->settings, $array );
109
- }
110
-
111
- /**
112
- * Header Fetcher
113
- * Gets csv headers into an array
114
- *
115
- * @access public
116
- * @return array
117
- */
118
- public function getHeaders() {
119
- return $this->headers;
120
- }
121
-
122
- /**
123
- * Header Counter
124
- * Retrives the total number of loaded headers
125
- *
126
- * @access public
127
- * @return integer gets the length of headers
128
- */
129
- public function countHeaders() {
130
- return count( $this->headers );
131
- }
132
-
133
- /**
134
- * Header and Row Relationship Builder
135
- * Attempts to create a relationship for every single cell that was captured and its corresponding header.
136
- * The sample below shows how a connection/relationship is built.
137
- *
138
- * @param array $columns the columns to connect, if nothing is given all headers will be used to create a connection
139
- * @access public
140
- * @return array If the data is not symmetric an empty array will be returned instead
141
- * @see isSymmetric(), getAsymmetricRows(), symmetrize(), getHeaders()
142
- */
143
- public function connect( $columns = array() ) {
144
- if ( !$this->isSymmetric() ) return array();
145
-
146
- if ( !is_array( $columns ) ) return array();
147
-
148
- if ( $columns === array() ) $columns = $this->headers;
149
-
150
- $ret_arr = array();
151
-
152
- foreach ( $this->rows as $record ) {
153
- $item_array = array();
154
- foreach ( $record as $column => $value ) {
155
- $header = $this->headers[$column];
156
- if ( in_array( $header, $columns ) ) {
157
- $item_array[$header] = $value;
158
- }
159
- }
160
-
161
- // do not append empty results
162
- if ( $item_array !== array() )
163
- array_push( $ret_arr, $item_array );
164
- }
165
-
166
- return $ret_arr;
167
- }
168
-
169
- /**
170
- * Data Length/Symmetry Checker
171
- * Tells if the headers and all of the contents length match.
172
- *
173
- * Note: there is a lot of methods that won't work if data is not symmetric this method is very important!
174
- *
175
- * @access public
176
- * @return boolean
177
- * @see symmetrize(), getAsymmetricRows(), isSymmetric()
178
- */
179
- public function isSymmetric() {
180
- $hc = count( $this->headers );
181
- foreach ( $this->rows as $row ) {
182
- if ( count( $row ) != $hc ) {
183
- return false;
184
- }
185
- }
186
- return true;
187
- }
188
-
189
- /**
190
- * Asymmetric Data Fetcher
191
- * Finds the rows that do not match the headers length lets assume that we add one more row to our csv file.
192
- * that has only two values. Something like
193
- *
194
- * @access public
195
- * @return array filled with rows that do not match headers
196
- * @see getHeaders(), symmetrize(), isSymmetric(),
197
- * getAsymmetricRows()
198
- */
199
- public function getAsymmetricRows() {
200
- $ret_arr = array();
201
- $hc = count( $this->headers );
202
- foreach ( $this->rows as $row ) {
203
- if ( count( $row ) != $hc ) {
204
- $ret_arr[] = $row;
205
- }
206
- }
207
- return $ret_arr;
208
- }
209
-
210
- /**
211
- * All Rows Length Equalizer
212
- * Makes the length of all rows and headers the same. If no $value is given
213
- * all unexistent cells will be filled with empty spaces
214
- *
215
- * @param mixed $value the value to fill the unexistent cells
216
- * @access public
217
- * @return array
218
- * @see isSymmetric(), getAsymmetricRows(), symmetrize()
219
- */
220
- public function symmetrize( $value = '' ) {
221
- $max_length = 0;
222
- $headers_length = count( $this->headers );
223
-
224
- foreach ( $this->rows as $row ) {
225
- $row_length = count( $row );
226
- if ( $max_length < $row_length ) {
227
- $max_length = $row_length;
228
- }
229
- }
230
-
231
- if ( $max_length < $headers_length ) $max_length = $headers_length;
232
-
233
- foreach ( $this->rows as $key => $row ) {
234
- $this->rows[$key] = array_pad( $row, $max_length, $value );
235
- }
236
-
237
- $this->headers = array_pad( $this->headers, $max_length, $value );
238
- }
239
-
240
- /**
241
- * Grid Walker
242
- * Travels through the whole dataset executing a callback per each cell
243
- *
244
- * Note: callback functions get the value of the cell as an argument, and whatever that
245
- * callback returns will be used to replace the current value of that cell.
246
- *
247
- * @param string $callback the callback function to be called per each cell in the dataset.
248
- * @access public
249
- * @return void
250
- * @see walkColumn(), walkRow(), fillColumn(), fillRow(), fillCell()
251
- */
252
- public function walkGrid( $callback ) {
253
- foreach ( array_keys( $this->getRows() ) as $key ) {
254
- if ( !$this->walkRow( $key, $callback ) ) {
255
- return false;
256
- }
257
- }
258
- return true;
259
- }
260
-
261
- /**
262
- * Column Fetcher
263
- * Gets all the data for a specific column identified by $name
264
- *
265
- * Note! $name is the same as the items returned by getHeaders()
266
- *
267
- * @param string $name the name of the column to fetch
268
- * @access public
269
- * @return array filled with values of a column
270
- * @see getHeaders(), fillColumn(), appendColumn(), getCell(), getRows(),
271
- * getRow(), hasColumn()
272
- */
273
- public function getColumn( $name ) {
274
- if ( !in_array( $name, $this->headers ) ) return array();
275
-
276
- $ret_arr = array();
277
- $key = array_search( $name, $this->headers, true );
278
- foreach ( $this->rows as $data ) {
279
- $ret_arr[] = $data[$key];
280
- }
281
- return $ret_arr;
282
- }
283
-
284
- /**
285
- * Column Existance Checker
286
- * Checks if a column exists, columns are identified by their header name.
287
- *
288
- * @param string $string an item returned by getHeaders()
289
- * @access public
290
- * @return boolean
291
- * @see getHeaders()
292
- */
293
- public function hasColumn( $string ) {
294
- return in_array( $string, $this->headers );
295
- }
296
-
297
- /**
298
- * Column Appender
299
- * Appends a column and each or all values in it can be dinamically filled. Only when the $values argument is given.
300
- *
301
- * @param string $column an item returned by getHeaders()
302
- * @param mixed $values same as fillColumn()
303
- * @access public
304
- * @return boolean
305
- * @see getHeaders(), fillColumn(), fillCell(), createHeaders(),
306
- * setHeaders()
307
- */
308
- public function appendColumn( $column, $values = null ) {
309
- if ( $this->hasColumn( $column ) ) return false;
310
-
311
- $this->headers[] = $column;
312
- $length = $this->countHeaders();
313
- $rows = array();
314
-
315
- foreach ( $this->rows as $row ) {
316
- $rows[] = array_pad( $row, $length, '' );
317
- }
318
-
319
- $this->rows = $rows;
320
-
321
- if ( $values === null ) $values = '';
322
-
323
- return $this->fillColumn( $column, $values );
324
- }
325
-
326
- /**
327
- * Collumn Data Injector
328
- * Fills alll the data in the given column with $values
329
- *
330
- * @param mixed $column the column identified by a string
331
- * @param mixed $values ither one of the following
332
- * - (Number) will fill the whole column with the value of number
333
- * - (String) will fill the whole column with the value of string
334
- * - (Array) will fill the while column with the values of array
335
- * the array gets ignored if it does not match the length of rows
336
- *
337
- * @access public
338
- * @return void
339
- */
340
- public function fillColumn( $column, $values = null ) {
341
- if ( !$this->hasColumn( $column ) ) return false;
342
-
343
- if ( $values === null ) return false;
344
-
345
- if ( !$this->isSymmetric() ) return false;
346
-
347
- $y = array_search( $column, $this->headers );
348
-
349
- if ( is_numeric( $values ) || is_string( $values ) ) {
350
- foreach ( range( 0, $this->countRows() -1 ) as $x ) {
351
- $this->fillCell( $x, $y, $values );
352
- }
353
- return true;
354
- }
355
-
356
- if ( $values === array() ) return false;
357
-
358
- $length = $this->countRows();
359
- if ( is_array( $values ) && $length == count( $values ) ) {
360
- for ( $x = 0; $x < $length; $x++ ) {
361
- $this->fillCell( $x, $y, $values[$x] );
362
- }
363
- return true;
364
- }
365
-
366
- return false;
367
- }
368
-
369
- /**
370
- * Column Remover
371
- * Completly removes a whole column identified by $name
372
- * Note: that this function will only work if data is symmetric.
373
- *
374
- * @param string $name same as the ones returned by getHeaders();
375
- * @access public
376
- * @return boolean
377
- * @see hasColumn(), getHeaders(), createHeaders(), setHeaders(),
378
- * isSymmetric(), getAsymmetricRows()
379
- */
380
- public function removeColumn( $name ) {
381
- if ( !in_array( $name, $this->headers ) ) return false;
382
-
383
- if ( !$this->isSymmetric() ) return false;
384
-
385
- $key = array_search( $name, $this->headers );
386
- unset( $this->headers[$key] );
387
- $this->resetKeys( $this->headers );
388
-
389
- foreach ( $this->rows as $target => $row ) {
390
- unset( $this->rows[$target][$key] );
391
- $this->resetKeys( $this->rows[$target] );
392
- }
393
-
394
- return $this->isSymmetric();
395
- }
396
-
397
- /**
398
- * Column Walker
399
- * Goes through the whole column and executes a callback for each
400
- * one of the cells in it.
401
- *
402
- * Note: callback functions get the value of the cell as an
403
- * argument, and whatever that callback returns will be used to
404
- * replace the current value of that cell.
405
- *
406
- * @param string $name the header name used to identify the column
407
- * @param string $callback the callback function to be called per
408
- * each cell value
409
- *
410
- * @access public
411
- * @return boolean
412
- * @see getHeaders(), fillColumn(), appendColumn()
413
- */
414
- public function walkColumn( $name, $callback ) {
415
- if ( !$this->isSymmetric() ) return false;
416
-
417
- if ( !$this->hasColumn( $name ) ) return false;
418
-
419
- if ( !function_exists( $callback ) ) return false;
420
-
421
- $column = $this->getColumn( $name );
422
- foreach ( $column as $key => $cell ) {
423
- $column[$key] = $callback( $cell );
424
- }
425
- return $this->fillColumn( $name, $column );
426
- }
427
-
428
- /**
429
- * Cell Fetcher
430
- * Gets the value of a specific cell by given coordinates
431
- *
432
- * Note: That indexes start with zero, and headers are not
433
- * searched.
434
- *
435
- * @access public
436
- * @return mixed|false the value of the cell or false if the cell does not exist
437
- * @see getHeaders(), hasCell(), getRow(), getRows(), getColumn()
438
- */
439
- public function getCell( $x, $y ) {
440
- if ( $this->hasCell( $x, $y ) ) {
441
- $row = $this->getRow( $x );
442
- return $row[$y];
443
- }
444
- return false;
445
- }
446
-
447
- /**
448
- * Cell Value Filler
449
- * Replaces the value of a specific cell
450
- *
451
- * @param integer $x the row to fetch
452
- * @param integer $y the column to fetch
453
- * @param mixed $value the value to fill the cell with
454
- * @access public
455
- * @return boolean
456
- * @see hasCell(), getRow(), getRows(), getColumn()
457
- */
458
- public function fillCell( $x, $y, $value ) {
459
- if ( !$this->hasCell( $x, $y ) ) return false;
460
-
461
- $row = $this->getRow( $x );
462
- $row[$y] = $value;
463
- $this->rows[$x] = $row;
464
-
465
- return true;
466
- }
467
-
468
- /**
469
- * Checks if a coordinate is valid
470
- *
471
- * @param mixed $x the row to fetch
472
- * @param mixed $y the column to fetch
473
- * @access public
474
- * @return void
475
- */
476
- public function hasCell( $x, $y ) {
477
- $has_x = array_key_exists( $x, $this->rows );
478
- $has_y = array_key_exists( $y, $this->headers );
479
- return ( $has_x && $has_y );
480
- }
481
-
482
- /**
483
- * Row Fetcher
484
- * Note: first row is zero
485
- *
486
- * @param integer $number the row number to fetch
487
- * @access public
488
- * @return array the row identified by number, if $number does
489
- * not exist an empty array is returned instead
490
- */
491
- public function getRow( $number ) {
492
- $raw = $this->rows;
493
- if ( array_key_exists( $number, $raw ) ) {
494
- return $raw[$number];
495
- }
496
- return array();
497
- }
498
-
499
- /**
500
- * Multiple Row Fetcher
501
- * Extracts a rows in the following fashion
502
- * - all rows if no $range argument is given
503
- * - a range of rows identified by their key
504
- * - if rows in range are not found nothing is retrived instead
505
- * - if no rows were found an empty array is returned
506
- *
507
- * @param array $range a list of rows to retrive
508
- * @access public
509
- * @return array
510
- */
511
- public function getRows( $range = array() ) {
512
- if ( is_array( $range ) && ( $range === array() ) ) return $this->rows;
513
-
514
- if ( !is_array( $range ) ) return $this->rows;
515
-
516
- $ret_arr = array();
517
- foreach ( $this->rows as $key => $row ) {
518
- if ( in_array( $key, $range ) ) {
519
- $ret_arr[] = $row;
520
- }
521
- }
522
- return $ret_arr;
523
- }
524
-
525
- /**
526
- * Row Counter
527
- * This function will exclude the headers
528
- *
529
- * @access public
530
- * @return integer
531
- */
532
- public function countRows() {
533
- return count( $this->rows );
534
- }
535
-
536
- /**
537
- * Row Appender
538
- * Aggregates one more row to the currently loaded dataset
539
- *
540
- * @param array $values the values to be appended to the row
541
- * @access public
542
- * @return boolean
543
- */
544
- public function appendRow( $values ) {
545
- $this->rows[] = array();
546
- $this->symmetrize();
547
- return $this->fillRow( $this->countRows() - 1, $values );
548
- }
549
-
550
- /**
551
- * Fill Row
552
- * Replaces the contents of cells in one given row with $values.
553
- *
554
- * @param integer $row the row to fill identified by its key
555
- * @param mixed $values the value to use, if a string or number
556
- * is given the whole row will be replaced with this value.
557
- * if an array is given instead the values will be used to fill
558
- * the row. Only when the currently loaded dataset is symmetric
559
- * @access public
560
- * @return boolean
561
- * @see isSymmetric(), getAsymmetricRows(), symmetrize(), fillColumn(),
562
- * fillCell(), appendRow()
563
- */
564
- public function fillRow( $row, $values ) {
565
- if ( !$this->hasRow( $row ) ) return false;
566
-
567
- if ( is_string( $values ) || is_numeric( $values ) ) {
568
- foreach ( $this->rows[$row] as $key => $cell ) {
569
- $this->rows[$row][$key] = $values;
570
- }
571
- return true;
572
- }
573
-
574
- $eql_to_headers = ( $this->countHeaders() == count( $values ) );
575
- if ( is_array( $values ) && $this->isSymmetric() && $eql_to_headers ) {
576
- $this->rows[$row] = $values;
577
- return true;
578
- }
579
-
580
- return false;
581
- }
582
-
583
- /**
584
- * Row Existance Checker
585
- * Scans currently loaded dataset and checks if a given row identified by $number exists
586
- *
587
- * @param mixed $number a numeric value that identifies the row you are trying to fetch.
588
- * @access public
589
- * @return boolean
590
- * @see getRow(), getRows(), appendRow(), fillRow()
591
- */
592
- public function hasRow( $number ) {
593
- return ( in_array( $number, array_keys( $this->rows ) ) );
594
- }
595
-
596
- /**
597
- * Row Remover
598
- * Removes one row from the current data set.
599
- *
600
- * @param mixed $number the key that identifies that row
601
- * @access public
602
- * @return boolean
603
- * @see hasColumn(), getHeaders(), createHeaders(), setHeaders(),
604
- * isSymmetric(), getAsymmetricRows()
605
- */
606
- public function removeRow( $number ) {
607
- $cnt = $this->countRows();
608
- $row = $this->getRow( $number );
609
- if ( is_array( $row ) && ( $row != array() ) ) {
610
- unset( $this->rows[$number] );
611
- } else {
612
- return false;
613
- }
614
- $this->resetKeys( $this->rows );
615
- return ( $cnt == ( $this->countRows() + 1 ) );
616
- }
617
-
618
- /**
619
- * Row Walker
620
- * Goes through one full row of data and executes a callback function per each cell in that row.
621
- *
622
- * Note: callback functions get the value of the cell as an argument, and whatever that callback
623
- * returns will be used to replace the current value of that cell.
624
- *
625
- * @param string|integer $row anything that is numeric is a valid row identificator. As long as
626
- * it is within the range of the currently loaded dataset
627
- * @param string $callback the callback function to be executed per each cell in a row
628
- * @access public
629
- * @return boolean
630
- * - false if callback does not exist
631
- * - false if row does not exits
632
- */
633
- public function walkRow( $row, $callback ) {
634
- if ( !function_exists( $callback ) ) return false;
635
-
636
- if ( $this->hasRow( $row ) ) {
637
- foreach ( $this->getRow( $row ) as $key => $value ) {
638
- $this->rows[$row][$key] = $callback( $value );
639
- }
640
- return true;
641
- }
642
- return false;
643
- }
644
-
645
- /**
646
- * Raw Data as array
647
- * Gets the data that was retrived from the csv file as an array
648
- *
649
- * Note: that changes and alterations made to rows, columns and values will
650
- * also reflect on what this function retrives.
651
- *
652
- * @access public
653
- * @return array
654
- * @see connect(), getHeaders(), getRows(), isSymmetric(), getAsymmetricRows(),
655
- * symmetrize()
656
- */
657
- public function getRawArray() {
658
- $ret_arr = array();
659
- $ret_arr[] = $this->headers;
660
- foreach ( $this->rows as $row ) {
661
- $ret_arr[] = $row;
662
- }
663
- return $ret_arr;
664
- }
665
-
666
- /**
667
- * Header Creator
668
- * Uses prefix and creates a header for each column suffixed by a numeric value
669
- * By default the first row is interpreted as headers but if we have a csv file with
670
- * data only and no headers it becomes really annoying to work with the current loaded data.
671
- * This function will create a set dinamically generated headers and make the current
672
- * headers accessable with the row handling functions
673
- *
674
- * Note: that the csv file contains only data but no headers
675
- *
676
- * @param string $prefix string to use as prefix for each independent header
677
- * @access public
678
- * @return boolean fails if data is not symmetric
679
- * @see isSymmetric(), getAsymmetricRows()
680
- */
681
- public function createHeaders( $prefix ) {
682
- if ( !$this->isSymmetric() ) return false;
683
-
684
- $length = count( $this->headers ) + 1;
685
- $this->moveHeadersToRows();
686
-
687
- $ret_arr = array();
688
- for ( $i = 1; $i < $length; $i++ ) {
689
- $ret_arr[] = $prefix . "_$i";
690
- }
691
- $this->headers = $ret_arr;
692
- return $this->isSymmetric();
693
- }
694
-
695
- /**
696
- * Header Injector
697
- * Uses a $list of values which wil be used to replace current headers.
698
- *
699
- * Note: that given $list must match the length of all rows.
700
- * Known as symmetric. see isSymmetric() and getAsymmetricRows() methods
701
- * Also, that current headers will be used as first row of data
702
- * and consecuently all rows order will change with this action.
703
- *
704
- * @param array $list a collection of names to use as headers,
705
- * @access public
706
- * @return boolean fails if data is not symmetric
707
- * @see isSymmetric(), getAsymmetricRows(), getHeaders(), createHeaders()
708
- */
709
- public function setHeaders( $list ) {
710
- if ( !$this->isSymmetric() ) return false;
711
-
712
- if ( !is_array( $list ) ) return false;
713
-
714
- if ( count( $list ) != count( $this->headers ) ) return false;
715
-
716
- $this->moveHeadersToRows();
717
- $this->headers = $list;
718
- return true;
719
- }
720
-
721
- /**
722
- * CSV Parser
723
- * Reads csv data and transforms it into php-data
724
- *
725
- * @access protected
726
- * @return boolean
727
- */
728
- protected function parse() {
729
- if ( !$this->validates() ) return false;
730
-
731
- $c = 0;
732
- $d = $this->settings['delimiter'];
733
- $e = $this->settings['escape'];
734
- $l = $this->settings['length'];
735
-
736
- $res = fopen( $this->_filename, 'r' );
737
-
738
- while ( $keys = fgetcsv( $res, $l, $d, $e ) ) {
739
-
740
- if ( $c == 0 ) {
741
- $this->headers = $keys;
742
- } else {
743
- array_push( $this->rows, $keys );
744
- }
745
- $c ++;
746
- }
747
-
748
- fclose( $res );
749
- $this->removeEmpty();
750
- return true;
751
- }
752
-
753
- /**
754
- * Empty row remover
755
- * Removes all records that have been defined but have no data.
756
- *
757
- * @access protected
758
- * @return array containing only the rows that have data
759
- */
760
- protected function removeEmpty() {
761
- $ret_arr = array();
762
- foreach ( $this->rows as $row ) {
763
- $line = trim( join( '', $row ) );
764
- if ( !empty( $line ) ) {
765
- $ret_arr[] = $row;
766
- }
767
- }
768
- $this->rows = $ret_arr;
769
- }
770
-
771
- /**
772
- * CSV File Validator
773
- * Checks wheather if the given csv file is valid or not
774
- *
775
- * @access protected
776
- * @return boolean
777
- */
778
- protected function validates() {
779
- // file existance
780
- if ( !file_exists( $this->_filename ) ) return false;
781
-
782
- // file readability
783
- if ( !is_readable( $this->_filename ) ) return false;
784
-
785
- return true;
786
- }
787
-
788
- /**
789
- * Header Relocator
790
- * @access protected
791
- * @return void
792
- */
793
- protected function moveHeadersToRows() {
794
- $arr = array();
795
- $arr[] = $this->headers;
796
- foreach ( $this->rows as $row ) {
797
- $arr[] = $row;
798
- }
799
- $this->rows = $arr;
800
- $this->headers = array();
801
- }
802
-
803
- /**
804
- * Array Key Reseter
805
- * Makes sure that an array's keys are setted in a correct numerical order
806
- *
807
- * Note: that this function does not return anything, all changes are made to
808
- * the original array as a reference
809
- *
810
- * @param array &$array any array, if keys are strings they will be replaced with numeric values
811
- * @access protected
812
- * @return void
813
- */
814
- protected function resetKeys( &$array ) {
815
- $arr = array();
816
- foreach ( $array as $item ) {
817
- $arr[] = $item;
818
- }
819
- $array = $arr;
820
- }
821
-
822
- /**
823
- * Object Data Flusher
824
- * Tells this object to forget all data loaded and start from scratch
825
- * @access protected
826
- * @return void
827
- */
828
- protected function flush() {
829
- $this->rows = array();
830
- $this->headers = array();
831
- }
832
- }
833
- }
834
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/import/includes/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- ?>
 
 
 
addons/import/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- ?>
 
 
 
addons/import/myCRED-addon-import.php DELETED
@@ -1,782 +0,0 @@
1
- <?php
2
- /**
3
- * Addon: Import
4
- * Addon URI: http://mycred.me/add-ons/import/
5
- * Version: 1.0.2
6
- * Description: With the Import add-on you can import CSV files, CubePoints or existing points under any custom user meta values.
7
- * Author: Gabriel S Merovingi
8
- * Author URI: http://www.merovingi.com
9
- */
10
- // Translate Header (by Dan bp-fr)
11
- $mycred_addon_header_translate = array(
12
- __( 'Import', 'mycred' ),
13
- __( 'With the Import add-on you can import CSV files, CubePoints or existing points under any custom user meta values.', 'mycred' )
14
- );
15
-
16
- if ( !defined( 'myCRED_VERSION' ) ) exit;
17
-
18
- define( 'myCRED_IMPORT', __FILE__ );
19
- define( 'myCRED_IMPORT_VERSION', myCRED_VERSION . '.1' );
20
- /**
21
- * myCRED_Import class
22
- *
23
- * Manages all available imports.
24
- * @since 0.1
25
- * @version 1.0
26
- */
27
- if ( !class_exists( 'myCRED_Import' ) ) {
28
- class myCRED_Import extends myCRED_Module {
29
-
30
- public $errors = '';
31
- public $import_ok = false;
32
-
33
- /**
34
- * Construct
35
- */
36
- function __construct() {
37
- parent::__construct( 'myCRED_Import', array(
38
- 'module_name' => 'import',
39
- 'labels' => array(
40
- 'menu' => __( 'Import', 'mycred' ),
41
- 'page_title' => __( 'Import', 'mycred' ),
42
- 'page_header' => __( 'Import', 'mycred' )
43
- ),
44
- 'screen_id' => 'myCRED_page_import',
45
- 'accordion' => true,
46
- 'register' => false,
47
- 'menu_pos' => 90
48
- ) );
49
-
50
- add_action( 'mycred_help', array( $this, 'help' ), 10, 2 );
51
- }
52
-
53
- /**
54
- * Module Init
55
- * @since 0.1
56
- * @version 1.0
57
- */
58
- public function module_init() {
59
- $installed = $this->get();
60
-
61
- // If an import is selected, run it
62
- if ( empty( $installed ) || !isset( $_REQUEST['selected-import'] ) ) return;
63
- if ( !array_key_exists( $_REQUEST['selected-import'], $installed ) ) return;
64
-
65
- $call = 'import_' . $_REQUEST['selected-import'];
66
- $this->$call();
67
-
68
- // Open accordion for import
69
- add_filter( 'mycred_localize_admin', array( $this, 'accordion' ) );
70
- }
71
-
72
- /**
73
- * Adjust Accordion
74
- * Marks the given import as active.
75
- * @since 0.1
76
- * @version 1.0
77
- */
78
- public function accordion() {
79
- $key = array_search( trim( $_REQUEST['selected-import'] ), array_keys( $this->installed ) );
80
- return array( 'active' => $key );
81
- }
82
-
83
- /**
84
- * Get Imports
85
- * @since 0.1
86
- * @version 1.0
87
- */
88
- public function get( $save = false ) {
89
- // Defaults
90
- $installed['csv'] = array(
91
- 'title' => __( 'CSV File', 'mycred' ),
92
- 'description' => __( 'Import %_plural% from a comma-separated values (CSV) file.', 'mycred' )
93
- );
94
- $installed['cubepoints'] = array(
95
- 'title' => __( 'CubePoints', 'mycred' ),
96
- 'description' => __( 'Import CubePoints', 'mycred' )
97
- );
98
- $installed['custom'] = array(
99
- 'title' => __( 'Custom User Meta', 'mycred' ),
100
- 'description' => __( 'Import %_plural% from pre-existing custom user meta.', 'mycred' )
101
- );
102
- $installed = apply_filters( 'mycred_setup_imports', $installed );
103
-
104
- $this->installed = $installed;
105
- return $installed;
106
- }
107
-
108
- /**
109
- * Update Users
110
- * @param $data (array), required associative array of users and amounts to be added to their account.
111
- * @since 0.1
112
- * @version 1.1
113
- */
114
- public function update_users( $data = array(), $verify = true ) {
115
- // Prep
116
- $id_user_by = 'id';
117
- if ( isset( $_POST['id_user_by'] ) )
118
- $id_user_by = $_POST['id_user_by'];
119
-
120
- $xrate = 1;
121
- if ( isset( $_POST['xrate'] ) )
122
- $xrate = $_POST['xrate'];
123
-
124
- $round = false;
125
- if ( isset( $_POST['round'] ) && $_POST['round'] != 'none' )
126
- $round = $_POST['round'];
127
-
128
- $precision = false;
129
- if ( isset( $_POST['precision'] ) && $_POST['precision'] != 0 )
130
- $precision = $_POST['precision'];
131
-
132
- // Loop
133
- $imports = $skipped = 0;
134
- foreach ( $data as $row ) {
135
- // mycred_user and mycred_amount are two mandatory columns!
136
- if ( !isset( $row['mycred_user'] ) || empty( $row['mycred_user'] ) ) {
137
- $skipped = $skipped+1;
138
- continue;
139
- }
140
- if ( !isset( $row['mycred_amount'] ) || empty( $row['mycred_amount'] ) ) {
141
- $skipped = $skipped+1;
142
- continue;
143
- }
144
-
145
- // Verify User exist
146
- if ( $verify === true ) {
147
- // Get User (and with that confirm user exists)
148
- $user = get_user_by( $id_user_by, $row['mycred_user'] );
149
-
150
- // User does not exist
151
- if ( $user === false ) {
152
- $skipped = $skipped+1;
153
- continue;
154
- }
155
-
156
- // User ID
157
- $user_id = $user->ID;
158
- unset( $user );
159
- }
160
- else {
161
- $user_id = $row['mycred_user'];
162
- }
163
-
164
- // Users is excluded
165
- if ( $this->core->exclude_user( $user_id ) ) {
166
- $skipped = $skipped+1;
167
- continue;
168
- }
169
-
170
- // Amount (can not be zero)
171
- $cred = $this->core->number( $row['mycred_amount'] );
172
- if ( $cred == 0 ) {
173
- $skipped = $skipped+1;
174
- continue;
175
- }
176
-
177
- // If exchange rate is not 1 for 1
178
- if ( $xrate != 1 ) {
179
- // Cred = rate*amount
180
- $amount = $xrate * $row['mycred_amount'];
181
- $cred = $this->core->round_value( $amount, $round, $precision );
182
- }
183
-
184
- // Adjust Balance
185
- $new_balance = $this->core->update_users_balance( $user_id, $cred );
186
-
187
- // First we check if the mycred_log column is used
188
- if ( isset( $row['mycred_log'] ) && !empty( $row['mycred_log'] ) ) {
189
- $this->core->add_to_log( 'import', $user_id, $cred, $row['mycred_log'] );
190
- }
191
- // Second we check if the log template is set
192
- elseif ( isset( $_POST['log_template'] ) && !empty( $_POST['log_template'] ) ) {
193
- $this->core->add_to_log( 'import', $user_id, $cred, sanitize_text_field( $_POST['log_template'] ) );
194
- }
195
-
196
- $imports = $imports+1;
197
- }
198
-
199
- // Pass on the news
200
- $this->imports = $imports;
201
- $this->skipped = $skipped;
202
-
203
- unset( $data );
204
- }
205
-
206
- /**
207
- * CSV Importer
208
- * Based on the csv-importer plugin. Thanks for teaching me something new.
209
- *
210
- * @see http://wordpress.org/extend/plugins/csv-importer/
211
- * @since 0.1
212
- * @version 1.0
213
- */
214
- public function import_csv() {
215
- // We need a file. or else...
216
- if ( !isset( $_FILES['mycred_csv'] ) || empty( $_FILES['mycred_csv']['tmp_name'] ) ) {
217
- $this->errors = __( 'No file selected. Please select your CSV file and try again.', 'mycred' );
218
- return;
219
- }
220
-
221
- // Grab CSV Data Fetcher
222
- require_once( myCRED_ADDONS_DIR . 'import/includes/File-CSV-DataSource.php' );
223
-
224
- // Prep
225
- $time_start = microtime( true );
226
- $csv = new File_CSV_DataSource();
227
- $file = $_FILES['mycred_csv']['tmp_name'];
228
- $this->strip_BOM( $file );
229
-
230
- // Failed to load file
231
- if ( !$csv->load( $file ) ) {
232
- $this->errors = __( 'Failed to load file.', 'mycred' );
233
- return;
234
- }
235
-
236
- // Equality for all
237
- $csv->symmetrize();
238
-
239
- // Update
240
- $this->update_users( $csv->connect() );
241
-
242
- // Unlink
243
- if ( file_exists( $file ) ) {
244
- @unlink( $file );
245
- }
246
-
247
- // Time
248
- $exec_time = microtime( true ) - $time_start;
249
-
250
- // Throw an error if there were no imports just skipps
251
- if ( $this->imports == 0 && $this->skipped != 0 ) {
252
- $this->errors = sprintf(
253
- __( 'Zero rows imported! Skipped %d entries. Import completed in %.2f seconds.', 'mycred' ),
254
- $this->skipped,
255
- $exec_time
256
- );
257
- return;
258
- }
259
-
260
- // Throw an error if there were no imports and no skipps
261
- elseif ( $this->imports == 0 && $this->skipped == 0 ) {
262
- $this->errors = __( 'No valid records found in file. Make sure you have selected the correct way to identify users in the mycred_user column!', 'mycred' );
263
- return;
264
- }
265
-
266
- // The joy of success
267
- $this->import_ok = sprintf(
268
- __( 'Import successfully completed. A total of %d users were effected and %d entires were skipped. Import completed in %.2f seconds.', 'mycred' ),
269
- $this->imports,
270
- $this->skipped,
271
- $exec_time
272
- );
273
-
274
- // Clean Up
275
- unset( $_FILES );
276
- unset( $csv );
277
-
278
- // Close accordion
279
- unset( $_POST );
280
- }
281
-
282
- /**
283
- * Import CubePoints
284
- * @since 0.1
285
- * @version 1.2
286
- */
287
- public function import_cubepoints() {
288
- $delete = false;
289
- if ( isset( $_POST['delete'] ) ) $delete = true;
290
-
291
- $meta_key = 'cpoints';
292
- $time_start = microtime( true );
293
-
294
- global $wpdb;
295
-
296
- // DB Query
297
- $SQL = "SELECT * FROM {$wpdb->usermeta} WHERE meta_key = %s;";
298
- $search = $wpdb->get_results( $wpdb->prepare( $SQL, $meta_key ) );
299
-
300
- // No results
301
- if ( $wpdb->num_rows == 0 ) {
302
- $this->errors = __( 'No CubePoints found.', 'mycred' );
303
- return;
304
- }
305
-
306
- // Found something
307
- else {
308
- // Construct a new array for $this->update_users() to match the format used
309
- // when importing CSV files. User ID goes under 'mycred_user' while 'mycred_amount' holds the value.
310
- $data = array();
311
- foreach ( $search as $result ) {
312
- $data[] = array(
313
- 'mycred_user' => $result->user_id,
314
- 'mycred_amount' => $result->meta_value,
315
- 'mycred_log' => ( isset( $_POST['log_template'] ) ) ? sanitize_text_field( $_POST['log_template'] ) : ''
316
- );
317
- }
318
-
319
- // Update User without the need to verify the user
320
- $this->update_users( $data, false );
321
-
322
- // Delete old value if requested
323
- if ( $delete === true ) {
324
- foreach ( $search as $result ) {
325
- delete_user_meta( $result->user_id, $meta_key );
326
- }
327
- }
328
- }
329
-
330
- // Time
331
- $exec_time = microtime( true ) - $time_start;
332
-
333
- // Throw an error if there were no imports just skipps
334
- if ( $this->imports == 0 && $this->skipped != 0 ) {
335
- $this->errors = sprintf(
336
- __( 'Zero CubePoints imported! Skipped %d entries. Import completed in %.2f seconds.', 'mycred' ),
337
- $this->skipped,
338
- $exec_time
339
- );
340
- return;
341
- }
342
-
343
- // Throw an error if there were no imports and no skipps
344
- elseif ( $this->imports == 0 && $this->skipped == 0 ) {
345
- $this->errors = __( 'No valid CubePoints founds.', 'mycred' );
346
- return;
347
- }
348
-
349
- // The joy of success
350
- $this->import_ok = sprintf(
351
- __( 'Import successfully completed. A total of %d users were effected and %d entires were skipped. Import completed in %.2f seconds.', 'mycred' ),
352
- $this->imports,
353
- $this->skipped,
354
- $exec_time
355
- );
356
-
357
- // Clean Up
358
- unset( $search );
359
-
360
- // Close Accordion
361
- unset( $_POST );
362
- }
363
-
364
- /**
365
- * Import Custom User Meta
366
- * @since 0.1
367
- * @version 1.0.1
368
- */
369
- public function import_custom() {
370
- if ( !isset( $_POST['meta_key'] ) || empty( $_POST['meta_key'] ) ) {
371
- $this->errors = __( 'Missing meta key. Not sure what I should be looking for.', 'mycred' );
372
- return;
373
- }
374
-
375
- // Prep
376
- $delete = false;
377
- if ( isset( $_POST['delete'] ) ) $delete = true;
378
-
379
- $meta_key = $_POST['meta_key'];
380
- $time_start = microtime( true );
381
-
382
- global $wpdb;
383
-
384
- // DB Query
385
- $SQL = "SELECT * FROM {$pwbd->usermeta} WHERE meta_key = %s;";
386
- $search = $wpdb->get_results( $wpdb->prepare( $SQL, $meta_key ) );
387
-
388
- // No results
389
- if ( $wpdb->num_rows == 0 ) {
390
- $this->errors = sprintf( __( 'No rows found for the <strong>%s</strong> meta key.', 'mycred' ), $meta_key );
391
- return;
392
- }
393
-
394
- // Found something
395
- else {
396
- // Construct a new array for $this->update_users() to match the format used
397
- // when importing CSV files. User ID goes under 'mycred_user' while 'mycred_amount' holds the value.
398
- $data = array();
399
- foreach ( $search as $result ) {
400
- $data[] = array(
401
- 'mycred_user' => $result->user_id,
402
- 'mycred_amount' => $result->meta_value
403
- );
404
- }
405
-
406
- // Update User without the need to verify the user
407
- $this->update_users( $data, false );
408
-
409
- // Delete old value if requested
410
- if ( $delete === true ) {
411
- foreach ( $search as $result ) {
412
- delete_user_meta( $result->user_id, $meta_key );
413
- }
414
- }
415
- }
416
-
417
- // Time
418
- $exec_time = microtime( true ) - $time_start;
419
-
420
- // Throw an error if there were no imports just skipps
421
- if ( $this->imports == 0 && $this->skipped != 0 ) {
422
- $this->errors = sprintf(
423
- __( 'Zero rows imported! Skipped %d entries. Import completed in %.2f seconds.', 'mycred' ),
424
- $this->skipped,
425
- $exec_time
426
- );
427
- return;
428
- }
429
-
430
- // Throw an error if there were no imports and no skipps
431
- elseif ( $this->imports == 0 && $this->skipped == 0 ) {
432
- $this->errors = __( 'No valid records founds.', 'mycred' );
433
- return;
434
- }
435
-
436
- // The joy of success
437
- $this->import_ok = sprintf(
438
- __( 'Import successfully completed. A total of %d users were effected and %d entires were skipped. Import completed in %.2f seconds.', 'mycred' ),
439
- $this->imports,
440
- $this->skipped,
441
- $exec_time
442
- );
443
-
444
- // Clean Up
445
- unset( $search );
446
-
447
- // Close Accordion
448
- unset( $_POST );
449
- }
450
-
451
- /**
452
- * Admin Page
453
- * @since 0.1
454
- * @version 1.0
455
- */
456
- public function admin_page() {
457
- // Security
458
- if ( !$this->core->can_edit_plugin( get_current_user_id() ) ) wp_die( __( 'Access Denied', 'mycred' ) );
459
-
460
- // Available Imports
461
- if ( empty( $this->installed ) )
462
- $this->get(); ?>
463
-
464
- <div class="wrap list" id="myCRED-wrap">
465
- <div id="icon-myCRED" class="icon32"><br /></div>
466
- <h2><?php echo sprintf( __( '%s Import', 'mycred' ), mycred_label() ); ?></h2>
467
- <?php
468
- // Errors
469
- if ( !empty( $this->errors ) ) {
470
- echo '<div class="error"><p>' . $this->errors . '</p></div>';
471
- }
472
-
473
- // Success
474
- elseif ( $this->import_ok !== false ) {
475
- echo '<div class="updated"><p>' . $this->import_ok . '</p></div>';
476
- } ?>
477
-
478
- <p><?php _e( 'Remember to de-activate this add-on once you are done importing!', 'mycred' ); ?></p>
479
- <div class="list-items expandable-li" id="accordion">
480
- <?php
481
- if ( !empty( $this->installed ) ) {
482
- foreach ( $this->installed as $id => $data ) {
483
- $call = $id . '_form';
484
- $this->$call( $data );
485
- }
486
- } ?>
487
-
488
- </div>
489
- </div>
490
- <?php
491
- unset( $this );
492
- }
493
-
494
- /**
495
- * CSV Import Form
496
- * @since 0.1
497
- * @version 1.0
498
- */
499
- public function csv_form( $data ) {
500
- $max_upload = (int) ( ini_get( 'upload_max_filesize' ) );
501
- $max_post = (int) ( ini_get( 'post_max_size' ) );
502
- $memory_limit = (int) ( ini_get( 'memory_limit' ) );
503
- $upload_mb = min( $max_upload, $max_post, $memory_limit ); ?>
504
-
505
- <h4><div class="icon icon-active"></div><label><?php echo $data['title']; ?></label></h4>
506
- <div class="body" style="display:none;">
507
- <form class="add:the-list: validate" method="post" enctype="multipart/form-data">
508
- <input type="hidden" name="selected-import" value="csv" />
509
- <p><?php echo nl2br( $this->core->template_tags_general( $data['description'] ) ); ?></p>
510
- <label class="subheader" for="mycred-csv-file"><?php _e( 'File', 'mycred' ); ?></label>
511
- <ol>
512
- <li>
513
- <div><input type="file" name="mycred_csv" id="mycred-csv-file" value="" aria-required="true" /></div>
514
- <span class="description"><?php echo __( 'Maximum allowed upload size is ', 'mycred' ) . $upload_mb . ' Mb<br />' . __( 'Required columns: <code>mycred_user</code> and <code>mycred_amount</code>. Optional columns: <code>mycred_log</code>.', 'mycred' ); ?></span>
515
- </li>
516
- </ol>
517
- <label class="subheader"><?php _e( 'Identify Users By', 'mycred' ); ?></label>
518
- <ol>
519
- <li>
520
- <input type="radio" name="id_user_by" id="mycred-csv-by-id" value="id" checked="checked" /><label for="mycred-csv-by-id"><?php _e( 'ID', 'mycred' ); ?></label><br />
521
- <input type="radio" name="id_user_by" id="mycred-csv-by-login" value="login" /><label for="mycred-csv-by-login"><?php _e( 'Username', 'mycred' ); ?></label><br />
522
- <input type="radio" name="id_user_by" id="mycred-csv-by-email" value="email" /><label for="mycred-csv-by-email"><?php _e( 'Email', 'mycred' ); ?></label>
523
- </li>
524
- </ol>
525
- <label class="subheader" for="mycred-csv-xrate"><?php _e( 'Exchange Rate', 'mycred' ); ?></label>
526
- <ol>
527
- <li>
528
- <div class="h2"><input type="text" name="xrate" id="mycred-csv-xrate" value="<?php echo $this->core->format_number( 1 ); ?>" class="short" /> = <?php echo $this->core->format_creds( 1 ); ?></div>
529
- <span class="description"><?php _e( 'How much is 1 imported value worth?', 'mycred' ); ?></span>
530
- </li>
531
- </ol>
532
- <ol class="inline">
533
- <li>
534
- <label><?php _e( 'Round', 'mycred' ); ?></label><br />
535
- <input type="radio" name="round" id="mycred-csv-round-none" value="none" checked="checked" /> <label for="mycred-csv-round-none"><?php _e( 'None', 'mycred' ); ?></label><br />
536
- <input type="radio" name="round" id="mycred-csv-round-up" value="up" /> <label for="mycred-csv-round-up"><?php _e( 'Round Up', 'mycred' ); ?></label><br />
537
- <input type="radio" name="round" id="mycred-csv-round-down" value="down" /> <label for="mycred-csv-round-down"><?php _e( 'Round Down', 'mycred' ); ?></label>
538
- </li>
539
- <?php if ( $this->core->format['decimals'] > 0 ) { ?>
540
-
541
- <li>
542
- <label for="mycred-csv-precision"><?php _e( 'Precision', 'mycred' ); ?></label>
543
- <div class="h2"><input type="text" name="precision" id="mycred-csv-precision" value="1" class="short" /></div>
544
- <span class="description"><?php echo __( 'The optional number of decimal digits to round to. Use zero to round the nearest whole number.', 'mycred' ); ?></span>
545
- </li>
546
- <?php } ?>
547
-
548
- </ol>
549
- <label class="subheader" for="mycred-csv-log-template"><?php _e( 'Log Entry', 'mycred' ); ?></label>
550
- <ol>
551
- <li>
552
- <div class="h2"><input type="text" name="log_template" id="mycred-csv-log-template" value="" class="long" /></div>
553
- <span class="description"><?php _e( 'See the help tab for available template tags. Leave blank to disable.', 'mycred' ); ?></span>
554
- </li>
555
- </ol>
556
- <ol>
557
- <li>
558
- <input type="submit" name="submit" id="mycred-csv-submit" value="<?php _e( 'Run Import', 'mycred' ); ?>" class="button button-primary button-large" />
559
- </li>
560
- </ol>
561
- </form>
562
- </div>
563
- <?php
564
- }
565
-
566
- /**
567
- * CubePoints Import Form
568
- * @since 0.1
569
- * @version 1.0
570
- */
571
- public function cubepoints_form( $data ) {
572
- $quick_check = get_users( array(
573
- 'meta_key' => 'cpoints',
574
- 'fields' => 'ID'
575
- ) );
576
- $cp_users = count( $quick_check ); ?>
577
-
578
- <h4><div class="icon icon-<?php if ( $cp_users > 0 ) echo 'active'; else echo 'inactive'; ?>"></div><label><?php echo $data['title']; ?></label></h4>
579
- <div class="body" style="display:none;">
580
- <form class="add:the-list: validate" method="post" enctype="multipart/form-data">
581
- <input type="hidden" name="selected-import" value="cubepoints" />
582
- <p><?php
583
-
584
- if ( $cp_users > 0 )
585
- echo sprintf( __( 'Found %d users with CubePoints.', 'mycred' ), $cp_users );
586
- else
587
- _e( 'No CubePoints found.', 'mycred' ); ?></p>
588
- <label class="subheader" for="mycred-cubepoints-user-meta-key"><?php _e( 'Meta Key', 'mycred' ); ?></label>
589
- <ol>
590
- <li>
591
- <div class="h2"><input type="text" name="meta_key" id="mycred-cubepoints-user-meta-key" value="cpoints" class="disabled medium" disabled="disabled" /></div>
592
- </li>
593
- </ol>
594
- <label class="subheader" for="mycred-cubepoints-xrate"><?php _e( 'Exchange Rate', 'mycred' ); ?></label>
595
- <ol>
596
- <li>
597
- <div class="h2"><input type="text" name="xrate" id="mycred-cubepoints-xrate" value="<?php echo $this->core->format_number( 1 ); ?>" class="short" /><?php echo 'CubePoint'; ?> = <?php echo $this->core->format_creds( 1 ); ?></div>
598
- </li>
599
- </ol>
600
- <ol class="inline">
601
- <li>
602
- <label><?php _e( 'Round', 'mycred' ); ?></label><br />
603
- <input type="radio" name="round" id="mycred-cubepoints-round-none" value="none" checked="checked" /> <label for="mycred-cubepoints-round-none"><?php _e( 'Do not round', 'mycred' ); ?></label><br />
604
- <input type="radio" name="round" id="mycred-cubepoints-round-up" value="up" /> <label for="mycred-cubepoints-round-up"><?php _e( 'Round Up', 'mycred' ); ?></label><br />
605
- <input type="radio" name="round" id="mycred-cubepoints-round-down" value="down" /> <label for="mycred-cubepoints-round-down"><?php _e( 'Round Down', 'mycred' ); ?></label>
606
- </li>
607
- <?php if ( $this->core->format['decimals'] > 0 ) { ?>
608
-
609
- <li>
610
- <label for="mycred-cubepoints-precision"><?php _e( 'Precision', 'mycred' ); ?></label>
611
- <div class="h2"><input type="text" name="precision" id="mycred-cubepoints-precision" value="1" class="short" /></div>
612
- <span class="description"><?php echo __( 'The optional number of decimal digits to round to. Use zero to round the nearest whole number.', 'mycred' ); ?></span>
613
- </li>
614
- <?php } ?>
615
-
616
- </ol>
617
- <label class="subheader" for="mycred-cubepoints-delete"><?php _e( 'After Import', 'mycred' ); ?></label>
618
- <ol>
619
- <li>
620
- <input type="checkbox" name="delete" id="mycred-cubepoints-delete" value="no" /> <label for="mycred-cubepoints-delete"><?php _e( 'Delete users CubePoints balance.', 'mycred' ); ?></label>
621
- </li>
622
- </ol>
623
- <label class="subheader" for="mycred-cubepoints-log-template"><?php _e( 'Log Entry', 'mycred' ); ?></label>
624
- <ol>
625
- <li>
626
- <div class="h2"><input type="text" name="log_template" id="mycred-cubepoints-log-template" value="" class="long" /></div>
627
- <span class="description"><?php _e( 'See the help tab for available template tags. Leave blank to disable.', 'mycred' ); ?></span>
628
- </li>
629
- </ol>
630
- <ol>
631
- <li>
632
- <input type="submit" name="submit" id="mycred-cubepoints-submit" value="<?php _e( 'Run Import', 'mycred' ); ?>" class="button button-primary button-large" />
633
- </li>
634
- </ol>
635
- </form>
636
- </div>
637
- <?php
638
- }
639
-
640
- /**
641
- * Custom User Meta Import Form
642
- * @since 0.1
643
- * @version 1.0
644
- */
645
- public function custom_form( $data ) { ?>
646
-
647
- <h4><div class="icon icon-active"></div><label><?php echo $data['title']; ?></label></h4>
648
- <div class="body" style="display:none;">
649
- <form class="add:the-list: validate" method="post" enctype="multipart/form-data">
650
- <input type="hidden" name="selected-import" value="custom" />
651
- <p><?php echo nl2br( $this->core->template_tags_general( $data['description'] ) ); ?></p>
652
- <label class="subheader" for="mycred-custom-user-meta-key"><?php _e( 'Meta Key', 'mycred' ); ?></label>
653
- <ol>
654
- <li>
655
- <div class="h2"><input type="text" name="meta_key" id="mycred-custom-user-meta-key" value="" class="medium" /></div>
656
- </li>
657
- </ol>
658
- <label class="subheader" for="mycred-custom-xrate"><?php _e( 'Exchange Rate', 'mycred' ); ?></label>
659
- <ol>
660
- <li>
661
- <div class="h2"><input type="text" name="xrate" id="mycred-custom-xrate" value="<?php echo $this->core->format_number( 1 ); ?>" class="short" /> = <?php echo $this->core->format_creds( 1 ); ?></div>
662
- </li>
663
- </ol>
664
- <ol class="inline">
665
- <li>
666
- <label><?php _e( 'Round', 'mycred' ); ?></label><br />
667
- <input type="radio" name="round" id="mycred-custom-round-none" value="none" checked="checked" /> <label for="mycred-custom-round-none"><?php _e( 'Do not round', 'mycred' ); ?></label><br />
668
- <input type="radio" name="round" id="mycred-custom-round-up" value="up" /> <label for="mycred-custom-round-up"><?php _e( 'Round Up', 'mycred' ); ?></label><br />
669
- <input type="radio" name="round" id="mycred-custom-round-down" value="down" /> <label for="mycred-custom-round-down"><?php _e( 'Round Down', 'mycred' ); ?></label>
670
- </li>
671
- <?php if ( $this->core->format['decimals'] > 0 ) { ?>
672
-
673
- <li>
674
- <label for="mycred-custom-precision"><?php _e( 'Precision', 'mycred' ); ?></label>
675
- <div class="h2"><input type="text" name="precision" id="mycred-custom-precision" value="1" class="short" /></div>
676
- <span class="description"><?php echo __( 'The optional number of decimal digits to round to. Use zero to round the nearest whole number.', 'mycred' ); ?></span>
677
- </li>
678
- <?php } ?>
679
-
680
- </ol>
681
- <label class="subheader" for="mycred-custom-log-template"><?php _e( 'Log Entry', 'mycred' ); ?></label>
682
- <ol>
683
- <li>
684
- <div class="h2"><input type="text" name="log_template" id="mycred-custom-log-template" value="" class="long" /></div>
685
- <span class="description"><?php _e( 'See the help tab for available template tags. Leave blank to disable.', 'mycred' ); ?></span>
686
- </li>
687
- </ol>
688
- <label class="subheader" for="mycred-custom-delete"><?php _e( 'After Import', 'mycred' ); ?></label>
689
- <ol>
690
- <li>
691
- <input type="checkbox" name="delete" id="mycred-custom-delete" value="no" /> <label for="mycred-custom-delete"><?php _e( 'Delete the old value.', 'mycred' ); ?></label>
692
- </li>
693
- </ol>
694
- <ol>
695
- <li>
696
- <input type="submit" name="submit" id="mycred-custom-submit" value="<?php _e( 'Run Import', 'mycred' ); ?>" class="button button-primary button-large" />
697
- </li>
698
- </ol>
699
- </form>
700
- </div>
701
- <?php
702
- unset( $this );
703
- }
704
-
705
- /**
706
- * Delete BOM from UTF-8 file.
707
- * @see http://wordpress.org/extend/plugins/csv-importer/
708
- * @param string $fname
709
- * @return void
710
- */
711
- public function strip_BOM( $fname ) {
712
- $res = fopen( $fname, 'rb' );
713
- if ( false !== $res ) {
714
- $bytes = fread( $res, 3 );
715
- if ( $bytes == pack( 'CCC', 0xef, 0xbb, 0xbf ) ) {
716
- fclose( $res );
717
-
718
- $contents = file_get_contents( $fname );
719
- if ( false === $contents ) {
720
- trigger_error( __( 'Failed to get file contents.', 'mycred' ), E_USER_WARNING );
721
- }
722
- $contents = substr( $contents, 3 );
723
- $success = file_put_contents( $fname, $contents );
724
- if ( false === $success ) {
725
- trigger_error( __( 'Failed to put file contents.', 'mycred' ), E_USER_WARNING );
726
- }
727
- } else {
728
- fclose( $res );
729
- }
730
- }
731
- }
732
-
733
- /**
734
- * Contextual Help
735
- * @since 0.1
736
- * @version 1.0
737
- */
738
- public function help( $screen_id, $screen ) {
739
- if ( $screen_id != 'mycred_page_myCRED_page_import' ) return;
740
-
741
- $screen->add_help_tab( array(
742
- 'id' => 'mycred-import',
743
- 'title' => __( 'Import', 'mycred' ),
744
- 'content' => '
745
- <p>' . $this->core->template_tags_general( __( 'This add-on lets you import %_plural% either though a CSV-file or from your database. Remember that the import can take time depending on your file size or the number of users being imported.', 'mycred' ) ) . '</p>'
746
- ) );
747
- $screen->add_help_tab( array(
748
- 'id' => 'mycred-import-csv',
749
- 'title' => __( 'CSV File', 'mycred' ),
750
- 'content' => '
751
- <p><strong>' . __( 'CSV Import', 'mycred' ) . '</strong></p>
752
- <p>' . __( 'Imports using a comma-separated values file requires the following columns:', 'mycred' ) . '</p>
753
- <p><code>mycred_user</code> ' . __( 'Column identifing the user. All rows must identify the user the same way, either using an ID, Username (user_login) or email. Users that can not be found will be ignored.', 'mycred' ) . '<br />
754
- <code>mycred_amount</code> ' . __( 'Column with the amount to be imported. If set, an exchange rate is applied to this value before import.', 'mycred' ) . '</p>
755
- <p>' . __( 'Optionally you can also use the <code>mycred_log</code> column to pre-define the log entry for each import.', 'mycred' ) . '</p>'
756
- ) );
757
- $screen->add_help_tab( array(
758
- 'id' => 'mycred-import-cube',
759
- 'title' => __( 'Cubepoints', 'mycred' ),
760
- 'content' => '
761
- <p><strong>' . __( 'Cubepoints Import', 'mycred' ) . '</strong></p>
762
- <p>' . __( 'When this page loads, the importer will automatically check if you have been using Cubepoints. If you have, you can import these with the option to delete the original Cubepoints once completed to help keep your database clean.', 'mycred' ) . '</p>
763
- <p>' . __( 'Before a value is imported, you can apply an exchange rate. To import without changing the value, use 1 as the exchange rate.', 'mycred' ) . '</p>
764
- <p>' . __( 'You can select to add a log entry for each import or leave the template empty to skip.', 'mycred' ) . '</p>
765
- <p>' . __( 'The Cubepoints importer will automatically disable itself if no Cubepoints installation exists.', 'mycred' ) . '</p>'
766
- ) );
767
- $screen->add_help_tab( array(
768
- 'id' => 'mycred-import-custom',
769
- 'title' => __( 'Custom User Meta', 'mycred' ),
770
- 'content' => '
771
- <p><strong>' . __( 'Custom User Meta Import', 'mycred' ) . '</strong></p>
772
- <p>' . __( 'You can import any type of points that have previously been saved in your database. All you need is the meta key under which it has been saved.', 'mycred' ) . '</p>
773
- <p>' . __( 'Before a value is imported, you can apply an exchange rate. To import without changing the value, use 1 as the exchange rate.', 'mycred' ) . '</p>
774
- <p>' . __( 'You can select to add a log entry for each import or leave the template empty to skip.', 'mycred' ) . '</p>
775
- <p>' . __( 'Please note that the meta key is case sensitive and can not contain whitespaces!', 'mycred' ) . '</p>'
776
- ) );
777
- }
778
- }
779
- $import = new myCRED_Import();
780
- $import->load();
781
- }
782
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/notifications/css/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- ?>
 
 
 
addons/notifications/css/notify.css DELETED
@@ -1,40 +0,0 @@
1
- .notice-wrap {
2
- position: fixed;
3
- top: 50px;
4
- right: 50px;
5
- z-index: 9999;
6
- opacity: 0.8;
7
- }
8
-
9
- * html .notice-wrap {
10
- position: absolute;
11
- }
12
-
13
- .notice-item {
14
- position: relative;
15
- display: block;
16
- width: auto;
17
- height: auto;
18
- margin: 0 0 24px 0;
19
- padding: 12px;
20
-
21
- line-height: 22px;
22
- font-size: 12px;
23
-
24
- border-radius: 5px;
25
- background-color: #dedede;
26
- color: #333;
27
- }
28
- .notice-item p { display: block; float: right; margin: 0; padding: 0; }
29
- .notice-item h1 { margin: 0 !important; padding: 0; }
30
-
31
- .notice-item-close{
32
- display: block;
33
- float: left;
34
- width: 22px;
35
- height: 22px;
36
- line-height: 22px;
37
- font-size: 20px;
38
- text-align: center;
39
- cursor: pointer;
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/notifications/js/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- ?>
 
 
 
addons/notifications/js/notify.js DELETED
@@ -1,80 +0,0 @@
1
- /**
2
- * jQuery.noticeAdd() and jQuery.noticeRemove()
3
- * These functions create and remove growl-like notices
4
- *
5
- * Copyright © 2009 Tim Benniks
6
- *
7
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8
- * of this software and associated documentation files (the "Software"), to deal
9
- * in the Software without restriction, including without limitation the rights
10
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- * copies of the Software, and to permit persons to whom the Software is
12
- * furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in
15
- * all copies or substantial portions of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- * THE SOFTWARE.
24
- *
25
- * @author Tim Benniks <tim@timbenniks.com>
26
- * @copyright 2009 timbenniks.com
27
- * @version $Id: jquery.notice.js 1 2009-01-24 12:24:18Z timbenniks $
28
- **/
29
- (function(jQuery)
30
- {
31
- jQuery.extend({
32
- noticeAdd: function(options)
33
- {
34
- var defaults = {
35
- inEffect: {opacity: 'show'}, // in effect
36
- inEffectDuration: 600, // in effect duration in miliseconds
37
- stayTime: parseInt( myCRED_Notice.duration, 10 ), // time in miliseconds before the item has to disappear
38
- text: '', // content of the item
39
- stay: true, // should the notice item stay or not?
40
- type: 'succes' // could also be error, succes
41
- }
42
-
43
- // declare varaibles
44
- var options, noticeWrapAll, noticeItemOuter, noticeItemInner, noticeItemClose;
45
-
46
- options = jQuery.extend({}, defaults, options);
47
- noticeWrapAll = (!jQuery('.notice-wrap').length) ? jQuery('<div></div>').addClass('notice-wrap').appendTo('body') : jQuery('.notice-wrap');
48
- noticeItemOuter = jQuery('<div></div>').addClass('notice-item-wrapper');
49
- noticeItemInner = jQuery('<div></div>').hide().addClass('notice-item ' + options.type).appendTo(noticeWrapAll).html( options.text ).animate(options.inEffect, options.inEffectDuration).wrap(noticeItemOuter);
50
- noticeItemClose = jQuery('<div></div>').addClass('notice-item-close').prependTo(noticeItemInner).html('&times;').click(function() { jQuery.noticeRemove(noticeItemInner) });
51
-
52
- // hmmmz, zucht
53
- if(navigator.userAgent.match(/MSIE 6/i))
54
- {
55
- noticeWrapAll.css({top: document.documentElement.scrollTop});
56
- }
57
-
58
- if(!options.stay)
59
- {
60
- setTimeout(function()
61
- {
62
- jQuery.noticeRemove(noticeItemInner);
63
- },
64
- options.stayTime);
65
- }
66
-
67
- },
68
-
69
- noticeRemove: function(obj)
70
- {
71
- obj.animate({opacity: '0'}, 200, function()
72
- {
73
- obj.parent().animate({height: '0px'}, 100, function()
74
- {
75
- obj.parent().remove();
76
- });
77
- });
78
- }
79
- });
80
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/ranks/includes/mycred-rank-functions.php CHANGED
@@ -459,7 +459,7 @@ if ( ! function_exists( 'mycred_find_users_rank' ) ) :
459
 
460
  // Demotions
461
  if ( $results->current_id !== false && $current_rank !== false && $current_rank->maximum > $results->maximum )
462
- do_action( 'mycred_user_got_demoted', $user_id, $results, $current_rank, $point_type );
463
 
464
  // Promotions
465
  else {
459
 
460
  // Demotions
461
  if ( $results->current_id !== false && $current_rank !== false && $current_rank->maximum > $results->maximum )
462
+ do_action( 'mycred_user_got_demoted', $user_id, $current_rank_id, $current_rank, $point_type );
463
 
464
  // Promotions
465
  else {
addons/ranks/myCRED-addon-ranks.php CHANGED
@@ -628,13 +628,13 @@ if ( ! class_exists( 'myCRED_Ranks_Module' ) ) :
628
 
629
  }
630
 
631
- /**
632
- * Manual Balance Adjustment
633
- * Checks if User's rank should be change.
634
- * @param $result
635
- * @since 2.1
636
- * @version 1.0
637
- */
638
  public function balance_adjustment_without_log( $result )
639
  {
640
  extract( $result );
628
 
629
  }
630
 
631
+ /**
632
+ * Manual Balance Adjustment
633
+ * Checks if User's rank should be change.
634
+ * @param $result
635
+ * @since 2.1
636
+ * @version 1.0
637
+ */
638
  public function balance_adjustment_without_log( $result )
639
  {
640
  extract( $result );
addons/sell-content/myCRED-addon-sell-content.php CHANGED
@@ -187,18 +187,22 @@ if ( ! class_exists( 'myCRED_Sell_Content_Module' ) ) :
187
  {
188
  $content_id = '';
189
 
190
- if( $log->ref == 'buy_content' && $log->id == $row_id)
191
  {
192
-
193
- $content_id = (int)$log->ref_id;
194
 
195
- $sold_content = mycred_get_post_meta( $content_id, '_mycred_content_sales' );
196
-
197
- $sold_content = (int)$sold_content[0];
198
 
199
- $sold_content--;
 
200
 
201
- mycred_update_post_meta( $content_id, '_mycred_content_sales', $sold_content );
 
 
 
202
  }
203
 
204
  }
187
  {
188
  $content_id = '';
189
 
190
+ if( $log->ref == 'buy_content' && $log->id == $row_id )
191
  {
192
+
193
+ $content_id = (int) $log->ref_id;
194
 
195
+ $sold_content = mycred_get_post_meta( $content_id, '_mycred_content_sales', true );
196
+
197
+ if ( ! empty( $sold_content ) ) {
198
 
199
+ $sold_content = (int) $sold_content;
200
+ $sold_content--;
201
 
202
+ mycred_update_post_meta( $content_id, '_mycred_content_sales', $sold_content );
203
+
204
+ }
205
+
206
  }
207
 
208
  }
addons/stats/includes/mycred-stats-functions.php CHANGED
@@ -821,6 +821,7 @@ if ( ! function_exists( 'mycred_get_users_history_data' ) ) :
821
  global $wpdb, $mycred_log_table;
822
 
823
  $point_colors = mycred_get_type_color();
 
824
  $colors = $point_colors[ $point_type ];
825
  $type_object = new myCRED_Point_Type( $point_type );
826
 
821
  global $wpdb, $mycred_log_table;
822
 
823
  $point_colors = mycred_get_type_color();
824
+
825
  $colors = $point_colors[ $point_type ];
826
  $type_object = new myCRED_Point_Type( $point_type );
827
 
addons/stats/includes/mycred-stats-object.php CHANGED
@@ -366,7 +366,7 @@ if ( ! class_exists( 'myCRED_Chart' ) ) :
366
 
367
  elseif ( $row->type == 'user' ) {
368
  $user = get_userdata( (int) $row->label );
369
- $label = $user->display_name;
370
  }
371
 
372
  elseif ( $row->type == 'amount' ) {
366
 
367
  elseif ( $row->type == 'user' ) {
368
  $user = get_userdata( (int) $row->label );
369
+ $label = ! empty( $user ) ? $user->display_name : 'User Missing (ID:' . (int) $row->label . ')';
370
  }
371
 
372
  elseif ( $row->type == 'amount' ) {
assets/css/admin-subscription.css CHANGED
@@ -521,15 +521,20 @@ line-height:34px;
521
  }
522
 
523
  .mycred-support-page-container {
524
- max-width: 1024px;
525
  }
526
 
527
  .mycred-support-page-content {
528
  padding: 10px 27px 14px 27px;
529
- background: white;
 
530
  margin-top: 10px;
531
  }
532
 
 
 
 
 
533
  .mycred-support-page-content h2 {
534
  margin-bottom: 2px;
535
  }
521
  }
522
 
523
  .mycred-support-page-container {
524
+ max-width: 1200px;
525
  }
526
 
527
  .mycred-support-page-content {
528
  padding: 10px 27px 14px 27px;
529
+ background: white !important;
530
+
531
  margin-top: 10px;
532
  }
533
 
534
+ .mycred-all-references-list {
535
+ margin-top: 12px;
536
+ }
537
+
538
  .mycred-support-page-content h2 {
539
  margin-bottom: 2px;
540
  }
assets/css/bootstrap-grid.css CHANGED
@@ -1,2 +1,7 @@
1
- /* Bootstrap Grid System 3.2 */
2
- @-ms-viewport { width: device-width; } .visible-xs, .visible-sm, .visible-md, .visible-lg { display: none !important; } .visible-xs-block, .visible-xs-inline, .visible-xs-inline-block, .visible-sm-block, .visible-sm-inline, .visible-sm-inline-block, .visible-md-block, .visible-md-inline, .visible-md-inline-block, .visible-lg-block, .visible-lg-inline, .visible-lg-inline-block { display: none !important; }@media (max-width: 767px) { .visible-xs { display: block !important; } table.visible-xs { display: table; } tr.visible-xs { display: table-row !important; } th.visible-xs, td.visible-xs { display: table-cell !important; }}@media (max-width: 767px) { .visible-xs-block { display: block !important; }}@media (max-width: 767px) { .visible-xs-inline { display: inline !important; }}@media (max-width: 767px) { .visible-xs-inline-block { display: inline-block !important; }}@media (min-width: 768px) and (max-width: 991px) { .visible-sm { display: block !important; } table.visible-sm { display: table; } tr.visible-sm { display: table-row !important; } th.visible-sm, td.visible-sm { display: table-cell !important; }}@media (min-width: 768px) and (max-width: 991px) { .visible-sm-block { display: block !important; }}@media (min-width: 768px) and (max-width: 991px) { .visible-sm-inline { display: inline !important; }}@media (min-width: 768px) and (max-width: 991px) { .visible-sm-inline-block { display: inline-block !important; }}@media (min-width: 992px) and (max-width: 1199px) { .visible-md { display: block !important; } table.visible-md { display: table; } tr.visible-md { display: table-row !important; } th.visible-md, td.visible-md { display: table-cell !important; }}@media (min-width: 992px) and (max-width: 1199px) { .visible-md-block { display: block !important; }}@media (min-width: 992px) and (max-width: 1199px) { .visible-md-inline { display: inline !important; }}@media (min-width: 992px) and (max-width: 1199px) { .visible-md-inline-block { display: inline-block !important; }}@media (min-width: 1200px) { .visible-lg { display: block !important; } table.visible-lg { display: table; } tr.visible-lg { display: table-row !important; } th.visible-lg, td.visible-lg { display: table-cell !important; }}@media (min-width: 1200px) { .visible-lg-block { display: block !important; }}@media (min-width: 1200px) { .visible-lg-inline { display: inline !important; }}@media (min-width: 1200px) { .visible-lg-inline-block { display: inline-block !important; }}@media (max-width: 767px) { .hidden-xs { display: none !important; }}@media (min-width: 768px) and (max-width: 991px) { .hidden-sm { display: none !important; }}@media (min-width: 992px) and (max-width: 1199px) { .hidden-md { display: none !important; }}@media (min-width: 1200px) { .hidden-lg { display: none !important; }} .visible-print { display: none !important; }@media print { .visible-print { display: block !important; } table.visible-print { display: table; } tr.visible-print { display: table-row !important; } th.visible-print, td.visible-print { display: table-cell !important; }} .visible-print-block { display: none !important; }@media print { .visible-print-block { display: block !important; }} .visible-print-inline { display: none !important; }@media print { .visible-print-inline { display: inline !important; }} .visible-print-inline-block { display: none !important; }@media print { .visible-print-inline-block { display: inline-block !important; }}@media print { .hidden-print { display: none !important; }} .container { margin-right: auto; margin-left: auto; padding-left: 12px; padding-right: 12px; }@media (min-width: 768px) { .container { width: 750px; }}@media (min-width: 992px) { .container { width: 970px; }}@media (min-width: 1200px) { .container { width: 1170px; }} .container-fluid { margin-right: auto; margin-left: auto; padding-left: 12px; padding-right: 12px; } .row { margin-left: -12px; margin-right: -12px; } .col, .col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { position: relative; min-height: 1px; padding-left: 12px; padding-right: 12px; } .col, .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 { float: left; } .col-xs-12 { width: 100%; } .col-xs-11 { width: 91.66666667%; } .col-xs-10 { width: 83.33333333%; } .col-xs-9 { width: 75%; } .col-xs-8 { width: 66.66666667%; } .col-xs-7 { width: 58.33333333%; } .col-xs-6 { width: 50%; } .col-xs-5 { width: 41.66666667%; } .col-xs-4 { width: 33.33333333%; } .col-xs-3 { width: 25%; } .col-xs-2 { width: 16.66666667%; } .col-xs-1 { width: 8.33333333%; } .col-xs-pull-12 { right: 100%; } .col-xs-pull-11 { right: 91.66666667%; } .col-xs-pull-10 { right: 83.33333333%; } .col-xs-pull-9 { right: 75%; } .col-xs-pull-8 { right: 66.66666667%; } .col-xs-pull-7 { right: 58.33333333%; } .col-xs-pull-6 { right: 50%; } .col-xs-pull-5 { right: 41.66666667%; } .col-xs-pull-4 { right: 33.33333333%; } .col-xs-pull-3 { right: 25%; } .col-xs-pull-2 { right: 16.66666667%; } .col-xs-pull-1 { right: 8.33333333%; } .col-xs-pull-0 { right: auto; } .col-xs-push-12 { left: 100%; } .col-xs-push-11 { left: 91.66666667%; } .col-xs-push-10 { left: 83.33333333%; } .col-xs-push-9 { left: 75%; } .col-xs-push-8 { left: 66.66666667%; } .col-xs-push-7 { left: 58.33333333%; } .col-xs-push-6 { left: 50%; } .col-xs-push-5 { left: 41.66666667%; } .col-xs-push-4 { left: 33.33333333%; } .col-xs-push-3 { left: 25%; } .col-xs-push-2 { left: 16.66666667%; } .col-xs-push-1 { left: 8.33333333%; } .col-xs-push-0 { left: auto; } .col-xs-offset-12 { margin-left: 100%; } .col-xs-offset-11 { margin-left: 91.66666667%; } .col-xs-offset-10 { margin-left: 83.33333333%; } .col-xs-offset-9 { margin-left: 75%; } .col-xs-offset-8 { margin-left: 66.66666667%; } .col-xs-offset-7 { margin-left: 58.33333333%; } .col-xs-offset-6 { margin-left: 50%; } .col-xs-offset-5 { margin-left: 41.66666667%; } .col-xs-offset-4 { margin-left: 33.33333333%; } .col-xs-offset-3 { margin-left: 25%; } .col-xs-offset-2 { margin-left: 16.66666667%; } .col-xs-offset-1 { margin-left: 8.33333333%; } .col-xs-offset-0 { margin-left: 0%; }@media (min-width: 768px) { .col, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { float: left; } .col-sm-12 { width: 100%; } .col-sm-11 { width: 91.66666667%; } .col-sm-10 { width: 83.33333333%; } .col-sm-9 { width: 75%; } .col-sm-8 { width: 66.66666667%; } .col-sm-7 { width: 58.33333333%; } .col-sm-6 { width: 50%; } .col-sm-5 { width: 41.66666667%; } .col-sm-4 { width: 33.33333333%; } .col-sm-3 { width: 25%; } .col-sm-2 { width: 16.66666667%; } .col-sm-1 { width: 8.33333333%; } .col-sm-pull-12 { right: 100%; } .col-sm-pull-11 { right: 91.66666667%; } .col-sm-pull-10 { right: 83.33333333%; } .col-sm-pull-9 { right: 75%; } .col-sm-pull-8 { right: 66.66666667%; } .col-sm-pull-7 { right: 58.33333333%; } .col-sm-pull-6 { right: 50%; } .col-sm-pull-5 { right: 41.66666667%; } .col-sm-pull-4 { right: 33.33333333%; } .col-sm-pull-3 { right: 25%; } .col-sm-pull-2 { right: 16.66666667%; } .col-sm-pull-1 { right: 8.33333333%; } .col-sm-pull-0 { right: auto; } .col-sm-push-12 { left: 100%; } .col-sm-push-11 { left: 91.66666667%; } .col-sm-push-10 { left: 83.33333333%; } .col-sm-push-9 { left: 75%; } .col-sm-push-8 { left: 66.66666667%; } .col-sm-push-7 { left: 58.33333333%; } .col-sm-push-6 { left: 50%; } .col-sm-push-5 { left: 41.66666667%; } .col-sm-push-4 { left: 33.33333333%; } .col-sm-push-3 { left: 25%; } .col-sm-push-2 { left: 16.66666667%; } .col-sm-push-1 { left: 8.33333333%; } .col-sm-push-0 { left: auto; } .col-sm-offset-12 { margin-left: 100%; } .col-sm-offset-11 { margin-left: 91.66666667%; } .col-sm-offset-10 { margin-left: 83.33333333%; } .col-sm-offset-9 { margin-left: 75%; } .col-sm-offset-8 { margin-left: 66.66666667%; } .col-sm-offset-7 { margin-left: 58.33333333%; } .col-sm-offset-6 { margin-left: 50%; } .col-sm-offset-5 { margin-left: 41.66666667%; } .col-sm-offset-4 { margin-left: 33.33333333%; } .col-sm-offset-3 { margin-left: 25%; } .col-sm-offset-2 { margin-left: 16.66666667%; } .col-sm-offset-1 { margin-left: 8.33333333%; } .col-sm-offset-0 { margin-left: 0%; }}@media (min-width: 992px) { .col, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { float: left; } .col-md-12 { width: 100%; } .col-md-11 { width: 91.66666667%; } .col-md-10 { width: 83.33333333%; } .col-md-9 { width: 75%; } .col-md-8 { width: 66.66666667%; } .col-md-7 { width: 58.33333333%; } .col-md-6 { width: 50%; } .col-md-5 { width: 41.66666667%; } .col-md-4 { width: 33.33333333%; } .col-md-3 { width: 25%; } .col-md-2 { width: 16.66666667%; } .col-md-1 { width: 8.33333333%; } .col-md-pull-12 { right: 100%; } .col-md-pull-11 { right: 91.66666667%; } .col-md-pull-10 { right: 83.33333333%; } .col-md-pull-9 { right: 75%; } .col-md-pull-8 { right: 66.66666667%; } .col-md-pull-7 { right: 58.33333333%; } .col-md-pull-6 { right: 50%; } .col-md-pull-5 { right: 41.66666667%; } .col-md-pull-4 { right: 33.33333333%; } .col-md-pull-3 { right: 25%; } .col-md-pull-2 { right: 16.66666667%; } .col-md-pull-1 { right: 8.33333333%; } .col-md-pull-0 { right: auto; } .col-md-push-12 { left: 100%; } .col-md-push-11 { left: 91.66666667%; } .col-md-push-10 { left: 83.33333333%; } .col-md-push-9 { left: 75%; } .col-md-push-8 { left: 66.66666667%; } .col-md-push-7 { left: 58.33333333%; } .col-md-push-6 { left: 50%; } .col-md-push-5 { left: 41.66666667%; } .col-md-push-4 { left: 33.33333333%; } .col-md-push-3 { left: 25%; } .col-md-push-2 { left: 16.66666667%; } .col-md-push-1 { left: 8.33333333%; } .col-md-push-0 { left: auto; } .col-md-offset-12 { margin-left: 100%; } .col-md-offset-11 { margin-left: 91.66666667%; } .col-md-offset-10 { margin-left: 83.33333333%; } .col-md-offset-9 { margin-left: 75%; } .col-md-offset-8 { margin-left: 66.66666667%; } .col-md-offset-7 { margin-left: 58.33333333%; } .col-md-offset-6 { margin-left: 50%; } .col-md-offset-5 { margin-left: 41.66666667%; } .col-md-offset-4 { margin-left: 33.33333333%; } .col-md-offset-3 { margin-left: 25%; } .col-md-offset-2 { margin-left: 16.66666667%; } .col-md-offset-1 { margin-left: 8.33333333%; } .col-md-offset-0 { margin-left: 0%; }}@media (min-width: 1200px) { .col, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 { float: left; } .col-lg-12 { width: 100%; } .col-lg-11 { width: 91.66666667%; } .col-lg-10 { width: 83.33333333%; } .col-lg-9 { width: 75%; } .col-lg-8 { width: 66.66666667%; } .col-lg-7 { width: 58.33333333%; } .col-lg-6 { width: 50%; } .col-lg-5 { width: 41.66666667%; } .col-lg-4 { width: 33.33333333%; } .col-lg-3 { width: 25%; } .col-lg-2 { width: 16.66666667%; } .col-lg-1 { width: 8.33333333%; } .col-lg-pull-12 { right: 100%; } .col-lg-pull-11 { right: 91.66666667%; } .col-lg-pull-10 { right: 83.33333333%; } .col-lg-pull-9 { right: 75%; } .col-lg-pull-8 { right: 66.66666667%; } .col-lg-pull-7 { right: 58.33333333%; } .col-lg-pull-6 { right: 50%; } .col-lg-pull-5 { right: 41.66666667%; } .col-lg-pull-4 { right: 33.33333333%; } .col-lg-pull-3 { right: 25%; } .col-lg-pull-2 { right: 16.66666667%; } .col-lg-pull-1 { right: 8.33333333%; } .col-lg-pull-0 { right: auto; } .col-lg-push-12 { left: 100%; } .col-lg-push-11 { left: 91.66666667%; } .col-lg-push-10 { left: 83.33333333%; } .col-lg-push-9 { left: 75%; } .col-lg-push-8 { left: 66.66666667%; } .col-lg-push-7 { left: 58.33333333%; } .col-lg-push-6 { left: 50%; } .col-lg-push-5 { left: 41.66666667%; } .col-lg-push-4 { left: 33.33333333%; } .col-lg-push-3 { left: 25%; } .col-lg-push-2 { left: 16.66666667%; } .col-lg-push-1 { left: 8.33333333%; } .col-lg-push-0 { left: auto; } .col-lg-offset-12 { margin-left: 100%; } .col-lg-offset-11 { margin-left: 91.66666667%; } .col-lg-offset-10 { margin-left: 83.33333333%; } .col-lg-offset-9 { margin-left: 75%; } .col-lg-offset-8 { margin-left: 66.66666667%; } .col-lg-offset-7 { margin-left: 58.33333333%; } .col-lg-offset-6 { margin-left: 50%; } .col-lg-offset-5 { margin-left: 41.66666667%; } .col-lg-offset-4 { margin-left: 33.33333333%; } .col-lg-offset-3 { margin-left: 25%; } .col-lg-offset-2 { margin-left: 16.66666667%; } .col-lg-offset-1 { margin-left: 8.33333333%; } .col-lg-offset-0 { margin-left: 0%; }} .clearfix, .clearfix:before, .clearfix:after, .container:before, .container:after, .container-fluid:before, .container-fluid:after, .row:before, .row:after { content: " "; display: table; } .clearfix:after, .container:after, .container-fluid:after, .row:after { clear: both; } .center-block { display: block; margin-left: auto; margin-right: auto; } .pull-right { float: right !important; } .pull-left { float: left !important; } .mycred-container *, .mycred-container *:before, .mycred-container *:after, .mycred-metabox *, .mycred-metabox *:before, .mycred-metabox *:after { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } .mycred-metabox .padded { padding: 12px; }
 
 
 
 
 
1
+ /*!
2
+ * Bootstrap Grid v5.1.3 (https://getbootstrap.com/)
3
+ * Copyright 2011-2021 The Bootstrap Authors
4
+ * Copyright 2011-2021 Twitter, Inc.
5
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
6
+ */:root{--bs-blue:#0d6efd;--bs-indigo:#6610f2;--bs-purple:#6f42c1;--bs-pink:#d63384;--bs-red:#dc3545;--bs-orange:#fd7e14;--bs-yellow:#ffc107;--bs-green:#198754;--bs-teal:#20c997;--bs-cyan:#0dcaf0;--bs-white:#fff;--bs-gray:#6c757d;--bs-gray-dark:#343a40;--bs-gray-100:#f8f9fa;--bs-gray-200:#e9ecef;--bs-gray-300:#dee2e6;--bs-gray-400:#ced4da;--bs-gray-500:#adb5bd;--bs-gray-600:#6c757d;--bs-gray-700:#495057;--bs-gray-800:#343a40;--bs-gray-900:#212529;--bs-primary:#0d6efd;--bs-secondary:#6c757d;--bs-success:#198754;--bs-info:#0dcaf0;--bs-warning:#ffc107;--bs-danger:#dc3545;--bs-light:#f8f9fa;--bs-dark:#212529;--bs-primary-rgb:13,110,253;--bs-secondary-rgb:108,117,125;--bs-success-rgb:25,135,84;--bs-info-rgb:13,202,240;--bs-warning-rgb:255,193,7;--bs-danger-rgb:220,53,69;--bs-light-rgb:248,249,250;--bs-dark-rgb:33,37,41;--bs-white-rgb:255,255,255;--bs-black-rgb:0,0,0;--bs-body-color-rgb:33,37,41;--bs-body-bg-rgb:255,255,255;--bs-font-sans-serif:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--bs-font-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--bs-gradient:linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));--bs-body-font-family:var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight:400;--bs-body-line-height:1.5;--bs-body-color:#212529;--bs-body-bg:#fff}.container,.container-fluid,.container-lg,.container-md,.container-sm,.container-xl,.container-xxl{width:100%;padding-right:var(--bs-gutter-x,.75rem);padding-left:var(--bs-gutter-x,.75rem);margin-right:auto;margin-left:auto}@media (min-width:576px){.container,.container-sm{max-width:540px}}@media (min-width:768px){.container,.container-md,.container-sm{max-width:720px}}@media (min-width:992px){.container,.container-lg,.container-md,.container-sm{max-width:960px}}@media (min-width:1200px){.container,.container-lg,.container-md,.container-sm,.container-xl{max-width:1140px}}@media (min-width:1400px){.container,.container-lg,.container-md,.container-sm,.container-xl,.container-xxl{max-width:1320px}}.row{--bs-gutter-x:1.5rem;--bs-gutter-y:0;display:flex;flex-wrap:wrap;margin-top:calc(-1 * var(--bs-gutter-y));margin-right:calc(-.5 * var(--bs-gutter-x));margin-left:calc(-.5 * var(--bs-gutter-x))}.row>*{box-sizing:border-box;flex-shrink:0;width:100%;max-width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5);margin-top:var(--bs-gutter-y)}.col{flex:1 0 0%}.row-cols-auto>*{flex:0 0 auto;width:auto}.row-cols-1>*{flex:0 0 auto;width:100%}.row-cols-2>*{flex:0 0 auto;width:50%}.row-cols-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-4>*{flex:0 0 auto;width:25%}.row-cols-5>*{flex:0 0 auto;width:20%}.row-cols-6>*{flex:0 0 auto;width:16.6666666667%}.col-auto{flex:0 0 auto;width:auto}.col-1{flex:0 0 auto;width:8.33333333%}.col-2{flex:0 0 auto;width:16.66666667%}.col-3{flex:0 0 auto;width:25%}.col-4{flex:0 0 auto;width:33.33333333%}.col-5{flex:0 0 auto;width:41.66666667%}.col-6{flex:0 0 auto;width:50%}.col-7{flex:0 0 auto;width:58.33333333%}.col-8{flex:0 0 auto;width:66.66666667%}.col-9{flex:0 0 auto;width:75%}.col-10{flex:0 0 auto;width:83.33333333%}.col-11{flex:0 0 auto;width:91.66666667%}.col-12{flex:0 0 auto;width:100%}.offset-1{margin-left:8.33333333%}.offset-2{margin-left:16.66666667%}.offset-3{margin-left:25%}.offset-4{margin-left:33.33333333%}.offset-5{margin-left:41.66666667%}.offset-6{margin-left:50%}.offset-7{margin-left:58.33333333%}.offset-8{margin-left:66.66666667%}.offset-9{margin-left:75%}.offset-10{margin-left:83.33333333%}.offset-11{margin-left:91.66666667%}.g-0,.gx-0{--bs-gutter-x:0}.g-0,.gy-0{--bs-gutter-y:0}.g-1,.gx-1{--bs-gutter-x:0.25rem}.g-1,.gy-1{--bs-gutter-y:0.25rem}.g-2,.gx-2{--bs-gutter-x:0.5rem}.g-2,.gy-2{--bs-gutter-y:0.5rem}.g-3,.gx-3{--bs-gutter-x:1rem}.g-3,.gy-3{--bs-gutter-y:1rem}.g-4,.gx-4{--bs-gutter-x:1.5rem}.g-4,.gy-4{--bs-gutter-y:1.5rem}.g-5,.gx-5{--bs-gutter-x:3rem}.g-5,.gy-5{--bs-gutter-y:3rem}@media (min-width:576px){.col-sm{flex:1 0 0%}.row-cols-sm-auto>*{flex:0 0 auto;width:auto}.row-cols-sm-1>*{flex:0 0 auto;width:100%}.row-cols-sm-2>*{flex:0 0 auto;width:50%}.row-cols-sm-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-sm-4>*{flex:0 0 auto;width:25%}.row-cols-sm-5>*{flex:0 0 auto;width:20%}.row-cols-sm-6>*{flex:0 0 auto;width:16.6666666667%}.col-sm-auto{flex:0 0 auto;width:auto}.col-sm-1{flex:0 0 auto;width:8.33333333%}.col-sm-2{flex:0 0 auto;width:16.66666667%}.col-sm-3{flex:0 0 auto;width:25%}.col-sm-4{flex:0 0 auto;width:33.33333333%}.col-sm-5{flex:0 0 auto;width:41.66666667%}.col-sm-6{flex:0 0 auto;width:50%}.col-sm-7{flex:0 0 auto;width:58.33333333%}.col-sm-8{flex:0 0 auto;width:66.66666667%}.col-sm-9{flex:0 0 auto;width:75%}.col-sm-10{flex:0 0 auto;width:83.33333333%}.col-sm-11{flex:0 0 auto;width:91.66666667%}.col-sm-12{flex:0 0 auto;width:100%}.offset-sm-0{margin-left:0}.offset-sm-1{margin-left:8.33333333%}.offset-sm-2{margin-left:16.66666667%}.offset-sm-3{margin-left:25%}.offset-sm-4{margin-left:33.33333333%}.offset-sm-5{margin-left:41.66666667%}.offset-sm-6{margin-left:50%}.offset-sm-7{margin-left:58.33333333%}.offset-sm-8{margin-left:66.66666667%}.offset-sm-9{margin-left:75%}.offset-sm-10{margin-left:83.33333333%}.offset-sm-11{margin-left:91.66666667%}.g-sm-0,.gx-sm-0{--bs-gutter-x:0}.g-sm-0,.gy-sm-0{--bs-gutter-y:0}.g-sm-1,.gx-sm-1{--bs-gutter-x:0.25rem}.g-sm-1,.gy-sm-1{--bs-gutter-y:0.25rem}.g-sm-2,.gx-sm-2{--bs-gutter-x:0.5rem}.g-sm-2,.gy-sm-2{--bs-gutter-y:0.5rem}.g-sm-3,.gx-sm-3{--bs-gutter-x:1rem}.g-sm-3,.gy-sm-3{--bs-gutter-y:1rem}.g-sm-4,.gx-sm-4{--bs-gutter-x:1.5rem}.g-sm-4,.gy-sm-4{--bs-gutter-y:1.5rem}.g-sm-5,.gx-sm-5{--bs-gutter-x:3rem}.g-sm-5,.gy-sm-5{--bs-gutter-y:3rem}}@media (min-width:768px){.col-md{flex:1 0 0%}.row-cols-md-auto>*{flex:0 0 auto;width:auto}.row-cols-md-1>*{flex:0 0 auto;width:100%}.row-cols-md-2>*{flex:0 0 auto;width:50%}.row-cols-md-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-md-4>*{flex:0 0 auto;width:25%}.row-cols-md-5>*{flex:0 0 auto;width:20%}.row-cols-md-6>*{flex:0 0 auto;width:16.6666666667%}.col-md-auto{flex:0 0 auto;width:auto}.col-md-1{flex:0 0 auto;width:8.33333333%}.col-md-2{flex:0 0 auto;width:16.66666667%}.col-md-3{flex:0 0 auto;width:25%}.col-md-4{flex:0 0 auto;width:33.33333333%}.col-md-5{flex:0 0 auto;width:41.66666667%}.col-md-6{flex:0 0 auto;width:50%}.col-md-7{flex:0 0 auto;width:58.33333333%}.col-md-8{flex:0 0 auto;width:66.66666667%}.col-md-9{flex:0 0 auto;width:75%}.col-md-10{flex:0 0 auto;width:83.33333333%}.col-md-11{flex:0 0 auto;width:91.66666667%}.col-md-12{flex:0 0 auto;width:100%}.offset-md-0{margin-left:0}.offset-md-1{margin-left:8.33333333%}.offset-md-2{margin-left:16.66666667%}.offset-md-3{margin-left:25%}.offset-md-4{margin-left:33.33333333%}.offset-md-5{margin-left:41.66666667%}.offset-md-6{margin-left:50%}.offset-md-7{margin-left:58.33333333%}.offset-md-8{margin-left:66.66666667%}.offset-md-9{margin-left:75%}.offset-md-10{margin-left:83.33333333%}.offset-md-11{margin-left:91.66666667%}.g-md-0,.gx-md-0{--bs-gutter-x:0}.g-md-0,.gy-md-0{--bs-gutter-y:0}.g-md-1,.gx-md-1{--bs-gutter-x:0.25rem}.g-md-1,.gy-md-1{--bs-gutter-y:0.25rem}.g-md-2,.gx-md-2{--bs-gutter-x:0.5rem}.g-md-2,.gy-md-2{--bs-gutter-y:0.5rem}.g-md-3,.gx-md-3{--bs-gutter-x:1rem}.g-md-3,.gy-md-3{--bs-gutter-y:1rem}.g-md-4,.gx-md-4{--bs-gutter-x:1.5rem}.g-md-4,.gy-md-4{--bs-gutter-y:1.5rem}.g-md-5,.gx-md-5{--bs-gutter-x:3rem}.g-md-5,.gy-md-5{--bs-gutter-y:3rem}}@media (min-width:992px){.col-lg{flex:1 0 0%}.row-cols-lg-auto>*{flex:0 0 auto;width:auto}.row-cols-lg-1>*{flex:0 0 auto;width:100%}.row-cols-lg-2>*{flex:0 0 auto;width:50%}.row-cols-lg-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-lg-4>*{flex:0 0 auto;width:25%}.row-cols-lg-5>*{flex:0 0 auto;width:20%}.row-cols-lg-6>*{flex:0 0 auto;width:16.6666666667%}.col-lg-auto{flex:0 0 auto;width:auto}.col-lg-1{flex:0 0 auto;width:8.33333333%}.col-lg-2{flex:0 0 auto;width:16.66666667%}.col-lg-3{flex:0 0 auto;width:25%}.col-lg-4{flex:0 0 auto;width:33.33333333%}.col-lg-5{flex:0 0 auto;width:41.66666667%}.col-lg-6{flex:0 0 auto;width:50%}.col-lg-7{flex:0 0 auto;width:58.33333333%}.col-lg-8{flex:0 0 auto;width:66.66666667%}.col-lg-9{flex:0 0 auto;width:75%}.col-lg-10{flex:0 0 auto;width:83.33333333%}.col-lg-11{flex:0 0 auto;width:91.66666667%}.col-lg-12{flex:0 0 auto;width:100%}.offset-lg-0{margin-left:0}.offset-lg-1{margin-left:8.33333333%}.offset-lg-2{margin-left:16.66666667%}.offset-lg-3{margin-left:25%}.offset-lg-4{margin-left:33.33333333%}.offset-lg-5{margin-left:41.66666667%}.offset-lg-6{margin-left:50%}.offset-lg-7{margin-left:58.33333333%}.offset-lg-8{margin-left:66.66666667%}.offset-lg-9{margin-left:75%}.offset-lg-10{margin-left:83.33333333%}.offset-lg-11{margin-left:91.66666667%}.g-lg-0,.gx-lg-0{--bs-gutter-x:0}.g-lg-0,.gy-lg-0{--bs-gutter-y:0}.g-lg-1,.gx-lg-1{--bs-gutter-x:0.25rem}.g-lg-1,.gy-lg-1{--bs-gutter-y:0.25rem}.g-lg-2,.gx-lg-2{--bs-gutter-x:0.5rem}.g-lg-2,.gy-lg-2{--bs-gutter-y:0.5rem}.g-lg-3,.gx-lg-3{--bs-gutter-x:1rem}.g-lg-3,.gy-lg-3{--bs-gutter-y:1rem}.g-lg-4,.gx-lg-4{--bs-gutter-x:1.5rem}.g-lg-4,.gy-lg-4{--bs-gutter-y:1.5rem}.g-lg-5,.gx-lg-5{--bs-gutter-x:3rem}.g-lg-5,.gy-lg-5{--bs-gutter-y:3rem}}@media (min-width:1200px){.col-xl{flex:1 0 0%}.row-cols-xl-auto>*{flex:0 0 auto;width:auto}.row-cols-xl-1>*{flex:0 0 auto;width:100%}.row-cols-xl-2>*{flex:0 0 auto;width:50%}.row-cols-xl-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-xl-4>*{flex:0 0 auto;width:25%}.row-cols-xl-5>*{flex:0 0 auto;width:20%}.row-cols-xl-6>*{flex:0 0 auto;width:16.6666666667%}.col-xl-auto{flex:0 0 auto;width:auto}.col-xl-1{flex:0 0 auto;width:8.33333333%}.col-xl-2{flex:0 0 auto;width:16.66666667%}.col-xl-3{flex:0 0 auto;width:25%}.col-xl-4{flex:0 0 auto;width:33.33333333%}.col-xl-5{flex:0 0 auto;width:41.66666667%}.col-xl-6{flex:0 0 auto;width:50%}.col-xl-7{flex:0 0 auto;width:58.33333333%}.col-xl-8{flex:0 0 auto;width:66.66666667%}.col-xl-9{flex:0 0 auto;width:75%}.col-xl-10{flex:0 0 auto;width:83.33333333%}.col-xl-11{flex:0 0 auto;width:91.66666667%}.col-xl-12{flex:0 0 auto;width:100%}.offset-xl-0{margin-left:0}.offset-xl-1{margin-left:8.33333333%}.offset-xl-2{margin-left:16.66666667%}.offset-xl-3{margin-left:25%}.offset-xl-4{margin-left:33.33333333%}.offset-xl-5{margin-left:41.66666667%}.offset-xl-6{margin-left:50%}.offset-xl-7{margin-left:58.33333333%}.offset-xl-8{margin-left:66.66666667%}.offset-xl-9{margin-left:75%}.offset-xl-10{margin-left:83.33333333%}.offset-xl-11{margin-left:91.66666667%}.g-xl-0,.gx-xl-0{--bs-gutter-x:0}.g-xl-0,.gy-xl-0{--bs-gutter-y:0}.g-xl-1,.gx-xl-1{--bs-gutter-x:0.25rem}.g-xl-1,.gy-xl-1{--bs-gutter-y:0.25rem}.g-xl-2,.gx-xl-2{--bs-gutter-x:0.5rem}.g-xl-2,.gy-xl-2{--bs-gutter-y:0.5rem}.g-xl-3,.gx-xl-3{--bs-gutter-x:1rem}.g-xl-3,.gy-xl-3{--bs-gutter-y:1rem}.g-xl-4,.gx-xl-4{--bs-gutter-x:1.5rem}.g-xl-4,.gy-xl-4{--bs-gutter-y:1.5rem}.g-xl-5,.gx-xl-5{--bs-gutter-x:3rem}.g-xl-5,.gy-xl-5{--bs-gutter-y:3rem}}@media (min-width:1400px){.col-xxl{flex:1 0 0%}.row-cols-xxl-auto>*{flex:0 0 auto;width:auto}.row-cols-xxl-1>*{flex:0 0 auto;width:100%}.row-cols-xxl-2>*{flex:0 0 auto;width:50%}.row-cols-xxl-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-xxl-4>*{flex:0 0 auto;width:25%}.row-cols-xxl-5>*{flex:0 0 auto;width:20%}.row-cols-xxl-6>*{flex:0 0 auto;width:16.6666666667%}.col-xxl-auto{flex:0 0 auto;width:auto}.col-xxl-1{flex:0 0 auto;width:8.33333333%}.col-xxl-2{flex:0 0 auto;width:16.66666667%}.col-xxl-3{flex:0 0 auto;width:25%}.col-xxl-4{flex:0 0 auto;width:33.33333333%}.col-xxl-5{flex:0 0 auto;width:41.66666667%}.col-xxl-6{flex:0 0 auto;width:50%}.col-xxl-7{flex:0 0 auto;width:58.33333333%}.col-xxl-8{flex:0 0 auto;width:66.66666667%}.col-xxl-9{flex:0 0 auto;width:75%}.col-xxl-10{flex:0 0 auto;width:83.33333333%}.col-xxl-11{flex:0 0 auto;width:91.66666667%}.col-xxl-12{flex:0 0 auto;width:100%}.offset-xxl-0{margin-left:0}.offset-xxl-1{margin-left:8.33333333%}.offset-xxl-2{margin-left:16.66666667%}.offset-xxl-3{margin-left:25%}.offset-xxl-4{margin-left:33.33333333%}.offset-xxl-5{margin-left:41.66666667%}.offset-xxl-6{margin-left:50%}.offset-xxl-7{margin-left:58.33333333%}.offset-xxl-8{margin-left:66.66666667%}.offset-xxl-9{margin-left:75%}.offset-xxl-10{margin-left:83.33333333%}.offset-xxl-11{margin-left:91.66666667%}.g-xxl-0,.gx-xxl-0{--bs-gutter-x:0}.g-xxl-0,.gy-xxl-0{--bs-gutter-y:0}.g-xxl-1,.gx-xxl-1{--bs-gutter-x:0.25rem}.g-xxl-1,.gy-xxl-1{--bs-gutter-y:0.25rem}.g-xxl-2,.gx-xxl-2{--bs-gutter-x:0.5rem}.g-xxl-2,.gy-xxl-2{--bs-gutter-y:0.5rem}.g-xxl-3,.gx-xxl-3{--bs-gutter-x:1rem}.g-xxl-3,.gy-xxl-3{--bs-gutter-y:1rem}.g-xxl-4,.gx-xxl-4{--bs-gutter-x:1.5rem}.g-xxl-4,.gy-xxl-4{--bs-gutter-y:1.5rem}.g-xxl-5,.gx-xxl-5{--bs-gutter-x:3rem}.g-xxl-5,.gy-xxl-5{--bs-gutter-y:3rem}}.d-inline{display:inline!important}.d-inline-block{display:inline-block!important}.d-block{display:block!important}.d-grid{display:grid!important}.d-table{display:table!important}.d-table-row{display:table-row!important}.d-table-cell{display:table-cell!important}.d-flex{display:flex!important}.d-inline-flex{display:inline-flex!important}.d-none{display:none!important}.flex-fill{flex:1 1 auto!important}.flex-row{flex-direction:row!important}.flex-column{flex-direction:column!important}.flex-row-reverse{flex-direction:row-reverse!important}.flex-column-reverse{flex-direction:column-reverse!important}.flex-grow-0{flex-grow:0!important}.flex-grow-1{flex-grow:1!important}.flex-shrink-0{flex-shrink:0!important}.flex-shrink-1{flex-shrink:1!important}.flex-wrap{flex-wrap:wrap!important}.flex-nowrap{flex-wrap:nowrap!important}.flex-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-start{justify-content:flex-start!important}.justify-content-end{justify-content:flex-end!important}.justify-content-center{justify-content:center!important}.justify-content-between{justify-content:space-between!important}.justify-content-around{justify-content:space-around!important}.justify-content-evenly{justify-content:space-evenly!important}.align-items-start{align-items:flex-start!important}.align-items-end{align-items:flex-end!important}.align-items-center{align-items:center!important}.align-items-baseline{align-items:baseline!important}.align-items-stretch{align-items:stretch!important}.align-content-start{align-content:flex-start!important}.align-content-end{align-content:flex-end!important}.align-content-center{align-content:center!important}.align-content-between{align-content:space-between!important}.align-content-around{align-content:space-around!important}.align-content-stretch{align-content:stretch!important}.align-self-auto{align-self:auto!important}.align-self-start{align-self:flex-start!important}.align-self-end{align-self:flex-end!important}.align-self-center{align-self:center!important}.align-self-baseline{align-self:baseline!important}.align-self-stretch{align-self:stretch!important}.order-first{order:-1!important}.order-0{order:0!important}.order-1{order:1!important}.order-2{order:2!important}.order-3{order:3!important}.order-4{order:4!important}.order-5{order:5!important}.order-last{order:6!important}.m-0{margin:0!important}.m-1{margin:.25rem!important}.m-2{margin:.5rem!important}.m-3{margin:1rem!important}.m-4{margin:1.5rem!important}.m-5{margin:3rem!important}.m-auto{margin:auto!important}.mx-0{margin-right:0!important;margin-left:0!important}.mx-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-3{margin-right:1rem!important;margin-left:1rem!important}.mx-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-5{margin-right:3rem!important;margin-left:3rem!important}.mx-auto{margin-right:auto!important;margin-left:auto!important}.my-0{margin-top:0!important;margin-bottom:0!important}.my-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-0{margin-top:0!important}.mt-1{margin-top:.25rem!important}.mt-2{margin-top:.5rem!important}.mt-3{margin-top:1rem!important}.mt-4{margin-top:1.5rem!important}.mt-5{margin-top:3rem!important}.mt-auto{margin-top:auto!important}.me-0{margin-right:0!important}.me-1{margin-right:.25rem!important}.me-2{margin-right:.5rem!important}.me-3{margin-right:1rem!important}.me-4{margin-right:1.5rem!important}.me-5{margin-right:3rem!important}.me-auto{margin-right:auto!important}.mb-0{margin-bottom:0!important}.mb-1{margin-bottom:.25rem!important}.mb-2{margin-bottom:.5rem!important}.mb-3{margin-bottom:1rem!important}.mb-4{margin-bottom:1.5rem!important}.mb-5{margin-bottom:3rem!important}.mb-auto{margin-bottom:auto!important}.ms-0{margin-left:0!important}.ms-1{margin-left:.25rem!important}.ms-2{margin-left:.5rem!important}.ms-3{margin-left:1rem!important}.ms-4{margin-left:1.5rem!important}.ms-5{margin-left:3rem!important}.ms-auto{margin-left:auto!important}.p-0{padding:0!important}.p-1{padding:.25rem!important}.p-2{padding:.5rem!important}.p-3{padding:1rem!important}.p-4{padding:1.5rem!important}.p-5{padding:3rem!important}.px-0{padding-right:0!important;padding-left:0!important}.px-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-3{padding-right:1rem!important;padding-left:1rem!important}.px-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-5{padding-right:3rem!important;padding-left:3rem!important}.py-0{padding-top:0!important;padding-bottom:0!important}.py-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-0{padding-top:0!important}.pt-1{padding-top:.25rem!important}.pt-2{padding-top:.5rem!important}.pt-3{padding-top:1rem!important}.pt-4{padding-top:1.5rem!important}.pt-5{padding-top:3rem!important}.pe-0{padding-right:0!important}.pe-1{padding-right:.25rem!important}.pe-2{padding-right:.5rem!important}.pe-3{padding-right:1rem!important}.pe-4{padding-right:1.5rem!important}.pe-5{padding-right:3rem!important}.pb-0{padding-bottom:0!important}.pb-1{padding-bottom:.25rem!important}.pb-2{padding-bottom:.5rem!important}.pb-3{padding-bottom:1rem!important}.pb-4{padding-bottom:1.5rem!important}.pb-5{padding-bottom:3rem!important}.ps-0{padding-left:0!important}.ps-1{padding-left:.25rem!important}.ps-2{padding-left:.5rem!important}.ps-3{padding-left:1rem!important}.ps-4{padding-left:1.5rem!important}.ps-5{padding-left:3rem!important}@media (min-width:576px){.d-sm-inline{display:inline!important}.d-sm-inline-block{display:inline-block!important}.d-sm-block{display:block!important}.d-sm-grid{display:grid!important}.d-sm-table{display:table!important}.d-sm-table-row{display:table-row!important}.d-sm-table-cell{display:table-cell!important}.d-sm-flex{display:flex!important}.d-sm-inline-flex{display:inline-flex!important}.d-sm-none{display:none!important}.flex-sm-fill{flex:1 1 auto!important}.flex-sm-row{flex-direction:row!important}.flex-sm-column{flex-direction:column!important}.flex-sm-row-reverse{flex-direction:row-reverse!important}.flex-sm-column-reverse{flex-direction:column-reverse!important}.flex-sm-grow-0{flex-grow:0!important}.flex-sm-grow-1{flex-grow:1!important}.flex-sm-shrink-0{flex-shrink:0!important}.flex-sm-shrink-1{flex-shrink:1!important}.flex-sm-wrap{flex-wrap:wrap!important}.flex-sm-nowrap{flex-wrap:nowrap!important}.flex-sm-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-sm-start{justify-content:flex-start!important}.justify-content-sm-end{justify-content:flex-end!important}.justify-content-sm-center{justify-content:center!important}.justify-content-sm-between{justify-content:space-between!important}.justify-content-sm-around{justify-content:space-around!important}.justify-content-sm-evenly{justify-content:space-evenly!important}.align-items-sm-start{align-items:flex-start!important}.align-items-sm-end{align-items:flex-end!important}.align-items-sm-center{align-items:center!important}.align-items-sm-baseline{align-items:baseline!important}.align-items-sm-stretch{align-items:stretch!important}.align-content-sm-start{align-content:flex-start!important}.align-content-sm-end{align-content:flex-end!important}.align-content-sm-center{align-content:center!important}.align-content-sm-between{align-content:space-between!important}.align-content-sm-around{align-content:space-around!important}.align-content-sm-stretch{align-content:stretch!important}.align-self-sm-auto{align-self:auto!important}.align-self-sm-start{align-self:flex-start!important}.align-self-sm-end{align-self:flex-end!important}.align-self-sm-center{align-self:center!important}.align-self-sm-baseline{align-self:baseline!important}.align-self-sm-stretch{align-self:stretch!important}.order-sm-first{order:-1!important}.order-sm-0{order:0!important}.order-sm-1{order:1!important}.order-sm-2{order:2!important}.order-sm-3{order:3!important}.order-sm-4{order:4!important}.order-sm-5{order:5!important}.order-sm-last{order:6!important}.m-sm-0{margin:0!important}.m-sm-1{margin:.25rem!important}.m-sm-2{margin:.5rem!important}.m-sm-3{margin:1rem!important}.m-sm-4{margin:1.5rem!important}.m-sm-5{margin:3rem!important}.m-sm-auto{margin:auto!important}.mx-sm-0{margin-right:0!important;margin-left:0!important}.mx-sm-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-sm-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-sm-3{margin-right:1rem!important;margin-left:1rem!important}.mx-sm-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-sm-5{margin-right:3rem!important;margin-left:3rem!important}.mx-sm-auto{margin-right:auto!important;margin-left:auto!important}.my-sm-0{margin-top:0!important;margin-bottom:0!important}.my-sm-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-sm-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-sm-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-sm-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-sm-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-sm-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-sm-0{margin-top:0!important}.mt-sm-1{margin-top:.25rem!important}.mt-sm-2{margin-top:.5rem!important}.mt-sm-3{margin-top:1rem!important}.mt-sm-4{margin-top:1.5rem!important}.mt-sm-5{margin-top:3rem!important}.mt-sm-auto{margin-top:auto!important}.me-sm-0{margin-right:0!important}.me-sm-1{margin-right:.25rem!important}.me-sm-2{margin-right:.5rem!important}.me-sm-3{margin-right:1rem!important}.me-sm-4{margin-right:1.5rem!important}.me-sm-5{margin-right:3rem!important}.me-sm-auto{margin-right:auto!important}.mb-sm-0{margin-bottom:0!important}.mb-sm-1{margin-bottom:.25rem!important}.mb-sm-2{margin-bottom:.5rem!important}.mb-sm-3{margin-bottom:1rem!important}.mb-sm-4{margin-bottom:1.5rem!important}.mb-sm-5{margin-bottom:3rem!important}.mb-sm-auto{margin-bottom:auto!important}.ms-sm-0{margin-left:0!important}.ms-sm-1{margin-left:.25rem!important}.ms-sm-2{margin-left:.5rem!important}.ms-sm-3{margin-left:1rem!important}.ms-sm-4{margin-left:1.5rem!important}.ms-sm-5{margin-left:3rem!important}.ms-sm-auto{margin-left:auto!important}.p-sm-0{padding:0!important}.p-sm-1{padding:.25rem!important}.p-sm-2{padding:.5rem!important}.p-sm-3{padding:1rem!important}.p-sm-4{padding:1.5rem!important}.p-sm-5{padding:3rem!important}.px-sm-0{padding-right:0!important;padding-left:0!important}.px-sm-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-sm-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-sm-3{padding-right:1rem!important;padding-left:1rem!important}.px-sm-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-sm-5{padding-right:3rem!important;padding-left:3rem!important}.py-sm-0{padding-top:0!important;padding-bottom:0!important}.py-sm-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-sm-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-sm-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-sm-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-sm-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-sm-0{padding-top:0!important}.pt-sm-1{padding-top:.25rem!important}.pt-sm-2{padding-top:.5rem!important}.pt-sm-3{padding-top:1rem!important}.pt-sm-4{padding-top:1.5rem!important}.pt-sm-5{padding-top:3rem!important}.pe-sm-0{padding-right:0!important}.pe-sm-1{padding-right:.25rem!important}.pe-sm-2{padding-right:.5rem!important}.pe-sm-3{padding-right:1rem!important}.pe-sm-4{padding-right:1.5rem!important}.pe-sm-5{padding-right:3rem!important}.pb-sm-0{padding-bottom:0!important}.pb-sm-1{padding-bottom:.25rem!important}.pb-sm-2{padding-bottom:.5rem!important}.pb-sm-3{padding-bottom:1rem!important}.pb-sm-4{padding-bottom:1.5rem!important}.pb-sm-5{padding-bottom:3rem!important}.ps-sm-0{padding-left:0!important}.ps-sm-1{padding-left:.25rem!important}.ps-sm-2{padding-left:.5rem!important}.ps-sm-3{padding-left:1rem!important}.ps-sm-4{padding-left:1.5rem!important}.ps-sm-5{padding-left:3rem!important}}@media (min-width:768px){.d-md-inline{display:inline!important}.d-md-inline-block{display:inline-block!important}.d-md-block{display:block!important}.d-md-grid{display:grid!important}.d-md-table{display:table!important}.d-md-table-row{display:table-row!important}.d-md-table-cell{display:table-cell!important}.d-md-flex{display:flex!important}.d-md-inline-flex{display:inline-flex!important}.d-md-none{display:none!important}.flex-md-fill{flex:1 1 auto!important}.flex-md-row{flex-direction:row!important}.flex-md-column{flex-direction:column!important}.flex-md-row-reverse{flex-direction:row-reverse!important}.flex-md-column-reverse{flex-direction:column-reverse!important}.flex-md-grow-0{flex-grow:0!important}.flex-md-grow-1{flex-grow:1!important}.flex-md-shrink-0{flex-shrink:0!important}.flex-md-shrink-1{flex-shrink:1!important}.flex-md-wrap{flex-wrap:wrap!important}.flex-md-nowrap{flex-wrap:nowrap!important}.flex-md-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-md-start{justify-content:flex-start!important}.justify-content-md-end{justify-content:flex-end!important}.justify-content-md-center{justify-content:center!important}.justify-content-md-between{justify-content:space-between!important}.justify-content-md-around{justify-content:space-around!important}.justify-content-md-evenly{justify-content:space-evenly!important}.align-items-md-start{align-items:flex-start!important}.align-items-md-end{align-items:flex-end!important}.align-items-md-center{align-items:center!important}.align-items-md-baseline{align-items:baseline!important}.align-items-md-stretch{align-items:stretch!important}.align-content-md-start{align-content:flex-start!important}.align-content-md-end{align-content:flex-end!important}.align-content-md-center{align-content:center!important}.align-content-md-between{align-content:space-between!important}.align-content-md-around{align-content:space-around!important}.align-content-md-stretch{align-content:stretch!important}.align-self-md-auto{align-self:auto!important}.align-self-md-start{align-self:flex-start!important}.align-self-md-end{align-self:flex-end!important}.align-self-md-center{align-self:center!important}.align-self-md-baseline{align-self:baseline!important}.align-self-md-stretch{align-self:stretch!important}.order-md-first{order:-1!important}.order-md-0{order:0!important}.order-md-1{order:1!important}.order-md-2{order:2!important}.order-md-3{order:3!important}.order-md-4{order:4!important}.order-md-5{order:5!important}.order-md-last{order:6!important}.m-md-0{margin:0!important}.m-md-1{margin:.25rem!important}.m-md-2{margin:.5rem!important}.m-md-3{margin:1rem!important}.m-md-4{margin:1.5rem!important}.m-md-5{margin:3rem!important}.m-md-auto{margin:auto!important}.mx-md-0{margin-right:0!important;margin-left:0!important}.mx-md-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-md-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-md-3{margin-right:1rem!important;margin-left:1rem!important}.mx-md-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-md-5{margin-right:3rem!important;margin-left:3rem!important}.mx-md-auto{margin-right:auto!important;margin-left:auto!important}.my-md-0{margin-top:0!important;margin-bottom:0!important}.my-md-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-md-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-md-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-md-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-md-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-md-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-md-0{margin-top:0!important}.mt-md-1{margin-top:.25rem!important}.mt-md-2{margin-top:.5rem!important}.mt-md-3{margin-top:1rem!important}.mt-md-4{margin-top:1.5rem!important}.mt-md-5{margin-top:3rem!important}.mt-md-auto{margin-top:auto!important}.me-md-0{margin-right:0!important}.me-md-1{margin-right:.25rem!important}.me-md-2{margin-right:.5rem!important}.me-md-3{margin-right:1rem!important}.me-md-4{margin-right:1.5rem!important}.me-md-5{margin-right:3rem!important}.me-md-auto{margin-right:auto!important}.mb-md-0{margin-bottom:0!important}.mb-md-1{margin-bottom:.25rem!important}.mb-md-2{margin-bottom:.5rem!important}.mb-md-3{margin-bottom:1rem!important}.mb-md-4{margin-bottom:1.5rem!important}.mb-md-5{margin-bottom:3rem!important}.mb-md-auto{margin-bottom:auto!important}.ms-md-0{margin-left:0!important}.ms-md-1{margin-left:.25rem!important}.ms-md-2{margin-left:.5rem!important}.ms-md-3{margin-left:1rem!important}.ms-md-4{margin-left:1.5rem!important}.ms-md-5{margin-left:3rem!important}.ms-md-auto{margin-left:auto!important}.p-md-0{padding:0!important}.p-md-1{padding:.25rem!important}.p-md-2{padding:.5rem!important}.p-md-3{padding:1rem!important}.p-md-4{padding:1.5rem!important}.p-md-5{padding:3rem!important}.px-md-0{padding-right:0!important;padding-left:0!important}.px-md-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-md-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-md-3{padding-right:1rem!important;padding-left:1rem!important}.px-md-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-md-5{padding-right:3rem!important;padding-left:3rem!important}.py-md-0{padding-top:0!important;padding-bottom:0!important}.py-md-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-md-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-md-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-md-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-md-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-md-0{padding-top:0!important}.pt-md-1{padding-top:.25rem!important}.pt-md-2{padding-top:.5rem!important}.pt-md-3{padding-top:1rem!important}.pt-md-4{padding-top:1.5rem!important}.pt-md-5{padding-top:3rem!important}.pe-md-0{padding-right:0!important}.pe-md-1{padding-right:.25rem!important}.pe-md-2{padding-right:.5rem!important}.pe-md-3{padding-right:1rem!important}.pe-md-4{padding-right:1.5rem!important}.pe-md-5{padding-right:3rem!important}.pb-md-0{padding-bottom:0!important}.pb-md-1{padding-bottom:.25rem!important}.pb-md-2{padding-bottom:.5rem!important}.pb-md-3{padding-bottom:1rem!important}.pb-md-4{padding-bottom:1.5rem!important}.pb-md-5{padding-bottom:3rem!important}.ps-md-0{padding-left:0!important}.ps-md-1{padding-left:.25rem!important}.ps-md-2{padding-left:.5rem!important}.ps-md-3{padding-left:1rem!important}.ps-md-4{padding-left:1.5rem!important}.ps-md-5{padding-left:3rem!important}}@media (min-width:992px){.d-lg-inline{display:inline!important}.d-lg-inline-block{display:inline-block!important}.d-lg-block{display:block!important}.d-lg-grid{display:grid!important}.d-lg-table{display:table!important}.d-lg-table-row{display:table-row!important}.d-lg-table-cell{display:table-cell!important}.d-lg-flex{display:flex!important}.d-lg-inline-flex{display:inline-flex!important}.d-lg-none{display:none!important}.flex-lg-fill{flex:1 1 auto!important}.flex-lg-row{flex-direction:row!important}.flex-lg-column{flex-direction:column!important}.flex-lg-row-reverse{flex-direction:row-reverse!important}.flex-lg-column-reverse{flex-direction:column-reverse!important}.flex-lg-grow-0{flex-grow:0!important}.flex-lg-grow-1{flex-grow:1!important}.flex-lg-shrink-0{flex-shrink:0!important}.flex-lg-shrink-1{flex-shrink:1!important}.flex-lg-wrap{flex-wrap:wrap!important}.flex-lg-nowrap{flex-wrap:nowrap!important}.flex-lg-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-lg-start{justify-content:flex-start!important}.justify-content-lg-end{justify-content:flex-end!important}.justify-content-lg-center{justify-content:center!important}.justify-content-lg-between{justify-content:space-between!important}.justify-content-lg-around{justify-content:space-around!important}.justify-content-lg-evenly{justify-content:space-evenly!important}.align-items-lg-start{align-items:flex-start!important}.align-items-lg-end{align-items:flex-end!important}.align-items-lg-center{align-items:center!important}.align-items-lg-baseline{align-items:baseline!important}.align-items-lg-stretch{align-items:stretch!important}.align-content-lg-start{align-content:flex-start!important}.align-content-lg-end{align-content:flex-end!important}.align-content-lg-center{align-content:center!important}.align-content-lg-between{align-content:space-between!important}.align-content-lg-around{align-content:space-around!important}.align-content-lg-stretch{align-content:stretch!important}.align-self-lg-auto{align-self:auto!important}.align-self-lg-start{align-self:flex-start!important}.align-self-lg-end{align-self:flex-end!important}.align-self-lg-center{align-self:center!important}.align-self-lg-baseline{align-self:baseline!important}.align-self-lg-stretch{align-self:stretch!important}.order-lg-first{order:-1!important}.order-lg-0{order:0!important}.order-lg-1{order:1!important}.order-lg-2{order:2!important}.order-lg-3{order:3!important}.order-lg-4{order:4!important}.order-lg-5{order:5!important}.order-lg-last{order:6!important}.m-lg-0{margin:0!important}.m-lg-1{margin:.25rem!important}.m-lg-2{margin:.5rem!important}.m-lg-3{margin:1rem!important}.m-lg-4{margin:1.5rem!important}.m-lg-5{margin:3rem!important}.m-lg-auto{margin:auto!important}.mx-lg-0{margin-right:0!important;margin-left:0!important}.mx-lg-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-lg-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-lg-3{margin-right:1rem!important;margin-left:1rem!important}.mx-lg-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-lg-5{margin-right:3rem!important;margin-left:3rem!important}.mx-lg-auto{margin-right:auto!important;margin-left:auto!important}.my-lg-0{margin-top:0!important;margin-bottom:0!important}.my-lg-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-lg-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-lg-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-lg-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-lg-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-lg-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-lg-0{margin-top:0!important}.mt-lg-1{margin-top:.25rem!important}.mt-lg-2{margin-top:.5rem!important}.mt-lg-3{margin-top:1rem!important}.mt-lg-4{margin-top:1.5rem!important}.mt-lg-5{margin-top:3rem!important}.mt-lg-auto{margin-top:auto!important}.me-lg-0{margin-right:0!important}.me-lg-1{margin-right:.25rem!important}.me-lg-2{margin-right:.5rem!important}.me-lg-3{margin-right:1rem!important}.me-lg-4{margin-right:1.5rem!important}.me-lg-5{margin-right:3rem!important}.me-lg-auto{margin-right:auto!important}.mb-lg-0{margin-bottom:0!important}.mb-lg-1{margin-bottom:.25rem!important}.mb-lg-2{margin-bottom:.5rem!important}.mb-lg-3{margin-bottom:1rem!important}.mb-lg-4{margin-bottom:1.5rem!important}.mb-lg-5{margin-bottom:3rem!important}.mb-lg-auto{margin-bottom:auto!important}.ms-lg-0{margin-left:0!important}.ms-lg-1{margin-left:.25rem!important}.ms-lg-2{margin-left:.5rem!important}.ms-lg-3{margin-left:1rem!important}.ms-lg-4{margin-left:1.5rem!important}.ms-lg-5{margin-left:3rem!important}.ms-lg-auto{margin-left:auto!important}.p-lg-0{padding:0!important}.p-lg-1{padding:.25rem!important}.p-lg-2{padding:.5rem!important}.p-lg-3{padding:1rem!important}.p-lg-4{padding:1.5rem!important}.p-lg-5{padding:3rem!important}.px-lg-0{padding-right:0!important;padding-left:0!important}.px-lg-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-lg-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-lg-3{padding-right:1rem!important;padding-left:1rem!important}.px-lg-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-lg-5{padding-right:3rem!important;padding-left:3rem!important}.py-lg-0{padding-top:0!important;padding-bottom:0!important}.py-lg-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-lg-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-lg-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-lg-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-lg-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-lg-0{padding-top:0!important}.pt-lg-1{padding-top:.25rem!important}.pt-lg-2{padding-top:.5rem!important}.pt-lg-3{padding-top:1rem!important}.pt-lg-4{padding-top:1.5rem!important}.pt-lg-5{padding-top:3rem!important}.pe-lg-0{padding-right:0!important}.pe-lg-1{padding-right:.25rem!important}.pe-lg-2{padding-right:.5rem!important}.pe-lg-3{padding-right:1rem!important}.pe-lg-4{padding-right:1.5rem!important}.pe-lg-5{padding-right:3rem!important}.pb-lg-0{padding-bottom:0!important}.pb-lg-1{padding-bottom:.25rem!important}.pb-lg-2{padding-bottom:.5rem!important}.pb-lg-3{padding-bottom:1rem!important}.pb-lg-4{padding-bottom:1.5rem!important}.pb-lg-5{padding-bottom:3rem!important}.ps-lg-0{padding-left:0!important}.ps-lg-1{padding-left:.25rem!important}.ps-lg-2{padding-left:.5rem!important}.ps-lg-3{padding-left:1rem!important}.ps-lg-4{padding-left:1.5rem!important}.ps-lg-5{padding-left:3rem!important}}@media (min-width:1200px){.d-xl-inline{display:inline!important}.d-xl-inline-block{display:inline-block!important}.d-xl-block{display:block!important}.d-xl-grid{display:grid!important}.d-xl-table{display:table!important}.d-xl-table-row{display:table-row!important}.d-xl-table-cell{display:table-cell!important}.d-xl-flex{display:flex!important}.d-xl-inline-flex{display:inline-flex!important}.d-xl-none{display:none!important}.flex-xl-fill{flex:1 1 auto!important}.flex-xl-row{flex-direction:row!important}.flex-xl-column{flex-direction:column!important}.flex-xl-row-reverse{flex-direction:row-reverse!important}.flex-xl-column-reverse{flex-direction:column-reverse!important}.flex-xl-grow-0{flex-grow:0!important}.flex-xl-grow-1{flex-grow:1!important}.flex-xl-shrink-0{flex-shrink:0!important}.flex-xl-shrink-1{flex-shrink:1!important}.flex-xl-wrap{flex-wrap:wrap!important}.flex-xl-nowrap{flex-wrap:nowrap!important}.flex-xl-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-xl-start{justify-content:flex-start!important}.justify-content-xl-end{justify-content:flex-end!important}.justify-content-xl-center{justify-content:center!important}.justify-content-xl-between{justify-content:space-between!important}.justify-content-xl-around{justify-content:space-around!important}.justify-content-xl-evenly{justify-content:space-evenly!important}.align-items-xl-start{align-items:flex-start!important}.align-items-xl-end{align-items:flex-end!important}.align-items-xl-center{align-items:center!important}.align-items-xl-baseline{align-items:baseline!important}.align-items-xl-stretch{align-items:stretch!important}.align-content-xl-start{align-content:flex-start!important}.align-content-xl-end{align-content:flex-end!important}.align-content-xl-center{align-content:center!important}.align-content-xl-between{align-content:space-between!important}.align-content-xl-around{align-content:space-around!important}.align-content-xl-stretch{align-content:stretch!important}.align-self-xl-auto{align-self:auto!important}.align-self-xl-start{align-self:flex-start!important}.align-self-xl-end{align-self:flex-end!important}.align-self-xl-center{align-self:center!important}.align-self-xl-baseline{align-self:baseline!important}.align-self-xl-stretch{align-self:stretch!important}.order-xl-first{order:-1!important}.order-xl-0{order:0!important}.order-xl-1{order:1!important}.order-xl-2{order:2!important}.order-xl-3{order:3!important}.order-xl-4{order:4!important}.order-xl-5{order:5!important}.order-xl-last{order:6!important}.m-xl-0{margin:0!important}.m-xl-1{margin:.25rem!important}.m-xl-2{margin:.5rem!important}.m-xl-3{margin:1rem!important}.m-xl-4{margin:1.5rem!important}.m-xl-5{margin:3rem!important}.m-xl-auto{margin:auto!important}.mx-xl-0{margin-right:0!important;margin-left:0!important}.mx-xl-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-xl-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-xl-3{margin-right:1rem!important;margin-left:1rem!important}.mx-xl-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-xl-5{margin-right:3rem!important;margin-left:3rem!important}.mx-xl-auto{margin-right:auto!important;margin-left:auto!important}.my-xl-0{margin-top:0!important;margin-bottom:0!important}.my-xl-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-xl-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-xl-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-xl-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-xl-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-xl-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-xl-0{margin-top:0!important}.mt-xl-1{margin-top:.25rem!important}.mt-xl-2{margin-top:.5rem!important}.mt-xl-3{margin-top:1rem!important}.mt-xl-4{margin-top:1.5rem!important}.mt-xl-5{margin-top:3rem!important}.mt-xl-auto{margin-top:auto!important}.me-xl-0{margin-right:0!important}.me-xl-1{margin-right:.25rem!important}.me-xl-2{margin-right:.5rem!important}.me-xl-3{margin-right:1rem!important}.me-xl-4{margin-right:1.5rem!important}.me-xl-5{margin-right:3rem!important}.me-xl-auto{margin-right:auto!important}.mb-xl-0{margin-bottom:0!important}.mb-xl-1{margin-bottom:.25rem!important}.mb-xl-2{margin-bottom:.5rem!important}.mb-xl-3{margin-bottom:1rem!important}.mb-xl-4{margin-bottom:1.5rem!important}.mb-xl-5{margin-bottom:3rem!important}.mb-xl-auto{margin-bottom:auto!important}.ms-xl-0{margin-left:0!important}.ms-xl-1{margin-left:.25rem!important}.ms-xl-2{margin-left:.5rem!important}.ms-xl-3{margin-left:1rem!important}.ms-xl-4{margin-left:1.5rem!important}.ms-xl-5{margin-left:3rem!important}.ms-xl-auto{margin-left:auto!important}.p-xl-0{padding:0!important}.p-xl-1{padding:.25rem!important}.p-xl-2{padding:.5rem!important}.p-xl-3{padding:1rem!important}.p-xl-4{padding:1.5rem!important}.p-xl-5{padding:3rem!important}.px-xl-0{padding-right:0!important;padding-left:0!important}.px-xl-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-xl-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-xl-3{padding-right:1rem!important;padding-left:1rem!important}.px-xl-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-xl-5{padding-right:3rem!important;padding-left:3rem!important}.py-xl-0{padding-top:0!important;padding-bottom:0!important}.py-xl-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-xl-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-xl-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-xl-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-xl-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-xl-0{padding-top:0!important}.pt-xl-1{padding-top:.25rem!important}.pt-xl-2{padding-top:.5rem!important}.pt-xl-3{padding-top:1rem!important}.pt-xl-4{padding-top:1.5rem!important}.pt-xl-5{padding-top:3rem!important}.pe-xl-0{padding-right:0!important}.pe-xl-1{padding-right:.25rem!important}.pe-xl-2{padding-right:.5rem!important}.pe-xl-3{padding-right:1rem!important}.pe-xl-4{padding-right:1.5rem!important}.pe-xl-5{padding-right:3rem!important}.pb-xl-0{padding-bottom:0!important}.pb-xl-1{padding-bottom:.25rem!important}.pb-xl-2{padding-bottom:.5rem!important}.pb-xl-3{padding-bottom:1rem!important}.pb-xl-4{padding-bottom:1.5rem!important}.pb-xl-5{padding-bottom:3rem!important}.ps-xl-0{padding-left:0!important}.ps-xl-1{padding-left:.25rem!important}.ps-xl-2{padding-left:.5rem!important}.ps-xl-3{padding-left:1rem!important}.ps-xl-4{padding-left:1.5rem!important}.ps-xl-5{padding-left:3rem!important}}@media (min-width:1400px){.d-xxl-inline{display:inline!important}.d-xxl-inline-block{display:inline-block!important}.d-xxl-block{display:block!important}.d-xxl-grid{display:grid!important}.d-xxl-table{display:table!important}.d-xxl-table-row{display:table-row!important}.d-xxl-table-cell{display:table-cell!important}.d-xxl-flex{display:flex!important}.d-xxl-inline-flex{display:inline-flex!important}.d-xxl-none{display:none!important}.flex-xxl-fill{flex:1 1 auto!important}.flex-xxl-row{flex-direction:row!important}.flex-xxl-column{flex-direction:column!important}.flex-xxl-row-reverse{flex-direction:row-reverse!important}.flex-xxl-column-reverse{flex-direction:column-reverse!important}.flex-xxl-grow-0{flex-grow:0!important}.flex-xxl-grow-1{flex-grow:1!important}.flex-xxl-shrink-0{flex-shrink:0!important}.flex-xxl-shrink-1{flex-shrink:1!important}.flex-xxl-wrap{flex-wrap:wrap!important}.flex-xxl-nowrap{flex-wrap:nowrap!important}.flex-xxl-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-xxl-start{justify-content:flex-start!important}.justify-content-xxl-end{justify-content:flex-end!important}.justify-content-xxl-center{justify-content:center!important}.justify-content-xxl-between{justify-content:space-between!important}.justify-content-xxl-around{justify-content:space-around!important}.justify-content-xxl-evenly{justify-content:space-evenly!important}.align-items-xxl-start{align-items:flex-start!important}.align-items-xxl-end{align-items:flex-end!important}.align-items-xxl-center{align-items:center!important}.align-items-xxl-baseline{align-items:baseline!important}.align-items-xxl-stretch{align-items:stretch!important}.align-content-xxl-start{align-content:flex-start!important}.align-content-xxl-end{align-content:flex-end!important}.align-content-xxl-center{align-content:center!important}.align-content-xxl-between{align-content:space-between!important}.align-content-xxl-around{align-content:space-around!important}.align-content-xxl-stretch{align-content:stretch!important}.align-self-xxl-auto{align-self:auto!important}.align-self-xxl-start{align-self:flex-start!important}.align-self-xxl-end{align-self:flex-end!important}.align-self-xxl-center{align-self:center!important}.align-self-xxl-baseline{align-self:baseline!important}.align-self-xxl-stretch{align-self:stretch!important}.order-xxl-first{order:-1!important}.order-xxl-0{order:0!important}.order-xxl-1{order:1!important}.order-xxl-2{order:2!important}.order-xxl-3{order:3!important}.order-xxl-4{order:4!important}.order-xxl-5{order:5!important}.order-xxl-last{order:6!important}.m-xxl-0{margin:0!important}.m-xxl-1{margin:.25rem!important}.m-xxl-2{margin:.5rem!important}.m-xxl-3{margin:1rem!important}.m-xxl-4{margin:1.5rem!important}.m-xxl-5{margin:3rem!important}.m-xxl-auto{margin:auto!important}.mx-xxl-0{margin-right:0!important;margin-left:0!important}.mx-xxl-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-xxl-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-xxl-3{margin-right:1rem!important;margin-left:1rem!important}.mx-xxl-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-xxl-5{margin-right:3rem!important;margin-left:3rem!important}.mx-xxl-auto{margin-right:auto!important;margin-left:auto!important}.my-xxl-0{margin-top:0!important;margin-bottom:0!important}.my-xxl-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-xxl-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-xxl-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-xxl-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-xxl-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-xxl-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-xxl-0{margin-top:0!important}.mt-xxl-1{margin-top:.25rem!important}.mt-xxl-2{margin-top:.5rem!important}.mt-xxl-3{margin-top:1rem!important}.mt-xxl-4{margin-top:1.5rem!important}.mt-xxl-5{margin-top:3rem!important}.mt-xxl-auto{margin-top:auto!important}.me-xxl-0{margin-right:0!important}.me-xxl-1{margin-right:.25rem!important}.me-xxl-2{margin-right:.5rem!important}.me-xxl-3{margin-right:1rem!important}.me-xxl-4{margin-right:1.5rem!important}.me-xxl-5{margin-right:3rem!important}.me-xxl-auto{margin-right:auto!important}.mb-xxl-0{margin-bottom:0!important}.mb-xxl-1{margin-bottom:.25rem!important}.mb-xxl-2{margin-bottom:.5rem!important}.mb-xxl-3{margin-bottom:1rem!important}.mb-xxl-4{margin-bottom:1.5rem!important}.mb-xxl-5{margin-bottom:3rem!important}.mb-xxl-auto{margin-bottom:auto!important}.ms-xxl-0{margin-left:0!important}.ms-xxl-1{margin-left:.25rem!important}.ms-xxl-2{margin-left:.5rem!important}.ms-xxl-3{margin-left:1rem!important}.ms-xxl-4{margin-left:1.5rem!important}.ms-xxl-5{margin-left:3rem!important}.ms-xxl-auto{margin-left:auto!important}.p-xxl-0{padding:0!important}.p-xxl-1{padding:.25rem!important}.p-xxl-2{padding:.5rem!important}.p-xxl-3{padding:1rem!important}.p-xxl-4{padding:1.5rem!important}.p-xxl-5{padding:3rem!important}.px-xxl-0{padding-right:0!important;padding-left:0!important}.px-xxl-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-xxl-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-xxl-3{padding-right:1rem!important;padding-left:1rem!important}.px-xxl-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-xxl-5{padding-right:3rem!important;padding-left:3rem!important}.py-xxl-0{padding-top:0!important;padding-bottom:0!important}.py-xxl-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-xxl-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-xxl-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-xxl-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-xxl-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-xxl-0{padding-top:0!important}.pt-xxl-1{padding-top:.25rem!important}.pt-xxl-2{padding-top:.5rem!important}.pt-xxl-3{padding-top:1rem!important}.pt-xxl-4{padding-top:1.5rem!important}.pt-xxl-5{padding-top:3rem!important}.pe-xxl-0{padding-right:0!important}.pe-xxl-1{padding-right:.25rem!important}.pe-xxl-2{padding-right:.5rem!important}.pe-xxl-3{padding-right:1rem!important}.pe-xxl-4{padding-right:1.5rem!important}.pe-xxl-5{padding-right:3rem!important}.pb-xxl-0{padding-bottom:0!important}.pb-xxl-1{padding-bottom:.25rem!important}.pb-xxl-2{padding-bottom:.5rem!important}.pb-xxl-3{padding-bottom:1rem!important}.pb-xxl-4{padding-bottom:1.5rem!important}.pb-xxl-5{padding-bottom:3rem!important}.ps-xxl-0{padding-left:0!important}.ps-xxl-1{padding-left:.25rem!important}.ps-xxl-2{padding-left:.5rem!important}.ps-xxl-3{padding-left:1rem!important}.ps-xxl-4{padding-left:1.5rem!important}.ps-xxl-5{padding-left:3rem!important}}@media print{.d-print-inline{display:inline!important}.d-print-inline-block{display:inline-block!important}.d-print-block{display:block!important}.d-print-grid{display:grid!important}.d-print-table{display:table!important}.d-print-table-row{display:table-row!important}.d-print-table-cell{display:table-cell!important}.d-print-flex{display:flex!important}.d-print-inline-flex{display:inline-flex!important}.d-print-none{display:none!important}}
7
+ /*# sourceMappingURL=bootstrap-grid.min.css.map */
assets/css/inline-edit.css DELETED
@@ -1,5 +0,0 @@
1
- .mycred-update-balance { background-color:white; }.mycred-update-balance>div { padding:12px; }.mycred-update-balance .ui-dialog-titlebar { line-height:24px; border-bottom: 1px solid #dedede; }.mycred-update-balance .ui-dialog-titlebar:hover { cursor:move; }.mycred-update-balance .ui-dialog-titlebar-close { float:right; }body.users-php .ui-widget-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background: repeat-x scroll 50% 50% #AAA; opacity:0.3; overflow:hidden; background: repeat-x scroll 50% 50% #333; }.mycred-adjustment-form { display:block; float:none; clear:both; padding:0; margin:0; }.mycred-adjustment-form .row { line-height:24px; margin:0; padding:0; float:none; margin: 0 0 4px 0; clear:both; }.mycred-adjustment-form .row.inline { float:left; clear:none; }}.mycred-update-balance .mycred-adjustment-form .row.inline span { font-size:18px; }.mycred-adjustment-form .row label { display:block; margin-bottom:0; }.mycred-adjustment-form .row input[type="text"] { width:90%; }.mycred-adjustment-form .row input[type="button"] { float:right; }input#mycred-update-users-balance-amount { width:25%; }#edit-mycred-balance #mycred-current.done { color:green; }.mycred-adjustment-form .row input.error { border-color:red; }
2
-
3
- .mycred-edit-log-entry { background-color:white; }.mycred-edit-log-entry>div { padding:12px; }.mycred-edit-log-entry .ui-dialog-titlebar { line-height:24px; border-bottom: 1px solid #dedede; }.mycred-edit-log-entry .ui-dialog-titlebar:hover { cursor:move; }.mycred-edit-log-entry .ui-dialog-titlebar-close { float:right; }body .ui-widget-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background: repeat-x scroll 50% 50% #AAA; opacity:0.3; overflow:hidden; background: repeat-x scroll 50% 50% #333; }#edit-mycred-log-entry .mycred-adjustment-form .row label{ font-weight:bold; }#edit-mycred-log-entry .mycred-adjustment-form .row input[type="button"] { float:right; margin-left: 24px; }#edit-mycred-log-entry #mycred-current.done { color:green; }.mycred-adjustment-form .row input.error { border-color:red; }
4
-
5
- .mycred-export-points { background-color:white; }.mycred-export-points>div { padding:12px; }.mycred-export-points .ui-dialog-titlebar { line-height:24px; border-bottom: 1px solid #dedede; }.mycred-export-points .ui-dialog-titlebar:hover { cursor:move; }.mycred-export-points .ui-dialog-titlebar-close { float:right; }
 
 
 
 
 
assets/css/overview.css DELETED
@@ -1,34 +0,0 @@
1
- #mycred_overview p.sub,
2
- #mycred_overview .table, #mycred_overview .versions { margin: -12px; }
3
- #mycred_overview .inside { font-size: 13px; padding-top: 20px; }
4
- body.mp6 #mycred_overview p.sub { padding: 5px 0 15px; font-size: 11px; font-weight: 600; left: 14px; letter-spacing: 1px; position: absolute; text-transform: uppercase; top: -17px; }
5
- body #mycred_overview p.sub { padding: 5px 0 15px; color: #8f8f8f; font-size: 14px; position: absolute; top: -17px; left: 15px; }
6
- #mycred_overview .table { margin: 0; padding: 0; position: relative; }
7
- body.mp6 #mycred_overview .table_content { float: left; width: 45%; }
8
- body #mycred_overview .table_content { float: left; width: 45%; border-top: 1px solid #ececec; }
9
- #mycred_overview .table_content.push { margin-right: 9%; }
10
- #mycred_overview table td { padding: 3px 0; white-space: nowrap; }
11
- #mycred_overview table tr.first td { border-top: none; }
12
- #mycred_overview td.b { padding-right: 6px; text-align: right; font-size: 14px; width: 1%; }
13
- #mycred_overview td.b a { font-size: 18px; }
14
- #mycred_overview td.b a:hover { color: #d54e21; }
15
- #mycred_overview .t { padding-right: 12px; }
16
- #mycred_overview .t,
17
- #mycred_overview .b { font-size: 14px; padding-top: 4px; }
18
- #mycred_overview .t a { white-space: nowrap; }
19
- #mycred_overview .spam { color: red; }
20
- #mycred_overview .waiting { color: #e66f00; }
21
- #mycred_overview .approved { color: green; }
22
- #mycred_overview .versions { padding: 6px 10px 12px; clear: both; }
23
- #mycred_overview a.button { float: right; clear: right; position: relative; top: -5px; }
24
- #mycred_overview .no-modules { color: #dedede; text-align: center; margin-top: 0; }
25
-
26
- div.columns-3 #mycred_overview .table_content,
27
- div.columns-4 #mycred_overview .table_content { float: none; width: 100%; clear: both; margin-bottom: 42px; }
28
- div.columns-3 #mycred_overview .table_content.push,
29
- div.columns-4 #mycred_overview .table_content.push { margin-right: 0; }
30
- div.columns-4 #mycred_overview td.b a,
31
- div.columns-4 #mycred_overview .t { font-size: 12px; }
32
- div.columns-4 #mycred_overview td { line-height: 1em; }
33
-
34
- #mycred_overview form.dashboard-widget-control-form { overflow: visible; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/widget.css DELETED
@@ -1 +0,0 @@
1
- .widget .myCRED-rank { float:right; }.widget .myCRED-rank span { padding-right:4px; color:gray; }.widget .myCRED-balance { display:block; margin-bottom:24px; text-align:center; font-size:larger; }.widget .myCRED-leaderboard .cred { float:right; }.widget .myCRED-leaderboard .first-item { font-size:110%; }.widget .myCRED-history { padding:0; margin:0; list-style-type:none; }.widget .myCRED-history .creds { float:right; padding: 0; clear:left; }
 
assets/images/about/badge.png DELETED
Binary file
assets/js/edit-log.js DELETED
@@ -1,278 +0,0 @@
1
- /**
2
- * myCRED Edit Log Scripts
3
- * These scripts are used to edit or delete entries
4
- * in the myCRED Log.
5
- * @since 1.4
6
- * @version 1.1
7
- */
8
- jQuery(function($) {
9
-
10
- /**
11
- * Click To Toggle Script
12
- */
13
- $( '.click-to-toggle' ).click(function(){
14
- var target = $(this).attr( 'data-toggle' );
15
- $( '#' + target ).toggle();
16
- });
17
-
18
- /**
19
- * Delete Log Entry AJAX caller
20
- */
21
- var mycred_delete_log_entry = function( rowid, button ) {
22
- $.ajax({
23
- type : "POST",
24
- data : {
25
- action : 'mycred-delete-log-entry',
26
- token : myCREDLog.tokens.delete_row,
27
- row : rowid
28
- },
29
- dataType : "JSON",
30
- url : myCREDLog.ajaxurl,
31
- success : function( response ) {
32
- // Debug
33
- //console.log( response );
34
-
35
- var parentrow = button.parent().parent().parent();
36
- var actioncol = button.parent().parent();
37
-
38
- if ( response.success ) {
39
- actioncol.empty();
40
- actioncol.text( response.data );
41
-
42
- parentrow.addClass( 'deleted-row' );
43
- parentrow.fadeOut( 3000, function(){ parentrow.remove(); });
44
- }
45
- else {
46
- actioncol.empty();
47
- actioncol.text( response.data );
48
- }
49
- },
50
- error : function( jqXHR, textStatus, errorThrown ) {
51
- // Debug
52
- //console.log( jqXHR );
53
- //console.log( 'textStatus: ' + textStatus + ' | errorThrown: ' + errorThrown );
54
- }
55
- });
56
- }
57
-
58
- /**
59
- * Log Entry Deletion Trigger
60
- */
61
- $( '.mycred-delete-row' ).click(function(){
62
- // Require user to confirm deletion
63
- if ( ! confirm( myCREDLog.messages.delete_row ) )
64
- return false;
65
-
66
- // Execute AJAX call
67
- mycred_delete_log_entry( $(this).attr( 'data-id' ), $(this) );
68
- });
69
-
70
- var log_row_id = '';
71
- var log_user = '';
72
- var log_time = '';
73
- var log_cred = '';
74
-
75
- var log_entry_raw = '';
76
- var log_entry = '';
77
-
78
- /**
79
- * Setup Log Editor Modal
80
- */
81
- $('#edit-mycred-log-entry').dialog({
82
- dialogClass : 'mycred-edit-log-entry',
83
- draggable : true,
84
- autoOpen : false,
85
- title : myCREDLog.title,
86
- closeText : myCREDLog.close,
87
- modal : true,
88
- width : 500,
89
- height : 'auto',
90
- resizable : false,
91
- show : {
92
- effect : 'slide',
93
- direction : 'up',
94
- duration : 250
95
- },
96
- hide : {
97
- effect : 'slide',
98
- direction : 'up',
99
- duration : 250
100
- }
101
- });
102
-
103
- /**
104
- * Edit Modal Trigger
105
- */
106
- $( '.mycred-open-log-entry-editor' ).click( function() {
107
-
108
- // Get the details we want to show
109
- log_row_id = $(this).attr( 'data-id' );
110
- log_user = $(this).parent().siblings( 'td.column-username' ).children( 'span' ).text();
111
- log_time = $(this).parent().siblings( 'td.column-time' ).text();
112
- log_cred = $(this).parent().siblings( 'td.column-creds' ).text();
113
-
114
- log_entry_raw = $(this).parent().siblings( 'td.column-entry' ).children( 'div.raw' ).text();
115
- log_entry = $(this).parent().siblings( 'td.column-entry' ).children( 'div.entry' ).text();
116
-
117
- // Show the modal window
118
- $( '#edit-mycred-log-entry' ).dialog( 'open' );
119
-
120
- // Populate the form
121
- var username_el = $( '#edit-mycred-log-entry #mycred-username' );
122
- username_el.empty();
123
- username_el.text( log_user );
124
-
125
- var time_el = $( '#edit-mycred-log-entry #mycred-time' );
126
- time_el.empty();
127
- time_el.text( log_time );
128
-
129
- var creds_el = $( '#edit-mycred-log-entry #mycred-creds' );
130
- creds_el.empty();
131
- creds_el.text( log_cred );
132
-
133
- var entry_el = $( '#edit-mycred-log-entry #mycred-raw-entry' );
134
- entry_el.val( '' );
135
- entry_el.val( log_entry );
136
-
137
- var raw_entry_el = $( '#edit-mycred-log-entry #mycred-new-entry' );
138
- raw_entry_el.val( '' );
139
- raw_entry_el.val( log_entry_raw );
140
-
141
- $( 'input#mycred-log-row-id' ).val( log_row_id );
142
-
143
- });
144
-
145
- /**
146
- * Edit AJAX Call
147
- */
148
- var mycred_update_log_entry = function( rowid, entry, button ) {
149
- var button_label = button.val();
150
-
151
- $.ajax({
152
- type : "POST",
153
- data : {
154
- action : 'mycred-update-log-entry',
155
- token : myCREDLog.tokens.update_row,
156
- row : rowid,
157
- new_entry : entry
158
- },
159
- dataType : "JSON",
160
- url : myCREDLog.ajaxurl,
161
- beforeSend : function() {
162
-
163
- button.removeClass( 'button-primary' );
164
- button.addClass( 'button-secondary' );
165
- button.val( myCREDLog.working );
166
- },
167
- success : function( response ) {
168
- // Debug
169
- console.log( response );
170
-
171
- var effected_row = $( '#mycred-log-entry-' + response.data.row_id );
172
- button.removeClass( 'button-secondary' );
173
-
174
- if ( response.success ) {
175
- effected_row.addClass( 'updated-row' );
176
- effected_row.children( 'td.column-entry' ).children( 'div.raw' ).empty().html( response.data.new_entry_raw );
177
-
178
- $( '#edit-mycred-log-entry #mycred-raw-entry' ).val( response.data.new_entry );
179
-
180
- effected_row.children( 'td.column-entry' ).children( 'div.entry' ).empty().html( response.data.new_entry );
181
-
182
- $( '#edit-mycred-log-entry #mycred-new-entry' ).val( response.data.new_entry_raw );
183
-
184
- button.val( response.data.label );
185
- setTimeout(function(){ button.val( button_label ); button.addClass( 'button-primary' ); }, 5000 );
186
- }
187
- else {
188
- button.val( response.data );
189
- setTimeout(function(){ button.val( button_label ); button.addClass( 'button-primary' ); }, 5000 );
190
- }
191
- },
192
- error : function( jqXHR, textStatus, errorThrown ) {
193
- // Debug
194
- //console.log( jqXHR );
195
- //console.log( 'textStatus: ' + textStatus + ' | errorThrown: ' + errorThrown );
196
- }
197
- });
198
- }
199
-
200
- /**
201
- * Edit AJAX Call Trigger
202
- */
203
- $( '#mycred-update-log-entry' ).click( function() {
204
- mycred_update_log_entry( $(this).next().val(), $( 'input#mycred-new-entry' ).val(), $(this) );
205
- });
206
-
207
- /* global setUserSetting, ajaxurl, commonL10n, alert, confirm, toggleWithKeyboard, pagenow */
208
- var showNotice, adminMenu, columns, validateForm, screenMeta;
209
-
210
- // Removed in 3.3.
211
- // (perhaps) needed for back-compat
212
- adminMenu = {
213
- init : function() {},
214
- fold : function() {},
215
- restoreMenuState : function() {},
216
- toggle : function() {},
217
- favorites : function() {}
218
- };
219
-
220
- // show/hide/save table columns
221
- columns = {
222
- init : function() {
223
- var that = this;
224
- $('.hide-column-tog', '#adv-settings').click( function() {
225
- var $t = $(this), column = $t.val();
226
- if ( $t.prop('checked') )
227
- that.checked(column);
228
- else
229
- that.unchecked(column);
230
-
231
- columns.saveManageColumnsState();
232
- });
233
- },
234
-
235
- saveManageColumnsState : function() {
236
- var hidden = this.hidden();
237
- $.post(ajaxurl, {
238
- action: 'hidden-columns',
239
- hidden: hidden,
240
- screenoptionnonce: $('#screenoptionnonce').val(),
241
- page: pagenow
242
- });
243
- },
244
-
245
- checked : function(column) {
246
- $('.' + column).show();
247
- this.colSpanChange(+1);
248
- },
249
-
250
- unchecked : function(column) {
251
- $('.' + column).hide();
252
- this.colSpanChange(-1);
253
- },
254
-
255
- hidden : function() {
256
- return $('.manage-column').filter(':hidden').map(function() { return this.id; }).get().join(',');
257
- },
258
-
259
- useCheckboxesForHidden : function() {
260
- this.hidden = function(){
261
- return $('.hide-column-tog').not(':checked').map(function() {
262
- var id = this.id;
263
- return id.substring( id, id.length - 5 );
264
- }).get().join(',');
265
- };
266
- },
267
-
268
- colSpanChange : function(diff) {
269
- var $t = $('table').find('.colspanchange'), n;
270
- if ( !$t.length )
271
- return;
272
- n = parseInt( $t.attr('colspan'), 10 ) + diff;
273
- $t.attr('colspan', n.toString());
274
- }
275
- };
276
-
277
- $(document).ready(function(){columns.init();});
278
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/management.js DELETED
@@ -1,202 +0,0 @@
1
- /**
2
- * myCRED Management Scripts
3
- * @since 1.3
4
- * @version 1.2
5
- */
6
- jQuery(function($) {
7
-
8
- /**
9
- * Empty Log AJAX Caller
10
- */
11
- var mycred_action_empty_log = function( button ) {
12
- var label = button.val();
13
- $.ajax({
14
- type : "POST",
15
- data : {
16
- action : 'mycred-action-empty-log',
17
- token : myCREDmanage.token,
18
- type : button.attr( 'data-type' )
19
- },
20
- dataType : "JSON",
21
- url : myCREDmanage.ajaxurl,
22
- beforeSend : function() {
23
- button.attr( 'value', myCREDmanage.working );
24
- button.attr( 'disabled', 'disabled' );
25
- },
26
- success : function( response ) {
27
- if ( response.success ) {
28
- $( 'input#mycred-manage-table-rows' ).val( response.data );
29
- button.val( myCREDmanage.done );
30
- button.removeClass( 'button-primary' );
31
- }
32
- else {
33
- button.val( label );
34
- button.removeAttr( 'disabled' );
35
- alert( response.data );
36
- }
37
- }
38
- });
39
- };
40
-
41
- /**
42
- * Empty Log Trigger
43
- */
44
- $( 'input#mycred-manage-action-empty-log' ).click(function(){
45
- // Confirm action
46
- if ( confirm( myCREDmanage.confirm_log ) )
47
- mycred_action_empty_log( $(this) );
48
- });
49
-
50
- /**
51
- * Reset Balance AJAX Caller
52
- */
53
- var mycred_action_reset_balance = function( button ) {
54
- var label = button.val();
55
- $.ajax({
56
- type : "POST",
57
- data : {
58
- action : 'mycred-action-reset-accounts',
59
- token : myCREDmanage.token,
60
- type : button.attr( 'data-type' )
61
- },
62
- dataType : "JSON",
63
- url : myCREDmanage.ajaxurl,
64
- beforeSend : function() {
65
- button.attr( 'value', myCREDmanage.working );
66
- button.attr( 'disabled', 'disabled' );
67
- },
68
- success : function( response ) {
69
- if ( response.success ) {
70
- button.val( response.data );
71
- button.removeClass( 'button-primary' );
72
- }
73
- else {
74
- button.val( label );
75
- button.removeAttr( 'disabled' );
76
- alert( response.data );
77
- }
78
- }
79
- });
80
- };
81
-
82
- /**
83
- * Reset Balance Trigger
84
- */
85
- $( 'input#mycred-manage-action-reset-accounts' ).click(function(){
86
- // Confirm action
87
- if ( confirm( myCREDmanage.confirm_reset ) )
88
- mycred_action_reset_balance( $(this) );
89
- });
90
-
91
- /**
92
- * Export Balances Modal
93
- */
94
- $('#export-points').dialog({
95
- dialogClass : 'mycred-export-points',
96
- draggable : false,
97
- autoOpen : false,
98
- closeText : myCREDmanage.export_close,
99
- title : myCREDmanage.export_title,
100
- modal : true,
101
- width : 500,
102
- resizable : false,
103
- show : { effect: 'slide', direction: 'up', duration: 250 },
104
- hide : { effect: 'slide', direction: 'up', duration: 250 }
105
- });
106
-
107
- /**
108
- * Export balances Modal Trigger
109
- */
110
- $( '#mycred-export-users-points' ).click( function() {
111
- $( '#export-points' ).dialog( 'open' );
112
- });
113
-
114
- /**
115
- * Export Balances AJAX Caller
116
- */
117
- var mycred_action_export_balances = function( button ) {
118
- var label = button.val();
119
- $.ajax({
120
- type : "POST",
121
- data : {
122
- action : 'mycred-action-export-balances',
123
- token : myCREDmanage.token,
124
- identify : $( '#mycred-export-identify-by' ).val(),
125
- log_temp : $( '#mycred-export-log-template' ).val(),
126
- type : button.attr( 'data-type' )
127
- },
128
- dataType : "JSON",
129
- url : myCREDmanage.ajaxurl,
130
- beforeSend : function() {
131
- button.attr( 'value', myCREDmanage.working );
132
- button.attr( 'disabled', 'disabled' );
133
- },
134
- success : function( response ) {
135
- // Debug
136
- //console.log( response );
137
-
138
- if ( response.success ) {
139
- setTimeout(function(){
140
- window.location.href = response.data;
141
- button.val( myCREDmanage.done );
142
- }, 2000 );
143
- setTimeout(function(){
144
- button.removeAttr( 'disabled' );
145
- button.val( label );
146
- }, 4000 );
147
- }
148
- else {
149
- button.val( label );
150
- button.before( response.data );
151
- }
152
- }
153
- });
154
- };
155
-
156
- /**
157
- * Balance Export Trigger
158
- */
159
- $( '#mycred-run-exporter' ).click(function(){
160
- mycred_action_export_balances( $(this) );
161
- });
162
-
163
- /**
164
- * Generate Key AJAX Caller
165
- */
166
- var mycred_generate_key = function() {
167
- $.ajax({
168
- type : "POST",
169
- data : {
170
- action : 'mycred-action-generate-key',
171
- token : myCREDmanage.token
172
- },
173
- dataType : "JSON",
174
- url : myCREDmanage.ajaxurl,
175
- success : function( response ) {
176
- $( '#myCRED-remote-key' ).val( response.data );
177
- $( '#mycred-length-counter' ).text( response.data.length );
178
- }
179
- });
180
- }
181
-
182
- /**
183
- * Generate Key Trigger
184
- */
185
- $( '#mycred-generate-api-key' ).click(function(){
186
- mycred_generate_key();
187
- });
188
-
189
- /**
190
- * Key Length Indicator
191
- */
192
- $( '#myCRED-remote-key' ).change(function(){
193
- $( '#mycred-length-counter' ).text( $(this).val().length );
194
- });
195
-
196
- /**
197
- * Key Length Indicator
198
- */
199
- $( '#myCRED-remote-key' ).keyup(function(){
200
- $( '#mycred-length-counter' ).text( $(this).val().length );
201
- });
202
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/mycred-tools.js CHANGED
@@ -71,6 +71,7 @@ jQuery(document).ready(function() {
71
  data: function(params) {
72
  var query = {
73
  search: params.term,
 
74
  action: 'mycred-tools-select-user'
75
  }
76
 
@@ -148,6 +149,7 @@ jQuery(document).ready(function() {
148
  type: 'POST',
149
  data: {
150
  action: 'mycred-tools-assign-award',
 
151
  selected_type: $selectedType,
152
  points_to_award: $pointsToAward,
153
  point_type: $pointType,
@@ -166,6 +168,7 @@ jQuery(document).ready(function() {
166
  jQuery('.tools-bulk-assign-award-btn').find('span').css('display', 'inherit');
167
  },
168
  success: function(data) {
 
169
  jQuery('.tools-bulk-assign-award-btn').find('span').hide();
170
 
171
  if (data.success === true && $pointsToAward < 0) {
@@ -177,20 +180,12 @@ jQuery(document).ready(function() {
177
  if (data.success === true) {
178
  alert(mycredTools.successfullyAwarded);
179
  mycredToolsResetForm();
 
180
  }
181
 
182
- if (data.success == 'pointsRequired') {
183
- alert(mycredTools.pointsRequired);
184
- }
185
- if (data.success == 'logEntryRequired') {
186
- alert(mycredTools.logEntryRequired);
187
- }
188
- if (data.success == 'userOrRoleIsRequired') {
189
- alert(mycredTools.userOrRoleIsRequired);
190
- }
191
- if (data.success == 'badgesFieldRequried') {
192
- alert(mycredTools.badgesFieldRequried);
193
- }
194
  }
195
  })
196
  });
@@ -211,12 +206,12 @@ jQuery(document).ready(function() {
211
  var $users = JSON.stringify(jQuery('[name="bulk_users"]').val());
212
  var $user_roles = JSON.stringify(jQuery('[name="bulk_roles"]').val());
213
 
214
-
215
  jQuery.ajax({
216
  url: ajaxurl,
217
  type: 'POST',
218
  data: {
219
  action: 'mycred-tools-assign-award',
 
220
  selected_type: $selectedType,
221
  revoke: 'revoke',
222
  badges_to_revoke: $badgesToRevoke,
@@ -228,18 +223,18 @@ jQuery(document).ready(function() {
228
  jQuery('.tools-revoke-btn').find('span').css('display', 'inherit');
229
  },
230
  success: function(data) {
 
231
  jQuery('.tools-revoke-btn').find('span').hide();
232
 
233
  if (data.success === true) {
234
  alert(mycredTools.successfullyRevoked);
235
  mycredToolsResetForm();
 
236
  }
237
- if (data.success == 'userOrRoleIsRequired') {
238
- alert(mycredTools.userOrRoleIsRequired);
239
- }
240
- if (data.success == 'badgesFieldRequried') {
241
- alert(mycredTools.badgesFieldRequried);
242
- }
243
  }
244
  });
245
  });
@@ -285,6 +280,7 @@ jQuery(document).ready(function() {
285
  type: 'POST',
286
  data: {
287
  action: 'mycred-tools-import-export',
 
288
  request_tab: $requestTab,
289
  template: 'formatted'
290
  },
@@ -306,6 +302,7 @@ jQuery(document).ready(function() {
306
  type: 'POST',
307
  data: {
308
  action: 'mycred-tools-import-export',
 
309
  request_tab: $requestTab,
310
  template: 'raw'
311
  },
@@ -383,6 +380,7 @@ jQuery(document).ready(function() {
383
  type: 'POST',
384
  data: {
385
  action: 'mycred-tools-import-export',
 
386
  request_tab: $requestTab,
387
  request: 'export',
388
  template: 'raw',
@@ -420,6 +418,7 @@ jQuery(document).ready(function() {
420
  type: 'POST',
421
  data: {
422
  action: 'mycred-tools-import-export',
 
423
  request_tab: $requestTab,
424
  request: 'export',
425
  template: 'formatted',
@@ -468,6 +467,7 @@ jQuery(document).ready(function() {
468
 
469
  var formData = new FormData();
470
  formData.append('action', 'mycred-tools-import-export');
 
471
  formData.append('request_tab', $requestTab);
472
  formData.append('import_format_type', $importFormatType);
473
  formData.append('request', 'import');
71
  data: function(params) {
72
  var query = {
73
  search: params.term,
74
+ token: mycredTools.token,
75
  action: 'mycred-tools-select-user'
76
  }
77
 
149
  type: 'POST',
150
  data: {
151
  action: 'mycred-tools-assign-award',
152
+ token: mycredTools.token,
153
  selected_type: $selectedType,
154
  points_to_award: $pointsToAward,
155
  point_type: $pointType,
168
  jQuery('.tools-bulk-assign-award-btn').find('span').css('display', 'inherit');
169
  },
170
  success: function(data) {
171
+
172
  jQuery('.tools-bulk-assign-award-btn').find('span').hide();
173
 
174
  if (data.success === true && $pointsToAward < 0) {
180
  if (data.success === true) {
181
  alert(mycredTools.successfullyAwarded);
182
  mycredToolsResetForm();
183
+ return;
184
  }
185
 
186
+ if ( mycredTools.hasOwnProperty( data.success ) )
187
+ alert( mycredTools[ data.success ] );
188
+
 
 
 
 
 
 
 
 
 
189
  }
190
  })
191
  });
206
  var $users = JSON.stringify(jQuery('[name="bulk_users"]').val());
207
  var $user_roles = JSON.stringify(jQuery('[name="bulk_roles"]').val());
208
 
 
209
  jQuery.ajax({
210
  url: ajaxurl,
211
  type: 'POST',
212
  data: {
213
  action: 'mycred-tools-assign-award',
214
+ token: mycredTools.token,
215
  selected_type: $selectedType,
216
  revoke: 'revoke',
217
  badges_to_revoke: $badgesToRevoke,
223
  jQuery('.tools-revoke-btn').find('span').css('display', 'inherit');
224
  },
225
  success: function(data) {
226
+
227
  jQuery('.tools-revoke-btn').find('span').hide();
228
 
229
  if (data.success === true) {
230
  alert(mycredTools.successfullyRevoked);
231
  mycredToolsResetForm();
232
+ return;
233
  }
234
+
235
+ if ( mycredTools.hasOwnProperty( data.success ) )
236
+ alert( mycredTools[ data.success ] );
237
+
 
 
238
  }
239
  });
240
  });
280
  type: 'POST',
281
  data: {
282
  action: 'mycred-tools-import-export',
283
+ token: mycredTools.token,
284
  request_tab: $requestTab,
285
  template: 'formatted'
286
  },
302
  type: 'POST',
303
  data: {
304
  action: 'mycred-tools-import-export',
305
+ token: mycredTools.token,
306
  request_tab: $requestTab,
307
  template: 'raw'
308
  },
380
  type: 'POST',
381
  data: {
382
  action: 'mycred-tools-import-export',
383
+ token: mycredTools.token,
384
  request_tab: $requestTab,
385
  request: 'export',
386
  template: 'raw',
418
  type: 'POST',
419
  data: {
420
  action: 'mycred-tools-import-export',
421
+ token: mycredTools.token,
422
  request_tab: $requestTab,
423
  request: 'export',
424
  template: 'formatted',
467
 
468
  var formData = new FormData();
469
  formData.append('action', 'mycred-tools-import-export');
470
+ formData.append('token', mycredTools.token);
471
  formData.append('request_tab', $requestTab);
472
  formData.append('import_format_type', $importFormatType);
473
  formData.append('request', 'import');
assets/js/mycred-type-management.js CHANGED
@@ -433,6 +433,7 @@ jQuery(function($) {
433
  data: function(params) {
434
  var query = {
435
  search: params.term,
 
436
  action: 'mycred-get-users-to-exclude'
437
  }
438
 
433
  data: function(params) {
434
  var query = {
435
  search: params.term,
436
+ token: myCREDmanage.token,
437
  action: 'mycred-get-users-to-exclude'
438
  }
439
 
assets/screenshot-5.png DELETED
Binary file
includes/classes/class.query-log.php CHANGED
@@ -2457,6 +2457,14 @@ if ( ! function_exists( 'mycred_get_all_references' ) ) :
2457
  $addons = apply_filters( 'mycred_buycred_refs', $addons );
2458
  }
2459
 
 
 
 
 
 
 
 
 
2460
  if ( class_exists( 'myCRED_Coupons_Module' ) )
2461
  $addons['coupon'] = __( 'Coupon Usage', 'mycred' );
2462
 
2457
  $addons = apply_filters( 'mycred_buycred_refs', $addons );
2458
  }
2459
 
2460
+ // added cashcred refernce in 2.2.4
2461
+ if ( class_exists( 'myCRED_cashCRED_Module' ) ) {
2462
+ $addons['fee_transfer'] = __( 'cashCred Fee Transfer', 'mycred' );
2463
+ $addons['cashcred_withdrawal_fee'] = __( 'cashCred Withdrawal Fee ', 'mycred' );
2464
+ $addons['cashcred_withdrawal'] = __( 'cashCred Withdrawal', 'mycred' );
2465
+ $addons = apply_filters( 'mycred_cashcred_refs', $addons );
2466
+ }
2467
+
2468
  if ( class_exists( 'myCRED_Coupons_Module' ) )
2469
  $addons['coupon'] = __( 'Coupon Usage', 'mycred' );
2470
 
includes/hooks/mycred-hook-referrals.php CHANGED
@@ -136,7 +136,7 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
136
  * @since 1.4
137
  * @version 1.1
138
  */
139
- public function shortcode_affiliate_link( $content = '', $atts ) {
140
 
141
  extract( shortcode_atts( array(
142
  'url' => 0,
@@ -164,7 +164,7 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
164
  * @since 1.4
165
  * @version 1.1
166
  */
167
- public function shortcode_affiliate_id( $content = '', $atts ) {
168
 
169
  extract( shortcode_atts( array(
170
  'user_id' => ''
@@ -345,34 +345,31 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
345
 
346
  if ( $this->ref_counts( $user_id, $IP, 'signup' ) ) {
347
 
348
-
349
  // Award when users account gets activated
350
  if ( function_exists( 'buddypress' ) ) {
351
- mycred_add_user_meta( $new_user_id, 'referred_by', '', $user_id, true );
352
- mycred_add_user_meta( $new_user_id, 'referred_by_IP', '', $IP, true );
353
- mycred_add_user_meta( $new_user_id, 'referred_by_type', '', $this->mycred_type, true );
354
- }
355
 
356
-
 
 
357
 
 
358
  // Award now
359
  else {
360
 
361
  $execute = apply_filters( 'mycred_signup_referral_execute_woo', true, $user_id, $IP, $new_user_id , $this );
362
 
 
363
 
364
- if ( $this->core->has_entry( 'signup_referral', $new_user_id, $user_id, $IP, $this->mycred_type ) ) return;
365
-
366
- if ( $execute === true ) {
367
- $this->core->add_creds(
368
- 'signup_referral',
369
- $user_id,
370
- $this->prefs['signup']['creds'],
371
- $this->prefs['signup']['log'],
372
- $new_user_id,
373
- $IP,
374
- $this->mycred_type
375
- );
376
 
377
  }
378
 
@@ -395,9 +392,9 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
395
  public function verified_signup( $user_id ) {
396
 
397
  // Check if there is a referral
398
- $referred_by = mycred_get_user_meta( $user_id, 'referred_by', '', true );
399
- $referred_by_IP = mycred_get_user_meta( $user_id, 'referred_by_IP', '', true );
400
- $referred_type = mycred_get_user_meta( $user_id, 'referred_by_type', '', true );
401
 
402
  if ( $referred_by == '' || $referred_by_IP == '' || $this->mycred_type != $referred_type ) return;
403
 
@@ -417,9 +414,9 @@ if ( ! class_exists( 'myCRED_Hook_Affiliate' ) ) :
417
  do_action( 'mycred_signup_referral', $referred_by, $referred_by_IP, $user_id, $this );
418
 
419
  // Clean up
420
- mycred_delete_user_meta( $user_id, 'referred_by' );
421
- mycred_delete_user_meta( $user_id, 'referred_by_IP' );
422
- mycred_delete_user_meta( $user_id, 'referred_by_type' );
423
 
424
  }
425
 
136
  * @since 1.4
137
  * @version 1.1
138
  */
139
+ public function shortcode_affiliate_link( $content, $atts ) {
140
 
141
  extract( shortcode_atts( array(
142
  'url' => 0,
164
  * @since 1.4
165
  * @version 1.1
166
  */
167
+ public function shortcode_affiliate_id( $content, $atts ) {
168
 
169
  extract( shortcode_atts( array(
170
  'user_id' => ''
345
 
346
  if ( $this->ref_counts( $user_id, $IP, 'signup' ) ) {
347
 
 
348
  // Award when users account gets activated
349
  if ( function_exists( 'buddypress' ) ) {
 
 
 
 
350
 
351
+ mycred_add_user_meta( $new_user_id, 'referred_by_', $this->mycred_type, $user_id, true );
352
+ mycred_add_user_meta( $new_user_id, 'referred_by_IP_', $this->mycred_type, $IP, true );
353
+ mycred_add_user_meta( $new_user_id, 'referred_by_type_', $this->mycred_type, $this->mycred_type, true );
354
 
355
+ }
356
  // Award now
357
  else {
358
 
359
  $execute = apply_filters( 'mycred_signup_referral_execute_woo', true, $user_id, $IP, $new_user_id , $this );
360
 
361
+ if ( $this->core->has_entry( 'signup_referral', $new_user_id, $user_id, $IP, $this->mycred_type ) ) return;
362
 
363
+ if ( $execute === true ) {
364
+ $this->core->add_creds(
365
+ 'signup_referral',
366
+ $user_id,
367
+ $this->prefs['signup']['creds'],
368
+ $this->prefs['signup']['log'],
369
+ $new_user_id,
370
+ $IP,
371
+ $this->mycred_type
372
+ );
 
 
373
 
374
  }
375
 
392
  public function verified_signup( $user_id ) {
393
 
394
  // Check if there is a referral
395
+ $referred_by = mycred_get_user_meta( $user_id, 'referred_by_', $this->mycred_type, true );
396
+ $referred_by_IP = mycred_get_user_meta( $user_id, 'referred_by_IP_', $this->mycred_type, true );
397
+ $referred_type = mycred_get_user_meta( $user_id, 'referred_by_type_', $this->mycred_type, true );
398
 
399
  if ( $referred_by == '' || $referred_by_IP == '' || $this->mycred_type != $referred_type ) return;
400
 
414
  do_action( 'mycred_signup_referral', $referred_by, $referred_by_IP, $user_id, $this );
415
 
416
  // Clean up
417
+ mycred_delete_user_meta( $user_id, 'referred_by_', $this->mycred_type );
418
+ mycred_delete_user_meta( $user_id, 'referred_by_IP_', $this->mycred_type );
419
+ mycred_delete_user_meta( $user_id, 'referred_by_type_', $this->mycred_type );
420
 
421
  }
422
 
includes/mycred-admin.php DELETED
@@ -1,788 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * myCRED_Admin class
6
- * Manages everything concerning the WordPress admin area.
7
- * @since 0.1
8
- * @version 1.2
9
- */
10
- if ( ! class_exists( 'myCRED_Admin' ) ) {
11
- class myCRED_Admin {
12
-
13
- public $core;
14
- public $using_bp = false;
15
-
16
- /**
17
- * Construct
18
- * @since 0.1
19
- * @version 1.0
20
- */
21
- function __construct( $settings = array() ) {
22
- $this->core = mycred();
23
- }
24
-
25
- /**
26
- * Load
27
- * @since 0.1
28
- * @version 1.2
29
- */
30
- public function load() {
31
- // Admin Styling
32
- add_action( 'admin_head', array( $this, 'admin_header' ) );
33
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
34
-
35
- // Custom Columns
36
- add_filter( 'manage_users_columns', array( $this, 'custom_user_column' ) );
37
- add_action( 'manage_users_custom_column', array( $this, 'custom_user_column_content' ), 10, 3 );
38
-
39
- // User Edit
40
- global $bp;
41
-
42
- // Check if BuddyPress is being used
43
- if ( is_object( $bp ) && isset( $bp->version ) && version_compare( $bp->version, '2.0', '>=' ) && bp_is_active( 'xprofile' ) )
44
- $this->using_bp = true;
45
-
46
- // Edit Profile
47
- if ( ! $this->using_bp )
48
- add_action( 'edit_user_profile', array( $this, 'user_nav' ) );
49
- else
50
- add_action( 'bp_members_admin_profile_nav', array( $this, 'bp_user_nav' ), 10, 2 );
51
-
52
- add_action( 'personal_options', array( $this, 'show_my_balance' ) );
53
- add_filter( 'mycred_admin_pages', array( $this, 'edit_profile_menu' ) );
54
- add_action( 'mycred_init', array( $this, 'edit_profile_actions' ) );
55
-
56
- // Sortable Column
57
- add_filter( 'manage_users_sortable_columns', array( $this, 'sortable_points_column' ) );
58
- add_action( 'pre_user_query', array( $this, 'sort_by_points' ) );
59
-
60
- // Inline Editing
61
- add_action( 'wp_ajax_mycred-inline-edit-users-balance', array( $this, 'inline_edit_user_balance' ) );
62
- add_action( 'in_admin_footer', array( $this, 'admin_footer' ) );
63
- }
64
-
65
- /**
66
- * Profile Actions
67
- * @since 1.5
68
- * @version 1.0
69
- */
70
- public function edit_profile_actions() {
71
-
72
- do_action( 'mycred_edit_profile_action' );
73
-
74
- // Update Balance
75
- if ( isset( $_POST['mycred_adjust_users_balance_run'] ) && isset( $_POST['mycred_adjust_users_balance'] ) ) {
76
-
77
- extract( $_POST['mycred_adjust_users_balance'] );
78
-
79
- if ( wp_verify_nonce( $token, 'mycred-adjust-balance' ) ) {
80
-
81
- $ctype = sanitize_key( $ctype );
82
- $mycred = mycred( $ctype );
83
-
84
- // Enforce requirement for log entry
85
- if ( $mycred->can_edit_creds() && ! $mycred->can_edit_plugin() && $log == '' ) {
86
- wp_safe_redirect( add_query_arg( array( 'result' => 'log_error' ) ) );
87
- exit;
88
- }
89
-
90
- // Make sure we can edit creds
91
- if ( $mycred->can_edit_creds() ) {
92
-
93
- // Prep
94
- $user_id = absint( $user_id );
95
- $amount = $mycred->number( $amount );
96
- $data = apply_filters( 'mycred_manual_change', array( 'ref_type' => 'user' ), $this );
97
-
98
- // Run
99
- $mycred->add_creds(
100
- 'manual',
101
- $user_id,
102
- $amount,
103
- $log,
104
- get_current_user_id(),
105
- $data,
106
- $ctype
107
- );
108
-
109
- wp_safe_redirect( add_query_arg( array( 'result' => 'balance_updated' ) ) );
110
- exit;
111
-
112
- }
113
-
114
- }
115
-
116
- }
117
-
118
- // Exclude
119
- elseif ( isset( $_GET['page'] ) && $_GET['page'] == 'mycred-edit-balance' && isset( $_GET['action'] ) && $_GET['action'] == 'exclude' ) {
120
-
121
- $ctype = sanitize_key( $_GET['ctype'] );
122
- $mycred = mycred( $ctype );
123
-
124
- // Make sure we can edit creds
125
- if ( $mycred->can_edit_creds() ) {
126
-
127
- // Make sure user is not already excluded
128
- $user_id = absint( $_GET['user_id'] );
129
- if ( ! $mycred->exclude_user( $user_id ) ) {
130
-
131
- // Get setttings
132
- $options = $mycred->core;
133
-
134
- // Get and clean up the exclude list
135
- $excludes = explode( ',', $options['exclude']['list'] );
136
- if ( ! empty( $excludes ) ) {
137
- $_excludes = array();
138
- foreach ( $excludes as $_user_id ) {
139
- $_user_id = sanitize_key( $_user_id );
140
- if ( $_user_id == '' ) continue;
141
- $_excludes[] = absint( $_user_id );
142
- }
143
- $excludes = $_excludes;
144
- }
145
-
146
- // If user ID is not yet in list
147
- if ( ! in_array( $user_id, $excludes ) ) {
148
- $excludes[] = $user_id;
149
- $options['exclude']['list'] = implode( ',', $excludes );
150
-
151
- $option_id = 'mycred_pref_core';
152
- if ( $ctype != 'mycred_default' )
153
- $option_id .= '_' . $ctype;
154
-
155
- mycred_update_option( $option_id, $options );
156
-
157
- // Remove Users balance
158
- mycred_delete_user_meta( $user_id, $ctype );
159
-
160
- global $wpdb;
161
-
162
- // Delete log entries
163
- $wpdb->delete(
164
- $mycred->log_table,
165
- array( 'user_id' => $user_id, 'ctype' => $ctype ),
166
- array( '%d', '%s' )
167
- );
168
-
169
- wp_safe_redirect( add_query_arg( array( 'user_id' => $user_id, 'result' => 'user_excluded' ), admin_url( 'user-edit.php' ) ) );
170
- exit;
171
- }
172
-
173
- }
174
-
175
- }
176
-
177
- }
178
-
179
- }
180
-
181
- /**
182
- * Admin Notices
183
- * @since 1.4
184
- * @version 1.1
185
- */
186
- public function admin_notices() {
187
-
188
- // Manual Adjustments
189
- if ( isset( $_GET['page'] ) && $_GET['page'] == 'mycred-edit-balance' && isset( $_GET['result'] ) ) {
190
-
191
- if ( $_GET['result'] == 'log_error' )
192
- echo '<div class="error"><p>' . __( 'A log entry is required in order to adjust this users balance', 'mycred' ) . '</p></div>';
193
- elseif ( $_GET['result'] == 'balance_updated' )
194
- echo '<div class="updated"><p>' . __( 'Users balance saved', 'mycred' ) . '</p></div>';
195
-
196
- }
197
-
198
- // Exclusions
199
- elseif ( isset( $_GET['user_id'] ) && isset( $_GET['result'] ) ) {
200
-
201
- if ( $_GET['result'] == 'user_excluded' )
202
- echo '<div class="updated"><p>' . __( 'Users excluded', 'mycred' ) . '</p></div>';
203
-
204
- }
205
-
206
- if ( get_option( 'mycred_buycred_reset', false ) !== false )
207
- echo '<div class="error"><p>' . __( 'All buyCRED Payment Gateways have been disabled! Please check your exchange rate settings and update all premium payment gateways!', 'mycred' ) . '</p></div>';
208
-
209
- do_action( 'mycred_admin_notices' );
210
-
211
- }
212
-
213
- /**
214
- * Ajax: Inline Edit Users Balance
215
- * @since 1.2
216
- * @version 1.1
217
- */
218
- public function inline_edit_user_balance() {
219
- // Security
220
- check_ajax_referer( 'mycred-update-users-balance', 'token' );
221
-
222
- // Check current user
223
- $current_user = get_current_user_id();
224
- if ( ! mycred_is_admin( $current_user ) )
225
- wp_send_json_error( 'ERROR_1' );
226
-
227
- // Type
228
- $type = sanitize_text_field( $_POST['type'] );
229
-
230
- $mycred = mycred( $type );
231
-
232
- // User
233
- $user_id = abs( $_POST['user'] );
234
- if ( $mycred->exclude_user( $user_id ) )
235
- wp_send_json_error( array( 'error' => 'ERROR_2', 'message' => __( 'User is excluded', 'mycred' ) ) );
236
-
237
- // Log entry
238
- $entry = trim( $_POST['entry'] );
239
- if ( $mycred->can_edit_creds() && ! $mycred->can_edit_plugin() && empty( $entry ) )
240
- wp_send_json_error( array( 'error' => 'ERROR_3', 'message' => __( 'Log Entry can not be empty', 'mycred' ) ) );
241
-
242
- // Amount
243
- if ( $_POST['amount'] == 0 || empty( $_POST['amount'] ) )
244
- wp_send_json_error( array( 'error' => 'ERROR_4', 'message' => __( 'Amount can not be zero', 'mycred' ) ) );
245
- else
246
- $amount = $mycred->number( $_POST['amount'] );
247
-
248
- // Data
249
- $data = apply_filters( 'mycred_manual_change', array( 'ref_type' => 'user' ), $this );
250
-
251
- // Execute
252
- $result = $mycred->add_creds(
253
- 'manual',
254
- $user_id,
255
- $amount,
256
- $entry,
257
- $current_user,
258
- $data,
259
- $type
260
- );
261
-
262
- if ( $result !== false )
263
- wp_send_json_success( $mycred->get_users_cred( $user_id, $type ) );
264
- else
265
- wp_send_json_error( array( 'error' => 'ERROR_5', 'message' => __( 'Failed to update this uses balance.', 'mycred' ) ) );
266
- }
267
-
268
- /**
269
- * Admin Header
270
- * @since 0.1
271
- * @version 1.3
272
- */
273
- public function admin_header() {
274
- global $wp_version;
275
-
276
- // Old navigation menu
277
- if ( version_compare( $wp_version, '3.8', '<' ) ) {
278
- $image = plugins_url( 'assets/images/logo-menu.png', myCRED_THIS ); ?>
279
-
280
- <!-- Support for pre 3.8 menus -->
281
- <style type="text/css">
282
- <?php foreach ( $mycred_types as $type => $label ) { if ( $mycred_type == 'mycred_default' ) $name = ''; else $name = '_' . $type; ?>
283
- #adminmenu .toplevel_page_myCRED<?php echo $name; ?> div.wp-menu-image { background-image: url(<?php echo $image; ?>); background-position: 1px -28px; }
284
- #adminmenu .toplevel_page_myCRED<?php echo $name; ?>:hover div.wp-menu-image,
285
- #adminmenu .toplevel_page_myCRED<?php echo $name; ?>.current div.wp-menu-image,
286
- #adminmenu .toplevel_page_myCRED<?php echo $name; ?> .wp-menu-open div.wp-menu-image { background-position: 1px 0; }
287
- <?php } ?>
288
- </style>
289
- <?php
290
- }
291
-
292
- $screen = get_current_screen();
293
- if ( $screen->id == 'users' ) {
294
- wp_enqueue_script( 'mycred-inline-edit' );
295
- wp_enqueue_style( 'mycred-inline-edit' );
296
- }
297
- }
298
-
299
- /**
300
- * Customize Users Column Headers
301
- * @since 0.1
302
- * @version 1.1
303
- */
304
- public function custom_user_column( $columns ) {
305
- global $mycred_types;
306
-
307
- if ( count( $mycred_types ) == 1 )
308
- $columns['mycred_default'] = $this->core->plural();
309
- else {
310
- foreach ( $mycred_types as $type => $label ) {
311
- if ( $type == 'mycred_default' ) $label = $this->core->plural();
312
- $columns[ $type ] = $label;
313
- }
314
- }
315
-
316
- return $columns;
317
- }
318
-
319
- /**
320
- * Sortable User Column
321
- * @since 1.2
322
- * @version 1.1
323
- */
324
- public function sortable_points_column( $columns ) {
325
- $mycred_types = mycred_get_types();
326
-
327
- if ( count( $mycred_types ) == 1 )
328
- $columns['mycred_default'] = 'mycred_default';
329
- else {
330
- foreach ( $mycred_types as $type => $label )
331
- $columns[ $type ] = $type;
332
- }
333
-
334
- return $columns;
335
- }
336
-
337
- /**
338
- * Sort by Points
339
- * @since 1.2
340
- * @version 1.3
341
- */
342
- public function sort_by_points( $query ) {
343
- if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || ! function_exists( 'get_current_screen' ) ) return;
344
- $screen = get_current_screen();
345
- if ( $screen === NULL || $screen->id != 'users' ) return;
346
-
347
- if ( isset( $query->query_vars['orderby'] ) ) {
348
- global $wpdb;
349
-
350
- $mycred_types = mycred_get_types();
351
- $cred_id = $query->query_vars['orderby'];
352
-
353
- $order = 'ASC';
354
- if ( isset( $query->query_vars['order'] ) )
355
- $order = $query->query_vars['order'];
356
-
357
- $mycred = $this->core;
358
- if ( isset( $_REQUEST['ctype'] ) && array_key_exists( $_REQUEST['ctype'], $mycred_types ) )
359
- $mycred = mycred( $_REQUEST['ctype'] );
360
-
361
- // Sort by only showing users with a particular point type
362
- if ( $cred_id == 'balance' ) {
363
-
364
- $amount = $mycred->zero();
365
- if ( isset( $_REQUEST['amount'] ) )
366
- $amount = $mycred->number( $_REQUEST['amount'] );
367
-
368
- $query->query_from .= "
369
- LEFT JOIN {$wpdb->usermeta}
370
- ON ({$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND {$wpdb->usermeta}.meta_key = '{$mycred->cred_id}')";
371
-
372
- $query->query_where .= " AND meta_value = {$amount}";
373
-
374
- }
375
-
376
- // Sort a particular point type
377
- elseif ( array_key_exists( $cred_id, $mycred_types ) ) {
378
-
379
- $query->query_from .= "
380
- LEFT JOIN {$wpdb->usermeta}
381
- ON ({$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND {$wpdb->usermeta}.meta_key = '{$cred_id}')";
382
-
383
- $query->query_orderby = "ORDER BY {$wpdb->usermeta}.meta_value+0 {$order} ";
384
-
385
- }
386
-
387
- }
388
- }
389
-
390
- /**
391
- * Customize User Columns Content
392
- * @filter 'mycred_user_row_actions'
393
- * @since 0.1
394
- * @version 1.3.2
395
- */
396
- public function custom_user_column_content( $value, $column_name, $user_id ) {
397
- global $mycred_types;
398
-
399
- if ( ! array_key_exists( $column_name, $mycred_types ) ) return $value;
400
-
401
- $mycred = mycred( $column_name );
402
-
403
- // User is excluded
404
- if ( $mycred->exclude_user( $user_id ) === true ) return __( 'Excluded', 'mycred' );
405
-
406
- $user = get_userdata( $user_id );
407
-
408
- // Show balance
409
- $ubalance = $mycred->get_users_cred( $user_id, $column_name );
410
- $balance = '<div id="mycred-user-' . $user_id . '-balance-' . $column_name . '">' . $mycred->before . ' <span>' . $mycred->format_number( $ubalance ) . '</span> ' . $mycred->after . '</div>';
411
-
412
- // Show total
413
- $total = mycred_query_users_total( $user_id, $column_name );
414
- $balance .= '<small style="display:block;">' . sprintf( __( 'Total: %s', 'mycred' ), $mycred->format_number( $total ) ) . '</small>';
415
-
416
- $page = 'myCRED';
417
- if ( $column_name != 'mycred_default' )
418
- $page .= '_' . $column_name;
419
-
420
- // Row actions
421
- $row = array();
422
- $row['history'] = '<a href="' . admin_url( 'admin.php?page=' . $page . '&user_id=' . $user_id ) . '">' . __( 'History', 'mycred' ) . '</a>';
423
- $row['adjust'] = '<a href="javascript:void(0)" class="mycred-open-points-editor" data-userid="' . $user_id . '" data-current="' . $ubalance . '" data-type="' . $column_name . '" data-username="' . $user->display_name . '">' . __( 'Adjust', 'mycred' ) . '</a>';
424
-
425
- $rows = apply_filters( 'mycred_user_row_actions', $row, $user_id, $mycred );
426
- $balance .= $this->row_actions( $rows );
427
-
428
- return $balance;
429
- }
430
-
431
- /**
432
- * User Row Actions
433
- * @since 1.5
434
- * @version 1.0
435
- */
436
- public function row_actions( $actions, $always_visible = false ) {
437
- $action_count = count( $actions );
438
- $i = 0;
439
-
440
- if ( !$action_count )
441
- return '';
442
-
443
- $out = '<div class="' . ( $always_visible ? 'row-actions-visible' : 'row-actions' ) . '">';
444
- foreach ( $actions as $action => $link ) {
445
- ++$i;
446
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
447
- $out .= "<span class='$action'>$link$sep</span>";
448
- }
449
- $out .= '</div>';
450
-
451
- return $out;
452
- }
453
-
454
- /**
455
- * Add Admin Page
456
- * @since 1.5
457
- * @version 1.0
458
- */
459
- public function edit_profile_menu( $pages = array() ) {
460
- $pages[] = add_users_page(
461
- __( 'Edit Balance', 'mycred' ),
462
- __( 'Edit Balance', 'mycred' ),
463
- 'read',
464
- 'mycred-edit-balance',
465
- array( $this, 'edit_profile_screen' )
466
- );
467
- return $pages;
468
- }
469
-
470
- /**
471
- * User Nav
472
- * @since 1.5
473
- * @version 1.0
474
- */
475
- public function user_nav( $user, $current = NULL ) {
476
- $types = mycred_get_types();
477
-
478
- $tabs = array();
479
- $tabs[] = array(
480
- 'label' => __( 'Profile', 'mycred' ),
481
- 'url' => add_query_arg( array( 'user_id' => $user->ID ), admin_url( 'user-edit.php' ) ),
482
- 'classes' => ( $current === NULL ) ? 'nav-tab nav-tab-active' : 'nav-tab'
483
- );
484
-
485
- if ( $this->using_bp )
486
- $tabs[] = array(
487
- 'label' => __( 'Extended Profile', 'mycred' ),
488
- 'url' => add_query_arg( array( 'page' => 'bp-profile-edit', 'user_id' => $user->ID ), admin_url( 'users.php' ) ),
489
- 'classes' => 'nav-tab'
490
- );
491
-
492
- foreach ( $types as $type => $label ) {
493
- $mycred = mycred( $type );
494
- if ( $mycred->exclude_user( $user->ID ) ) continue;
495
-
496
- $classes = 'nav-tab';
497
- if ( isset( $_GET['ctype'] ) && $_GET['ctype'] == $type ) $classes .= ' nav-tab-active';
498
-
499
- $tabs[] = array(
500
- 'label' => $mycred->plural(),
501
- 'url' => add_query_arg( array( 'page' => 'mycred-edit-balance', 'user_id' => $user->ID, 'ctype' => $type ), admin_url( 'users.php' ) ),
502
- 'classes' => $classes
503
- );
504
- }
505
-
506
- $tabs = apply_filters( 'mycred_edit_profile_tabs', $tabs, $user, false );
507
-
508
- ?>
509
- <style type="text/css">
510
- div#edit-balance-page.wrap form#your-profile, div#profile-page.wrap form#your-profile { position:relative; }
511
- div#edit-balance-page.wrap form#your-profile h3:first-of-type { margin-top:3em; }
512
- div#profile-page.wrap form#your-profile h3:first-of-type { margin-top:6em; }
513
- div#edit-balance-page.wrap form#your-profile ul#profile-nav { border-bottom:solid 1px #ccc; width:100%; }
514
- div#profile-page.wrap form#your-profile ul#profile-nav { position:absolute; top:-6em; border-bottom:solid 1px #ccc; width:100%; }
515
- div#edit-balance-page ul#profile-nav { border-bottom:solid 1px #ccc; width:100%; margin-top:1em; margin-bottom:1em; padding:1em 0; padding-bottom: 0; height:2.4em; }
516
- ul#profile-nav li { margin-left:0.4em; float:left;font-weight: bold;font-size: 15px;line-height: 24px;}
517
- ul#profile-nav li a {text-decoration: none;color:#888;}
518
- ul#profile-nav li a:hover, ul#profile-nav li.nav-tab-active a {text-decoration: none;color:#000; }
519
- </style>
520
- <ul id="profile-nav" class="nav-tab-wrapper">
521
-
522
- <?php foreach ( $tabs as $tab ) echo '<li class="' . $tab['classes'] . '"><a href="' . $tab['url'] . '">' . $tab['label'] . '</a></li>'; ?>
523
-
524
- </ul>
525
- <?php
526
- }
527
-
528
- /**
529
- * BuddyPress User Nav
530
- * @since 1.5
531
- * @version 1.0
532
- */
533
- public function bp_user_nav( $active, $user ) {
534
- $types = mycred_get_types();
535
-
536
- $tabs = array();
537
- foreach ( $types as $type => $label ) {
538
- $mycred = mycred( $type );
539
- if ( $mycred->exclude_user( $user->ID ) ) continue;
540
-
541
- $tabs[] = array(
542
- 'label' => $mycred->plural(),
543
- 'url' => add_query_arg( array( 'page' => 'mycred-edit-balance', 'user_id' => $user->ID, 'ctype' => $type ), admin_url( 'users.php' ) ),
544
- 'classes' => 'nav-tab'
545
- );
546
- }
547
-
548
- $tabs = apply_filters( 'mycred_edit_profile_tabs', $tabs, $user, true );
549
-
550
- if ( ! empty( $tabs ) )
551
- foreach ( $tabs as $tab ) echo '<li class="' . $tab['classes'] . '"><a href="' . $tab['url'] . '">' . $tab['label'] . '</a></li>';
552
- }
553
-
554
- /**
555
- * Edit Profile Screen
556
- * @since 1.5
557
- * @version 1.0
558
- */
559
- public function edit_profile_screen() {
560
- if ( ! isset( $_GET['user_id'] ) ) return;
561
-
562
- $user_id = absint( $_GET['user_id'] );
563
-
564
- if ( ! isset( $_GET['ctype'] ) )
565
- $type = 'mycred_default';
566
- else
567
- $type = sanitize_key( $_GET['ctype'] );
568
-
569
- $mycred = mycred( $type );
570
-
571
- // Security
572
- if ( ! $mycred->can_edit_creds() )
573
- wp_die( __( 'Access Denied', 'mycred' ) );
574
-
575
- // User is excluded
576
- if ( $mycred->exclude_user( $user_id ) )
577
- wp_die( sprintf( __( 'This user is excluded from using %s', 'mycred' ), mycred_label() ) );
578
-
579
- $user = get_userdata( $user_id );
580
- $balance = $mycred->get_users_balance( $user_id );
581
-
582
- if ( $type == 'mycred_default' )
583
- $log_slug = 'myCRED';
584
- else
585
- $log_slug = 'myCRED_' . $type;
586
-
587
- $history_url = add_query_arg( array( 'page' => $log_slug, 'user_id' => $user->ID ), admin_url( 'admin.php' ) );
588
- $exclude_url = add_query_arg( array( 'action' => 'exclude' ) ) ?>
589
-
590
- <style type="text/css">
591
- div#edit-balance-page table.table { width: 100%; margin-top: 24px; }
592
- div#edit-balance-page table.table th { text-align: left; }
593
- div#edit-balance-page table.table td { width: 33%; font-size: 24px; line-height: 48px; }
594
- div#edit-balance-page table tr td table tr td { vertical-align: top; }
595
- div#edit-balance-page table.form-table { border-top: 1px solid #ccc; }
596
- div#edit-balance-page.wrap form#your-profile h3 { margin-top: 3em; }
597
- </style>
598
- <div class="wrap" id="edit-balance-page">
599
- <h2><?php
600
- _e( 'Edit User', 'mycred' );
601
- if ( current_user_can( 'create_users' ) ) { ?>
602
- <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user', 'mycred' ); ?></a>
603
- <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
604
- <a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user', 'mycred' ); ?></a>
605
- <?php }
606
- ?></h2>
607
- <form id="your-profile" action="" method="post">
608
- <?php echo $this->user_nav( $user, $type ); ?>
609
-
610
- <div class="clear clearfix"></div>
611
- <table class="table">
612
- <thead>
613
- <tr>
614
- <th><?php _e( 'Current Balance', 'mycred' ); ?></th>
615
- <th><?php printf( __( 'Total %s Accumulated', 'mycred' ), $mycred->plural() ); ?></th>
616
- <th><?php printf( __( 'Total %s Spent', 'mycred' ), $mycred->plural() ); ?></th>
617
- </tr>
618
- </thead>
619
- <tbody>
620
- <tr>
621
- <td><?php echo $mycred->format_creds( $balance ); ?></td>
622
- <td><?php echo $mycred->format_creds( mycred_get_users_total( $user->ID, $type ) ); ?></td>
623
- <td><?php echo $mycred->format_creds( $this->get_users_total_spent( $user->ID, $type ) ); ?></td>
624
- </tr>
625
- </tbody>
626
- </table>
627
- <a href="<?php echo $history_url; ?>" class="button button-secondary"><?php _e( 'View History', 'mycred' ); ?></a>
628
- <a href="<?php echo $exclude_url; ?>" class="button button-primary" id="mycred-exclude-this-user"><?php _e( 'Exclude User', 'mycred' ); ?></a>
629
-
630
- <?php do_action( 'mycred_before_edit_profile', $user, $type ); ?>
631
-
632
- <h3><?php _e( 'Adjust Balance', 'mycred' ); ?></h3>
633
- <?php $this->adjust_users_balance( $user ); ?>
634
-
635
- <?php do_action( 'mycred_edit_profile', $user, $type ); ?>
636
-
637
- </form>
638
- <script type="text/javascript">
639
- jQuery(function($) {
640
- $( 'a#mycred-exclude-this-user' ).click(function(){
641
- if ( ! confirm( '<?php _e( 'Warning! Excluding this user will result in their balance being deleted along with any entries currently in your log! This can not be undone!', 'mycred' ); ?>' ) )
642
- return false;
643
- });
644
- });
645
- </script>
646
- </div>
647
- <?php
648
- }
649
-
650
- /**
651
- * Get Users Total Accumulated
652
- * @since 1.5
653
- * @version 1.0
654
- */
655
- public function get_users_total_accumulated( $user_id, $type ) {
656
- global $wpdb;
657
-
658
- return $wpdb->get_var( $wpdb->prepare( "
659
- SELECT SUM( creds )
660
- FROM {$this->core->log_table}
661
- WHERE ctype = %s
662
- AND user_id = %d
663
- AND creds > 0;", $type, $user_id ) );
664
- }
665
-
666
- /**
667
- * Get Users Total Spending
668
- * @since 1.5
669
- * @version 1.0
670
- */
671
- public function get_users_total_spent( $user_id, $type ) {
672
- global $wpdb;
673
-
674
- return $wpdb->get_var( $wpdb->prepare( "
675
- SELECT SUM( creds )
676
- FROM {$this->core->log_table}
677
- WHERE ctype = %s
678
- AND user_id = %d
679
- AND creds < 0;", $type, $user_id ) );
680
- }
681
-
682
- /**
683
- * Insert Ballance into Profile
684
- * @since 0.1
685
- * @version 1.1
686
- */
687
- public function show_my_balance( $user ) {
688
- $user_id = $user->ID;
689
- $mycred_types = mycred_get_types();
690
-
691
- foreach ( $mycred_types as $type => $label ) {
692
- $mycred = mycred( $type );
693
- if ( $mycred->exclude_user( $user_id ) ) continue;
694
-
695
- $balance = $mycred->get_users_cred( $user_id, $type );
696
- $balance = $mycred->format_creds( $balance ); ?>
697
-
698
- <tr>
699
- <th scope="row"><?php echo $mycred->template_tags_general( __( '%singular% balance', 'mycred' ) ); ?></th>
700
- <td><h2 style="margin:0;padding:0;"><?php echo $balance; ?></h2></td>
701
- </tr>
702
- <?php
703
- }
704
- }
705
-
706
- /**
707
- * Adjust Users Balance
708
- * @since 0.1
709
- * @version 1.2
710
- */
711
- public function adjust_users_balance( $user ) {
712
- if ( ! isset( $_GET['ctype'] ) )
713
- $type = 'mycred_default';
714
- else
715
- $type = sanitize_key( $_GET['ctype'] );
716
-
717
- $mycred = mycred( $type );
718
-
719
- if ( $mycred->can_edit_creds() && ! $mycred->can_edit_plugin() )
720
- $req = '(<strong>' . __( 'required', 'mycred' ) . '</strong>)';
721
- else
722
- $req = '(' . __( 'optional', 'mycred' ) . ')'; ?>
723
-
724
- <table class="form-table">
725
- <tr>
726
- <th scope="row"><label for="myCRED-manual-add-points"><?php _e( 'Amount', 'mycred' ) ?></label></th>
727
- <td id="myCRED-adjust-users-points">
728
- <input type="text" name="mycred_adjust_users_balance[amount]" id="myCRED-manual-add-points" value="<?php echo $mycred->zero(); ?>" size="8" />
729
- <input type="hidden" name="mycred_adjust_users_balance[ctype]" value="<?php echo $type; ?>" />
730
- <input type="hidden" name="mycred_adjust_users_balance[user_id]" value="<?php echo $user->ID; ?>" />
731
- <input type="hidden" name="mycred_adjust_users_balance[token]" value="<?php echo wp_create_nonce( 'mycred-adjust-balance' ); ?>" />
732
- </td>
733
- </tr>
734
- <tr>
735
- <th scope="row"><label for="myCRED-manual-add-description"><?php _e( 'Log Entry', 'mycred' ); ?> <?php echo $req; ?></label></th>
736
- <td>
737
- <input type="text" name="mycred_adjust_users_balance[log]" id="myCRED-manual-add-description" value="" class="regular-text" /><br />
738
- <span class="description"><?php echo $mycred->available_template_tags( array( 'general' ) ); ?></span><br /><br />
739
- <?php submit_button( __( 'Update Balance', 'mycred' ), 'primary medium', 'mycred_adjust_users_balance_run', false ); ?>
740
- </td>
741
- </tr>
742
- </table>
743
- <?php
744
- }
745
-
746
- /**
747
- * Admin Footer
748
- * Inserts the Inline Edit Form modal.
749
- * @since 1.2
750
- * @version 1.2
751
- */
752
- public function admin_footer() {
753
- $screen = get_current_screen();
754
- if ( $screen->id != 'users' ) return;
755
-
756
- if ( $this->core->can_edit_creds() && ! $this->core->can_edit_plugin() )
757
- $req = '(<strong>' . __( 'required', 'mycred' ) . '</strong>)';
758
- else
759
- $req = '(' . __( 'optional', 'mycred' ) . ')';
760
-
761
- ob_start(); ?>
762
-
763
- <div id="edit-mycred-balance" style="display: none;">
764
- <div class="mycred-adjustment-form">
765
- <p class="row inline" style="width: 20%"><label><?php _e( 'ID', 'mycred' ); ?>:</label><span id="mycred-userid"></span></p>
766
- <p class="row inline" style="width: 40%"><label><?php _e( 'User', 'mycred' ); ?>:</label><span id="mycred-username"></span></p>
767
- <p class="row inline" style="width: 40%"><label><?php _e( 'Current Balance', 'mycred' ); ?>:</label> <span id="mycred-current"></span></p>
768
- <div class="clear"></div>
769
- <input type="hidden" name="mycred_update_users_balance[token]" id="mycred-update-users-balance-token" value="<?php echo wp_create_nonce( 'mycred-update-users-balance' ); ?>" />
770
- <input type="hidden" name="mycred_update_users_balance[type]" id="mycred-update-users-balance-type" value="" />
771
- <p class="row"><label for="mycred-update-users-balance-amount"><?php _e( 'Amount', 'mycred' ); ?>:</label><input type="text" name="mycred_update_users_balance[amount]" id="mycred-update-users-balance-amount" value="" /><br /><span class="description"><?php _e( 'A positive or negative value', 'mycred' ); ?>.</span></p>
772
- <p class="row"><label for="mycred-update-users-balance-entry"><?php _e( 'Log Entry', 'mycred' ); ?>:</label><input type="text" name="mycred_update_users_balance[entry]" id="mycred-update-users-balance-entry" value="" /><br /><span class="description"><?php echo $req; ?></span></p>
773
- <p class="row"><input type="button" name="mycred-update-users-balance-submit" id="mycred-update-users-balance-submit" value="<?php _e( 'Update Balance', 'mycred' ); ?>" class="button button-primary button-large" /></p>
774
- <div class="clear"></div>
775
- </div>
776
- <div class="clear"></div>
777
- </div>
778
- <?php
779
-
780
- $content = ob_get_contents();
781
- ob_end_clean();
782
-
783
- echo apply_filters( 'mycred_admin_inline_editor', $content );
784
-
785
- }
786
- }
787
- }
788
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mycred-blocks/blocks/mycred-affiliate-id/index.js CHANGED
@@ -8,6 +8,7 @@
8
  var InspectorControls = wp.editor.InspectorControls;
9
  var el = wp.element.createElement;
10
  var SelectControl = wp.components.SelectControl;
 
11
  var __ = wp.i18n.__;
12
 
13
  registerBlockType('mycred-gb-blocks/mycred-affiliate-id', {
@@ -33,9 +34,9 @@
33
  }
34
 
35
  return el('div', {}, [
36
- el('p', {}, __('Affiliate ID Shortcode', 'mycred')
37
- ),
38
  el(InspectorControls, null,
 
39
  el(SelectControl, {
40
  label: __('Point Types', 'mycred'),
41
  help: __('The point type you want to show the affiliate link for.', 'mycred'),
@@ -43,7 +44,8 @@
43
  onChange: setPtType,
44
  options
45
  }),
46
- )
 
47
  ]);
48
  },
49
  save: function (props) {
8
  var InspectorControls = wp.editor.InspectorControls;
9
  var el = wp.element.createElement;
10
  var SelectControl = wp.components.SelectControl;
11
+ var panelBody = wp.components.PanelBody;
12
  var __ = wp.i18n.__;
13
 
14
  registerBlockType('mycred-gb-blocks/mycred-affiliate-id', {
34
  }
35
 
36
  return el('div', {}, [
37
+ el('p', {}, __('Affiliate ID Shortcode', 'mycred') ),
 
38
  el(InspectorControls, null,
39
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
40
  el(SelectControl, {
41
  label: __('Point Types', 'mycred'),
42
  help: __('The point type you want to show the affiliate link for.', 'mycred'),
44
  onChange: setPtType,
45
  options
46
  }),
47
+ )
48
+ )
49
  ]);
50
  },
51
  save: function (props) {
includes/mycred-blocks/blocks/mycred-affiliate-link/index.js CHANGED
@@ -9,6 +9,7 @@
9
  var el = wp.element.createElement;
10
  var SelectControl = wp.components.SelectControl;
11
  var TextControl = wp.components.TextControl;
 
12
  var __ = wp.i18n.__;
13
 
14
  registerBlockType('mycred-gb-blocks/mycred-affiliate-link', {
@@ -39,9 +40,9 @@
39
  props.setAttributes({url: value});
40
  }
41
  return el('div', {}, [
42
- el('p', {}, __('Affiliate Link Shortcode', 'mycred')
43
- ),
44
  el(InspectorControls, null,
 
45
  el(SelectControl, {
46
  label: __('Point Types', 'mycred'),
47
  help: __('The point type you want to show the affiliate link for.', 'mycred'),
@@ -56,8 +57,9 @@
56
  value: url,
57
  onChange: setUrl
58
 
59
- })
60
- )
 
61
  ]);
62
  },
63
  save: function (props) {
9
  var el = wp.element.createElement;
10
  var SelectControl = wp.components.SelectControl;
11
  var TextControl = wp.components.TextControl;
12
+ var panelBody = wp.components.PanelBody;
13
  var __ = wp.i18n.__;
14
 
15
  registerBlockType('mycred-gb-blocks/mycred-affiliate-link', {
40
  props.setAttributes({url: value});
41
  }
42
  return el('div', {}, [
43
+ el('p', {}, __('Affiliate Link Shortcode', 'mycred') ),
 
44
  el(InspectorControls, null,
45
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
46
  el(SelectControl, {
47
  label: __('Point Types', 'mycred'),
48
  help: __('The point type you want to show the affiliate link for.', 'mycred'),
57
  value: url,
58
  onChange: setUrl
59
 
60
+ }),
61
+ )
62
+ )
63
  ]);
64
  },
65
  save: function (props) {
includes/mycred-blocks/blocks/mycred-badges-list/index.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+
8
+ var __ = wp.i18n.__;
9
+ registerBlockType('mycred-gb-blocks/mycred-badges-list', {
10
+ title: __('Badges List', 'mycred'),
11
+ category: 'mycred',
12
+ attributes: {
13
+ achievement_tabs : {
14
+ type: 'string',
15
+ default: 1
16
+ }
17
+ },
18
+ edit: function (props) {
19
+ var achievement_tabs = props.attributes.achievement_tabs;
20
+
21
+ function setAchievement_tabs(value) {
22
+ props.setAttributes({achievement_tabs: value});
23
+ }
24
+
25
+
26
+ return el('div', {}, [
27
+ el('p', {}, __('Badges List Shortcode', 'mycred') ),
28
+ el(InspectorControls, null,
29
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
30
+ el(TextControl, {
31
+ label: __('Achievement Tabs', 'mycred'),
32
+ help: __(' Use (1) to enable or (0) to disable the achievement tabs.', 'mycred'),
33
+ value: achievement_tabs,
34
+ onChange: setAchievement_tabs
35
+
36
+ }),
37
+ )
38
+ )
39
+ ]);
40
+ },
41
+ save: function (props) {
42
+ return null;
43
+ }
44
+ });
45
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-badges-list/mycred-badges-list.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_badges_list_block') ) :
7
+ class mycred_badges_list_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-badges-list',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-badges-list',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_badges_list " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_badges_list_block();
includes/mycred-blocks/blocks/mycred-badges/index.js CHANGED
@@ -3,6 +3,7 @@
3
  var InspectorControls = wp.editor.InspectorControls;
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
 
6
 
7
  var __ = wp.i18n.__;
8
  registerBlockType('mycred-gb-blocks/mycred-badges', {
@@ -32,9 +33,9 @@
32
 
33
 
34
  return el('div', {}, [
35
- el('p', {}, __('Badges Shortcode', 'mycred')
36
- ),
37
  el(InspectorControls, null,
 
38
  el(TextControl, {
39
  label: __('Width', 'mycred'),
40
  help: __('The badge image width to use.', 'mycred'),
@@ -47,8 +48,9 @@
47
  help: __('The badge image height to use.', 'mycred'),
48
  value: height,
49
  onChange: setHeight
50
- })
51
- )
 
52
  ]);
53
  },
54
  save: function (props) {
3
  var InspectorControls = wp.editor.InspectorControls;
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-badges', {
33
 
34
 
35
  return el('div', {}, [
36
+ el('p', {}, __('Badges Shortcode', 'mycred') ),
 
37
  el(InspectorControls, null,
38
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
39
  el(TextControl, {
40
  label: __('Width', 'mycred'),
41
  help: __('The badge image width to use.', 'mycred'),
48
  help: __('The badge image height to use.', 'mycred'),
49
  value: height,
50
  onChange: setHeight
51
+ }),
52
+ )
53
+ )
54
  ]);
55
  },
56
  save: function (props) {
includes/mycred-blocks/blocks/mycred-best-user/index.js CHANGED
@@ -10,7 +10,7 @@
10
  var TextControl = wp.components.TextControl;
11
  var TextareaControl = wp.components.TextareaControl;
12
  var RichText = wp.editor.RichText;
13
-
14
  var __ = wp.i18n.__;
15
 
16
 
@@ -83,9 +83,9 @@
83
  }
84
 
85
  return el('div', {}, [
86
- el('p', {}, __('Best User Shortcode', 'mycred')
87
- ),
88
  el(InspectorControls, null,
 
89
  el(TextareaControl, {
90
  label: __('Reference(s)', 'mycred'),
91
  help: __('Comma separated list of references to add up.', 'mycred'),
@@ -140,8 +140,9 @@
140
  value: content,
141
  onChange: setContent,
142
  rows:2
143
- })
144
- )
 
145
  ]);
146
  },
147
  save: function (props) {
10
  var TextControl = wp.components.TextControl;
11
  var TextareaControl = wp.components.TextareaControl;
12
  var RichText = wp.editor.RichText;
13
+ var panelBody = wp.components.PanelBody;
14
  var __ = wp.i18n.__;
15
 
16
 
83
  }
84
 
85
  return el('div', {}, [
86
+ el('p', {}, __('Best User Shortcode', 'mycred') ),
 
87
  el(InspectorControls, null,
88
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
89
  el(TextareaControl, {
90
  label: __('Reference(s)', 'mycred'),
91
  help: __('Comma separated list of references to add up.', 'mycred'),
140
  value: content,
141
  onChange: setContent,
142
  rows:2
143
+ }),
144
+ )
145
+ )
146
  ]);
147
  },
148
  save: function (props) {
includes/mycred-blocks/blocks/mycred-buy-form/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-buy-form', {
10
  title: __('Buy Form', 'mycred'),
@@ -77,9 +78,9 @@
77
  });
78
  });
79
  return el('div', {}, [
80
- el('p', {}, __('Buy Form Shortcode', 'mycred')
81
- ),
82
- el(InspectorControls, null,
83
  el(TextControl, {
84
  label: __('Button Label', 'mycred'),
85
  help: __('The label for the form submit button.', 'mycred'),
@@ -122,7 +123,8 @@
122
  checked: inline,
123
  onChange: setInline
124
  }),
125
- )
 
126
  ]);
127
  },
128
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-buy-form', {
11
  title: __('Buy Form', 'mycred'),
78
  });
79
  });
80
  return el('div', {}, [
81
+ el( 'p', {}, __('Buy Form Shortcode', 'mycred') ),
82
+ el( InspectorControls, null,
83
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
84
  el(TextControl, {
85
  label: __('Button Label', 'mycred'),
86
  help: __('The label for the form submit button.', 'mycred'),
123
  checked: inline,
124
  onChange: setInline
125
  }),
126
+ )
127
+ )
128
  ]);
129
  },
130
  save: function (props) {
includes/mycred-blocks/blocks/mycred-buy-pending/index.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+
8
+ var __ = wp.i18n.__;
9
+ registerBlockType('mycred-gb-blocks/mycred-buy-pending', {
10
+ title: __('Buy Pending', 'mycred'),
11
+ category: 'mycred',
12
+ attributes: {
13
+ ctype : {
14
+ type: 'string',
15
+ },
16
+ pay_now : {
17
+ type: 'string',
18
+ default: 'Pay Now'
19
+ },
20
+ cancel : {
21
+ type: 'string',
22
+ default: 'Cancel'
23
+ }
24
+ },
25
+ edit: function (props) {
26
+ var ctype = props.attributes.ctype;
27
+ var pay_now = props.attributes.pay_now;
28
+ var cancel = props.attributes.cancel;
29
+
30
+ function setTypes(value) {
31
+ props.setAttributes({ctype: value});
32
+ }
33
+
34
+ function setPayNow(value) {
35
+ props.setAttributes({pay_now: value});
36
+ }
37
+
38
+ function setCancel(value) {
39
+ props.setAttributes({cancel: value});
40
+ }
41
+
42
+
43
+ return el('div', {}, [
44
+ el('p', {}, __('Buy Pending Shortcode', 'mycred') ),
45
+ el(InspectorControls, null,
46
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
47
+ el(TextControl, {
48
+ label: __('Point Type', 'mycred'),
49
+ help: __('Set to empty if you sell multiple point types and want to show all of them in one table. Should not be used if you only sell one point type.', 'mycred'),
50
+ value: ctype,
51
+ onChange: setTypes
52
+
53
+ }),
54
+ el(TextControl, {
55
+ label: __('Pay Now label', 'mycred'),
56
+ help: __('The label to use for the "Pay Now" action.', 'mycred'),
57
+ value: pay_now,
58
+ onChange: setPayNow
59
+
60
+ }),
61
+ el(TextControl, {
62
+ label: __('Cancel label', 'mycred'),
63
+ help: __('The label to use for the "Cancel" action.', 'mycred'),
64
+ value: cancel,
65
+ onChange: setCancel
66
+
67
+ }),
68
+ )
69
+ )
70
+ ]);
71
+ },
72
+ save: function (props) {
73
+ return null;
74
+ }
75
+ });
76
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-buy-pending/mycred-buy-pending.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_buy_pending_block') ) :
7
+ class mycred_buy_pending_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-buy-pending',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-buy-pending',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_buy_pending " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_buy_pending_block();
includes/mycred-blocks/blocks/mycred-buy/index.js CHANGED
@@ -4,7 +4,7 @@
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
-
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-buy', {
10
  title: __('Buy', 'mycred'),
@@ -85,9 +85,9 @@
85
  });
86
  });
87
  return el('div', {}, [
88
- el('p', {}, __('Buy Shortcode', 'mycred')
89
- ),
90
  el(InspectorControls, null,
 
91
  el(TextControl, {
92
  label: __('Link Title', 'mycred'),
93
  help: __('The purchase link title. If not set, the anchor element will be rendered but will be empty. Only leave this entry if you intend to style the element and need this to be empty!', 'mycred'),
@@ -132,7 +132,8 @@
132
  value: login,
133
  onChange: setLogin
134
  }),
135
- )
 
136
  ]);
137
  },
138
  save: function (props) {
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
+ var panelBody = wp.components.PanelBody;
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-buy', {
10
  title: __('Buy', 'mycred'),
85
  });
86
  });
87
  return el('div', {}, [
88
+ el('p', {}, __('Buy Shortcode', 'mycred') ),
 
89
  el(InspectorControls, null,
90
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
91
  el(TextControl, {
92
  label: __('Link Title', 'mycred'),
93
  help: __('The purchase link title. If not set, the anchor element will be rendered but will be empty. Only leave this entry if you intend to style the element and need this to be empty!', 'mycred'),
132
  value: login,
133
  onChange: setLogin
134
  }),
135
+ )
136
+ )
137
  ]);
138
  },
139
  save: function (props) {
includes/mycred-blocks/blocks/mycred-cashcred/index.js ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var SelectControl = wp.components.SelectControl;
7
+ var panelBody = wp.components.PanelBody;
8
+ var __ = wp.i18n.__;
9
+ registerBlockType('mycred-gb-blocks/mycred-cashcred', {
10
+ title: __('Cashcred', 'mycred'),
11
+ category: 'mycred',
12
+ attributes: {
13
+ button: {
14
+ type: 'string',
15
+ default: 'Submit Request'
16
+ },
17
+ gateways: {
18
+ type: 'array'
19
+ },
20
+ types: {
21
+ type: 'array'
22
+ },
23
+ excluded: {
24
+ type: 'string',
25
+ default: 'You have excluded from this point type'
26
+ },
27
+ insufficient: {
28
+ type: 'string',
29
+ default: 'Insufficient Points for Withdrawal.'
30
+ },
31
+
32
+ },
33
+ edit: function (props) {
34
+ var button = props.attributes.button;
35
+ var gateways = props.attributes.gateways;
36
+ var types = props.attributes.types;
37
+ var excluded = props.attributes.excluded;
38
+ var insufficient = props.attributes.insufficient;
39
+ var options = [];
40
+ var gateway_options = [];
41
+
42
+ function setGateways(value) {
43
+ props.setAttributes({gateways: value});
44
+ }
45
+
46
+ function setButton(value) {
47
+ props.setAttributes({button: value});
48
+ }
49
+
50
+ function setTypes(value) {
51
+ props.setAttributes({types: value});
52
+ }
53
+ function setExclude(value) {
54
+ props.setAttributes({excluded: value});
55
+ }
56
+ function setInsufficient(value) {
57
+ props.setAttributes({insufficient: value});
58
+ }
59
+
60
+ Object.keys(mycred_types).forEach(function (key) {
61
+ options.push({
62
+ label: mycred_types[key],
63
+ value: key
64
+ });
65
+ });
66
+
67
+ console.log(mycred_cashcred_gateways);
68
+
69
+ Object.keys(mycred_cashcred_gateways).forEach(function (key) {
70
+ gateway_options.push({
71
+ label: mycred_cashcred_gateways[key],
72
+ value: key
73
+ });
74
+ });
75
+
76
+ return el('div', {}, [
77
+ el('p', {}, __('Cashcred Shortcode', 'mycred') ),
78
+ el(InspectorControls, null,
79
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
80
+ el(TextControl, {
81
+ label: __('Button Label', 'mycred'),
82
+ help: __('The label for the form submit button.', 'mycred'),
83
+ value: button,
84
+ onChange: setButton
85
+ }),
86
+ el(SelectControl, {
87
+ multiple: true,
88
+ label: __('Gateways', 'mycred'),
89
+ help: __('Select the Gateways to enforce the use of a specific gateways', 'mycred'),
90
+ value: gateways,
91
+ onChange: setGateways,
92
+ options: gateway_options,
93
+ style: { height:"100px" }
94
+ }),
95
+ el(SelectControl, {
96
+ multiple: true,
97
+ label: __('Point Types', 'mycred'),
98
+ help: __('The point type you want to show.', 'mycred'),
99
+ value: types,
100
+ onChange: setTypes,
101
+ options: options,
102
+ style: { height:"100px" }
103
+ }),
104
+ el(TextControl, {
105
+ label: __('Excluded Message', 'mycred'),
106
+ help: __('By default, the current user will see this msg "You have excluded from this point type.."', 'mycred'),
107
+ value: excluded,
108
+ onChange: setExclude
109
+ }),
110
+ el(TextControl, {
111
+ label: __('Insufficient Message', 'mycred'),
112
+ help: __('By default, the current user will see this msg "Insufficient Points for Withdrawal."', 'mycred'),
113
+ value: insufficient,
114
+ onChange: setInsufficient
115
+ }),
116
+ )
117
+ )
118
+ ]);
119
+ },
120
+ save: function (props) {
121
+ return null;
122
+ }
123
+ });
124
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-cashcred/mycred-cashcred.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_cashcred_block') ) :
7
+ class mycred_cashcred_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-cashcred',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ $mycred_cashcred_gateways = array( '' => __( 'Select Gateways', 'mycred' ) );
23
+
24
+ foreach( cashcred_get_usable_gateways( array() ) as $id => $gateway ) {
25
+
26
+ $mycred_cashcred_gateways[ $id ] = $gateway['title'];
27
+
28
+ }
29
+
30
+ wp_enqueue_script(
31
+ 'mycred-cashcred',
32
+ plugins_url('index.js', __FILE__),
33
+ array(
34
+ 'wp-blocks',
35
+ 'wp-element',
36
+ 'wp-components',
37
+ 'wp-editor'
38
+ )
39
+ );
40
+
41
+ wp_localize_script( 'mycred-cashcred', 'mycred_cashcred_gateways', $mycred_cashcred_gateways );
42
+
43
+ }
44
+
45
+ public function render_block( $attributes, $content ) {
46
+
47
+ if ( ! empty( $attributes['types'] ) && is_array( $attributes['types'] ) )
48
+ $attributes['types'] = implode( ',', $attributes['types'] );
49
+
50
+ if ( ! empty( $attributes['gateways'] ) && is_array( $attributes['gateways'] ) )
51
+ $attributes['gateways'] = implode( ',', $attributes['gateways'] );
52
+
53
+ return "[mycred_cashcred " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
54
+
55
+ }
56
+
57
+ }
58
+ endif;
59
+
60
+ new mycred_cashcred_block();
includes/mycred-blocks/blocks/mycred-chart-balance-history/index.js ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+ var __ = wp.i18n.__;
8
+ registerBlockType('mycred-gb-blocks/mycred-balance-history', {
9
+ title: __('Chart Balance History', 'mycred'),
10
+ category: 'mycred',
11
+ attributes: {
12
+ type : {
13
+ type: 'string',
14
+ default: 'line'
15
+ },
16
+ ctype : {
17
+ type: 'string',
18
+ default: 'mycred_default'
19
+ },
20
+ user : {
21
+ type: 'string',
22
+ },
23
+ period : {
24
+ type: 'string',
25
+ default: 'days'
26
+ },
27
+ number : {
28
+ type: 'string',
29
+ default: '10'
30
+ },
31
+ order : {
32
+ type: 'string',
33
+ default: 'DESC'
34
+ },
35
+ title : {
36
+ type: 'string',
37
+ },
38
+ animate : {
39
+ type: 'string',
40
+ default: '1'
41
+ },
42
+ bezier : {
43
+ type: 'string',
44
+ default: '1'
45
+ },
46
+ labels : {
47
+ type: 'string',
48
+ default: '1'
49
+ },
50
+ legend : {
51
+ type: 'string',
52
+ default: '1'
53
+ },
54
+ width : {
55
+ type: 'string'
56
+ },
57
+ height : {
58
+ type: 'string'
59
+ }
60
+ },
61
+ edit: function (props) {
62
+ var type = props.attributes.type;
63
+ var ctype = props.attributes.ctype;
64
+ var user = props.attributes.user;
65
+ var period = props.attributes.period;
66
+ var number = props.attributes.number;
67
+ var order = props.attributes.order;
68
+ var title = props.attributes.title;
69
+ var animate = props.attributes.animate;
70
+ var bezier = props.attributes.bezier;
71
+ var labels = props.attributes.labels;
72
+ var legend = props.attributes.legend;
73
+ var width = props.attributes.width;
74
+ var height = props.attributes.height;
75
+
76
+ function setTypes(value) {
77
+ props.setAttributes({type: value});
78
+ }
79
+
80
+ function setPtypes(value) {
81
+ props.setAttributes({ctype: value});
82
+ }
83
+
84
+ function setUser(value) {
85
+ props.setAttributes({user: value});
86
+ }
87
+
88
+ function setPeriod(value) {
89
+ props.setAttributes({period: value});
90
+ }
91
+
92
+ function setNumber(value) {
93
+ props.setAttributes({number: value});
94
+ }
95
+
96
+ function setOrder(value) {
97
+ props.setAttributes({order: value});
98
+ }
99
+
100
+ function setTitle(value) {
101
+ props.setAttributes({title: value});
102
+ }
103
+
104
+ function setAnimate(value) {
105
+ props.setAttributes({animate: value});
106
+ }
107
+
108
+ function setBezier(value) {
109
+ props.setAttributes({bezier: value});
110
+ }
111
+
112
+ function setLabels(value) {
113
+ props.setAttributes({labels: value});
114
+ }
115
+
116
+ function setLegend(value) {
117
+ props.setAttributes({legend: value});
118
+ }
119
+
120
+ function setWidth(value) {
121
+ props.setAttributes({width: value});
122
+ }
123
+
124
+ function setHeight(value) {
125
+ props.setAttributes({height: value});
126
+ }
127
+
128
+ return el('div', {}, [
129
+ el('p', {}, __('Chart Balance History Shortcode', 'mycred')
130
+ ),
131
+ el(InspectorControls, null,
132
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
133
+ el(TextControl, {
134
+ label: __('Type', 'mycred'),
135
+ help: __('The chart type to render. Supports: "line" and "bar".', 'mycred'),
136
+ value: type,
137
+ onChange: setTypes
138
+
139
+ }),
140
+ el(TextControl, {
141
+ label: __('Point Type', 'mycred'),
142
+ help: __('The point type we want to show data for. Should only be used when you need to show data for a custom point type.', 'mycred'),
143
+ value: ctype,
144
+ onChange: setPtypes
145
+
146
+ }),
147
+ el(TextControl, {
148
+ label: __('User', 'mycred'),
149
+ help: __("The user whom's history we want to show. Accepts either a numeric user ID or the keyword current to show the current users history.", 'mycred'),
150
+ value: user,
151
+ onChange: setUser
152
+
153
+ }),
154
+ el(TextControl, {
155
+ label: __('Period', 'mycred'),
156
+ help: __('The type of periods we want to use. Accepts days, weeks, months and years.', 'mycred'),
157
+ value: period,
158
+ onChange: setPeriod
159
+
160
+ }),
161
+ el(TextControl, {
162
+ label: __('Number', 'mycred'),
163
+ help: __('The number of periods to show in the chart e.g. 10 days or 12 months.', 'mycred'),
164
+ value: number,
165
+ onChange: setNumber
166
+
167
+ }),
168
+ el(TextControl, {
169
+ label: __('Order', 'mycred'),
170
+ help: __('The order of which the periods should be sorted.', 'mycred'),
171
+ value: order,
172
+ onChange: setOrder
173
+
174
+ }),
175
+ el(TextControl, {
176
+ label: __('Title', 'mycred'),
177
+ help: __('To set a title for the chart.', 'mycred'),
178
+ value: title,
179
+ onChange: setTitle
180
+
181
+ }),
182
+ el(TextControl, {
183
+ label: __('Animate', 'mycred'),
184
+ help: __('If the chart should be animated (1) or not (0).', 'mycred'),
185
+ value: animate,
186
+ onChange: setAnimate
187
+
188
+ }),
189
+ el(TextControl, {
190
+ label: __('Bezier', 'mycred'),
191
+ help: __('If line charts should use bezier curves (1) or not (0)', 'mycred'),
192
+ value: bezier,
193
+ onChange: setBezier
194
+
195
+ }),
196
+ el(TextControl, {
197
+ label: __('Labels', 'mycred'),
198
+ help: __('If labels should be shown in the chart (1) or not (0). Not all chart types use labels, it is mainly for bar and line charts where we have both an x and y axis.', 'mycred'),
199
+ value: labels,
200
+ onChange: setLabels
201
+ }),
202
+ el(TextControl, {
203
+ label: __('Legend', 'mycred'),
204
+ help: __('If a legend should be shown in the chart (1) or not (0). Not all charts show legends.', 'mycred'),
205
+ value: legend,
206
+ onChange: setLegend
207
+ }),
208
+ el(TextControl, {
209
+ label: __('Width', 'mycred'),
210
+ help: __('The chart canvas width. By default the chart will render full with of the container where the shortcode is used. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
211
+ value: width,
212
+ onChange: setWidth
213
+ }),
214
+ el(TextControl, {
215
+ label: __('Height', 'mycred'),
216
+ help: __('The chart canvas height. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
217
+ value: height,
218
+ onChange: setHeight
219
+ }),
220
+ )
221
+ )
222
+ ]);
223
+ },
224
+ save: function (props) {
225
+ return null;
226
+ }
227
+ });
228
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-chart-balance-history/mycred-chart-balance-history.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_chart_balance_block') ) :
7
+ class mycred_chart_balance_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-balance-history',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-chart-balance-history',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_chart_balance_history " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_chart_balance_block();
includes/mycred-blocks/blocks/mycred-chart-circu/index.js ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+ var __ = wp.i18n.__;
8
+ registerBlockType('mycred-gb-blocks/mycred-chart-circulation', {
9
+ title: __('Chart Circulation', 'mycred'),
10
+ category: 'mycred',
11
+ attributes: {
12
+ type : {
13
+ type: 'string',
14
+ default: 'pie'
15
+ },
16
+ title : {
17
+ type: 'string',
18
+ },
19
+ animate : {
20
+ type: 'string',
21
+ default: '1'
22
+ },
23
+ bezier : {
24
+ type: 'string',
25
+ default: '1'
26
+ },
27
+ labels : {
28
+ type: 'string',
29
+ default: '1'
30
+ },
31
+ legend : {
32
+ type: 'string',
33
+ default: '1'
34
+ },
35
+ width : {
36
+ type: 'string'
37
+ },
38
+ height : {
39
+ type: 'string'
40
+ }
41
+ },
42
+ edit: function (props) {
43
+ var type = props.attributes.type;
44
+ var title = props.attributes.title;
45
+ var animate = props.attributes.animate;
46
+ var bezier = props.attributes.bezier;
47
+ var labels = props.attributes.labels;
48
+ var legend = props.attributes.legend;
49
+ var width = props.attributes.width;
50
+ var height = props.attributes.height;
51
+
52
+ function setTypes(value) {
53
+ props.setAttributes({type: value});
54
+ }
55
+
56
+ function setTitle(value) {
57
+ props.setAttributes({title: value});
58
+ }
59
+
60
+ function setAnimate(value) {
61
+ props.setAttributes({animate: value});
62
+ }
63
+
64
+ function setBezier(value) {
65
+ props.setAttributes({bezier: value});
66
+ }
67
+
68
+ function setLabels(value) {
69
+ props.setAttributes({labels: value});
70
+ }
71
+
72
+ function setLegend(value) {
73
+ props.setAttributes({legend: value});
74
+ }
75
+
76
+ function setWidth(value) {
77
+ props.setAttributes({width: value});
78
+ }
79
+
80
+ function setHeight(value) {
81
+ props.setAttributes({height: value});
82
+ }
83
+
84
+ return el('div', {}, [
85
+ el('p', {}, __('Chart Circulation Shortcode', 'mycred') ),
86
+ el(InspectorControls, null,
87
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
88
+ el(TextControl, {
89
+ label: __('Type', 'mycred'),
90
+ help: __('The chart type to render. Supports: "pie", "doughnut", "line", "bar", "radar" and "polarArea".', 'mycred'),
91
+ value: type,
92
+ onChange: setTypes
93
+
94
+ }),
95
+ el(TextControl, {
96
+ label: __('Title', 'mycred'),
97
+ help: __('To set a title for the chart.', 'mycred'),
98
+ value: title,
99
+ onChange: setTitle
100
+
101
+ }),
102
+ el(TextControl, {
103
+ label: __('Animate', 'mycred'),
104
+ help: __('If the chart should be animated (1) or not (0).', 'mycred'),
105
+ value: animate,
106
+ onChange: setAnimate
107
+
108
+ }),
109
+ el(TextControl, {
110
+ label: __('Bezier', 'mycred'),
111
+ help: __('If line charts should use bezier curves (1) or not (0)', 'mycred'),
112
+ value: bezier,
113
+ onChange: setBezier
114
+
115
+ }),
116
+ el(TextControl, {
117
+ label: __('Labels', 'mycred'),
118
+ help: __('If labels should be shown in the chart (1) or not (0). Not all chart types use labels, it is mainly for bar and line charts where we have both an x and y axis.', 'mycred'),
119
+ value: labels,
120
+ onChange: setLabels
121
+ }),
122
+ el(TextControl, {
123
+ label: __('Legend', 'mycred'),
124
+ help: __('If a legend should be shown in the chart (1) or not (0). Not all charts show legends.', 'mycred'),
125
+ value: legend,
126
+ onChange: setLegend
127
+ }),
128
+ el(TextControl, {
129
+ label: __('Width', 'mycred'),
130
+ help: __('The chart canvas width. By default the chart will render full with of the container where the shortcode is used. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
131
+ value: width,
132
+ onChange: setWidth
133
+ }),
134
+ el(TextControl, {
135
+ label: __('Height', 'mycred'),
136
+ help: __('The chart canvas height. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
137
+ value: height,
138
+ onChange: setHeight
139
+ }),
140
+ )
141
+ )
142
+ ]);
143
+ },
144
+ save: function (props) {
145
+ return null;
146
+ }
147
+ });
148
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-chart-circu/mycred-chart-circu.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_chart_circulation_block') ) :
7
+ class mycred_chart_circulation_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-chart-circulation',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-chart-circu',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_chart_circulation " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_chart_circulation_block();
includes/mycred-blocks/blocks/mycred-chart-gain-loss/index.js ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+ var __ = wp.i18n.__;
8
+ registerBlockType('mycred-gb-blocks/mycred-chart-gain-loss', {
9
+ title: __('Chart Gain/Loss', 'mycred'),
10
+ category: 'mycred',
11
+ attributes: {
12
+ type : {
13
+ type: 'string',
14
+ default: 'pie'
15
+ },
16
+ ctype : {
17
+ type: 'string',
18
+ default: 'mycred_default'
19
+ },
20
+ title : {
21
+ type: 'string',
22
+ },
23
+ animate : {
24
+ type: 'string',
25
+ default: '1'
26
+ },
27
+ bezier : {
28
+ type: 'string',
29
+ default: '1'
30
+ },
31
+ labels : {
32
+ type: 'string',
33
+ default: '1'
34
+ },
35
+ legend : {
36
+ type: 'string',
37
+ default: '1'
38
+ },
39
+ width : {
40
+ type: 'string'
41
+ },
42
+ height : {
43
+ type: 'string'
44
+ },
45
+ gains : {
46
+ type: 'string'
47
+ },
48
+ losses : {
49
+ type: 'string'
50
+ }
51
+ },
52
+ edit: function (props) {
53
+ var type = props.attributes.type;
54
+ var ctype = props.attributes.ctype;
55
+ var title = props.attributes.title;
56
+ var animate = props.attributes.animate;
57
+ var bezier = props.attributes.bezier;
58
+ var labels = props.attributes.labels;
59
+ var legend = props.attributes.legend;
60
+ var width = props.attributes.width;
61
+ var height = props.attributes.height;
62
+ var gains = props.attributes.gains;
63
+ var losses = props.attributes.losses;
64
+
65
+ function setTypes(value) {
66
+ props.setAttributes({type: value});
67
+ }
68
+
69
+ function setPtypes(value) {
70
+ props.setAttributes({ctype: value});
71
+ }
72
+
73
+ function setTitle(value) {
74
+ props.setAttributes({title: value});
75
+ }
76
+
77
+ function setAnimate(value) {
78
+ props.setAttributes({animate: value});
79
+ }
80
+
81
+ function setBezier(value) {
82
+ props.setAttributes({bezier: value});
83
+ }
84
+
85
+ function setLabels(value) {
86
+ props.setAttributes({labels: value});
87
+ }
88
+
89
+ function setLegend(value) {
90
+ props.setAttributes({legend: value});
91
+ }
92
+
93
+ function setWidth(value) {
94
+ props.setAttributes({width: value});
95
+ }
96
+
97
+ function setHeight(value) {
98
+ props.setAttributes({height: value});
99
+ }
100
+
101
+ function setGains(value) {
102
+ props.setAttributes({gains: value});
103
+ }
104
+
105
+ function setLosses(value) {
106
+ props.setAttributes({losses: value});
107
+ }
108
+
109
+ return el('div', {}, [
110
+ el('p', {}, __('Chart Gain/Loss Shortcode', 'mycred') ),
111
+ el(InspectorControls, null,
112
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
113
+ el(TextControl, {
114
+ label: __('Type', 'mycred'),
115
+ help: __('The chart type to render. Supports: "pie", "doughnut", "line", "bar" and "polarArea".', 'mycred'),
116
+ value: type,
117
+ onChange: setTypes
118
+
119
+ }),
120
+ el(TextControl, {
121
+ label: __('Point Type', 'mycred'),
122
+ help: __('The point type we want to show data for. Should only be used when you need to show data for a custom point type.', 'mycred'),
123
+ value: ctype,
124
+ onChange: setPtypes
125
+
126
+ }),
127
+ el(TextControl, {
128
+ label: __('Title', 'mycred'),
129
+ help: __('To set a title for the chart.', 'mycred'),
130
+ value: title,
131
+ onChange: setTitle
132
+
133
+ }),
134
+ el(TextControl, {
135
+ label: __('Animate', 'mycred'),
136
+ help: __('If the chart should be animated (1) or not (0).', 'mycred'),
137
+ value: animate,
138
+ onChange: setAnimate
139
+
140
+ }),
141
+ el(TextControl, {
142
+ label: __('Bezier', 'mycred'),
143
+ help: __('If line charts should use bezier curves (1) or not (0)', 'mycred'),
144
+ value: bezier,
145
+ onChange: setBezier
146
+
147
+ }),
148
+ el(TextControl, {
149
+ label: __('Labels', 'mycred'),
150
+ help: __('If labels should be shown in the chart (1) or not (0). Not all chart types use labels, it is mainly for bar and line charts where we have both an x and y axis.', 'mycred'),
151
+ value: labels,
152
+ onChange: setLabels
153
+ }),
154
+ el(TextControl, {
155
+ label: __('Legend', 'mycred'),
156
+ help: __('If a legend should be shown in the chart (1) or not (0). Not all charts show legends.', 'mycred'),
157
+ value: legend,
158
+ onChange: setLegend
159
+ }),
160
+ el(TextControl, {
161
+ label: __('Width', 'mycred'),
162
+ help: __('The chart canvas width. By default the chart will render full with of the container where the shortcode is used. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
163
+ value: width,
164
+ onChange: setWidth
165
+ }),
166
+ el(TextControl, {
167
+ label: __('Height', 'mycred'),
168
+ help: __('The chart canvas height. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
169
+ value: height,
170
+ onChange: setHeight
171
+ }),
172
+ el(TextControl, {
173
+ label: __('Gain', 'mycred'),
174
+ help: __('use a different word than "Gains".', 'mycred'),
175
+ value: gains,
176
+ onChange: setGains
177
+ }),
178
+ el(TextControl, {
179
+ label: __('Loss', 'mycred'),
180
+ help: __('use a different word than "Losses".', 'mycred'),
181
+ value: losses,
182
+ onChange: setLosses
183
+ }),
184
+ )
185
+ )
186
+ ]);
187
+ },
188
+ save: function (props) {
189
+ return null;
190
+ }
191
+ });
192
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-chart-gain-loss/mycred-chart-gain-loss.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_chart_gain_loss_block') ) :
7
+ class mycred_chart_gain_loss_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-chart-gain-loss',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-chart-gain-loss',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_chart_gain_loss " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_chart_gain_loss_block();
includes/mycred-blocks/blocks/mycred-chart-history/index.js ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+ var __ = wp.i18n.__;
8
+ registerBlockType('mycred-gb-blocks/mycred-chart-history', {
9
+ title: __('Chart History', 'mycred'),
10
+ category: 'mycred',
11
+ attributes: {
12
+ type : {
13
+ type: 'string',
14
+ default: 'line'
15
+ },
16
+ ctype : {
17
+ type: 'string',
18
+ },
19
+ period : {
20
+ type: 'string',
21
+ default: 'days'
22
+ },
23
+ number : {
24
+ type: 'string',
25
+ default: '10'
26
+ },
27
+ order : {
28
+ type: 'string',
29
+ default: 'DESC'
30
+ },
31
+ title : {
32
+ type: 'string',
33
+ },
34
+ animate : {
35
+ type: 'string',
36
+ default: '1'
37
+ },
38
+ bezier : {
39
+ type: 'string',
40
+ default: '1'
41
+ },
42
+ labels : {
43
+ type: 'string',
44
+ default: '1'
45
+ },
46
+ legend : {
47
+ type: 'string',
48
+ default: '1'
49
+ },
50
+ width : {
51
+ type: 'string'
52
+ },
53
+ height : {
54
+ type: 'string'
55
+ }
56
+ },
57
+ edit: function (props) {
58
+ var type = props.attributes.type;
59
+ var ctype = props.attributes.ctype;
60
+ var period = props.attributes.period;
61
+ var number = props.attributes.number;
62
+ var order = props.attributes.order;
63
+ var title = props.attributes.title;
64
+ var animate = props.attributes.animate;
65
+ var bezier = props.attributes.bezier;
66
+ var labels = props.attributes.labels;
67
+ var legend = props.attributes.legend;
68
+ var width = props.attributes.width;
69
+ var height = props.attributes.height;
70
+
71
+ function setTypes(value) {
72
+ props.setAttributes({type: value});
73
+ }
74
+
75
+ function setPtypes(value) {
76
+ props.setAttributes({ctype: value});
77
+ }
78
+
79
+ function setPeriod(value) {
80
+ props.setAttributes({period: value});
81
+ }
82
+
83
+ function setNumber(value) {
84
+ props.setAttributes({number: value});
85
+ }
86
+
87
+ function setOrder(value) {
88
+ props.setAttributes({order: value});
89
+ }
90
+
91
+ function setTitle(value) {
92
+ props.setAttributes({title: value});
93
+ }
94
+
95
+ function setAnimate(value) {
96
+ props.setAttributes({animate: value});
97
+ }
98
+
99
+ function setBezier(value) {
100
+ props.setAttributes({bezier: value});
101
+ }
102
+
103
+ function setLabels(value) {
104
+ props.setAttributes({labels: value});
105
+ }
106
+
107
+ function setLegend(value) {
108
+ props.setAttributes({legend: value});
109
+ }
110
+
111
+ function setWidth(value) {
112
+ props.setAttributes({width: value});
113
+ }
114
+
115
+ function setHeight(value) {
116
+ props.setAttributes({height: value});
117
+ }
118
+
119
+ return el('div', {}, [
120
+ el('p', {}, __('Chart History Shortcode', 'mycred') ),
121
+ el(InspectorControls, null,
122
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
123
+ el(TextControl, {
124
+ label: __('Type', 'mycred'),
125
+ help: __('The chart type to render. Supports: "line" and "bar".', 'mycred'),
126
+ value: type,
127
+ onChange: setTypes
128
+
129
+ }),
130
+ el(TextControl, {
131
+ label: __('Point Type', 'mycred'),
132
+ help: __('The point type we want to show data for. Should only be used when you need to show data for a custom point type.', 'mycred'),
133
+ value: ctype,
134
+ onChange: setPtypes
135
+
136
+ }),
137
+ el(TextControl, {
138
+ label: __('Period', 'mycred'),
139
+ help: __('The type of periods we want to use. Accepts days, weeks, months and years.', 'mycred'),
140
+ value: period,
141
+ onChange: setPeriod
142
+
143
+ }),
144
+ el(TextControl, {
145
+ label: __('Number', 'mycred'),
146
+ help: __('The number of periods to show in the chart e.g. 10 days or 12 months.', 'mycred'),
147
+ value: number,
148
+ onChange: setNumber
149
+
150
+ }),
151
+ el(TextControl, {
152
+ label: __('Order', 'mycred'),
153
+ help: __('The order of which the periods should be sorted.', 'mycred'),
154
+ value: order,
155
+ onChange: setOrder
156
+
157
+ }),
158
+ el(TextControl, {
159
+ label: __('Title', 'mycred'),
160
+ help: __('To set a title for the chart.', 'mycred'),
161
+ value: title,
162
+ onChange: setTitle
163
+
164
+ }),
165
+ el(TextControl, {
166
+ label: __('Animate', 'mycred'),
167
+ help: __('If the chart should be animated (1) or not (0).', 'mycred'),
168
+ value: animate,
169
+ onChange: setAnimate
170
+
171
+ }),
172
+ el(TextControl, {
173
+ label: __('Bezier', 'mycred'),
174
+ help: __('If line charts should use bezier curves (1) or not (0)', 'mycred'),
175
+ value: bezier,
176
+ onChange: setBezier
177
+
178
+ }),
179
+ el(TextControl, {
180
+ label: __('Labels', 'mycred'),
181
+ help: __('If labels should be shown in the chart (1) or not (0). Not all chart types use labels, it is mainly for bar and line charts where we have both an x and y axis.', 'mycred'),
182
+ value: labels,
183
+ onChange: setLabels
184
+ }),
185
+ el(TextControl, {
186
+ label: __('Legend', 'mycred'),
187
+ help: __('If a legend should be shown in the chart (1) or not (0). Not all charts show legends.', 'mycred'),
188
+ value: legend,
189
+ onChange: setLegend
190
+ }),
191
+ el(TextControl, {
192
+ label: __('Width', 'mycred'),
193
+ help: __('The chart canvas width. By default the chart will render full with of the container where the shortcode is used. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
194
+ value: width,
195
+ onChange: setWidth
196
+ }),
197
+ el(TextControl, {
198
+ label: __('Height', 'mycred'),
199
+ help: __('The chart canvas height. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
200
+ value: height,
201
+ onChange: setHeight
202
+ }),
203
+ )
204
+ )
205
+ ]);
206
+ },
207
+ save: function (props) {
208
+ return null;
209
+ }
210
+ });
211
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-chart-history/mycred-chart-history.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_chart_history_block') ) :
7
+ class mycred_chart_history_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-chart-history',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-chart-history',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_chart_history " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_chart_history_block();
includes/mycred-blocks/blocks/mycred-chart-instance-history/index.js ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+ var __ = wp.i18n.__;
8
+ registerBlockType('mycred-gb-blocks/mycred-instance-history', {
9
+ title: __('Chart Instance History', 'mycred'),
10
+ category: 'mycred',
11
+ attributes: {
12
+ type : {
13
+ type: 'string',
14
+ default: 'line'
15
+ },
16
+ ctype : {
17
+ type: 'string',
18
+ default: 'mycred_default'
19
+ },
20
+ ref : {
21
+ type: 'string',
22
+ },
23
+ period : {
24
+ type: 'string',
25
+ default: 'days'
26
+ },
27
+ number : {
28
+ type: 'string',
29
+ default: '10'
30
+ },
31
+ order : {
32
+ type: 'string',
33
+ default: 'DESC'
34
+ },
35
+ title : {
36
+ type: 'string',
37
+ },
38
+ animate : {
39
+ type: 'string',
40
+ default: '1'
41
+ },
42
+ bezier : {
43
+ type: 'string',
44
+ default: '1'
45
+ },
46
+ labels : {
47
+ type: 'string',
48
+ default: '1'
49
+ },
50
+ legend : {
51
+ type: 'string',
52
+ default: '1'
53
+ },
54
+ width : {
55
+ type: 'string'
56
+ },
57
+ height : {
58
+ type: 'string'
59
+ }
60
+ },
61
+ edit: function (props) {
62
+ var type = props.attributes.type;
63
+ var ctype = props.attributes.ctype;
64
+ var ref = props.attributes.ref;
65
+ var period = props.attributes.period;
66
+ var number = props.attributes.number;
67
+ var order = props.attributes.order;
68
+ var title = props.attributes.title;
69
+ var animate = props.attributes.animate;
70
+ var bezier = props.attributes.bezier;
71
+ var labels = props.attributes.labels;
72
+ var legend = props.attributes.legend;
73
+ var width = props.attributes.width;
74
+ var height = props.attributes.height;
75
+
76
+ function setTypes(value) {
77
+ props.setAttributes({type: value});
78
+ }
79
+
80
+ function setPtypes(value) {
81
+ props.setAttributes({ctype: value});
82
+ }
83
+
84
+ function setRefernce(value) {
85
+ props.setAttributes({ref: value});
86
+ }
87
+
88
+ function setPeriod(value) {
89
+ props.setAttributes({period: value});
90
+ }
91
+
92
+ function setNumber(value) {
93
+ props.setAttributes({number: value});
94
+ }
95
+
96
+ function setOrder(value) {
97
+ props.setAttributes({order: value});
98
+ }
99
+
100
+ function setTitle(value) {
101
+ props.setAttributes({title: value});
102
+ }
103
+
104
+ function setAnimate(value) {
105
+ props.setAttributes({animate: value});
106
+ }
107
+
108
+ function setBezier(value) {
109
+ props.setAttributes({bezier: value});
110
+ }
111
+
112
+ function setLabels(value) {
113
+ props.setAttributes({labels: value});
114
+ }
115
+
116
+ function setLegend(value) {
117
+ props.setAttributes({legend: value});
118
+ }
119
+
120
+ function setWidth(value) {
121
+ props.setAttributes({width: value});
122
+ }
123
+
124
+ function setHeight(value) {
125
+ props.setAttributes({height: value});
126
+ }
127
+
128
+ return el('div', {}, [
129
+ el('p', {}, __('Chart Instance History Shortcode', 'mycred') ),
130
+ el(InspectorControls, null,
131
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
132
+ el(TextControl, {
133
+ label: __('Type', 'mycred'),
134
+ help: __('The chart type to render. Supports: "line" and "bar".', 'mycred'),
135
+ value: type,
136
+ onChange: setTypes
137
+
138
+ }),
139
+ el(TextControl, {
140
+ label: __('Point Type', 'mycred'),
141
+ help: __('The point type we want to show data for. Should only be used when you need to show data for a custom point type.', 'mycred'),
142
+ value: ctype,
143
+ onChange: setPtypes
144
+
145
+ }),
146
+ el(TextControl, {
147
+ label: __('Log Reference', 'mycred'),
148
+ help: __("The log reference we want to show history for.", 'mycred'),
149
+ value: ref,
150
+ onChange: setRefernce
151
+
152
+ }),
153
+ el(TextControl, {
154
+ label: __('Period', 'mycred'),
155
+ help: __('The type of periods we want to use. Accepts days, weeks, months and years.', 'mycred'),
156
+ value: period,
157
+ onChange: setPeriod
158
+
159
+ }),
160
+ el(TextControl, {
161
+ label: __('Number', 'mycred'),
162
+ help: __('The number of periods to show in the chart e.g. 10 days or 12 months.', 'mycred'),
163
+ value: number,
164
+ onChange: setNumber
165
+
166
+ }),
167
+ el(TextControl, {
168
+ label: __('Order', 'mycred'),
169
+ help: __('The order of which the periods should be sorted.', 'mycred'),
170
+ value: order,
171
+ onChange: setOrder
172
+
173
+ }),
174
+ el(TextControl, {
175
+ label: __('Title', 'mycred'),
176
+ help: __('To set a title for the chart.', 'mycred'),
177
+ value: title,
178
+ onChange: setTitle
179
+
180
+ }),
181
+ el(TextControl, {
182
+ label: __('Animate', 'mycred'),
183
+ help: __('If the chart should be animated (1) or not (0).', 'mycred'),
184
+ value: animate,
185
+ onChange: setAnimate
186
+
187
+ }),
188
+ el(TextControl, {
189
+ label: __('Bezier', 'mycred'),
190
+ help: __('If line charts should use bezier curves (1) or not (0)', 'mycred'),
191
+ value: bezier,
192
+ onChange: setBezier
193
+
194
+ }),
195
+ el(TextControl, {
196
+ label: __('Labels', 'mycred'),
197
+ help: __('If labels should be shown in the chart (1) or not (0). Not all chart types use labels, it is mainly for bar and line charts where we have both an x and y axis.', 'mycred'),
198
+ value: labels,
199
+ onChange: setLabels
200
+ }),
201
+ el(TextControl, {
202
+ label: __('Legend', 'mycred'),
203
+ help: __('If a legend should be shown in the chart (1) or not (0). Not all charts show legends.', 'mycred'),
204
+ value: legend,
205
+ onChange: setLegend
206
+ }),
207
+ el(TextControl, {
208
+ label: __('Width', 'mycred'),
209
+ help: __('The chart canvas width. By default the chart will render full with of the container where the shortcode is used. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
210
+ value: width,
211
+ onChange: setWidth
212
+ }),
213
+ el(TextControl, {
214
+ label: __('Height', 'mycred'),
215
+ help: __('The chart canvas height. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
216
+ value: height,
217
+ onChange: setHeight
218
+ }),
219
+ )
220
+ )
221
+ ]);
222
+ },
223
+ save: function (props) {
224
+ return null;
225
+ }
226
+ });
227
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-chart-instance-history/mycred-chart-instance-history.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_chart_instance_block') ) :
7
+ class mycred_chart_instance_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-instance-history',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-chart-instance-history',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_chart_instance_history " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_chart_instance_block();
includes/mycred-blocks/blocks/mycred-chart-top-balance/index.js ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+ var __ = wp.i18n.__;
8
+ registerBlockType('mycred-gb-blocks/mycred-chart-top-balance', {
9
+ title: __('Chart Top Balance', 'mycred'),
10
+ category: 'mycred',
11
+ attributes: {
12
+ type : {
13
+ type: 'string',
14
+ default: 'bar'
15
+ },
16
+ ctype : {
17
+ type: 'string',
18
+ },
19
+ number : {
20
+ type: 'string',
21
+ default: '10'
22
+ },
23
+ order : {
24
+ type: 'string',
25
+ default: 'DESC'
26
+ },
27
+ title : {
28
+ type: 'string',
29
+ },
30
+ animate : {
31
+ type: 'string',
32
+ default: '1'
33
+ },
34
+ bezier : {
35
+ type: 'string',
36
+ default: '1'
37
+ },
38
+ labels : {
39
+ type: 'string',
40
+ default: '1'
41
+ },
42
+ legend : {
43
+ type: 'string',
44
+ default: '1'
45
+ },
46
+ width : {
47
+ type: 'string'
48
+ },
49
+ height : {
50
+ type: 'string'
51
+ }
52
+ },
53
+ edit: function (props) {
54
+ var type = props.attributes.type;
55
+ var ctype = props.attributes.ctype;
56
+ var number = props.attributes.number;
57
+ var order = props.attributes.order;
58
+ var title = props.attributes.title;
59
+ var animate = props.attributes.animate;
60
+ var bezier = props.attributes.bezier;
61
+ var labels = props.attributes.labels;
62
+ var legend = props.attributes.legend;
63
+ var width = props.attributes.width;
64
+ var height = props.attributes.height;
65
+
66
+ function setTypes(value) {
67
+ props.setAttributes({type: value});
68
+ }
69
+
70
+ function setPtypes(value) {
71
+ props.setAttributes({ctype: value});
72
+ }
73
+
74
+ function setNumber(value) {
75
+ props.setAttributes({number: value});
76
+ }
77
+
78
+ function setOrder(value) {
79
+ props.setAttributes({order: value});
80
+ }
81
+
82
+ function setTitle(value) {
83
+ props.setAttributes({title: value});
84
+ }
85
+
86
+ function setAnimate(value) {
87
+ props.setAttributes({animate: value});
88
+ }
89
+
90
+ function setBezier(value) {
91
+ props.setAttributes({bezier: value});
92
+ }
93
+
94
+ function setLabels(value) {
95
+ props.setAttributes({labels: value});
96
+ }
97
+
98
+ function setLegend(value) {
99
+ props.setAttributes({legend: value});
100
+ }
101
+
102
+ function setWidth(value) {
103
+ props.setAttributes({width: value});
104
+ }
105
+
106
+ function setHeight(value) {
107
+ props.setAttributes({height: value});
108
+ }
109
+
110
+ return el('div', {}, [
111
+ el('p', {}, __('Chart Top Balance Shortcode', 'mycred') ),
112
+ el(InspectorControls, null,
113
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
114
+ el(TextControl, {
115
+ label: __('Type', 'mycred'),
116
+ help: __('The chart type to render. Supports: pie, doughnut, line, bar, radar and polarArea', 'mycred'),
117
+ value: type,
118
+ onChange: setTypes
119
+
120
+ }),
121
+ el(TextControl, {
122
+ label: __('Point Type', 'mycred'),
123
+ help: __('The point type we want to show data for. Should only be used when you need to show data for a custom point type.', 'mycred'),
124
+ value: ctype,
125
+ onChange: setPtypes
126
+
127
+ }),
128
+ el(TextControl, {
129
+ label: __('Number', 'mycred'),
130
+ help: __('The number of balances to show.', 'mycred'),
131
+ value: number,
132
+ onChange: setNumber
133
+
134
+ }),
135
+ el(TextControl, {
136
+ label: __('Order', 'mycred'),
137
+ help: __('The order of which the periods should be sorted.', 'mycred'),
138
+ value: order,
139
+ onChange: setOrder
140
+
141
+ }),
142
+ el(TextControl, {
143
+ label: __('Title', 'mycred'),
144
+ help: __('To set a title for the chart.', 'mycred'),
145
+ value: title,
146
+ onChange: setTitle
147
+
148
+ }),
149
+ el(TextControl, {
150
+ label: __('Animate', 'mycred'),
151
+ help: __('If the chart should be animated (1) or not (0).', 'mycred'),
152
+ value: animate,
153
+ onChange: setAnimate
154
+
155
+ }),
156
+ el(TextControl, {
157
+ label: __('Bezier', 'mycred'),
158
+ help: __('If line charts should use bezier curves (1) or not (0)', 'mycred'),
159
+ value: bezier,
160
+ onChange: setBezier
161
+
162
+ }),
163
+ el(TextControl, {
164
+ label: __('Labels', 'mycred'),
165
+ help: __('If labels should be shown in the chart (1) or not (0). Not all chart types use labels, it is mainly for bar and line charts where we have both an x and y axis.', 'mycred'),
166
+ value: labels,
167
+ onChange: setLabels
168
+ }),
169
+ el(TextControl, {
170
+ label: __('Legend', 'mycred'),
171
+ help: __('If a legend should be shown in the chart (1) or not (0). Not all charts show legends.', 'mycred'),
172
+ value: legend,
173
+ onChange: setLegend
174
+ }),
175
+ el(TextControl, {
176
+ label: __('Width', 'mycred'),
177
+ help: __('The chart canvas width. By default the chart will render full with of the container where the shortcode is used. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
178
+ value: width,
179
+ onChange: setWidth
180
+ }),
181
+ el(TextControl, {
182
+ label: __('Height', 'mycred'),
183
+ help: __('The chart canvas height. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
184
+ value: height,
185
+ onChange: setHeight
186
+ }),
187
+ )
188
+ )
189
+ ]);
190
+ },
191
+ save: function (props) {
192
+ return null;
193
+ }
194
+ });
195
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-chart-top-balance/mycred-chart-top-balance.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_chart_top_balance_block') ) :
7
+ class mycred_chart_top_balance_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-chart-top-balance',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-chart-top-balance',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_chart_top_balances " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_chart_top_balance_block();
includes/mycred-blocks/blocks/mycred-chart-top-instance/index.js ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (wp) {
2
+ var registerBlockType = wp.blocks.registerBlockType;
3
+ var InspectorControls = wp.blockEditor.InspectorControls;
4
+ var el = wp.element.createElement;
5
+ var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
+ var __ = wp.i18n.__;
8
+ registerBlockType('mycred-gb-blocks/mycred-chart-top-instance', {
9
+ title: __('Chart Top Instance', 'mycred'),
10
+ category: 'mycred',
11
+ attributes: {
12
+ type : {
13
+ type: 'string',
14
+ default: 'bar'
15
+ },
16
+ ctype : {
17
+ type: 'string',
18
+ },
19
+ number : {
20
+ type: 'string',
21
+ default: '10'
22
+ },
23
+ order : {
24
+ type: 'string',
25
+ default: 'DESC'
26
+ },
27
+ title : {
28
+ type: 'string',
29
+ },
30
+ animate : {
31
+ type: 'string',
32
+ default: '1'
33
+ },
34
+ bezier : {
35
+ type: 'string',
36
+ default: '1'
37
+ },
38
+ labels : {
39
+ type: 'string',
40
+ default: '1'
41
+ },
42
+ legend : {
43
+ type: 'string',
44
+ default: '1'
45
+ },
46
+ width : {
47
+ type: 'string'
48
+ },
49
+ height : {
50
+ type: 'string'
51
+ }
52
+ },
53
+ edit: function (props) {
54
+ var type = props.attributes.type;
55
+ var ctype = props.attributes.ctype;
56
+ var number = props.attributes.number;
57
+ var order = props.attributes.order;
58
+ var title = props.attributes.title;
59
+ var animate = props.attributes.animate;
60
+ var bezier = props.attributes.bezier;
61
+ var labels = props.attributes.labels;
62
+ var legend = props.attributes.legend;
63
+ var width = props.attributes.width;
64
+ var height = props.attributes.height;
65
+
66
+ function setTypes(value) {
67
+ props.setAttributes({type: value});
68
+ }
69
+
70
+ function setPtypes(value) {
71
+ props.setAttributes({ctype: value});
72
+ }
73
+
74
+ function setNumber(value) {
75
+ props.setAttributes({number: value});
76
+ }
77
+
78
+ function setOrder(value) {
79
+ props.setAttributes({order: value});
80
+ }
81
+
82
+ function setTitle(value) {
83
+ props.setAttributes({title: value});
84
+ }
85
+
86
+ function setAnimate(value) {
87
+ props.setAttributes({animate: value});
88
+ }
89
+
90
+ function setBezier(value) {
91
+ props.setAttributes({bezier: value});
92
+ }
93
+
94
+ function setLabels(value) {
95
+ props.setAttributes({labels: value});
96
+ }
97
+
98
+ function setLegend(value) {
99
+ props.setAttributes({legend: value});
100
+ }
101
+
102
+ function setWidth(value) {
103
+ props.setAttributes({width: value});
104
+ }
105
+
106
+ function setHeight(value) {
107
+ props.setAttributes({height: value});
108
+ }
109
+
110
+ return el('div', {}, [
111
+ el('p', {}, __('Chart Top Instance Shortcode', 'mycred') ),
112
+ el(InspectorControls, null,
113
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
114
+ el(TextControl, {
115
+ label: __('Type', 'mycred'),
116
+ help: __('The chart type to render. Supports: pie, doughnut, line, bar, radar and polarArea', 'mycred'),
117
+ value: type,
118
+ onChange: setTypes
119
+
120
+ }),
121
+ el(TextControl, {
122
+ label: __('Point Type', 'mycred'),
123
+ help: __('The point type we want to show data for. Should only be used when you need to show data for a custom point type.', 'mycred'),
124
+ value: ctype,
125
+ onChange: setPtypes
126
+
127
+ }),
128
+ el(TextControl, {
129
+ label: __('Number', 'mycred'),
130
+ help: __('The number of balances to show.', 'mycred'),
131
+ value: number,
132
+ onChange: setNumber
133
+
134
+ }),
135
+ el(TextControl, {
136
+ label: __('Order', 'mycred'),
137
+ help: __('The order of which the periods should be sorted.', 'mycred'),
138
+ value: order,
139
+ onChange: setOrder
140
+
141
+ }),
142
+ el(TextControl, {
143
+ label: __('Title', 'mycred'),
144
+ help: __('To set a title for the chart.', 'mycred'),
145
+ value: title,
146
+ onChange: setTitle
147
+
148
+ }),
149
+ el(TextControl, {
150
+ label: __('Animate', 'mycred'),
151
+ help: __('If the chart should be animated (1) or not (0).', 'mycred'),
152
+ value: animate,
153
+ onChange: setAnimate
154
+
155
+ }),
156
+ el(TextControl, {
157
+ label: __('Bezier', 'mycred'),
158
+ help: __('If line charts should use bezier curves (1) or not (0)', 'mycred'),
159
+ value: bezier,
160
+ onChange: setBezier
161
+
162
+ }),
163
+ el(TextControl, {
164
+ label: __('Labels', 'mycred'),
165
+ help: __('If labels should be shown in the chart (1) or not (0). Not all chart types use labels, it is mainly for bar and line charts where we have both an x and y axis.', 'mycred'),
166
+ value: labels,
167
+ onChange: setLabels
168
+ }),
169
+ el(TextControl, {
170
+ label: __('Legend', 'mycred'),
171
+ help: __('If a legend should be shown in the chart (1) or not (0). Not all charts show legends.', 'mycred'),
172
+ value: legend,
173
+ onChange: setLegend
174
+ }),
175
+ el(TextControl, {
176
+ label: __('Width', 'mycred'),
177
+ help: __('The chart canvas width. By default the chart will render full with of the container where the shortcode is used. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
178
+ value: width,
179
+ onChange: setWidth
180
+ }),
181
+ el(TextControl, {
182
+ label: __('Height', 'mycred'),
183
+ help: __('The chart canvas height. Can be either a pixel value (without px) or a percentage value (with %).', 'mycred'),
184
+ value: height,
185
+ onChange: setHeight
186
+ }),
187
+ )
188
+ )
189
+ ]);
190
+ },
191
+ save: function (props) {
192
+ return null;
193
+ }
194
+ });
195
+ })(window.wp);
includes/mycred-blocks/blocks/mycred-chart-top-instance/mycred-chart-top-instance.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace MG_Blocks;
3
+
4
+ if ( ! defined('ABSPATH') ) exit;
5
+
6
+ if ( ! class_exists('mycred_chart_top_instance_block') ) :
7
+ class mycred_chart_top_instance_block {
8
+
9
+ public function __construct() {
10
+
11
+ add_action('enqueue_block_editor_assets', array( $this, 'register_assets' ) );
12
+
13
+ register_block_type(
14
+ 'mycred-gb-blocks/mycred-chart-top-instance',
15
+ array( 'render_callback' => array( $this, 'render_block' ) )
16
+ );
17
+
18
+ }
19
+
20
+ public function register_assets() {
21
+
22
+ wp_enqueue_script(
23
+ 'mycred-chart-top-instance',
24
+ plugins_url('index.js', __FILE__),
25
+ array(
26
+ 'wp-blocks',
27
+ 'wp-element',
28
+ 'wp-components',
29
+ 'wp-editor',
30
+ 'wp-rich-text'
31
+ )
32
+ );
33
+
34
+ }
35
+
36
+ public function render_block( $attributes, $content ) {
37
+ return "[mycred_chart_top_instances " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
38
+ }
39
+
40
+ }
41
+ endif;
42
+
43
+ new mycred_chart_top_instance_block();
includes/mycred-blocks/blocks/mycred-email-subsc/index.js CHANGED
@@ -3,7 +3,7 @@
3
  var InspectorControls = wp.editor.InspectorControls;
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
-
7
  var __ = wp.i18n.__;
8
  registerBlockType('mycred-gb-blocks/mycred-email-subsc', {
9
  title: __('Email Subscriptions', 'mycred'),
@@ -22,16 +22,17 @@
22
  }
23
 
24
  return el('div', {}, [
25
- el('p', {}, __('Email Subscriptions Shortcode', 'mycred')
26
- ),
27
  el(InspectorControls, null,
 
28
  el(TextControl, {
29
  label: __('Success', 'mycred'),
30
  help: __('Message to show when settings have been changed.', 'mycred'),
31
  value: success,
32
  onChange: setSuccess
33
- })
34
- )
 
35
  ]);
36
  },
37
  save: function (props) {
3
  var InspectorControls = wp.editor.InspectorControls;
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
  var __ = wp.i18n.__;
8
  registerBlockType('mycred-gb-blocks/mycred-email-subsc', {
9
  title: __('Email Subscriptions', 'mycred'),
22
  }
23
 
24
  return el('div', {}, [
25
+ el('p', {}, __('Email Subscriptions Shortcode', 'mycred') ),
 
26
  el(InspectorControls, null,
27
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
28
  el(TextControl, {
29
  label: __('Success', 'mycred'),
30
  help: __('Message to show when settings have been changed.', 'mycred'),
31
  value: success,
32
  onChange: setSuccess
33
+ }),
34
+ )
35
+ )
36
  ]);
37
  },
38
  save: function (props) {
includes/mycred-blocks/blocks/mycred-exchange/index.js CHANGED
@@ -10,6 +10,7 @@
10
  var el = wp.element.createElement;
11
  var SelectControl = wp.components.SelectControl;
12
  var TextControl = wp.components.TextControl;
 
13
  var __ = wp.i18n.__;
14
  registerBlockType('mycred-gb-blocks/mycred-exchange', {
15
  title: __('Exchange', 'mycred'),
@@ -63,9 +64,9 @@
63
  props.setAttributes({button: value});
64
  }
65
  return el('div', {}, [
66
- el('p', {}, 'Exchange Shortcode'
67
- ),
68
  el(InspectorControls, null,
 
69
  el(SelectControl, {
70
  label: __('From', 'mycred'),
71
  helper: __('The point type to exchange from', 'mycred'),
@@ -98,7 +99,8 @@
98
  value: button,
99
  onChange: setButton
100
  }),
101
- )
 
102
  ]);
103
  },
104
  save: function (props) {
10
  var el = wp.element.createElement;
11
  var SelectControl = wp.components.SelectControl;
12
  var TextControl = wp.components.TextControl;
13
+ var panelBody = wp.components.PanelBody;
14
  var __ = wp.i18n.__;
15
  registerBlockType('mycred-gb-blocks/mycred-exchange', {
16
  title: __('Exchange', 'mycred'),
64
  props.setAttributes({button: value});
65
  }
66
  return el('div', {}, [
67
+ el('p', {}, __('Exchange Shortcode', 'mycred' ) ),
 
68
  el(InspectorControls, null,
69
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
70
  el(SelectControl, {
71
  label: __('From', 'mycred'),
72
  helper: __('The point type to exchange from', 'mycred'),
99
  value: button,
100
  onChange: setButton
101
  }),
102
+ )
103
+ )
104
  ]);
105
  },
106
  save: function (props) {
includes/mycred-blocks/blocks/mycred-give/index.js CHANGED
@@ -10,6 +10,7 @@
10
  var SelectControl = wp.components.SelectControl;
11
  var TextControl = wp.components.TextControl;
12
  var TextareaControl = wp.components.TextareaControl;
 
13
  var __ = wp.i18n.__;
14
 
15
  registerBlockType('mycred-gb-blocks/mycred-give', {
@@ -79,9 +80,9 @@
79
  props.setAttributes({content: value});
80
  }
81
  return el('div', {}, [
82
- el('p', {}, 'Give Shortcode'
83
- ),
84
  el(InspectorControls, null,
 
85
  el(TextControl, {
86
  label: __('Amount', 'mycred'),
87
  help: __('Required amount to give the user when this shortcode fires', 'mycred'),
@@ -124,8 +125,9 @@
124
  help: __('Content to show visitors viewing this shortcode. Leave empty to show nothing.', 'mycred'),
125
  value: content,
126
  onChange: setContent
127
- })
128
- )
 
129
  ]);
130
  },
131
  save: function (props) {
10
  var SelectControl = wp.components.SelectControl;
11
  var TextControl = wp.components.TextControl;
12
  var TextareaControl = wp.components.TextareaControl;
13
+ var panelBody = wp.components.PanelBody;
14
  var __ = wp.i18n.__;
15
 
16
  registerBlockType('mycred-gb-blocks/mycred-give', {
80
  props.setAttributes({content: value});
81
  }
82
  return el('div', {}, [
83
+ el('p', {}, __( 'Give Shortcode', 'mycred' ) ),
 
84
  el(InspectorControls, null,
85
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
86
  el(TextControl, {
87
  label: __('Amount', 'mycred'),
88
  help: __('Required amount to give the user when this shortcode fires', 'mycred'),
125
  help: __('Content to show visitors viewing this shortcode. Leave empty to show nothing.', 'mycred'),
126
  value: content,
127
  onChange: setContent
128
+ }),
129
+ )
130
+ )
131
  ]);
132
  },
133
  save: function (props) {
includes/mycred-blocks/blocks/mycred-history/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-history', {
10
  title: __('History', 'mycred'),
@@ -104,9 +105,9 @@
104
  });
105
  });
106
  return el('div', {}, [
107
- el('p', {}, __('History Shortcode', 'mycred')
108
- ),
109
  el(InspectorControls, null,
 
110
  el(TextControl, {
111
  label: __('User ID', 'mycred'),
112
  help: __('Option to show a specific users history. Use "current" to show the current users history or leave empty to show everyones history.', 'mycred'),
@@ -188,7 +189,8 @@
188
  checked: inlinenav,
189
  onChange: setInlineNav
190
  }),
191
- )
 
192
  ]);
193
  },
194
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-history', {
11
  title: __('History', 'mycred'),
105
  });
106
  });
107
  return el('div', {}, [
108
+ el('p', {}, __('History Shortcode', 'mycred') ),
 
109
  el(InspectorControls, null,
110
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
111
  el(TextControl, {
112
  label: __('User ID', 'mycred'),
113
  help: __('Option to show a specific users history. Use "current" to show the current users history or leave empty to show everyones history.', 'mycred'),
189
  checked: inlinenav,
190
  onChange: setInlineNav
191
  }),
192
+ )
193
+ )
194
  ]);
195
  },
196
  save: function (props) {
includes/mycred-blocks/blocks/mycred-hook-table/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-hook-table', {
10
  title: __('Hook Table', 'mycred'),
@@ -75,9 +76,9 @@
75
  });
76
  });
77
  return el('div', {}, [
78
- el('p', {}, __('Hook Table Shortcode', 'mycred')
79
- ),
80
  el(InspectorControls, null,
 
81
  el(SelectControl, {
82
  label: __('Point Type', 'mycred'),
83
  help: __('The point type to show hooks for.', 'mycred'),
@@ -124,7 +125,8 @@
124
  value: nothing,
125
  onChange: setNth
126
  }),
127
- )
 
128
  ]);
129
  },
130
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-hook-table', {
11
  title: __('Hook Table', 'mycred'),
76
  });
77
  });
78
  return el('div', {}, [
79
+ el('p', {}, __('Hook Table Shortcode', 'mycred') ),
 
80
  el(InspectorControls, null,
81
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
82
  el(SelectControl, {
83
  label: __('Point Type', 'mycred'),
84
  help: __('The point type to show hooks for.', 'mycred'),
125
  value: nothing,
126
  onChange: setNth
127
  }),
128
+ )
129
+ )
130
  ]);
131
  },
132
  save: function (props) {
includes/mycred-blocks/blocks/mycred-leaderboard/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-leaderboard', {
10
  title: __('Leaderboard', 'mycred'),
@@ -122,9 +123,9 @@
122
  });
123
  });
124
  return el('div', {}, [
125
- el('p', {}, __('Leaderboard Shortcode', 'mycred')
126
- ),
127
  el(InspectorControls, null,
 
128
  el(TextControl, {
129
  label: __('Number of Users', 'mycred'),
130
  help: __('The maximum number of users to include in the leaderboard.', 'mycred'),
@@ -202,7 +203,8 @@
202
  value: timeframe,
203
  onChange: setTimeFrame
204
  }),
205
- )
 
206
  ]);
207
  },
208
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-leaderboard', {
11
  title: __('Leaderboard', 'mycred'),
123
  });
124
  });
125
  return el('div', {}, [
126
+ el('p', {}, __('Leaderboard Shortcode', 'mycred') ),
 
127
  el(InspectorControls, null,
128
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
129
  el(TextControl, {
130
  label: __('Number of Users', 'mycred'),
131
  help: __('The maximum number of users to include in the leaderboard.', 'mycred'),
203
  value: timeframe,
204
  onChange: setTimeFrame
205
  }),
206
+ )
207
+ )
208
  ]);
209
  },
210
  save: function (props) {
includes/mycred-blocks/blocks/mycred-link/index.js CHANGED
@@ -5,7 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var TextareaControl = wp.components.TextareaControl;
8
-
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-link', {
11
  title: __('Link', 'mycred'),
@@ -131,9 +131,9 @@
131
  });
132
  });
133
  return el('div', {}, [
134
- el('p', {}, __('Link Shortcode', 'mycred')
135
- ),
136
  el(InspectorControls, null,
 
137
  el(TextControl, {
138
  label: __('Amount', 'mycred'),
139
  help: __('Amount of points for clicking on this link. Use zero to give the amount you set in your "Points for clicking on links" hook settings.', 'mycred'),
@@ -218,8 +218,9 @@
218
  label: __('Link Title', 'mycred'),
219
  value: content,
220
  onChange: setContent
221
- })
222
- )
 
223
  ]);
224
  },
225
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
  var TextareaControl = wp.components.TextareaControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-link', {
11
  title: __('Link', 'mycred'),
131
  });
132
  });
133
  return el('div', {}, [
134
+ el('p', {}, __('Link Shortcode', 'mycred') ),
 
135
  el(InspectorControls, null,
136
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
137
  el(TextControl, {
138
  label: __('Amount', 'mycred'),
139
  help: __('Amount of points for clicking on this link. Use zero to give the amount you set in your "Points for clicking on links" hook settings.', 'mycred'),
218
  label: __('Link Title', 'mycred'),
219
  value: content,
220
  onChange: setContent
221
+ }),
222
+ )
223
+ )
224
  ]);
225
  },
226
  save: function (props) {
includes/mycred-blocks/blocks/mycred-list-ranks/index.js CHANGED
@@ -4,6 +4,7 @@
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
 
7
  var __ = wp.i18n.__;
8
  registerBlockType('mycred-gb-blocks/mycred-list-ranks', {
9
  title: __('List Ranks', 'mycred'),
@@ -44,9 +45,9 @@
44
  });
45
 
46
  return el('div', {}, [
47
- el('p', {}, __('List Ranks Shortcode', 'mycred')
48
- ),
49
  el(InspectorControls, null,
 
50
  el(SelectControl, {
51
  label: __('Order', 'mycred'),
52
  help: __('Rank listing order', 'mycred'),
@@ -70,7 +71,8 @@
70
  value: wrap,
71
  onChange: setWrap
72
  }),
73
- )
 
74
  ]);
75
  },
76
  save: function (props) {
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
+ var panelBody = wp.components.PanelBody;
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-list-ranks', {
10
  title: __('List Ranks', 'mycred'),
45
  });
46
 
47
  return el('div', {}, [
48
+ el('p', {}, __('List Ranks Shortcode', 'mycred') ),
 
49
  el(InspectorControls, null,
50
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
51
  el(SelectControl, {
52
  label: __('Order', 'mycred'),
53
  help: __('Rank listing order', 'mycred'),
71
  value: wrap,
72
  onChange: setWrap
73
  }),
74
+ )
75
+ )
76
  ]);
77
  },
78
  save: function (props) {
includes/mycred-blocks/blocks/mycred-load-coupon/index.js CHANGED
@@ -3,7 +3,7 @@
3
  var InspectorControls = wp.editor.InspectorControls;
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
-
7
  var __ = wp.i18n.__;
8
  registerBlockType('mycred-gb-blocks/mycred-load-coupon', {
9
  title: __('Load Coupon', 'mycred'),
@@ -39,9 +39,9 @@
39
  }
40
 
41
  return el('div', {}, [
42
- el('p', {}, __('Load Coupon Shortcode', 'mycred')
43
- ),
44
  el(InspectorControls, null,
 
45
  el(TextControl, {
46
  label: __('Label', 'mycred'),
47
  help: __('The coupon label. Can not be empty.', 'mycred'),
@@ -61,8 +61,9 @@
61
  help: __('The placeholder label for the coupon field.', 'mycred'),
62
  value: placeholder,
63
  onChange: setPlaceholder
64
- })
65
- )
 
66
  ]);
67
  },
68
  save: function (props) {
3
  var InspectorControls = wp.editor.InspectorControls;
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
+ var panelBody = wp.components.PanelBody;
7
  var __ = wp.i18n.__;
8
  registerBlockType('mycred-gb-blocks/mycred-load-coupon', {
9
  title: __('Load Coupon', 'mycred'),
39
  }
40
 
41
  return el('div', {}, [
42
+ el('p', {}, __('Load Coupon Shortcode', 'mycred') ),
 
43
  el(InspectorControls, null,
44
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
45
  el(TextControl, {
46
  label: __('Label', 'mycred'),
47
  help: __('The coupon label. Can not be empty.', 'mycred'),
61
  help: __('The placeholder label for the coupon field.', 'mycred'),
62
  value: placeholder,
63
  onChange: setPlaceholder
64
+ }),
65
+ )
66
+ )
67
  ]);
68
  },
69
  save: function (props) {
includes/mycred-blocks/blocks/mycred-my-badges/index.js CHANGED
@@ -4,7 +4,7 @@
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
-
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-my-badges', {
10
  title: __('My Badges', 'mycred'),
@@ -52,6 +52,7 @@
52
  el('p', {}, __('My Badges Shortcode', 'mycred')
53
  ),
54
  el(InspectorControls, null,
 
55
  el(SelectControl, {
56
  label: __('Show', 'mycred'),
57
  help: __('Select if you want to show only badges that a user has earned or all badges', 'mycred'),
@@ -80,8 +81,9 @@
80
  help: __('Option to show badges of a particular user. If you want to show the badges of the current user, type in current.', 'mycred'),
81
  value: user_id,
82
  onChange: setUserId
83
- })
84
- )
 
85
  ]);
86
  },
87
  save: function (props) {
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
+ var panelBody = wp.components.PanelBody;
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-my-badges', {
10
  title: __('My Badges', 'mycred'),
52
  el('p', {}, __('My Badges Shortcode', 'mycred')
53
  ),
54
  el(InspectorControls, null,
55
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
56
  el(SelectControl, {
57
  label: __('Show', 'mycred'),
58
  help: __('Select if you want to show only badges that a user has earned or all badges', 'mycred'),
81
  help: __('Option to show badges of a particular user. If you want to show the badges of the current user, type in current.', 'mycred'),
82
  value: user_id,
83
  onChange: setUserId
84
+ }),
85
+ )
86
+ )
87
  ]);
88
  },
89
  save: function (props) {
includes/mycred-blocks/blocks/mycred-my-balance-converted/index.js CHANGED
@@ -4,6 +4,7 @@
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
 
7
  var __ = wp.i18n.__;
8
  registerBlockType('mycred-gb-blocks/mycred-my-balance-converted', {
9
  title: __('My Balance Converted', 'mycred'),
@@ -55,9 +56,9 @@
55
  });
56
 
57
  return el('div', {}, [
58
- el('p', {}, __('My Balance Converted Shortcode', 'mycred')
59
- ),
60
  el(InspectorControls, null,
 
61
  el(SelectControl, {
62
  label: __('Point Type', 'mycred'),
63
  help: __('The point type you want to show a Conversion for.', 'mycred'),
@@ -82,8 +83,9 @@
82
  help: __('', 'mycred'),
83
  value: suffix,
84
  onChange: setSuffix
85
- })
86
- )
 
87
  ]);
88
  },
89
  save: function (props) {
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
+ var panelBody = wp.components.PanelBody;
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-my-balance-converted', {
10
  title: __('My Balance Converted', 'mycred'),
56
  });
57
 
58
  return el('div', {}, [
59
+ el('p', {}, __('My Balance Converted Shortcode', 'mycred') ),
 
60
  el(InspectorControls, null,
61
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
62
  el(SelectControl, {
63
  label: __('Point Type', 'mycred'),
64
  help: __('The point type you want to show a Conversion for.', 'mycred'),
83
  help: __('', 'mycred'),
84
  value: suffix,
85
  onChange: setSuffix
86
+ }),
87
+ )
88
+ )
89
  ]);
90
  },
91
  save: function (props) {
includes/mycred-blocks/blocks/mycred-my-balance/index.js CHANGED
@@ -6,6 +6,7 @@
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
8
  var TextareaControl = wp.components.TextareaControl;
 
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-my-balance', {
11
  title: __('My Balance', 'mycred'),
@@ -85,9 +86,9 @@
85
  });
86
  });
87
  return el('div', {}, [
88
- el('p', {}, __('My Balance Shortcode', 'mycred')
89
- ),
90
  el(InspectorControls, null,
 
91
  el(TextControl, {
92
  label: __('User ID', 'mycred'),
93
  help: __('The users balance you want to show. Use "current" to show the user who is viewing the shortcode. Can not be empty.', 'mycred'),
@@ -136,8 +137,9 @@
136
  help: __('Optional message to show when the shortcode is viewed by a visitor that is not logged in.', 'mycred'),
137
  value: content,
138
  onChange: setContent
139
- })
140
- )
 
141
  ]);
142
  },
143
  save: function (props) {
6
  var SelectControl = wp.components.SelectControl;
7
  var ToggleControl = wp.components.ToggleControl;
8
  var TextareaControl = wp.components.TextareaControl;
9
+ var panelBody = wp.components.PanelBody;
10
  var __ = wp.i18n.__;
11
  registerBlockType('mycred-gb-blocks/mycred-my-balance', {
12
  title: __('My Balance', 'mycred'),
86
  });
87
  });
88
  return el('div', {}, [
89
+ el('p', {}, __('My Balance Shortcode', 'mycred') ),
 
90
  el(InspectorControls, null,
91
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
92
  el(TextControl, {
93
  label: __('User ID', 'mycred'),
94
  help: __('The users balance you want to show. Use "current" to show the user who is viewing the shortcode. Can not be empty.', 'mycred'),
137
  help: __('Optional message to show when the shortcode is viewed by a visitor that is not logged in.', 'mycred'),
138
  value: content,
139
  onChange: setContent
140
+ }),
141
+ )
142
+ )
143
  ]);
144
  },
145
  save: function (props) {
includes/mycred-blocks/blocks/mycred-my-rank/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-my-rank', {
10
  title: __('My Rank', 'mycred'),
@@ -70,9 +71,9 @@
70
  });
71
 
72
  return el('div', {}, [
73
- el('p', {}, __('My Rank Shortcode', 'mycred')
74
- ),
75
  el(InspectorControls, null,
 
76
  el(TextControl, {
77
  label: __('User ID', 'mycred'),
78
  help: __('Optional ID of a specific user. If you want to show the rank of the user viewing this shortcode, leave this field empty.', 'mycred'),
@@ -115,7 +116,8 @@
115
  onChange: setPtType,
116
  options
117
  }),
118
- )
 
119
  ]);
120
  },
121
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-my-rank', {
11
  title: __('My Rank', 'mycred'),
71
  });
72
 
73
  return el('div', {}, [
74
+ el('p', {}, __('My Rank Shortcode', 'mycred') ),
 
75
  el(InspectorControls, null,
76
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
77
  el(TextControl, {
78
  label: __('User ID', 'mycred'),
79
  help: __('Optional ID of a specific user. If you want to show the rank of the user viewing this shortcode, leave this field empty.', 'mycred'),
116
  onChange: setPtType,
117
  options
118
  }),
119
+ )
120
+ )
121
  ]);
122
  },
123
  save: function (props) {
includes/mycred-blocks/blocks/mycred-my-ranks/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-my-ranks', {
10
  title: __('My Ranks', 'mycred'),
@@ -58,9 +59,9 @@
58
  }
59
 
60
  return el('div', {}, [
61
- el('p', {}, __('My Ranks Shortcode', 'mycred')
62
- ),
63
  el(InspectorControls, null,
 
64
  el(TextControl, {
65
  label: __('User ID', 'mycred'),
66
  help: __('Optional ID of a specific user. If you want to show the rank of the user viewing this shortcode, leave this field empty.', 'mycred'),
@@ -96,7 +97,8 @@
96
  {label: 'Title then Logo', value: 'title'}
97
  ]
98
  }),
99
- )
 
100
  ]);
101
  },
102
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-my-ranks', {
11
  title: __('My Ranks', 'mycred'),
59
  }
60
 
61
  return el('div', {}, [
62
+ el('p', {}, __('My Ranks Shortcode', 'mycred') ),
 
63
  el(InspectorControls, null,
64
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
65
  el(TextControl, {
66
  label: __('User ID', 'mycred'),
67
  help: __('Optional ID of a specific user. If you want to show the rank of the user viewing this shortcode, leave this field empty.', 'mycred'),
97
  {label: 'Title then Logo', value: 'title'}
98
  ]
99
  }),
100
+ )
101
+ )
102
  ]);
103
  },
104
  save: function (props) {
includes/mycred-blocks/blocks/mycred-total-balance/index.js CHANGED
@@ -5,7 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var TextareaControl = wp.components.TextareaControl;
8
-
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-total-balance', {
11
  title: __('Total Balance', 'mycred'),
@@ -45,9 +45,9 @@
45
  props.setAttributes({total: value});
46
  }
47
  return el('div', {}, [
48
- el('p', {}, __('Total Balance Shortcode', 'mycred')
49
- ),
50
  el(InspectorControls, null,
 
51
  el(TextControl, {
52
  label: __('User ID', 'mycred'),
53
  help: __('Option to return a specific users balance. Use "current" to show the current users total balance.', 'mycred'),
@@ -74,7 +74,8 @@
74
  checked: total,
75
  onChange: setTotal
76
  }),
77
- )
 
78
  ]);
79
  },
80
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var TextareaControl = wp.components.TextareaControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-total-balance', {
11
  title: __('Total Balance', 'mycred'),
45
  props.setAttributes({total: value});
46
  }
47
  return el('div', {}, [
48
+ el('p', {}, __('Total Balance Shortcode', 'mycred') ),
 
49
  el(InspectorControls, null,
50
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
51
  el(TextControl, {
52
  label: __('User ID', 'mycred'),
53
  help: __('Option to return a specific users balance. Use "current" to show the current users total balance.', 'mycred'),
74
  checked: total,
75
  onChange: setTotal
76
  }),
77
+ )
78
+ )
79
  ]);
80
  },
81
  save: function (props) {
includes/mycred-blocks/blocks/mycred-total-pts/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-total-pts', {
10
  title: __('Total Points', 'mycred'),
@@ -59,9 +60,9 @@
59
  });
60
 
61
  return el('div', {}, [
62
- el('p', {}, __('Total Points Shortcode', 'mycred')
63
- ),
64
  el(InspectorControls, null,
 
65
  el(TextControl, {
66
  label: __('Reference ID', 'mycred'),
67
  help: __('Option to filter results based on reference ID. Leave empty if not used', 'mycred'),
@@ -94,7 +95,8 @@
94
  checked: formatted,
95
  onChange: setFormatted
96
  }),
97
- )
 
98
  ]);
99
  },
100
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-total-pts', {
11
  title: __('Total Points', 'mycred'),
60
  });
61
 
62
  return el('div', {}, [
63
+ el('p', {}, __('Total Points Shortcode', 'mycred') ),
 
64
  el(InspectorControls, null,
65
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
66
  el(TextControl, {
67
  label: __('Reference ID', 'mycred'),
68
  help: __('Option to filter results based on reference ID. Leave empty if not used', 'mycred'),
95
  checked: formatted,
96
  onChange: setFormatted
97
  }),
98
+ )
99
+ )
100
  ]);
101
  },
102
  save: function (props) {
includes/mycred-blocks/blocks/mycred-total-since/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-total-since', {
10
  title: __('Total Since', 'mycred'),
@@ -66,9 +67,9 @@
66
  });
67
 
68
  return el('div', {}, [
69
- el('p', {}, __('Total Since Shortcode', 'mycred')
70
- ),
71
  el(InspectorControls, null,
 
72
  el(TextControl, {
73
  label: __('From', 'mycred'),
74
  help: __('Option to set from when we should start adding up points. Accepts: "today" for start of today, a UNIX timestamp or a well formatted date. See PHPs strtotime for further information on available options.', 'mycred'),
@@ -108,7 +109,8 @@
108
  checked: formatted,
109
  onChange: setFormatted
110
  }),
111
- )
 
112
  ]);
113
  },
114
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-total-since', {
11
  title: __('Total Since', 'mycred'),
67
  });
68
 
69
  return el('div', {}, [
70
+ el('p', {}, __('Total Since Shortcode', 'mycred') ),
 
71
  el(InspectorControls, null,
72
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
73
  el(TextControl, {
74
  label: __('From', 'mycred'),
75
  help: __('Option to set from when we should start adding up points. Accepts: "today" for start of today, a UNIX timestamp or a well formatted date. See PHPs strtotime for further information on available options.', 'mycred'),
109
  checked: formatted,
110
  onChange: setFormatted
111
  }),
112
+ )
113
+ )
114
  ]);
115
  },
116
  save: function (props) {
includes/mycred-blocks/blocks/mycred-transfer/index.js CHANGED
@@ -5,7 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var TextareaControl = wp.components.TextareaControl;
8
-
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-transfers', {
11
  title: __('Transfer', 'mycred'),
@@ -113,9 +113,9 @@
113
  }
114
 
115
  return el('div', {}, [
116
- el('p', {}, __('Transfer Shortcode', 'mycred')
117
- ),
118
  el(InspectorControls, null,
 
119
  el(TextControl, {
120
  label: __('Button Label', 'mycred'),
121
  help: __('The submit transfer button label. Leave empty to use the default label you set in your settings.', 'mycred'),
@@ -189,7 +189,8 @@
189
  value: balance_label,
190
  onChange: setBalanceLabel
191
  }),
192
- )
 
193
  ]);
194
  },
195
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var TextareaControl = wp.components.TextareaControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-transfers', {
11
  title: __('Transfer', 'mycred'),
113
  }
114
 
115
  return el('div', {}, [
116
+ el('p', {}, __('Transfer Shortcode', 'mycred') ),
 
117
  el(InspectorControls, null,
118
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
119
  el(TextControl, {
120
  label: __('Button Label', 'mycred'),
121
  help: __('The submit transfer button label. Leave empty to use the default label you set in your settings.', 'mycred'),
189
  value: balance_label,
190
  onChange: setBalanceLabel
191
  }),
192
+ )
193
+ )
194
  ]);
195
  },
196
  save: function (props) {
includes/mycred-blocks/blocks/mycred-users-of-all-ranks/index.js CHANGED
@@ -5,6 +5,7 @@
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
 
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-users-of-all-ranks', {
10
  title: __('Users of all ranks', 'mycred'),
@@ -79,9 +80,9 @@
79
  });
80
 
81
  return el('div', {}, [
82
- el('p', {}, __('Users of all ranks Shortcode', 'mycred')
83
- ),
84
  el(InspectorControls, null,
 
85
  el(TextControl, {
86
  label: __('Login Message', 'mycred'),
87
  help: __('Message to show for logged out users. This shortcode will not return anything if this is left empty.', 'mycred'),
@@ -125,7 +126,8 @@
125
  value: nothing,
126
  onChange: setNothing
127
  }),
128
- )
 
129
  ]);
130
  },
131
  save: function (props) {
5
  var TextControl = wp.components.TextControl;
6
  var ToggleControl = wp.components.ToggleControl;
7
  var SelectControl = wp.components.SelectControl;
8
+ var panelBody = wp.components.PanelBody;
9
  var __ = wp.i18n.__;
10
  registerBlockType('mycred-gb-blocks/mycred-users-of-all-ranks', {
11
  title: __('Users of all ranks', 'mycred'),
80
  });
81
 
82
  return el('div', {}, [
83
+ el('p', {}, __('Users of all ranks Shortcode', 'mycred') ),
 
84
  el(InspectorControls, null,
85
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
86
  el(TextControl, {
87
  label: __('Login Message', 'mycred'),
88
  help: __('Message to show for logged out users. This shortcode will not return anything if this is left empty.', 'mycred'),
126
  value: nothing,
127
  onChange: setNothing
128
  }),
129
+ )
130
+ )
131
  ]);
132
  },
133
  save: function (props) {
includes/mycred-blocks/blocks/mycred-users-of-rank/index.js CHANGED
@@ -4,6 +4,7 @@
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
 
7
  var __ = wp.i18n.__;
8
 
9
  registerBlockType('mycred-gb-blocks/mycred-users-of-rank', {
@@ -86,9 +87,9 @@
86
  });
87
 
88
  return el('div', {}, [
89
- el('p', {}, __('Users of rank Shortcode', 'mycred')
90
- ),
91
  el(InspectorControls, null,
 
92
  el(TextControl, {
93
  label: __('Rank ID', 'mycred'),
94
  help: __('The rank to list users for', 'mycred'),
@@ -142,7 +143,8 @@
142
  onChange: setPtType,
143
  options
144
  }),
145
- )
 
146
  ]);
147
  },
148
  save: function (props) {
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
+ var panelBody = wp.components.PanelBody;
8
  var __ = wp.i18n.__;
9
 
10
  registerBlockType('mycred-gb-blocks/mycred-users-of-rank', {
87
  });
88
 
89
  return el('div', {}, [
90
+ el('p', {}, __('Users of rank Shortcode', 'mycred') ),
 
91
  el(InspectorControls, null,
92
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
93
  el(TextControl, {
94
  label: __('Rank ID', 'mycred'),
95
  help: __('The rank to list users for', 'mycred'),
143
  onChange: setPtType,
144
  options
145
  }),
146
+ )
147
+ )
148
  ]);
149
  },
150
  save: function (props) {
includes/mycred-blocks/blocks/mycred-video/index.js CHANGED
@@ -4,7 +4,7 @@
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
-
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-video', {
10
  title: __('Video', 'mycred'),
@@ -35,6 +35,7 @@
35
  }
36
  },
37
  edit: function (props) {
 
38
  var video_id = props.attributes.video_id;
39
  var width = props.attributes.width;
40
  var height = props.attributes.height;
@@ -75,9 +76,9 @@
75
  });
76
 
77
  return el('div', {}, [
78
- el('p', {}, __('Video Shortcode', 'mycred')
79
- ),
80
  el(InspectorControls, null,
 
81
  el(TextControl, {
82
  label: __('Video ID', 'mycred'),
83
  help: __('Required video ID to show. No URls or embed codes! Just the video ID', 'mycred'),
@@ -126,7 +127,8 @@
126
  onChange: setPtType,
127
  options
128
  }),
129
- )
 
130
  ]);
131
  },
132
  save: function (props) {
4
  var el = wp.element.createElement;
5
  var TextControl = wp.components.TextControl;
6
  var SelectControl = wp.components.SelectControl;
7
+ var panelBody = wp.components.PanelBody;
8
  var __ = wp.i18n.__;
9
  registerBlockType('mycred-gb-blocks/mycred-video', {
10
  title: __('Video', 'mycred'),
35
  }
36
  },
37
  edit: function (props) {
38
+ console.log(props.attributes)
39
  var video_id = props.attributes.video_id;
40
  var width = props.attributes.width;
41
  var height = props.attributes.height;
76
  });
77
 
78
  return el('div', {}, [
79
+ el('p', {}, __('Video Shortcode', 'mycred') ),
 
80
  el(InspectorControls, null,
81
+ el( panelBody, { title: 'Form Settings', initialOpen: true },
82
  el(TextControl, {
83
  label: __('Video ID', 'mycred'),
84
  help: __('Required video ID to show. No URls or embed codes! Just the video ID', 'mycred'),
127
  onChange: setPtType,
128
  options
129
  }),
130
+ )
131
+ )
132
  ]);
133
  },
134
  save: function (props) {
includes/mycred-blocks/blocks/mycred-video/mycred-video.php CHANGED
@@ -33,10 +33,13 @@ if ( ! class_exists('mycred_video_block') ) :
33
  }
34
 
35
  public function render_block( $attributes, $content ) {
36
-
37
  if ( empty( $attributes['ctype'] ) )
38
  $attributes['ctype'] = 'mycred_default';
39
 
 
 
 
40
  return "[mycred_video " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
41
 
42
  }
33
  }
34
 
35
  public function render_block( $attributes, $content ) {
36
+ // var_dump($attributes['video_id']);
37
  if ( empty( $attributes['ctype'] ) )
38
  $attributes['ctype'] = 'mycred_default';
39
 
40
+ if( ! empty( $attributes['video_id'] ) )
41
+ $attributes['id'] = $attributes['video_id'];
42
+
43
  return "[mycred_video " . mycred_blocks_functions::mycred_extract_attributes( $attributes ) . "]";
44
 
45
  }
includes/mycred-blocks/mycred-blocks.php CHANGED
@@ -105,11 +105,17 @@ final class MyCred_Gutenberg {
105
  if (class_exists('myCRED_Badge_Module')) {
106
  $mycred_modules[] = 'mycred-my-badges';
107
  $mycred_modules[] = 'mycred-badges';
 
108
  }
109
 
110
  if (class_exists('myCRED_buyCRED_Module')) {
111
  $mycred_modules[] = 'mycred-buy';
112
  $mycred_modules[] = 'mycred-buy-form';
 
 
 
 
 
113
  }
114
  if (class_exists('myCRED_Coupons_Module')) {
115
  $mycred_modules[] = 'mycred-load-coupon';
@@ -130,6 +136,16 @@ final class MyCred_Gutenberg {
130
  $mycred_modules[] = 'mycred-transfer';
131
  }
132
 
 
 
 
 
 
 
 
 
 
 
133
  foreach ($mycred_modules as $mycred_module) {
134
  require_once __DIR__ . "/blocks/$mycred_module/$mycred_module.php";
135
  }
105
  if (class_exists('myCRED_Badge_Module')) {
106
  $mycred_modules[] = 'mycred-my-badges';
107
  $mycred_modules[] = 'mycred-badges';
108
+ $mycred_modules[] = 'mycred-badges-list';
109
  }
110
 
111
  if (class_exists('myCRED_buyCRED_Module')) {
112
  $mycred_modules[] = 'mycred-buy';
113
  $mycred_modules[] = 'mycred-buy-form';
114
+ $mycred_modules[] = 'mycred-buy-pending';
115
+ }
116
+
117
+ if (class_exists('myCRED_cashCRED_Module')) {
118
+ $mycred_modules[] = 'mycred-cashcred';
119
  }
120
  if (class_exists('myCRED_Coupons_Module')) {
121
  $mycred_modules[] = 'mycred-load-coupon';
136
  $mycred_modules[] = 'mycred-transfer';
137
  }
138
 
139
+ if (class_exists('myCRED_Stats_Module')) {
140
+ $mycred_modules[] = 'mycred-chart-circu';
141
+ $mycred_modules[] = 'mycred-chart-gain-loss';
142
+ $mycred_modules[] = 'mycred-chart-history';
143
+ $mycred_modules[] = 'mycred-chart-balance-history';
144
+ $mycred_modules[] = 'mycred-chart-top-balance';
145
+ $mycred_modules[] = 'mycred-chart-instance-history';
146
+ $mycred_modules[] = 'mycred-chart-top-instance';
147
+ }
148
+
149
  foreach ($mycred_modules as $mycred_module) {
150
  require_once __DIR__ . "/blocks/$mycred_module/$mycred_module.php";
151
  }
includes/mycred-depreciated.php DELETED
@@ -1,356 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- // _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' );
5
-
6
- /**
7
- * Get Settings
8
- * Returns myCRED's general settings.
9
- * @since 0.1
10
- * @version 1.0
11
- */
12
- if ( ! function_exists( 'mycred_get_settings' ) ) :
13
- function mycred_get_settings()
14
- {
15
- _deprecated_function( 'mycred_get_settings()', '1.4', 'mycred()' );
16
-
17
- return mycred();
18
- }
19
- endif;
20
-
21
- /**
22
- * myCRED Query Rankings Class
23
- * @see http://codex.mycred.me/classes/mycred_query_rankings/
24
- * @since 1.1.2
25
- * @version 1.1
26
- */
27
- if ( ! class_exists( 'myCRED_Query_Rankings' ) ) {
28
- class myCRED_Query_Rankings {
29
-
30
- public $args;
31
- public $count = 0;
32
- public $result;
33
-
34
- /**
35
- * Constructor
36
- */
37
- public function __construct( $args = '' ) {
38
- $this->args = shortcode_atts( array(
39
- 'number' => '-1',
40
- 'order' => 'DESC',
41
- 'user_fields' => 'user_login,display_name,user_email,user_nicename,user_url',
42
- 'offset' => 0,
43
- 'zero' => 1,
44
- 'type' => 'mycred_default'
45
- ), $args );
46
- }
47
-
48
- /**
49
- * Have Results
50
- * @returns true or false
51
- * @since 1.1.2
52
- * @version 1.0
53
- */
54
- public function have_results() {
55
- if ( !empty( $this->result ) ) return true;
56
-
57
- return false;
58
- }
59
-
60
- /**
61
- * Get Rankings
62
- * Queries the DB for all users in order of their point balance.
63
- * @since 1.1.2
64
- * @version 1.0.2
65
- */
66
- public function get_rankings() {
67
- global $wpdb;
68
-
69
- // Type can not be empty
70
- if ( !empty( $this->args['type'] ) )
71
- $key = $this->args['type'];
72
- else
73
- $key = 'mycred_default';
74
-
75
- // Order
76
- if ( !empty( $this->args['order'] ) )
77
- $order = $this->args['order'];
78
- else
79
- $order = 'DESC';
80
-
81
- // Number
82
- if ( $this->args['number'] != '-1' )
83
- $limit = 'LIMIT ' . abs( $this->args['offset'] ) . ',' . abs( $this->args['number'] );
84
- else
85
- $limit = '';
86
-
87
- // User fields
88
- if ( empty( $this->args['user_fields'] ) )
89
- $this->args['user_fields'] = 'display_name,user_login';
90
-
91
- $user_fields = trim( $this->args['user_fields'] );
92
- $user_fields = str_replace( ' ', '', $user_fields );
93
- $user_fields = explode( ',', $user_fields );
94
-
95
- // SELECT
96
- $selects = array( "{$wpdb->users}.ID" );
97
- foreach ( $user_fields as $field ) {
98
- if ( $field == 'ID' ) continue;
99
- $selects[] = "{$wpdb->users}." . $field;
100
- }
101
- $selects[] = "{$wpdb->usermeta}.meta_value AS cred";
102
- $select = implode( ', ', $selects );
103
-
104
- // WHERE
105
- $where = '';
106
- if ( $this->args['zero'] )
107
- $where = "WHERE {$wpdb->usermeta}.meta_value > 0 ";
108
-
109
- $SQL = apply_filters( 'mycred_ranking_sql', "
110
- SELECT {$select}
111
- FROM {$wpdb->users}
112
- LEFT JOIN {$wpdb->usermeta}
113
- ON {$wpdb->users}.ID = {$wpdb->usermeta}.user_id
114
- AND {$wpdb->usermeta}.meta_key = %s
115
- {$where}
116
- ORDER BY {$wpdb->usermeta}.meta_value+1 {$order} {$limit};", $this->args, $wpdb );
117
-
118
- $this->result = $wpdb->get_results( $wpdb->prepare( $SQL, $key ), 'ARRAY_A' );
119
- $this->count = $wpdb->num_rows;
120
- }
121
-
122
- /**
123
- * Save
124
- * With the option to reset and bypass any set frequency.
125
- * If a frequency is set to something other then 'always', then that
126
- * setting is enforced.
127
- * @since 1.1.2
128
- * @version 1.0
129
- */
130
- public function save( $reset = false ) {
131
-
132
- }
133
- }
134
- }
135
-
136
- /**
137
- * myCRED_Rankings class
138
- * @see http://codex.mycred.me/classes/mycred_rankings/
139
- * @since 0.1
140
- * @version 2.0
141
- */
142
- if ( !class_exists( 'myCRED_Rankings' ) ) {
143
- class myCRED_Rankings {
144
-
145
- public $core;
146
- public $args;
147
- public $result;
148
-
149
- /**
150
- * Constructor
151
- */
152
- public function __construct( $args = array(), $results = array() ) {
153
- // Get settings
154
- $mycred = mycred();
155
- $this->core = $mycred;
156
- $this->args = $args;
157
- $this->result = $results;
158
- }
159
-
160
- /**
161
- * Have Results
162
- * @returns true or false
163
- * @since 0.1
164
- * @version 1.1
165
- */
166
- public function have_results() {
167
- if ( !empty( $this->result ) ) return true;
168
- return false;
169
- }
170
-
171
- /**
172
- * Users Position
173
- * @param $user_id (int) required user id
174
- * @returns position (int)
175
- * @since 0.1
176
- * @version 1.1
177
- */
178
- public function users_position( $user_id = NULL ) {
179
- if ( $user_id !== NULL ) {
180
- if ( $this->have_results() ) {
181
- foreach ( $this->result as $row_id => $row_data ) {
182
- if ( !isset( $row_data['ID'] ) ) $row_uid = $row_data['user_id'];
183
- else $row_uid = $row_data['ID'];
184
-
185
- if ( $row_uid == (int) $user_id ) return $row_id+1;
186
- }
187
- }
188
- }
189
-
190
- return 0;
191
- }
192
-
193
- /**
194
- * Users Creds
195
- * @param $user_id (int) user id
196
- * @returns position (int) or empty
197
- * @since 0.1
198
- * @version 1.1
199
- */
200
- public function users_creds( $user_id = NULL ) {
201
- if ( $user_id !== NULL ) {
202
- if ( $this->have_results() ) {
203
- foreach ( $this->result as $row_id => $row_data ) {
204
- if ( !isset( $row_data['ID'] ) ) $row_uid = $row_data['user_id'];
205
- else $row_uid = $row_data['ID'];
206
-
207
- if ( $row_uid == (int) $user_id ) return $row_data['creds'];
208
- }
209
- }
210
- }
211
-
212
- return 0;
213
- }
214
-
215
- /**
216
- * Leaderboard
217
- * @since 0.1
218
- * @version 1.0
219
- */
220
- public function leaderboard() {
221
- echo $this->get_leaderboard();
222
- }
223
-
224
- /**
225
- * Get Leaderboard
226
- * @since 0.1
227
- * @version 1.1
228
- */
229
- public function get_leaderboard() {
230
- return '<ol class="myCRED-leaderboard">' . $this->loop( 'li' ) . '</ol>';
231
- }
232
-
233
- /**
234
- * Leaderboard Loop
235
- * @since 1.1.2
236
- * @version 1.0.2
237
- */
238
- public function loop( $wrap = '' ) {
239
- // Default template
240
- if ( empty( $this->args['template'] ) ) $this->args['template'] = '#%ranking% %user_profile_link% %cred_f%';
241
- $output = '';
242
-
243
- // Loop
244
- foreach ( $this->result as $position => $row ) {
245
- // Prep
246
- $class = array();
247
-
248
- // Classes
249
- $class[] = 'item-' . $position;
250
- if ( $position == 0 )
251
- $class[] = 'first-item';
252
-
253
- if ( $position % 2 != 0 )
254
- $class[] = 'alt';
255
-
256
- // Template Tags
257
- if ( !function_exists( 'mycred_get_users_rank' ) )
258
- $layout = str_replace( array( '%rank%', '%ranking%' ), $position+1, $this->args['template'] );
259
- else
260
- $layout = str_replace( '%ranking%', $position+1, $this->args['template'] );
261
-
262
- $layout = $this->core->template_tags_amount( $layout, $row['cred'] );
263
- $layout = $this->core->template_tags_user( $layout, false, $row );
264
-
265
- // Wrapper
266
- if ( !empty( $wrap ) )
267
- $layout = '<' . $wrap . ' class="%classes%">' . $layout . '</' . $wrap . '>';
268
-
269
- $layout = str_replace( '%classes%', apply_filters( 'mycred_ranking_classes', implode( ' ', $class ) ), $layout );
270
- $layout = apply_filters( 'mycred_ranking_row', $layout, $this->args['template'], $row, $position+1 );
271
-
272
- $output .= $layout . "\n";
273
- }
274
-
275
- return $output;
276
- }
277
- }
278
- }
279
-
280
- /**
281
- * Get myCRED Rankings
282
- * Returns the myCRED_Rankings object containing results.
283
- *
284
- * @param $args (array) optional array of arguments for the ranking
285
- * @var number (int) number of results to return
286
- * @var order (string) ASC to return with lowest creds or DESC to return highest creds first
287
- * @var user_fields (string) comma seperated list of table columns to return with each user.
288
- * @var offset (int) optional number to start from when returning records. defaults to zero (first result)
289
- * @var type (string) optional points type
290
- * @var template (string) if this function is called to create a leaderboard this string can contain the template
291
- * for each user
292
- * @uses myCRED_Query_Rankings()
293
- * @uses myCRED_Rankings()
294
- * @returns class object
295
- * @since 0.1
296
- * @version 2.0
297
- */
298
- if ( !function_exists( 'mycred_rankings' ) ) {
299
- function mycred_rankings( $args = array(), $reset = false )
300
- {
301
- $default = array(
302
- 'number' => '-1',
303
- 'order' => 'DESC',
304
- 'user_fields' => 'user_login,display_name,user_email,user_nicename,user_url',
305
- 'offset' => 0,
306
- 'type' => 'mycred_default',
307
- 'template' => '#%ranking% %user_profile_link% %cred_f%'
308
- );
309
- $args = shortcode_atts( $default, $args );
310
- $diff = array_diff( $args, $default );
311
-
312
- global $mycred_rankings;
313
-
314
- $_rankings = get_transient( $args['type'] . '_ranking' );
315
- // Transient is missing or request for reset
316
- if ( false === $_rankings || true === $reset ) {
317
- $ranking = new myCRED_Query_Rankings( array( 'type' => $args['type'] ) );
318
- $ranking->get_rankings();
319
- //$ranking->save( $reset );
320
-
321
- $_rankings = $ranking->result;
322
- }
323
- // Else if arguments are not the default and a new query is required
324
- elseif ( !empty( $diff ) ) {
325
- $ranking = new myCRED_Query_Rankings( $args );
326
- $ranking->get_rankings();
327
-
328
- $_rankings = $ranking->result;
329
- }
330
- $mycred_rankings = new myCRED_Rankings( $args, $_rankings );
331
-
332
- return $mycred_rankings;
333
- }
334
- }
335
-
336
- /**
337
- * Get Users Position
338
- * Returns a given users position in the ranking list.
339
- *
340
- * @param $user_id (int) required user id
341
- * @param $type (string) optional points type
342
- * @returns position (int) or empty if no record could be made
343
- * @since 0.1
344
- * @version 1.1
345
- */
346
- if ( !function_exists( 'mycred_rankings_position' ) ) {
347
- function mycred_rankings_position( $user_id = '', $type = 'mycred_default' )
348
- {
349
- $rankings = mycred_rankings( array( 'type' => $type ) );
350
- return $rankings->users_position( $user_id );
351
- }
352
- }
353
-
354
-
355
-
356
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mycred-functions.php CHANGED
@@ -421,7 +421,7 @@ if ( ! class_exists( 'myCRED_Settings' ) ) :
421
  * @since 0.1
422
  * @version 1.0
423
  */
424
- public function parse_template_tags( $content = '', $log_entry ) {
425
 
426
  // Prep
427
  $reference = $log_entry->ref;
@@ -3576,7 +3576,7 @@ endif;
3576
  * @version 1.0.1
3577
  */
3578
  if ( ! function_exists( 'mycred_translate_limit_code' ) ) :
3579
- function mycred_translate_limit_code( $code = '', $id, $mycred ) {
3580
 
3581
  if ( $code == '' ) return '-';
3582
 
421
  * @since 0.1
422
  * @version 1.0
423
  */
424
+ public function parse_template_tags( $content, $log_entry ) {
425
 
426
  // Prep
427
  $reference = $log_entry->ref;
3576
  * @version 1.0.1
3577
  */
3578
  if ( ! function_exists( 'mycred_translate_limit_code' ) ) :
3579
+ function mycred_translate_limit_code( $code, $id, $mycred ) {
3580
 
3581
  if ( $code == '' ) return '-';
3582
 
includes/mycred-importer.php DELETED
@@ -1,107 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * Register Importer: Log Entries
6
- * @since 1.4
7
- * @version 1.0
8
- */
9
- register_importer(
10
- 'mycred_import_log',
11
- sprintf( __( '%s Log Import', 'mycred' ), mycred_label() ),
12
- __( 'Import log entries via a CSV file.', 'mycred' ),
13
- 'mycred_importer_log_entries'
14
- );
15
-
16
- /**
17
- * Load Importer: Log Entries
18
- * @since 1.4
19
- * @version 1.0
20
- */
21
- function mycred_importer_log_entries() {
22
- require_once( ABSPATH . 'wp-admin/includes/import.php' );
23
-
24
- if ( ! class_exists( 'WP_Importer' ) ) {
25
- $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
26
- if ( file_exists( $class_wp_importer ) )
27
- require $class_wp_importer;
28
- }
29
-
30
- require_once( myCRED_INCLUDES_DIR . 'importers/mycred-log-entries.php' );
31
-
32
- $importer = new myCRED_Importer_Log_Entires();
33
- $importer->load();
34
- }
35
-
36
- /**
37
- * Register Importer: Balances
38
- * @since 1.4.2
39
- * @version 1.0
40
- */
41
- register_importer(
42
- 'mycred_import_balance',
43
- sprintf( __( '%s Balance Import', 'mycred' ), mycred_label() ),
44
- __( 'Import balances.', 'mycred' ),
45
- 'mycred_importer_point_balances'
46
- );
47
-
48
- /**
49
- * Load Importer: Point Balances
50
- * @since 1.4
51
- * @version 1.0
52
- */
53
- function mycred_importer_point_balances() {
54
- require_once( ABSPATH . 'wp-admin/includes/import.php' );
55
-
56
- if ( ! class_exists( 'WP_Importer' ) ) {
57
- $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
58
- if ( file_exists( $class_wp_importer ) )
59
- require $class_wp_importer;
60
- }
61
-
62
- require_once( myCRED_INCLUDES_DIR . 'importers/mycred-balances.php' );
63
-
64
- $importer = new myCRED_Importer_Balances();
65
- $importer->load();
66
- }
67
-
68
- /**
69
- * Register Importer: CubePoints
70
- * @since 1.4
71
- * @version 1.0
72
- */
73
- register_importer(
74
- 'mycred_import_cp',
75
- sprintf( __( '%s CubePoints Import', 'mycred' ), mycred_label() ),
76
- __( 'Import CubePoints log entries and / or balances.', 'mycred' ),
77
- 'mycred_importer_cubepoints'
78
- );
79
-
80
- /**
81
- * Load Importer: CubePoints
82
- * @since 1.4
83
- * @version 1.0
84
- */
85
- function mycred_importer_cubepoints() {
86
- require_once( ABSPATH . 'wp-admin/includes/import.php' );
87
-
88
- global $wpdb;
89
-
90
- // No use continuing if there is no log to import
91
- if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s;", $wpdb->prefix . 'cp' ) ) == 0 ) {
92
- echo '<p>' . __( 'No CubePoints log exists.', 'mycred' ) . '</p>';
93
- return;
94
- }
95
-
96
- if ( ! class_exists( 'WP_Importer' ) ) {
97
- $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php';
98
- if ( file_exists( $class_wp_importer ) )
99
- require $class_wp_importer;
100
- }
101
-
102
- require_once( myCRED_INCLUDES_DIR . 'importers/mycred-cubepoints.php' );
103
-
104
- $importer = new myCRED_Importer_CubePoints();
105
- $importer->load();
106
- }
107
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mycred-leaderboard.php DELETED
@@ -1,320 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * Get myCRED Leaderboard
6
- * Returns the myCRED_Leaderboard object containing results.
7
- *
8
- * @param $args (array) optional array of arguments for the ranking
9
- * @var number (int) number of results to return
10
- * @var order (string) ASC to return with lowest creds or DESC to return highest creds first
11
- * @var user_fields (string) comma seperated list of table columns to return with each user.
12
- * @var offset (int) optional number to start from when returning records. defaults to zero (first result)
13
- * @var type (string) optional points type
14
- * @var template (string) if this function is called to create a leaderboard this string can contain the template
15
- * for each user
16
- * @uses myCRED_Query_Rankings()
17
- * @uses myCRED_Rankings()
18
- * @returns class object
19
- * @since 1.4
20
- * @version 1.0
21
- */
22
- if ( ! function_exists( 'mycred_get_leaderboard' ) ) :
23
- function mycred_get_leaderboard( $args = array(), $reset = false, $raw = false )
24
- {
25
- $default = array(
26
- 'number' => '-1',
27
- 'order' => 'DESC',
28
- 'user_fields' => 'user_login,display_name,user_email,user_nicename,user_url',
29
- 'offset' => 0,
30
- 'type' => 'mycred_default',
31
- 'template' => '#%ranking% %user_profile_link% %cred_f%'
32
- );
33
- $args = shortcode_atts( $default, $args );
34
-
35
- return new myCRED_Query_Leaderboard( $args );
36
- }
37
- endif;
38
-
39
- /**
40
- * Get Users Position
41
- * Returns a given users position in the leaderboard.
42
- *
43
- * @param $user_id (int) required user id
44
- * @param $type (string) optional points type
45
- * @returns position (int) or empty if no record could be made
46
- * @since 1.4
47
- * @version 1.0
48
- */
49
- if ( ! function_exists( 'mycred_leaderboard_position' ) ) :
50
- function mycred_leaderboard_position( $user_id = '', $type = 'mycred_default' )
51
- {
52
- $args = array( 'type' => $type );
53
- $rankings = mycred_get_leaderboard( $args);
54
- $leaderboard = new myCRED_Leaderboard( $args, $rankings->get_results() );
55
- return apply_filters( 'mycred_get_leaderboard_position', $leaderboard->users_position( $user_id ), $user_id, $type );
56
- }
57
- endif;
58
-
59
- /**
60
- * myCRED Query Leaderboard Class
61
- * @see http://codex.mycred.me/classes/mycred_query_leaderboard/
62
- * @since 1.4
63
- * @version 1.0
64
- */
65
- if ( ! class_exists( 'myCRED_Query_Leaderboard' ) ) :
66
- class myCRED_Query_Leaderboard {
67
-
68
- public $args;
69
- public $count = 0;
70
- public $result;
71
-
72
- /**
73
- * Constructor
74
- */
75
- public function __construct( $args = '' ) {
76
- $this->args = shortcode_atts( array(
77
- 'number' => 10,
78
- 'order' => 'DESC',
79
- 'user_fields' => 'user_login,display_name,user_email,user_nicename,user_url',
80
- 'offset' => 0,
81
- 'zero' => 1,
82
- 'type' => 'mycred_default'
83
- ), $args );
84
- }
85
-
86
- /**
87
- * Have Results
88
- * @returns true or false
89
- * @since 1.1.2
90
- * @version 1.0
91
- */
92
- public function have_results() {
93
- if ( ! empty( $this->result ) ) return true;
94
-
95
- return false;
96
- }
97
-
98
- /**
99
- * Get Leaderboard
100
- * Queries the DB for all users in order of their point balance.
101
- * @since 1.1.2
102
- * @version 1.0.2
103
- */
104
- public function get_results() {
105
- global $wpdb;
106
-
107
- // Type can not be empty
108
- if ( ! empty( $this->args['type'] ) )
109
- $key = $this->args['type'];
110
- else
111
- $key = 'mycred_default';
112
-
113
- // Order
114
- if ( ! empty( $this->args['order'] ) )
115
- $order = $this->args['order'];
116
- else
117
- $order = 'DESC';
118
-
119
- // Number
120
- if ( $this->args['number'] != '-1' )
121
- $limit = 'LIMIT ' . abs( $this->args['offset'] ) . ',' . abs( $this->args['number'] );
122
- else
123
- $limit = '';
124
-
125
- // User fields
126
- if ( empty( $this->args['user_fields'] ) )
127
- $this->args['user_fields'] = 'display_name,user_login';
128
-
129
- $user_fields = trim( $this->args['user_fields'] );
130
- $user_fields = str_replace( ' ', '', $user_fields );
131
- $user_fields = explode( ',', $user_fields );
132
-
133
- // SELECT
134
- $selects = array( "{$wpdb->users}.ID" );
135
- foreach ( $user_fields as $field ) {
136
- if ( $field == 'ID' ) continue;
137
- $selects[] = "{$wpdb->users}." . $field;
138
- }
139
- $selects[] = "{$wpdb->usermeta}.meta_value AS cred";
140
- $select = implode( ', ', $selects );
141
-
142
- // WHERE
143
- $where = '';
144
- if ( $this->args['zero'] )
145
- $where = "WHERE {$wpdb->usermeta}.meta_value > 0 ";
146
-
147
- $SQL = apply_filters( 'mycred_ranking_sql', "
148
- SELECT {$select}
149
- FROM {$wpdb->users}
150
- LEFT JOIN {$wpdb->usermeta}
151
- ON {$wpdb->users}.ID = {$wpdb->usermeta}.user_id
152
- AND {$wpdb->usermeta}.meta_key = %s
153
- {$where}
154
- ORDER BY {$wpdb->usermeta}.meta_value+1 {$order} {$limit};", $this->args, $wpdb );
155
-
156
- $this->result = $wpdb->get_results( $wpdb->prepare( $SQL, $key ), 'ARRAY_A' );
157
- $this->count = $wpdb->num_rows;
158
- }
159
-
160
- /**
161
- * Save
162
- * With the option to reset and bypass any set frequency.
163
- * If a frequency is set to something other then 'always', then that
164
- * setting is enforced.
165
- * @since 1.1.2
166
- * @version 1.0
167
- */
168
- public function save( $reset = false ) {
169
- // No longer used
170
- }
171
- }
172
- endif;
173
-
174
- /**
175
- * myCRED_Rankings class
176
- * @see http://codex.mycred.me/classes/mycred_leaderboard/
177
- * @since 1.4
178
- * @version 1.0
179
- */
180
- if ( ! class_exists( 'myCRED_Leaderboard' ) ) :
181
- class myCRED_Leaderboard {
182
-
183
- public $core;
184
- public $args;
185
- public $result;
186
-
187
- /**
188
- * Constructor
189
- */
190
- public function __construct( $args = array(), $results = array() ) {
191
- if ( ! isset( $args['type'] ) || empty( $args['type'] ) )
192
- $args['type'] = 'mycred_default';
193
-
194
- // Get settings
195
- $mycred = mycred( $args['type'] );
196
- $this->core = $mycred;
197
- $this->args = $args;
198
- $this->result = $results;
199
- }
200
-
201
- /**
202
- * Have Results
203
- * @returns true or false
204
- * @since 0.1
205
- * @version 1.1
206
- */
207
- public function have_results() {
208
- if ( ! empty( $this->result ) ) return true;
209
- return false;
210
- }
211
-
212
- /**
213
- * Users Position
214
- * @param $user_id (int) required user id
215
- * @returns position (int)
216
- * @since 0.1
217
- * @version 1.1
218
- */
219
- public function users_position( $user_id = NULL ) {
220
- if ( $user_id !== NULL ) {
221
- if ( $this->have_results() ) {
222
- foreach ( $this->result as $row_id => $row_data ) {
223
- if ( ! isset( $row_data['ID'] ) ) $row_uid = $row_data['user_id'];
224
- else $row_uid = $row_data['ID'];
225
-
226
- if ( $row_uid == (int) $user_id ) return $row_id+1;
227
- }
228
- }
229
- }
230
-
231
- return 0;
232
- }
233
-
234
- /**
235
- * Users Creds
236
- * @param $user_id (int) user id
237
- * @returns position (int) or empty
238
- * @since 0.1
239
- * @version 1.1
240
- */
241
- public function users_creds( $user_id = NULL ) {
242
- if ( $user_id !== NULL ) {
243
- if ( $this->have_results() ) {
244
- foreach ( $this->result as $row_id => $row_data ) {
245
- if ( ! isset( $row_data['ID'] ) ) $row_uid = $row_data['user_id'];
246
- else $row_uid = $row_data['ID'];
247
-
248
- if ( $row_uid == (int) $user_id ) return $row_data['creds'];
249
- }
250
- }
251
- }
252
-
253
- return 0;
254
- }
255
-
256
- /**
257
- * Leaderboard
258
- * @since 0.1
259
- * @version 1.0
260
- */
261
- public function leaderboard() {
262
- echo $this->get_leaderboard();
263
- }
264
-
265
- /**
266
- * Get Leaderboard
267
- * @since 0.1
268
- * @version 1.1
269
- */
270
- public function get_leaderboard() {
271
- return '<ol class="myCRED-leaderboard">' . $this->loop( 'li' ) . '</ol>';
272
- }
273
-
274
- /**
275
- * Leaderboard Loop
276
- * @since 1.1.2
277
- * @version 1.0.2
278
- */
279
- public function loop( $wrap = '' ) {
280
- // Default template
281
- if ( empty( $this->args['template'] ) ) $this->args['template'] = '#%ranking% %user_profile_link% %cred_f%';
282
- $output = '';
283
-
284
- // Loop
285
- foreach ( $this->result as $position => $row ) {
286
- // Prep
287
- $class = array();
288
-
289
- // Classes
290
- $class[] = 'item-' . $position;
291
- if ( $position == 0 )
292
- $class[] = 'first-item';
293
-
294
- if ( $position % 2 != 0 )
295
- $class[] = 'alt';
296
-
297
- // Template Tags
298
- if ( ! function_exists( 'mycred_get_users_rank' ) )
299
- $layout = str_replace( array( '%rank%', '%ranking%' ), $position+1, $this->args['template'] );
300
- else
301
- $layout = str_replace( '%ranking%', $position+1, $this->args['template'] );
302
-
303
- $layout = $this->core->template_tags_amount( $layout, $row['cred'] );
304
- $layout = $this->core->template_tags_user( $layout, false, $row );
305
-
306
- // Wrapper
307
- if ( ! empty( $wrap ) )
308
- $layout = '<' . $wrap . ' class="%classes%">' . $layout . '</' . $wrap . '>';
309
-
310
- $layout = str_replace( '%classes%', apply_filters( 'mycred_ranking_classes', implode( ' ', $class ) ), $layout );
311
- $layout = apply_filters( 'mycred_ranking_row', $layout, $this->args['template'], $row, $position+1 );
312
-
313
- $output .= $layout . "\n";
314
- }
315
-
316
- return $output;
317
- }
318
- }
319
- endif;
320
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mycred-log.php DELETED
@@ -1,902 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * Query Log
6
- * @see http://codex.mycred.me/classes/mycred_query_log/
7
- * @since 0.1
8
- * @version 1.4.1
9
- */
10
- if ( ! class_exists( 'myCRED_Query_Log' ) ) :
11
- class myCRED_Query_Log {
12
-
13
- public $args;
14
- public $request;
15
- public $prep;
16
- public $num_rows;
17
- public $max_num_pages;
18
- public $total_rows;
19
-
20
- public $results;
21
-
22
- public $headers;
23
- public $core;
24
-
25
- /**
26
- * Construct
27
- */
28
- public function __construct( $args = array(), $array = false ) {
29
- if ( empty( $args ) ) return false;
30
-
31
- global $wpdb;
32
-
33
- $select = $where = $sortby = $limits = '';
34
- $prep = $wheres = array();
35
-
36
- // Load General Settings
37
- if ( isset( $args['ctype'] ) )
38
- $type = $args['ctype'];
39
- else
40
- $type = 'mycred_default';
41
-
42
- $this->core = mycred( $type );
43
- if ( $this->core->format['decimals'] > 0 )
44
- $format = '%f';
45
- else
46
- $format = '%d';
47
-
48
- // Prep Defaults
49
- $defaults = array(
50
- 'user_id' => NULL,
51
- 'ctype' => 'mycred_default',
52
- 'number' => 25,
53
- 'time' => NULL,
54
- 'ref' => NULL,
55
- 'ref_id' => NULL,
56
- 'amount' => NULL,
57
- 's' => NULL,
58
- 'data' => NULL,
59
- 'orderby' => 'time',
60
- 'offset' => '',
61
- 'order' => 'DESC',
62
- 'ids' => false,
63
- 'cache' => '',
64
- 'paged' => $this->get_pagenum()
65
- );
66
- $this->args = mycred_apply_defaults( $defaults, $args );
67
-
68
- // Difference between default and given args
69
- $this->diff = array_diff_assoc( $this->args, $defaults );
70
- if ( isset( $this->diff['number'] ) )
71
- unset( $this->diff['number'] );
72
-
73
- $data = false;
74
- if ( $this->args['cache'] != '' ) {
75
- $cache_id = substr( $this->args['cache'], 0, 23 );
76
- if ( is_multisite() )
77
- $data = get_site_transient( 'mycred_log_query_' . $cache_id );
78
- else
79
- $data = get_transient( 'mycred_log_query_' . $cache_id );
80
- }
81
- if ( $data === false ) {
82
-
83
- // Type
84
- $wheres[] = 'ctype = %s';
85
- $prep[] = $this->args['ctype'];
86
-
87
- // User ID
88
- if ( $this->args['user_id'] !== NULL && $this->args['user_id'] != '' ) {
89
- $wheres[] = 'user_id = %d';
90
- $prep[] = abs( $this->args['user_id'] );
91
- }
92
-
93
- // Reference
94
- if ( $this->args['ref'] !== NULL && $this->args['ref'] != '' ) {
95
- $refs = explode( ',', $this->args['ref'] );
96
- $ref_count = count( $refs );
97
- if ( $ref_count > 1 ) {
98
- $ref_count = $ref_count-1;
99
- $wheres[] = 'ref IN (%s' . str_repeat( ',%s', $ref_count ) . ')';
100
- foreach ( $refs as $ref )
101
- $prep[] = sanitize_text_field( $ref );
102
- }
103
- else {
104
- $wheres[] = 'ref = %s';
105
- $prep[] = sanitize_text_field( $refs[0] );
106
- }
107
- }
108
-
109
- // Reference ID
110
- if ( $this->args['ref_id'] !== NULL && $this->args['ref_id'] != '' ) {
111
- $ref_ids = explode( ',', $this->args['ref_id'] );
112
- if ( count( $ref_ids ) > 1 ) {
113
- $ref_id_count = count( $ref_ids )-1;
114
- $wheres[] = 'ref_id IN (%d' . str_repeat( ',%d', $ref_id_count ) . ')';
115
- foreach ( $ref_ids as $ref_id )
116
- $prep[] = (int) sanitize_text_field( $ref_id );
117
- }
118
- else {
119
- $wheres[] = 'ref_id = %d';
120
- $prep[] = (int) sanitize_text_field( $ref_ids[0] );
121
- }
122
- }
123
-
124
- // Amount
125
- if ( $this->args['amount'] !== NULL && $this->args['amount'] != '' ) {
126
- // Advanced query
127
- if ( is_array( $this->args['amount'] ) ) {
128
- // Range
129
- if ( isset( $this->args['amount']['start'] ) && isset( $this->args['amount']['end'] ) ) {
130
- $wheres[] = 'creds BETWEEN ' . $format . ' AND ' . $format;
131
- $prep[] = $this->core->number( sanitize_text_field( $this->args['amount']['start'] ) );
132
- $prep[] = $this->core->number( sanitize_text_field( $this->args['amount']['end'] ) );
133
- }
134
- // Compare
135
- elseif ( isset( $this->args['amount']['num'] ) && isset( $this->args['amount']['compare'] ) ) {
136
- $compare = urldecode( $this->args['amount']['compare'] );
137
- $wheres[] = 'creds ' . trim( $compare ) . ' ' . $format;
138
- $prep[] = $this->core->number( sanitize_text_field( $this->args['amount']['num'] ) );
139
- }
140
- }
141
- // Specific amount(s)
142
- else {
143
- $amounts = explode( ',', $this->args['amount'] );
144
- $amount_count = count( $amounts );
145
- if ( $amount_count > 1 ) {
146
- $amount_count = $amount_count-1;
147
- $wheres[] = 'amount IN (' . $format . str_repeat( ',' . $format, $ref_id_count ) . ')';
148
- foreach ( $amount_count as $amount )
149
- $prep[] = $this->core->number( sanitize_text_field( $amount ) );
150
- }
151
- else {
152
- $wheres[] = 'creds = ' . $format;
153
- $prep[] = $this->core->number( sanitize_text_field( $amounts[0] ) );
154
- }
155
- }
156
- }
157
-
158
- // Time
159
- if ( $this->args['time'] !== NULL && $this->args['time'] != '' ) {
160
- $now = date_i18n( 'U' );
161
- $today = strtotime( date_i18n( 'Y/m/d' ) . ' midnight' );
162
- $todays_date = date_i18n( 'd' );
163
-
164
- // Show todays entries
165
- if ( $this->args['time'] == 'today' ) {
166
- $wheres[] = "time BETWEEN $today AND $now";
167
- }
168
- // Show yesterdays entries
169
- elseif ( $this->args['time'] == 'yesterday' ) {
170
- $yesterday = strtotime( '-1 day midnight' );
171
- $wheres[] = "time BETWEEN $yesterday AND $today";
172
- }
173
- // Show this weeks entries
174
- elseif ( $this->args['time'] == 'thisweek' ) {
175
- $weekday = date_i18n( 'w' );
176
- // New week started today so show only todays
177
- if ( get_option( 'start_of_week' ) == $weekday ) {
178
- $wheres[] = "time BETWEEN $today AND $now";
179
- }
180
- // Show rest of this week
181
- else {
182
- $week_start = strtotime( '-' . ( $weekday+1 ) . ' days midnight' );
183
- $wheres[] = "time BETWEEN $week_start AND $now";
184
- }
185
- }
186
- // Show this months entries
187
- elseif ( $this->args['time'] == 'thismonth' ) {
188
- $start_of_month = strtotime( date_i18n( 'Y/m/01' ) . ' midnight' );
189
- $wheres[] = "time BETWEEN $start_of_month AND $now";
190
- }
191
- else {
192
- $times = explode( ',', $this->args['time'] );
193
- if ( count( $times ) == 2 ) {
194
- $from = sanitize_key( $times[0] );
195
- $to = sanitize_key( $times[1] );
196
- $wheres[] = "time BETWEEN $from AND $to";
197
- }
198
- }
199
- }
200
-
201
- // Entry Search
202
- if ( $this->args['s'] !== NULL && $this->args['s'] != '' ) {
203
- $search_query = sanitize_text_field( $this->args['s'] );
204
-
205
- if ( is_int( $search_query ) )
206
- $search_query = (string) $search_query;
207
-
208
- $wheres[] = "entry LIKE %s";
209
- $prep[] = "%$search_query%";
210
- }
211
-
212
- // Data
213
- if ( $this->args['data'] !== NULL && $this->args['data'] != '' ) {
214
- $data_query = sanitize_text_field( $this->args['data'] );
215
-
216
- if ( is_int( $data_query ) )
217
- $data_query = (string) $data_query;
218
-
219
- $wheres[] = "data LIKE %s";
220
- $prep[] = $data_query;
221
- }
222
-
223
- // Order by
224
- if ( $this->args['orderby'] != '' ) {
225
- // Make sure $sortby is valid
226
- $sortbys = array( 'id', 'ref', 'ref_id', 'user_id', 'creds', 'ctype', 'entry', 'data', 'time' );
227
- $allowed = apply_filters( 'mycred_allowed_sortby', $sortbys );
228
- if ( in_array( $this->args['orderby'], $allowed ) ) {
229
- $sortby = "ORDER BY " . $this->args['orderby'] . " " . $this->args['order'];
230
- }
231
- }
232
-
233
- // Number of results
234
- $number = $this->args['number'];
235
- if ( $number < -1 )
236
- $number = abs( $number );
237
- elseif ( $number == 0 || $number == -1 )
238
- $number = NULL;
239
-
240
- // Limits
241
- if ( $number !== NULL ) {
242
- $page = 1;
243
- if ( $this->args['paged'] !== NULL ) {
244
- $page = absint( $this->args['paged'] );
245
- if ( ! $page )
246
- $page = 1;
247
- }
248
-
249
- if ( $this->args['offset'] != '' ) {
250
- $pgstrt = ($page - 1) * $number . ', ';
251
- }
252
- else {
253
- $offset = absint( $this->args['offset'] );
254
- $pgstrt = $offset . ', ';
255
- }
256
-
257
- $limits = 'LIMIT ' . $pgstrt . $number;
258
- }
259
- else {
260
- $limits = '';
261
- }
262
-
263
- // Prep return
264
- if ( $this->args['ids'] === true )
265
- $select = 'id';
266
- else
267
- $select = '*';
268
-
269
- $found_rows = '';
270
- if ( $limits != '' )
271
- $found_rows = 'SQL_CALC_FOUND_ROWS';
272
-
273
- // Filter
274
- $select = apply_filters( 'mycred_query_log_select', $select, $this->args, $this->core );
275
- $sortby = apply_filters( 'mycred_query_log_sortby', $sortby, $this->args, $this->core );
276
- $limits = apply_filters( 'mycred_query_log_limits', $limits, $this->args, $this->core );
277
- $wheres = apply_filters( 'mycred_query_log_wheres', $wheres, $this->args, $this->core );
278
-
279
- $prep = apply_filters( 'mycred_query_log_prep', $prep, $this->args, $this->core );
280
-
281
- $where = 'WHERE ' . implode( ' AND ', $wheres );
282
-
283
- // Run
284
- $this->request = $wpdb->prepare( "SELECT {$found_rows} {$select} FROM {$this->core->log_table} {$where} {$sortby} {$limits}", $prep );
285
- $this->prep = $prep;
286
-
287
- $this->results = $wpdb->get_results( $this->request, $array ? ARRAY_A : OBJECT );
288
-
289
- if ( $limits != '' )
290
- $this->num_rows = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
291
- else
292
- $this->num_rows = count( $this->results );
293
-
294
- if ( $limits != '' )
295
- $this->max_num_pages = ceil( $this->num_rows / $number );
296
-
297
- if ( $this->args['cache'] != '' ) {
298
- if ( is_multisite() )
299
- set_site_transient( 'mycred_log_query_' . $cache_id, $this->results, DAY_IN_SECONDS * 1 );
300
- else
301
- set_transient( 'mycred_log_query_' . $cache_id, $this->results, DAY_IN_SECONDS * 1 );
302
- }
303
-
304
- $this->total_rows = $wpdb->get_var( "SELECT COUNT( * ) FROM {$this->core->log_table}" );
305
- }
306
-
307
- // Return the transient
308
- else {
309
- $this->request = 'transient';
310
- $this->results = $data;
311
- $this->prep = '';
312
-
313
- $this->num_rows = count( $data );
314
- }
315
-
316
- $this->headers = $this->table_headers();
317
- }
318
-
319
- /**
320
- * Has Entries
321
- * @returns true or false
322
- * @since 0.1
323
- * @version 1.0
324
- */
325
- public function have_entries() {
326
- if ( ! empty( $this->results ) ) return true;
327
- return false;
328
- }
329
-
330
- /**
331
- * Table Nav
332
- * @since 0.1
333
- * @version 1.1
334
- */
335
- public function table_nav( $location = 'top', $is_profile = false ) {
336
- if ( $location == 'top' ) {
337
-
338
- $this->filter_options( $is_profile );
339
- $this->navigation( $location );
340
-
341
- }
342
- else {
343
-
344
- $this->navigation( $location );
345
-
346
- }
347
- }
348
-
349
- /**
350
- * Item Count
351
- * @since 0.1
352
- * @version 1.1
353
- */
354
- public function navigation( $location = 'top', $id = '' ) { ?>
355
-
356
- <div class="tablenav-pages<?php if ( $this->max_num_pages == 1 ) echo ' one-page'; ?>">
357
- <?php $this->pagination( $location, $id ); ?>
358
-
359
- </div>
360
- <?php
361
- }
362
-
363
- /**
364
- * Get Page Number
365
- * @since 1.4
366
- * @version 1.0
367
- */
368
- public function get_pagenum() {
369
- global $paged;
370
-
371
- if ( $paged > 0 )
372
- $pagenum = absint( $paged );
373
-
374
- elseif ( isset( $_REQUEST['paged'] ) )
375
- $pagenum = absint( $_REQUEST['paged'] );
376
-
377
- else return 1;
378
-
379
- return max( 1, $pagenum );
380
- }
381
-
382
- /**
383
- * Pagination
384
- * @since 1.4
385
- * @version 1.0
386
- */
387
- public function pagination( $location = 'top', $id = '' ) {
388
- $output = '';
389
- $total_pages = $this->max_num_pages;
390
- $current = $this->get_pagenum();
391
- $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $id );
392
- if ( ! is_admin() )
393
- $current_url = str_replace( '/page/' . $current . '/', '/', $current_url );
394
- $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
395
-
396
- if ( $this->have_entries() ) {
397
- $total_number = count( $this->results );
398
- $output = '<span class="displaying-num">' . sprintf( __( 'Showing %d %s', 'mycred' ), $total_number, _n( 'entry', 'entries', $total_number, 'mycred' ) ) . '</span>';
399
- }
400
-
401
- $page_links = array();
402
-
403
- $disable_first = $disable_last = '';
404
- if ( $current == 1 )
405
- $disable_first = ' disabled';
406
- if ( $current == $total_pages )
407
- $disable_last = ' disabled';
408
-
409
- $page_links[] = sprintf( '<a class="%s" title="%s" href="%s">%s</a>',
410
- 'btn btn-default btn-sm first-page' . $disable_first,
411
- esc_attr__( 'Go to the first page' ),
412
- esc_url( remove_query_arg( 'paged', $current_url ) ),
413
- '&laquo;'
414
- );
415
-
416
- $page_links[] = sprintf( '<a class="%s" title="%s" href="%s">%s</a>',
417
- 'btn btn-default btn-sm prev-page' . $disable_first,
418
- esc_attr__( 'Go to the previous page' ),
419
- esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
420
- '&lsaquo;'
421
- );
422
-
423
- if ( 'bottom' == $location )
424
- $html_current_page = $current;
425
- else
426
- $html_current_page = sprintf( '<input class="current-page btn btn-sm" title="%s" type="text" name="paged" value="%s" size="%d" />',
427
- esc_attr__( 'Current page' ),
428
- $current,
429
- strlen( $total_pages )
430
- );
431
-
432
- $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
433
- $page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
434
-
435
- $page_links[] = sprintf( '<a class="%s" title="%s" href="%s">%s</a>',
436
- 'btn btn-default btn-sm next-page' . $disable_last,
437
- esc_attr__( 'Go to the next page' ),
438
- esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
439
- '&rsaquo;'
440
- );
441
-
442
- $page_links[] = sprintf( '<a class="%s" title="%s" href="%s">%s</a>',
443
- 'btn btn-default btn-sm last-page' . $disable_last,
444
- esc_attr__( 'Go to the last page' ),
445
- esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
446
- '&raquo;'
447
- );
448
-
449
- $pagination_links_class = 'pagination-links';
450
- $output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
451
-
452
- if ( $total_pages )
453
- $page_class = $total_pages < 2 ? ' one-page' : '';
454
- else
455
- $page_class = ' no-pages';
456
-
457
- echo "<div class='tablenav-pages{$page_class}'>$output</div>";
458
- }
459
-
460
- /**
461
- * Get References
462
- * Returns all available references in the database.
463
- * @since 0.1
464
- * @version 1.1
465
- */
466
- public function get_refs( $req = array() ) {
467
- $refs = mycred_get_used_references( $this->args['ctype'] );
468
-
469
- foreach ( $refs as $i => $ref ) {
470
- if ( ! empty( $req ) && ! in_array( $ref, $req ) )
471
- unset( $refs[ $i ] );
472
- }
473
- $refs = array_values( $refs );
474
-
475
- return apply_filters( 'mycred_log_get_refs', $refs );
476
- }
477
-
478
- /**
479
- * Get Users
480
- * Returns an array of user id's and display names.
481
- * @since 0.1
482
- * @version 1.0
483
- */
484
- protected function get_users() {
485
- $users = wp_cache_get( 'mycred_users' );
486
-
487
- if ( false === $users ) {
488
- $users = array();
489
- $blog_users = get_users( array( 'orderby' => 'display_name' ) );
490
- foreach ( $blog_users as $user ) {
491
- if ( false === $this->core->exclude_user( $user->ID ) )
492
- $users[ $user->ID ] = $user->display_name;
493
- }
494
- wp_cache_set( 'mycred_users', $users );
495
- }
496
-
497
- return apply_filters( 'mycred_log_get_users', $users );
498
- }
499
-
500
- /**
501
- * Filter Log options
502
- * @since 0.1
503
- * @version 1.3
504
- */
505
- public function filter_options( $is_profile = false, $refs = array() ) {
506
- echo '<div class="alignleft actions">';
507
- $show = false;
508
-
509
- // Filter by reference
510
- $references = $this->get_refs( $refs );
511
- if ( ! empty( $references ) ) {
512
- echo '<select name="ref" id="myCRED-reference-filter"><option value="">' . __( 'Show all references', 'mycred' ) . '</option>';
513
- foreach ( $references as $ref ) {
514
- $label = str_replace( array( '_', '-' ), ' ', $ref );
515
- echo '<option value="' . $ref . '"';
516
- if ( isset( $_GET['ref'] ) && $_GET['ref'] == $ref ) echo ' selected="selected"';
517
- echo '>' . ucwords( $label ) . '</option>';
518
- }
519
- echo '</select>';
520
- $show = true;
521
- }
522
-
523
- // Filter by user
524
- if ( $this->core->can_edit_creds() && ! $is_profile && $this->num_rows > 0 ) {
525
- echo '<input type="text" class="form-control" name="user_id" id="myCRED-user-filter" size="12" placeholder="' . __( 'User ID', 'mycred' ) . '" value="' . ( ( isset( $_GET['user_id'] ) ) ? $_GET['user_id'] : '' ) . '" /> ';
526
- $show = true;
527
- }
528
-
529
- // Filter Order
530
- if ( $this->num_rows > 0 ) {
531
- echo '<select name="order" id="myCRED-order-filter"><option value="">' . __( 'Show in order', 'mycred' ) . '</option>';
532
- $options = array( 'ASC' => __( 'Ascending', 'mycred' ), 'DESC' => __( 'Descending', 'mycred' ) );
533
- foreach ( $options as $value => $label ) {
534
- echo '<option value="' . $value . '"';
535
- if ( ! isset( $_GET['order'] ) && $value == 'DESC' ) echo ' selected="selected"';
536
- elseif ( isset( $_GET['order'] ) && $_GET['order'] == $value ) echo ' selected="selected"';
537
- echo '>' . $label . '</option>';
538
- }
539
- echo '</select>';
540
- $show = true;
541
- }
542
-
543
- // Let others play
544
- if ( has_action( 'mycred_filter_log_options' ) ) {
545
- do_action( 'mycred_filter_log_options', $this );
546
- $show = true;
547
- }
548
-
549
- if ( $show === true )
550
- echo '<input type="submit" class="btn btn-default button button-secondary button-large" value="' . __( 'Filter', 'mycred' ) . '" />';
551
-
552
- echo '</div>';
553
- }
554
-
555
- /**
556
- * Exporter
557
- * Displays all available export options.
558
- * @since 0.1
559
- * @version 1.0
560
- */
561
- public function exporter( $title = '', $is_profile = false ) {
562
- // Must be logged in
563
- if ( ! is_user_logged_in() ) return;
564
-
565
- // Make sure current user can export
566
- if ( ! apply_filters( 'mycred_user_can_export', false ) && ! $this->core->can_edit_creds() ) return;
567
-
568
- // Check if we allow export from front end. Disallowed by default
569
- if ( ! apply_filters( 'mycred_allow_front_export', false ) && ! is_admin() ) return;
570
-
571
- // Export options
572
- $exports = mycred_get_log_exports();
573
-
574
- // A difference in the default aguments should show us "search results"
575
- if ( empty( $this->diff ) || ( ! empty( $this->diff ) && $this->max_num_pages < 2 ) )
576
- unset( $exports['search'] );
577
-
578
- // Entire log export is not available when viewing our own history
579
- if ( $is_profile )
580
- unset( $exports['all'] ); ?>
581
-
582
- <div style="display:none;" class="clear" id="export-log-history">
583
- <?php if ( ! empty( $title ) ) : ?><h3 class="group-title"><?php echo $title; ?></h3><?php endif; ?>
584
- <form action="<?php echo add_query_arg( array( 'mycred-export' => 'do' ) ); ?>" method="post">
585
- <input type="hidden" name="token" value="<?php echo wp_create_nonce( 'mycred-run-log-export' ); ?>" />
586
- <?php
587
- if ( ! empty( $exports ) ) {
588
-
589
- foreach ( (array) $this->args as $arg_key => $arg_value )
590
- echo '<input type="hidden" name="' . $arg_key . '" value="' . $arg_value . '" />';
591
-
592
- foreach ( (array) $exports as $id => $data ) {
593
- // Label
594
- if ( $is_profile )
595
- $label = $data['my_label'];
596
- else
597
- $label = $data['label'];
598
-
599
- echo '<input type="submit" class="' . $data['class'] . '" name="action" value="' . $label . '" /> ';
600
- }
601
- ?>
602
- </form>
603
- <p><span class="description"><?php _e( 'Log entries are exported to a CSV file and depending on the number of entries selected, the process may take a few seconds.', 'mycred' ); ?></span></p>
604
- <?php
605
- }
606
- else {
607
- echo '<p>' . __( 'No export options available.', 'mycred' ) . '</p>';
608
- }
609
- ?>
610
- </div>
611
- <script type="text/javascript">
612
- jQuery(function($) {
613
- $( '.toggle-exporter' ).click(function(){
614
- $( '#export-log-history' ).toggle();
615
- });
616
- });
617
- </script>
618
- <?php
619
- }
620
-
621
- /**
622
- * Table Headers
623
- * Returns all table column headers.
624
- *
625
- * @filter mycred_log_column_headers
626
- * @since 0.1
627
- * @version 1.1
628
- */
629
- public function table_headers() {
630
- global $mycred_types;
631
-
632
- return apply_filters( 'mycred_log_column_headers', array(
633
- 'column-username' => __( 'User', 'mycred' ),
634
- 'column-time' => __( 'Date', 'mycred' ),
635
- 'column-creds' => $this->core->plural(),
636
- 'column-entry' => __( 'Entry', 'mycred' )
637
- ), $this );
638
- }
639
-
640
- /**
641
- * Display
642
- * @since 0.1
643
- * @version 1.0
644
- */
645
- public function display() {
646
- echo $this->get_display();
647
- }
648
-
649
- /**
650
- * Get Display
651
- * Generates a table for our results.
652
- *
653
- * @since 0.1
654
- * @version 1.0
655
- */
656
- public function get_display() {
657
- $output = '
658
- <table class="table mycred-table widefat log-entries table-striped" cellspacing="0">
659
- <thead>
660
- <tr>';
661
-
662
- // Table header
663
- foreach ( $this->headers as $col_id => $col_title ) {
664
- $output .= '<th scope="col" id="' . str_replace( 'column-', '', $col_id ) . '" class="manage-column ' . $col_id . '">' . $col_title . '</th>';
665
- }
666
-
667
- $output .= '
668
- </tr>
669
- </thead>
670
- <tfoot>';
671
-
672
- // Table footer
673
- foreach ( $this->headers as $col_id => $col_title ) {
674
- $output .= '<th scope="col" class="manage-column ' . $col_id . '">' . $col_title . '</th>';
675
- }
676
-
677
- $output .= '
678
- </tfoot>
679
- <tbody id="the-list">';
680
-
681
- // Loop
682
- if ( $this->have_entries() ) {
683
- $alt = 0;
684
-
685
- foreach ( $this->results as $log_entry ) {
686
- $row_class = apply_filters( 'mycred_log_row_classes', array( 'myCRED-log-row' ), $log_entry );
687
-
688
- $alt = $alt+1;
689
- if ( $alt % 2 == 0 )
690
- $row_class[] = ' alt';
691
-
692
- $output .= '<tr class="' . implode( ' ', $row_class ) . '">';
693
- $output .= $this->get_the_entry( $log_entry );
694
- $output .= '</tr>';
695
- }
696
- }
697
- // No log entry
698
- else {
699
- $output .= '<tr><td colspan="' . count( $this->headers ) . '" class="no-entries">' . $this->get_no_entries() . '</td></tr>';
700
- }
701
-
702
- $output .= '
703
- </tbody>
704
- </table>' . "\n";
705
-
706
- return $output;
707
- }
708
-
709
- /**
710
- * The Entry
711
- * @since 0.1
712
- * @version 1.1
713
- */
714
- public function the_entry( $log_entry, $wrap = 'td' ) {
715
- echo $this->get_the_entry( $log_entry, $wrap );
716
- }
717
-
718
- /**
719
- * Get The Entry
720
- * Generated a single entry row depending on the columns used / requested.
721
- * @filter mycred_log_date
722
- * @since 0.1
723
- * @version 1.3
724
- */
725
- public function get_the_entry( $log_entry, $wrap = 'td' ) {
726
- $date_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
727
- $entry_data = '';
728
-
729
- // Run though columns
730
- foreach ( $this->headers as $column_id => $column_name ) {
731
- switch ( $column_id ) {
732
- // Username Column
733
- case 'column-username' :
734
-
735
- $user = get_userdata( $log_entry->user_id );
736
- if ( $user === false )
737
- $content = '<span>' . __( 'User Missing', 'mycred' ) . ' (ID: ' . $log_entry->user_id . ')</span>';
738
- else
739
- $content = '<span>' . $user->display_name . '</span>';
740
-
741
- $content = apply_filters( 'mycred_log_username', $content, $log_entry->user_id, $log_entry );
742
-
743
- break;
744
- // Date & Time Column
745
- case 'column-time' :
746
-
747
- $content = $time = apply_filters( 'mycred_log_date', date_i18n( $date_format, $log_entry->time ), $log_entry->time, $log_entry );
748
-
749
- break;
750
- // Amount Column
751
- case 'column-creds' :
752
-
753
- $content = $creds = $this->core->format_creds( $log_entry->creds );
754
- $content = apply_filters( 'mycred_log_creds', $content, $log_entry->creds, $log_entry );
755
-
756
- break;
757
- // Log Entry Column
758
- case 'column-entry' :
759
-
760
- $content = '<div class="mycred-mobile-log" style="display:none;">' . $time . '<div>' . $creds . '</div></div>';
761
- $content .= $this->core->parse_template_tags( $log_entry->entry, $log_entry );
762
- $content = apply_filters( 'mycred_log_entry', $content, $log_entry->entry, $log_entry );
763
-
764
- break;
765
- // Let others play
766
- default :
767
-
768
- $content = apply_filters( 'mycred_log_' . $column_id, '', $log_entry );
769
-
770
- break;
771
- }
772
- $entry_data .= '<' . $wrap . ' class="' . $column_id . '">' . $content . '</' . $wrap . '>';
773
- }
774
- return $entry_data;
775
- }
776
-
777
- /**
778
- * Mobile Support
779
- * @since 1.4
780
- * @version 1.0
781
- */
782
- public function mobile_support() {
783
- echo '<style type="text/css">' . apply_filters( 'mycred_log_mobile_support', '
784
- @media all and (max-width: 480px) {
785
- .column-time, .column-creds { display: none; }
786
- .mycred-mobile-log { display: block !important; }
787
- .mycred-mobile-log div { float: right; font-weight: bold; }
788
- }
789
- ' ) . '</style>';
790
- }
791
-
792
- /**
793
- * No Entries
794
- * @since 0.1
795
- * @version 1.0
796
- */
797
- public function no_entries() {
798
- echo $this->get_no_entries();
799
- }
800
-
801
- /**
802
- * Get No Entries
803
- * @since 0.1
804
- * @version 1.0
805
- */
806
- public function get_no_entries() {
807
- return __( 'No log entries found', 'mycred' );
808
- }
809
-
810
- /**
811
- * Log Search
812
- * @since 0.1
813
- * @version 1.0.1
814
- */
815
- public function search() {
816
- if ( isset( $_GET['s'] ) && $_GET['s'] != '' )
817
- $serarch_string = $_GET['s'];
818
- else
819
- $serarch_string = ''; ?>
820
-
821
- <p class="search-box">
822
- <label class="screen-reader-text" for=""><?php _e( 'Search Log', 'mycred' ); ?>:</label>
823
- <input type="search" name="s" value="<?php echo $serarch_string; ?>" placeholder="<?php _e( 'search log entries', 'mycred' ); ?>" />
824
- <input type="submit" name="mycred-search-log" id="search-submit" class="button button-medium button-secondary" value="<?php _e( 'Search Log', 'mycred' ); ?>" />
825
- </p>
826
- <?php
827
- }
828
-
829
- /**
830
- * Filter by Dates
831
- * @since 0.1
832
- * @version 1.0
833
- */
834
- public function filter_dates( $url = '' ) {
835
- $date_sorting = apply_filters( 'mycred_sort_by_time', array(
836
- '' => __( 'All', 'mycred' ),
837
- 'today' => __( 'Today', 'mycred' ),
838
- 'yesterday' => __( 'Yesterday', 'mycred' ),
839
- 'thisweek' => __( 'This Week', 'mycred' ),
840
- 'thismonth' => __( 'This Month', 'mycred' )
841
- ) );
842
-
843
- if ( ! empty( $date_sorting ) ) {
844
- $total = count( $date_sorting );
845
- $count = 0;
846
- echo '<ul class="subsubsub">';
847
- foreach ( $date_sorting as $sorting_id => $sorting_name ) {
848
- $count = $count+1;
849
- echo '<li class="' . $sorting_id . '"><a href="';
850
-
851
- // Build Query Args
852
- $url_args = array();
853
- if ( isset( $_GET['user_id'] ) && $_GET['user_id'] != '' )
854
- $url_args['user_id'] = $_GET['user_id'];
855
- if ( isset( $_GET['ref'] ) && $_GET['ref'] != '' )
856
- $url_args['ref'] = $_GET['ref'];
857
- if ( isset( $_GET['order'] ) && $_GET['order'] != '' )
858
- $url_args['order'] = $_GET['order'];
859
- if ( isset( $_GET['s'] ) && $_GET['s'] != '' )
860
- $url_args['s'] = $_GET['s'];
861
- if ( $sorting_id != '' )
862
- $url_args['show'] = $sorting_id;
863
-
864
- // Build URL
865
- if ( ! empty( $url_args ) )
866
- echo add_query_arg( $url_args, $url );
867
- else
868
- echo $url;
869
-
870
- echo '"';
871
-
872
- if ( isset( $_GET['show'] ) && $_GET['show'] == $sorting_id ) echo ' class="current"';
873
- elseif ( ! isset( $_GET['show'] ) && $sorting_id != '' ) echo ' class="current"';
874
-
875
- echo '>' . $sorting_name . '</a>';
876
- if ( $count != $total ) echo ' | ';
877
- echo '</li>';
878
- }
879
- echo '</ul>';
880
- }
881
- }
882
-
883
- /**
884
- * Reset Query
885
- * @since 1.3
886
- * @version 1.0
887
- */
888
- public function reset_query() {
889
- $this->args = NULL;
890
- $this->request = NULL;
891
- $this->prep = NULL;
892
- $this->num_rows = NULL;
893
- $this->max_num_pages = NULL;
894
- $this->total_rows = NULL;
895
-
896
- $this->results = NULL;
897
-
898
- $this->headers = NULL;
899
- }
900
- }
901
- endif;
902
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mycred-referrals.php DELETED
@@ -1,72 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * Load Referral Program
6
- * @since 1.5.3
7
- * @version 1.0
8
- */
9
- if ( ! function_exists( 'mycred_load_referral_program' ) ) :
10
- function mycred_load_referral_program() {
11
-
12
- // BuddyPress: Hook into user activation
13
- if ( function_exists( 'buddypress' ) )
14
- add_action( 'bp_core_activated_user', 'mycred_detect_bp_user_activation' );
15
-
16
- // Logged in users do not get points
17
- if ( is_user_logged_in() && apply_filters( 'mycred_affiliate_allow_members', false ) === false ) return;
18
-
19
- // Points for visits
20
- add_action( 'template_redirect', 'mycred_detect_referred_visits' );
21
-
22
- // Points for signups
23
- add_action( 'user_register', 'mycred_detect_referred_signups' );
24
-
25
- }
26
- endif;
27
- add_action( 'mycred_init', 'mycred_load_referral_program' );
28
-
29
- /**
30
- * Detect Referred Visits
31
- * @since 1.5.3
32
- * @version 1.0.1
33
- */
34
- if ( ! function_exists( 'mycred_detect_referred_visits' ) ) :
35
- function mycred_detect_referred_visits() {
36
-
37
- do_action( 'mycred_referred_visit' );
38
-
39
- $keys = apply_filters( 'mycred_referral_keys', array() );
40
- if ( ! empty( $keys ) ) {
41
- wp_redirect( remove_query_arg( $keys ), 301 );
42
- exit;
43
- }
44
-
45
- }
46
- endif;
47
-
48
- /**
49
- * Detect Referred Signups
50
- * @since 1.5.3
51
- * @version 1.0
52
- */
53
- if ( ! function_exists( 'mycred_detect_referred_signups' ) ) :
54
- function mycred_detect_referred_signups( $new_user_id ) {
55
-
56
- do_action( 'mycred_referred_signup', $new_user_id );
57
-
58
- }
59
- endif;
60
-
61
- /**
62
- * Detect Referred BP User Activation
63
- * @since 1.5.3
64
- * @version 1.0
65
- */
66
- if ( ! function_exists( 'mycred_detect_bp_user_activation' ) ) :
67
- function mycred_detect_bp_user_activation( $user_id ) {
68
-
69
- do_action( 'mycred_bp_user_activated', $user_id );
70
-
71
- }
72
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mycred-shortcodes.php DELETED
@@ -1,1056 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * myCRED Shortcode: my_balance
6
- * Returns the current users balance.
7
- * @see http://codex.mycred.me/shortcodes/mycred_my_balance/
8
- * @contributor Ian Tasker
9
- * @since 1.0.9
10
- * @version 1.2.1
11
- */
12
- if ( ! function_exists( 'mycred_render_shortcode_my_balance' ) ) :
13
- function mycred_render_shortcode_my_balance( $atts )
14
- {
15
- extract( shortcode_atts( array(
16
- 'login' => NULL,
17
- 'title' => '',
18
- 'title_el' => 'h1',
19
- 'balance_el' => 'div',
20
- 'wrapper' => 1,
21
- 'type' => 'mycred_default'
22
- ), $atts ) );
23
-
24
- $output = '';
25
-
26
- // Not logged in
27
- if ( ! is_user_logged_in() ) {
28
- if ( $login !== NULL ) {
29
- if ( $wrapper )
30
- $output .= '<div class="mycred-not-logged-in">';
31
-
32
- $output .= $login;
33
-
34
- if ( $wrapper )
35
- $output .= '</div>';
36
-
37
- return $output;
38
- }
39
- return;
40
- }
41
-
42
- $user_id = get_current_user_id();
43
- $mycred = mycred( $type );
44
- // Check for exclusion
45
- if ( $mycred->exclude_user( $user_id ) ) return;
46
-
47
- if ( ! empty( $type ) )
48
- $mycred->cred_id = $type;
49
-
50
- if ( $wrapper )
51
- $output .= '<div class="mycred-my-balance-wrapper">';
52
-
53
- // Title
54
- if ( ! empty( $title ) ) {
55
- if ( ! empty( $title_el ) )
56
- $output .= '<' . $title_el . '>';
57
-
58
- $output .= $title;
59
-
60
- if ( ! empty( $title_el ) )
61
- $output .= '</' . $title_el . '>';
62
- }
63
-
64
- // Balance
65
- if ( ! empty( $balance_el ) )
66
- $output .= '<' . $balance_el . '>';
67
-
68
- $balance = $mycred->get_users_cred( $user_id, $type );
69
- $output .= $mycred->format_creds( $balance );
70
-
71
- if ( ! empty( $balance_el ) )
72
- $output .= '</' . $balance_el . '>';
73
-
74
- if ( $wrapper )
75
- $output .= '</div>';
76
-
77
- return $output;
78
- }
79
- endif;
80
-
81
- /**
82
- * myCRED Shortcode: mycred_history
83
- * Returns the points history.
84
- * @see http://codex.mycred.me/shortcodes/mycred_history/
85
- * @since 1.0.9
86
- * @version 1.1.1
87
- */
88
- if ( ! function_exists( 'mycred_render_shortcode_history' ) ) :
89
- function mycred_render_shortcode_history( $atts )
90
- {
91
- extract( shortcode_atts( array(
92
- 'user_id' => NULL,
93
- 'number' => NULL,
94
- 'time' => NULL,
95
- 'ref' => NULL,
96
- 'order' => NULL,
97
- 'show_user' => false,
98
- 'login' => '',
99
- 'type' => 'mycred_default'
100
- ), $atts ) );
101
-
102
- // If we are not logged in
103
- if ( ! is_user_logged_in() && ! empty( $login ) ) return '<p class="mycred-history login">' . $login . '</p>';
104
-
105
- if ( $user_id === NULL )
106
- $user_id = get_current_user_id();
107
-
108
- $args = array(
109
- 'user_id' => $user_id,
110
- 'ctype' => $type
111
- );
112
-
113
- if ( $number !== NULL )
114
- $args['number'] = $number;
115
-
116
- if ( $time !== NULL )
117
- $args['time'] = $time;
118
-
119
- if ( $ref !== NULL )
120
- $args['ref'] = $ref;
121
-
122
- if ( $order !== NULL )
123
- $args['order'] = $order;
124
-
125
- $log = new myCRED_Query_Log( $args );
126
-
127
- if ( $show_user !== true )
128
- unset( $log->headers['column-username'] );
129
-
130
- $result = $log->get_display();
131
- $log->reset_query();
132
- return $result;
133
- }
134
- endif;
135
-
136
- /**
137
- * myCRED Shortcode: mycred_leaderboard
138
- * @see http://codex.mycred.me/shortcodes/mycred_leaderboard/
139
- * @since 0.1
140
- * @version 1.4
141
- */
142
- if ( ! function_exists( 'mycred_render_shortcode_leaderboard' ) ) :
143
- function mycred_render_shortcode_leaderboard( $atts, $content = '' )
144
- {
145
- extract( shortcode_atts( array(
146
- 'number' => '-1',
147
- 'order' => 'DESC',
148
- 'offset' => 0,
149
- 'type' => 'mycred_default',
150
- 'based_on' => 'balance',
151
- 'wrap' => 'li',
152
- 'template' => '#%position% %user_profile_link% %cred_f%',
153
- 'nothing' => __( 'Leaderboard is empty.', 'mycred' ),
154
- 'current' => 0
155
- ), $atts ) );
156
-
157
- if ( ! in_array( $order, array( 'ASC', 'DESC' ) ) )
158
- $order = 'DESC';
159
-
160
- if ( $number != '-1' )
161
- $limit = 'LIMIT ' . absint( $offset ) . ',' . absint( $number );
162
- else
163
- $limit = '';
164
-
165
- $mycred = mycred( $type );
166
-
167
- global $wpdb;
168
-
169
- // Leaderboard based on balance
170
- $based_on = sanitize_text_field( $based_on );
171
-
172
- if ( $based_on == 'balance' )
173
- $SQL = $wpdb->prepare( "
174
- SELECT DISTINCT u.ID, um.meta_value AS cred
175
- FROM {$wpdb->users} u
176
- INNER JOIN {$wpdb->usermeta} um
177
- ON ( u.ID = um.user_id )
178
- WHERE um.meta_key = %s
179
- ORDER BY um.meta_value+0 {$order} {$limit};", $type );
180
- else
181
- $SQL = $wpdb->prepare( "
182
- SELECT DISTINCT user_id AS ID, SUM( creds ) AS cred
183
- FROM {$mycred->log_table}
184
- WHERE ref = %s
185
- GROUP BY user_id
186
- ORDER BY SUM( creds ) {$order} {$limit};", $based_on );
187
-
188
- $leaderboard = $wpdb->get_results( apply_filters( 'mycred_ranking_sql', $SQL ), 'ARRAY_A' );
189
-
190
- $output = '';
191
- $in_list = false;
192
-
193
- // Get current users object
194
- $current_user = wp_get_current_user();
195
-
196
- if ( ! empty( $leaderboard ) ) {
197
-
198
- // Check if current user is in the leaderboard
199
- if ( $current == 1 && is_user_logged_in() ) {
200
-
201
- // Find the current user in the leaderboard
202
- foreach ( $leaderboard as $position => $user ) {
203
- if ( $user['ID'] == $current_user->ID ) {
204
- $in_list = true;
205
- break;
206
- }
207
- }
208
-
209
- }
210
-
211
- // Load myCRED
212
- $mycred = mycred( $type );
213
-
214
- // Wrapper
215
- if ( $wrap == 'li' )
216
- $output .= '<ol class="myCRED-leaderboard">';
217
-
218
- // Loop
219
- foreach ( $leaderboard as $position => $user ) {
220
-
221
- // Prep
222
- $class = array();
223
-
224
- // Classes
225
- $class[] = 'item-' . $position;
226
- if ( $position == 0 )
227
- $class[] = 'first-item';
228
-
229
- if ( $position % 2 != 0 )
230
- $class[] = 'alt';
231
-
232
- if ( ! empty( $content ) )
233
- $template = $content;
234
-
235
- // Template Tags
236
- if ( ! function_exists( 'mycred_get_users_rank' ) )
237
- $layout = str_replace( array( '%rank%', '%ranking%', '%position%' ), $position+1, $template );
238
- else
239
- $layout = str_replace( array( '%ranking%', '%position%' ), $position+1, $template );
240
-
241
- $layout = $mycred->template_tags_amount( $layout, $user['cred'] );
242
- $layout = $mycred->template_tags_user( $layout, $user['ID'] );
243
-
244
- // Wrapper
245
- if ( ! empty( $wrap ) )
246
- $layout = '<' . $wrap . ' class="%classes%">' . $layout . '</' . $wrap . '>';
247
-
248
- $layout = str_replace( '%classes%', apply_filters( 'mycred_ranking_classes', implode( ' ', $class ) ), $layout );
249
- $layout = apply_filters( 'mycred_ranking_row', $layout, $template, $user, $position+1 );
250
-
251
- $output .= $layout . "\n";
252
-
253
- }
254
-
255
- $leaderboard = NULL;
256
-
257
- // Current user is not in list but we want to show his position
258
- if ( ! $in_list && $current == 1 && is_user_logged_in() ) {
259
-
260
- // Flush previous query
261
- $wpdb->flush();
262
-
263
- // Get a complete leaderboard with just user IDs
264
- if ( $based_on == 'balance' )
265
- $full_SQL = $wpdb->prepare( "
266
- SELECT DISTINCT u.ID
267
- FROM {$wpdb->users} u
268
- INNER JOIN {$wpdb->usermeta} um
269
- ON ( u.ID = um.user_id )
270
- WHERE um.meta_key = %s
271
- ORDER BY um.meta_value+0 {$order};", $type );
272
- else
273
- $full_SQL = $wpdb->prepare( "
274
- SELECT DISTINCT user_id AS ID, SUM( creds ) AS cred
275
- FROM {$mycred->log_table}
276
- WHERE ref = %s
277
- GROUP BY user_id
278
- ORDER BY SUM( creds ) {$order} {$limit};", $based_on );
279
-
280
- $full_leaderboard = $wpdb->get_results( $full_SQL, 'ARRAY_A' );
281
-
282
- if ( ! empty( $full_leaderboard ) ) {
283
-
284
- // Get current users position
285
- $current_position = array_search( array( 'ID' => $current_user->ID ), $full_leaderboard );
286
- $full_leaderboard = NULL;
287
-
288
- // If position is found
289
- if ( $current_position !== false ) {
290
-
291
- // Template Tags
292
- if ( ! function_exists( 'mycred_get_users_rank' ) )
293
- $layout = str_replace( array( '%rank%', '%ranking%', '%position%' ), $current_position+1, $template );
294
- else
295
- $layout = str_replace( array( '%ranking%', '%position%' ), $current_position+1, $template );
296
-
297
- $layout = $mycred->template_tags_amount( $layout, $mycred->get_users_cred( $current_user->ID, $type ) );
298
- $layout = $mycred->template_tags_user( $layout, false, $current_user );
299
-
300
- // Wrapper
301
- if ( ! empty( $wrap ) )
302
- $layout = '<' . $wrap . ' class="%classes%">' . $layout . '</' . $wrap . '>';
303
-
304
- $layout = str_replace( '%classes%', apply_filters( 'mycred_ranking_classes', implode( ' ', $class ) ), $layout );
305
- $layout = apply_filters( 'mycred_ranking_row', $layout, $template, $current_user, $current_position+1 );
306
-
307
- $output .= $layout . "\n";
308
-
309
- }
310
- }
311
-
312
- }
313
-
314
- if ( $wrap == 'li' )
315
- $output .= '</ol>';
316
-
317
- }
318
-
319
- // No result template is set
320
- else {
321
-
322
- $output .= '<p class="mycred-leaderboard-none">' . $nothing . '</p>';
323
-
324
- }
325
-
326
- return do_shortcode( apply_filters( 'mycred_leaderboard', $output, $atts ) );
327
- }
328
- endif;
329
-
330
- /**
331
- * myCRED Shortcode: mycred_my_ranking
332
- * @see http://codex.mycred.me/shortcodes/mycred_my_ranking/
333
- * @since 0.1
334
- * @version 1.4
335
- */
336
- if ( ! function_exists( 'mycred_render_shortcode_my_ranking' ) ) :
337
- function mycred_render_shortcode_my_ranking( $atts )
338
- {
339
- extract( shortcode_atts( array(
340
- 'user_id' => NULL,
341
- 'ctype' => 'mycred_default',
342
- 'based_on' => 'balance',
343
- 'missing' => 0
344
- ), $atts ) );
345
-
346
- // If no id is given
347
- if ( $user_id === NULL ) {
348
- // Current user must be logged in for this shortcode to work
349
- if ( ! is_user_logged_in() ) return;
350
- // Get current user id
351
- $user_id = get_current_user_id();
352
- }
353
-
354
- // If no type is given
355
- if ( $ctype == '' )
356
- $ctype = 'mycred_default';
357
-
358
- $mycred = mycred( $ctype );
359
-
360
- global $wpdb;
361
-
362
- $based_on = sanitize_text_field( $based_on );
363
-
364
- // Get a complete leaderboard with just user IDs
365
- if ( $based_on == 'balance' )
366
- $full_SQL = $wpdb->prepare( "
367
- SELECT DISTINCT u.ID
368
- FROM {$wpdb->users} u
369
- INNER JOIN {$wpdb->usermeta} um
370
- ON ( u.ID = um.user_id )
371
- WHERE um.meta_key = %s
372
- ORDER BY um.meta_value+0 {$order};", $ctype );
373
- else
374
- $full_SQL = $wpdb->prepare( "
375
- SELECT DISTINCT user_id AS ID, SUM( creds ) AS cred
376
- FROM {$mycred->log_table}
377
- WHERE ref = %s
378
- GROUP BY user_id
379
- ORDER BY SUM( creds ) {$order} {$limit};", $based_on );
380
-
381
- $full_leaderboard = $wpdb->get_results( $full_SQL, 'ARRAY_A' );
382
-
383
- $position = 0;
384
- if ( ! empty( $full_leaderboard ) ) {
385
-
386
- // Get current users position
387
- $current_position = array_search( array( 'ID' => $user_id ), $full_leaderboard );
388
- $position = $current_position+1;
389
-
390
- }
391
- else $position = $missing;
392
-
393
- $full_leaderboard = NULL;
394
-
395
- return apply_filters( 'mycred_get_leaderboard_position', $position, $user_id, $ctype );
396
- }
397
- endif;
398
-
399
- /**
400
- * myCRED Shortcode: mycred_give
401
- * This shortcode allows you to award or deduct points from a given user or the current user
402
- * when this shortcode is executed. You can insert this in page/post content
403
- * or in a template file. Note that users are awarded/deducted points each time
404
- * this shortcode exectutes!
405
- * @see http://codex.mycred.me/shortcodes/mycred_give/
406
- * @since 1.1
407
- * @version 1.1.1
408
- */
409
- if ( ! function_exists( 'mycred_render_shortcode_give' ) ) :
410
- function mycred_render_shortcode_give( $atts )
411
- {
412
- if ( ! is_user_logged_in() ) return;
413
-
414
- extract( shortcode_atts( array(
415
- 'amount' => NULL,
416
- 'user_id' => '',
417
- 'log' => '',
418
- 'ref' => 'gift',
419
- 'limit' => 0,
420
- 'type' => 'mycred_default'
421
- ), $atts ) );
422
-
423
- if ( $amount === NULL )
424
- return '<strong>' . __( 'error', 'mycred' ) . '</strong> ' . __( 'Amount missing!', 'mycred' );
425
-
426
- if ( empty( $log ) )
427
- return '<strong>' . __( 'error', 'mycred' ) . '</strong> ' . __( 'Log Template Missing!', 'mycred' );
428
-
429
- $mycred = mycred();
430
-
431
- if ( empty( $user_id ) )
432
- $user_id = get_current_user_id();
433
-
434
- // Check for exclusion
435
- if ( $mycred->exclude_user( $user_id ) ) return;
436
-
437
- // Limit
438
- $limit = abs( $limit );
439
- if ( $limit != 0 && mycred_count_ref_instances( $ref, $user_id ) >= $limit ) return;
440
-
441
- $amount = $mycred->number( $amount );
442
- $mycred->add_creds(
443
- $ref,
444
- $user_id,
445
- $amount,
446
- $log,
447
- '',
448
- '',
449
- $type
450
- );
451
- }
452
- endif;
453
-
454
- /**
455
- * myCRED Shortcode: mycred_link
456
- * This shortcode allows you to award or deduct points from the current user
457
- * when their click on a link. The shortcode will generate an anchor element
458
- * and call the mycred-click-link jQuery script which will award the points.
459
- *
460
- * Note! Only HTML5 anchor attributes are supported and this shortcode is only
461
- * available if the hook is enabled!
462
- *
463
- * @see http://codex.mycred.me/shortcodes/mycred_link/
464
- * @since 1.1
465
- * @version 1.1
466
- */
467
- if ( ! function_exists( 'mycred_render_shortcode_link' ) ) :
468
- function mycred_render_shortcode_link( $atts, $content = '' )
469
- {
470
- global $mycred_link_points;
471
-
472
- $atts = shortcode_atts( array(
473
- 'id' => '',
474
- 'rel' => '',
475
- 'class' => '',
476
- 'href' => '',
477
- 'title' => '',
478
- 'target' => '',
479
- 'style' => '',
480
- 'amount' => 0,
481
- 'ctype' => 'mycred_default',
482
- 'hreflang' => '', // for advanced users
483
- 'media' => '', // for advanced users
484
- 'type' => '' // for advanced users
485
- ), $atts );
486
-
487
- // HREF is required
488
- if ( empty( $atts['href'] ) )
489
- return '<strong>' . __( 'error', 'mycred' ) . '</strong> ' . __( 'Anchor missing URL!', 'mycred' );
490
-
491
- // All links must contain the 'mycred-points-link' class
492
- if ( empty( $atts['class'] ) )
493
- $atts['class'] = 'mycred-points-link';
494
- else
495
- $atts['class'] = 'mycred-points-link ' . $atts['class'];
496
-
497
- // If no id exists, make one
498
- if ( empty( $atts['id'] ) ) {
499
- $id = str_replace( array( 'http://', 'https://', 'http%3A%2F%2F', 'https%3A%2F%2F' ), 'hs', $atts['href'] );
500
- $id = str_replace( array( '/', '-', '_', ':', '.', '?', '=', '+', '\\', '%2F' ), '', $id );
501
- $atts['id'] = $id;
502
- }
503
-
504
- // Construct anchor attributes
505
- $attr = array();
506
- foreach ( $atts as $attribute => $value ) {
507
- if ( !empty( $value ) && ! in_array( $attribute, array( 'amount', 'ctype' ) ) ) {
508
- $attr[] = $attribute . '="' . $value . '"';
509
- }
510
- }
511
-
512
- // Add key
513
- $token = mycred_create_token( array( $atts['amount'], $atts['ctype'], $atts['id'] ) );
514
- $attr[] = 'data-token="' . $token . '"';
515
-
516
- // Make sure jQuery script is called
517
- $mycred_link_points = true;
518
-
519
- // Return result
520
- return '<a ' . implode( ' ', $attr ) . '>' . $content . '</a>';
521
- }
522
- endif;
523
-
524
- /**
525
- * myCRED Shortcode: mycred_send
526
- * This shortcode allows the current user to send a pre-set amount of points
527
- * to a pre-set user. A simpler version of the mycred_transfer shortcode.
528
- * @see http://codex.mycred.me/shortcodes/mycred_send/
529
- * @since 1.1
530
- * @version 1.0
531
- */
532
- if ( ! function_exists( 'mycred_render_shortcode_send' ) ) :
533
- function mycred_render_shortcode_send( $atts, $content = NULL )
534
- {
535
- if ( ! is_user_logged_in() ) return;
536
-
537
- extract( shortcode_atts( array(
538
- 'amount' => NULL,
539
- 'to' => NULL,
540
- 'log' => '',
541
- 'ref' => 'gift',
542
- 'type' => 'mycred_default'
543
- ), $atts ) );
544
-
545
- // Amount is required
546
- if ( $amount === NULL )
547
- return '<strong>' . __( 'error', 'mycred' ) . '</strong> ' . __( 'Amount missing!', 'mycred' );
548
-
549
- // Recipient is required
550
- if ( empty( $to ) )
551
- return '<strong>' . __( 'error', 'mycred' ) . '</strong> ' . __( 'User ID missing for recipient.', 'mycred' );
552
-
553
- // Log template is required
554
- if ( empty( $log ) )
555
- return '<strong>' . __( 'error', 'mycred' ) . '</strong> ' . __( 'Log Template Missing!', 'mycred' );
556
-
557
- if ( $to == 'author' ) {
558
- // You can not use this outside the loop
559
- $author = get_the_author_meta( 'ID' );
560
- if ( empty( $author ) ) $author = $GLOBALS['post']->post_author;
561
- $to = $author;
562
- }
563
-
564
- global $mycred_sending_points;
565
-
566
- $mycred = mycred( $type );
567
- $user_id = get_current_user_id();
568
-
569
- // Make sure current user or recipient is not excluded!
570
- if ( $mycred->exclude_user( $to ) || $mycred->exclude_user( $user_id ) ) return;
571
-
572
- $account_limit = (int) apply_filters( 'mycred_transfer_acc_limit', 0 );
573
- $balance = $mycred->get_users_cred( $user_id, $type );
574
- $amount = $mycred->number( $amount );
575
-
576
- // Insufficient Funds
577
- if ( $balance-$amount < $account_limit ) return;
578
-
579
- // We are ready!
580
- $mycred_sending_points = true;
581
-
582
- return '<input type="button" class="mycred-send-points-button" data-to="' . $to . '" data-ref="' . $ref . '" data-log="' . $log . '" data-amount="' . $amount . '" data-type="' . $type . '" value="' . $mycred->template_tags_general( $content ) . '" />';
583
- }
584
- endif;
585
-
586
- /**
587
- * Load myCRED Send Points Footer
588
- * @since 0.1
589
- * @version 1.2
590
- */
591
- if ( ! function_exists( 'mycred_send_shortcode_footer' ) ) :
592
- add_action( 'wp_footer', 'mycred_send_shortcode_footer' );
593
- function mycred_send_shortcode_footer()
594
- {
595
- global $mycred_sending_points;
596
-
597
- if ( $mycred_sending_points === true ) {
598
- $mycred = mycred();
599
- $base = array(
600
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
601
- 'token' => wp_create_nonce( 'mycred-send-points' )
602
- );
603
-
604
- $language = apply_filters( 'mycred_send_language', array(
605
- 'working' => __( 'Processing...', 'mycred' ),
606
- 'done' => __( 'Sent', 'mycred' ),
607
- 'error' => __( 'Error - Try Again', 'mycred' )
608
- ) );
609
- wp_localize_script(
610
- 'mycred-send-points',
611
- 'myCREDsend',
612
- array_merge_recursive( $base, $language )
613
- );
614
- wp_enqueue_script( 'mycred-send-points' );
615
- }
616
- }
617
- endif;
618
-
619
- /**
620
- * myCRED Send Points Ajax
621
- * @since 0.1
622
- * @version 1.3
623
- */
624
- if ( ! function_exists( 'mycred_shortcode_send_points_ajax' ) ) :
625
- add_action( 'wp_ajax_mycred-send-points', 'mycred_shortcode_send_points_ajax' );
626
- function mycred_shortcode_send_points_ajax()
627
- {
628
- // We must be logged in
629
- if ( ! is_user_logged_in() ) die();
630
-
631
- // Security
632
- check_ajax_referer( 'mycred-send-points', 'token' );
633
-
634
- $mycred_types = mycred_get_types();
635
- $type = 'mycred_default';
636
- if ( isset( $_POST['type'] ) )
637
- $type = sanitize_text_field( $type );
638
-
639
- if ( ! array_key_exists( $type, $mycred_types ) ) die();
640
-
641
- $mycred = mycred( $type );
642
- $user_id = get_current_user_id();
643
-
644
- $account_limit = (int) apply_filters( 'mycred_transfer_acc_limit', 0 );
645
- $balance = $mycred->get_users_cred( $user_id, $type );
646
- $amount = $mycred->number( $_POST['amount'] );
647
- $new_balance = $balance-$amount;
648
-
649
- // Insufficient Funds
650
- if ( $new_balance < $account_limit )
651
- die();
652
- // After this transfer our account will reach zero
653
- elseif ( $new_balance == $account_limit )
654
- $reply = 'zero';
655
- // Check if this is the last time we can do these kinds of amounts
656
- elseif ( $new_balance-$amount < $account_limit )
657
- $reply = 'minus';
658
- // Else everything is fine
659
- else
660
- $reply = 'done';
661
-
662
- // First deduct points
663
- $mycred->add_creds(
664
- trim( $_POST['reference'] ),
665
- $user_id,
666
- 0-$amount,
667
- trim( $_POST['log'] ),
668
- $_POST['recipient'],
669
- array( 'ref_type' => 'user' ),
670
- $type
671
- );
672
-
673
- // Then add to recipient
674
- $mycred->add_creds(
675
- trim( $_POST['reference'] ),
676
- $_POST['recipient'],
677
- $amount,
678
- trim( $_POST['log'] ),
679
- $user_id,
680
- array( 'ref_type' => 'user' ),
681
- $type
682
- );
683
-
684
- // Share the good news
685
- wp_send_json( $reply );
686
- }
687
- endif;
688
-
689
- /**
690
- * myCRED Shortcode: mycred_video
691
- * This shortcode allows points to be given to the current user
692
- * for watchinga YouTube video.
693
- * @see http://codex.mycred.me/shortcodes/mycred_video/
694
- * @since 1.2
695
- * @version 1.1.1
696
- */
697
- if ( ! function_exists( 'mycred_render_shortcode_video' ) ) :
698
- function mycred_render_shortcode_video( $atts )
699
- {
700
- global $mycred_video_points;
701
-
702
- $hooks = mycred_get_option( 'mycred_pref_hooks', false );
703
- if ( $hooks === false ) return;
704
- $prefs = $hooks['hook_prefs']['video_view'];
705
-
706
- extract( shortcode_atts( array(
707
- 'id' => NULL,
708
- 'width' => 560,
709
- 'height' => 315,
710
- 'amount' => $prefs['creds'],
711
- 'logic' => $prefs['logic'],
712
- 'interval' => $prefs['interval']
713
- ), $atts ) );
714
-
715
- // ID is required
716
- if ( $id === NULL || empty( $id ) ) return __( 'A video ID is required for this shortcode', 'mycred' );
717
-
718
- // Interval
719
- if ( strlen( $interval ) < 3 )
720
- $interval = abs( $interval * 1000 );
721
-
722
- // Video ID
723
- $video_id = str_replace( '-', '__', $id );
724
-
725
- // Create key
726
- $key = mycred_create_token( array( 'youtube', $video_id, $amount, $logic, $interval ) );
727
-
728
- if ( ! isset( $mycred_video_points ) || ! is_array( $mycred_video_points ) )
729
- $mycred_video_points = array();
730
-
731
- // Construct YouTube Query
732
- $query = apply_filters( 'mycred_video_query_youtube', array(
733
- 'enablejsapi' => 1,
734
- 'version' => 3,
735
- 'playerapiid' => 'mycred_vvideo_v' . $video_id,
736
- 'rel' => 0,
737
- 'controls' => 1,
738
- 'showinfo' => 0
739
- ), $atts, $video_id );
740
-
741
- // Construct Youtube Query Address
742
- $url = 'https://www.youtube.com/embed/' . $id;
743
- $url = add_query_arg( $query, $url );
744
-
745
- $mycred_video_points[] = 'youtube';
746
-
747
- // Make sure video source ids are unique
748
- $mycred_video_points = array_unique( $mycred_video_points );
749
-
750
- ob_start(); ?>
751
-
752
- <div class="mycred-video-wrapper youtube-video">
753
- <iframe id="mycred_vvideo_v<?php echo $video_id; ?>" class="mycred-video mycred-youtube-video" data-vid="<?php echo $video_id; ?>" src="<?php echo $url; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
754
- <script type="text/javascript">
755
- function mycred_vvideo_v<?php echo $video_id; ?>( state ) {
756
- duration[ "<?php echo $video_id; ?>" ] = state.target.getDuration();
757
- mycred_view_video( "<?php echo $video_id; ?>", state.data, "<?php echo $logic; ?>", "<?php echo $interval; ?>", "<?php echo $key; ?>" );
758
- }
759
- </script>
760
- </div>
761
- <?php
762
- $output = ob_get_contents();
763
- ob_end_clean();
764
-
765
- // Return the shortcode output
766
- return apply_filters( 'mycred_video_output', $output, $atts );
767
- }
768
- endif;
769
-
770
- /**
771
- * myCRED Shortcode: mycred_total_balance
772
- * This shortcode will return either the current user or a given users
773
- * total balance based on either all point types or a comma seperated list
774
- * of types.
775
- * @see http://codex.mycred.me/shortcodes/mycred_total_balance/
776
- * @since 1.4.3
777
- * @version 1.1
778
- */
779
- if ( ! function_exists( 'mycred_render_shortcode_total' ) ) :
780
- function mycred_render_shortcode_total( $atts, $content = '' )
781
- {
782
- extract( shortcode_atts( array(
783
- 'user_id' => NULL,
784
- 'types' => 'mycred_default',
785
- 'raw' => 0
786
- ), $atts ) );
787
-
788
- // If user ID is not set, get the current users ID
789
- if ( $user_id === NULL ) {
790
- // If user is not logged in bail now
791
- if ( ! is_user_logged_in() ) return $content;
792
- $user_id = get_current_user_id();
793
- }
794
-
795
- // Get types
796
- $types_to_addup = array();
797
- $all = false;
798
- $existing_types = mycred_get_types();
799
-
800
- if ( $types == 'all' ) {
801
- $types_to_addup = array_keys( $existing_types );
802
- }
803
- else {
804
- $types = explode( ',', $types );
805
- if ( ! empty( $types ) ) {
806
- foreach ( $types as $type_key ) {
807
- $type_key = sanitize_text_field( $type_key );
808
- if ( ! array_key_exists( $type_key, $existing_types ) ) continue;
809
-
810
- if ( ! in_array( $type_key, $types_to_addup ) )
811
- $types_to_addup[] = $type_key;
812
- }
813
- }
814
- }
815
-
816
- // In case we still have no types, we add the default one
817
- if ( empty( $types_to_addup ) )
818
- $types_to_addup = array( 'mycred_default' );
819
-
820
- // Add up all point type balances
821
- $total = 0;
822
- foreach ( $types_to_addup as $type ) {
823
- // Get the balance for this type
824
- $balance = mycred_query_users_total( $user_id, $type );
825
-
826
- $total = $total+$balance;
827
- }
828
-
829
- // If we want the total unformatted return this now
830
- if ( $raw )
831
- return $total;
832
-
833
- // Return formatted
834
- return apply_filters( 'mycred_total_balances_output', $total, $atts );
835
- }
836
- endif;
837
-
838
- /**
839
- * myCRED Shortcode: mycred_exchange
840
- * This shortcode will return an exchange form allowing users to
841
- * exchange one point type for another.
842
- * @see http://codex.mycred.me/shortcodes/mycred_exchange/
843
- * @since 1.5
844
- * @version 1.0
845
- */
846
- if ( ! function_exists( 'mycred_render_shortcode_exchange' ) ) :
847
- function mycred_render_shortcode_exchange( $atts, $content = '' )
848
- {
849
- if ( ! is_user_logged_in() ) return $content;
850
-
851
- extract( shortcode_atts( array(
852
- 'from' => '',
853
- 'to' => '',
854
- 'rate' => 1,
855
- 'min' => 1
856
- ), $atts ) );
857
-
858
- if ( $from == '' || $to == '' ) return '';
859
-
860
- $types = mycred_get_types();
861
- if ( ! array_key_exists( $from, $types ) || ! array_key_exists( $to, $types ) ) return __( 'Point types not found.', 'mycred' );
862
-
863
- $user_id = get_current_user_id();
864
-
865
- $mycred_from = mycred( $from );
866
- if ( $mycred_from->exclude_user( $user_id ) )
867
- return sprintf( __( 'You are excluded from using %s.', 'mycred' ), $mycred_from->plural() );
868
-
869
- $balance = $mycred_from->get_users_balance( $user_id, $from );
870
- if ( $balance < $mycred_from->number( $min ) )
871
- return __( 'Your balance is too low to use this feature.', 'mycred' );
872
-
873
- $mycred_to = mycred( $to );
874
- if ( $mycred_to->exclude_user( $user_id ) )
875
- return sprintf( __( 'You are excluded from using %s.', 'mycred' ), $mycred_to->plural() );
876
-
877
- global $mycred_exchange;
878
-
879
- $token = mycred_create_token( array( $from, $to, $user_id, $rate, $min ) );
880
-
881
- ob_start(); ?>
882
-
883
- <style type="text/css">
884
- #mycred-exchange table tr td { width: 50%; }
885
- #mycred-exchange table tr td label { display: block; font-weight: bold; font-size: 12px; }
886
- #mycred-exchange { margin-bottom: 24px; }
887
- .alert-success { color: green; }
888
- .alert-warning { color: red; }
889
- </style>
890
- <div class="mycred-exchange">
891
- <form action="" method="post">
892
- <h3><?php printf( __( 'Convert <span>%s</span> to <span>%s</span>', 'mycred' ), $mycred_from->plural(), $mycred_to->plural() ); ?></h3>
893
-
894
- <?php if ( isset( $mycred_exchange['message'] ) ) : ?>
895
- <div class="alert alert-<?php if ( $mycred_exchange['success'] ) echo 'success'; else echo 'warning'; ?>"><?php echo $mycred_exchange['message']; ?></div>
896
- <?php endif; ?>
897
-
898
- <table class="table">
899
- <tr>
900
- <td colspan="2">
901
- <label><?php printf( __( 'Your current %s balance', 'mycred' ), $mycred_from->singular() ); ?></label>
902
- <p><?php echo $mycred_from->format_creds( $balance ); ?></p>
903
- </td>
904
- </tr>
905
- <tr>
906
- <td>
907
- <label for="mycred-exchange-amount"><?php _e( 'Amount', 'mycred' ); ?></label>
908
- <input type="text" size="12" value="0" id="mycred-exchange-amount" name="mycred_exchange[amount]" />
909
- <?php if ( $min != 0 ) : ?><p><small><?php printf( __( 'Minimum %s', 'mycred' ), $mycred_from->format_creds( $min ) ); ?></small></p><?php endif; ?>
910
- </td>
911
- <td>
912
- <label for="exchange-rate"><?php _e( 'Exchange Rate', 'mycred' ); ?></label>
913
- <p><?php printf( __( '1 %s = <span class="rate">%s</span> %s', 'mycred' ), $mycred_from->singular(), $rate, $mycred_to->plural() ); ?></p>
914
- </td>
915
- </tr>
916
- </table>
917
- <input type="hidden" name="mycred_exchange[token]" value="<?php echo $token; ?>" />
918
- <input type="hidden" name="mycred_exchange[nonce]" value="<?php echo wp_create_nonce( 'mycred-exchange' ); ?>" />
919
- <input type="submit" class="btn btn-primary button button-primary" value="<?php _e( 'Exchange', 'mycred' ); ?>" />
920
- <div class="clear clearfix"></div>
921
- </form>
922
- </div>
923
- <?php
924
- $output = ob_get_contents();
925
- ob_end_clean();
926
-
927
- return apply_filters( 'mycred_exchange_output', $output, $atts );
928
- }
929
- endif;
930
-
931
- /**
932
- * Run Exchange
933
- * Intercepts and executes exchange requests.
934
- * @since 1.5
935
- * @version 1.0
936
- */
937
- if ( ! function_exists( 'mycred_run_exchange' ) ) :
938
- add_filter( 'mycred_init', 'mycred_run_exchange' );
939
- function mycred_run_exchange()
940
- {
941
- if ( ! isset( $_POST['mycred_exchange']['nonce'] ) || ! wp_verify_nonce( $_POST['mycred_exchange']['nonce'], 'mycred-exchange' ) ) return;
942
-
943
- // Decode token
944
- $token = mycred_verify_token( $_POST['mycred_exchange']['token'], 5 );
945
- if ( $token === false ) return;
946
-
947
- global $mycred_exchange;
948
- list ( $from, $to, $user_id, $rate, $min ) = $token;
949
-
950
- // Check point types
951
- $types = mycred_get_types();
952
- if ( ! array_key_exists( $from, $types ) || ! array_key_exists( $to, $types ) ) {
953
- $mycred_exchange = array(
954
- 'success' => false,
955
- 'message' => __( 'Point types not found.', 'mycred' )
956
- );
957
- return;
958
- }
959
-
960
- $user_id = get_current_user_id();
961
-
962
- // Check for exclusion
963
- $mycred_from = mycred( $from );
964
- if ( $mycred_from->exclude_user( $user_id ) ) {
965
- $mycred_exchange = array(
966
- 'success' => false,
967
- 'message' => sprintf( __( 'You are excluded from using %s.', 'mycred' ), $mycred_from->plural() )
968
- );
969
- return;
970
- }
971
-
972
- // Check balance
973
- $balance = $mycred_from->get_users_balance( $user_id, $from );
974
- if ( $balance < $mycred_from->number( $min ) ) {
975
- $mycred_exchange = array(
976
- 'success' => false,
977
- 'message' => __( 'Your balance is too low to use this feature.', 'mycred' )
978
- );
979
- return;
980
- }
981
-
982
- // Check for exclusion
983
- $mycred_to = mycred( $to );
984
- if ( $mycred_to->exclude_user( $user_id ) ) {
985
- $mycred_exchange = array(
986
- 'success' => false,
987
- 'message' => sprintf( __( 'You are excluded from using %s.', 'mycred' ), $mycred_to->plural() )
988
- );
989
- return;
990
- }
991
-
992
- // Prep Amount
993
- $amount = abs( $_POST['mycred_exchange']['amount'] );
994
- $amount = $mycred_from->number( $amount );
995
-
996
- // Make sure we are sending more then minimum
997
- if ( $amount < $min ) {
998
- $mycred_exchange = array(
999
- 'success' => false,
1000
- 'message' => sprintf( __( 'You must exchange at least %s!', 'mycred' ), $mycred_from->format_creds( $min ) )
1001
- );
1002
- return;
1003
- }
1004
-
1005
- // Make sure we have enough points
1006
- if ( $amount > $balance ) {
1007
- $mycred_exchange = array(
1008
- 'success' => false,
1009
- 'message' => __( 'Insufficient Funds. Please try a lower amount.', 'mycred' )
1010
- );
1011
- return;
1012
- }
1013
-
1014
- // Let others decline
1015
- $reply = apply_filters( 'mycred_decline_exchange', false, compact( 'from', 'to', 'user_id', 'rate', 'min', 'amount' ) );
1016
- if ( $reply === false ) {
1017
-
1018
- $mycred_from->add_creds(
1019
- 'exchange',
1020
- $user_id,
1021
- 0-$amount,
1022
- sprintf( __( 'Exchange from %s', 'mycred' ), $mycred_from->plural() ),
1023
- 0,
1024
- array( 'from' => $from, 'rate' => $rate, 'min' => $min ),
1025
- $from
1026
- );
1027
-
1028
- $exchanged = $mycred_to->number( ( $amount * $rate ) );
1029
-
1030
- $mycred_to->add_creds(
1031
- 'exchange',
1032
- $user_id,
1033
- $exchanged,
1034
- sprintf( __( 'Exchange to %s', 'mycred' ), $mycred_to->plural() ),
1035
- 0,
1036
- array( 'to' => $to, 'rate' => $rate, 'min' => $min ),
1037
- $to
1038
- );
1039
-
1040
- $mycred_exchange = array(
1041
- 'success' => true,
1042
- 'message' => sprintf( __( 'You have successfully exchanged %s into %s.', 'mycred' ), $mycred_from->format_creds( $amount ), $mycred_to->format_creds( $exchanged ) )
1043
- );
1044
-
1045
- }
1046
- else {
1047
- $mycred_exchange = array(
1048
- 'success' => false,
1049
- 'message' => $reply
1050
- );
1051
- return;
1052
- }
1053
-
1054
- }
1055
- endif;
1056
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/mycred-tools-import-export.php CHANGED
@@ -944,6 +944,19 @@ class myCRED_Tools_Import_Export extends myCRED_Setup_Import_Export
944
 
945
  public function import_export()
946
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
947
  if( isset( $_POST['action'] ) && $_POST['action'] == 'mycred-tools-import-export' )
948
  {
949
  //Export Raw points
944
 
945
  public function import_export()
946
  {
947
+
948
+ check_ajax_referer( 'mycred-tools', 'token' );
949
+
950
+ $current_user_id = get_current_user_id();
951
+ $mycred = mycred();
952
+
953
+ if ( ! $mycred->user_is_point_admin( $current_user_id ) ) {
954
+
955
+ wp_send_json( array( 'success', 'accessDenied' ) );
956
+ wp_die();
957
+
958
+ }
959
+
960
  if( isset( $_POST['action'] ) && $_POST['action'] == 'mycred-tools-import-export' )
961
  {
962
  //Export Raw points
includes/mycred-tools.php CHANGED
@@ -8,6 +8,8 @@ if ( ! defined( 'ABSPATH' ) ) {
8
  if ( ! class_exists( 'myCRED_Tools' ) ) :
9
  class myCRED_Tools {
10
 
 
 
11
  /**
12
  * Construct
13
  */
@@ -38,17 +40,23 @@ class myCRED_Tools {
38
  MYCRED_SLUG . '-tools-script',
39
  'mycredTools',
40
  array(
41
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
42
- 'awardConfirmText' => __( 'Do you really want to bulk award?', 'mycred' ),
43
- 'revokeConfirmText' => __( 'Do you really want to bulk deduct?', 'mycred' ),
44
- 'successfullyAwarded' => __( 'Successfully Awarded.', 'mycred' ),
45
- 'successfullyDeducted' => __( 'Successfully Deducted.', 'mycred' ),
46
- 'pointsRequired' => __( 'Points field is required.', 'mycred' ),
47
- 'logEntryRequired' => __( 'Log Entry is requried.', 'mycred' ),
48
- 'revokeConfirmText' => __( 'Do you really want to bulk revoke?', 'mycred' ),
49
- 'successfullyRevoked' => __( 'Successfully Revoked.', 'mycred' ),
50
- 'userOrRoleIsRequired' => __( 'Username or Role field required.', 'mycred' ),
51
- 'badgesFieldRequried' => __( 'Badges field required.', 'mycred' )
 
 
 
 
 
 
52
  )
53
  );
54
  }
@@ -185,207 +193,252 @@ class myCRED_Tools {
185
  return $user_ids;
186
  }
187
 
188
- public function tools_assign_award()
189
- {
190
- if( isset( $_REQUEST['selected_type'] ) ):
191
 
192
- $selected_type = sanitize_text_field( $_REQUEST['selected_type'] );
193
 
194
- $award_to_all_users = sanitize_text_field( $_REQUEST['award_to_all_users'] ) == 'true' ? true : false;
195
- $users = sanitize_text_field( $_REQUEST['users'] );
196
- $user_roles = sanitize_text_field( $_REQUEST['user_roles'] );
197
 
198
- //Gathering users
199
- $users_to_award = array();
200
- if( $award_to_all_users )
201
- {
202
- $users = $this->get_all_users();
203
 
204
- foreach( $users as $email => $user_name )
205
- {
206
- $users_to_award[] = $email;
 
 
 
 
 
 
 
 
 
 
 
207
  }
208
 
209
- $users_to_award = $this->get_users_by_email( $users_to_award );
210
  }
211
- else
212
- {
213
- $users = json_decode( stripslashes( $users ) );
214
 
215
- $roles = json_decode( stripslashes( $user_roles ) );
 
216
 
217
- if( empty( $users ) && empty( $roles ) )
218
- {
219
- $response = array( 'success' => 'userOrRoleIsRequired' );
220
-
221
- wp_send_json( $response );
222
-
223
- die;
224
- }
225
-
226
- $users_to_award = $this->get_users_by_email( $users );
227
 
228
- if( $user_roles )
229
- {
230
- $users_by_role = $this->get_users_by_role( $roles );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
- $users_to_award = array_merge( $users_by_role, $users_to_award );
233
 
234
- $users_to_award = array_unique( $users_to_award );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  }
 
236
  }
237
 
238
- //Awarding Points
239
- if( $selected_type == 'points' )
240
- {
241
- $response = '';
242
- $log_entry_text = '';
243
- $points_to_award = sanitize_text_field( $_REQUEST['points_to_award'] );
244
- $point_type = sanitize_text_field( $_REQUEST['point_type'] );
245
- $log_entry = sanitize_text_field( $_REQUEST['log_entry'] ) == 'true' ? true : false;
 
 
 
 
246
 
247
- if( empty( $points_to_award ) )
248
- {
249
- $response = array( 'success' => 'pointsRequired' );
250
 
251
- wp_send_json( $response );
 
 
 
 
 
 
 
 
252
 
253
- die;
254
  }
255
 
256
- $mycred = mycred( $point_type );
257
 
258
- foreach( $users_to_award as $user_id )
259
- {
260
- //Entries with log
261
- if( $log_entry )
262
- {
263
- $log_entry_text = sanitize_text_field( $_REQUEST['log_entry_text'] );
264
-
265
- if( empty( $log_entry_text ) )
266
- {
267
- $response = array( 'success' => 'logEntryRequired' );
268
-
269
- wp_send_json( $response );
270
-
271
- die;
272
- }
273
-
274
- mycred_add(
275
- 'bulk_assign',
276
- $user_id,
277
- $points_to_award,
278
- $log_entry_text,
279
- '',
280
- '',
281
- $point_type
282
- );
283
 
284
- }
285
 
286
- //Entries with log
287
- if( !$log_entry )
288
- {
289
- $new_balance = $mycred->update_users_balance( $user_id, $points_to_award, $point_type );
290
- }
291
 
292
- $response = array( 'success' => true );
293
  }
294
 
295
- wp_send_json( $response );
296
 
297
- die;
298
  }
299
 
300
- //Awarding Ranks
301
- if( $selected_type == 'ranks' )
302
- {
303
- $rank_to_award = sanitize_text_field( $_REQUEST['rank_to_award'] );
304
 
305
- foreach( $users_to_award as $user_id )
306
- {
307
- if( class_exists( 'myCRED_Ranks_Module' ) && mycred_manual_ranks() )
308
- {
309
- $rank_pt = mycred_get_rank_pt( $rank_to_award );
310
- mycred_save_users_rank( $user_id, $rank_to_award, $rank_pt );
311
- $response = array( 'success' => true );
312
- }
313
- }
314
-
315
- wp_send_json( $response );
316
 
317
- die;
318
  }
 
 
 
 
 
319
 
320
- //Awarding/ Revoking Badges
321
- if( $selected_type == 'badges' )
322
- {
323
- //Awarding Badges
324
- if( $_REQUEST['action'] == 'mycred-tools-assign-award' && !isset( $_REQUEST['revoke'] ) )
325
- {
326
- $badges_to_award = sanitize_text_field( $_REQUEST['badges_to_award'] );
327
 
328
- $badges_to_award = json_decode( stripslashes( $badges_to_award ) );
329
 
330
- if( empty( $badges_to_award ) )
331
- {
332
- $response = array( 'success' => 'badgesFieldRequried' );
333
-
334
- wp_send_json( $response );
 
 
 
 
 
 
 
 
 
 
 
335
 
336
- die;
 
 
337
  }
 
338
 
339
- foreach( $badges_to_award as $badge_id )
340
- {
341
- foreach( $users_to_award as $user_id )
342
- {
343
- $badge_id = (int)$badge_id;
344
 
345
- mycred_assign_badge_to_user( $user_id, $badge_id );
346
- }
347
  }
348
 
349
- $response = array( 'success' => true );
350
-
351
  }
352
-
353
- //Revoking Badges
354
- if( $_REQUEST['action'] == 'mycred-tools-assign-award' && isset( $_REQUEST['revoke'] ) && $_REQUEST['revoke'] == 'revoke' )
355
- {
356
- $badges_to_revoke = sanitize_text_field( $_REQUEST['badges_to_revoke'] );
357
 
358
- $badges_to_revoke = json_decode( stripslashes( $badges_to_revoke ) );
 
 
 
 
 
 
 
 
359
 
360
- if( empty( $badges_to_revoke ) )
361
- {
362
- $response = array( 'success' => 'badgesFieldRequried' );
 
 
363
 
364
- wp_send_json( $response );
365
-
366
- die;
 
367
  }
368
 
369
- foreach( $badges_to_revoke as $badge_id )
370
- {
371
- foreach( $users_to_award as $user_id )
372
- {
373
- $badge = mycred_get_badge( $badge_id );
374
 
375
- $badge->divest( $user_id );
376
- }
377
- }
 
 
 
 
 
378
 
379
- $response = array( 'success' => true );
 
 
 
 
 
 
380
 
381
- }
382
 
383
- wp_send_json( $response );
384
 
385
- die;
386
  }
387
 
388
- endif;
 
 
 
 
389
  }
390
 
391
  /**
@@ -395,6 +448,8 @@ class myCRED_Tools {
395
  */
396
  public function tools_select_user()
397
  {
 
 
398
  if( isset( $_GET['action'] ) && $_GET['action'] == 'mycred-tools-select-user' )
399
  {
400
  $search = sanitize_text_field( $_GET['search'] );
8
  if ( ! class_exists( 'myCRED_Tools' ) ) :
9
  class myCRED_Tools {
10
 
11
+ private $response = array();
12
+
13
  /**
14
  * Construct
15
  */
40
  MYCRED_SLUG . '-tools-script',
41
  'mycredTools',
42
  array(
43
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
44
+ 'token' => wp_create_nonce( 'mycred-tools' ),
45
+ 'awardConfirmText' => __( 'Do you really want to bulk award?', 'mycred' ),
46
+ 'revokeConfirmText' => __( 'Do you really want to bulk deduct?', 'mycred' ),
47
+ 'successfullyAwarded' => __( 'Successfully Awarded.', 'mycred' ),
48
+ 'successfullyDeducted' => __( 'Successfully Deducted.', 'mycred' ),
49
+ 'pointsRequired' => __( 'Points field is required.', 'mycred' ),
50
+ 'logEntryRequired' => __( 'Log Entry is requried.', 'mycred' ),
51
+ 'revokeConfirmText' => __( 'Do you really want to bulk revoke?', 'mycred' ),
52
+ 'successfullyRevoked' => __( 'Successfully Revoked.', 'mycred' ),
53
+ 'userOrRoleIsRequired' => __( 'Username or Role field required.', 'mycred' ),
54
+ 'tryLater' => __( 'Something went wrong try later.', 'mycred' ),
55
+ 'selectPointType' => __( 'Please select point type.', 'mycred' ),
56
+ 'accessDenied' => __( 'Access Denied', 'mycred' ),
57
+ 'selectUser' => __( 'Please select atleast one user.', 'mycred' ),
58
+ 'selectRank' => __( 'Please select rank.', 'mycred' ),
59
+ 'badgesFieldRequried' => __( 'Please select atleast one badge.', 'mycred' ),
60
  )
61
  );
62
  }
193
  return $user_ids;
194
  }
195
 
196
+ public function tools_assign_award() {
 
 
197
 
198
+ check_ajax_referer( 'mycred-tools', 'token' );
199
 
200
+ $this->response = array( 'success' => 'tryLater' );
 
 
201
 
202
+ if( isset( $_REQUEST['selected_type'] ) ) {
 
 
 
 
203
 
204
+ $selected_type = sanitize_text_field( $_REQUEST['selected_type'] );
205
+
206
+ switch ( $selected_type ) {
207
+ case 'points':
208
+ $this->process_points();
209
+ break;
210
+ case 'ranks':
211
+ $this->process_ranks();
212
+ break;
213
+ case 'badges':
214
+ $this->process_badges();
215
+ break;
216
+ default:
217
+ break;
218
  }
219
 
 
220
  }
 
 
 
221
 
222
+ wp_send_json( $this->response );
223
+ wp_die();
224
 
225
+ }
 
 
 
 
 
 
 
 
 
226
 
227
+ private function process_points() {
228
+
229
+ if ( ! isset( $_REQUEST['point_type'] ) ) {
230
+
231
+ $this->response = array( 'success' => 'selectPointType' );
232
+ return;
233
+
234
+ }
235
+
236
+ $point_type = sanitize_text_field( $_REQUEST['point_type'] );
237
+ $current_user_id = get_current_user_id();
238
+ $mycred = mycred( $point_type );
239
+
240
+ if ( ! $mycred->user_is_point_admin( $current_user_id ) ) {
241
+
242
+ $this->response = array( 'success' => 'accessDenied' );
243
+ return;
244
+
245
+ }
246
+
247
+ if ( empty( $_REQUEST['points_to_award'] ) ) {
248
+
249
+ $this->response = array( 'success' => 'pointsRequired' );
250
+ return;
251
+
252
+ }
253
 
254
+ $points_to_award = sanitize_text_field( $_REQUEST['points_to_award'] );
255
 
256
+ $log_entry = isset( $_REQUEST['log_entry'] ) ? ( sanitize_text_field( $_REQUEST['log_entry'] ) == 'true' ? true : false ) : false;
257
+
258
+ $users_to_award = $this->get_requested_users();
259
+
260
+ if ( empty( $users_to_award ) ) return;
261
+
262
+ foreach ( $users_to_award as $user_id ) {
263
+
264
+ if ( $mycred->exclude_user( $user_id ) ) continue;
265
+
266
+ //Entries with log
267
+ if( $log_entry ) {
268
+
269
+ $log_entry_text = isset( $_REQUEST['log_entry_text'] ) ? sanitize_text_field( $_REQUEST['log_entry_text'] ) : '';
270
+
271
+ if( empty( $log_entry_text ) ) {
272
+
273
+ $this->response = array( 'success' => 'logEntryRequired' );
274
+ return;
275
+
276
+ }
277
+
278
+ $mycred->add_creds(
279
+ 'bulk_assign',
280
+ $user_id,
281
+ $points_to_award,
282
+ $log_entry_text
283
+ );
284
+
285
+ }
286
+ else {
287
+
288
+ $new_balance = $mycred->update_users_balance( $user_id, $points_to_award, $point_type );
289
+
290
  }
291
+
292
  }
293
 
294
+ $this->response = array( 'success' => true );
295
+
296
+ }
297
+
298
+ private function process_ranks() {
299
+
300
+ if( class_exists( 'myCRED_Ranks_Module' ) && mycred_manual_ranks() ) {
301
+
302
+ if ( empty( $_REQUEST['rank_to_award'] ) ) {
303
+
304
+ $this->response = array( 'success' => 'selectRank' );
305
+ return;
306
 
307
+ }
 
 
308
 
309
+ $rank_id = intval( $_REQUEST['rank_to_award'] );
310
+ $point_type = mycred_get_rank_pt( $rank_id );
311
+ $current_user_id = get_current_user_id();
312
+ $mycred = mycred( $point_type );
313
+
314
+ if ( ! $mycred->user_is_point_admin( $current_user_id ) ) {
315
+
316
+ $this->response = array( 'success' => 'accessDenied' );
317
+ return;
318
 
 
319
  }
320
 
321
+ $users_to_award = $this->get_requested_users();
322
 
323
+ if ( empty( $users_to_award ) ) return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
 
325
+ foreach ( $users_to_award as $user_id ) {
326
 
327
+ if ( $mycred->exclude_user( $user_id ) ) continue;
328
+
329
+ mycred_save_users_rank( $user_id, $rank_id, $point_type );
 
 
330
 
 
331
  }
332
 
333
+ $this->response = array( 'success' => true );
334
 
 
335
  }
336
 
337
+ }
 
 
 
338
 
339
+ private function process_badges() {
340
+
341
+ $current_user_id = get_current_user_id();
342
+ $mycred = mycred();
343
+ $is_revoke = ( isset( $_REQUEST['revoke'] ) && $_REQUEST['revoke'] == 'revoke' );
344
+
345
+ if ( ! $mycred->user_is_point_admin( $current_user_id ) ) {
346
+
347
+ $this->response = array( 'success' => 'accessDenied' );
348
+ return;
 
349
 
 
350
  }
351
+
352
+ if ( $is_revoke )
353
+ $selected_badges = isset( $_REQUEST['badges_to_revoke'] ) ? sanitize_text_field( $_REQUEST['badges_to_revoke'] ) : '';
354
+ else
355
+ $selected_badges = isset( $_REQUEST['badges_to_award'] ) ? sanitize_text_field( $_REQUEST['badges_to_award'] ) : '';
356
 
357
+ $selected_badges = json_decode( stripslashes( $selected_badges ) );
 
 
 
 
 
 
358
 
359
+ if( empty( $selected_badges ) ) {
360
 
361
+ $this->response = array( 'success' => 'badgesFieldRequried' );
362
+ return;
363
+
364
+ }
365
+
366
+ $selected_users = $this->get_requested_users();
367
+
368
+ if ( empty( $selected_users ) ) return;
369
+
370
+ foreach( $selected_badges as $badge_id ) {
371
+
372
+ foreach( $selected_users as $user_id ) {
373
+
374
+ if ( $mycred->exclude_user( $user_id ) ) continue;
375
+
376
+ if ( $is_revoke ) {
377
 
378
+ $badge = mycred_get_badge( (int) $badge_id );
379
+ $badge->divest( $user_id );
380
+
381
  }
382
+ else {
383
 
384
+ mycred_assign_badge_to_user( $user_id, (int) $badge_id );
 
 
 
 
385
 
 
 
386
  }
387
 
 
 
388
  }
 
 
 
 
 
389
 
390
+ }
391
+
392
+ $this->response = array( 'success' => true );
393
+
394
+ }
395
+
396
+ private function get_requested_users() {
397
+
398
+ $users_to_award = array();
399
 
400
+ if ( isset( $_REQUEST['award_to_all_users'] ) ) {
401
+
402
+ $award_to_all_users = sanitize_text_field( $_REQUEST['award_to_all_users'] ) == 'true' ? true : false;
403
+
404
+ if ( $award_to_all_users ) {
405
 
406
+ $users = $this->get_all_users();
407
+
408
+ foreach( $users as $email => $user_name ) {
409
+ $users_to_award[] = $email;
410
  }
411
 
412
+ $users_to_award = $this->get_users_by_email( $users_to_award );
 
 
 
 
413
 
414
+ }
415
+ else {
416
+
417
+ $selected_users = isset( $_REQUEST['users'] ) ? sanitize_text_field( $_REQUEST['users'] ) : '[]';
418
+ $selected_user_roles = isset( $_REQUEST['user_roles'] ) ? sanitize_text_field( $_REQUEST['user_roles'] ) : '[]';
419
+
420
+ $selected_users = json_decode( stripslashes( $selected_users ) );
421
+ $selected_user_roles = json_decode( stripslashes( $selected_user_roles ) );
422
 
423
+ $users_to_award = $this->get_users_by_email( $selected_users );
424
+
425
+ if( ! empty( $selected_user_roles ) ) {
426
+
427
+ $users_by_role = $this->get_users_by_role( $selected_user_roles );
428
+ $users_to_award = array_merge( $users_by_role, $users_to_award );
429
+ $users_to_award = array_unique( $users_to_award );
430
 
431
+ }
432
 
433
+ }
434
 
 
435
  }
436
 
437
+ if ( empty( $users_to_award ) )
438
+ $this->response = array( 'success' => 'selectUser' );
439
+
440
+ return $users_to_award;
441
+
442
  }
443
 
444
  /**
448
  */
449
  public function tools_select_user()
450
  {
451
+ check_ajax_referer( 'mycred-tools', 'token' );
452
+
453
  if( isset( $_GET['action'] ) && $_GET['action'] == 'mycred-tools-select-user' )
454
  {
455
  $search = sanitize_text_field( $_GET['search'] );
includes/mycred-update.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
 
 
includes/mycred-widgets.php DELETED
@@ -1,634 +0,0 @@
1
- <?php
2
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
3
-
4
- /**
5
- * Widget: myCRED Balance
6
- * @since 0.1
7
- * @version 1.4.3
8
- */
9
- if ( ! class_exists( 'myCRED_Widget_Balance' ) ) :
10
- class myCRED_Widget_Balance extends WP_Widget {
11
-
12
- /**
13
- * Construct
14
- */
15
- public function __construct() {
16
-
17
- parent::__construct(
18
- 'mycred_widget_balance',
19
- sprintf( __( '(%s) My Balance', 'mycred' ), mycred_label( true ) ),
20
- array(
21
- 'classname' => 'widget-my-cred',
22
- 'description' => __( 'Show the current users balance and history.', 'mycred' )
23
- )
24
- );
25
-
26
- }
27
-
28
- /**
29
- * Widget Output
30
- */
31
- public function widget( $args, $instance ) {
32
-
33
- extract( $args, EXTR_SKIP );
34
-
35
- // Make sure we always have a type set
36
- if ( ! isset( $instance['type'] ) || $instance['type'] == '' )
37
- $instance['type'] = MYCRED_DEFAULT_TYPE_KEY;
38
-
39
- // If we are logged in
40
- if ( is_user_logged_in() ) {
41
-
42
- // Get Current Users Account Object
43
- $account = mycred_get_account();
44
- if ( $account === false ) return;
45
-
46
- // Excluded users have no balance(s)
47
- if ( empty( $account->balance ) || ! array_key_exists( $instance['type'], $account->balance ) ) return;
48
-
49
- // Get balance object
50
- $balance = $account->balance[ $instance['type'] ];
51
- $mycred = mycred( $instance['type'] );
52
-
53
- // Start
54
- echo $before_widget;
55
-
56
- // Title
57
- if ( ! empty( $instance['title'] ) )
58
- echo $before_title . $instance['title'] . $after_title;
59
-
60
- $layout = $mycred->template_tags_amount( $instance['cred_format'], $balance->current );
61
- $layout = $mycred->template_tags_user( $layout, false, wp_get_current_user() );
62
-
63
- echo '<div class="myCRED-balance ' . esc_attr( $instance['type'] ) . '">' . do_shortcode( $layout ) . '</div>';
64
-
65
- // If we want to include history
66
- if ( $instance['show_history'] ) {
67
-
68
- echo '<div class="myCRED-widget-history">';
69
-
70
- // Query Log
71
- $log = new myCRED_Query_Log( array(
72
- 'user_id' => $account->user_id,
73
- 'number' => $instance['number'],
74
- 'ctype' => $instance['type']
75
- ) );
76
-
77
- // Have results
78
- if ( $log->have_entries() ) {
79
-
80
- // Title
81
- if ( ! empty( $instance['history_title'] ) )
82
- echo $before_title . $mycred->template_tags_general( $instance['history_title'] ) . $after_title;
83
-
84
- // Organized List
85
- echo '<ol class="myCRED-history">';
86
- $alt = 0;
87
- $date_format = get_option( 'date_format' );
88
- foreach ( $log->results as $entry ) {
89
-
90
- // Row Layout
91
- $layout = $instance['history_format'];
92
-
93
- $layout = str_replace( '%date%', '<span class="date">' . date( $date_format, $entry->time ) . '</span>', $layout );
94
- $layout = str_replace( '%entry%', $mycred->parse_template_tags( $entry->entry, $entry ), $layout );
95
-
96
- $layout = $mycred->template_tags_amount( $layout, $entry->creds );
97
-
98
- // Alternating rows
99
- $alt = $alt+1;
100
- if ( $alt % 2 == 0 ) $class = 'row alternate';
101
- else $class = 'row';
102
-
103
- // Output list item
104
- echo '<li class="' . $class . '">' . $layout . '</li>';
105
-
106
- }
107
- echo '</ol>';
108
-
109
- }
110
- $log->reset_query();
111
-
112
- echo '</div>';
113
- }
114
-
115
- // End
116
- echo $after_widget;
117
-
118
- }
119
-
120
- // Visitor
121
- else {
122
-
123
- // If we want to show a message, then do so
124
- if ( $instance['show_visitors'] ) {
125
-
126
- echo $before_widget;
127
-
128
- $mycred = mycred( $instance['type'] );
129
-
130
- // Title
131
- if ( ! empty( $instance['title'] ) )
132
- echo $before_title . $instance['title'] . $after_title;
133
-
134
- $message = $instance['message'];
135
- $message = $mycred->template_tags_general( $message );
136
- $message = $mycred->allowed_tags( $message );
137
-
138
- echo '<div class="myCRED-my-balance-message"><p>' . nl2br( $message ) . '</p></div>';
139
-
140
- echo $after_widget;
141
-
142
- }
143
-
144
- }
145
-
146
- }
147
-
148
- /**
149
- * Outputs the options form on admin
150
- */
151
- public function form( $instance ) {
152
-
153
- // Defaults
154
- $title = isset( $instance['title'] ) ? $instance['title'] : 'My Balance';
155
- $type = isset( $instance['type'] ) ? $instance['type'] : MYCRED_DEFAULT_TYPE_KEY;
156
- $cred_format = isset( $instance['cred_format'] ) ? $instance['cred_format'] : '%cred_f%';
157
- $show_history = isset( $instance['show_history'] ) ? $instance['show_history'] : 0;
158
- $history_title = isset( $instance['history_title'] ) ? $instance['history_title'] : '%plural% History';
159
- $history_entry = isset( $instance['history_format'] ) ? $instance['history_format'] : '%entry% <span class="creds">%cred_f%</span>';
160
- $history_length = isset( $instance['number'] ) ? $instance['number'] : 5;
161
- $show_visitors = isset( $instance['show_visitors'] ) ? $instance['show_visitors'] : 0;
162
- $message = isset( $instance['message'] ) ? $instance['message'] : '<a href="%login_url_here%">Login</a> to view your balance.';
163
-
164
- $mycred = mycred( $type );
165
- $mycred_types = mycred_get_types();
166
-
167
- ?>
168
- <!-- Widget Admin Styling -->
169
- <style type="text/css">
170
- div.mycred-hidden { display: none; }
171
- div.mycred-hidden.ex-field { display: block; }
172
- </style>
173
-
174
- <!-- Widget Options -->
175
- <p class="myCRED-widget-field">
176
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'mycred' ); ?>:</label>
177
- <input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" class="widefat" />
178
- </p>
179
-
180
- <!-- Point Type -->
181
- <?php if ( count( $mycred_types ) > 1 ) : ?>
182
- <p class="myCRED-widget-field">
183
- <label for="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>"><?php _e( 'Point Type', 'mycred' ); ?>:</label>
184
- <?php mycred_types_select_from_dropdown( $this->get_field_name( 'type' ), $this->get_field_id( 'type' ), $type ); ?>
185
- </p>
186
- <?php else : ?>
187
- <?php mycred_types_select_from_dropdown( $this->get_field_name( 'type' ), $this->get_field_id( 'type' ), $type ); ?>
188
- <?php endif; ?>
189
-
190
- <!-- Balance layout -->
191
- <p class="myCRED-widget-field">
192
- <label for="<?php echo esc_attr( $this->get_field_id( 'cred_format' ) ); ?>"><?php _e( 'Balance Layout', 'mycred' ); ?>:</label>
193
- <textarea name="<?php echo esc_attr( $this->get_field_name( 'cred_format' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'cred_format' ) ); ?>" rows="3" cols="20" class="widefat"><?php echo esc_attr( $cred_format ); ?></textarea>
194
- <small><?php echo $mycred->available_template_tags( array( 'general', 'amount', 'user' ) ); ?></small>
195
- </p>
196
-
197
- <!-- History -->
198
- <p class="myCRED-widget-field">
199
- <label for="<?php echo esc_attr( $this->get_field_id( 'show_history' ) ); ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_history' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_history' ) ); ?>" value="1"<?php checked( $show_history, 1 ); ?> class="checkbox" /> <?php _e( 'Include history', 'mycred' ); ?></label>
200
- </p>
201
- <div id="<?php echo esc_attr( $this->get_field_id( 'show_history' ) ); ?>-details" class="mycred-hidden<?php if ( $show_history == 1 ) echo ' ex-field'; ?>">
202
- <p class="myCRED-widget-field">
203
- <label for="<?php echo esc_attr( $this->get_field_id( 'history_title' ) ); ?>"><?php _e( 'History Title', 'mycred' ); ?>:</label>
204
- <input id="<?php echo esc_attr( $this->get_field_id( 'history_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'history_title' ) ); ?>" type="text" value="<?php echo esc_attr( $history_title ); ?>" class="widefat" />
205
- </p>
206
- <p class="myCRED-widget-field">
207
- <label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php _e( 'Number of entires', 'mycred' ); ?>:</label>
208
- <input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo absint( $history_length ); ?>" size="3" class="widefat" /><br />
209
- </p>
210
- <p class="myCRED-widget-field">
211
- <label for="<?php echo esc_attr( $this->get_field_id( 'history_format' ) ); ?>"><?php _e( 'Row layout', 'mycred' ); ?>:</label>
212
- <textarea name="<?php echo esc_attr( $this->get_field_name( 'history_format' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'history_format' ) ); ?>" rows="3" cols="20" class="widefat"><?php echo esc_attr( $history_entry ); ?></textarea>
213
- <small><?php echo $mycred->available_template_tags( array( 'general', 'widget' ) ); ?></small>
214
- </p>
215
- </div>
216
- <!-- Show to Visitors -->
217
- <p class="myCRED-widget-field">
218
- <label for="<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_visitors' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>" value="1"<?php checked( $show_visitors, 1 ); ?> class="checkbox" /> <?php _e( 'Show message when not logged in', 'mycred' ); ?></label>
219
- </p>
220
- <div id="<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>-details" class="mycred-hidden<?php if ( $show_visitors == 1 ) echo ' ex-field'; ?>">
221
- <p class="myCRED-widget-field">
222
- <label for="<?php echo esc_attr( $this->get_field_id( 'message' ) ); ?>"><?php _e( 'Message', 'mycred' ); ?>:</label>
223
- <textarea name="<?php echo esc_attr( $this->get_field_name( 'message' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'message' ) ); ?>" rows="3" cols="20" class="widefat"><?php echo esc_attr( $message ); ?></textarea>
224
- <small><?php echo $mycred->available_template_tags( array( 'general', 'amount' ) ); ?></small>
225
- </p>
226
- </div>
227
- <!-- Widget Admin Scripting -->
228
- <script type="text/javascript">//<![CDATA[
229
- jQuery(function($) {
230
-
231
- $( '#<?php echo esc_attr( $this->get_field_id( 'show_history' ) ); ?>, #<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>' ).change(function(){
232
- $( '#' + $(this).attr( 'id' ) + '-details' ).toggleClass( 'ex-field' );
233
- });
234
-
235
- });//]]>
236
- </script>
237
- <?php
238
-
239
- }
240
-
241
- /**
242
- * Processes widget options to be saved
243
- */
244
- public function update( $new_instance, $old_instance ) {
245
-
246
- $instance = $old_instance;
247
-
248
- $instance['title'] = wp_kses_post( $new_instance['title'] );
249
- $instance['type'] = sanitize_text_field( $new_instance['type'] );
250
- $instance['cred_format'] = wp_kses_post( $new_instance['cred_format'] );
251
- $instance['show_history'] = ( isset( $new_instance['show_history'] ) ) ? 1 : 0;
252
- $instance['history_title'] = wp_kses_post( $new_instance['history_title'] );
253
- $instance['history_format'] = wp_kses_post( $new_instance['history_format'] );
254
- $instance['number'] = absint( $new_instance['number'] );
255
- $instance['show_visitors'] = ( isset( $new_instance['show_visitors'] ) ) ? 1 : 0;
256
- $instance['message'] = wp_kses_post( $new_instance['message'] );
257
-
258
- mycred_flush_widget_cache( 'mycred_widget_balance' );
259
-
260
- return $instance;
261
-
262
- }
263
-
264
- }
265
- endif;
266
-
267
- /**
268
- * Widget: Leaderboard
269
- * @since 0.1
270
- * @version 1.3.2
271
- */
272
- if ( ! class_exists( 'myCRED_Widget_Leaderboard' ) ) :
273
- class myCRED_Widget_Leaderboard extends WP_Widget {
274
-
275
- /**
276
- * Construct
277
- */
278
- public function __construct() {
279
-
280
- parent::__construct(
281
- 'mycred_widget_list',
282
- sprintf( __( '(%s) Leaderboard', 'mycred' ), mycred_label( true ) ),
283
- array(
284
- 'classname' => 'widget-mycred-list',
285
- 'description' => __( 'Leaderboard based on instances or balances.', 'mycred' )
286
- )
287
- );
288
-
289
- }
290
-
291
- /**
292
- * Widget Output
293
- */
294
- public function widget( $args, $instance ) {
295
-
296
- extract( $args, EXTR_SKIP );
297
-
298
- // Check if we want to show this to visitors
299
- if ( ! $instance['show_visitors'] && ! is_user_logged_in() ) return;
300
-
301
- if ( ! isset( $instance['type'] ) || empty( $instance['type'] ) )
302
- $instance['type'] = MYCRED_DEFAULT_TYPE_KEY;
303
-
304
- $mycred = mycred( $instance['type'] );
305
-
306
- // Get Rankings
307
- $args = array(
308
- 'number' => $instance['number'],
309
- 'template' => $instance['text'],
310
- 'type' => $instance['type'],
311
- 'based_on' => $instance['based_on']
312
- );
313
-
314
- if ( isset( $instance['order'] ) )
315
- $args['order'] = $instance['order'];
316
-
317
- if ( isset( $instance['offset'] ) )
318
- $args['offset'] = $instance['offset'];
319
-
320
- if ( isset( $instance['current'] ) )
321
- $args['current'] = 1;
322
-
323
- echo $before_widget;
324
-
325
- // Title
326
- if ( ! empty( $instance['title'] ) )
327
- echo $before_title . $mycred->template_tags_general( $instance['title'] ) . $after_title;
328
-
329
- echo mycred_render_shortcode_leaderboard( $args );
330
-
331
- // Footer
332
- echo $after_widget;
333
- }
334
-
335
- /**
336
- * Outputs the options form on admin
337
- */
338
- public function form( $instance ) {
339
-
340
- // Defaults
341
- $title = isset( $instance['title'] ) ? $instance['title'] : 'Leaderboard';
342
- $type = isset( $instance['type'] ) ? $instance['type'] : MYCRED_DEFAULT_TYPE_KEY;
343
- $based_on = isset( $instance['based_on'] ) ? $instance['based_on'] : 'balance';
344
-
345
- $number = isset( $instance['number'] ) ? $instance['number'] : 5;
346
- $show_visitors = isset( $instance['show_visitors'] ) ? $instance['show_visitors'] : 0;
347
- $text = isset( $instance['text'] ) ? $instance['text'] : '#%position% %user_profile_link% %cred_f%';
348
- $offset = isset( $instance['offset'] ) ? $instance['offset'] : 0;
349
- $order = isset( $instance['order'] ) ? $instance['order'] : 'DESC';
350
- $current = isset( $instance['current'] ) ? $instance['current'] : 0;
351
- $timeframe = isset( $instance['timeframe'] ) ? $instance['timeframe'] : '';
352
- $exclude = isset( $instance['exclude'] ) ? $instance['exclude'] : '';
353
- $mycred = mycred( $type );
354
- $mycred_types = mycred_get_types();
355
-
356
- ?>
357
- <p class="myCRED-widget-field">
358
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'mycred' ); ?>:</label>
359
- <input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" class="widefat" />
360
- </p>
361
-
362
- <?php if ( count( $mycred_types ) > 1 ) : ?>
363
- <p class="myCRED-widget-field">
364
- <label for="<?php echo esc_attr( $this->get_field_id( 'type' ) ); ?>"><?php _e( 'Point Type', 'mycred' ); ?>:</label>
365
- <?php mycred_types_select_from_dropdown( $this->get_field_name( 'type' ), $this->get_field_id( 'type' ), $type ); ?>
366
- </p>
367
- <?php else : ?>
368
- <?php mycred_types_select_from_dropdown( $this->get_field_name( 'type' ), $this->get_field_id( 'type' ), $type ); ?>
369
- <?php endif; ?>
370
-
371
- <p class="myCRED-widget-field">
372
- <label for="<?php echo esc_attr( $this->get_field_id( 'based_on' ) ); ?>"><?php _e( 'Based On', 'mycred' ); ?>:</label>
373
- <input id="<?php echo esc_attr( $this->get_field_id( 'based_on' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'based_on' ) ); ?>" type="text" value="<?php echo esc_attr( $based_on ); ?>" class="widefat" />
374
- <small><?php _e( 'Use "balance" to base the leaderboard on your users current balances or use a specific reference.', 'mycred' ); ?> <a href="http://codex.mycred.me/chapter-vi/log-references/" target="_blank"><?php _e( 'Reference Guide', 'mycred' ); ?></a></small>
375
- </p>
376
-
377
- <p class="myCRED-widget-field">
378
- <label for="<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_visitors' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>" value="1"<?php checked( $show_visitors, 1 ); ?> class="checkbox" /> <?php _e( 'Visible to non-members', 'mycred' ); ?></label>
379
- </p>
380
- <p class="myCRED-widget-field">
381
- <label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php _e( 'Number of users', 'mycred' ); ?>:</label>
382
- <input id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>" type="text" value="<?php echo absint( $number ); ?>" size="3" class="widefat" />
383
- </p>
384
- <p class="myCRED-widget-field">
385
- <label for="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>"><?php _e( 'Row layout', 'mycred' ); ?>:</label>
386
- <textarea name="<?php echo esc_attr( $this->get_field_name( 'text' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'text' ) ); ?>" rows="3" cols="20" class="widefat"><?php echo esc_attr( $text ); ?></textarea>
387
- <small><?php echo $mycred->available_template_tags( array( 'general', 'balance' ) ); ?></small>
388
- </p>
389
- <p class="myCRED-widget-field">
390
- <label for="<?php echo esc_attr( $this->get_field_id( 'offset' ) ); ?>"><?php _e( 'Offset', 'mycred' ); ?>:</label>
391
- <input id="<?php echo esc_attr( $this->get_field_id( 'offset' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'offset' ) ); ?>" type="text" value="<?php echo absint( $offset ); ?>" size="3" class="widefat" />
392
- <small><?php _e( 'Optional offset of order. Use zero to return the first in the list.', 'mycred' ); ?></small>
393
- </p>
394
- <p class="myCRED-widget-field">
395
- <label for="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>"><?php _e( 'Order', 'mycred' ); ?>:</label>
396
- <select name="<?php echo esc_attr( $this->get_field_name( 'order' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'order' ) ); ?>">
397
- <?php
398
-
399
- $options = array(
400
- 'ASC' => __( 'Ascending', 'mycred' ),
401
- 'DESC' => __( 'Descending', 'mycred' )
402
- );
403
-
404
- foreach ( $options as $value => $label ) {
405
- echo '<option value="' . $value . '"';
406
- if ( $order == $value ) echo ' selected="selected"';
407
- echo '>' . $label . '</option>';
408
- }
409
-
410
- ?>
411
- </select>
412
- </p>
413
- <p class="myCRED-widget-field">
414
- <label for="<?php echo esc_attr( $this->get_field_id( 'current' ) ); ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'current' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'current' ) ); ?>" value="1"<?php checked( $current, 1 ); ?> class="checkbox" /> <?php _e( 'Append current users position', 'mycred' ); ?></label><br />
415
- <small><?php _e( 'If the current user is not in this leaderboard, you can select to append them at the end with their current position.', 'mycred' ); ?></small>
416
- </p>
417
- <p class="myCRED-widget-field">
418
- <label for="<?php echo esc_attr( $this->get_field_id( 'timeframe' ) ); ?>"><?php _e( 'Timeframe', 'mycred' ); ?>:</label>
419
- <input id="<?php echo esc_attr( $this->get_field_id( 'timeframe' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'timeframe' ) ); ?>" type="text" value="<?php echo esc_attr( $timeframe ); ?>" size="3" class="widefat" />
420
- <small><?php _e( 'Option to limit the leaderboard based on a specific timeframe. Leave empty if not used.', 'mycred' ); ?></small>
421
- </p>
422
- <p class="myCRED-widget-field">
423
- <label for="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>"><?php _e( 'Exclude Users', 'mycred' ); ?>:</label>
424
- <input id="<?php echo esc_attr( $this->get_field_id( 'exclude' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'timeframe' ) ); ?>" type="text" value="<?php echo esc_attr( $timeframe ); ?>" size="3" class="widefat" />
425
- <small><?php _e( 'Option to exclude users from leaderboard based on a specific role or id. Leave empty if not used. Use comma seperated values for Role or ID', 'mycred' ); ?></small>
426
- </p>
427
- <?php
428
-
429
- }
430
-
431
- /**
432
- * Processes widget options to be saved
433
- */
434
- public function update( $new_instance, $old_instance ) {
435
-
436
- $instance = $old_instance;
437
-
438
- $instance['number'] = absint( $new_instance['number'] );
439
- $instance['title'] = wp_kses_post( $new_instance['title'] );
440
- $instance['type'] = sanitize_key( $new_instance['type'] );
441
- $instance['based_on'] = sanitize_key( $new_instance['based_on'] );
442
- $instance['show_visitors'] = ( isset( $new_instance['show_visitors'] ) ) ? 1 : 0;
443
- $instance['text'] = wp_kses_post( $new_instance['text'] );
444
- $instance['offset'] = sanitize_text_field( $new_instance['offset'] );
445
- $instance['order'] = sanitize_text_field( $new_instance['order'] );
446
- $instance['current'] = ( isset( $new_instance['current'] ) ) ? 1 : 0;
447
- $instance['timeframe'] = sanitize_text_field( $new_instance['timeframe'] );
448
- $instance['exclude'] = sanitize_text_field( $new_instance['exclude'] );
449
-
450
- mycred_flush_widget_cache( 'mycred_widget_list' );
451
-
452
- return $instance;
453
-
454
- }
455
-
456
- }
457
- endif;
458
-
459
- /**
460
- * Widget: myCRED Wallet
461
- * @since 1.4
462
- * @version 1.2
463
- */
464
- if ( ! class_exists( 'myCRED_Widget_Wallet' ) ) :
465
- class myCRED_Widget_Wallet extends WP_Widget {
466
-
467
- /**
468
- * Construct
469
- */
470
- public function __construct() {
471
-
472
- parent::__construct(
473
- 'mycred_widget_wallet',
474
- sprintf( __( '(%s) Wallet', 'mycred' ), mycred_label( true ) ),
475
- array(
476
- 'classname' => 'widget-my-wallet',
477
- 'description' => __( 'Shows multiple balances.', 'mycred' )
478
- )
479
- );
480
-
481
- }
482
-
483
- /**
484
- * Widget Output
485
- */
486
- public function widget( $args, $instance ) {
487
-
488
- extract( $args, EXTR_SKIP );
489
-
490
- $mycred = mycred();
491
-
492
- // If we are logged in
493
- if ( is_user_logged_in() ) {
494
-
495
- if ( ! isset( $instance['types'] ) || empty( $instance['types'] ) )
496
- $instance['types'] = array( MYCRED_DEFAULT_TYPE_KEY );
497
-
498
- // Get Current Users Account Object
499
- $account = mycred_get_account();
500
- if ( $account === false ) return;
501
-
502
- // Excluded users have no balance(s)
503
- if ( empty( $account->balance ) || empty( $instance['types'] ) ) return;
504
-
505
- // Start
506
- echo $before_widget;
507
-
508
- // Title
509
- if ( ! empty( $instance['title'] ) )
510
- echo $before_title . $instance['title'] . $after_title;
511
-
512
- $current_user = wp_get_current_user();
513
-
514
- // Loop through balances
515
- foreach ( $account->balance as $point_type_id => $balance ) {
516
-
517
- if ( ! in_array( $point_type_id, (array) $instance['types'] ) ) continue;
518
-
519
- $point_type = mycred( $point_type_id );
520
-
521
- $layout = $instance['row'];
522
- $layout = $point_type->template_tags_amount( $layout, $balance->current );
523
- $layout = $point_type->template_tags_user( $layout, false, $current_user );
524
- $layout = str_replace( '%label%', $account->point_types[ $point_type_id ], $layout );
525
-
526
- echo '<div class="myCRED-balance mycred-balance-' . esc_attr( $point_type_id ) . '">' . do_shortcode( $layout ) . '</div>';
527
-
528
- }
529
-
530
- // End
531
- echo $after_widget;
532
-
533
- }
534
-
535
- // Visitor
536
- elseif ( ! is_user_logged_in() && $instance['show_visitors'] ) {
537
-
538
- echo $before_widget;
539
-
540
- // Title
541
- if ( ! empty( $instance['title'] ) )
542
- echo $before_title . $instance['title'] . $after_title;
543
-
544
- $message = $instance['message'];
545
- $message = $mycred->template_tags_general( $message );
546
-
547
- echo '<div class="myCRED-wallet-message"><p>' . wptexturize( $message ) . '</p></div>';
548
-
549
- echo $after_widget;
550
-
551
- }
552
-
553
- }
554
-
555
- /**
556
- * Outputs the options form on admin
557
- */
558
- public function form( $instance ) {
559
-
560
- $mycred = mycred();
561
-
562
- // Defaults
563
- $title = isset( $instance['title'] ) ? $instance['title'] : 'My Wallet';
564
- $types = isset( $instance['types'] ) ? $instance['types'] : array();
565
- $row_template = isset( $instance['row'] ) ? $instance['row'] : '%label%: %cred_f%';
566
- $show_visitors = isset( $instance['show_visitors'] ) ? $instance['show_visitors'] : 0;
567
- $message = isset( $instance['message'] ) ? $instance['message'] : '<a href="%login_url_here%">Login</a> to view your balance.';
568
-
569
- ?>
570
- <!-- Widget Options -->
571
- <p class="myCRED-widget-field">
572
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'mycred' ); ?>:</label>
573
- <input id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" class="widefat" />
574
- </p>
575
-
576
- <!-- Point Type -->
577
- <p class="myCRED-widget-field">
578
- <label for="<?php echo esc_attr( $this->get_field_id( 'types' ) ); ?>"><?php _e( 'Point Types', 'mycred' ); ?>:</label><br />
579
- <?php mycred_types_select_from_checkboxes( $this->get_field_name( 'types' ) . '[]', $this->get_field_id( 'types' ), $types ); ?>
580
- </p>
581
-
582
- <!-- Row layout -->
583
- <p class="myCRED-widget-field">
584
- <label for="<?php echo esc_attr( $this->get_field_id( 'row' ) ); ?>"><?php _e( 'Row Layout', 'mycred' ); ?>:</label>
585
- <textarea name="<?php echo esc_attr( $this->get_field_name( 'row' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'row' ) ); ?>" rows="3" cols="20" class="widefat"><?php echo esc_attr( $row_template ); ?></textarea>
586
- <small><?php echo $mycred->available_template_tags( array( 'general', 'amount' ) ); ?></small>
587
- </p>
588
-
589
- <!-- Show to Visitors -->
590
- <p class="myCRED-widget-field">
591
- <label for="<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'show_visitors' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>" value="1"<?php checked( $show_visitors, 1 ); ?> class="checkbox" /> <?php _e( 'Show message when not logged in', 'mycred' ); ?></label>
592
- </p>
593
- <div id="<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>-details" class="mycred-hidden<?php if ( $show_visitors == 1 ) echo ' ex-field'; ?>">
594
- <p class="myCRED-widget-field">
595
- <label for="<?php echo esc_attr( $this->get_field_id( 'message' ) ); ?>"><?php _e( 'Message', 'mycred' ); ?>:</label>
596
- <textarea name="<?php echo esc_attr( $this->get_field_name( 'message' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'message' ) ); ?>" rows="3" cols="20" class="widefat"><?php echo esc_attr( $message ); ?></textarea>
597
- <small><?php echo $mycred->available_template_tags( array( 'general', 'amount' ) ); ?></small>
598
- </p>
599
- </div>
600
- <!-- Widget Admin Scripting -->
601
- <script type="text/javascript">//<![CDATA[
602
- jQuery(function($) {
603
-
604
- $( '#<?php echo esc_attr( $this->get_field_id( 'show_visitors' ) ); ?>' ).change(function(){
605
- $( '#' + $(this).attr( 'id' ) + '-details' ).toggleClass( 'ex-field' );
606
- });
607
-
608
- });//]]>
609
- </script>
610
- <?php
611
-
612
- }
613
-
614
- /**
615
- * Processes widget options to be saved
616
- */
617
- public function update( $new_instance, $old_instance ) {
618
-
619
- $instance = $old_instance;
620
-
621
- $instance['title'] = wp_kses_post( $new_instance['title'] );
622
- $instance['types'] = (array) $new_instance['types'];
623
- $instance['row'] = wp_kses_post( $new_instance['row'] );
624
- $instance['show_visitors'] = ( isset( $new_instance['show_visitors'] ) ) ? 1 : 0;
625
- $instance['message'] = wp_kses_post( $new_instance['message'] );
626
-
627
- mycred_flush_widget_cache( 'mycred_widget_wallet' );
628
-
629
- return $instance;
630
-
631
- }
632
-
633
- }
634
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
membership/mycred-connect-membership.php CHANGED
@@ -109,7 +109,12 @@ if ( ! class_exists( 'myCRED_Connect_Membership' ) ) :
109
  );
110
  }
111
 
112
- public function mycred_support_callback() {?>
 
 
 
 
 
113
  <div class="wrap mycred-support-page-container">
114
  <h1 class="wp-heading-inline">myCred Help and Support</h1>
115
 
@@ -142,11 +147,20 @@ if ( ! class_exists( 'myCRED_Connect_Membership' ) ) :
142
 
143
  <h2>myCred Add-ons Update:</h2>
144
  <p>For our users' convenience and their site optimization, we made a unified license system for individual and membership users. <a href="<?php echo admin_url('options.php?page=mycred-update'); ?>">Click here to update your add-ons</a></p>
 
 
 
 
 
 
 
 
145
 
146
  </div>
147
-
148
 
149
  </div>
 
 
150
  <?php
151
  }
152
 
109
  );
110
  }
111
 
112
+ public function mycred_support_callback() {
113
+
114
+ $references = mycred_get_all_references();
115
+
116
+ ?>
117
+
118
  <div class="wrap mycred-support-page-container">
119
  <h1 class="wp-heading-inline">myCred Help and Support</h1>
120
 
147
 
148
  <h2>myCred Add-ons Update:</h2>
149
  <p>For our users' convenience and their site optimization, we made a unified license system for individual and membership users. <a href="<?php echo admin_url('options.php?page=mycred-update'); ?>">Click here to update your add-ons</a></p>
150
+ <hr>
151
+
152
+ <h2>myCred Log References:</h2>
153
+ <div class="row mycred-all-references-list">
154
+ <?php foreach ( $references as $key => $entry ):?>
155
+ <div class="col-md-6 mb-2"><code><?php echo $key;?></code> - <?php echo $entry;?></div>
156
+ <?php endforeach;?>
157
+ </div>
158
 
159
  </div>
 
160
 
161
  </div>
162
+
163
+
164
  <?php
165
  }
166
 
modules/mycred-module-buddypress.php CHANGED
@@ -180,7 +180,7 @@ if ( ! class_exists( 'myCRED_BuddyPress_Module' ) ) :
180
  $balance = $mycred->get_users_balance( $user_id, $type );
181
 
182
  // Output
183
- if($buddyboss_settings['types']['sort'][$type] == true && class_exists( 'BuddyPress' ) && is_plugin_active('mycred-buddyboss/mycred-buddyboss.php')) {
184
  $template = str_replace( '%label%', $label, $template );
185
  $template = $mycred->template_tags_general( $template );
186
  $output .= '<div class="mycred-balance mycred-' . $type . '">' . $template . ' ' . $mycred->format_creds( $balance ) . '</div>';
180
  $balance = $mycred->get_users_balance( $user_id, $type );
181
 
182
  // Output
183
+ if(!empty($buddyboss_settings) && $buddyboss_settings['types']['sort'][$type] == true && class_exists( 'BuddyPress' ) && is_plugin_active('mycred-buddyboss/mycred-buddyboss.php')) {
184
  $template = str_replace( '%label%', $label, $template );
185
  $template = $mycred->template_tags_general( $template );
186
  $output .= '<div class="mycred-balance mycred-' . $type . '">' . $template . ' ' . $mycred->format_creds( $balance ) . '</div>';
modules/mycred-module-settings.php CHANGED
@@ -698,7 +698,7 @@ if ( ! class_exists( 'myCRED_Settings_Module' ) ) :
698
  </div>
699
  <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">
700
  <div class="form-group">
701
- <label for="<?php echo $excluded_ids_args['id']; ?>"><?php _e( 'Exclude by User ID', 'mycred' ); ?></label>
702
  <?php echo mycred_create_select2( $all_users, $excluded_ids_args, $excluded_ids ); ?>
703
  </div>
704
  <div class="form-group">
@@ -1234,6 +1234,8 @@ if ( ! class_exists( 'myCRED_Settings_Module' ) ) :
1234
  */
1235
  public function get_users()
1236
  {
 
 
1237
  if( isset( $_GET['action'] ) && $_GET['action'] == 'mycred-get-users-to-exclude' )
1238
  {
1239
  $search = sanitize_text_field( $_GET['search'] );
698
  </div>
699
  <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">
700
  <div class="form-group">
701
+ <label for="<?php echo $excluded_ids_args['id']; ?>"><?php _e( 'Exclude Users', 'mycred' ); ?></label>
702
  <?php echo mycred_create_select2( $all_users, $excluded_ids_args, $excluded_ids ); ?>
703
  </div>
704
  <div class="form-group">
1234
  */
1235
  public function get_users()
1236
  {
1237
+ check_ajax_referer( 'mycred-management-actions', 'token' );
1238
+
1239
  if( isset( $_GET['action'] ) && $_GET['action'] == 'mycred-get-users-to-exclude' )
1240
  {
1241
  $search = sanitize_text_field( $_GET['search'] );
mycred.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: myCred
4
  * Plugin URI: https://mycred.me
5
  * Description: An adaptive points management system for WordPress powered websites.
6
- * Version: 2.4.3.1
7
  * Tags: point, credit, loyalty program, engagement, reward, woocommerce rewards
8
  * Author: myCred
9
  * Author URI: https://mycred.me
10
  * Author Email: support@mycred.me
11
  * Requires at least: WP 4.8
12
- * Tested up to: WP 5.9.1
13
  * Text Domain: mycred
14
  * Domain Path: /lang
15
  * License: GPLv2 or later
@@ -20,7 +20,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
20
  final class myCRED_Core {
21
 
22
  // Plugin Version
23
- public $version = '2.4.3.1';
24
 
25
  // Instnace
26
  protected static $_instance = NULL;
@@ -54,14 +54,14 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
54
  * @since 1.7
55
  * @version 1.0
56
  */
57
- public function __clone() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.4.3.1' ); }
58
 
59
  /**
60
  * Not allowed
61
  * @since 1.7
62
  * @version 1.0
63
  */
64
- public function __wakeup() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.4.3.1' ); }
65
 
66
  /**
67
  * Get
@@ -82,7 +82,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
82
  if ( ! defined( $name ) )
83
  define( $name, $value );
84
  elseif ( ! $definable && defined( $name ) )
85
- _doing_it_wrong( 'myCRED_Core->define()', 'Could not define: ' . $name . ' as it is already defined somewhere else!', '2.4.3' );
86
  }
87
 
88
  /**
@@ -94,7 +94,7 @@ if ( ! class_exists( 'myCRED_Core' ) ) :
94
  if ( file_exists( $required_file ) )
95
  require_once $required_file;
96
  else
97
- _doing_it_wrong( 'myCRED_Core->file()', 'Requested file ' . $required_file . ' not found.', '2.4.3.1' );
98
  }
99
 
100
  /**
3
  * Plugin Name: myCred
4
  * Plugin URI: https://mycred.me
5
  * Description: An adaptive points management system for WordPress powered websites.
6
+ * Version: 2.4.4
7
  * Tags: point, credit, loyalty program, engagement, reward, woocommerce rewards
8
  * Author: myCred
9
  * Author URI: https://mycred.me
10
  * Author Email: support@mycred.me
11
  * Requires at least: WP 4.8
12
+ * Tested up to: WP 5.9.2
13
  * Text Domain: mycred
14
  * Domain Path: /lang
15
  * License: GPLv2 or later
20
  final class myCRED_Core {
21
 
22
  // Plugin Version
23
+ public $version = '2.4.4';
24
 
25
  // Instnace
26
  protected static $_instance = NULL;
54
  * @since 1.7
55
  * @version 1.0
56
  */
57
+ public function __clone() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.4.4' ); }
58
 
59
  /**
60
  * Not allowed
61
  * @since 1.7
62
  * @version 1.0
63
  */
64
+ public function __wakeup() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.4.4' ); }
65
 
66
  /**
67
  * Get
82
  if ( ! defined( $name ) )
83
  define( $name, $value );
84
  elseif ( ! $definable && defined( $name ) )
85
+ _doing_it_wrong( 'myCRED_Core->define()', 'Could not define: ' . $name . ' as it is already defined somewhere else!', '2.4.4' );
86
  }
87
 
88
  /**
94
  if ( file_exists( $required_file ) )
95
  require_once $required_file;
96
  else
97
+ _doing_it_wrong( 'myCRED_Core->file()', 'Requested file ' . $required_file . ' not found.', '2.4.4' );
98
  }
99
 
100
  /**
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: mycred,wpexpertsio
3
  Tags: badges, gamification, loyalty, points, rewards
4
  Requires at least: 4.8
5
- Tested up to: 5.9.1
6
  Stable tag: 2.4.3.1
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
@@ -300,8 +300,8 @@ You can find a list of [frequently asked questions](https://mycred.me/about/faq/
300
 
301
  == Upgrade Notice ==
302
 
303
- = 2.4.3.1 =
304
- Code improvement.
305
 
306
  = 2.4.3 =
307
  Code improvement.
@@ -357,14 +357,20 @@ The banking module have been replaced by Central deposite module, and interest r
357
 
358
  == Changelog ==
359
 
360
- = 2.4.3.1 =
361
- - **TWAEK** - Code improvement.
 
 
 
 
 
 
362
 
363
  = 2.4.3 =
364
  - **TWAEK** - Improve license system.
365
 
366
  = 2.4.2 =
367
- - **TWEAK** - SQL query optimization.
368
 
369
  = 2.4.1 =
370
  - **NEW** - Added new attributes "streaming" and "duration" in mycred_video shortcode.
2
  Contributors: mycred,wpexpertsio
3
  Tags: badges, gamification, loyalty, points, rewards
4
  Requires at least: 4.8
5
+ Tested up to: 5.9.2
6
  Stable tag: 2.4.3.1
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
300
 
301
  == Upgrade Notice ==
302
 
303
+ = 2.4.4 =
304
+ New features and Bug fixes.
305
 
306
  = 2.4.3 =
307
  Code improvement.
357
 
358
  == Changelog ==
359
 
360
+ = 2.4.4 =
361
+ - **NEW** - All registered references will be listed on the support page.
362
+ - **NEW** - Added Gutenberg blocks for the following shortcodes mycred_cahcred, mycred_badges_list, mycred_buy_pending, mycred_chart_circulation, mycred_chart_gain_loss, mycred_chart_history, mycred_chart_balance_history, mycred_chart_top_balance, mycred_chart_instance_history and mycred_chart_top_instance.
363
+ - **NEW** - Added fee feature in cashCred.
364
+ - **TWEAK** - Code improvements for tools.
365
+ - **FIX** - Resolved depreciated warnings for PHP 8.
366
+ - **FIX** - Sign-up referral was not working for multiple point types at a time when BuddyPress is active.
367
+ - **FIX** - Duplicate Email triggers when rank promoted or demoted.
368
 
369
  = 2.4.3 =
370
  - **TWAEK** - Improve license system.
371
 
372
  = 2.4.2 =
373
+ - **TWEAK** - SQL query optimization
374
 
375
  = 2.4.1 =
376
  - **NEW** - Added new attributes "streaming" and "duration" in mycred_video shortcode.