Making WordPress.org


Ignore:
Timestamp:
01/10/2018 06:04:22 PM (9 years ago)
Author:
obenland
Message:

Plugins: Display a date with internal notes.

Fixes #3001.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-internal-notes.php

    r6287 r6337  
    3939                wp_comment_trashnotice();
    4040        }
     41
     42        /**
     43         * Ajax handler for getting notes.
     44         *
     45         * @global int $post_id
     46         *
     47         * @param string $action Action to perform.
     48         */
     49        function get_notes( $action ) {
     50                global $post_id;
     51                if ( empty( $action ) ) {
     52                        $action = 'get-comments';
     53                }
     54                check_ajax_referer( $action );
     55
     56                if ( empty( $post_id ) && ! empty( $_REQUEST['p'] ) ) {
     57                        $id = absint( $_REQUEST['p'] );
     58                        if ( ! empty( $id ) ) {
     59                                $post_id = $id;
     60                        }
     61                }
     62
     63                if ( empty( $post_id ) ) {
     64                        wp_die( -1 );
     65                }
     66                $wp_list_table = new Plugin_Comments( [
     67                        'screen' => convert_to_screen( [ 'screen' => 'edit-comments' ] ),
     68                ] );
     69
     70                if ( ! current_user_can( 'edit_post', $post_id ) ) {
     71                        wp_die( -1 );
     72                }
     73
     74                $wp_list_table->prepare_items();
     75
     76                if ( ! $wp_list_table->has_items() ) {
     77                        wp_die( 1 );
     78                }
     79
     80                $x = new \WP_Ajax_Response();
     81                ob_start();
     82                foreach ( $wp_list_table->items as $comment ) {
     83                        if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && 0 === $comment->comment_approved ) {
     84                                continue;
     85                        }
     86                        get_comment( $comment );
     87                        $wp_list_table->single_row( $comment );
     88                }
     89                $comment_list_item = ob_get_clean();
     90
     91                $x->add( [
     92                        'what' => 'comments',
     93                        'data' => $comment_list_item,
     94                ] );
     95                $x->send();
     96        }
    4197}
Note: See TracChangeset for help on using the changeset viewer.