Making WordPress.org

Changeset 11843


Ignore:
Timestamp:
05/13/2022 04:46:05 PM (4 years ago)
Author:
iandunn
Message:

Profiles: Remove unnecessary _what_ comments.

Comments should explain _why_ something is doing what it's doing. Expaining _what_ it's obviously doing adds clutter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-profiles-wp-activity-notifier/wporg-profiles-wp-activity-notifier.php

    r11842 r11843  
    6666         */
    6767        public function is_post_notifiable( $post ) {
    68                 // Sanity check the argument is a post
    6968                if ( ! $post || ! is_a( $post, 'WP_Post' ) ) {
    7069                        return false;
    7170                }
    7271
    73                 // Don't notify if the site is for subscribers only
    7472                if ( class_exists( 'Subscribers_Only' ) ) {
    7573                        $notifiable = false;
    7674                }
    7775
    78                 // Don't notify if not of 'post' post_type
    7976                elseif ( 'post' != $post->post_type ) {
    8077                        $notifiable = false;
    8178                }
    8279
    83                 // Don't notify if not publicly published
    8480                elseif ( 'publish' != $post->post_status ) {
    8581                        $notifiable = false;
    8682                }
    8783
    88                 // Don't notify if password is required
    8984                elseif ( ! empty( $post->post_password ) ) {
    9085                        $notifiable = false;
    9186                }
    9287
    93                 // At this point it is permitted to notify about the post
    9488                else {
    9589                        $notifiable = true;
    9690                }
    9791
    98                 // Return filtered value to allow overriding or extending checks
    9992                return apply_filters( 'wporg_profiles_wp_activity-is_post_notifiable', $notifiable, $post );
    10093        }
    … …  
    108101         */
    109102        public function maybe_notify_new_published_post( $new_status, $old_status, $post ) {
    110                 // Only proceed if the post is transitioning to the publish status
    111103                if ( 'publish' != $new_status ) {
    112104                        return;
    113105                }
    114106
    115                 // Only proceed if the post is actually changing status
    116107                if ( $old_status == $new_status ) {
    117108                        return;
    118109                }
    119110
    120                 // Only proceed if permitted to notify about the post
    121111                if ( ! $this->is_post_notifiable( $post ) ) {
    122112                        return;
    123113                }
    124114
    125                 // Send notification for the post
    126115                $this->notify_new_blog_post( $post );
    127116        }
    … …  
    133122         */
    134123        public function notify_new_blog_post( $post ) {
    135                 // Don't notify if importing.
    136124                if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
    137125                        return;
    … …  
    182170         */
    183171        public function maybe_notify_new_approved_comment( $new_status, $old_status, $comment ) {
    184                 // Only proceed if the comment is transitioning to the approved status
    185172                if ( 'approved' != $new_status ) {
    186173                        return;
    … …  
    189176                $post = get_post( $comment->comment_post_ID );
    190177
    191                 // Only proceed if permitted to notify about the post
    192178                if ( ! $this->is_post_notifiable( $post ) ) {
    193179                        return;
    194180                }
    195181
    196                 // Only proceed if there are no objections to the comment notification
    197182                if ( apply_filters( 'wporg_profiles_wp_activity-is_comment_notifiable', true, $comment, $post ) ) {
    198183                        $this->notify_new_approved_comment( $comment, $post );
    … …  
    207192         */
    208193        private function notify_new_approved_comment( $comment, $post ) {
    209                 // Don't notify if importing.
    210194                if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
    211195                        return;
    … …  
    246230         */
    247231        private function _notify_forum_topic_payload( $activity, $topic_id ) {
    248                 // Don't notify if importing.
    249232                if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
    250233                        return;
    251234                }
    252235
    253                 // Bail if site is private.
    254236                if ( ! bbp_is_site_public() ) {
    255237                        return;
    256238                }
    257239
    258                 // Only handle recognized activities.
    259240                if ( ! in_array( $activity, array( 'create-topic', 'remove-topic' ) ) ) {
    260241                        return;
    261242                }
    262243
    263                 // Bail on create-topic if topic is not published.
    264244                if ( 'create-topic' === $activity && ! bbp_is_topic_published( $topic_id ) ) {
    265245                        return;
    … …  
    317297         */
    318298        private function _notify_forum_reply_payload( $activity, $reply_id ) {
    319                 // Don't notify if importing.
    320299                if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
    321300                        return;
    322301                }
    323302
    324                 // Bail if site is private.
    325303                if ( ! bbp_is_site_public() ) {
    326304                        return;
    327305                }
    328306
    329                 // Only handle recognized activities.
    330307                if ( ! in_array( $activity, array( 'create-reply', 'remove-reply' ) ) ) {
    331308                        return;
    332309                }
    333310
    334                 // Bail on create-reply if not published.
    335311                if ( 'create-reply' === $activity && ! bbp_is_reply_published( $reply_id ) ) {
    336312                        return;
    … …  
    420396                $text = preg_replace( '/<blockquote>.+?<\/blockquote>/s', '', $text );
    421397
    422                 // Strip tags and surrounding whitespace.
    423398                $text = trim( strip_tags( $text ) );
    424399
    425                 // Strip shortcodes.
    426400                if ( function_exists( 'strip_shortcodes' ) ) {
    427401                        $text = strip_shortcodes( $text );
    … …  
    431405                // /* bbp_get_reply_excerpt */().
    432406                if ( 'chars' === $trim_style ) {
    433                         // Multibyte support
    434407                        if ( function_exists( 'mb_strlen' ) ) {
    435408                                $text_length = mb_strlen( $text );
Note: See TracChangeset for help on using the changeset viewer.