Applies wc_get_order_notes() on admin
This commit is contained in:
parent
1b93282245
commit
97f9dab0ce
|
@ -586,26 +586,19 @@ class WC_Admin_Post_Types {
|
|||
|
||||
if ( $post->comment_count ) {
|
||||
|
||||
// check the status of the post
|
||||
$status = ( 'trash' !== $post->post_status ) ? '' : 'post-trashed';
|
||||
|
||||
remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
|
||||
|
||||
$latest_notes = get_comments( array(
|
||||
'post_id' => $post->ID,
|
||||
'number' => 1,
|
||||
'status' => $status,
|
||||
$latest_notes = wc_get_order_notes( array(
|
||||
'order_id' => $post->ID,
|
||||
'limit' => 1,
|
||||
'orderby' => 'date_created_gmt',
|
||||
) );
|
||||
|
||||
add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
|
||||
|
||||
$latest_note = current( $latest_notes );
|
||||
|
||||
if ( isset( $latest_note->comment_content ) && 1 == $post->comment_count ) {
|
||||
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->comment_content ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
||||
} elseif ( isset( $latest_note->comment_content ) ) {
|
||||
if ( isset( $latest_note->content ) && 1 == $post->comment_count ) {
|
||||
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->content ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
||||
} elseif ( isset( $latest_note->content ) ) {
|
||||
/* translators: %d: notes count */
|
||||
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->comment_content . '<br/><small style="display:block">' . sprintf( _n( 'plus %d other note', 'plus %d other notes', ( $post->comment_count - 1 ), 'woocommerce' ), $post->comment_count - 1 ) . '</small>' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
||||
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( $latest_note->content . '<br/><small style="display:block">' . sprintf( _n( 'Plus %d other note', 'Plus %d other notes', ( $post->comment_count - 1 ), 'woocommerce' ), $post->comment_count - 1 ) . '</small>' ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
||||
} else {
|
||||
/* translators: %d: notes count */
|
||||
echo '<span class="note-on tips" data-tip="' . wc_sanitize_tooltip( sprintf( _n( '%d note', '%d notes', $post->comment_count, 'woocommerce' ), $post->comment_count ) ) . '">' . __( 'Yes', 'woocommerce' ) . '</span>';
|
||||
|
|
|
@ -26,18 +26,10 @@ class WC_Meta_Box_Order_Notes {
|
|||
global $post;
|
||||
|
||||
$args = array(
|
||||
'post_id' => $post->ID,
|
||||
'orderby' => 'comment_ID',
|
||||
'order' => 'DESC',
|
||||
'approve' => 'approve',
|
||||
'type' => 'order_note',
|
||||
'order_id' => $post->ID,
|
||||
);
|
||||
|
||||
remove_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
|
||||
|
||||
$notes = get_comments( $args );
|
||||
|
||||
add_filter( 'comments_clauses', array( 'WC_Comments', 'exclude_order_comments' ), 10, 1 );
|
||||
$notes = wc_get_order_notes( $args );
|
||||
|
||||
echo '<ul class="order_notes">';
|
||||
|
||||
|
@ -46,20 +38,20 @@ class WC_Meta_Box_Order_Notes {
|
|||
foreach ( $notes as $note ) {
|
||||
|
||||
$note_classes = array( 'note' );
|
||||
$note_classes[] = get_comment_meta( $note->comment_ID, 'is_customer_note', true ) ? 'customer-note' : '';
|
||||
$note_classes[] = ( __( 'WooCommerce', 'woocommerce' ) === $note->comment_author ) ? 'system-note' : '';
|
||||
$note_classes[] = $note->customer_note ? 'customer-note' : '';
|
||||
$note_classes[] = 'system' === $note->added_by ? 'system-note' : '';
|
||||
$note_classes = apply_filters( 'woocommerce_order_note_class', array_filter( $note_classes ), $note );
|
||||
?>
|
||||
<li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( implode( ' ', $note_classes ) ); ?>">
|
||||
<li rel="<?php echo absint( $note->id ); ?>" class="<?php echo esc_attr( implode( ' ', $note_classes ) ); ?>">
|
||||
<div class="note_content">
|
||||
<?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
|
||||
<?php echo wpautop( wptexturize( wp_kses_post( $note->content ) ) ); ?>
|
||||
</div>
|
||||
<p class="meta">
|
||||
<abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), date_i18n( wc_date_format(), strtotime( $note->comment_date ) ), date_i18n( wc_time_format(), strtotime( $note->comment_date ) ) ); ?></abbr>
|
||||
<abbr class="exact-date" title="<?php echo $note->date_created->date( 'y-m-d h:i:s' ); ?>"><?php printf( __( 'added on %1$s at %2$s', 'woocommerce' ), $note->date_created->date_i18n( wc_date_format() ), $note->date_created->date_i18n( wc_time_format() ) ); ?></abbr>
|
||||
<?php
|
||||
if ( __( 'WooCommerce', 'woocommerce' ) !== $note->comment_author ) :
|
||||
if ( 'system' !== $note->added_by ) :
|
||||
/* translators: %s: note author */
|
||||
printf( ' ' . __( 'by %s', 'woocommerce' ), $note->comment_author );
|
||||
printf( ' ' . __( 'by %s', 'woocommerce' ), $note->added_by );
|
||||
endif;
|
||||
?>
|
||||
<a href="#" class="delete_note" role="button"><?php _e( 'Delete note', 'woocommerce' ); ?></a>
|
||||
|
|
Loading…
Reference in New Issue