Making WordPress.org

Opened 6 years ago

Closed 6 years ago

#3572 closed enhancement (fixed)

Allow users to edit their own notes

Reported by: keesiemeijer's profile keesiemeijer Owned by: coffee2code's profile coffee2code
Milestone: Priority: normal
Component: Developer Hub Keywords: has-patch has-screenshots
Cc:

Description

Users should be able to edit their own user contributed notes.
See this comment

The patch adds the ability for users to edit their own contributed notes.

Users can only edit a note if it's awaiting moderation. The endpoint reference/comment/edit/{comment_ID} is created for users to edit their notes in the front end of the site. You're redirected to the home page (from this endpoint) if the note doesn't exist, or you don't have the right edit permissions. A new template comments-edit.php is used for the edit note form.

This patch also adds the following rules to the feedback form (similar to the note form).

  • This form is not for support requests, spam, bug reports, complaints, or self-promotion. Entries of this nature will be deleted.
  • NOTE: All contributions are licensed under GFDL and are moderated before appearing on the site.

Related: #1504

Attachments (11)

3572.patch (117.2 KB) - added by keesiemeijer 6 years ago.
Add ability for user to edit their own user contibuted notes
3572.png (79.5 KB) - added by keesiemeijer 6 years ago.
Screenshot of edit note form
3572.2.patch (123.7 KB) - added by keesiemeijer 6 years ago.
Improvements
3572.3.patch (45.5 KB) - added by keesiemeijer 6 years ago.
3572.4.png (84.5 KB) - added by keesiemeijer 6 years ago.
Updated screenshot of the edit note template
3572.5.png (61.2 KB) - added by keesiemeijer 6 years ago.
Screenshot of edited note notice
3572.6.patch (47.5 KB) - added by keesiemeijer 6 years ago.
Add a new rule to the feedback form
3572.7.png (69.3 KB) - added by keesiemeijer 6 years ago.
Feedback form with new rule
3572.8.patch (49.1 KB) - added by keesiemeijer 6 years ago.
Don't allow empty comments when editing
3572.9.patch (57.6 KB) - added by keesiemeijer 6 years ago.
Redirect after a comment is edited
3572.10.patch (58.6 KB) - added by keesiemeijer 6 years ago.
Don't show edit notice if a comment wasn't updated

Download all attachments as: .zip

Change History (23)

@keesiemeijer
6 years ago

Add ability for user to edit their own user contibuted notes

@keesiemeijer
6 years ago

Screenshot of edit note form

#1 @keesiemeijer
6 years ago

  • Keywords has-screenshots added

#2 @netweb
6 years ago

#3339 was marked as a duplicate.

@keesiemeijer
6 years ago

Improvements

#3 @keesiemeijer
6 years ago

@netweb Thanks.

Patch 3572.2.patch adds the following improvements

  • Adds a nonce field to the edit comment form.
  • Verifies the nonce when updating a comment.
  • Adds a notice to the edited note.
  • Improves scrolling to notes for logged in users.

#4 @netweb
6 years ago

  • Keywords needs-refresh added

FYI, there's some unrelated changes in 3572.2.patch, there should be no changes to the package.json file, and also don't include the package-lock.json file in the patch.

@keesiemeijer
6 years ago

#5 @keesiemeijer
6 years ago

  • Keywords needs-refresh removed

In patch 3572.3.patch the package.json file is restored and package-lock.json is removed.

Thanks @netweb, I wasn't sure if I should include the package-lock.json file or not.

It also adds the following improvements.

  • Display the 404 template if the global post data or comment is not found in the edit template (comments-edit.php).
  • Include links to the note and note author in the description of the edit template.
  • Add breadcrumb trail items to the reference and post type archive.

@keesiemeijer
6 years ago

Updated screenshot of the edit note template

@keesiemeijer
6 years ago

Screenshot of edited note notice

#6 @netweb
6 years ago

Thanks @keesiemeijer, I'll leave the rest of the code review to @coffee2code and @drew who are more familiar with teh DevHub codebase

@keesiemeijer
6 years ago

Add a new rule to the feedback form

#7 @keesiemeijer
6 years ago

Patch 3572.6.patch adds a new rule to the note feedback form.

Many users are using the note feedback form to ask (support) questions and are not really adding to the documentation.

That's why I added this new rule.

  • Feedback is part of the documentation. Use this form to report errors or to add additional information to this note.

When editing a note a link to to the note you're replying to is added to the rule.

  • Feedback is part of the documentation. Use this form to report errors or to add additional information to note 22 by admin.

A screenshot is following.

@keesiemeijer
6 years ago

Feedback form with new rule

@keesiemeijer
6 years ago

Don't allow empty comments when editing

#8 @keesiemeijer
6 years ago

Patch 3572.8.patch displays an error and a way back to the edit form if a comment is empty after editing.

Other improvements:

  • Add extra checks (post_id, post_type) before updating a comment.
  • Use htmlspecialchars_decode() for comment content when editing a top level comment.

Just to recap, this patch:

  • Allows users to edit their own top level comments and child (feedback) comments
  • Adds a new rewrite rule and theme template file for editing comments
  • Adds comment rules (guidelines) to the feedback form
  • Improves scrolling to notes (adjusting for the admin bar)
  • Works with Javascript disabled
Last edited 6 years ago by keesiemeijer (previous) (diff)

@keesiemeijer
6 years ago

Redirect after a comment is edited

#9 @keesiemeijer
6 years ago

With patch 3572.9.patch you're redirected to the edited comment after a comment is updated.
This matches what happens after a new comment is created.

@keesiemeijer
6 years ago

Don't show edit notice if a comment wasn't updated

#10 @keesiemeijer
6 years ago

Patch 3572.10.patch removes the edit notice if a comment wasn't updated after editing. Comments are now updated on the init hook with priority 20. This ensures the theme (or the WP Parser) have registered the parsed post types needed to check if a the current user can edit a comment.

Sorry for the many patches. This was a work in progress that (I think) is now stable for commit.

This ticket was mentioned in Slack in #docs by coffee2code. View the logs.


6 years ago

#12 @coffee2code
6 years ago

  • Owner set to coffee2code
  • Resolution set to fixed
  • Status changed from new to closed

In 7754:

developer.wordpress.org: Allow users to edit their own submitted notes that are still in moderation.

Props keesiemeijer.
Fixes #3572.

Note: See TracTickets for help on using tickets.