WordPress.org

Making WordPress.org

Changeset 5308


Ignore:
Timestamp:
04/10/2017 08:00:18 PM (5 years ago)
Author:
ocean90
Message:

Plugin Directory: Link internal notes to the edit post screen.

Fixes #2667.

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

Legend:

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

    r5271 r5308  
    4040        add_action( 'wp_ajax_replyto-comment', array( $this, 'save_custom_comment' ), 0 );
    4141        add_filter( 'comment_row_actions', array( $this, 'custom_comment_row_actions' ), 10, 2 );
     42        add_filter( 'get_comment_link', array( $this, 'link_internal_notes_to_admin' ), 10, 2 );
    4243
    4344        // Admin Metaboxes
     
    109110                case 'post.php':
    110111                    wp_enqueue_style( 'plugin-admin-post-css', plugins_url( 'css/edit-form.css', Plugin_Directory\PLUGIN_FILE ), array( 'edit' ), 4 );
    111                     wp_enqueue_script( 'plugin-admin-post-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util', 'wp-lists' ), 1 );
     112                    wp_enqueue_script( 'plugin-admin-post-js', plugins_url( 'js/edit-form.js', Plugin_Directory\PLUGIN_FILE ), array( 'wp-util', 'wp-lists' ), 2 );
    112113                    wp_localize_script( 'plugin-admin-post-js', 'pluginDirectory', array(
    113114                        'removeCommitterAYS' => __( 'Are you sure you want to remove this committer?', 'wporg-plugins' ),
     
    411412
    412413        return $actions;
     414    }
     415
     416    /**
     417     * Changes the permalink for internal notes to link to the edit post screen.
     418     *
     419     * @param string $link The comment permalink with '#comment-$id' appended.
     420     * @param \WP_Comment $comment The current comment object.
     421     * @return string The permalink to the given comment.
     422     */
     423    public function link_internal_notes_to_admin( $link, $comment ) {
     424        if ( 'internal-note' === $comment->comment_type ) {
     425            $link = get_edit_post_link( $comment->comment_post_ID );
     426            $link = $link . '#comment-' . $comment->comment_ID;
     427        }
     428
     429        return $link;
    413430    }
    414431
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js

    r4223 r5308  
    9999
    100100                    $( 'a[className*=\':\']' ).unbind();
     101
     102                    if ( 0 === location.hash.indexOf( '#comment-' ) ) {
     103                        $( document.body ).animate( { scrollTop: $( location.hash ).offset().top - 100 }, 100 );
     104                    }
    101105                }
    102106            } );
Note: See TracChangeset for help on using the changeset viewer.