Making WordPress.org

Ticket #1965: 1965.patch

File 1965.patch, 4.7 KB (added by Clorith, 6 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php

     
    468468
    469469                $permalink = $this->get_permalink( $post->ID );
    470470
     471                $classes = array();
     472
     473                if ( bbp_is_topic( $r['post_id'] ) ) {
     474                        $classes[] = 'bbp-topic-archive-link';
     475                } else {
     476                        $classes[] = 'bbp-reply-archive-link';
     477                }
     478
    471479                $url = esc_url( wp_nonce_url( add_query_arg( $query_args, $permalink ), 'toggle-post-archive_' . $user_id . '_' . $post->ID ) );
    472                 return sprintf( "<a href='%s'>%s</a>", $url, esc_html( $text ) );
     480                return sprintf( "<a href='%s' class='%s'>%s</a>", $url, esc_attr( implode( ' ', $classes ) ), esc_html( $text ) );
    473481        }
    474482
    475483        public function is_post_archived( $post_id ) {
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/js/forums.js

     
    44                $( '[type="submit"]', $(this) ).prop( 'disabled', 'disabled' );
    55        });
    66
     7        function wporg_bbp_ajax_moderator_action( link, element, type ) {
     8                $.get(
     9                        link
     10                ).done( function() {
     11                        element.fadeOut( 250, function() {
     12                                $( this ).html( '<div class="bbp-template-notice">' + wporgSupport.strings[ type ] + '</div>' );
     13                        } ).fadeIn( 250 );
     14                } ).error( function() {
     15                        element.fadeOut( 250, function() {
     16                                $( '.bbp-topic-content', $( this ) ).prepend( '<div class="bbp-template-notice">' + wporgSupport.strings.action_failed + '</div>' );
     17                        } ).fadeIn( 250 );
     18                } );
     19        }
     20
     21        $( '.bbp-topic-approve-link, .bbp-post-approve-link', 'body.bbp-view-pending, body.bbp-view-spam' ).click( function( e ) {
     22                e.preventDefault();
     23                wporg_bbp_ajax_moderator_action( $( this ).attr( 'href' ), $( this ).closest( '.bbp-body' ), 'approve' );
     24        } );
     25        $( '.bbp-topic-spam-link, .bbp-post-spam-link', 'body.bbp-view-pending, body.bbp-view-spam' ).click( function( e ) {
     26                e.preventDefault();
     27                wporg_bbp_ajax_moderator_action( $( this ).attr( 'href' ), $( this ).closest( '.bbp-body' ), 'spam' );
     28        } );
     29        $( '.bbp-topic-archive-link, .bbp-post-archive-link', 'body.bbp-view-pending, body.bbp-view-spam' ).click( function( e ) {
     30                e.preventDefault();
     31                wporg_bbp_ajax_moderator_action( $( this ).attr( 'href' ), $( this ).closest( '.bbp-body' ), 'archive' );
     32        } );
     33
    734} )( window.jQuery );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-support/functions.php

     
    2424
    2525        wp_enqueue_script( 'wporg-support-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20181209', true );
    2626        wp_enqueue_script( 'wporg-support-forums', get_template_directory_uri() . '/js/forums.js', array( 'jquery' ), '20180801', true );
     27
     28        wp_localize_script(
     29                'wporg-support-forums',
     30                'wporgSupport',
     31                array(
     32                        'strings' => array(
     33                                'approve'       => __( 'The approval status of this post has been changed.', 'wporg-forums' ),
     34                                'spam'          => __( 'The spam status of this post has been changed.', 'wporg-forums' ),
     35                                'archive'       => __( 'The archive status of this post has been changed.', 'wporg-forums' ),
     36                                'action_failed' => __( 'Unable to complete the requested action, please try again.', 'wporg-forums' ),
     37                        ),
     38                )
     39        );
    2740}
    2841add_action( 'wp_enqueue_scripts', 'wporg_support_scripts' );
    2942
     
    165178}
    166179add_filter( 'body_class', 'wporg_support_body_class' );
    167180
     181/**
     182 * Exten the bbPress body class when applicable.
     183 */
     184function wporg_support_bbp_body_class( $classes ) {
     185        global $wp_query;
     186
     187        // If this is a single view, we will add a custom rule for it.
     188        if ( ! empty( $wp_query->bbp_is_view ) && ( true === $wp_query->bbp_is_view ) ) {
     189                $single_view = 'bbp-view-' . $wp_query->get( 'bbp_view' );
     190                if ( ! in_array( $single_view, $classes ) ) {
     191                        $classes[] = $single_view;
     192                }
     193        }
     194
     195        return $classes;
     196}
     197add_filter( 'bbp_body_class', 'wporg_support_bbp_body_class' );
     198
    168199/**
    169200 * Change the amount of words allowed in excerpts on archive listings.
    170201 *