Make WordPress Core

Changeset 61199


Ignore:
Timestamp:
11/10/2025 10:49:33 PM (6 weeks ago)
Author:
adamsilverstein
Message:

Notes: refine post author notifications.

Code maintenance follow up to r61179. Move wp_new_comment_via_rest_notify_postauthor callback from REST API Comments controller to comment.php. Add default to wp_notes_notify for multisite compatibility.

Props adamsilverstein, justlevine, mukesh27, mamaduka, peterwilsoncc, desros.
See #64204.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/schema.php

    r61179 r61199  
    564564        // 6.9.0
    565565        'wp_notes_notify'                 => 1,
    566 
    567566    );
    568567
  • trunk/src/wp-admin/options-discussion.php

    r61179 r61199  
    163163<br />
    164164<label for="wp_notes_notify">
    165 <input name="wp_notes_notify" type="checkbox" id="wp_notes_notify" value="1" <?php checked( '1', get_option( 'wp_notes_notify' ) ); ?> />
     165<input name="wp_notes_notify" type="checkbox" id="wp_notes_notify" value="1" <?php checked( '1', get_option( 'wp_notes_notify', 1 ) ); ?> />
    166166<?php _e( 'Anyone posts a note' ); ?> </label>
    167167
  • trunk/src/wp-includes/comment.php

    r61179 r61199  
    24282428    $is_note = ( $comment && 'note' === $comment->comment_type );
    24292429
    2430     $maybe_notify = $is_note ? get_option( 'wp_notes_notify' ) : get_option( 'comments_notify' );
     2430    $maybe_notify = $is_note ? get_option( 'wp_notes_notify', 1 ) : get_option( 'comments_notify' );
    24312431
    24322432    /**
     
    24572457
    24582458    return wp_notify_postauthor( $comment_id );
     2459}
     2460
     2461/**
     2462 * Send a notification to the post author when a new note is added via the REST API.
     2463 *
     2464 * @since 6.9.0
     2465 *
     2466 * @param WP_Comment $comment The comment object.
     2467 */
     2468function wp_new_comment_via_rest_notify_postauthor( $comment ) {
     2469    if ( $comment instanceof WP_Comment && 'note' === $comment->comment_type ) {
     2470        wp_new_comment_notify_postauthor( (int) $comment->comment_ID );
     2471    }
    24592472}
    24602473
  • trunk/src/wp-includes/default-filters.php

    r61179 r61199  
    523523add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
    524524add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
    525 add_action( 'rest_insert_comment', array( 'WP_REST_Comments_Controller', 'wp_new_comment_via_rest_notify_postauthor' ) );
     525add_action( 'rest_insert_comment', 'wp_new_comment_via_rest_notify_postauthor' );
    526526add_action( 'after_password_reset', 'wp_password_change_notification' );
    527527add_action( 'register_new_user', 'wp_send_new_user_notifications' );
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    r61179 r61199  
    3737    }
    3838
    39     /**
    40      * Send a notification to the post author when a new note is added via the REST API.
    41      *
    42      * @since 6.9.0
    43      *
    44      * @param WP_Comment $comment The comment object.
    45      */
    46     public static function wp_new_comment_via_rest_notify_postauthor( $comment ) {
    47         if ( 'note' === $comment->comment_type ) {
    48             wp_new_comment_notify_postauthor( $comment->comment_ID );
    49         }
    50     }
    5139    /**
    5240     * Registers the routes for comments.
Note: See TracChangeset for help on using the changeset viewer.