Making WordPress.org


Ignore:
Timestamp:
06/20/2016 04:37:50 PM (9 years ago)
Author:
dd32
Message:

Plugin Directory: Allow a user to subscribe/unsubscribe from plugin commit emails.

Note: Plugin committers are automatically subscribed, and cannot unsubscribe.

See #1597

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-developers.php

    r3435 r3510  
    3232        $output .= '</ul>';
    3333
     34        if ( is_user_logged_in() ) {
     35            $subscribed = Tools::subscribed_to_plugin_commits( $post, get_current_user_id() );
     36
     37            $subscribe_change_url = esc_url( add_query_arg(
     38                array(
     39                    '_wpnonce' => wp_create_nonce( 'wp_rest' ),
     40                    ( $subscribed ? 'unsubscribe' : 'subscribe' ) => '1'
     41                ),
     42                home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/commit-subscription' )
     43            ) );
     44        }
     45
    3446        return $output .
    3547            '<h5>' . __( 'Browse the code', 'wporg-plugins' ) . '</h5>' .
     
    3749                '<li>' .
    3850                    '<a href="' . esc_url( "https://plugins.trac.wordpress.org/log/{$post->post_name}/" ) . '" rel="nofollow">' . __( 'Development Log', 'wporg-plugins' ) . '</a>' . "\n" .
    39                     '<a href="' . esc_url( "https://plugins.trac.wordpress.org/log/{$post->post_name}/?limit=100&mode=stop_on_copy&format=rss" ) . '" rel="nofollow"><img src="//s.w.org/style/images/feedicon.png" /></a>' .
     51                    '<a href="' . esc_url( "https://plugins.trac.wordpress.org/log/{$post->post_name}/?limit=100&mode=stop_on_copy&format=rss" ) . '" rel="nofollow"><img src="https://s.w.org/style/images/feedicon.png" /></a>' .
    4052                '</li>' .
    4153                '<li><a href="' . esc_url( "https://plugins.svn.wordpress.org/{$post->post_name}/" ) . '" rel="nofollow">' . __( 'Subversion Repository', 'wporg-plugins' ) . '</a></li>' .
    4254                '<li><a href="' . esc_url( "https://plugins.trac.wordpress.org/browser/{$post->post_name}/" ) . '" rel="nofollow">' . __( 'Browse in Trac', 'wporg-plugins' ) . '</a></li>' .
    4355                '<li><a href="' . esc_url( "https://translate.wordpress.org/projects/wp-plugins/{$post->post_name}/" ) . '" rel="nofollow">' . __( 'Translation Contributors', 'wporg-plugins' ) . '</a></li>' .
     56                 ( !is_user_logged_in() ? '' : (
     57                    $subscribed ?
     58                    "<li><a href='$subscribe_change_url'>" . __( 'Unsubscribe from plugin commits', 'wporg-plugins' ) . '</a></li>' :
     59                    "<li><a href='$subscribe_change_url'>" . __( 'Subscribe to plugin commits via email', 'wporg-plugins' ) . '</a></li>'
     60                 ) ) .
    4461            '</ul>';
    4562    }
Note: See TracChangeset for help on using the changeset viewer.