Changeset 12063 for sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers/helper-translation-discussion.php
- Timestamp:
- 09/15/2022 03:13:17 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/gp-translation-helpers/helpers/helper-translation-discussion.php
r12003 r12063 41 41 42 42 /** 43 * Indicates whether we're currently using a temporary post. 44 * 45 * @since 0.0.2 46 * @var object|null 47 */ 48 public static $temporary_post = null; 49 50 /** 43 51 * The post type used to store the comments. 44 52 * … … 90 98 $this->register_post_type_and_taxonomy(); 91 99 add_filter( 'pre_comment_approved', array( $this, 'comment_moderation' ), 10, 2 ); 100 add_filter( 'comments_open', array( $this, 'comments_open_override' ), 10, 2 ); 92 101 add_filter( 'map_meta_cap', array( $this, 'map_comment_meta_caps' ), 10, 4 ); 93 102 add_filter( 'user_has_cap', array( $this, 'give_user_read_cap' ), 10, 3 ); … … 253 262 254 263 /** 264 * Enable showing the comment form on non-existing posts. 265 * 266 * @param boolean $open Whether the comments are open or not. 267 * @param int $post_id The post id. 268 * 269 * @return bool Whether the comments are open or not. 270 */ 271 public function comments_open_override( $open, $post_id ) { 272 if ( self::is_temporary_post_id( $post_id ) ) { 273 return true; 274 } 275 276 // If we just had to define a temporary post, the post id can also be 0. 277 // This is due to a code change in core in this commit: 278 // https://github.com/WordPress/WordPress/commit/1069ac4afda821742cf7f600412aacc139013a55 279 if ( self::$temporary_post && 0 === $post_id ) { 280 return true; 281 } 282 return $open; 283 } 284 285 /** 255 286 * Updates the comment's approval status before it is set. 256 287 * … … 366 397 public static function maybe_get_temporary_post( $post_id ) { 367 398 if ( self::is_temporary_post_id( $post_id ) ) { 368 return new Gth_Temporary_Post( $post_id ); 399 self::$temporary_post = new Gth_Temporary_Post( $post_id ); 400 return self::$temporary_post; 369 401 } 370 402 … … 527 559 'translation_id' => isset( $this->data['translation_id'] ) ? $this->data['translation_id'] : null, 528 560 'locale_slug' => $this->data['locale_slug'], 529 'original_permalink' => $this->data['original_permalink'],530 561 'original_id' => $this->data['original_id'], 531 562 'project' => $this->data['project'], … … 654 685 'replyto' => sprintf( $args['reply_to_text'], $comment->comment_author ), 655 686 ); 687 688 if ( get_option( 'page_comments' ) ) { 689 $permalink = str_replace( '#comment-' . $comment->comment_ID, '', get_comment_link( $comment ) ); 690 } else { 691 $permalink = get_permalink( $post->ID ); 692 } 656 693 657 694 $data_attribute_string = ''; … … 672 709 'moderation-hash' => false, 673 710 ), 674 $ args['original_permalink']711 $permalink 675 712 ) 676 713 ) . '#' . $args['respond_id'],
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)