Changeset 11843
- Timestamp:
- 05/13/2022 04:46:05 PM (4 years ago)
- 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 66 66 */ 67 67 public function is_post_notifiable( $post ) { 68 // Sanity check the argument is a post69 68 if ( ! $post || ! is_a( $post, 'WP_Post' ) ) { 70 69 return false; 71 70 } 72 71 73 // Don't notify if the site is for subscribers only74 72 if ( class_exists( 'Subscribers_Only' ) ) { 75 73 $notifiable = false; 76 74 } 77 75 78 // Don't notify if not of 'post' post_type79 76 elseif ( 'post' != $post->post_type ) { 80 77 $notifiable = false; 81 78 } 82 79 83 // Don't notify if not publicly published84 80 elseif ( 'publish' != $post->post_status ) { 85 81 $notifiable = false; 86 82 } 87 83 88 // Don't notify if password is required89 84 elseif ( ! empty( $post->post_password ) ) { 90 85 $notifiable = false; 91 86 } 92 87 93 // At this point it is permitted to notify about the post94 88 else { 95 89 $notifiable = true; 96 90 } 97 91 98 // Return filtered value to allow overriding or extending checks99 92 return apply_filters( 'wporg_profiles_wp_activity-is_post_notifiable', $notifiable, $post ); 100 93 } … … 108 101 */ 109 102 public function maybe_notify_new_published_post( $new_status, $old_status, $post ) { 110 // Only proceed if the post is transitioning to the publish status111 103 if ( 'publish' != $new_status ) { 112 104 return; 113 105 } 114 106 115 // Only proceed if the post is actually changing status116 107 if ( $old_status == $new_status ) { 117 108 return; 118 109 } 119 110 120 // Only proceed if permitted to notify about the post121 111 if ( ! $this->is_post_notifiable( $post ) ) { 122 112 return; 123 113 } 124 114 125 // Send notification for the post126 115 $this->notify_new_blog_post( $post ); 127 116 } … … 133 122 */ 134 123 public function notify_new_blog_post( $post ) { 135 // Don't notify if importing.136 124 if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { 137 125 return; … … 182 170 */ 183 171 public function maybe_notify_new_approved_comment( $new_status, $old_status, $comment ) { 184 // Only proceed if the comment is transitioning to the approved status185 172 if ( 'approved' != $new_status ) { 186 173 return; … … 189 176 $post = get_post( $comment->comment_post_ID ); 190 177 191 // Only proceed if permitted to notify about the post192 178 if ( ! $this->is_post_notifiable( $post ) ) { 193 179 return; 194 180 } 195 181 196 // Only proceed if there are no objections to the comment notification197 182 if ( apply_filters( 'wporg_profiles_wp_activity-is_comment_notifiable', true, $comment, $post ) ) { 198 183 $this->notify_new_approved_comment( $comment, $post ); … … 207 192 */ 208 193 private function notify_new_approved_comment( $comment, $post ) { 209 // Don't notify if importing.210 194 if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { 211 195 return; … … 246 230 */ 247 231 private function _notify_forum_topic_payload( $activity, $topic_id ) { 248 // Don't notify if importing.249 232 if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { 250 233 return; 251 234 } 252 235 253 // Bail if site is private.254 236 if ( ! bbp_is_site_public() ) { 255 237 return; 256 238 } 257 239 258 // Only handle recognized activities.259 240 if ( ! in_array( $activity, array( 'create-topic', 'remove-topic' ) ) ) { 260 241 return; 261 242 } 262 243 263 // Bail on create-topic if topic is not published.264 244 if ( 'create-topic' === $activity && ! bbp_is_topic_published( $topic_id ) ) { 265 245 return; … … 317 297 */ 318 298 private function _notify_forum_reply_payload( $activity, $reply_id ) { 319 // Don't notify if importing.320 299 if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { 321 300 return; 322 301 } 323 302 324 // Bail if site is private.325 303 if ( ! bbp_is_site_public() ) { 326 304 return; 327 305 } 328 306 329 // Only handle recognized activities.330 307 if ( ! in_array( $activity, array( 'create-reply', 'remove-reply' ) ) ) { 331 308 return; 332 309 } 333 310 334 // Bail on create-reply if not published.335 311 if ( 'create-reply' === $activity && ! bbp_is_reply_published( $reply_id ) ) { 336 312 return; … … 420 396 $text = preg_replace( '/<blockquote>.+?<\/blockquote>/s', '', $text ); 421 397 422 // Strip tags and surrounding whitespace.423 398 $text = trim( strip_tags( $text ) ); 424 399 425 // Strip shortcodes.426 400 if ( function_exists( 'strip_shortcodes' ) ) { 427 401 $text = strip_shortcodes( $text ); … … 431 405 // /* bbp_get_reply_excerpt */(). 432 406 if ( 'chars' === $trim_style ) { 433 // Multibyte support434 407 if ( function_exists( 'mb_strlen' ) ) { 435 408 $text_length = mb_strlen( $text );
Note: See TracChangeset
for help on using the changeset viewer.