Comment “allowed” checks in WordPress 4.7

In WP 4.4, comment submission was abstracted so that most of the logic was run in a function that returned a value, rather than inline in wp-comments-post.php. See #34059 for background. This overhaul was incomplete: the process of checking for comment floods and duplicate comments – wp_allow_comment() and friends – contained direct calls to die() and wp_die(), making it impossible to use the results of a failed comment check in the context of unit tests, the REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/., or other clients. See #36901. [38778] introduced an optional parameter for wp_allow_comment() and related functions that lets the caller decide whether to preserve the default behavior (wp_die()) or, instead, to return WP_Error objects in the case of failed comment checks.

There is a small backward-incompatible change in [38778]. Historically [5947] it’s been possible to unhook the default comment flood check as follows:

remove_action( 'check_comment_flood', 'check_comment_flood_db', 10, 3 );

In order to maintain backward compatibility with this usage, while at the same time changing the comment flood check so that it returns a value, we’ve performed a trick: check_comment_flood_db() is still hooked in the same way, but is now a wrapper for an add_filter() call that hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. the actual comment flood checking function to the new 'wp_is_comment_flood' filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output..

The backward compatibility break is as follows. Calling check_comment_flood_db() directly, in isolation, will no longer do anything (except to register a filter callback). If you need to run WP’s default comment flood check manually, outside the context of wp_allow_comment(), use the new wp_check_comment_flood() function. I searched GitHubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/ and the wordpress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/ pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party repo and didn’t find a single instance check_comment_flood_db() being used this way in the wild – it’s hard to imagine a situation where it’d be done, given its previous reliance on wp_die() – but if you’ve done custom work related to comment floods, it’s worth double-checking your code before 4.7 is released.

#4-7, #comments, #dev-notes

Comments in 4.6 can now be cached by a persistent object cache

The ‘comment’ cache group was made non-persistent in [7986], to address the difficulty of reliable cache invalidation. This meant the comment cache values were only held for the current page load, and lost on reload or navigation. The comment APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. has improved since WordPress 2.6, and cache is king.

In WordPress 4.6 the ‘comment’ cache group has been removed from the list of non-persistent cache groups, see [37613]. When comments are added, modified, or deleted we properly invalidate out of date cache values. You can now cache with confidence.

If you have a pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party which modifies comment data directly please change them to make use of the various comment API functions or use clean_comment_cache().

Don’t miss out on this change. For more background on the change, see #36906.

#4-6, #comments, #dev-notes

Comments Bug Scrub Summary, 2016-05-09

The 90-minute bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. scrub took place in #coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress.-comments and ended in a 1 – 1 tie between @boonebgorges and @rachelbaker. You can read an archive of the bug scrub and discussion: https://wordpress.slack.com/archives/core-comments/p1462820499000036.

Attendees:
@rachelbaker, @boonebgorges, @aaroncampbell, @ocean90, @samuelsidler, @sidati, @presskopp, and @dshanske

Bug Scrub:
#6342 – moved to “Future Release”
#16365 – moved to “Future Release”
#16576 – moved to “Future Release” and needs testing for backwards compatability
#17913 – needs a refresh and screenshots
#18762 – closed, after testing confirmed this was resolved in 4.4
#26596 – moved to “Future Release” to limit the scope of the JSJS JavaScript, a web scripting language typically executed in the browser. Often used for advanced user interfaces and behaviors. selector
#20302 – moved to “Future Release”, with suggestion from @boonebgorges
#20977 – moved to “Future Release”, but needs more input to determine how to approach

Open Floor:
#36427 – milestoned for 4.6, needs a refresh for the inline docsinline docs (phpdoc, docblock, xref)
#36564 – needs additional exploration before we can decide how to store the data/time of when a comment was last modified
#36424 – moved to “Future Release”, and requested a patchpatch A special text file that describes changes to code, by identifying the files and lines which are added, removed, and altered. It may also be referred to as a diff. A patch can be applied to a codebase for testing. refresh and screenshots
#36409@sidati is going to attempt writing the unit tests

#4-6, #comments

Comments Component Bug Scrub – May 9, 2016

A bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. scrub focused on open tickets in the Comments component will be held in the #core channel on SlackSlack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. at May 9, 2016 19:00 UTC.

Meeting Goals

  1. Give attention and feedback to the tickets gathering dust in the Awaiting Review milestone
  2. Reduce the number of tickets in the Awaiting Review milestone to 20 (currently at 37)
  3. Have an open floor for anyone to request feedback for any Comments component ticketticket Created for both bug reports and feature development on the bug tracker.

If you have a ticket you want included in the open floor feedback leave a comment below. I promise to “read the comments”.

#4-6, #bug-scrub, #comments

Comment Changes in WordPress 4.5

WordPress 4.5 includes several ancient bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. fixes and a few enhancements in the Comments component. We have closed 25 tickets. Check out the full list of changes.

Moderate Comment Screen Refresh

