Changeset 14055
- Timestamp:
- 09/16/2024 08:34:15 PM (5 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/moderation.php
r13786 r14055 391 391 // Check for moderator's note to user. 392 392 $mod_note = ''; 393 $mod_note_to_user = Rejection::get_moderator_note_to_user( $post );393 $mod_note_to_user = Rejection::get_moderator_note_to_user( $post, 'publish' ); 394 394 if ( $mod_note_to_user ) { 395 395 $mod_note = "\n" . __( 'Message from the moderator:', 'wporg-photos' ) . "\n{$mod_note_to_user}\n"; … … 475 475 476 476 // Check for moderator's note to user. 477 $mod_note = Rejection::get_moderator_note_to_user( $post );477 $mod_note = Rejection::get_moderator_note_to_user( $post, 'reject' ); 478 478 if ( $mod_note ) { 479 479 $rejection_message .= "\n" . __( 'Message from the moderator:', 'wporg-photos' ) . "\n" . $mod_note . "\n"; … … 548 548 549 549 // Check for moderator's note to user. 550 $mod_note = Rejection::get_moderator_note_to_user( $post );550 $mod_note = Rejection::get_moderator_note_to_user( $post, 'reject' ); 551 551 if ( $mod_note ) { 552 552 $rejection_message .= "\n" . __( 'Message from the moderator:', 'wporg-photos' ) . "\n" . $mod_note . "\n"; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/rejection.php
r14051 r14055 208 208 'input_in_metabox' => true, 209 209 'meta_config' => [ 210 'description' => __( 'A message sent to the user by the moderator within the approval/rejection email.', 'wporg-photos' ), 210 'description' => __( 'A message sent to the user by the moderator within the rejection email.', 'wporg-photos' ), 211 ], 212 ], 213 'moderator_note_to_user_on_publish' => [ 214 'input_in_metabox' => true, 215 'meta_config' => [ 216 'description' => __( 'A message sent to the user by the moderator within the approval email.', 'wporg-photos' ), 211 217 ], 212 218 ], … … 366 372 * Returns the note the moderator has for the user. 367 373 * 368 * @param int|WP_Post The post or post ID. 374 * There are two types of notes to user: 375 * - 'publish': A note sent to the user when a photo is published. 376 * - 'reject': A note sent to the user when a photo is rejected. 377 * 378 * It is possible for both types of notes to apply to a photo. However, it currently does not make sense 379 * for two separate notes of a given type to be possible, nor does the implementation support it. 380 * 381 * @param int|WP_Post $post The post or post ID. 382 * @param string $type The note type. Either 'reject' or 'publish'. Default 'reject'. 369 383 * @return string 370 384 */ 371 public static function get_moderator_note_to_user( $post ) {385 public static function get_moderator_note_to_user( $post, $type = 'reject' ) { 372 386 $post = get_post( $post ); 373 387 … … 376 390 } 377 391 378 return get_post_meta( $post->ID, 'moderator_note_to_user', true ); 392 $meta_key = ( 'publish' === $type ) ? 'moderator_note_to_user_on_publish' : 'moderator_note_to_user'; 393 394 return get_post_meta( $post->ID, $meta_key, true ); 379 395 } 380 396 … … 382 398 * Returns the private note left by the moderator. 383 399 * 384 * @param int|WP_Post The post or post ID.400 * @param int|WP_Post $post The post or post ID. 385 401 * @return string 386 402 */ … … 847 863 // Reject button should be disabled if no rejection reason is selected. 848 864 document.querySelector('#reject-post').disabled = !hasRejectReason; 865 // Rejection note to user should be disabled if no rejection reason is selected. 866 const inputRejectNoteToUser = document.querySelector('#moderator_note_to_user'); 867 if ( inputRejectNoteToUser ) { 868 inputRejectNoteToUser.disabled = !hasRejectReason || rejectSelect.disabled; 869 const rejectNoteToUser = document.querySelector('.moderator_note_to_user'); 870 // Potentially hide the note input based on whether the dropdown has a value. 871 rejectNoteToUser.style.display = !hasRejectReason ? 'none' : 'block'; 872 // If choosing to not reject photo, then delete the rejection note content to avoid it being saved. 873 if ( !hasRejectReason ) { 874 inputRejectNoteToUser.value = ''; 875 } 876 } 877 878 // Handling for the note-to-user fields for a pending photo (to facilitate only showing one at a time). 879 const pendingPublishNoteToUser = document.querySelector('.pending_moderator_note_to_user.moderator_note_to_user_on_publish'); 880 const pendingRejectNoteToUser = document.querySelector('.pending_moderator_note_to_user.moderator_note_to_user'); 881 if ( pendingPublishNoteToUser && pendingRejectNoteToUser ) { 882 // Hide one of the note-to-user fields if awaiting initial moderation. 883 pendingPublishNoteToUser.style.display = ( hasRejectReason ? 'none' : 'block' ); 884 pendingRejectNoteToUser.style.display = ( hasRejectReason ? 'block' : 'none' ); 885 886 // When a note field gets hidden, transfer note field value to other note then clear it out. 887 if ( 'none' === pendingPublishNoteToUser.style.display ) { 888 const pendingPublishNote = pendingPublishNoteToUser.querySelector('textarea').value; 889 // Transfer value from approval note to rejection note if it had a value. 890 if ( pendingPublishNote ) { 891 pendingRejectNoteToUser.querySelector('textarea').value = pendingPublishNote; 892 } 893 pendingPublishNoteToUser.querySelector('textarea').value = ''; 894 } else { 895 const pendingRejectNote = pendingRejectNoteToUser.querySelector('textarea').value; 896 // Transfer value from rejection note to approval note if it had a value. 897 if ( pendingRejectNote ) { 898 pendingPublishNoteToUser.querySelector('textarea').value = pendingRejectNote; 899 } 900 pendingRejectNoteToUser.querySelector('textarea').value = ''; 901 } 902 } 903 849 904 // Notice of rejection of published post should be shown if post is published. 850 905 const rejectPublishWarn = document.querySelector('.reject-warn-if-about-to-reject-published'); … … 904 959 echo '<div class="reject-additional-fields">'; 905 960 961 // Assign a class only if the post is currently in a pending state. 962 $note_to_user_label_class = ( $is_disabled ? '' : ' pending_moderator_note_to_user' ); 963 906 964 // Markup for optional note to send to user in rejection email. 907 echo '<label for="moderator_note_to_user" >' . __( '(Optional) Note to user:', 'wporg-photos' );908 echo '<p class="description"><em>' . __( 'Included in approval/rejection email.', 'wporg-photos' ) . '</em></p>';965 echo '<label for="moderator_note_to_user" class="moderator_note_to_user' . esc_attr( $note_to_user_label_class ) . '">' . __( '(Optional) Note to user on rejection:', 'wporg-photos' ); 966 echo '<p class="description"><em>' . __( 'Included in rejection email.', 'wporg-photos' ) . '</em></p>'; 909 967 echo '<textarea id="moderator_note_to_user" name="moderator_note_to_user" rows="4"' . disabled( true, $is_disabled, false ) . '>'; 910 echo esc_textarea( self::get_moderator_note_to_user( $post ) ); 968 echo esc_textarea( self::get_moderator_note_to_user( $post, 'reject' ) ); 969 echo '</textarea>'; 970 echo '</label>'; 971 972 // Markup for optional note sent to user in approval email. 973 echo '<label for="moderator_note_to_user_on_publish" class="moderator_note_to_user_on_publish' . esc_attr( $note_to_user_label_class ) . '">' . __( '(Optional) Note to user on approval:', 'wporg-photos' ); 974 echo '<p class="description"><em>' . __( 'Included in approval email.', 'wporg-photos' ) . '</em></p>'; 975 echo '<textarea id="moderator_note_to_user_on_publish" name="moderator_note_to_user_on_publish" rows="4"' . disabled( true, $is_disabled, false ) . '>'; 976 echo esc_textarea( self::get_moderator_note_to_user( $post, 'publish' ) ); 911 977 echo '</textarea>'; 912 978 echo '</label>'; … … 1075 1141 echo self::get_rejection_reason( $post_id ); 1076 1142 // Add asterisk to denote there was a moderator note to user. 1077 if ( self::get_moderator_note_to_user( $post_id ) ) {1143 if ( self::get_moderator_note_to_user( $post_id, 'reject' ) || self::get_moderator_note_to_user( $post_id, 'publish' ) ) { 1078 1144 echo '*'; 1079 1145 }
Note: See TracChangeset
for help on using the changeset viewer.