Making WordPress.org

Changeset 6337


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

Plugins: Display a date with internal notes.

Fixes #3001.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
4 edited

Legend:

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

    r6287 r6337  
    5353                add_filter( 'postbox_classes_plugin_plugin-committers', array( __NAMESPACE__ . '\Metabox\Committers', 'postbox_classes' ) );
    5454                add_filter( 'postbox_classes_plugin_plugin-support-reps', array( __NAMESPACE__ . '\Metabox\Support_Reps', 'postbox_classes' ) );
     55                add_filter( 'wp_ajax_get-notes', array( __NAMESPACE__ . '\Metabox\Internal_Notes', 'get_notes' ) );
    5556                add_filter( 'wp_ajax_add-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'add_committer' ) );
    5657                add_filter( 'wp_ajax_delete-committer', array( __NAMESPACE__ . '\Metabox\Committers', 'remove_committer' ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-comments.php

    r6287 r6337  
    4242                <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" data-comment-type="<?php echo esc_attr( $this->comment_type ); ?>" style="display:none;">
    4343                        <colgroup>
     44                                <col width="15%">
     45                                <col width="65%">
    4446                                <col width="20%">
    45                                 <col width="80%">
    4647                        </colgroup>
    4748                        <tbody id="the-comment-list"<?php if ( $singular ) { echo " data-wp-lists='list:$singular'"; } ?>>
    … …  
    5556        <?php
    5657        }
     58
     59        /**
     60         * @return array
     61         */
     62        protected function get_column_info() {
     63                return [
     64                        [
     65                                'author'  => __( 'Author' ),
     66                                'comment' => _x( 'Comment', 'column name' ),
     67                                'date'    => __( 'Date' ),
     68                        ],
     69                        [],
     70                        [],
     71                        'comment',
     72                ];
     73        }
    5774}
  • 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}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js

    r5867 r6337  
    7070                                };
    7171
    72                         wp.ajax.post( 'get-comments', data ).always( function( response ) {
     72                        wp.ajax.post( 'get-notes', data ).always( function( response ) {
    7373                                response = wpAjax.parseAjaxResponse( response );
    7474
Note: See TracChangeset for help on using the changeset viewer.