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