Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avatar functionality to membership card #56

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pmpro-membership-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ function pmpro_membership_card_shortcode($atts, $content=null, $code="")
extract(shortcode_atts(array(
'print_size' => 'all',
'qr_code' => 'false',
'qr_data' => 'ID' // Accepts ID, email and level
'qr_data' => 'ID', // Accepts ID, email and level
'show_avatar' => 'false'
), $atts));

$print_sizes = explode(",", $print_size);
Expand Down
62 changes: 60 additions & 2 deletions templates/membership-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
else
$print_large = false;


if ( $show_avatar === 'false' ) {
$show_avatar = false;
} else {
$show_avatar = true;
}
?>
<style>
/* Hide any thumbnail that might be on the page. */
Expand Down Expand Up @@ -208,6 +212,24 @@
<div class="pmpro_membership_card-print pmpro_membership_card-print-sm"<?php if(empty($print_small)) { ?> style="display: none;"<?php } ?>>
<div class="pmpro_membership_card-inner <?php do_action( 'pmpro_membership_card-extra_classes', $pmpro_membership_card_user, $print_sizes, $qr_code, $qr_data ); ?>">
<div class="pmpro_membership_card-data">
<?php
if ( function_exists( 'get_avatar' ) && $show_avatar !== false ) {
$avatar_args = apply_filters( 'pmpro_membership_card_avatar_args',
array(
'size' => 150,
'default' => 'wavatar',
'alt' => pmpro_membership_card_return_user_name( $pmpro_membership_card_user ) . ' avatar',
'args' => array(
'class' => 'pmpro_membership_card_avatar'
)
)
);
$avatar = get_avatar( $pmpro_membership_card_user->ID, $avatar_args['size'], $avatar_args['default'], $avatar_args['alt'], $avatar_args['args'] );
if( ! empty( $avatar ) ) {
?><div id="pmpro_membership_card_avatar"><?php echo $avatar; ?></div><?php
}
}
?>
<h1>
<?php
echo pmpro_membership_card_return_user_name( $pmpro_membership_card_user );
Expand Down Expand Up @@ -236,7 +258,7 @@
pmpro_membership_card_output_levels_for_user( $pmpro_membership_card_user );
?>
</p>
<p><strong><?php _e("Membership Expires", 'pmpro-membership-card');?>:</strong>
<p id="pmpro_membership_card_member_end_date"><strong><?php esc_html_e("Membership Expires", 'pmpro-membership-card');?>:</strong>
<?php
echo pmpro_membership_card_return_end_date( $pmpro_membership_card_user );
?>
Expand All @@ -253,6 +275,24 @@
<div class="pmpro_membership_card-print pmpro_membership_card-print-md">
<div class="pmpro_membership_card-inner <?php do_action( 'pmpro_membership_card-extra_classes', $pmpro_membership_card_user, $print_sizes, $qr_code, $qr_data ); ?>">
<div class="pmpro_membership_card-data">
<?php
if ( function_exists( 'get_avatar' ) && $show_avatar !== false ) {
$avatar_args = apply_filters( 'pmpro_membership_card_avatar_args',
array(
'size' => 150,
'default' => 'wavatar',
'alt' => pmpro_membership_card_return_user_name( $pmpro_membership_card_user ) . ' avatar',
'args' => array(
'class' => 'pmpro_membership_card_avatar'
)
)
);
$avatar = get_avatar( $pmpro_membership_card_user->ID, $avatar_args['size'], $avatar_args['default'], $avatar_args['alt'], $avatar_args['args'] );
if( ! empty( $avatar ) ) {
?><div id="pmpro_membership_card_avatar"><?php echo $avatar; ?></div><?php
}
}
?>
<h1>
<?php
echo pmpro_membership_card_return_user_name( $pmpro_membership_card_user );
Expand Down Expand Up @@ -299,6 +339,24 @@
<div class="pmpro_membership_card-print pmpro_membership_card-print-lg"<?php if(empty($print_large)) { ?> style="display: none;"<?php } ?>>
<div class="pmpro_membership_card-inner <?php do_action( 'pmpro_membership_card-extra_classes', $pmpro_membership_card_user, $print_sizes, $qr_code, $qr_data ); ?>">
<div class="pmpro_membership_card-data">
<?php
if ( function_exists( 'get_avatar' ) && $show_avatar !== false ) {
$avatar_args = apply_filters( 'pmpro_membership_card_avatar_args',
array(
'size' => 150,
'default' => 'wavatar',
'alt' => pmpro_membership_card_return_user_name( $pmpro_membership_card_user ) . ' avatar',
'args' => array(
'class' => 'pmpro_membership_card_avatar'
)
)
);
$avatar = get_avatar( $pmpro_membership_card_user->ID, $avatar_args['size'], $avatar_args['default'], $avatar_args['alt'], $avatar_args['args'] );
if( ! empty( $avatar ) ) {
?><div id="pmpro_membership_card_avatar"><?php echo $avatar; ?></div><?php
}
}
?>
<h1>
<?php
echo pmpro_membership_card_return_user_name( $pmpro_membership_card_user );
Expand Down