This often neglected screen has received a UXUX User experience update. Don’t know what the “Moderate Comment” screen is? This is where you land when clicking one of the moderation actions from a comment notification email message.

Changes of note:

  • Comment content is formatted for display, instead of one massive blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. of escaped text
  • Include navigation via a text link to the Edit Comment screen at the bottom of the comment
  • Updated message styles that match other screens
  • Only wrap the comment date in a link if the comment permalink exists to avoid confusion
  • Appended #wpbody-content to the comment email message links for accessibilityAccessibility Accessibility (commonly shortened to a11y) refers to the design of products, devices, services, or environments for people with disabilities. The concept of accessible design ensures both “direct access” (i.e. unassisted) and “indirect access” meaning compatibility with a person’s assistive technology (for example, computer screen readers). (https://en.wikipedia.org/wiki/Accessibility)

Before:
34133-before
After:
34133-after

See #34133

Max Lengths for Comment Form Fields

Be verbose without having to worry that your insightful words will be lost.

The comment form will now enforce the maximum length of each field’s respective database column with hardcoded maxlength attributes. The hardcoded maxlength attributes can be adjusted for custom database schemas by using the comment_form_default_fields filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output..

The default length settings are as follows:

  • Comment: 65525 characters
  • Name : 245 characters
  • Email: 100 characters
  • Url: 200 characters

Comments will also have the input lengths checked by the new function wp_get_comment_fields_max_lengths(), and accompanying filter wp_get_comment_fields_max_lengths, upon submission returning a WP_Error object if any value is longer than its database column.

See #10377.

Comment Error Page Navigation

Previously, visitors who submitted a comment that was unable to be processed were shown an error message without a method to navigate back to their comment. Your potential commenter would have to use their browser’s back button to get back to their comment to resolve the error.

A simple back link has been added to the bottom of the error message page. See the screenshots below.

Before:
4332-before

After:
4332-after

See #4332.

Other Changes of Note

  • The rel=nofollow attribute and value pair will no longer be added to relative or same domain links within comment_content. See #11360.
  • WP_Comment_Query now supports the author_url parameter. See #36224.
  • The new pre_wp_update_comment_count_now filter allows you to bail out of updating the comment count for a given Post. See #35060

#4-5, #comments, #dev-notes

Comment Object and Query Features in 4.4

Without comments, a website is as effective at creating a community as the Chicago Cubs are at winning World Series titles. WordPress 4.4 is a rebuilding release and the comments system is much improved under the hood.

This release lays the groundwork for future features and improvements.

A New Classy and Strong Comment Object

The new WP_Comment class provides a single organized comment object that models its row in $wpdb->comments. You may be familiar with this approach from WP_Post, which inspired the caching implementation used in WP_Comment.

This was a prerequisite to many of the other comment-related bugbug A bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority. fixes and features added in 4.4. The WP_Comment class is marked final to retain flexibility while it is young.

See #32619.

Comment Queries for the Whole Family

WP_Comment_Query has new query parameters for traversing your comments family tree.

  • parent__in takes an array of comment parent IDs to return all matching children.
  • parent__not_in takes an array of comment parent IDs and does not return any matching children.
  • hierarchical can be set to either threaded, flat, or false.
    • threaded returns a tree for matched comments, with the children for each comment included in its children property.
    • flat returns a flat array of matched comments plus their children.
    • false does not include descendants for matched comments. This is the default behavior.
  • orderby has a new option comment__in, useful when querying by comment__in the matched results will return in the same order.

See #8071 and #33882.

#4-4, #comments, #dev-notes

Changes to fields output by comment_form in WordPress 4.4

A change in WordPress that just landed in trunktrunk A directory in Subversion containing the latest development code in preparation for the next major release cycle. If you are running "trunk", then you are on the latest revision. is to move the comment textarea to the top for logged-out users when replying. This is done largely with the goal to improve keyboard/focus navigation, but also aims to make it easier for end users to leave comments on WordPress sites. The change necessitated some filters and actions now being run in a different order. It also means that the HTMLHTML HyperText Markup Language. The semantic scripting language primarily used for outputting content in web browsers. output by comment_form will now be different.

This is what the comment form looked like before

This is what the comment form looked like before

This is what the comment form looks like after.

If you use any of the hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. inside comment_form, but especially comment_form_field_comment and comment_form_after_fields, you are highly encouraged to test your code against the current WordPress nightly and report any issues on ticketticket Created for both bug reports and feature development on the bug tracker. #29974 so that any necessary adjustments can be made. Visual records and example code will help ensure everyone is satisfied with the final result.

#4-4, #comments, #dev-notes

Today in the Nightly: Site icons in the customizer, editor patterns, more accessible comment bubbles, row toggle focus styling

Install the nightly, and try out this fresh batch of shiny.

Site Icons in the CustomizerCustomizer Tool built into WordPress core that hooks into most modern themes. You can use it to preview and modify many of your site’s appearance settings.

