WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 6 weeks ago

#12991 assigned enhancement

Allow setting default_comment_status specifically for Pages (or for any post type)

Reported by: demetris Owned by: messenlehner
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

Now that the default theme has comments_template in Pages too, I have been thinking that maybe we should offer a way of setting default_comment_status specifically for Pages (as distinguished from Posts).

Why?

Say that I select Twenty Ten as my theme. I leave the global option for comments ON, because, like most people, I want comments on my Posts. However, like most people, I do not want comments on Pages, or I want comments only on a few selected Pages. So, every time I make a new Page, I have to untick the checkbox on the Edit screen, in order to override the global setting. That’s not convenient!

I think we need to do something about that:

Either we leave Twenty Ten as is and change something at the level of post type registration, or we change something in Twenty Ten.

(I have no idea what would be a satisfactory way to deal with this at the theme level. Sandbox, for instance, displayed the form on Pages only if there was a certain custom field with a certain value, which may seem very unfriendly at first sight, but I find it is much friendlier than what we have now in Twenty Ten.)

Attachments (2)

default_page_comments.patch (2.2 KB) - added by messenlehner 4 years ago.
Update for setting default comments on or off for pages
default_page_comments2.patch (2.2 KB) - added by messenlehner 4 years ago.
Update for setting default comments on or off for pages

Download all attachments as: .zip

Change History (31)

comment:1 greenshady4 years ago

The previous Default theme just did things wrong. It should've always shown the comments form by default on pages. Twenty Ten just fixes a bug. Changing something in the theme should not be an option at all. The Sandbox theme just adds another level of complexity to something already built in.

I'm impartial to allowing a default for other post types, but a big -1 to changing how this is handled in Twenty Ten.

comment:2 mikeschinkel4 years ago

  • Cc mikeschinkel@… added

@demetris: I agree, the default should be comments on Post and no comments on Pages or any other custom post types. The user should be able to turn on comments for non-Posts, either on a per-post or a global basis but by default only Posts (post_type="post") should have comments. (Note: Post is post_type="post" and post is any post_type.)

IMO, anyway.

comment:3 zeo4 years ago

IMHO, this should be a great addition under Settings > Discussion >
Discussion Settings.

Under Default article settings add another checkbox "Allow people to post comments on new articles Page" or something like that.

comment:4 messenlehner4 years ago

  • Owner set to messenlehner
  • Status changed from new to assigned

Made changes to following files to account for option on Settings > Discussion > Discussion Settings to allow for people to set default open/closed comments on pages:

wp-admin\options-discussion.php #45
wp-admin\includes\post.php #382
includes\post.php #2145

messenlehner4 years ago

Update for setting default comments on or off for pages

comment:5 messenlehner4 years ago

  • Keywords has-patch added

messenlehner4 years ago

Update for setting default comments on or off for pages

comment:6 wpmuguru4 years ago

(In [14448]) add default comment status setting for pages, props messenlehner, see #12991

comment:7 wpmuguru4 years ago

(In [14451]) add default comment status setting to populate_options(), see #12991

comment:8 nacin4 years ago

  • Keywords ux-feedback added

I think we should revert these and revisit this in 3.1. We need to properly handle an upgrade, for one, also, if we're going to do this, we should consider providing support for custom post types. I know it was committed during the code sprint, but I'm also not sure if this got any ux feedback.

comment:9 demetris4 years ago

There are a couple more issues I’ve noticed after the latest patch:

  1. The explanatory sentence is repeated twice. We only need it once.
  2. The option appears even when it does nothing, i.e., even when the active theme does not support Page comments.

Revisiting all this in v3.1 sounds a reasonable idea at this stage of the release cycle. On the other hand, this is something I would like to see addressed sooner than later, provided we want Twenty Ten to be a theme people will want to use, and will be happy using.

comment:10 follow-up: johnonolan4 years ago

  • Cc john.wp@… added

I agree that a more comprehensive solution should be looked at rather than just bolting on another checkbox

comment:11 in reply to: ↑ 10 ; follow-up: demetris4 years ago

Replying to johnonolan:

I agree that a more comprehensive solution should be looked at rather than just bolting on another checkbox

“bolting on another checkbox”, either at the theme level or at the core level, will be part of any comprehensive solution in any case, since this option must be somehow exposed in the UI.

comment:12 in reply to: ↑ 11 johnonolan4 years ago

Replying to demetris:

Replying to johnonolan:

I agree that a more comprehensive solution should be looked at rather than just bolting on another checkbox

“bolting on another checkbox”, either at the theme level or at the core level, will be part of any comprehensive solution in any case, since this option must be somehow exposed in the UI.

Indeed, but where and what exactly the checkbox does depend on a final functionality spec

comment:13 nacin4 years ago

(In [14650]) Remove default_comment_status_pages setting. Reverts [14451], [14448] for 3.0. see #12991.

comment:14 nacin4 years ago

  • Milestone changed from 3.0 to Future Release

