Making WordPress.org

Changeset 10673


Ignore:
Timestamp:
02/15/2021 04:03:50 AM (4 years ago)
Author:
dd32
Message:

Support Forums: Move the "Subscribe to this plugin/theme" button to the sidebar instead of before the main topic listing.

This also adds a javascript-based confirm "are you sure?" confirmation upon attempting to subscribe to the plugin/theme.

See #3456.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r10349 r10673  
    286286            // Add plugin- and theme-specific filters and actions.
    287287            add_action( 'wporg_compat_view_sidebar',       array( $this, 'do_view_sidebar' ) );
     288            add_action( 'wporg_compat_view_sidebar',       array( $this, 'do_subscription_link' ), 11 );
    288289            add_action( 'wporg_compat_before_single_view', array( $this, 'do_view_header' ) );
    289             add_action( 'wporg_compat_before_single_view', array( $this, 'do_subscription_link' ), 11 );
    290290
    291291            // Add output filters and actions.
     
    751751                $subscribe   = esc_html__( 'Subscribe to this plugin', 'wporg-forums' );
    752752                $unsubscribe = esc_html__( 'Unsubscribe from this plugin', 'wporg-forums' );
     753                $js_confirm  = esc_html__( 'Are you sure you wish to subscribe by email to all future topics created in this plugin forum?', 'wporg-forums' );
    753754            } else {
    754755                $subscribe   = esc_html__( 'Subscribe to this theme', 'wporg-forums' );
    755756                $unsubscribe = esc_html__( 'Unsubscribe from this theme', 'wporg-forums' );
     757                $js_confirm  = esc_html__( 'Are you sure you wish to subscribe by email to all future topics created in this theme forum?', 'wporg-forums' );
    756758            }
    757759            $term_subscription = Term_Subscription\Plugin::get_subscription_link( array(
     
    760762                'subscribe'   => $subscribe,
    761763                'unsubscribe' => $unsubscribe,
     764                'js_confirm'  => $js_confirm,
    762765            ) );
    763766        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-term-subscription/inc/class-plugin.php

    r9476 r10673  
    584584            'term_id'     => 0,
    585585            'taxonomy'    => 'topic-tag',
     586            'class'       => 'button',
    586587            'subscribe'   => esc_html__( 'Subscribe to this topic tag', 'wporg-forums' ),
    587588            'unsubscribe' => esc_html__( 'Unsubscribe from this topic tag', 'wporg-forums' ),
     589            'js_confirm'  => esc_html__( 'Are you sure you wish to subscribe by email to all future topics created in this tag?', 'wporg-forums' ),
    588590        ), 'get_term_subscription_link' );
    589591        if ( empty( $r['user_id'] ) || empty( $r['term_id'] ) || empty( $r['taxonomy'] ) ) {
     
    596598
    597599        $url = self::get_subscription_url( $r['user_id'], $r['term_id'], $r['taxonomy'] );
    598         $text = $r['subscribe'];
    599600        if ( self::is_user_subscribed_to_term( $r['user_id'], $r['term_id'] ) ) {
    600             $text = $r['unsubscribe'];
    601         }
    602         return sprintf( "<div class='wporg-bbp-term-subscription'><a href='%s'>%s</a></div>",
     601            $text       = $r['unsubscribe'];
     602            $js_confirm = '';
     603        } else {
     604            $text       = $r['subscribe'];
     605            $js_confirm = 'javascript:return confirm(' . json_encode( $r['js_confirm'] ) . ');';
     606        }
     607
     608        return sprintf(
     609            "<div class='wporg-bbp-term-subscription'><a href='%s' class='%s' onclick='%s'>%s</a></div>",
    603610            $url,
    604             esc_html( $text ) );
     611            esc_attr( $r['class'] ),
     612            esc_attr( $js_confirm ),
     613            esc_html( $text )
     614        );
    605615    }
    606616
Note: See TracChangeset for help on using the changeset viewer.