I’ve long wanted site icons in the customizer alongside site title and tagline. The identity information that I always want to edit when first setting up a site are now all together in the customizer.

For more visuals, see these visual records.

See #16434.

Editor Patterns

Create bulleted lists, ordered lists, and blockquotes using markdown like patterns. I find this particularly handy on phones when the editor toolbar is offscreen.

Screen Shot 2015-07-14 at 4.39.12 PM

See #31441.

Better focus styling for list table row toggles

See #32395.

Better accessibilityAccessibility Accessibility (commonly shortened to a11y) refers to the design of products, devices, services, or environments for people with disabilities. The concept of accessible design ensures both “direct access” (i.e. unassisted) and “indirect access” meaning compatibility with a person’s assistive technology (for example, computer screen readers). (https://en.wikipedia.org/wiki/Accessibility) and design for the comments bubble

The comments columns in our list tables were among the most confusing for screen reader users. Accessibility and visuals are now improved.

See #32152.

Eliminate content overruns on small screens

An audit of content overruns on small screens resulted in many fixes.

After:

Before:

See #32846.

Styling improvements on small screens for Right Now in the networknetwork (versus site, blog) adminadmin (and super admin)

See #32962.

Improved headerHeader The header of your site is typically the first thing people will experience. The masthead or header art located across the top of your page is part of the look and feel of your website. It can influence a visitor’s opinion about your content and you/ your organization’s brand. It may also look different on different screen sizes. information in Network Admin Edit Site tabs

  • Use the site’s name rather than URLURL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org in the Edit Site header.
  • Provide “Visit” and “Dashboard” links for the site on all tabs.

After:

Before:

See #32525.

Disambiguate “Automatically add new top-level pages to this menu”

In the customizer, a menu’s auto-add pages option is now separated from the preceding menu location checkboxes.

See #32820.

 Passwords UIUI User interface Improvements

Passwords received a couple of improvements. The show/hide toggles look better, and passwords ui is on the install screen. Passwords on the install screen still needs a little more flow work.

See #32589 and #32925.

For more visuals, see these visual records.

Reduce link noise in media library list view

This is visually subtle but removes confusion for screen readers.

KL_7dmW58c

See #32254.

 

Previously: Today in the Nightly: Customize in the Toolbar, Passwords UI, List Tables on Phones, Dashicons

#accessibility, #bubbles, #comments, #content-overrun, #customize, #edit-site, #editor, #list-tables, #media, #menus, #multisite, #network-admin, #right-now, #site-icons, #today-in-the-nightly

Comments are now turned off on pages by default

In [33041] and [33054] for #31168, we’ve turned comments off on new pages by default.

I know many of you have done the “make a bunch of pages, fill them out, realize comments are turned on, go back into the adminadmin (and super admin), turn off comments” dance. Now when you make a page, you won’t have to manually turn off comments — it’ll match the expected behavior of being off by default.

In addition to pages, this functionality has been extended to all custom post types. Post registrations that don’t explicitly add support for comments will now default to comments being off on new posts of that type (before, they defaulted to on). Up until now, post type support for comments has only affected admin UIUI User interface; a developer could omit comment support on registration but still allow comments to be posted. This is a change in behavior, and we will be closely monitoring its effects during betaBeta A pre-release of software that is given out to a large group of users to trial under real conditions. Beta versions have gone through alpha testing in-house and are generally fairly close in look, feel and function to the final product; however, design changes often occur as part of the process.. Moving to explicit support will allow coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. behavior to be more predictable and robust in the future, but we will always consider real-world usage.

In trunktrunk A directory in Subversion containing the latest development code in preparation for the next major release cycle. If you are running "trunk", then you are on the latest revision., you’ll notice two new things: the get_default_comment_status() function, which accepts the post type and comment type as arguments (both optional), and within it a get_default_comment_status filterFilter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output., which receives the status, post type, and comment type as arguments. If you’ve been directly checking options such as with get_option( 'default_comment_status' ), you will likely want to replace those calls with get_default_comment_status(). We recommend explicit registration of post type support for comments, but as an example of using the filter, you can restore current behavior using the following:

/**
 * Filter whether comments are open for a given post type.
 *
 * @param string $status       Default status for the given post type,
 *                             either 'open' or 'closed'.
 * @param string $post_type    Post type. Default is `post`.
 * @param string $comment_type Type of comment. Default is `comment`.
 * @return string (Maybe) filtered default status for the given post type.
 */
function wpdocs_open_comments_for_myposttype( $status, $post_type, $comment_type ) {
    if ( 'myposttype' !== $post_type ) {
        return $status;
    }

    // You could be more specific here for different comment types if desired
    return 'open';
}
add_filter( 'get_default_comment_status', 'wpdocs_open_comments_for_myposttype', 10, 3 );

#4-3, #comments, #dev-notes, #post-types

Trying to decide what to do with comment …

Trying to decide what to do with comment permalinks when paging is turned on.

#comments, #permalinks