Plugin Directory

Changeset 3259357


Ignore:
Timestamp:
03/20/2025 05:59:38 PM (12 months ago)
Author:
happyprime
Message:

Update to version 2.0.0 from GitHub

Location:
turn-comments-off
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • turn-comments-off/tags/2.0.0/LICENSE

    r2889508 r3259357  
    11Turn Comments Off plugin for WordPress
    22
    3 Copyright 2022-2023, Happy Prime and contributors
     3Copyright 2022-2025, Happy Prime and contributors
    44
    55This program is free software; you can redistribute it and/or modify
  • turn-comments-off/tags/2.0.0/plugin.php

    r3124314 r3259357  
    33 * Plugin Name:  Turn Comments Off
    44 * Description:  Turn comments off everywhere in WordPress.
    5  * Version:      1.3.2
     5 * Version:      2.0.0
    66 * Plugin URI:   https://github.com/happyprime/turn-comments-off/
    77 * Author:       Happy Prime
     
    3939add_filter( 'get_comments_number', '__return_zero' );
    4040
    41 // So return an empty set of comments for all comment queries.
    42 add_filter( 'comments_pre_query', '__return_empty_array' );
     41// So return an empty set or count of comments for all comment queries.
     42add_filter( 'comments_pre_query', __NAMESPACE__ . '\filter_comments_pre_query', 10, 2 );
    4343
    4444// And disable the comments feed.
     
    6363add_action( 'load-options-discussion.php', __NAMESPACE__ . '\block_comments_admin_screen' );
    6464add_action( 'load-edit-comments.php', __NAMESPACE__ . '\block_comments_admin_screen' );
     65
     66/**
     67 * Filter the comments pre query.
     68 *
     69 * @param array<int,\WP_Comment>|int|null $comments The comments to filter.
     70 * @param \WP_Comment_Query               $query The query object.
     71 * @return array<int,\WP_Comment>|int The filtered comments.
     72 */
     73function filter_comments_pre_query( $comments, \WP_Comment_Query $query ) {
     74    if ( $query->query_vars['count'] ) {
     75        return 0;
     76    }
     77
     78    return [];
     79}
    6580
    6681/**
  • turn-comments-off/tags/2.0.0/readme.txt

    r3182834 r3259357  
    44Requires at least: 5.9
    55Tested up to: 6.7
    6 Stable tag: 1.3.2
     6Stable tag: 2.0.0
    77License: GPLv2 or later
    88Requires PHP: 7.4
     
    2828
    2929## Changelog
     30
     31### 2.0.0
     32
     33* Fix a fatal PHP error when a comment query requests a count.
     34* Note: If you had manually removed our `comments_pre_query` filter for any reason,
     35  (you likely weren't), you'll need to adjust your code to account for the new
     36  namespaced function.
     37* Update development dependencies.
    3038
    3139### 1.3.2
  • turn-comments-off/trunk/LICENSE

    r2889508 r3259357  
    11Turn Comments Off plugin for WordPress
    22
    3 Copyright 2022-2023, Happy Prime and contributors
     3Copyright 2022-2025, Happy Prime and contributors
    44
    55This program is free software; you can redistribute it and/or modify
  • turn-comments-off/trunk/plugin.php

    r3124314 r3259357  
    33 * Plugin Name:  Turn Comments Off
    44 * Description:  Turn comments off everywhere in WordPress.
    5  * Version:      1.3.2
     5 * Version:      2.0.0
    66 * Plugin URI:   https://github.com/happyprime/turn-comments-off/
    77 * Author:       Happy Prime
     
    3939add_filter( 'get_comments_number', '__return_zero' );
    4040
    41 // So return an empty set of comments for all comment queries.
    42 add_filter( 'comments_pre_query', '__return_empty_array' );
     41// So return an empty set or count of comments for all comment queries.
     42add_filter( 'comments_pre_query', __NAMESPACE__ . '\filter_comments_pre_query', 10, 2 );
    4343
    4444// And disable the comments feed.
     
    6363add_action( 'load-options-discussion.php', __NAMESPACE__ . '\block_comments_admin_screen' );
    6464add_action( 'load-edit-comments.php', __NAMESPACE__ . '\block_comments_admin_screen' );
     65
     66/**
     67 * Filter the comments pre query.
     68 *
     69 * @param array<int,\WP_Comment>|int|null $comments The comments to filter.
     70 * @param \WP_Comment_Query               $query The query object.
     71 * @return array<int,\WP_Comment>|int The filtered comments.
     72 */
     73function filter_comments_pre_query( $comments, \WP_Comment_Query $query ) {
     74    if ( $query->query_vars['count'] ) {
     75        return 0;
     76    }
     77
     78    return [];
     79}
    6580
    6681/**
  • turn-comments-off/trunk/readme.txt

    r3182834 r3259357  
    44Requires at least: 5.9
    55Tested up to: 6.7
    6 Stable tag: 1.3.2
     6Stable tag: 2.0.0
    77License: GPLv2 or later
    88Requires PHP: 7.4
     
    2828
    2929## Changelog
     30
     31### 2.0.0
     32
     33* Fix a fatal PHP error when a comment query requests a count.
     34* Note: If you had manually removed our `comments_pre_query` filter for any reason,
     35  (you likely weren't), you'll need to adjust your code to account for the new
     36  namespaced function.
     37* Update development dependencies.
    3038
    3139### 1.3.2
Note: See TracChangeset for help on using the changeset viewer.