myCRED - Version 2.0

Version Description

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 2.0
Comparing to
See all releases

Code changes from version beta2.0 to 2.0

addons/cash-creds/includes/cashcred-functions.php CHANGED
@@ -450,5 +450,20 @@ if ( ! class_exists( 'CashCred_Gateway_Fields' ) ) :
450
  endforeach;
451
  }
452
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  }
454
  endif;
450
  endforeach;
451
  }
452
 
453
+ }
454
+ endif;
455
+
456
+ if ( ! function_exists( 'mycred_get_cashcred_settings' ) ) :
457
+ function mycred_get_cashcred_settings() {
458
+
459
+ $defaults = array(
460
+ 'debugging' => 'disable'
461
+ );
462
+
463
+ $settings = mycred_get_addon_settings( 'cashcreds' );
464
+ $settings = wp_parse_args( $settings, $defaults );
465
+
466
+ return apply_filters( 'mycred_get_cashcred_settings', $settings );
467
+
468
  }
469
  endif;
addons/cash-creds/modules/cashcred-module-core.php CHANGED
@@ -25,9 +25,9 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
25
  'gateway_prefs' => array()
26
  ),
27
  'labels' => array(
28
- 'menu' => __( 'Cashcreds Settings', 'mycred' ),
29
- 'page_title' => __( 'CashCreds Settings', 'mycred' ),
30
- 'page_header' => __( 'Cashcreds Settings', 'mycred' )
31
  ),
32
  'screen_id' => MYCRED_SLUG . '-cashcreds',
33
  'accordion' => true,
@@ -60,6 +60,9 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
60
  add_action( 'wp_ajax_cashcred_pay_now', array( $this, 'cashcred_pay_now'), 10, 2 );
61
  add_action( 'wp_ajax_nopriv_cashcred_pay_now', array( $this, 'cashcred_pay_now'), 10, 2 );
62
 
 
 
 
63
  }
64
 
65
 
@@ -687,14 +690,14 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
687
  <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
688
  <div class="form-group">
689
  <div>&nbsp;</div>
690
- <label for="buycred-gateway-<?php echo $key; ?>"><input type="checkbox" name="mycred_pref_cashcreds[active][]" id="buycred-gateway-<?php echo $key; ?>" value="<?php echo $key; ?>"<?php if ( $this->is_active( $key ) ) echo ' checked="checked"'; ?> /> <?php _e( 'Enable', 'mycred' ); ?></label>
691
  </div>
692
  </div>
693
  <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
694
  <?php if ( $has_test_mode ) : ?>
695
  <div class="form-group">
696
  <div>&nbsp;</div>
697
- <label for="buycred-gateway-<?php echo $key; ?>-sandbox"><input type="checkbox" name="mycred_pref_cashcreds[gateway_prefs][<?php echo $key; ?>][sandbox]" id="buycred-gateway-<?php echo $key; ?>-sandbox" value="<?php echo $key; ?>"<?php if ( $sandbox_mode ) echo ' checked="checked"'; ?> /> <?php _e( 'Sandbox Mode', 'mycred' ); ?></label>
698
  </div>
699
  <?php endif; ?>
700
  </div>
@@ -721,13 +724,13 @@ if ( ! class_exists( 'myCRED_cashCRED_Module' ) ) :
721
  ?>
722
  </div>
723
 
724
- <?php do_action( 'mycred_after_buycreds_page', $this ); ?>
725
 
726
  <p><?php submit_button( __( 'Update Settings', 'mycred' ), 'primary large', 'submit', false ); ?> <?php if ( MYCRED_SHOW_PREMIUM_ADDONS ) : ?><a href="https://mycred.me/product-category/buycred-gateways/" class="button button-secondary button-large" target="_blank">More Gateways</a><?php endif; ?></p>
727
 
728
  </form>
729
 
730
- <?php do_action( 'mycred_bottom_buycreds_page', $this ); ?>
731
 
732
  <script type="text/javascript">
733
  jQuery(function($) {
@@ -770,6 +773,56 @@ jQuery(function($) {
770
 
771
  }
772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
773
  }
774
  endif;
775
 
25
  'gateway_prefs' => array()
26
  ),
27
  'labels' => array(
28
+ 'menu' => __( 'cashcred Gateways', 'mycred' ),
29
+ 'page_title' => __( 'cashCred Gateways', 'mycred' ),
30
+ 'page_header' => __( 'cashcred Gateways', 'mycred' )
31
  ),
32
  'screen_id' => MYCRED_SLUG . '-cashcreds',
33
  'accordion' => true,
60
  add_action( 'wp_ajax_cashcred_pay_now', array( $this, 'cashcred_pay_now'), 10, 2 );
61
  add_action( 'wp_ajax_nopriv_cashcred_pay_now', array( $this, 'cashcred_pay_now'), 10, 2 );
62
 
63
+ add_action( 'mycred_after_core_prefs', array( $this, 'after_general_settings' ) );
64
+ add_filter( 'mycred_save_core_prefs', array( $this, 'sanitize_extra_settings' ), 90, 3 );
65
+
66
  }
67
 
68
 
690
  <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
691
  <div class="form-group">
692
  <div>&nbsp;</div>
693
+ <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>
694
  </div>
695
  </div>
696
  <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12">
697
  <?php if ( $has_test_mode ) : ?>
698
  <div class="form-group">
699
  <div>&nbsp;</div>
700
+ <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>
701
  </div>
702
  <?php endif; ?>
703
  </div>
724
  ?>
725
  </div>
726
 
727
+ <?php do_action( 'mycred_after_cashcred_page', $this ); ?>
728
 
729
  <p><?php submit_button( __( 'Update Settings', 'mycred' ), 'primary large', 'submit', false ); ?> <?php if ( MYCRED_SHOW_PREMIUM_ADDONS ) : ?><a href="https://mycred.me/product-category/buycred-gateways/" class="button button-secondary button-large" target="_blank">More Gateways</a><?php endif; ?></p>
730
 
731
  </form>
732
 
733
+ <?php do_action( 'mycred_bottom_cashcred_page', $this ); ?>
734
 
735
  <script type="text/javascript">
736
  jQuery(function($) {
773
 
774
  }
775
 
776
+ /**
777
+ * Settings Page
778
+ * @since 1.2.3
779
+ * @version 1.2
780
+ */
781
+ public function after_general_settings( $mycred = NULL ) {
782
+
783
+ $cashcred_prefs = mycred_get_cashcred_settings();
784
+
785
+ ?>
786
+ <h4><span class="dashicons dashicons-admin-plugins static"></span><strong>cash</strong>CRED</h4>
787
+ <div class="body" style="display:none;">
788
+
789
+ <div class="row">
790
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
791
+
792
+ <div class="form-group">
793
+ <label for="mycred_pref_core_cashcreds_debugging"><?php _e( 'Payment Debugging Log', 'mycred' ); ?></label>
794
+ <select class="form-control" name="mycred_pref_core[cashcreds][debugging]" id="mycred_pref_core_cashcreds_debugging">
795
+ <option value="disable" <?php echo $cashcred_prefs['debugging'] != 'enable' ? 'selected="selected"' : ''; ?>>Disabled</option>
796
+ <option value="enable" <?php echo $cashcred_prefs['debugging'] == 'enable' ? 'selected="selected"' : ''; ?>>Enable</option>
797
+ </select>
798
+ <p><span class="description"><?php _e( 'Payment Debugging log for developers.', 'mycred' ); ?></span></p>
799
+ </div>
800
+
801
+ </div>
802
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"></div>
803
+ </div>
804
+
805
+ </div>
806
+ <?php
807
+
808
+ }
809
+
810
+ /**
811
+ * Sanitize & Save Settings
812
+ * @since 2.0
813
+ * @version 1.0
814
+ */
815
+ public function sanitize_extra_settings( $new_data, $data, $general ) {
816
+
817
+ $new_data['cashcreds']['debugging'] = sanitize_text_field( $data['cashcreds']['debugging'] );
818
+
819
+ //var_dump( $new_data, $data );die;
820
+
821
+ return $new_data;
822
+
823
+ }
824
+
825
+
826
  }
827
  endif;
828
 