Also [14651].

comment:15 follow-ups: demetris4 years ago

Another problem with the current implementation in WP / Twenty Ten, that I failed to mention before:

If you switch to Twenty Ten from another theme, then comments are turned automatically on for all existing Pages.

comment:16 in reply to: ↑ 15 zeo4 years ago

Replying to demetris:

If you switch to Twenty Ten from another theme, then comments are turned automatically on for all existing Pages.

Obviously the Discussion setting for Allow Comments / pingback for that particular Page is ticked. Need to turn it off individually. That's how it suppose to work.

comment:17 follow-up: demetris4 years ago

@zeo:

That’s exactly the problem:

That, if you want to keep the previous behaviour, you have to go to each one of your Pages and untick an option.

comment:18 in reply to: ↑ 17 nacin4 years ago

Replying to demetris:

@zeo:

That’s exactly the problem:

That, if you want to keep the previous behaviour, you have to go to each one of your Pages and untick an option.

Or use bulk edit and have it done in 10 seconds.

comment:19 demetris4 years ago

@nacin:

Certainly. Bulk edit reduces the inconvenience in this particular case, but bulk edit is not what everyone will think of when they see comment forms on their Pages, and, in any case, that’s not the only issue in the current implementation.

comment:20 in reply to: ↑ 15 greenshady4 years ago

Replying to demetris:

Another problem with the current implementation in WP / Twenty Ten, that I failed to mention before:

If you switch to Twenty Ten from another theme, then comments are turned automatically on for all existing Pages.

This is not a problem with WP / TwentyTen. This is a problem with your previous theme for not properly supporting comments on pages. Comments are not turned on automatically. You just happened to switch to a theme that does things the correct way.

comment:21 chipbennett2 years ago

  • Cc chip@… added

comment:22 follow-up: chipbennett2 years ago

Is this ticket going anywhere, or is it DOA? I would be happy to work on it, if the underlying intent is still acceptable.

I think the correct approach would be to replace default_comment_status with default_comment_status_post, default_comment_status_page, and default_comment_status_attachment (which establishes a convention of default_comment_status_$posttype for CPTs).

Also, the Default article settings text needs to be changed. As far as I know, Posts aren't referred to as Articles anywhere else?

Regarding the UI, I would propose renaming the section from "Default article settings" to "Default comment status", and then provide grouped checkboxes for the following:

Allow people to post comments on:       [ ] Posts
                                        [ ] Pages
                                        [ ] Attachments

Allow link notifications 
(pingbacks/trackbacks) on:              [ ] Posts
                                        [ ] Pages
                                        [ ] Attachments

Attempt to notify blogs linked to from: [ ] Posts
                                        [ ] Pages

...but this would need to be extensible for registered CPTs. (Perhaps through a filter?)

Related: when will the core options-$section.php files be implementing the Settings API? If/when that happens, then custom post type support becomes nothing more than a matter of adding an add_settings_field() call along with the register_post_type() call.

Last edited 2 years ago by chipbennett (previous) (diff)

comment:23 jane2 years ago

  • Keywords ux-feedback removed

@chipbennett: I think your grouped checkboxes proposal looks great. Would love to see that improvement. Not sure if existing patch needs refresh or if it needs to be scrapped and a new one started.

comment:24 follow-up: chipbennett2 years ago

@jane - looks like probably a new patch will be in order.

Do you think I should include all post types (i.e. to include any user-registered post types), or just Posts and Pages (and Attachments)?

comment:25 in reply to: ↑ 24 DrewAPicture2 years ago

  • Cc xoodrew@… added

Replying to chipbennett:

Do you think I should include all post types (i.e. to include any user-registered post types), or just Posts and Pages (and Attachments)?

IANAJ but it would be nice to have support for all post types here, assuming said post types have comments enabled in their supports arrays.

comment:26 F J Kaiser19 months ago

For all people stumbling over this ticket (that hasn't made progress for a while), here's a temporary solution written by a user on WordPress StackExchange.

function wpse48145_unchecked_page_discussion () {
      if( 'page' == $_REQUEST[ 'post_type' ]  ) {
        add_filter( 'pre_option_default_comment_status', 'wpse48145_unchecked_page_discussion_filter' );
        // & if you want...
        add_filter( 'pre_option_default_ping_status', 'wpse48145_unchecked_page_discussion_filter' );
    }
}
add_action( 'load-post-new.php', 'wpse48145_unchecked_page_discussion' );

function wpse48145_unchecked_page_discussion_filter ( $val ) {
    return 'closed';
}

comment:27 in reply to: ↑ 22 SergeyBiryukov17 months ago

Replying to chipbennett:

Also, the Default article settings text needs to be changed. As far as I know, Posts aren't referred to as Articles anywhere else?

Related: #22579

comment:28 lkraav9 months ago

  • Cc leho@… added
Note: See TracTickets for help on using tickets.