%s',
esc_url( add_query_arg( array(
'wpaf_coupon_category' => $term->slug,
'post_type' => $post->post_type
), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'cpt_coupon_category', 'display' ) )
);
}
echo wp_kses_post( join( ', ', $out ) );
} else {
esc_html_e( 'No Category', 'affcoupon' );
}
break;
case 'coupon_vendor':
$terms = get_the_terms( $post_id, 'wpaf_coupon_vendor' );
if ( ! empty( $terms ) ) {
$out = array();
foreach ( $terms as $term ) {
$out[] = sprintf( '%s',
esc_url( add_query_arg( array(
'wpaf_coupon_vendor' => $term->slug,
'post_type' => $post->post_type
), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'cpt_coupon_vendor', 'display' ) )
);
}
echo wp_kses_post( join( ', ', $out ) );
} else {
esc_html_e( 'No Vendor', 'affcoupon' );
}
break;
case 'coupon_shortcode':
$coupon_type = get_post_meta( $post_id, 'coupon_details_coupon-type', true );
if ( $coupon_type === 'Image' ) {
$shortcode = "[affcoupon id=" . $post_id . "]";
echo esc_html( $shortcode );
} else {
$shortcode = "[affcoupon id=" . $post_id . "]";
$code_shortcode = "[affcoupon_btn id=" . $post_id . "]";
echo esc_html( $shortcode ) . '
' . esc_html( $code_shortcode );
}
break;
case 'coupon_details_coupon-code':
$coupon_code = get_post_meta( $post_id, 'coupon_details_coupon-code-text', true );
echo wp_kses_post( $coupon_code );
break;
case 'coupon_details_description':
$description = get_post_meta( $post_id, 'coupon_details_description', true );
echo wp_kses_post( $description );
break;
case 'coupon_details_link':
$link = get_post_meta( $post_id, 'coupon_details_link', true );
echo esc_url( $link );
break;
case 'coupon_type':
$coupon_type = get_post_meta( $post_id, 'coupon_details_coupon-type', true );
echo esc_html( $coupon_type );
break;
case 'coupon_expire':
$today = gmdate( 'd-m-Y' );
$expire = get_post_meta( $post_id, 'coupon_details_expire-date', true );
$expireDateFormat = get_option( 'wpaf_expiry-date-format' );
$expireDateFormatFun = wpaf_getExpireDateFormatFun( $expireDateFormat );
if ( ! empty ( $expire ) ) {
if ( (string)(int)$expire != $expire ) {
$expire = strtotime( $expire );
}
if ( $expire >= strtotime( $today ) ) {
echo esc_html( gmdate( $expireDateFormatFun, $expire ) );
} elseif ( $expire < strtotime( $today ) ) {
echo esc_html__( 'Expired', 'affcoupon' );
}
} else {
echo esc_html__( "Doesn't Expire", 'affcoupon' );
}
break;
}
/**
* Filtering the coupon list column information.
*
* @since 1.0
*/
if ( has_filter( 'wpaf_filter_column_cases' ) ) {
/**
* This filters the admin coupon list columns information
* for custom coupon post type.
*
* @since 1.0
*
* @param string $column data to display in the admin columns.
* @param int $post_id id of the custom coupon post.
*
*/
apply_filters( 'wpaf_filter_column_cases', $column, $post_id );
apply_filters( 'wpaf_filter_column_cases', $column, $post_id );
}
}
/**
* This will make custom column sortable.
*
* @since 1.0
*
* @param array $columns array of the custom columns.
*
* @return array $columns
*
*/
public static function wpaf_column_sortable( $columns ) {
/**
* Adding the custom fields to columns array.
*
* @since 1.0
*/
$columns['coupon_details_link'] = 'coupon_details_link';
$columns['coupon_details_coupon-code'] = 'coupon_details_coupon-code';
$columns['coupon_type'] = 'coupon_details_coupon-type';
$columns['coupon_expire'] = 'coupon_details_expire-date';
/**
* Returning the columns array after adding the custom fields.
*
* @since 1.0
*/
return $columns;
}
/**
* Setting the columns sorting order.
*
* @param $query
*
* @since 1.0
*/
public static function setting_orderby( $query ) {
$orderby = $query->get( 'orderby' );
if ( 'coupon_details_coupon-type' == $orderby ) {
$query->set( 'meta_key', 'coupon_details_coupon-type' );
$query->set( 'orderby', 'meta_value' );
}
if ( 'coupon_details_coupon-code' == $orderby ) {
$query->set( 'meta_key', 'coupon_details_coupon-code-text' );
$query->set( 'orderby', 'meta_value' );
}
if ( 'coupon_details_link' == $orderby ) {
$query->set( 'meta_key', 'coupon_details_link' );
$query->set( 'orderby', 'meta_value' );
}
if ( 'coupon_details_expire-date' == $orderby ) {
$query->set( 'meta_key', 'coupon_details_expire-date' );
$query->set( 'orderby', 'meta_value' );
}
}
/**
* Custom coloumns for Coupon Category page.
*
* @param $columns
*
* @return array
* @since 1.0
*/
public static function wpaf_custom_taxonomy_columns( $columns ) {
$columns = array(
'cb' => '',
'name' => __( 'Name', 'affcoupon' ),
'slug' => __( 'Slug', 'affcoupon' ),
'posts' => __( 'Posts', 'affcoupon' ),
'wpaf_cat_shortcode' => __( 'Shortcode', 'affcoupon' )
);
return $columns;
}
/**
* Content for custom taxonomy columns.
*
* @param $content
* @param $column_name
* @param $term_id
*
* @return string
*
* @since 1.0
*/
public static function Wpaf_custom_taxonomy_columns_content( $content, $column_name, $term_id ) {
if ( 'wpaf_cat_id' == $column_name ) {
$content = $term_id;
}
if ( 'wpaf_cat_shortcode' == $column_name ) {
$content = '[affcoupon_loop cat=' . $term_id . ']';
}
return $content;
}
/**
* Custom coloumns for Coupon Vendor page.
*
* @param $columns
*
* @return array
* @since 1.0
*/
public static function wpaf_vendor_taxonomy_columns( $columns ) {
$columns = array(
'cb' => '',
'name' => __( 'Name', 'affcoupon' ),
'slug' => __( 'Slug', 'affcoupon' ),
'posts' => __( 'Posts', 'affcoupon' ),
'wpaf_vend_shortcode' => __( 'Shortcode', 'affcoupon' )
);
return $columns;
}
/**
* Content for vendor taxonomy columns.
*
* @param $content
* @param $column_name
* @param $term_id
*
* @return string
*
* @since 1.0
*/
public static function Wpaf_vendor_taxonomy_columns_content( $content, $column_name, $term_id ) {
if ( 'wpaf_vend_id' == $column_name ) {
$content = $term_id;
}
if ( 'wpaf_vend_shortcode' == $column_name ) {
$content = '[affcoupon_loop vend=' . $term_id . ']';
}
return $content;
}
}