addons/cash-creds/modules/cashcred-module-withdrawal.php CHANGED
@@ -205,11 +205,11 @@ if ( ! class_exists( 'cashCRED_Pending_Payments' ) ) :
205
  protected function register_cashcred_payments() {
206
 
207
  $labels = array(
208
- 'name' => _x( 'CashCred Withdrawal', 'Post Type General Name', 'mycred' ),
209
- 'singular_name' => _x( 'CashCred Withdrawal', 'Post Type Singular Name', 'mycred' ),
210
- 'menu_name' => __( 'CashCred Withdrawal', 'mycred' ),
211
  'parent_item_colon' => '',
212
- 'all_items' => __( 'CashCred Withdrawal', 'mycred' ),
213
  'view_item' => '',
214
  'add_new_item' => '',
215
  'add_new' => '',
@@ -306,8 +306,8 @@ if ( ! class_exists( 'cashCRED_Pending_Payments' ) ) :
306
 
307
  add_submenu_page(
308
  MYCRED_SLUG,
309
- __( 'CashCred withdrawal', 'mycred' ),
310
- __( 'CashCred withdrawal', 'mycred' ),
311
  $this->core->get_point_editor_capability(),
312
  'edit.php?post_type=' . MYCRED_CASHCRED_KEY
313
  );
@@ -538,11 +538,10 @@ if ( ! class_exists( 'cashCRED_Pending_Payments' ) ) :
538
  'default'
539
  );
540
 
541
- $mycred_pref_cashcreds = mycred_get_option( 'mycred_pref_cashcreds' , false );
542
 
543
- if( isset($mycred_pref_cashcreds["gateway_prefs"]["paypal"]["cashcred_deve_log"]) &&
544
- $mycred_pref_cashcreds["gateway_prefs"]["paypal"]["cashcred_deve_log"] == 'on' ) {
545
-
546
  add_meta_box(
547
  'cashcred-developer-log',
548
  __( 'Debugging Log', 'mycred' ),
@@ -1071,9 +1070,6 @@ if ( ! class_exists( 'cashCRED_Pending_Payments' ) ) :
1071
  if ( $event === false )
1072
  $c->comment_content .= ' Unsaved';
1073
 
1074
- else
1075
- $c->comment_content .= ' ' . $event;
1076
-
1077
  $comments[] = $c;
1078
 
1079
  }
205
  protected function register_cashcred_payments() {
206
 
207
  $labels = array(
208
+ 'name' => _x( 'cashCred Withdrawal', 'Post Type General Name', 'mycred' ),
209
+ 'singular_name' => _x( 'cashCred Withdrawal', 'Post Type Singular Name', 'mycred' ),
210
+ 'menu_name' => __( 'cashCred Withdrawal', 'mycred' ),
211
  'parent_item_colon' => '',
212
+ 'all_items' => __( 'cashCred Withdrawal', 'mycred' ),
213
  'view_item' => '',
214
  'add_new_item' => '',
215
  'add_new' => '',
306
 
307
  add_submenu_page(
308
  MYCRED_SLUG,
309
+ __( 'cashCred Withdrawal', 'mycred' ),
310
+ __( 'cashCred Withdrawal', 'mycred' ),
311
  $this->core->get_point_editor_capability(),
312
  'edit.php?post_type=' . MYCRED_CASHCRED_KEY
313
  );
538
  'default'
539
  );
540
 
541
+ $mycred_pref_cashcreds = mycred_get_cashcred_settings();
542
 
543
+ if( isset( $mycred_pref_cashcreds["debugging"] ) && $mycred_pref_cashcreds["debugging"] == 'enable' ) {
544
+
 
545
  add_meta_box(
546
  'cashcred-developer-log',
547
  __( 'Debugging Log', 'mycred' ),
1070
  if ( $event === false )
1071
  $c->comment_content .= ' Unsaved';
1072
 
 
 
 
1073
  $comments[] = $c;
1074
 
1075
  }
addons/sell-content/myCRED-addon-sell-content.php CHANGED
@@ -1,1339 +1,1344 @@
1
- <?php
2
- /**
3
- * Addon: Sell Content
4
- * Addon URI: http://codex.mycred.me/chapter-iii/sell-content/
5
- * Version: 2.0.1
6
- */
7
- if ( ! defined( 'myCRED_VERSION' ) ) exit;
8
-
9
- define( 'myCRED_SELL', __FILE__ );
10
- define( 'myCRED_SELL_VERSION', '1.5' );
11
- define( 'MYCRED_SELL_DIR', myCRED_ADDONS_DIR . 'sell-content/' );
12
- define( 'MYCRED_SELL_ASSETS_DIR', MYCRED_SELL_DIR . 'assets/' );
13
- define( 'MYCRED_SELL_INCLUDES_DIR', MYCRED_SELL_DIR . 'includes/' );
14
-
15
- require_once MYCRED_SELL_INCLUDES_DIR . 'mycred-sell-functions.php';
16
- require_once MYCRED_SELL_INCLUDES_DIR . 'mycred-sell-shortcodes.php';
17
-
18
- /**
19
- * myCRED_Sell_Content_Module class
20
- * @since 0.1
21
- * @version 2.0.1
22
- */
23
- if ( ! class_exists( 'myCRED_Sell_Content_Module' ) ) :
24
- class myCRED_Sell_Content_Module extends myCRED_Module {
25
-
26
- public $current_user_id = 0;
27
- public $priority = 10;
28
- public $bbp_content = '';
29
-
30
- /**
31
- * Construct
32
- */
33
- function __construct() {
34
-
35
- parent::__construct( 'myCRED_Sell_Content_Module', array(
36
- 'module_name' => 'sell_content',
37
- 'register' => false,
38
- 'defaults' => array(
39
- 'post_types' => 'post,page',
40
- 'filters' => array(),
41
- 'type' => array( MYCRED_DEFAULT_TYPE_KEY ),
42
- 'reload' => 0,
43
- 'working' => 'Processing ...',
44
- 'templates' => array(
45
- 'members' => '<div class="text-center"><h3>Premium Content</h3><p>Buy access to this content.</p><p>%buy_button%</p></div>',
46
- 'visitors' => '<div class="text-center"><h3>Premium Content</h3><p>Login to buy access to this content.</p></div>',
47
- 'cantafford' => '<div class="text-center"><h3>Premium Content</h3><p>Buy access to this content.</p><p><strong>Insufficient Funds</strong></p></div>'
48
- )
49
- ),
50
- 'add_to_core' => true
51
- ) );
52
-
53
- if ( ! is_array( $this->sell_content['type'] ) )
54
- $this->sell_content['type'] = array( $this->sell_content['type'] );
55
-
56
- }
57
-
58
- /**
59
- * Module Init
60
- * @since 0.1
61
- * @version 1.2.1
62
- */
63
- public function module_init() {
64
-
65
- $this->current_user_id = get_current_user_id();
66
- $this->priority = apply_filters( 'mycred_sell_content_priority', 25, $this );
67
-
68
- // Email add-on support
69
- add_filter( 'mycred_get_email_events', array( $this, 'email_notice_instance' ), 10, 2 );
70
- add_filter( 'mycred_email_before_send', array( $this, 'email_notices' ), 40, 2 );
71
-
72
- // Setup Content Override
73
- add_action( 'template_redirect', array( $this, 'template_redirect' ), 99990 );
74
-
75
- // Register shortcodes
76
- add_shortcode( MYCRED_SLUG . '_sell_this', 'mycred_render_sell_this' );
77
- add_shortcode( MYCRED_SLUG . '_sell_this_ajax', 'mycred_render_sell_this_ajax' );
78
- add_shortcode( MYCRED_SLUG . '_sales_history', 'mycred_render_sell_history' );
79
- add_shortcode( MYCRED_SLUG . '_content_sale_count', 'mycred_render_sell_count' );
80
- add_shortcode( MYCRED_SLUG . '_content_buyer_count', 'mycred_render_sell_buyer_count' );
81
- add_shortcode( MYCRED_SLUG . '_content_buyer_avatars', 'mycred_render_sell_buyer_avatars' );
82
-
83
- // Setup Script
84
- add_action( 'mycred_register_assets', array( $this, 'register_assets' ) );
85
- add_action( 'mycred_front_enqueue_footer', array( $this, 'enqueue_footer' ) );
86
- add_action( 'bbp_template_redirect', array( $this, 'bbp_content' ), 10 );
87
-
88
- }
89
-
90
- /**
91
- * Module Admin Init
92
- * @since 1.7
93
- * @version 1.0
94
- */
95
- public function module_admin_init() {
96
-
97
- // Setup the "Sell This" Metaboxes
98
- $post_types = explode( ',', $this->sell_content['post_types'] );
99
- if ( ! empty( $post_types ) ) {
100
-
101
- foreach ( $post_types as $type ) {
102
- add_action( "add_meta_boxes_{$type}", array( $this, 'add_metabox' ) );
103
- add_action( "save_post_{$type}", array( $this, 'save_metabox' ) );
104
- }
105
-
106
- }
107
-
108
- // User Override
109
- add_action( 'mycred_user_edit_after_balances', array( $this, 'sell_content_user_screen' ), 50 );
110
-
111
- add_action( 'personal_options_update', array( $this, 'save_manual_profit_share' ), 50 );
112
- add_action( 'edit_user_profile_update', array( $this, 'save_manual_profit_share' ), 50 );
113
-
114
- }
115
-
116
- /**
117
- * Register Assets
118
- * @since 1.7
119
- * @version 1.0
120
- */
121
- public function register_assets() {
122
-
123
- wp_register_script(
124
- 'mycred-sell-this',
125
- plugins_url( 'assets/js/buy-content.js', myCRED_SELL ),
126
- array( 'jquery' ),
127
- '2.0.1',
128
- true
129
- );
130
-
131
- }
132
-
133
- /**
134
- * Load Script
135
- * @since 1.7
136
- * @version 1.0.2
137
- */
138
- public function enqueue_footer() {
139
-
140
- global $mycred_sell_this;
141
-
142
- // Only enqueue our script if it's needed
143
- if ( $mycred_sell_this === true ) {
144
-
145
- global $post;
146
-
147
- wp_localize_script(
148
- 'mycred-sell-this',
149
- 'myCREDBuyContent',
150
- array(
151
- 'ajaxurl' => esc_url( ( isset( $post->ID ) ) ? mycred_get_permalink( $post->ID ) : home_url( '/' ) ),
152
- 'token' => wp_create_nonce( 'mycred-buy-this-content' ),
153
- 'working' => esc_js( $this->sell_content['working'] ),
154
- 'reload' => $this->sell_content['reload'],
155
- 'sweeterror' => __( 'Error', 'mycred' )
156
- )
157
- );
158
-
159
- wp_enqueue_script( 'mycred-sell-this' );
160
-
161
- }
162
-
163
- }
164
-
165
- /**
166
- * Setup Content Filter
167
- * We are using the template_redirect action to prevent this add-on having to run anywhere else but
168
- * in the front-end of our website, since the the_content filter is used in soooo many places.
169
- * As of 1.7.6, purchases are made via front-end submissions and not via admin-ajax.php
170
- * @since 1.7
171
- * @version 1.0.1
172
- */
173
- public function template_redirect() {
174
-
175
- global $mycred_partial_content_sale;
176
-
177
- $mycred_partial_content_sale = false;
178
-
179
- // Handle purhchase requests
180
- $this->maybe_buy_content();
181
-
182
- // Unless we successfully bought the content, filter it
183
- add_filter( 'the_content', array( $this, 'the_content' ), $this->priority );
184
-
185
- }
186
-
187
- /**
188
- * Maybe Buy Content
189
- * Check if a purchase request has been made either via an AJAX submission.
190
- * @since 1.7.6
191
- * @version 1.0
192
- */
193
- public function maybe_buy_content() {
194
-
195
- if ( is_user_logged_in() && ! mycred_is_admin() ) {
196
-
197
- if ( isset( $_POST['action'] ) && $_POST['action'] == 'mycred-buy-content' && isset( $_POST['postid'] ) && isset( $_POST['token'] ) && wp_verify_nonce( $_POST['token'], 'mycred-buy-this-content' ) ) {
198
-
199
- $post_id = absint( $_POST['postid'] );
200
- $point_type = sanitize_key( $_POST['ctype'] );
201
-
202
- global $mycred_types;
203
-
204
- if ( ! array_key_exists( $point_type, $mycred_types ) || mycred_force_singular_session( $this->current_user_id, 'mycred-last-content-purchase' ) )
205
- wp_send_json( 'ERROR' );
206
-
207
- // If the content is for sale and we have not paid for it
208
- if ( mycred_post_is_for_sale( $post_id ) && ! mycred_user_paid_for_content( $this->current_user_id, $post_id ) ) {
209
-
210
- $content = '';
211
- $post = mycred_get_post( $post_id );
212
- $purchase = mycred_sell_content_new_purchase( $post, $this->current_user_id, $point_type );
213
-
214
- // Successfull purchase
215
- if ( $purchase === true ) {
216
-
217
- preg_match('/\[mycred_sell_this[^\]]*](.*)\[\/mycred_sell_this[^\]]*]/uis', $post->post_content , $match );
218
-
219
- $content = $post->post_content;
220
- if ( is_array( $match ) && array_key_exists( 1, $match ) )
221
- $content = $match[1];
222
-
223
- do_action( 'mycred_sell_before_content_render' );
224
-
225
- remove_filter( 'the_content', array( $this, 'the_content' ), $this->priority );
226
- $content = apply_filters( 'the_content', $content );
227
- $content = str_replace( ']]>', ']]&gt;', $content );
228
- $content = do_shortcode( $content );
229
- add_filter( 'the_content', array( $this, 'the_content' ), $this->priority );
230
-
231
- }
232
-
233
- // Something went wrong
234
- else {
235
-
236
- $content = $purchase;
237
-
238
- }
239
-
240
- // Let others play
241
- $content = apply_filters( 'mycred_content_purchase_ajax', $content, $purchase );
242
-
243
- if ( $purchase !== true )
244
- wp_send_json_error( $content );
245
-
246
- wp_send_json_success( $content );
247
-
248
- }
249
-
250
- wp_send_json( 'ERROR' );
251
-
252
- }
253
-
254
- }
255
-
256
- }
257
-
258
- /**
259
- * The Content Overwrite
260
- * Handles content sales by replacing the posts content with the appropriate template
261
- * for those who have not paid. Admins and authors are excluded.
262
- * @since 0.1
263
- * @version 1.2.2
264
- */
265
- public function the_content( $content ) {
266
-
267
- global $mycred_partial_content_sale, $mycred_sell_this;
268
-
269
- $post_id = mycred_sell_content_post_id();
270
- $post = mycred_get_post( $post_id );
271
-
272
- // If content is for sale
273
- if ( mycred_post_is_for_sale( $post_id ) ) {
274
-
275
- $mycred_sell_this = true;
276
-
277
- // Parse shortcodes now just in case it has not been done already
278
- $_content = do_shortcode( $content );
279
-
280
- // Partial Content Sale - We have already done the work in the shortcode
281
- if ( $mycred_partial_content_sale === true )
282
- return $_content;
283
-
284
- // Logged in users
285
- if ( is_user_logged_in() ) {
286
-
287
- // Authors and admins do not pay
288
- if ( ! mycred_is_admin() && $post->post_author != $this->current_user_id ) {
289
-
290
- // In case we have not paid
291
- if ( ! mycred_user_paid_for_content( $this->current_user_id, $post_id ) ) {
292
-
293
- // Get Payment Options
294
- $payment_options = mycred_sell_content_payment_buttons( $this->current_user_id, $post_id );
295
-
296
- // User can buy
297
- if ( $payment_options !== false ) {
298
-
299
- $content = $this->sell_content['templates']['members'];
300
- $content = str_replace( '%buy_button%', $payment_options, $content );
301
- $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-unpaid' );
302
-
303
- }
304
-
305
- // Can not afford to buy
306
- else {
307
-
308
- $content = $this->sell_content['templates']['cantafford'];
309
- $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-insufficient' );
310
-
311
- }
312
-
313
- }
314
-
315
- }
316
-
317
- }
318
-
319
- // Visitors
320
- else {
321
-
322
- $content = $this->sell_content['templates']['visitors'];
323
- $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-visitor' );
324
-
325
- }
326
-
327
- }
328
-
329
- return $content;
330
-
331
- }
332
-
333
-
334
-
335
- public function bbp_content() {
336
-
337
- global $mycred_partial_content_sale, $mycred_sell_this;
338
-
339
- $post_id = mycred_sell_content_post_id();
340
- $post = mycred_get_post( $post_id );
341
- $content = '';
342
-
343
- // If content is for sale
344
- if ( mycred_post_is_for_sale( $post_id ) && ( bbp_is_single_forum() || bbp_is_single_topic() || bbp_is_single_reply() ) ) {
345
-
346
- $mycred_sell_this = true;
347
-
348
- // Partial Content Sale - We have already done the work in the shortcode
349
- if ( $mycred_partial_content_sale === true ) return;
350
-
351
- // Logged in users
352
- if ( is_user_logged_in() ) {
353
-
354
- // Authors and admins do not pay
355
- if ( ! mycred_is_admin() && $post->post_author != $this->current_user_id ) {
356
-
357
- // In case we have not paid
358
- if ( ! mycred_user_paid_for_content( $this->current_user_id, $post_id ) ) {
359
-
360
- // Get Payment Options
361
- $payment_options = mycred_sell_content_payment_buttons( $this->current_user_id, $post_id );
362
-
363
- // User can buy
364
- if ( $payment_options !== false ) {
365
-
366
- $content = $this->sell_content['templates']['members'];
367
- $content = str_replace( '%buy_button%', $payment_options, $content );
368
- $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-unpaid' );
369
- $this->mycred_bbp_sell_forum_actions();
370
-
371
- }
372
-
373
- // Can not afford to buy
374
- else {
375
-
376
- $content = $this->sell_content['templates']['cantafford'];
377
- $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-insufficient' );
378
- $this->mycred_bbp_sell_forum_actions();
379
-
380
- }
381
-
382
- }
383
-
384
- }
385
-
386
- }
387
-
388
- // Visitors
389
- else {
390
-
391
- $content = $this->sell_content['templates']['visitors'];
392
- $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-visitor' );
393
- $this->mycred_bbp_sell_forum_actions();
394
-
395
- }
396
-
397
- }
398
-
399
- $this->bbp_content = $content;
400
-
401
- }
402
-
403
-
404
- public function mycred_bbp_sell_forum_actions() {
405
-
406
- add_action( 'bbp_template_before_single_forum', array( $this, 'bbp_template_before_single' ) );
407
- add_action( 'bbp_template_before_single_topic', array( $this, 'bbp_template_before_single' ) );
408
- add_filter( 'bbp_no_breadcrumb', array( $this, 'bbp_remove_breadcrumb' ), 10 );
409
- add_filter( 'bbp_get_forum_subscribe_link', array( $this, 'bbp_remove_subscribe_link' ), 10 , 3 );
410
- add_filter( 'bbp_get_topic_subscribe_link', array( $this, 'bbp_remove_subscribe_link' ), 10 , 3 );
411
- add_filter( 'bbp_get_topic_favorite_link', array( $this, 'bbp_remove_subscribe_link' ), 10 , 3 );
412
- add_filter( 'bbp_get_template_part', array( $this, 'bbp_remove_templates' ), 10 , 3 );
413
- add_filter( 'bbp_get_single_forum_description', array( $this, 'bbp_get_single_description' ), 10 , 3 );
414
- add_filter( 'bbp_get_single_topic_description', array( $this, 'bbp_get_single_description' ), 10 , 3 );
415
-
416
- }
417
-
418
- public function bbp_template_before_single() {
419
-
420
- echo $this->bbp_content;
421
-
422
- }
423
-
424
- public function bbp_remove_breadcrumb( $is_front ) {
425
- return true;
426
- }
427
-
428
- public function bbp_remove_subscribe_link( $retval, $r, $args ) {
429
- return '';
430
- }
431
-
432
- public function bbp_remove_templates( $templates, $slug, $name ) {
433
-
434
- if ( $slug == 'content' ) return $templates;
435
-
436
- return array('');
437
- }
438
-
439
- public function bbp_get_single_description( $retstr, $r, $args ) {
440
- return '';
441
- }
442
-
443
- /**
444
- * User Level Override
445
- * @since 1.5
446
- * @version 1.3.1
447
- */
448
- public function sell_content_user_screen( $user ) {
449
-
450
- // Only visible to admins
451
- if ( ! mycred_is_admin() ) return;
452
-
453
- $mycred_types = mycred_get_types( true );
454
- $available_options = array();
455
-
456
- foreach ( $mycred_types as $point_type_key => $label ) {
457
-
458
- $setup = array( 'name' => $label, 'enabled' => false, 'default' => 0, 'excluded' => true, 'override' => false, 'custom' => 0 );
459
-
460
- if ( ! empty( $this->sell_content['type'] ) && in_array( $point_type_key, $this->sell_content['type'] ) ) {
461
-
462
- $setup['enabled'] = true;
463
- $mycred = mycred( $point_type_key );
464
-
465
- if ( ! $mycred->exclude_user( $user->ID ) ) {
466
-
467
- $setup['excluded'] = false;
468
-
469
- $settings = mycred_get_option( 'mycred_sell_this_' . $point_type_key );
470
-
471
- $setup['default'] = $settings['profit_share'];
472
-
473
- $users_share = mycred_get_user_meta( $user->ID, 'mycred_sell_content_share_' . $point_type_key, '', true );
474
- if ( strlen( $users_share ) > 0 ) {
475
-
476
- $setup['override'] = true;
477
- $setup['custom'] = $users_share;
478
-
479
- }
480
-
481
- }
482
-
483
- }
484
-
485
- $available_options[ $point_type_key ] = $setup;
486
-
487
- }
488
-
489
- if ( empty( $available_options ) ) return;
490
-
491
- ?>
492
- <p class="mycred-p"><?php _e( 'Users profit share when their content is purchased.', 'mycred' ); ?></p>
493
- <table class="form-table mycred-inline-table">
494
- <tr>
495
- <th scope="row"><?php _e( 'Profit Share', 'mycred' ); ?></th>
496
- <td>
497
- <fieldset id="mycred-badge-list" class="badge-list">
498
- <legend class="screen-reader-text"><span><?php _e( 'Profit Share', 'mycred' ); ?></span></legend>
499
- <?php
500
-
501
- foreach ( $available_options as $point_type => $data ) {
502
-
503
- // This point type is not for sale
504
- if ( ! $data['enabled'] ) {
505
-
506
- ?>
507
- <div class="mycred-wrapper buycred-wrapper disabled-option color-option">
508
- <div><?php printf( _x( '%s Profit Share', 'Points Name', 'mycred' ), $data['name'] ); ?></div>
509
- <div class="balance-row">
510
- <div class="balance-view"><?php _e( 'Disabled', 'mycred' ); ?></div>
511
- <div class="balance-desc"><em><?php _e( 'Not accepted as payment.', 'mycred' ); ?></em></div>
512
- </div>
513
- </div>
514
- <?php
515
-
516
- }
517
-
518
- // This user is excluded from this point type
519
- elseif ( $data['excluded'] ) {
520
-
521
- ?>
522
- <div class="mycred-wrapper buycred-wrapper disabled-option color-option">
523
- <div><?php printf( _x( '%s Profit Share', 'Points Name', 'mycred' ), $data['name'] ); ?></div>
524
- <div class="balance-row">
525
- <div class="balance-view"><?php _e( 'Excluded', 'mycred' ); ?></div>
526
- <div class="balance-desc"><em><?php printf( _x( 'User can not pay using %s', 'Points Name', 'mycred' ), $data['name'] ); ?></em></div>
527
- </div>
528
- </div>
529
- <?php
530
-
531
- }
532
-
533
- // Eligeble user
534
- else {
535
-
536
- ?>
537
- <div class="mycred-wrapper buycred-wrapper color-option selected">
538
- <div><?php printf( _x( '%s Profit Share', 'Buying Points', 'mycred' ), $data['name'] ); ?></div>
539
- <div class="balance-row">
540
- <div class="balance-view"><input type="text" size="8" name="mycred_sell_this[<?php echo $point_type; ?>]" class="half" placeholder="<?php echo esc_attr( $data['default'] ); ?>" value="<?php if ( $data['override'] ) echo esc_attr( $data['custom'] ); ?>" /> %</div>
541
- <div class="balance-desc"><em><?php _e( 'Leave empty to use the default.', 'mycred' ); ?></em></div>
542
- </div>
543
- </div>
544
- <?php
545
-
546
- }
547
-
548
- }
549
-
550
- ?>
551
- </fieldset>
552
- </td>
553
- </tr>
554
- </table>
555
- <hr />
556
- <?php
557
-
558
- }
559
-
560
- /**
561
- * Save Override
562
- * @since 1.5
563
- * @version 1.2
564
- */
565
- function save_manual_profit_share( $user_id ) {
566
-
567
- // Only visible to admins
568
- if ( ! mycred_is_admin() ) return;
569
-
570
- if ( isset( $_POST['mycred_sell_this'] ) && ! empty( $_POST['mycred_sell_this'] ) ) {
571
-
572
- foreach ( $_POST['mycred_sell_this'] as $point_type => $share ) {
573
-
574
- $share = sanitize_text_field( $share );
575
-
576
- mycred_delete_user_meta( $user_id, 'mycred_sell_content_share_' . $point_type );
577
- if ( $share != '' && is_numeric( $share ) )
578
- mycred_update_user_meta( $user_id, 'mycred_sell_content_share_' . $point_type, '', $share );
579
-
580
- }
581
-
582
- }
583
-
584
- }
585
-
586
- /**
587
- * Enabled / Disabled Select Options
588
- * @since 1.7
589
- * @version 1.0
590
- */
591
- protected function enabled_options( $selected = '' ) {
592
-
593
- $options = array(
594
- 'disabled' => __( 'Disabled', 'mycred' ),
595
- 'enabled' => __( 'Enabled', 'mycred' )
596
- );
597
-
598
- $output = '';
599
- foreach ( $options as $value => $label ) {
600
- $output .= '<option value="' . $value . '"';
601
- if ( $selected == $value ) $output .= ' selected="selected"';
602
- $output .= '>' . $label . '</option>';
603
- }
604
-
605
- return $output;
606
-
607
- }
608
-
609
- /**
610
- * Settings Page
611
- * @since 0.1
612
- * @version 1.4
613
- */
614
- public function after_general_settings( $mycred = NULL ) {
615
-
616
- $post_types = mycred_sell_content_post_types();
617
- $selected_types = explode( ',', $this->sell_content['post_types'] );
618
-
619
- $point_types = mycred_get_types( true );
620
-
621
- ?>
622
- <h4><span class="dashicons dashicons-admin-plugins static"></span><?php _e( 'Sell Content', 'mycred' ); ?></h4>
623
- <div class="body" style="display:none;">
624
-
625
- <h3><?php _e( 'Post Types', 'mycred' ); ?></h3>
626
- <p><?php _e( 'Which post type(s) content field do you want to sell access to?', 'mycred' ); ?></p>
627
- <div id="mycred-sell-this-post-type-filter">
628
- <?php
629
-
630
- if ( ! empty( $post_types ) ) {
631
- foreach ( $post_types as $post_type => $post_type_label ) {
632
-
633
- $selected = '';
634
- if ( in_array( $post_type, $selected_types ) )
635
- $selected = ' checked="checked"';
636
-
637
- $show_options = 'none';
638
- if ( in_array( $post_type, $selected_types ) )
639
- $show_options = 'block';
640
-
641
- ?>
642
- <div class="row">
643
- <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12">
644
- <div class="checkbox">
645
- <label for="<?php echo $this->field_id( array( 'post_types' => $post_type ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'post_types' => $post_type ) ); ?>"<?php echo $selected; ?> id="<?php echo $this->field_id( array( 'post_types' => $post_type ) ); ?>" class="mycred-check-count" data-type="<?php echo $post_type; ?>" value="<?php echo $post_type; ?>" /> <?php echo esc_attr( $post_type_label ); ?></label>
646
- </div>
647
- </div>
648
- <div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
649
- <div id="<?php echo $this->field_id( array( 'post_types' => $post_type ) ); ?>-wrap" style="display: <?php echo $show_options; ?>;">
650
- <div class="row">
651
- <div class="col-lg-5 col-md-5 col-sm-6 col-xs-12">
652
- <div class="form-group">
653
- <select name="<?php echo $this->field_name( array( 'filters' => $post_type ) ); ?>[by]" class="form-control toggle-filter-menu" data-type="<?php echo $post_type; ?>">
654
- <?php
655
-
656
- $settings = array( 'by' => 'all', 'list' => '' );
657
- if ( array_key_exists( $post_type, $this->sell_content['filters'] ) )
658
- $settings = $this->sell_content['filters'][ $post_type ];
659
-
660
- $options = mycred_get_post_type_options( $post_type );
661
- if ( ! empty( $options ) ) {
662
- foreach ( $options as $value => $option ) {
663
-
664
- echo '<option value="' . $value . '"';
665
- if ( $value == $settings['by'] ) echo ' selected="selected"';
666
- if ( $option['data'] != '' ) echo ' data-place="' . $option['data'] . '"';
667
- echo '>' . $option['label'] . '</option>';
668
-
669
- }
670
- }
671
-
672
- ?>
673
- </select>
674
- </div>
675
- </div>
676
- <div class="col-lg-7 col-md-7 col-sm-6 col-xs-12">
677
- <div id="post-type-filter-<?php echo $post_type; ?>" style="display: <?php if ( ! in_array( $settings['by'], array( 'all', 'manual' ) ) ) echo 'block'; else echo 'none'; ?>;">
678
- <div class="form-group">
679
- <input type="text" name="<?php echo $this->field_name( array( 'filters' => $post_type ) ); ?>[list]" value="<?php echo esc_attr( $settings['list'] ); ?>" placeholder="<?php if ( array_key_exists( $settings['by'], $options ) ) echo esc_attr( $options[ $settings['by'] ]['data'] ); ?>" class="form-control" />
680
- </div>
681
- </div>
682
- </div>
683
- </div>
684
- </div>
685
- </div>
686
- </div>
687
- <?php
688
-
689
- }
690
- }
691
-
692
- ?>
693
- </div>
694
-
695
- <h3><?php _e( 'Point Types', 'mycred' ); ?></h3>
696
- <p><?php _e( 'Which point type(s) can be used as payment for accessing content?', 'mycred' ); ?></p>
697
- <div class="row">
698
- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
699
- <?php
700
-
701
- if ( ! empty( $point_types ) ) {
702
- foreach ( $point_types as $point_type => $point_type_label ) {
703
-
704
- $selected = '';
705
- if ( in_array( $point_type, $this->sell_content['type'] ) )
706
- $selected = ' checked="checked"';
707
-
708
- if ( count( $point_types ) === 1 )
709
- $selected = ' checked="checked" disabled="disabled"';
710
-
711
- ?>
712
- <div class="form-group">
713
- <label for="<?php echo $this->field_id( array( 'type' => $point_type ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'type' => $point_type ) ); ?>"<?php echo $selected; ?> id="<?php echo $this->field_id( array( 'type' => $point_type ) ); ?>" class="mycred-check-count" data-type="<?php echo $point_type; ?>" value="<?php echo $point_type; ?>" /> <?php echo esc_attr( $point_type_label ); ?></label>
714
- </div>
715
- <?php
716
-
717
- }
718
- }
719
-
720
- ?>
721
- </div>
722
- </div>
723
-
724
- <?php
725
-
726
- if ( ! empty( $point_types ) ) {
727
- foreach ( $point_types as $point_type => $point_type_label ) {
728
-
729
- $selected = 'none';
730
- if ( in_array( $point_type, $this->sell_content['type'] ) )
731
- $selected = 'block';
732
-
733
- if ( count( $point_types ) === 1 )
734
- $selected = 'block';
735
-
736
- $mycred = mycred( $point_type );
737
- $type_setup = mycred_get_option( 'mycred_sell_this_' . $point_type );
738
- $type_setup = wp_parse_args( $type_setup, array(
739
- 'status' => 'disabled',
740
- 'price' => 0,
741
- 'expire' => 0,
742
- 'profit_share' => 0,
743
- 'button_label' => 'Pay %price%',
744
- 'button_classes' => 'btn btn-primary btn-lg',
745
- 'log_payment' => 'Purchase of %link_with_title%',
746
- 'log_sale' => 'Sale of %link_with_title%'
747
- ) );
748
-
749
- $expiration_label = apply_filters( 'mycred_sell_exp_title', __( 'Hour(s)', 'mycred' ), $point_type );
750
-
751
- ?>
752
- <div id="mycred-sell-<?php echo $point_type; ?>-wrap" style="display: <?php echo $selected; ?>;">
753
- <h3><?php printf( __( '%s Setup', 'mycred' ), $point_type_label ); ?></h3>
754
- <div class="row">
755
- <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
756
- <div class="form-group">
757
- <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-status' ) ); ?>"><?php _e( 'Default Status', 'mycred' ); ?></label>
758
- <select name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[status]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-status' ) ); ?>" class="form-control">
759
- <?php echo $this->enabled_options( $type_setup['status'] ); ?>
760
- </select>
761
- </div>
762
- </div>
763
- <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
764
- <div class="form-group">
765
- <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-price' ) ); ?>"><?php _e( 'Default Price', 'mycred' ); ?></label>
766
- <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[price]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-price' ) ); ?>" class="form-control" value="<?php echo esc_attr( $type_setup['price'] ); ?>" />
767
- </div>
768
- </div>
769
- <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
770
- <div class="form-group">
771
- <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-expire' ) ); ?>"><?php _e( 'Expiration', 'mycred' ); ?></label>
772
- <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[expire]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-expire' ) ); ?>" class="form-control" value="<?php echo esc_attr( $type_setup['expire'] ); ?>" />
773
- <p><span class="description"><?php printf( __( 'Option to automatically expire purchases after certain number of %s. Use zero to disable.', 'mycred' ), $expiration_label ); ?></span></p>
774
- </div>
775
- </div>
776
- <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
777
- <div class="form-group">
778
- <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-profit-share' ) ); ?>"><?php _e( 'Profit Share', 'mycred' ); ?></label>
779
- <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[profit_share]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-profit-share' ) ); ?>" class="form-control" value="<?php echo esc_attr( $type_setup['profit_share'] ); ?>" />
780
- <p><span class="description"><?php printf( __( 'Option to pay a percentage of each sale with the content author.', 'mycred' ), $expiration_label ); ?></span></p>
781
- </div>
782
- </div>
783
- </div>
784
- <div class="row">
785
- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
786
- <div class="form-group">
787
- <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-button' ) ); ?>"><?php _e( 'Button Label', 'mycred' ); ?></label>
788
- <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[button_label]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-button' ) ); ?>" class="form-control" placeholder="<?php _e( 'Required', 'mycred' ); ?>" value="<?php echo esc_attr( $type_setup['button_label'] ); ?>" />
789
- <p><span class="description"><?php echo $this->core->available_template_tags( array(), '%price%' ); ?></span></p>
790
- </div>
791
- </div>
792
- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
793
- <div class="form-group">
794
- <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-css' ) ); ?>"><?php _e( 'Button CSS Classes', 'mycred' ); ?></label>
795
- <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[button_classes]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-css' ) ); ?>" class="form-control" value="<?php echo esc_attr( $type_setup['button_classes'] ); ?>" />
796
- </div>
797
- </div>
798
- </div>
799
- <h3><?php _e( 'Log Templates', 'mycred' ); ?></h3>
800
- <div class="row">
801
- <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
802
- <div class="form-group">
803
- <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-log-pay' ) ); ?>"><?php _e( 'Payment log entry template', 'mycred' ); ?></label>
804
- <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[log_payment]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-log-pay' ) ); ?>" class="form-control" placeholder="<?php _e( 'Required', 'mycred' ); ?>" value="<?php echo esc_attr( $type_setup['log_payment'] ); ?>" />
805
- <p><span class="description"><?php echo $this->core->available_template_tags( array( 'general', 'post' ) ); ?></span></p>
806
- </div>
807
- </div>
808
- <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
809
- <div class="form-group">
810
- <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-log-share' ) ); ?>"><?php _e( 'Profit Share payout log entry template', 'mycred' ); ?></label>
811
- <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[log_sale]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-log-share' ) ); ?>" class="form-control" placeholder="<?php _e( 'Required', 'mycred' ); ?>" value="<?php echo esc_attr( $type_setup['log_sale'] ); ?>" />
812
- <p><span class="description"><?php echo $this->core->available_template_tags( array( 'general', 'post' ) ); ?></span></p>
813
- </div>
814
- </div>
815
- </div>
816
- </div>
817
- <?php
818
-
819
- }
820
- }
821
-
822
- ?>
823
-
824
- <h3><?php _e( 'Transactions', 'mycred' ); ?></h3>
825
- <div class="row">
826
- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
827
- <div class="checkbox">
828
- <label for="<?php echo $this->field_id( 'reload' ); ?>"><input type="checkbox" name="<?php echo $this->field_name( 'reload' ); ?>" id="<?php echo $this->field_id( 'reload' ); ?>" <?php checked( $this->sell_content['reload'], 1 ); ?> value="1" /> <?php _e( 'Reload page after successful payments.', 'mycred' ); ?></label>
829
- </div>
830
- </div>
831
- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
832
- <div class="form-group">
833
- <label for="<?php echo $this->field_id( 'working' ); ?>"><?php _e( 'Button Label', 'mycred' ); ?></label>
834
- <input type="text" name="<?php echo $this->field_name( 'working' ); ?>" id="<?php echo $this->field_id( 'working' ); ?>" class="form-control" placeholder="<?php _e( 'Required', 'mycred' ); ?>" value="<?php echo esc_attr( $this->sell_content['working'] ); ?>" />
835
- <p><span class="description"><?php _e( 'Option to show a custom button label while the payment is being processed. HTML is allowed.', 'mycred' ); ?></span></p>
836
- </div>
837
- </div>
838
- </div>
839
-
840
- <div class="row">
841
- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
842
- <h3><?php _e( 'Purchase Template', 'mycred' ); ?></h3>
843
- <p><span class="description"><?php _e( 'The content will be replaced with this template when viewed by a user that has not paid for the content but can afford to pay.', 'mycred' ); ?></span></p>
844
- <?php
845
-
846
- wp_editor( $this->sell_content['templates']['members'], $this->field_id( array( 'templates' => 'members' ) ), array(
847
- 'textarea_name' => $this->field_name( array( 'templates' => 'members' ) ),
848
- 'textarea_rows' => 10
849
- ) );
850
-
851
- echo '<p>' . $this->core->available_template_tags( array( 'post' ), '%buy_button%' ) . '</p>';
852
-
853
- ?>
854
- </div>
855
- </div>
856
-
857
- <div class="row">
858
- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
859
- <h3><?php _e( 'Insufficient Funds Template', 'mycred' ); ?></h3>
860
- <p><span class="description"><?php _e( 'The content will be replaced with this template when viewed by a user that has not paid for the content and can not afford to pay.', 'mycred' ); ?></span></p>
861
- <?php
862
-
863
- wp_editor( $this->sell_content['templates']['cantafford'], $this->field_id( array( 'templates' => 'cantafford' ) ), array(
864
- 'textarea_name' => $this->field_name( array( 'templates' => 'cantafford' ) ),
865
- 'textarea_rows' => 10
866
- ) );
867
-
868
- echo '<p>' . $this->core->available_template_tags( array( 'post' ) ) . '</p>';
869
-
870
- ?>
871
- </div>
872
- </div>
873
-
874
- <div class="row">
875
- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
876
- <h3><?php _e( 'Visitors Template', 'mycred' ); ?></h3>
877
- <p><span class="description"><?php _e( 'The content will be replaced with this template when viewed by someone who is not logged in on your website.', 'mycred' ); ?></span></p>
878
- <?php
879
-
880
- wp_editor( $this->sell_content['templates']['visitors'], $this->field_id( array( 'templates' => 'visitors' ) ), array(
881
- 'textarea_name' => $this->field_name( array( 'templates' => 'visitors' ) ),
882
- 'textarea_rows' => 10
883
- ) );
884
-
885
- echo '<p>' . $this->core->available_template_tags( array( 'post' ) ) . '</p>';
886
-
887
- ?>
888
- </div>
889
- </div>
890
-
891
- </div>
892
- <script type="text/javascript">
893
- (function($) {
894
-
895
- var selectedposttypes = <?php echo count( $selected_types ); ?>;
896
- var selectedpointtypes = <?php echo count( $this->sell_content['type'] ); ?>;
897
-
898
- $( '#myCRED-wrap .mycred-check-count' ).click(function(){
899
-
900
- if ( $(this).is( ':checked' ) ) {
901
-
902
- selectedposttypes++;
903
- $( '#mycred-sell-content-post-type-warning' ).hide();
904
-
905
- $( '#sellcontentprefsposttypes' + $(this).data( 'type' ) + '-wrap' ).show();
906
-
907
- }
908
- else {
909
- selectedposttypes--;
910
- if ( selectedposttypes <= 0 )
911
- $( '#mycred-sell-content-post-type-warning' ).show();
912
- else
913
- $( '#mycred-sell-content-post-type-warning' ).hide();
914
-
915
- $( '#sellcontentprefsposttypes' + $(this).data( 'type' ) + '-wrap' ).hide();
916
- }
917
-
918
- });
919
-
920
- $( '#myCRED-wrap .mycred-check-count' ).click(function(){
921
-
922
- if ( $(this).is( ':checked' ) ) {
923
-
924
- selectedpointtypes++;
925
- $( '#mycred-sell-content-point-type-warning' ).hide();
926
-
927
- $( '#mycred-sell-' + $(this).data( 'type' ) + '-wrap' ).show();
928
-
929
- }
930
- else {
931
- selectedpointtypes--;
932
- if ( selectedpointtypes <= 0 )
933
- $( '#mycred-sell-content-point-type-warning' ).show();
934
- else
935
- $( '#mycred-sell-content-point-type-warning' ).hide();
936
-
937
- $( '#mycred-sell-' + $(this).data( 'type' ) + '-wrap' ).hide();
938
- }
939
-
940
- });
941
-
942
- $( '#mycred-sell-this-post-type-filter' ).on( 'change', 'select.toggle-filter-menu', function(){
943
-
944
- var post_type = $(this).data( 'type' );
945
- var selectedfilter = $(this).find( ':selected' );
946
- var placeholder = selectedfilter.data( 'place' );
947
-
948
- if ( selectedfilter === undefined || selectedfilter.val() == 'all' || selectedfilter.val() == 'manual' ) {
949
- $( '#post-type-filter-' + post_type ).hide();
950
- $( '#post-type-filter-' + post_type + ' input' ).val( '' );
951
- }
952
-
953
- else {
954
- $( '#post-type-filter-' + post_type ).show();
955
- }
956
-
957
- if ( placeholder === undefined )
958
- $( '#post-type-filter-' + post_type + ' input' ).attr( 'placeholder', '' );
959
-
960
- else
961
- $( '#post-type-filter-' + post_type + ' input' ).attr( 'placeholder', placeholder );
962
-
963
- });
964
-
965
- })( jQuery );
966
- </script>
967
- <?php
968
-
969
- }
970
-
971
- /**
972
- * Sanitize & Save Settings
973
- * @since 0.1
974
- * @version 1.4
975
- */
976
- public function sanitize_extra_settings( $new_data, $data, $general ) {
977
-
978
- $settings = $data['sell_content'];
979
-
980
- // Post Types
981
- $post_types = array();
982
- if ( array_key_exists( 'post_types', $settings ) && is_array( $settings['post_types'] ) && ! empty( $settings['post_types'] ) ) {
983
-
984
- foreach ( $settings['post_types'] as $post_type ) {
985
- $post_types[] = sanitize_text_field( $post_type );
986
- }
987
-
988
- }
989
- $new_data['sell_content']['post_types'] = implode( ',', $post_types );
990
-
991
- // Post Type Filter
992
- $filters = array();
993
- if ( array_key_exists( 'filters', $settings ) && is_array( $settings['filters'] ) && ! empty( $settings['filters'] ) ) {
994
-
995
- foreach ( $settings['filters'] as $post_type => $setup ) {
996
-
997
- if ( ! in_array( $post_type, $post_types ) ) continue;
998
-
999
- $filters[ $post_type ] = array( 'by' => 'all', 'list' => '' );
1000
-
1001
- $by = sanitize_text_field( $setup['by'] );
1002
- if ( $by != '' ) {
1003
-
1004
- // Unless we selected all, we need to check the list
1005
- if ( $by !== 'all' && $by !== 'manual' ) {
1006
-
1007
- // Clean up list by sanitizing and removing stray empty spaces
1008
- $list = sanitize_text_field( $setup['list'] );
1009
- if ( $list != '' ) {
1010
- $_list = array();
1011
- foreach ( explode( ',', $list ) as $object_slug ) {
1012
- $object_slug = sanitize_text_field( $object_slug );
1013
- $object_slug = trim( $object_slug );
1014
- $_list[] = $object_slug;
1015
- }
1016
- $list = implode( ',', $_list );
1017
- }
1018
-
1019
- $filters[ $post_type ]['by'] = $by;
1020
- $filters[ $post_type ]['list'] = $list;
1021
-
1022
- }
1023
- elseif ( $by === 'manual' ) {
1024
-
1025
- $filters[ $post_type ]['by'] = 'manual';
1026
-
1027
- }
1028
-
1029
- }
1030
-
1031
- }
1032
-
1033
- }
1034
- $new_data['sell_content']['filters'] = $filters;
1035
-
1036
- // Point Types
1037
- $point_types = array();
1038
- if ( array_key_exists( 'type', $settings ) && is_array( $settings['type'] ) && ! empty( $settings['type'] ) ) {
1039
-
1040
- foreach ( $settings['type'] as $point_type ) {
1041
- $point_types[] = sanitize_key( $point_type );
1042
- }
1043
-
1044
- }
1045
- if ( empty( $point_types ) )
1046
- $point_types[] = MYCRED_DEFAULT_TYPE_KEY;
1047
-
1048
- $new_data['sell_content']['type'] = $point_types;
1049
-
1050
- // Point type default setup
1051
- if ( array_key_exists( 'post_type_setup', $settings ) ) {
1052
- foreach ( $settings['post_type_setup'] as $point_type => $setup ) {
1053
-
1054
- $new = wp_parse_args( $setup, array(
1055
- 'status' => 'disabled',
1056
- 'price' => 0,
1057
- 'expire' => 0,
1058
- 'profit_share' => 0,
1059
- 'button_label' => '',
1060
- 'button_classes' => '',
1061
- 'log_payment' => '',
1062
- 'log_sale' => ''
1063
- ) );
1064
-
1065
- mycred_update_option( 'mycred_sell_this_' . $point_type, $new );
1066
-
1067
- }
1068
- }
1069
-
1070
- $new_data['sell_content']['reload'] = ( ( isset( $settings['reload'] ) ) ? absint( $settings['reload'] ) : 0 );
1071
- $new_data['sell_content']['working'] = wp_kses_post( $settings['working'] );
1072
-
1073
- // Templates
1074
- $new_data['sell_content']['templates']['members'] = wp_kses_post( $settings['templates']['members'] );
1075
- $new_data['sell_content']['templates']['visitors'] = wp_kses_post( $settings['templates']['visitors'] );
1076
- $new_data['sell_content']['templates']['cantafford'] = wp_kses_post( $settings['templates']['cantafford'] );
1077
-
1078
- update_option( 'mycred_sell_content_one_seven_updated', time() );
1079
-
1080
- return $new_data;
1081
-
1082
- }
1083
-
1084
- /**
1085
- * Scripts & Styles
1086
- * @since 1.7
1087
- * @version 1.0
1088
- */
1089
- public function scripts_and_styles() {
1090
-
1091
- $screen = get_current_screen();
1092
-
1093
- if ( in_array( $screen->id, explode( ',', $this->sell_content['post_types'] ) ) ) {
1094
- wp_enqueue_style( 'mycred-bootstrap-grid' );
1095
- wp_enqueue_style( 'mycred-forms' );
1096
- }
1097
-
1098
- }
1099
-
1100
- /**
1101
- * Add Meta Box to Content
1102
- * @since 0.1
1103
- * @version 1.1
1104
- */
1105
- public function add_metabox( $post ) {
1106
-
1107
- $settings = mycred_sell_content_settings();
1108
-
1109
- // Do not add the metabox unless we set this post type to be "manual"
1110
- if ( empty( $settings['filters'][ $post->post_type ] ) || $settings['filters'][ $post->post_type ]['by'] !== 'manual' ) return;
1111
-
1112
- add_meta_box(
1113
- 'mycred-sell-content-setup',
1114
- apply_filters( 'mycred_sell_this_label', __( 'Sell Content', 'mycred' ), $this ),
1115
- array( $this, 'metabox' ),
1116
- $post->post_type,
1117
- 'side',
1118
- 'high'
1119
- );
1120
-
1121
- add_filter( 'postbox_classes_' . $post->post_type . '_mycred-sell-content-setup', array( $this, 'metabox_classes' ) );
1122
-
1123
- }
1124
-
1125
- /**
1126
- * Sell Meta Box
1127
- * @since 0.1
1128
- * @version 1.2
1129
- */
1130
- public function metabox( $post ) {
1131
-
1132
- $settings = mycred_sell_content_settings();
1133
- $expiration = apply_filters( 'mycred_sell_exp_title', __( 'Hour(s)', 'mycred' ) );
1134
- $is_author = ( ( $post->post_author == $this->current_user_id ) ? true : false );
1135
-
1136
- ?>
1137
- <style type="text/css">
1138
- #mycred-sell-content-setup .inside { padding: 0 !important; }
1139
- #mycred-sell-content-setup .inside .row { margin-bottom: 0; }
1140
- #mycred-sell-content-setup .inside .container-fluid { padding-left: 0; padding-right: 0; }
1141
- #mycred-sell-content-setup .inside .row .col-lg-12 .form-group { padding: 12px 12px 10px 12px; background-color: white; border-bottom: 1px solid #ddd; }
1142
- #mycred-sell-content-types .point-type-setup .cover { border-bottom: 1px solid #ddd; }
1143
- #mycred-sell-content-types .point-type-setup .cover > .row { padding-top: 6px; padding-bottom: 12px; }
1144
- #mycred-sell-content-types .point-type-setup:last-child .cover { border-bottom: none; }
1145
- </style>
1146
- <div id="mycred-sell-content-types" class="container-fluid">
1147
- <input type="hidden" name="mycred-sell-this-setup-token" value="<?php echo wp_create_nonce( 'mycred-sell-this-content' ); ?>" />
1148
- <?php
1149
-
1150
- if ( ! empty( $settings['type'] ) ) {
1151
- foreach ( $settings['type'] as $point_type ) {
1152
-
1153
- $setup = mycred_get_option( 'mycred_sell_this_' . $point_type );
1154
-
1155
- if ( $setup['status'] === 'disabled' ) continue;
1156
-
1157
- $mycred = mycred( $point_type );
1158
-
1159
- $suffix = '_' . $point_type;
1160
- if ( $point_type == MYCRED_DEFAULT_TYPE_KEY )
1161
- $suffix = '';
1162
-
1163
- $sale_setup = (array) mycred_get_post_meta( $post->ID, 'myCRED_sell_content' . $suffix );
1164
-
1165
- $sale_setup = empty($sale_setup) ? $sale_setup : $sale_setup[0];
1166
-
1167
- $sale_setup = shortcode_atts( array(
1168
- 'status' => 'disabled',
1169
- 'price' => 0,
1170
- 'expire' => 0
1171
- ), $sale_setup );
1172
-
1173
- $expiration_description = __( 'Never expires', 'mycred' );
1174
- if ( absint( $sale_setup['expire'] ) > 0 )
1175
- $expiration_description = $sale_setup['expire'] . ' ' . $expiration;
1176
-
1177
- ?>
1178
- <div class="form point-type-setup">
1179
- <div class="row row-narrow">
1180
- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
1181
- <div class="form-group slim">
1182
- <label for="mycred-sell-this-<?php echo $point_type; ?>-status" class="slim"><input type="checkbox" name="mycred_sell_this[<?php echo $point_type; ?>][status]" id="mycred-sell-this-<?php echo $point_type; ?>-status"<?php if ( $sale_setup['status'] === 'enabled' ) echo ' checked="checked"'; ?> value="enabled" class="toggle-setup" data-type="<?php echo $point_type; ?>" /> <?php printf( __( 'Sell using %s', 'Point types name', 'mycred' ), $mycred->plural() ); ?></label>
1183
- </div>
1184
- </div>
1185
- </div>
1186
- <div class="cover">
1187
- <div class="row row-narrow padded-row mycred-sell-setup-container" id="mycred-sell-content-<?php echo $point_type; ?>-wrap" style="display: <?php if ( $sale_setup['status'] === 'enabled' ) echo 'block'; else echo 'none'; ?>;">
1188
- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
1189
- <div class="form-group slim">
1190
- <label for="mycred-sell-this-<?php echo $point_type; ?>-price"><?php _e( 'Price', 'mycred' ); ?></label>
1191
- <input type="text" name="mycred_sell_this[<?php echo $point_type; ?>][price]" id="mycred-sell-this-<?php echo $point_type; ?>-price" class="form-control" value="<?php echo esc_attr( $sale_setup['price'] ); ?>" />
1192
- </div>
1193
- </div>
1194
- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
1195
- <div class="form-group slim">
1196
- <label for="mycred-sell-this-<?php echo $point_type; ?>-expire"><?php _e( 'Expiration', 'mycred' ); ?></label>
1197
- <input type="text" name="mycred_sell_this[<?php echo $point_type; ?>][expire]" id="mycred-sell-this-<?php echo $point_type; ?>-expire" class="form-control" value="<?php echo absint( $sale_setup['expire'] ); ?>" />
1198
- </div>
1199
- </div>
1200
- </div>
1201
- </div>
1202
- </div>
1203
- <?php
1204
-
1205
- }
1206
- }
1207
-
1208
- ?>
1209
- <script type="text/javascript">
1210
- (function($) {
1211
-
1212
- $( '#mycred-sell-content-types .toggle-setup' ).click(function(){
1213
-
1214
- if ( $(this).is( ':checked' ) ) {
1215
- $( '#mycred-sell-content-types #mycred-sell-content-' + $(this).data( 'type' ) + '-wrap' ).slideDown();
1216
- }
1217
- else {
1218
- $( '#mycred-sell-content-types #mycred-sell-content-' + $(this).data( 'type' ) + '-wrap' ).slideUp();
1219
- }
1220
-
1221
- });
1222
-
1223
- })( jQuery );
1224
- </script>
1225
- </div>
1226
- <?php
1227
-
1228
- }
1229
-
1230
- /**
1231
- * Save Sell Meta Box
1232
- * @since 0.1
1233
- * @version 1.1
1234
- */
1235
- public function save_metabox( $post_id ) {
1236
-
1237
- // Minimum requirement
1238
- if ( ! isset( $_POST['mycred_sell_this'] ) || ! is_array( $_POST['mycred_sell_this'] ) || empty( $_POST['mycred_sell_this'] ) ) return;
1239
-
1240
- // Verify nonce
1241
- if ( isset( $_POST['mycred-sell-this-setup-token'] ) && wp_verify_nonce( $_POST['mycred-sell-this-setup-token'], 'mycred-sell-this-content' ) ) {
1242
-
1243
- $settings = mycred_sell_content_settings();
1244
-
1245
- if ( ! empty( $settings['type'] ) ) {
1246
- foreach ( $settings['type'] as $point_type ) {
1247
-
1248
- if ( ! array_key_exists( $point_type, $_POST['mycred_sell_this'] ) ) continue;
1249
-
1250
- $mycred = mycred( $point_type );
1251
-
1252
- $new_setup = array( 'status' => 'disabled', 'price' => 0, 'expire' => 0 );
1253
- $submission = shortcode_atts( array(
1254
- 'status' => 'disabled',
1255
- 'price' => 0,
1256
- 'expire' => 0
1257
- ), $_POST['mycred_sell_this'][ $point_type ] );
1258
-
1259
- if ( $submission['status'] == '' ) $submission['status'] = 'disabled';
1260
-
1261
- // If not empty and different from the general setup, save<
1262
- if ( in_array( $submission['status'], array( 'enabled', 'disabled' ) ) )
1263
- $new_setup['status'] = sanitize_key( $submission['status'] );
1264
-
1265
- // If not empty and different from the general setup, save<
1266
- if ( strlen( $submission['price'] ) > 0 )
1267
- $new_setup['price'] = $mycred->number( sanitize_text_field( $submission['price'] ) );
1268
-
1269
- // If not empty and different from the general setup, save<
1270
- if ( strlen( $submission['expire'] ) > 0 )
1271
- $new_setup['expire'] = absint( sanitize_text_field( $submission['expire'] ) );
1272
-
1273
- $suffix = '_' . $point_type;
1274
- if ( $point_type == MYCRED_DEFAULT_TYPE_KEY )
1275
- $suffix = '';
1276
-
1277
- mycred_update_post_meta( $post_id, 'myCRED_sell_content' . $suffix, $new_setup );
1278
-
1279
- }
1280
- }
1281
-
1282
- }
1283
-
1284
- }
1285
-
1286
- /**
1287
- * Add Email Notice Instance
1288
- * @since 1.5.4
1289
- * @version 1.0
1290
- */
1291
- public function email_notice_instance( $events, $request ) {
1292
-
1293
- if ( $request['ref'] == 'buy_content' ) {
1294
- if ( $request['amount'] < 0 )
1295
- $events[] = 'buy_content|negative';
1296
- elseif ( $request['amount'] > 0 )
1297
- $events[] = 'buy_content|positive';
1298
- }
1299
-
1300
- return $events;
1301
-
1302
- }
1303
-
1304
- /**
1305
- * Support for Email Notices
1306
- * @since 1.1
1307
- * @version 1.0
1308
- */
1309
- public function email_notices( $data ) {
1310
-
1311
- if ( $data['request']['ref'] == 'buy_content' ) {
1312
- $message = $data['message'];
1313
- $data['message'] = $this->core->template_tags_post( $message, $data['request']['ref_id'] );
1314
- }
1315
-
1316
- return $data;
1317
-
1318
- }
1319
-
1320
- }
1321
-
1322
- endif;
1323
-
1324
- /**
1325
- * Load Sell Content Module
1326
- * @since 1.7
1327
- * @version 1.0
1328
- */
1329
- if ( ! function_exists( 'mycred_load_sell_content_addon' ) ) :
1330
- function mycred_load_sell_content_addon( $modules, $point_types ) {
1331
-
1332
- $modules['solo']['content'] = new myCRED_Sell_Content_Module();
1333
- $modules['solo']['content']->load();
1334
-
1335
- return $modules;
1336
-
1337
- }
1338
- endif;
1339
- add_filter( 'mycred_load_modules', 'mycred_load_sell_content_addon', 90, 2 );
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Addon: Sell Content
4
+ * Addon URI: http://codex.mycred.me/chapter-iii/sell-content/
5
+ * Version: 2.0.1
6
+ */
7
+ if ( ! defined( 'myCRED_VERSION' ) ) exit;
8
+
9
+ define( 'myCRED_SELL', __FILE__ );
10
+ define( 'myCRED_SELL_VERSION', '1.5' );
11
+ define( 'MYCRED_SELL_DIR', myCRED_ADDONS_DIR . 'sell-content/' );
12
+ define( 'MYCRED_SELL_ASSETS_DIR', MYCRED_SELL_DIR . 'assets/' );
13
+ define( 'MYCRED_SELL_INCLUDES_DIR', MYCRED_SELL_DIR . 'includes/' );
14
+
15
+ require_once MYCRED_SELL_INCLUDES_DIR . 'mycred-sell-functions.php';
16
+ require_once MYCRED_SELL_INCLUDES_DIR . 'mycred-sell-shortcodes.php';
17
+
18
+ /**
19
+ * myCRED_Sell_Content_Module class
20
+ * @since 0.1
21
+ * @version 2.0.1
22
+ */
23
+ if ( ! class_exists( 'myCRED_Sell_Content_Module' ) ) :
24
+ class myCRED_Sell_Content_Module extends myCRED_Module {
25
+
26
+ public $current_user_id = 0;
27
+ public $priority = 10;
28
+ public $bbp_content = '';
29
+
30
+ /**
31
+ * Construct
32
+ */
33
+ function __construct() {
34
+
35
+ parent::__construct( 'myCRED_Sell_Content_Module', array(
36
+ 'module_name' => 'sell_content',
37
+ 'register' => false,
38
+ 'defaults' => array(
39
+ 'post_types' => 'post,page',
40
+ 'filters' => array(),
41
+ 'type' => array( MYCRED_DEFAULT_TYPE_KEY ),
42
+ 'reload' => 0,
43
+ 'working' => 'Processing ...',
44
+ 'templates' => array(
45
+ 'members' => '<div class="text-center"><h3>Premium Content</h3><p>Buy access to this content.</p><p>%buy_button%</p></div>',
46
+ 'visitors' => '<div class="text-center"><h3>Premium Content</h3><p>Login to buy access to this content.</p></div>',
47
+ 'cantafford' => '<div class="text-center"><h3>Premium Content</h3><p>Buy access to this content.</p><p><strong>Insufficient Funds</strong></p></div>'
48
+ )
49
+ ),
50
+ 'add_to_core' => true
51
+ ) );
52
+
53
+ if ( ! is_array( $this->sell_content['type'] ) )
54
+ $this->sell_content['type'] = array( $this->sell_content['type'] );
55
+
56
+ }
57
+
58
+ /**
59
+ * Module Init
60
+ * @since 0.1
61
+ * @version 1.2.1
62
+ */
63
+ public function module_init() {
64
+
65
+ $this->current_user_id = get_current_user_id();
66
+ $this->priority = apply_filters( 'mycred_sell_content_priority', 25, $this );
67
+
68
+ // Email add-on support
69
+ add_filter( 'mycred_get_email_events', array( $this, 'email_notice_instance' ), 10, 2 );
70
+ add_filter( 'mycred_email_before_send', array( $this, 'email_notices' ), 40, 2 );
71
+
72
+ // Setup Content Override
73
+ add_action( 'template_redirect', array( $this, 'template_redirect' ), 99990 );
74
+
75
+ // Register shortcodes
76
+ add_shortcode( MYCRED_SLUG . '_sell_this', 'mycred_render_sell_this' );
77
+ add_shortcode( MYCRED_SLUG . '_sell_this_ajax', 'mycred_render_sell_this_ajax' );
78
+ add_shortcode( MYCRED_SLUG . '_sales_history', 'mycred_render_sell_history' );
79
+ add_shortcode( MYCRED_SLUG . '_content_sale_count', 'mycred_render_sell_count' );
80
+ add_shortcode( MYCRED_SLUG . '_content_buyer_count', 'mycred_render_sell_buyer_count' );
81
+ add_shortcode( MYCRED_SLUG . '_content_buyer_avatars', 'mycred_render_sell_buyer_avatars' );
82
+
83
+ // Setup Script
84
+ add_action( 'mycred_register_assets', array( $this, 'register_assets' ) );
85
+ add_action( 'mycred_front_enqueue_footer', array( $this, 'enqueue_footer' ) );
86
+ add_action( 'bbp_template_redirect', array( $this, 'bbp_content' ), 10 );
87
+
88
+ }
89
+
90
+ /**
91
+ * Module Admin Init
92
+ * @since 1.7
93
+ * @version 1.0
94
+ */
95
+ public function module_admin_init() {
96
+
97
+ // Setup the "Sell This" Metaboxes
98
+ $post_types = explode( ',', $this->sell_content['post_types'] );
99
+ if ( ! empty( $post_types ) ) {
100
+
101
+ foreach ( $post_types as $type ) {
102
+ add_action( "add_meta_boxes_{$type}", array( $this, 'add_metabox' ) );
103
+ add_action( "save_post_{$type}", array( $this, 'save_metabox' ) );
104
+ }
105
+
106
+ }
107
+
108
+ // User Override
109
+ add_action( 'mycred_user_edit_after_balances', array( $this, 'sell_content_user_screen' ), 50 );
110
+
111
+ add_action( 'personal_options_update', array( $this, 'save_manual_profit_share' ), 50 );
112
+ add_action( 'edit_user_profile_update', array( $this, 'save_manual_profit_share' ), 50 );
113
+
114
+ }
115
+
116
+ /**
117
+ * Register Assets
118
+ * @since 1.7
119
+ * @version 1.0
120
+ */
121
+ public function register_assets() {
122
+
123
+ wp_register_script(
124
+ 'mycred-sell-this',
125
+ plugins_url( 'assets/js/buy-content.js', myCRED_SELL ),
126
+ array( 'jquery' ),
127
+ '2.0.1',
128
+ true
129
+ );
130
+
131
+ }
132
+
133
+ /**
134
+ * Load Script
135
+ * @since 1.7
136
+ * @version 1.0.2
137
+ */
138
+ public function enqueue_footer() {
139
+
140
+ global $mycred_sell_this;
141
+
142
+ // Only enqueue our script if it's needed
143
+ if ( $mycred_sell_this === true ) {
144
+
145
+ global $post;
146
+
147
+ wp_localize_script(
148
+ 'mycred-sell-this',
149
+ 'myCREDBuyContent',
150
+ array(
151
+ 'ajaxurl' => esc_url( ( isset( $post->ID ) ) ? mycred_get_permalink( $post->ID ) : home_url( '/' ) ),
152
+ 'token' => wp_create_nonce( 'mycred-buy-this-content' ),
153
+ 'working' => esc_js( $this->sell_content['working'] ),
154
+ 'reload' => $this->sell_content['reload'],
155
+ 'sweeterror' => __( 'Error', 'mycred' )
156
+ )
157
+ );
158
+
159
+ wp_enqueue_script( 'mycred-sell-this' );
160
+
161
+ }
162
+
163
+ }
164
+
165
+ /**
166
+ * Setup Content Filter
167
+ * We are using the template_redirect action to prevent this add-on having to run anywhere else but
168
+ * in the front-end of our website, since the the_content filter is used in soooo many places.
169
+ * As of 1.7.6, purchases are made via front-end submissions and not via admin-ajax.php
170
+ * @since 1.7
171
+ * @version 1.0.1
172
+ */
173
+ public function template_redirect() {
174
+
175
+ global $mycred_partial_content_sale;
176
+
177
+ $mycred_partial_content_sale = false;
178
+
179
+ // Handle purhchase requests
180
+ $this->maybe_buy_content();
181
+
182
+ // Unless we successfully bought the content, filter it
183
+ add_filter( 'the_content', array( $this, 'the_content' ), $this->priority );
184
+
185
+ }
186
+
187
+ /**
188
+ * Maybe Buy Content
189
+ * Check if a purchase request has been made either via an AJAX submission.
190
+ * @since 1.7.6
191
+ * @version 1.0
192
+ */
193
+ public function maybe_buy_content() {
194
+
195
+ if ( is_user_logged_in() && ! mycred_is_admin() ) {
196
+
197
+ if ( isset( $_POST['action'] ) && $_POST['action'] == 'mycred-buy-content' && isset( $_POST['postid'] ) && isset( $_POST['token'] ) && wp_verify_nonce( $_POST['token'], 'mycred-buy-this-content' ) ) {
198
+
199
+ $post_id = absint( $_POST['postid'] );
200
+ $point_type = sanitize_key( $_POST['ctype'] );
201
+ $buying_cred = $this->sell_content['type'];
202
+ $point_types = mycred_get_types( true );
203
+ global $mycred_types;
204
+
205
+ if ( ! array_key_exists( $point_type, $mycred_types ) || mycred_force_singular_session( $this->current_user_id, 'mycred-last-content-purchase' ) || !in_array($point_type, $buying_cred) )
206
+ wp_send_json( 'ERROR' );
207
+
208
+
209
+
210
+
211
+
212
+ // If the content is for sale and we have not paid for it
213
+ if ( mycred_post_is_for_sale( $post_id ) && ! mycred_user_paid_for_content( $this->current_user_id, $post_id ) ) {
214
+
215
+ $content = '';
216
+ $post = mycred_get_post( $post_id );
217
+ $purchase = mycred_sell_content_new_purchase( $post, $this->current_user_id, $point_type );
218
+
219
+ // Successfull purchase
220
+ if ( $purchase === true ) {
221
+
222
+ preg_match('/\[mycred_sell_this[^\]]*](.*)\[\/mycred_sell_this[^\]]*]/uis', $post->post_content , $match );
223
+
224
+ $content = $post->post_content;
225
+ if ( is_array( $match ) && array_key_exists( 1, $match ) )
226
+ $content = $match[1];
227
+
228
+ do_action( 'mycred_sell_before_content_render' );
229
+
230
+ remove_filter( 'the_content', array( $this, 'the_content' ), $this->priority );
231
+ $content = apply_filters( 'the_content', $content );
232
+ $content = str_replace( ']]>', ']]&gt;', $content );
233
+ $content = do_shortcode( $content );
234
+ add_filter( 'the_content', array( $this, 'the_content' ), $this->priority );
235
+
236
+ }
237
+
238
+ // Something went wrong
239
+ else {
240
+
241
+ $content = $purchase;
242
+
243
+ }
244
+
245
+ // Let others play
246
+ $content = apply_filters( 'mycred_content_purchase_ajax', $content, $purchase );
247
+
248
+ if ( $purchase !== true )
249
+ wp_send_json_error( $content );
250
+
251
+ wp_send_json_success( $content );
252
+
253
+ }
254
+
255
+ wp_send_json( 'ERROR' );
256
+
257
+ }
258
+
259
+ }
260
+
261
+ }
262
+
263
+ /**
264
+ * The Content Overwrite
265
+ * Handles content sales by replacing the posts content with the appropriate template
266
+ * for those who have not paid. Admins and authors are excluded.
267
+ * @since 0.1
268
+ * @version 1.2.2
269
+ */
270
+ public function the_content( $content ) {
271
+
272
+ global $mycred_partial_content_sale, $mycred_sell_this;
273
+
274
+ $post_id = mycred_sell_content_post_id();
275
+ $post = mycred_get_post( $post_id );
276
+
277
+ // If content is for sale
278
+ if ( mycred_post_is_for_sale( $post_id ) ) {
279
+
280
+ $mycred_sell_this = true;
281
+
282
+ // Parse shortcodes now just in case it has not been done already
283
+ $_content = do_shortcode( $content );
284
+
285
+ // Partial Content Sale - We have already done the work in the shortcode
286
+ if ( $mycred_partial_content_sale === true )
287
+ return $_content;
288
+
289
+ // Logged in users
290
+ if ( is_user_logged_in() ) {
291
+
292
+ // Authors and admins do not pay
293
+ if ( ! mycred_is_admin() && $post->post_author != $this->current_user_id ) {
294
+
295
+ // In case we have not paid
296
+ if ( ! mycred_user_paid_for_content( $this->current_user_id, $post_id ) ) {
297
+
298
+ // Get Payment Options
299
+ $payment_options = mycred_sell_content_payment_buttons( $this->current_user_id, $post_id );
300
+
301
+ // User can buy
302
+ if ( $payment_options !== false ) {
303
+
304
+ $content = $this->sell_content['templates']['members'];
305
+ $content = str_replace( '%buy_button%', $payment_options, $content );
306
+ $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-unpaid' );
307
+
308
+ }
309
+
310
+ // Can not afford to buy
311
+ else {
312
+
313
+ $content = $this->sell_content['templates']['cantafford'];
314
+ $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-insufficient' );
315
+
316
+ }
317
+
318
+ }
319
+
320
+ }
321
+
322
+ }
323
+
324
+ // Visitors
325
+ else {
326
+
327
+ $content = $this->sell_content['templates']['visitors'];
328
+ $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-visitor' );
329
+
330
+ }
331
+
332
+ }
333
+
334
+ return $content;
335
+
336
+ }
337
+
338
+
339
+
340
+ public function bbp_content() {
341
+
342
+ global $mycred_partial_content_sale, $mycred_sell_this;
343
+
344
+ $post_id = mycred_sell_content_post_id();
345
+ $post = mycred_get_post( $post_id );
346
+ $content = '';
347
+
348
+ // If content is for sale
349
+ if ( mycred_post_is_for_sale( $post_id ) && ( bbp_is_single_forum() || bbp_is_single_topic() || bbp_is_single_reply() ) ) {
350
+
351
+ $mycred_sell_this = true;
352
+
353
+ // Partial Content Sale - We have already done the work in the shortcode
354
+ if ( $mycred_partial_content_sale === true ) return;
355
+
356
+ // Logged in users
357
+ if ( is_user_logged_in() ) {
358
+
359
+ // Authors and admins do not pay
360
+ if ( ! mycred_is_admin() && $post->post_author != $this->current_user_id ) {
361
+
362
+ // In case we have not paid
363
+ if ( ! mycred_user_paid_for_content( $this->current_user_id, $post_id ) ) {
364
+
365
+ // Get Payment Options
366
+ $payment_options = mycred_sell_content_payment_buttons( $this->current_user_id, $post_id );
367
+
368
+ // User can buy
369
+ if ( $payment_options !== false ) {
370
+
371
+ $content = $this->sell_content['templates']['members'];
372
+ $content = str_replace( '%buy_button%', $payment_options, $content );
373
+ $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-unpaid' );
374
+ $this->mycred_bbp_sell_forum_actions();
375
+
376
+ }
377
+
378
+ // Can not afford to buy
379
+ else {
380
+
381
+ $content = $this->sell_content['templates']['cantafford'];
382
+ $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-insufficient' );
383
+ $this->mycred_bbp_sell_forum_actions();
384
+
385
+ }
386
+
387
+ }
388
+
389
+ }
390
+
391
+ }
392
+
393
+ // Visitors
394
+ else {
395
+
396
+ $content = $this->sell_content['templates']['visitors'];
397
+ $content = mycred_sell_content_template( $content, $post, 'mycred-sell-entire-content', 'mycred-sell-visitor' );
398
+ $this->mycred_bbp_sell_forum_actions();
399
+
400
+ }
401
+
402
+ }
403
+
404
+ $this->bbp_content = $content;
405
+
406
+ }
407
+
408
+
409
+ public function mycred_bbp_sell_forum_actions() {
410
+
411
+ add_action( 'bbp_template_before_single_forum', array( $this, 'bbp_template_before_single' ) );
412
+ add_action( 'bbp_template_before_single_topic', array( $this, 'bbp_template_before_single' ) );
413
+ add_filter( 'bbp_no_breadcrumb', array( $this, 'bbp_remove_breadcrumb' ), 10 );
414
+ add_filter( 'bbp_get_forum_subscribe_link', array( $this, 'bbp_remove_subscribe_link' ), 10 , 3 );
415
+ add_filter( 'bbp_get_topic_subscribe_link', array( $this, 'bbp_remove_subscribe_link' ), 10 , 3 );
416
+ add_filter( 'bbp_get_topic_favorite_link', array( $this, 'bbp_remove_subscribe_link' ), 10 , 3 );
417
+ add_filter( 'bbp_get_template_part', array( $this, 'bbp_remove_templates' ), 10 , 3 );
418
+ add_filter( 'bbp_get_single_forum_description', array( $this, 'bbp_get_single_description' ), 10 , 3 );
419
+ add_filter( 'bbp_get_single_topic_description', array( $this, 'bbp_get_single_description' ), 10 , 3 );
420
+
421
+ }
422
+
423
+ public function bbp_template_before_single() {
424
+
425
+ echo $this->bbp_content;
426
+
427
+ }
428
+
429
+ public function bbp_remove_breadcrumb( $is_front ) {
430
+ return true;
431
+ }
432
+
433
+ public function bbp_remove_subscribe_link( $retval, $r, $args ) {
434
+ return '';
435
+ }
436
+
437
+ public function bbp_remove_templates( $templates, $slug, $name ) {
438
+
439
+ if ( $slug == 'content' ) return $templates;
440
+
441
+ return array('');
442
+ }
443
+
444
+ public function bbp_get_single_description( $retstr, $r, $args ) {
445
+ return '';
446
+ }
447
+
448
+ /**
449
+ * User Level Override
450
+ * @since 1.5
451
+ * @version 1.3.1
452
+ */
453
+ public function sell_content_user_screen( $user ) {
454
+
455
+ // Only visible to admins
456
+ if ( ! mycred_is_admin() ) return;
457
+
458
+ $mycred_types = mycred_get_types( true );
459
+ $available_options = array();
460
+
461
+ foreach ( $mycred_types as $point_type_key => $label ) {
462
+
463
+ $setup = array( 'name' => $label, 'enabled' => false, 'default' => 0, 'excluded' => true, 'override' => false, 'custom' => 0 );
464
+
465
+ if ( ! empty( $this->sell_content['type'] ) && in_array( $point_type_key, $this->sell_content['type'] ) ) {
466
+
467
+ $setup['enabled'] = true;
468
+ $mycred = mycred( $point_type_key );
469
+
470
+ if ( ! $mycred->exclude_user( $user->ID ) ) {
471
+
472
+ $setup['excluded'] = false;
473
+
474
+ $settings = mycred_get_option( 'mycred_sell_this_' . $point_type_key );
475
+
476
+ $setup['default'] = $settings['profit_share'];
477
+
478
+ $users_share = mycred_get_user_meta( $user->ID, 'mycred_sell_content_share_' . $point_type_key, '', true );
479
+ if ( strlen( $users_share ) > 0 ) {
480
+
481
+ $setup['override'] = true;
482
+ $setup['custom'] = $users_share;
483
+
484
+ }
485
+
486
+ }
487
+
488
+ }
489
+
490
+ $available_options[ $point_type_key ] = $setup;
491
+
492
+ }
493
+
494
+ if ( empty( $available_options ) ) return;
495
+
496
+ ?>
497
+ <p class="mycred-p"><?php _e( 'Users profit share when their content is purchased.', 'mycred' ); ?></p>
498
+ <table class="form-table mycred-inline-table">
499
+ <tr>
500
+ <th scope="row"><?php _e( 'Profit Share', 'mycred' ); ?></th>
501
+ <td>
502
+ <fieldset id="mycred-badge-list" class="badge-list">
503
+ <legend class="screen-reader-text"><span><?php _e( 'Profit Share', 'mycred' ); ?></span></legend>
504
+ <?php
505
+
506
+ foreach ( $available_options as $point_type => $data ) {
507
+
508
+ // This point type is not for sale
509
+ if ( ! $data['enabled'] ) {
510
+
511
+ ?>
512
+ <div class="mycred-wrapper buycred-wrapper disabled-option color-option">
513
+ <div><?php printf( _x( '%s Profit Share', 'Points Name', 'mycred' ), $data['name'] ); ?></div>
514
+ <div class="balance-row">
515
+ <div class="balance-view"><?php _e( 'Disabled', 'mycred' ); ?></div>
516
+ <div class="balance-desc"><em><?php _e( 'Not accepted as payment.', 'mycred' ); ?></em></div>
517
+ </div>
518
+ </div>
519
+ <?php
520
+
521
+ }
522
+
523
+ // This user is excluded from this point type
524
+ elseif ( $data['excluded'] ) {
525
+
526
+ ?>
527
+ <div class="mycred-wrapper buycred-wrapper disabled-option color-option">
528
+ <div><?php printf( _x( '%s Profit Share', 'Points Name', 'mycred' ), $data['name'] ); ?></div>
529
+ <div class="balance-row">
530
+ <div class="balance-view"><?php _e( 'Excluded', 'mycred' ); ?></div>
531
+ <div class="balance-desc"><em><?php printf( _x( 'User can not pay using %s', 'Points Name', 'mycred' ), $data['name'] ); ?></em></div>
532
+ </div>
533
+ </div>
534
+ <?php
535
+
536
+ }
537
+
538
+ // Eligeble user
539
+ else {
540
+
541
+ ?>
542
+ <div class="mycred-wrapper buycred-wrapper color-option selected">
543
+ <div><?php printf( _x( '%s Profit Share', 'Buying Points', 'mycred' ), $data['name'] ); ?></div>
544
+ <div class="balance-row">
545
+ <div class="balance-view"><input type="text" size="8" name="mycred_sell_this[<?php echo $point_type; ?>]" class="half" placeholder="<?php echo esc_attr( $data['default'] ); ?>" value="<?php if ( $data['override'] ) echo esc_attr( $data['custom'] ); ?>" /> %</div>
546
+ <div class="balance-desc"><em><?php _e( 'Leave empty to use the default.', 'mycred' ); ?></em></div>
547
+ </div>
548
+ </div>
549
+ <?php
550
+
551
+ }
552
+
553
+ }
554
+
555
+ ?>
556
+ </fieldset>
557
+ </td>
558
+ </tr>
559
+ </table>
560
+ <hr />
561
+ <?php
562
+
563
+ }
564
+
565
+ /**
566
+ * Save Override
567
+ * @since 1.5
568
+ * @version 1.2
569
+ */
570
+ function save_manual_profit_share( $user_id ) {
571
+
572
+ // Only visible to admins
573
+ if ( ! mycred_is_admin() ) return;
574
+
575
+ if ( isset( $_POST['mycred_sell_this'] ) && ! empty( $_POST['mycred_sell_this'] ) ) {
576
+
577
+ foreach ( $_POST['mycred_sell_this'] as $point_type => $share ) {
578
+
579
+ $share = sanitize_text_field( $share );
580
+
581
+ mycred_delete_user_meta( $user_id, 'mycred_sell_content_share_' . $point_type );
582
+ if ( $share != '' && is_numeric( $share ) )
583
+ mycred_update_user_meta( $user_id, 'mycred_sell_content_share_' . $point_type, '', $share );
584
+
585
+ }
586
+
587
+ }
588
+
589
+ }
590
+
591
+ /**
592
+ * Enabled / Disabled Select Options
593
+ * @since 1.7
594
+ * @version 1.0
595
+ */
596
+ protected function enabled_options( $selected = '' ) {
597
+
598
+ $options = array(
599
+ 'disabled' => __( 'Disabled', 'mycred' ),
600
+ 'enabled' => __( 'Enabled', 'mycred' )
601
+ );
602
+
603
+ $output = '';
604
+ foreach ( $options as $value => $label ) {
605
+ $output .= '<option value="' . $value . '"';
606
+ if ( $selected == $value ) $output .= ' selected="selected"';
607
+ $output .= '>' . $label . '</option>';
608
+ }
609
+
610
+ return $output;
611
+
612
+ }
613
+
614
+ /**
615
+ * Settings Page
616
+ * @since 0.1
617
+ * @version 1.4
618
+ */
619
+ public function after_general_settings( $mycred = NULL ) {
620
+
621
+ $post_types = mycred_sell_content_post_types();
622
+ $selected_types = explode( ',', $this->sell_content['post_types'] );
623
+
624
+ $point_types = mycred_get_types( true );
625
+
626
+ ?>
627
+ <h4><span class="dashicons dashicons-admin-plugins static"></span><?php _e( 'Sell Content', 'mycred' ); ?></h4>
628
+ <div class="body" style="display:none;">
629
+
630
+ <h3><?php _e( 'Post Types', 'mycred' ); ?></h3>
631
+ <p><?php _e( 'Which post type(s) content field do you want to sell access to?', 'mycred' ); ?></p>
632
+ <div id="mycred-sell-this-post-type-filter">
633
+ <?php
634
+
635
+ if ( ! empty( $post_types ) ) {
636
+ foreach ( $post_types as $post_type => $post_type_label ) {
637
+
638
+ $selected = '';
639
+ if ( in_array( $post_type, $selected_types ) )
640
+ $selected = ' checked="checked"';
641
+
642
+ $show_options = 'none';
643
+ if ( in_array( $post_type, $selected_types ) )
644
+ $show_options = 'block';
645
+
646
+ ?>
647
+ <div class="row">
648
+ <div class="col-lg-3 col-md-3 col-sm-12 col-xs-12">
649
+ <div class="checkbox">
650
+ <label for="<?php echo $this->field_id( array( 'post_types' => $post_type ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'post_types' => $post_type ) ); ?>"<?php echo $selected; ?> id="<?php echo $this->field_id( array( 'post_types' => $post_type ) ); ?>" class="mycred-check-count" data-type="<?php echo $post_type; ?>" value="<?php echo $post_type; ?>" /> <?php echo esc_attr( $post_type_label ); ?></label>
651
+ </div>
652
+ </div>
653
+ <div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
654
+ <div id="<?php echo $this->field_id( array( 'post_types' => $post_type ) ); ?>-wrap" style="display: <?php echo $show_options; ?>;">
655
+ <div class="row">
656
+ <div class="col-lg-5 col-md-5 col-sm-6 col-xs-12">
657
+ <div class="form-group">
658
+ <select name="<?php echo $this->field_name( array( 'filters' => $post_type ) ); ?>[by]" class="form-control toggle-filter-menu" data-type="<?php echo $post_type; ?>">
659
+ <?php
660
+
661
+ $settings = array( 'by' => 'all', 'list' => '' );
662
+ if ( array_key_exists( $post_type, $this->sell_content['filters'] ) )
663
+ $settings = $this->sell_content['filters'][ $post_type ];
664
+
665
+ $options = mycred_get_post_type_options( $post_type );
666
+ if ( ! empty( $options ) ) {
667
+ foreach ( $options as $value => $option ) {
668
+
669
+ echo '<option value="' . $value . '"';
670
+ if ( $value == $settings['by'] ) echo ' selected="selected"';
671
+ if ( $option['data'] != '' ) echo ' data-place="' . $option['data'] . '"';
672
+ echo '>' . $option['label'] . '</option>';
673
+
674
+ }
675
+ }
676
+
677
+ ?>
678
+ </select>
679
+ </div>
680
+ </div>
681
+ <div class="col-lg-7 col-md-7 col-sm-6 col-xs-12">
682
+ <div id="post-type-filter-<?php echo $post_type; ?>" style="display: <?php if ( ! in_array( $settings['by'], array( 'all', 'manual' ) ) ) echo 'block'; else echo 'none'; ?>;">
683
+ <div class="form-group">
684
+ <input type="text" name="<?php echo $this->field_name( array( 'filters' => $post_type ) ); ?>[list]" value="<?php echo esc_attr( $settings['list'] ); ?>" placeholder="<?php if ( array_key_exists( $settings['by'], $options ) ) echo esc_attr( $options[ $settings['by'] ]['data'] ); ?>" class="form-control" />
685
+ </div>
686
+ </div>
687
+ </div>
688
+ </div>
689
+ </div>
690
+ </div>
691
+ </div>
692
+ <?php
693
+
694
+ }
695
+ }
696
+
697
+ ?>
698
+ </div>
699
+
700
+ <h3><?php _e( 'Point Types', 'mycred' ); ?></h3>
701
+ <p><?php _e( 'Which point type(s) can be used as payment for accessing content?', 'mycred' ); ?></p>
702
+ <div class="row">
703
+ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
704
+ <?php
705
+
706
+ if ( ! empty( $point_types ) ) {
707
+ foreach ( $point_types as $point_type => $point_type_label ) {
708
+
709
+ $selected = '';
710
+ if ( in_array( $point_type, $this->sell_content['type'] ) )
711
+ $selected = ' checked="checked"';
712
+
713
+ if ( count( $point_types ) === 1 )
714
+ $selected = ' checked="checked" disabled="disabled"';
715
+
716
+ ?>
717
+ <div class="form-group">
718
+ <label for="<?php echo $this->field_id( array( 'type' => $point_type ) ); ?>"><input type="checkbox" name="<?php echo $this->field_name( array( 'type' => $point_type ) ); ?>"<?php echo $selected; ?> id="<?php echo $this->field_id( array( 'type' => $point_type ) ); ?>" class="mycred-check-count" data-type="<?php echo $point_type; ?>" value="<?php echo $point_type; ?>" /> <?php echo esc_attr( $point_type_label ); ?></label>
719
+ </div>
720
+ <?php
721
+
722
+ }
723
+ }
724
+
725
+ ?>
726
+ </div>
727
+ </div>
728
+
729
+ <?php
730
+
731
+ if ( ! empty( $point_types ) ) {
732
+ foreach ( $point_types as $point_type => $point_type_label ) {
733
+
734
+ $selected = 'none';
735
+ if ( in_array( $point_type, $this->sell_content['type'] ) )
736
+ $selected = 'block';
737
+
738
+ if ( count( $point_types ) === 1 )
739
+ $selected = 'block';
740
+
741
+ $mycred = mycred( $point_type );
742
+ $type_setup = mycred_get_option( 'mycred_sell_this_' . $point_type );
743
+ $type_setup = wp_parse_args( $type_setup, array(
744
+ 'status' => 'disabled',
745
+ 'price' => 0,
746
+ 'expire' => 0,
747
+ 'profit_share' => 0,
748
+ 'button_label' => 'Pay %price%',
749
+ 'button_classes' => 'btn btn-primary btn-lg',
750
+ 'log_payment' => 'Purchase of %link_with_title%',
751
+ 'log_sale' => 'Sale of %link_with_title%'
752
+ ) );
753
+
754
+ $expiration_label = apply_filters( 'mycred_sell_exp_title', __( 'Hour(s)', 'mycred' ), $point_type );
755
+
756
+ ?>
757
+ <div id="mycred-sell-<?php echo $point_type; ?>-wrap" style="display: <?php echo $selected; ?>;">
758
+ <h3><?php printf( __( '%s Setup', 'mycred' ), $point_type_label ); ?></h3>
759
+ <div class="row">
760
+ <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
761
+ <div class="form-group">
762
+ <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-status' ) ); ?>"><?php _e( 'Default Status', 'mycred' ); ?></label>
763
+ <select name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[status]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-status' ) ); ?>" class="form-control">
764
+ <?php echo $this->enabled_options( $type_setup['status'] ); ?>
765
+ </select>
766
+ </div>
767
+ </div>
768
+ <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
769
+ <div class="form-group">
770
+ <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-price' ) ); ?>"><?php _e( 'Default Price', 'mycred' ); ?></label>
771
+ <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[price]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-price' ) ); ?>" class="form-control" value="<?php echo esc_attr( $type_setup['price'] ); ?>" />
772
+ </div>
773
+ </div>
774
+ <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
775
+ <div class="form-group">
776
+ <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-expire' ) ); ?>"><?php _e( 'Expiration', 'mycred' ); ?></label>
777
+ <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[expire]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-expire' ) ); ?>" class="form-control" value="<?php echo esc_attr( $type_setup['expire'] ); ?>" />
778
+ <p><span class="description"><?php printf( __( 'Option to automatically expire purchases after certain number of %s. Use zero to disable.', 'mycred' ), $expiration_label ); ?></span></p>
779
+ </div>
780
+ </div>
781
+ <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
782
+ <div class="form-group">
783
+ <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-profit-share' ) ); ?>"><?php _e( 'Profit Share', 'mycred' ); ?></label>
784
+ <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[profit_share]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-profit-share' ) ); ?>" class="form-control" value="<?php echo esc_attr( $type_setup['profit_share'] ); ?>" />
785
+ <p><span class="description"><?php printf( __( 'Option to pay a percentage of each sale with the content author.', 'mycred' ), $expiration_label ); ?></span></p>
786
+ </div>
787
+ </div>
788
+ </div>
789
+ <div class="row">
790
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
791
+ <div class="form-group">
792
+ <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-button' ) ); ?>"><?php _e( 'Button Label', 'mycred' ); ?></label>
793
+ <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[button_label]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-button' ) ); ?>" class="form-control" placeholder="<?php _e( 'Required', 'mycred' ); ?>" value="<?php echo esc_attr( $type_setup['button_label'] ); ?>" />
794
+ <p><span class="description"><?php echo $this->core->available_template_tags( array(), '%price%' ); ?></span></p>
795
+ </div>
796
+ </div>
797
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
798
+ <div class="form-group">
799
+ <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-css' ) ); ?>"><?php _e( 'Button CSS Classes', 'mycred' ); ?></label>
800
+ <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[button_classes]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-css' ) ); ?>" class="form-control" value="<?php echo esc_attr( $type_setup['button_classes'] ); ?>" />
801
+ </div>
802
+ </div>
803
+ </div>
804
+ <h3><?php _e( 'Log Templates', 'mycred' ); ?></h3>
805
+ <div class="row">
806
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
807
+ <div class="form-group">
808
+ <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-log-pay' ) ); ?>"><?php _e( 'Payment log entry template', 'mycred' ); ?></label>
809
+ <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[log_payment]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-log-pay' ) ); ?>" class="form-control" placeholder="<?php _e( 'Required', 'mycred' ); ?>" value="<?php echo esc_attr( $type_setup['log_payment'] ); ?>" />
810
+ <p><span class="description"><?php echo $this->core->available_template_tags( array( 'general', 'post' ) ); ?></span></p>
811
+ </div>
812
+ </div>
813
+ <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
814
+ <div class="form-group">
815
+ <label for="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-log-share' ) ); ?>"><?php _e( 'Profit Share payout log entry template', 'mycred' ); ?></label>
816
+ <input type="text" name="<?php echo $this->field_name( array( 'post_type_setup' => $point_type ) ); ?>[log_sale]" id="<?php echo $this->field_id( array( 'post_type_setup' => $point_type . '-log-share' ) ); ?>" class="form-control" placeholder="<?php _e( 'Required', 'mycred' ); ?>" value="<?php echo esc_attr( $type_setup['log_sale'] ); ?>" />
817
+ <p><span class="description"><?php echo $this->core->available_template_tags( array( 'general', 'post' ) ); ?></span></p>
818
+ </div>
819
+ </div>
820
+ </div>
821
+ </div>
822
+ <?php
823
+
824
+ }
825
+ }
826
+
827
+ ?>
828
+
829
+ <h3><?php _e( 'Transactions', 'mycred' ); ?></h3>
830
+ <div class="row">
831
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
832
+ <div class="checkbox">
833
+ <label for="<?php echo $this->field_id( 'reload' ); ?>"><input type="checkbox" name="<?php echo $this->field_name( 'reload' ); ?>" id="<?php echo $this->field_id( 'reload' ); ?>" <?php checked( $this->sell_content['reload'], 1 ); ?> value="1" /> <?php _e( 'Reload page after successful payments.', 'mycred' ); ?></label>
834
+ </div>
835
+ </div>
836
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
837
+ <div class="form-group">
838
+ <label for="<?php echo $this->field_id( 'working' ); ?>"><?php _e( 'Button Label', 'mycred' ); ?></label>
839
+ <input type="text" name="<?php echo $this->field_name( 'working' ); ?>" id="<?php echo $this->field_id( 'working' ); ?>" class="form-control" placeholder="<?php _e( 'Required', 'mycred' ); ?>" value="<?php echo esc_attr( $this->sell_content['working'] ); ?>" />
840
+ <p><span class="description"><?php _e( 'Option to show a custom button label while the payment is being processed. HTML is allowed.', 'mycred' ); ?></span></p>
841
+ </div>
842
+ </div>
843
+ </div>
844
+
845
+ <div class="row">
846
+ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
847
+ <h3><?php _e( 'Purchase Template', 'mycred' ); ?></h3>
848
+ <p><span class="description"><?php _e( 'The content will be replaced with this template when viewed by a user that has not paid for the content but can afford to pay.', 'mycred' ); ?></span></p>
849
+ <?php
850
+
851
+ wp_editor( $this->sell_content['templates']['members'], $this->field_id( array( 'templates' => 'members' ) ), array(
852
+ 'textarea_name' => $this->field_name( array( 'templates' => 'members' ) ),
853
+ 'textarea_rows' => 10
854
+ ) );
855
+
856
+ echo '<p>' . $this->core->available_template_tags( array( 'post' ), '%buy_button%' ) . '</p>';
857
+
858
+ ?>
859
+ </div>
860
+ </div>
861
+
862
+ <div class="row">
863
+ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
864
+ <h3><?php _e( 'Insufficient Funds Template', 'mycred' ); ?></h3>
865
+ <p><span class="description"><?php _e( 'The content will be replaced with this template when viewed by a user that has not paid for the content and can not afford to pay.', 'mycred' ); ?></span></p>
866
+ <?php
867
+
868
+ wp_editor( $this->sell_content['templates']['cantafford'], $this->field_id( array( 'templates' => 'cantafford' ) ), array(
869
+ 'textarea_name' => $this->field_name( array( 'templates' => 'cantafford' ) ),
870
+ 'textarea_rows' => 10
871
+ ) );
872
+
873
+ echo '<p>' . $this->core->available_template_tags( array( 'post' ) ) . '</p>';
874
+
875
+ ?>
876
+ </div>
877
+ </div>
878
+
879
+ <div class="row">
880
+ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
881
+ <h3><?php _e( 'Visitors Template', 'mycred' ); ?></h3>
882
+ <p><span class="description"><?php _e( 'The content will be replaced with this template when viewed by someone who is not logged in on your website.', 'mycred' ); ?></span></p>
883
+ <?php
884
+
885
+ wp_editor( $this->sell_content['templates']['visitors'], $this->field_id( array( 'templates' => 'visitors' ) ), array(
886
+ 'textarea_name' => $this->field_name( array( 'templates' => 'visitors' ) ),
887
+ 'textarea_rows' => 10
888
+ ) );
889
+
890
+ echo '<p>' . $this->core->available_template_tags( array( 'post' ) ) . '</p>';
891
+
892
+ ?>
893
+ </div>
894
+ </div>
895
+
896
+ </div>
897
+ <script type="text/javascript">
898
+ (function($) {
899
+
900
+ var selectedposttypes = <?php echo count( $selected_types ); ?>;
901
+ var selectedpointtypes = <?php echo count( $this->sell_content['type'] ); ?>;
902
+
903
+ $( '#myCRED-wrap .mycred-check-count' ).click(function(){
904
+
905
+ if ( $(this).is( ':checked' ) ) {
906
+
907
+ selectedposttypes++;
908
+ $( '#mycred-sell-content-post-type-warning' ).hide();
909
+
910
+ $( '#sellcontentprefsposttypes' + $(this).data( 'type' ) + '-wrap' ).show();
911
+
912
+ }
913
+ else {
914
+ selectedposttypes--;
915
+ if ( selectedposttypes <= 0 )
916
+ $( '#mycred-sell-content-post-type-warning' ).show();
917
+ else
918
+ $( '#mycred-sell-content-post-type-warning' ).hide();
919
+
920
+ $( '#sellcontentprefsposttypes' + $(this).data( 'type' ) + '-wrap' ).hide();
921
+ }
922
+
923
+ });
924
+
925
+ $( '#myCRED-wrap .mycred-check-count' ).click(function(){
926
+
927
+ if ( $(this).is( ':checked' ) ) {
928
+
929
+ selectedpointtypes++;
930
+ $( '#mycred-sell-content-point-type-warning' ).hide();
931
+
932
+ $( '#mycred-sell-' + $(this).data( 'type' ) + '-wrap' ).show();
933
+
934
+ }
935
+ else {
936
+ selectedpointtypes--;
937
+ if ( selectedpointtypes <= 0 )
938
+ $( '#mycred-sell-content-point-type-warning' ).show();
939
+ else
940
+ $( '#mycred-sell-content-point-type-warning' ).hide();
941
+
942
+ $( '#mycred-sell-' + $(this).data( 'type' ) + '-wrap' ).hide();
943
+ }
944
+
945
+ });
946
+
947
+ $( '#mycred-sell-this-post-type-filter' ).on( 'change', 'select.toggle-filter-menu', function(){
948
+
949
+ var post_type = $(this).data( 'type' );
950
+ var selectedfilter = $(this).find( ':selected' );
951
+ var placeholder = selectedfilter.data( 'place' );
952
+
953
+ if ( selectedfilter === undefined || selectedfilter.val() == 'all' || selectedfilter.val() == 'manual' ) {
954
+ $( '#post-type-filter-' + post_type ).hide();
955
+ $( '#post-type-filter-' + post_type + ' input' ).val( '' );
956
+ }
957
+
958
+ else {
959
+ $( '#post-type-filter-' + post_type ).show();
960
+ }
961
+
962
+ if ( placeholder === undefined )
963
+ $( '#post-type-filter-' + post_type + ' input' ).attr( 'placeholder', '' );
964
+
965
+ else
966
+ $( '#post-type-filter-' + post_type + ' input' ).attr( 'placeholder', placeholder );
967
+
968
+ });
969
+
970
+ })( jQuery );
971
+ </script>
972
+ <?php
973
+
974
+ }
975
+
976
+ /**
977
+ * Sanitize & Save Settings
978
+ * @since 0.1
979
+ * @version 1.4
980
+ */
981
+ public function sanitize_extra_settings( $new_data, $data, $general ) {
982
+
983
+ $settings = $data['sell_content'];
984
+
985
+ // Post Types
986
+ $post_types = array();
987
+ if ( array_key_exists( 'post_types', $settings ) && is_array( $settings['post_types'] ) && ! empty( $settings['post_types'] ) ) {
988
+
989
+ foreach ( $settings['post_types'] as $post_type ) {
990
+ $post_types[] = sanitize_text_field( $post_type );
991
+ }
992
+
993
+ }
994
+ $new_data['sell_content']['post_types'] = implode( ',', $post_types );
995
+
996
+ // Post Type Filter
997
+ $filters = array();
998
+ if ( array_key_exists( 'filters', $settings ) && is_array( $settings['filters'] ) && ! empty( $settings['filters'] ) ) {
999
+
1000
+ foreach ( $settings['filters'] as $post_type => $setup ) {
1001
+
1002
+ if ( ! in_array( $post_type, $post_types ) ) continue;
1003
+
1004
+ $filters[ $post_type ] = array( 'by' => 'all', 'list' => '' );
1005
+
1006
+ $by = sanitize_text_field( $setup['by'] );
1007
+ if ( $by != '' ) {
1008
+
1009
+ // Unless we selected all, we need to check the list
1010
+ if ( $by !== 'all' && $by !== 'manual' ) {
1011
+
1012
+ // Clean up list by sanitizing and removing stray empty spaces
1013
+ $list = sanitize_text_field( $setup['list'] );
1014
+ if ( $list != '' ) {
1015
+ $_list = array();
1016
+ foreach ( explode( ',', $list ) as $object_slug ) {
1017
+ $object_slug = sanitize_text_field( $object_slug );
1018
+ $object_slug = trim( $object_slug );
1019
+ $_list[] = $object_slug;
1020
+ }
1021
+ $list = implode( ',', $_list );
1022
+ }
1023
+
1024
+ $filters[ $post_type ]['by'] = $by;
1025
+ $filters[ $post_type ]['list'] = $list;
1026
+
1027
+ }
1028
+ elseif ( $by === 'manual' ) {
1029
+
1030
+ $filters[ $post_type ]['by'] = 'manual';
1031
+
1032
+ }
1033
+
1034
+ }
1035
+
1036
+ }
1037
+
1038
+ }
1039
+ $new_data['sell_content']['filters'] = $filters;
1040
+
1041
+ // Point Types
1042
+ $point_types = array();
1043
+ if ( array_key_exists( 'type', $settings ) && is_array( $settings['type'] ) && ! empty( $settings['type'] ) ) {
1044
+
1045
+ foreach ( $settings['type'] as $point_type ) {
1046
+ $point_types[] = sanitize_key( $point_type );
1047
+ }
1048
+
1049
+ }
1050
+ if ( empty( $point_types ) )
1051
+ $point_types[] = MYCRED_DEFAULT_TYPE_KEY;
1052
+
1053
+ $new_data['sell_content']['type'] = $point_types;
1054
+
1055
+ // Point type default setup
1056
+ if ( array_key_exists( 'post_type_setup', $settings ) ) {
1057
+ foreach ( $settings['post_type_setup'] as $point_type => $setup ) {
1058
+
1059
+ $new = wp_parse_args( $setup, array(
1060
+ 'status' => 'disabled',
1061
+ 'price' => 0,
1062
+ 'expire' => 0,
1063
+ 'profit_share' => 0,
1064
+ 'button_label' => '',
1065
+ 'button_classes' => '',
1066
+ 'log_payment' => '',
1067
+ 'log_sale' => ''
1068
+ ) );
1069
+
1070
+ mycred_update_option( 'mycred_sell_this_' . $point_type, $new );
1071
+
1072
+ }
1073
+ }
1074
+
1075
+ $new_data['sell_content']['reload'] = ( ( isset( $settings['reload'] ) ) ? absint( $settings['reload'] ) : 0 );
1076
+ $new_data['sell_content']['working'] = wp_kses_post( $settings['working'] );
1077
+
1078
+ // Templates
1079
+ $new_data['sell_content']['templates']['members'] = wp_kses_post( $settings['templates']['members'] );
1080
+ $new_data['sell_content']['templates']['visitors'] = wp_kses_post( $settings['templates']['visitors'] );
1081
+ $new_data['sell_content']['templates']['cantafford'] = wp_kses_post( $settings['templates']['cantafford'] );
1082
+
1083
+ update_option( 'mycred_sell_content_one_seven_updated', time() );
1084
+
1085
+ return $new_data;
1086
+
1087
+ }
1088
+
1089
+ /**
1090
+ * Scripts & Styles
1091
+ * @since 1.7
1092
+ * @version 1.0
1093
+ */
1094
+ public function scripts_and_styles() {
1095
+
1096
+ $screen = get_current_screen();
1097
+
1098
+ if ( in_array( $screen->id, explode( ',', $this->sell_content['post_types'] ) ) ) {
1099
+ wp_enqueue_style( 'mycred-bootstrap-grid' );
1100
+ wp_enqueue_style( 'mycred-forms' );
1101
+ }
1102
+
1103
+ }
1104
+
1105
+ /**
1106
+ * Add Meta Box to Content
1107
+ * @since 0.1
1108
+ * @version 1.1
1109
+ */
1110
+ public function add_metabox( $post ) {
1111
+
1112
+ $settings = mycred_sell_content_settings();
1113
+
1114
+ // Do not add the metabox unless we set this post type to be "manual"
1115
+ if ( empty( $settings['filters'][ $post->post_type ] ) || $settings['filters'][ $post->post_type ]['by'] !== 'manual' ) return;
1116
+
1117
+ add_meta_box(
1118
+ 'mycred-sell-content-setup',
1119
+ apply_filters( 'mycred_sell_this_label', __( 'Sell Content', 'mycred' ), $this ),
1120
+ array( $this, 'metabox' ),
1121
+ $post->post_type,
1122
+ 'side',
1123
+ 'high'
1124
+ );
1125
+
1126
+ add_filter( 'postbox_classes_' . $post->post_type . '_mycred-sell-content-setup', array( $this, 'metabox_classes' ) );
1127
+
1128
+ }
1129
+
1130
+ /**
1131
+ * Sell Meta Box
1132
+ * @since 0.1
1133
+ * @version 1.2
1134
+ */
1135
+ public function metabox( $post ) {
1136
+
1137
+ $settings = mycred_sell_content_settings();
1138
+ $expiration = apply_filters( 'mycred_sell_exp_title', __( 'Hour(s)', 'mycred' ) );
1139
+ $is_author = ( ( $post->post_author == $this->current_user_id ) ? true : false );
1140
+
1141
+ ?>
1142
+ <style type="text/css">
1143
+ #mycred-sell-content-setup .inside { padding: 0 !important; }
1144
+ #mycred-sell-content-setup .inside .row { margin-bottom: 0; }
1145
+ #mycred-sell-content-setup .inside .container-fluid { padding-left: 0; padding-right: 0; }
1146
+ #mycred-sell-content-setup .inside .row .col-lg-12 .form-group { padding: 12px 12px 10px 12px; background-color: white; border-bottom: 1px solid #ddd; }
1147
+ #mycred-sell-content-types .point-type-setup .cover { border-bottom: 1px solid #ddd; }
1148
+ #mycred-sell-content-types .point-type-setup .cover > .row { padding-top: 6px; padding-bottom: 12px; }
1149
+ #mycred-sell-content-types .point-type-setup:last-child .cover { border-bottom: none; }
1150
+ </style>
1151
+ <div id="mycred-sell-content-types" class="container-fluid">
1152
+ <input type="hidden" name="mycred-sell-this-setup-token" value="<?php echo wp_create_nonce( 'mycred-sell-this-content' ); ?>" />
1153
+ <?php
1154
+
1155
+ if ( ! empty( $settings['type'] ) ) {
1156
+ foreach ( $settings['type'] as $point_type ) {
1157
+
1158
+ $setup = mycred_get_option( 'mycred_sell_this_' . $point_type );
1159
+
1160
+ if ( $setup['status'] === 'disabled' ) continue;
1161
+
1162
+ $mycred = mycred( $point_type );
1163
+
1164
+ $suffix = '_' . $point_type;
1165
+ if ( $point_type == MYCRED_DEFAULT_TYPE_KEY )
1166
+ $suffix = '';
1167
+
1168
+ $sale_setup = (array) mycred_get_post_meta( $post->ID, 'myCRED_sell_content' . $suffix );
1169
+
1170
+ $sale_setup = empty($sale_setup) ? $sale_setup : $sale_setup[0];
1171
+
1172
+ $sale_setup = shortcode_atts( array(
1173
+ 'status' => 'disabled',
1174
+ 'price' => 0,
1175
+ 'expire' => 0
1176
+ ), $sale_setup );
1177
+
1178
+ $expiration_description = __( 'Never expires', 'mycred' );
1179
+ if ( absint( $sale_setup['expire'] ) > 0 )
1180
+ $expiration_description = $sale_setup['expire'] . ' ' . $expiration;
1181
+
1182
+ ?>
1183
+ <div class="form point-type-setup">
1184
+ <div class="row row-narrow">
1185
+ <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
1186
+ <div class="form-group slim">
1187
+ <label for="mycred-sell-this-<?php echo $point_type; ?>-status" class="slim"><input type="checkbox" name="mycred_sell_this[<?php echo $point_type; ?>][status]" id="mycred-sell-this-<?php echo $point_type; ?>-status"<?php if ( $sale_setup['status'] === 'enabled' ) echo ' checked="checked"'; ?> value="enabled" class="toggle-setup" data-type="<?php echo $point_type; ?>" /> <?php printf( __( 'Sell using %s', 'Point types name', 'mycred' ), $mycred->plural() ); ?></label>
1188
+ </div>
1189
+ </div>
1190
+ </div>
1191
+ <div class="cover">
1192
+ <div class="row row-narrow padded-row mycred-sell-setup-container" id="mycred-sell-content-<?php echo $point_type; ?>-wrap" style="display: <?php if ( $sale_setup['status'] === 'enabled' ) echo 'block'; else echo 'none'; ?>;">
1193
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
1194
+ <div class="form-group slim">
1195
+ <label for="mycred-sell-this-<?php echo $point_type; ?>-price"><?php _e( 'Price', 'mycred' ); ?></label>
1196
+ <input type="text" name="mycred_sell_this[<?php echo $point_type; ?>][price]" id="mycred-sell-this-<?php echo $point_type; ?>-price" class="form-control" value="<?php echo esc_attr( $sale_setup['price'] ); ?>" />
1197
+ </div>
1198
+ </div>
1199
+ <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
1200
+ <div class="form-group slim">
1201
+ <label for="mycred-sell-this-<?php echo $point_type; ?>-expire"><?php _e( 'Expiration', 'mycred' ); ?></label>
1202
+ <input type="text" name="mycred_sell_this[<?php echo $point_type; ?>][expire]" id="mycred-sell-this-<?php echo $point_type; ?>-expire" class="form-control" value="<?php echo absint( $sale_setup['expire'] ); ?>" />
1203
+ </div>
1204
+ </div>
1205
+ </div>
1206
+ </div>
1207
+ </div>
1208
+ <?php
1209
+
1210
+ }
1211
+ }
1212
+
1213
+ ?>
1214
+ <script type="text/javascript">
1215
+ (function($) {
1216
+
1217
+ $( '#mycred-sell-content-types .toggle-setup' ).click(function(){
1218
+
1219
+ if ( $(this).is( ':checked' ) ) {
1220
+ $( '#mycred-sell-content-types #mycred-sell-content-' + $(this).data( 'type' ) + '-wrap' ).slideDown();
1221
+ }
1222
+ else {
1223
+ $( '#mycred-sell-content-types #mycred-sell-content-' + $(this).data( 'type' ) + '-wrap' ).slideUp();
1224
+ }
1225
+
1226
+ });
1227
+
1228
+ })( jQuery );
1229
+ </script>
1230
+ </div>
1231
+ <?php
1232
+
1233
+ }
1234
+
1235
+ /**
1236
+ * Save Sell Meta Box
1237
+ * @since 0.1
1238
+ * @version 1.1
1239
+ */
1240
+ public function save_metabox( $post_id ) {
1241
+
1242
+ // Minimum requirement
1243
+ if ( ! isset( $_POST['mycred_sell_this'] ) || ! is_array( $_POST['mycred_sell_this'] ) || empty( $_POST['mycred_sell_this'] ) ) return;
1244
+
1245
+ // Verify nonce
1246
+ if ( isset( $_POST['mycred-sell-this-setup-token'] ) && wp_verify_nonce( $_POST['mycred-sell-this-setup-token'], 'mycred-sell-this-content' ) ) {
1247
+
1248
+ $settings = mycred_sell_content_settings();
1249
+
1250
+ if ( ! empty( $settings['type'] ) ) {
1251
+ foreach ( $settings['type'] as $point_type ) {
1252
+
1253
+ if ( ! array_key_exists( $point_type, $_POST['mycred_sell_this'] ) ) continue;
1254
+
1255
+ $mycred = mycred( $point_type );
1256
+
1257
+ $new_setup = array( 'status' => 'disabled', 'price' => 0, 'expire' => 0 );
1258
+ $submission = shortcode_atts( array(
1259
+ 'status' => 'disabled',
1260
+ 'price' => 0,
1261
+ 'expire' => 0
1262
+ ), $_POST['mycred_sell_this'][ $point_type ] );
1263
+
1264
+ if ( $submission['status'] == '' ) $submission['status'] = 'disabled';
1265
+
1266
+ // If not empty and different from the general setup, save<
1267
+ if ( in_array( $submission['status'], array( 'enabled', 'disabled' ) ) )
1268
+ $new_setup['status'] = sanitize_key( $submission['status'] );
1269
+
1270
+ // If not empty and different from the general setup, save<
1271
+ if ( strlen( $submission['price'] ) > 0 )
1272
+ $new_setup['price'] = $mycred->number( sanitize_text_field( $submission['price'] ) );
1273
+
1274
+ // If not empty and different from the general setup, save<
1275
+ if ( strlen( $submission['expire'] ) > 0 )
1276
+ $new_setup['expire'] = absint( sanitize_text_field( $submission['expire'] ) );
1277
+
1278
+ $suffix = '_' . $point_type;
1279
+ if ( $point_type == MYCRED_DEFAULT_TYPE_KEY )
1280
+ $suffix = '';
1281
+
1282
+ mycred_update_post_meta( $post_id, 'myCRED_sell_content' . $suffix, $new_setup );
1283
+
1284
+ }
1285
+ }
1286
+
1287
+ }
1288
+
1289
+ }
1290
+
1291
+ /**
1292
+ * Add Email Notice Instance
1293
+ * @since 1.5.4
1294
+ * @version 1.0
1295
+ */
1296
+ public function email_notice_instance( $events, $request ) {
1297
+
1298
+ if ( $request['ref'] == 'buy_content' ) {
1299
+ if ( $request['amount'] < 0 )
1300
+ $events[] = 'buy_content|negative';
1301
+ elseif ( $request['amount'] > 0 )
1302
+ $events[] = 'buy_content|positive';
1303
+ }
1304
+
1305
+ return $events;
1306
+
1307
+ }
1308
+
1309
+ /**
1310
+ * Support for Email Notices
1311
+ * @since 1.1
1312
+ * @version 1.0
1313
+ */
1314
+ public function email_notices( $data ) {
1315
+
1316
+ if ( $data['request']['ref'] == 'buy_content' ) {
1317
+ $message = $data['message'];
1318
+ $data['message'] = $this->core->template_tags_post( $message, $data['request']['ref_id'] );
1319
+ }
1320
+
1321
+ return $data;
1322
+
1323
+ }
1324
+
1325
+ }
1326
+
1327
+ endif;
1328
+
1329
+ /**
1330
+ * Load Sell Content Module
1331
+ * @since 1.7
1332
+ * @version 1.0
1333
+ */
1334
+ if ( ! function_exists( 'mycred_load_sell_content_addon' ) ) :
1335
+ function mycred_load_sell_content_addon( $modules, $point_types ) {
1336
+
1337
+ $modules['solo']['content'] = new myCRED_Sell_Content_Module();
1338
+ $modules['solo']['content']->load();
1339
+
1340
+ return $modules;
1341
+
1342
+ }
1343
+ endif;
1344
+ add_filter( 'mycred_load_modules', 'mycred_load_sell_content_addon', 90, 2 );
includes/classes/class.query-log.php CHANGED
@@ -886,14 +886,12 @@ if ( ! class_exists( 'myCRED_Query_Log' ) ) :
886
 
887
  /**
888
  * Ordering of results
889
- *
890
-
891
- // Single order
892
- orderby=time&order=ASC
893
-
894
- // Multiple orders
895
- 'orderby' => array( 'time' => 'ASC', 'id' => 'ASC' )
896
-
897
  */
898
  $this->sortby = "ORDER BY time DESC";
899
  if ( ! empty( $this->args['orderby'] ) ) {
886
 
887
  /**
888
  * Ordering of results
889
+ *
890
+ * Single order
891
+ * orderby=time&order=ASC
892
+ *
893
+ * Multiple orders
894
+ * 'orderby' => array( 'time' => 'ASC', 'id' => 'ASC' )
 
 
895
  */
896
  $this->sortby = "ORDER BY time DESC";
897
  if ( ! empty( $this->args['orderby'] ) ) {
mycred.php CHANGED
@@ -9,7 +9,7 @@
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.5.1
13
  * Text Domain: mycred
14
  * Domain Path: /lang
15
  * License: GPLv2 or later
@@ -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?', '1.8.13.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?', '1.8.13.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!', '1.8.11' );
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.', '1.8.13.1' );
98
  }
99
 
100
  /**
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.6
13
  * Text Domain: mycred
14
  * Domain Path: /lang
15
  * License: GPLv2 or later
54
  * @since 1.7
55
  * @version 1.0
56
  */
57
+ public function __clone() { _doing_it_wrong( __FUNCTION__, 'Cheatin&#8217; huh?', '2.0' ); }
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.0' ); }
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.0' );
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.0' );
98
  }
99
 
100
  /**
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: mycred,wpexpertsio
3
  Tags: badges, gamification, loyalty, points, rewards
4
  Requires at least: 4.8
5
- Tested up to: 5.5.1
6
- Stable tag: 1.8.14.2
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -14,9 +14,9 @@ An adaptive and powerful points management system for WordPress powered websites
14
 
15
  myCred is an intelligent and adaptive **points management system** that allows you to build and manage a broad range of digital rewards including points, ranks and, badges on your WordPress/WooCommerce powered website.
16
 
17
- Build **brand loyalty** by rewarding your customers through store reward systems, community leaderboards, monetizing your website content, etc. – The possibilities are endless.
18
 
19
- **Increase customer engagement tenfold – Rewarding your users for community engagement will help your business grow.**
20
 
21
  = AMAZING AWARD SYSTEMS TO ENGAGE AND REWARD LOYAL CUSTOMERS =
22
 
@@ -24,9 +24,9 @@ myCred allows **THREE different ways** through which you can award your users:
24
 
25
  * **Points -** Set events and triggers to allow real-time tracking and automatically award your users with points.
26
 
27
- * **Ranks –** Set ranks within your leaderboards and reward your users with significant perks after they reach a certain milestone.
28
 
29
- * **Badges -** Boost your users’ participation by rewarding them for their exceptional performance.
30
 
31
  = BECOME A VIP MEMBER OF THE MYCRED MEMBERSHIP CLUB =
32
 
@@ -40,35 +40,54 @@ Join the myCred membership club today and take advantage of premium services tha
40
 
41
  [Check the package pricing page for the add-on list](https://mycred.me/membership/)
42
 
43
- **Important Announcement** You have to update your myCred plugin to version 1.8.8 in order to use the myCred Membership services.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  = Features =
46
 
47
- **- Point Balances:** Each user on your website will have their own point balance, where they’ll be able to view points that were gained/lost.
48
  **- Account History:** Each time a user gains or loses points on your website, the transaction is logged into a central log for accountability.
49
- **- Points Management:** You have full control over your users’ point balances; You can adjust your user/s balance by adding or removing points with or without a log entry.
50
  **- White-Labeling:** myCred has built-in support for white-labeling - This allows you to rename the plugin in your admin area to anything you like.
51
  **- Import & Export:** myCred comes with three built-in import tools allowing you to import points, log entries, or migrate your CubePoints installation.
52
- **- Automatic Points:** Automatically award or deduct points from your user’s balance for their interaction on your Wordpress/WooCommerce website.
53
  **- Multiple Point Types:** Create multiple point types through the admin area to manage things easily. There is no limit to the number of point types you can have at your disposal.
54
  **- Multi-Site Support:** myCred has built-in support for multi-sites, allowing you to choose between using a unique myCred installation or centralize balances across your network.
55
- **- Leaderboards:** Generate leaderboards based on your user’s balance or points history - display users with the most points for a particular instance.
56
  **- Badges:** Award badges to your users based on their points history. You can set certain requirements for this feature so that myCred automatically awards them to the deserving users.
57
  **- Buy Points:** The buyCred add-on allows your users to purchase points using real money using some of the most popular payment gateways available in the market today.
58
  **- Coupons:** Create and share coupon codes with your users, which can be redeemed when they have generated a certain amount of points.
59
  **- Notifications:** The notifications add-on allows you to show popup notifications each time a user gains or loses points on your website.
60
- **- Ranks:** Ranks are based on how well your user balance is performing. As a user’s balance changes, so do their rank.
61
  **- Store Payments:** myCred supports some of the most popular store plugins for WordPress, allowing your users to pay for orders/tickets using their point balance instead of real money.
62
  **- Reward Purchases:** You can opt to reward your users with points that they can use to buy products in your store.
63
  **- Sell Content:** The Sell Content add-on allows you to sell access to the content field of posts/pages or custom post types on your website.
64
  **- Statistics:** The statistics add-on will convert your log data into charts to help visualize points usage and circulation on your website.
65
  **- Transfers:** The transfer add-on allows your users to transfer points to other users on your website.
66
  **- Theme Independent:** The myCred plugin is theme independent - Your theme needs to support widgets and shortcodes in order to run myCred.
67
- **- BuddyPress Ready:** myCred has had built-in support for BuddyPress through which you can access BuddyPress related features like Insert point balances/badges/ranks into your user’s profiles.
68
  **- Bootstrap Ready:** myCred comes with minimal CSS styling to give you the freedom to style everything according to your needs.
69
  **- Translation Ready:** You can add your own language translation or adjust the built-in translation support.
70
 
71
-
72
  = AN ATTRACTIVE AND EFFECTIVE POINTS AND REWARDS SYSTEM =
73
 
74
  Empower your WordPress website users by rewarding them points - each user has their own **POINT BALANCE** that can be used in purchasing online products or online activities.
@@ -77,25 +96,25 @@ Not only will you be able to manually adjust the point balance system at any tim
77
 
78
  = AWARD OR DEDUCT POINTS AUTOMATICALLY =
79
 
80
- **myCred** supports an extensive set of WordPress interactions through which you can automatically give/take points from a user. These actions can be as simple as logging in, publishing content, or leaving a comment. These automatic adjustments are managed by a feature called “[Hooks](https://mycred.me/about/features/#automatic-points)” that can be set up in your admin area.
81
 
82
 
83
  = DEDICATED LOG =
84
 
85
- Each time **myCred** adds or deducts points from a user, the adjustment is [logged](https://mycred.me/about/features/#account-history) in a dedicated log, allowing your users to browse their history. This log keeps a record of your users’ accountability, badges, and ranks, among other useful statistics.
86
 
87
  This log data can be converted into charts to help you visualize the usage and circulation of points on your website.
88
 
89
  You can achieve the following features by using a dedicated log for your points system:
90
 
91
  * Set a limit to the maximum number of times each hook can give out points to your user.
92
- * Badges will use the log’s data to determine which user has earned a badge.
93
  * Add-ons such as “Sell Content” use the log to keep track of users who have purchased posts from your website.
94
  * Add-ons use the log to make sure that a user does not gain repetitive points for the same interaction within a given time frame.
95
 
96
  = BUILT-IN ADD-ONS =
97
 
98
- myCred is much more than just a point management system – The plugin comes with several [built-in add-ons](https://www.mycred.me/add-ons/) that enable you to perform complex tasks such as transfer or buy points for real money, allow payments in stores, etc.
99
 
100
  **- Badges:** Award your users badges based on their points history.
101
  **- buyCred:** Let your users buy points in exchange for real money.
@@ -103,7 +122,7 @@ myCred is much more than just a point management system – The plugin come
103
  **- Email notifications:** Setup email notifications for status updates.
104
  **- Gateway:** Let users pay with points in your store.
105
  **- Notifications:** Enable popup notifications that display status updates.
106
- **- Ranks:** Create ranks based on the user’s point balance.
107
  **- Sell Content:** Sell your content in exchange for points.
108
  **- Statistics:** Get a statistical overview of points in circulation, etc.
109
  **- Transfers:** Allow your users to transfer points to other users.
@@ -114,7 +133,7 @@ Power your WordPress website with 50+ add-ons ranging from categories like **Gam
114
 
115
  myCred supports some of the most popular WordPress plugins like **BuddyPress, WooCommerce, Jetpack, Contact Form 7, Disqus, Gravity Forms,** among countless others.
116
 
117
- **Simple & organized –** To keep your admin area organized, myCred will only show features and setting for those third-party plugins that are installed and enabled.
118
 
119
 
120
  = INTEGRATED WITH THE MOST POPULAR LEARNING MANAGEMENT SYSTEMS =
@@ -142,10 +161,10 @@ myCred is integrated with a large number of popular learning management systems,
142
  [Explore to find out more...](https://www.mycred.me/product-category/freebies/)
143
 
144
 
145
- = MYCRED’S THIRD-PARTY BRIDGES PLUGINS: =
146
 
147
- - [Stripe – buyCred Gateway](https://www.mycred.me/store/buycred-stripe/)
148
- - [Easy Digital Downloads – myCred Gateway](https://www.mycred.me/store/mycred-for-easy-digital-downloads/)
149
  - [myCred Zapier Addon](https://mycred.me/store/mycred-zapier-addon/)
150
  - [myCred Dokan](https://www.mycred.me/store/mycred-dokan/)
151
  - [myCred WCVendors](https://www.mycred.me/store/mycred-wc-vendors/)
@@ -153,13 +172,13 @@ myCred is integrated with a large number of popular learning management systems,
153
  - [myCred for Users Ultra](https://www.mycred.me/store/mycred-for-users-ultra/)
154
  - [myCred for User Pro](https://www.mycred.me/store/mycred-for-user-pro/)
155
 
156
- = MYCRED’S GAMIFICATION PLUGINS: =
157
 
158
  - [myCred PacMan](https://www.mycred.me/store/mycred-pacman/)
159
  - [Wheel of Fortune Add-On](https://www.mycred.me/store/wheel-of-fortune-add-on/)
160
 
161
 
162
- = MYCRED’S ENHANCEMENT PLUGINS: =
163
 
164
  - [myCred WooCommerce Plus](https://www.mycred.me/store/mycred-woocommerce-plus/)
165
  - [myCred Email Digest](https://mycred.me/store/mycred-email-digest/)
@@ -167,7 +186,7 @@ myCred is integrated with a large number of popular learning management systems,
167
  - [myCred Points Cap](https://mycred.me/store/mycred-points-cap/)
168
  - [myCred Level Cred](https://www.mycred.me/store/mycred-level-cred/)
169
  - [myCred Social Proof](https://www.mycred.me/store/mycred-social-proof/)
170
- - [myCred SMS Payments – Twilio Transfers](https://www.mycred.me/store/sms-payments/)
171
  - [myCred Expiration Add on](https://www.mycred.me/store/mycred-expiration-add-on/)
172
  - [myCred Social Share Add on](https://www.mycred.me/store/mycred-social-share-add-on/)
173
  - [myCred Progress Bar Add on](https://www.mycred.me/store/mycred-progress-bar-add-on/)
@@ -191,11 +210,11 @@ myCred has the ability to “do-it-all” because we have put in a lot o
191
 
192
  = Support =
193
 
194
- We offer support on our [myCred website](https://mycred.me/support/) from 9 AM – 5 PM, Monday to Friday (GMT+5).
195
 
196
- You can either submit a [customization request](https://mycred.me/customize/request-quote/) or open a [support ticket](https://mycred.me/support/) any time you’re facing trouble with myCred.
197
 
198
- If you’re facing a problem that is not described in our technical documentation, we suggest that you consult myCred’s [online community](https://mycred.me/support/forums/) with your question. We pay users through myCred Store Tokens as a reward for reporting bugs and even their fixes.
199
 
200
  == Installation ==
201
 
@@ -229,6 +248,9 @@ You can find a list of [frequently asked questions](https://mycred.me/about/faq/
229
 
230
  == Upgrade Notice ==
231
 
 
 
 
232
  = 1.8.0 =
233
  Major release(Make sure to take backup before updating)
234
 
@@ -310,6 +332,19 @@ Bug fixes release.
310
 
311
  == Changelog ==
312
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  = 1.8.14.2 =
314
  - **TWEAK** - Code optimization.
315
 
@@ -518,4 +553,4 @@ IMPROVEMENT - Added check for existing logs getting disappeared.
518
 
519
 
520
  = Previous Versions =
521
- https://mycred.me/support/changelog/
2
  Contributors: mycred,wpexpertsio
3
  Tags: badges, gamification, loyalty, points, rewards
4
  Requires at least: 4.8
5
+ Tested up to: 5.6
6
+ Stable tag: 2.0
7
  Requires PHP: 7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
14
 
15
  myCred is an intelligent and adaptive **points management system** that allows you to build and manage a broad range of digital rewards including points, ranks and, badges on your WordPress/WooCommerce powered website.
16
 
17
+ Build **brand loyalty** by rewarding your customers through store reward systems, community leaderboards, monetizing your website content, etc. - The possibilities are endless.
18
 
19
+ **Increase customer engagement tenfold - Rewarding your users for community engagement will help your business grow.**
20
 
21
  = AMAZING AWARD SYSTEMS TO ENGAGE AND REWARD LOYAL CUSTOMERS =
22
 
24
 
25
  * **Points -** Set events and triggers to allow real-time tracking and automatically award your users with points.
26
 
27
+ * **Ranks -** Set ranks within your leaderboards and reward your users with significant perks after they reach a certain milestone.
28
 
29
+ * **Badges -** Boost your users participation by rewarding them for their exceptional performance.
30
 
31
  = BECOME A VIP MEMBER OF THE MYCRED MEMBERSHIP CLUB =
32
 
40
 
41
  [Check the package pricing page for the add-on list](https://mycred.me/membership/)
42
 
43
+ = Introducing cashCred in myCred v2.0 =
44
+
45
+ **GIVE USERS THE POWER TO CONVERT THEIR MYCRED POINTS INTO REAL MONEY.**
46
+
47
+ **cashCred** is a built-in myCred add-on that allows users to redeem myCred points for real money anytime, anywhere. **Give users the power to earn points through myCred's intelligent rewards system.** Instead of giving them cash, you reward them with points that can be encashed at any time.
48
+
49
+ **cashCred** works perfectly with a reward system that engages users to perform activities that require user interaction (watching a video, filling out a survey and more).
50
+
51
+ * **Convert Points to Cash -** Users can redeem myCred points for money.
52
+ * **Multiple Point Types -** Allow multiple custom point types.
53
+ * **Exchange Rates -** Define exchange rates for each point type.
54
+ * **Cash Withdrawal -** Users can send a request to the admin for cash withdrawal
55
+ * **User Requests -** Approve or deny user requests for cash withdrawal.
56
+ * **Additional Notes -** Write additional notes for users which will be displayed on the payment form.
57
+ * **Currency Code -** Define the currency code (USD, GBP, AUD, etc.) for the payment form.
58
+ * **Shortcode Support -** Display the cashCred module on the website using a shortcode.
59
+ * **Set Limits & Restrictions -** Set minimum or maximum restriction limits on point conversion requests.
60
+ * **Pay Through PayPal -** cashCred supports payment through PayPal.
61
+ * **Pay Through Stripe -** cashCred supports payment through Stripe.
62
+
63
+ **Important Announcement** You have to update your myCred plugin to version 2.0 in order to use the myCred cashCred services.
64
 
65
  = Features =
66
 
67
+ **- Point Balances:** Each user on your website will have their own point balance, where they'll be able to view points that were gained/lost.
68
  **- Account History:** Each time a user gains or loses points on your website, the transaction is logged into a central log for accountability.
69
+ **- Points Management:** You have full control over your users' point balances; You can adjust your user/s balance by adding or removing points with or without a log entry.
70
  **- White-Labeling:** myCred has built-in support for white-labeling - This allows you to rename the plugin in your admin area to anything you like.
71
  **- Import & Export:** myCred comes with three built-in import tools allowing you to import points, log entries, or migrate your CubePoints installation.
72
+ **- Automatic Points:** Automatically award or deduct points from your user's balance for their interaction on your Wordpress/WooCommerce website.
73
  **- Multiple Point Types:** Create multiple point types through the admin area to manage things easily. There is no limit to the number of point types you can have at your disposal.
74
  **- Multi-Site Support:** myCred has built-in support for multi-sites, allowing you to choose between using a unique myCred installation or centralize balances across your network.
75
+ **- Leaderboards:** Generate leaderboards based on your user's balance or points history - display users with the most points for a particular instance.
76
  **- Badges:** Award badges to your users based on their points history. You can set certain requirements for this feature so that myCred automatically awards them to the deserving users.
77
  **- Buy Points:** The buyCred add-on allows your users to purchase points using real money using some of the most popular payment gateways available in the market today.
78
  **- Coupons:** Create and share coupon codes with your users, which can be redeemed when they have generated a certain amount of points.
79
  **- Notifications:** The notifications add-on allows you to show popup notifications each time a user gains or loses points on your website.
80
+ **- Ranks:** Ranks are based on how well your user balance is performing. As a user's balance changes, so do their rank.
81
  **- Store Payments:** myCred supports some of the most popular store plugins for WordPress, allowing your users to pay for orders/tickets using their point balance instead of real money.
82
  **- Reward Purchases:** You can opt to reward your users with points that they can use to buy products in your store.
83
  **- Sell Content:** The Sell Content add-on allows you to sell access to the content field of posts/pages or custom post types on your website.
84
  **- Statistics:** The statistics add-on will convert your log data into charts to help visualize points usage and circulation on your website.
85
  **- Transfers:** The transfer add-on allows your users to transfer points to other users on your website.
86
  **- Theme Independent:** The myCred plugin is theme independent - Your theme needs to support widgets and shortcodes in order to run myCred.
87
+ **- BuddyPress Ready:** myCred has had built-in support for BuddyPress through which you can access BuddyPress related features like Insert point balances/badges/ranks into your user's profiles.
88
  **- Bootstrap Ready:** myCred comes with minimal CSS styling to give you the freedom to style everything according to your needs.
89
  **- Translation Ready:** You can add your own language translation or adjust the built-in translation support.
90
 
 
91
  = AN ATTRACTIVE AND EFFECTIVE POINTS AND REWARDS SYSTEM =
92
 
93
  Empower your WordPress website users by rewarding them points - each user has their own **POINT BALANCE** that can be used in purchasing online products or online activities.
96
 
97
  = AWARD OR DEDUCT POINTS AUTOMATICALLY =
98
 
99
+ **myCred** supports an extensive set of WordPress interactions through which you can automatically give/take points from a user. These actions can be as simple as logging in, publishing content, or leaving a comment. These automatic adjustments are managed by a feature called [Hooks](https://mycred.me/about/features/#automatic-points)” that can be set up in your admin area.
100
 
101
 
102
  = DEDICATED LOG =
103
 
104
+ Each time **myCred** adds or deducts points from a user, the adjustment is [logged](https://mycred.me/about/features/#account-history) in a dedicated log, allowing your users to browse their history. This log keeps a record of your user’s accountability, badges, and ranks, among other useful statistics.
105
 
106
  This log data can be converted into charts to help you visualize the usage and circulation of points on your website.
107
 
108
  You can achieve the following features by using a dedicated log for your points system:
109
 
110
  * Set a limit to the maximum number of times each hook can give out points to your user.
111
+ * Badges will use the logs data to determine which user has earned a badge.
112
  * Add-ons such as “Sell Content” use the log to keep track of users who have purchased posts from your website.
113
  * Add-ons use the log to make sure that a user does not gain repetitive points for the same interaction within a given time frame.
114
 
115
  = BUILT-IN ADD-ONS =
116
 
117
+ myCred is much more than just a point management system - The plugin comes with several [built-in add-ons](https://www.mycred.me/add-ons/) that enable you to perform complex tasks such as transfer or buy points for real money, allow payments in stores, etc.
118
 
119
  **- Badges:** Award your users badges based on their points history.
120
  **- buyCred:** Let your users buy points in exchange for real money.
122
  **- Email notifications:** Setup email notifications for status updates.
123
  **- Gateway:** Let users pay with points in your store.
124
  **- Notifications:** Enable popup notifications that display status updates.
125
+ **- Ranks:** Create ranks based on the users point balance.
126
  **- Sell Content:** Sell your content in exchange for points.
127
  **- Statistics:** Get a statistical overview of points in circulation, etc.
128
  **- Transfers:** Allow your users to transfer points to other users.
133
 
134
  myCred supports some of the most popular WordPress plugins like **BuddyPress, WooCommerce, Jetpack, Contact Form 7, Disqus, Gravity Forms,** among countless others.
135
 
136
+ **Simple & organized –** To keep your admin area organized, myCred will only show features and setting for those third-party plugins that are installed and enabled.
137
 
138
 
139
  = INTEGRATED WITH THE MOST POPULAR LEARNING MANAGEMENT SYSTEMS =
161
  [Explore to find out more...](https://www.mycred.me/product-category/freebies/)
162
 
163
 
164
+ = MYCRED'S THIRD-PARTY BRIDGES PLUGINS: =
165
 
166
+ - [Stripe - buyCred Gateway](https://www.mycred.me/store/buycred-stripe/)
167
+ - [Easy Digital Downloads - myCred Gateway](https://www.mycred.me/store/mycred-for-easy-digital-downloads/)
168
  - [myCred Zapier Addon](https://mycred.me/store/mycred-zapier-addon/)
169
  - [myCred Dokan](https://www.mycred.me/store/mycred-dokan/)
170
  - [myCred WCVendors](https://www.mycred.me/store/mycred-wc-vendors/)
172
  - [myCred for Users Ultra](https://www.mycred.me/store/mycred-for-users-ultra/)
173
  - [myCred for User Pro](https://www.mycred.me/store/mycred-for-user-pro/)
174
 
175
+ = MYCRED'S GAMIFICATION PLUGINS: =
176
 
177
  - [myCred PacMan](https://www.mycred.me/store/mycred-pacman/)
178
  - [Wheel of Fortune Add-On](https://www.mycred.me/store/wheel-of-fortune-add-on/)
179
 
180
 
181
+ = MYCRED'S ENHANCEMENT PLUGINS: =
182
 
183
  - [myCred WooCommerce Plus](https://www.mycred.me/store/mycred-woocommerce-plus/)
184
  - [myCred Email Digest](https://mycred.me/store/mycred-email-digest/)
186
  - [myCred Points Cap](https://mycred.me/store/mycred-points-cap/)
187
  - [myCred Level Cred](https://www.mycred.me/store/mycred-level-cred/)
188
  - [myCred Social Proof](https://www.mycred.me/store/mycred-social-proof/)
189
+ - [myCred SMS Payments - Twilio Transfers](https://www.mycred.me/store/sms-payments/)
190
  - [myCred Expiration Add on](https://www.mycred.me/store/mycred-expiration-add-on/)
191
  - [myCred Social Share Add on](https://www.mycred.me/store/mycred-social-share-add-on/)
192
  - [myCred Progress Bar Add on](https://www.mycred.me/store/mycred-progress-bar-add-on/)
210
 
211
  = Support =
212
 
213
+ We offer support on our [myCred website](https://mycred.me/support/) from 9 AM - 5 PM, Monday to Friday (GMT+5).
214
 
215
+ You can either submit a [customization request](https://mycred.me/customize/request-quote/) or open a [support ticket](https://mycred.me/support/) any time you're facing trouble with myCred.
216
 
217
+ If you're facing a problem that is not described in our technical documentation, we suggest that you consult myCred's [online community](https://mycred.me/support/forums/) with your question. We pay users through myCred Store Tokens as a reward for reporting bugs and even their fixes.
218
 
219
  == Installation ==
220
 
248
 
249
  == Upgrade Notice ==
250
 
251
+ = 2.0 =
252
+ 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.
253
+
254
  = 1.8.0 =
255
  Major release(Make sure to take backup before updating)
256
 
332
 
333
  == Changelog ==
334
 
335
+ = 2.0 =
336
+ NEW - myCred CashCred
337
+ NEW - Added filter 'mycred_link_click_amount'
338
+ NEW - Added exclude attribute in myCred leaderboard
339
+ NEW - Added 'NOT LIKE' and '!=' operator for expiration addon
340
+ FIX - Php notices in rank addon
341
+ FIX - Rewards points option not visible for other product type in woocommerce
342
+ FIX - Erros in mycred_total_balance shortcode
343
+ FIX - myCred logs export issue
344
+ FIX - Fixed mycred admin dashboard overview widget showing incorrect or same amount of points
345
+ FIX - buyCred gift_to attribute not working
346
+ TWEAK - myCred Central Deposit
347
+
348
  = 1.8.14.2 =
349
  - **TWEAK** - Code optimization.
350
 
553
 
554
 
555
  = Previous Versions =
556
+ https://mycred.me/support/changelog/