Making WordPress.org


Ignore:
Timestamp:
09/15/2022 03:13:17 PM (4 years ago)
Author:
amieiro
Message:

Translate. Add new status in the gp-translation-helpers plugin

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  
    4141
    4242        /**
     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        /**
    4351         * The post type used to store the comments.
    4452         *
     
    9098                $this->register_post_type_and_taxonomy();
    9199                add_filter( 'pre_comment_approved', array( $this, 'comment_moderation' ), 10, 2 );
     100                add_filter( 'comments_open', array( $this, 'comments_open_override' ), 10, 2 );
    92101                add_filter( 'map_meta_cap', array( $this, 'map_comment_meta_caps' ), 10, 4 );
    93102                add_filter( 'user_has_cap', array( $this, 'give_user_read_cap' ), 10, 3 );
     
    253262
    254263        /**
     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        /**
    255286         * Updates the comment's approval status before it is set.
    256287         *
     
    366397        public static function maybe_get_temporary_post( $post_id ) {
    367398                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;
    369401                }
    370402
     
    527559                                'translation_id'       => isset( $this->data['translation_id'] ) ? $this->data['translation_id'] : null,
    528560                                'locale_slug'          => $this->data['locale_slug'],
    529                                 'original_permalink'   => $this->data['original_permalink'],
    530561                                'original_id'          => $this->data['original_id'],
    531562                                'project'              => $this->data['project'],
     
    654685                        'replyto'        => sprintf( $args['reply_to_text'], $comment->comment_author ),
    655686                );
     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                }
    656693
    657694                $data_attribute_string = '';
     
    672709                                                'moderation-hash' => false,
    673710                                        ),
    674                                         $args['original_permalink']
     711                                        $permalink
    675712                                )
    676713                        ) . '#' . $args['respond_id'],
Note: See TracChangeset for help on using the changeset viewer.