| 1 |
<?php |
| 2 |
/** |
| 3 |
* Renders the Campaign Creator metabox. |
| 4 |
* |
| 5 |
* @author David Bisset |
| 6 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 7 |
* @package Charitable/Admin Views/Metaboxes |
| 8 |
* @since 1.2.0 |
| 9 |
* @version 1.6.45 |
| 10 |
*/ |
| 11 |
|
| 12 |
global $post, $wpdb; |
| 13 |
|
| 14 |
/* If no post_author is set yet, WP returns 1, but we need to know if no creator is set. */ |
| 15 |
$creator_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_author FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post->ID ) ); |
| 16 |
$campaign = new Charitable_Campaign( $post ); |
| 17 |
$authors = get_users( |
| 18 |
[ |
| 19 |
'orderby' => 'display_name', |
| 20 |
'fields' => [ 'ID', 'display_name' ], |
| 21 |
] |
| 22 |
); |
| 23 |
|
| 24 |
?> |
| 25 |
<div id="charitable-campaign-creator-metabox-wrap" class="charitable-metabox-wrap"> |
| 26 |
<?php |
| 27 |
if ( $creator_id ) : |
| 28 |
$creator = new Charitable_User( $creator_id ); |
| 29 |
?> |
| 30 |
<div id="campaign-creator" class="charitable-media-block"> |
| 31 |
<div class="creator-avatar charitable-media-image"> |
| 32 |
<?php echo $creator->get_avatar(); ?> |
| 33 |
</div><!--.creator-avatar--> |
| 34 |
<div class="creator-facts charitable-media-body"> |
| 35 |
<h3 class="creator-name"><a href="<?php echo admin_url( 'user-edit.php?user_id=' . $creator->ID ); ?>"><?php printf( '%s (%s %d)', $creator->display_name, __( 'User ID', 'charitable-ambassadors' ), $creator->ID ); ?></a></h3> |
| 36 |
<p><?php printf( '%s %s', _x( 'Joined on', 'joined on date', 'charitable-ambassadors' ), date_i18n( 'F Y', strtotime( $creator->user_registered ) ) ); ?></p> |
| 37 |
<ul> |
| 38 |
<li><a href="<?php echo get_author_posts_url( $creator->ID ); ?>"><?php _e( 'Public Profile', 'charitable-ambassadors' ); ?></a></li> |
| 39 |
<li><a href="<?php echo admin_url( 'user-edit.php?user_id=' . $creator->ID ); ?>"><?php _e( 'Edit Profile', 'charitable' ); ?></a></li> |
| 40 |
</ul> |
| 41 |
</div><!--.creator-facts--> |
| 42 |
</div><!--#campaign-creator--> |
| 43 |
<?php endif; ?> |
| 44 |
<div id="charitable-post-author-wrap" class="charitable-metabox charitable-select-wrap"> |
| 45 |
<label for="post_author_override"><?php _e( 'Change the campaign creator' ); ?></label> |
| 46 |
<select name="post_author_override"> |
| 47 |
<option value="-" <?php selected( $creator_id, 0 ); ?>><?php _e( 'Select a user', 'charitable' ); ?></option> |
| 48 |
<?php foreach ( $authors as $author ) : ?> |
| 49 |
<option value="<?php echo esc_attr( $author->ID ); ?>" <?php selected( $creator_id, $author->ID ); ?>><?php echo $author->display_name; ?></option> |
| 50 |
<?php endforeach; ?> |
| 51 |
</select> |
| 52 |
</div> |
| 53 |
</div><!--#charitable-campaign-description-metabox-wrap--> |
| 54 |
|