Making WordPress.org


Ignore:
Timestamp:
09/05/2022 08:21:02 PM (4 years ago)
Author:
iandunn
Message:

Developer: Sync with Git 41e97d9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-voting.php

    r10937 r12053  
    4848        public static function do_init() {
    4949                // Save a non-AJAX submitted vote.
    50                 add_action( 'template_redirect',  array( __CLASS__, 'vote_submission' ) );
     50                add_action( 'template_redirect', array( __CLASS__, 'vote_submission' ) );
    5151
    5252                // Save AJAX submitted vote.
    53                 add_action( 'wp_ajax_note_vote',  array( __CLASS__, 'ajax_vote_submission' ) );
     53                add_action( 'wp_ajax_note_vote', array( __CLASS__, 'ajax_vote_submission' ) );
    5454
    5555                // Enqueue scripts and styles.
     
    6565                // Only need to enqueue voting-related resources if there are comments to vote on.
    6666                if ( self::user_can_vote() && is_singular() && '0' != get_comments_number() ) {
    67                         wp_register_script( 'wporg-developer-user-notes-voting', get_template_directory_uri() . '/js/user-notes-voting.js', array( 'wp-a11y' ), '20210428', true );
    68                         wp_localize_script( 'wporg-developer-user-notes-voting', 'wporg_note_voting', array(
    69                                 'ajaxurl' => admin_url( 'admin-ajax.php' ),
    70                         ) );
     67                        wp_register_script(
     68                                'wporg-developer-user-notes-voting',
     69                                get_template_directory_uri() . '/js/user-notes-voting.js',
     70                                array( 'wp-a11y' ),
     71                                filemtime( dirname( __DIR__ ) . '/js/user-notes-voting.js' ),
     72                                true
     73                        );
     74
     75                        wp_localize_script(
     76                                'wporg-developer-user-notes-voting',
     77                                'wporg_note_voting',
     78                                array(
     79                                        'ajaxurl' => admin_url( 'admin-ajax.php' ),
     80                                )
     81                        );
    7182                        wp_enqueue_script( 'wporg-developer-user-notes-voting' );
    7283                }
     
    97108                                exit();
    98109                        }
    99 
    100110                }
    101111
     
    177187         * @access public
    178188         *
    179          * @param  int  $user_id    Optional. The user ID. If not defined, assumes current user.
    180          * @param  int  $comment_id Optional. The comment ID. If not defined, assumes being able to comment generally.
     189         * @param  int $user_id    Optional. The user ID. If not defined, assumes current user.
     190         * @param  int $comment_id Optional. The comment ID. If not defined, assumes being able to comment generally.
    181191         * @return bool True if the user can vote.
    182192         */
     
    209219         * Determines if a note was submitted by the current user.
    210220         *
    211          * @param int   $comment_id The comment ID, or empty to use current comment.
     221         * @param int $comment_id The comment ID, or empty to use current comment.
    212222         * @return bool True if the note was submitted by the current user.
    213223         */
     
    237247         * @access public
    238248         *
    239          * @param  int    $comment_id The comment ID
    240          * @param  int    $user_id    Optional. The user ID. If not defined, assumes current user.
     249         * @param  int $comment_id The comment ID
     250         * @param  int $user_id    Optional. The user ID. If not defined, assumes current user.
    241251         * @return bool   True if the user has upvoted the comment.
    242252         */
     
    262272         * @access public
    263273         *
    264          * @param  int    $comment_id The comment ID
    265          * @param  int    $user_id    Optional. The user ID. If not defined, assumes current user.
     274         * @param  int $comment_id The comment ID
     275         * @param  int $user_id    Optional. The user ID. If not defined, assumes current user.
    266276         * @return bool   True if the user has downvoted the comment.
    267277         */
     
    289299         * @param int $comment_id The comment ID, or empty to use current comment.
    290300         */
    291         public static function show_voting( $comment_id = '') {
     301        public static function show_voting( $comment_id = '' ) {
    292302                if ( ! $comment_id ) {
    293303                        global $comment;
     
    330340                if ( 'a' === $tag ) {
    331341                        $up_url = $logged_in ?
    332                                 add_query_arg( array( '_wpnonce' => $nonce , 'comment' => $comment_id, 'vote' => 'up' ), $comment_link ) :
     342                                add_query_arg(
     343                                        array(
     344                                                '_wpnonce' => $nonce,
     345                                                'comment' => $comment_id,
     346                                                'vote' => 'up',
     347                                        ),
     348                                        $comment_link
     349                                ) :
    333350                                $log_in_url;
    334351                        echo '" href="' . esc_url( $up_url );
     
    336353                echo '">';
    337354                echo '<span class="dashicons dashicons-arrow-up" aria-hidden="true"></span>';
    338                 echo '<span class="screen-reader-text">' . $title .  '</span>';
     355                echo '<span class="screen-reader-text">' . $title . '</span>';
    339356                echo "</{$tag}>";
    340357
     
    348365                        . 'class="user-note-voting-count ' . esc_attr( $class ) . '" '
    349366                        . 'title="' . esc_attr( $title ) . '">'
    350                         . '<span class="screen-reader-text">' . __( 'Vote results for this note: ', 'wporg' ) .  '</span>'
     367                        . '<span class="screen-reader-text">' . __( 'Vote results for this note: ', 'wporg' ) . '</span>'
    351368                        . self::count_votes( $comment_id, 'difference' )
    352369                        . '</span>';
     
    371388                if ( 'a' === $tag ) {
    372389                        $down_url = $logged_in ?
    373                                 add_query_arg( array( '_wpnonce' => $nonce , 'comment' => $comment_id, 'vote' => 'down' ), $comment_link ) :
     390                                add_query_arg(
     391                                        array(
     392                                                '_wpnonce' => $nonce,
     393                                                'comment' => $comment_id,
     394                                                'vote' => 'down',
     395                                        ),
     396                                        $comment_link
     397                                ) :
    374398                                $log_in_url;
    375399                        echo '" href="' . esc_url( $down_url );
     
    377401                echo '">';
    378402                echo '<span class="dashicons dashicons-arrow-down" aria-hidden="true"></span>';
    379                 echo '<span class="screen-reader-text">' . $title .  '</span>';
     403                echo '<span class="screen-reader-text">' . $title . '</span>';
    380404                echo "</{$tag}>";
    381405
     
    435459         * @access public
    436460         *
    437          * @param  int  $comment_id The comment ID
    438          * @param  int  $user_id    Optional. The user ID. Default is current user.
     461         * @param  int $comment_id The comment ID
     462         * @param  int $user_id    Optional. The user ID. Default is current user.
    439463         * @return bool Whether the up vote succeed (a new vote or a change in vote).
    440464         */
     
    448472         * @access public
    449473         *
    450          * @param  int  $comment_id The comment ID
    451          * @param  int  $user_id    Optional. The user ID. Default is current user.
     474         * @param  int $comment_id The comment ID
     475         * @param  int $user_id    Optional. The user ID. Default is current user.
    452476         * @return bool Whether the down vote succeed (a new vote or a change in vote).
    453477         */
Note: See TracChangeset for help on using the changeset viewer.