Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * View my Coupons
- * @since 1.4
- * @version 1.1
- */
- add_shortcode( 'mycred_my_coupons', 'mycred_pro_render_shortcode_my_coupons' );
- function mycred_pro_render_shortcode_my_coupons( $attr, $content ) {
- extract( shortcode_atts( array(
- 'user_id' => NULL,
- 'ctype' => 'mycred_default',
- 'ref' => 'points_to_coupon',
- 'number' => 10
- ), $attr ) );
- if ( ! function_exists( 'mycred' ) ) return 'myCRED is not installed';
- if ( $user_id === NULL && ! is_user_logged_in() ) return $content;
- if ( $user_id === NULL )
- $user_id = get_current_user_id();
- $args = array();
- $args['user_id'] = $user_id;
- $args['ref'] = $ref;
- $args['number'] = $number;
- $log = new myCRED_Query_Log( $args );
- $log->headers = array(
- 'coupon-code' => 'Coupon Code',
- 'coupon-status' => 'Status',
- 'coupon-date' => 'Date Created',
- 'coupon-value' => 'Value'
- );
- ob_start();
- if ( $log->have_entries() )
- $log->display();
- else
- echo '<p>You do not have any coupons</p>';
- $content = ob_get_contents();
- ob_end_clean();
- return $content;
- }
- /**
- * View my Coupons Column : Code
- * @version 1.2
- */
- add_filter( 'mycred_log_coupon-code', 'mycred_pro_column_coupon_code', 10, 2 );
- function mycred_pro_column_coupon_code( $content, $log ) {
- $data = maybe_unserialize( $log->data );
- return $data['code'];
- }
- /**
- * View my Coupons Column : Status
- * @version 1.0
- */
- add_filter( 'mycred_log_coupon-status', 'mycred_pro_column_coupon_status', 10, 2 );
- function mycred_pro_column_coupon_status( $content, $log ) {
- if ( get_the_title( $log->ref_id ) == '' )
- return 'Used';
- else
- return 'Unused';
- }
- /**
- * View my Coupons Column : Date
- * @version 1.0
- */
- add_filter( 'mycred_log_coupon-date', 'mycred_pro_column_coupon_date', 10, 2 );
- function mycred_pro_column_coupon_date( $content, $log ) {
- return date_i18n( 'Y-m-d', $log->time );
- }
- /**
- * View my Coupons Column : Value
- * @version 1.1
- */
- add_filter( 'mycred_log_coupon-value', 'mycred_pro_column_coupon_value', 10, 2 );
- function mycred_pro_column_coupon_value( $content, $log ) {
- $data = maybe_unserialize( $log->data );
- if ( isset( $data['value'] ) )
- return '$' . $data['value'];
- else
- return '-';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement