WordPress.org

Making WordPress.org

Changeset 10124


Ignore:
Timestamp:
08/06/2020 08:31:07 AM (7 weeks ago)
Author:
dd32
Message:

Plugin Directory: Convert Plugin Approved/Rejected emails over to the new Email class.

Additionally, this causes rejected emails not to be sent to blocked users and updates the text slightly.
Props Ipstenu.

See #5351.
Fixes #5354.

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

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php

    r10023 r10124  
    66use WordPressdotorg\Plugin_Directory\Tools\SVN;
    77use WordPressdotorg\Plugin_Directory\Tools\Filesystem;
     8use WordPressdotorg\Plugin_Directory\Email\Plugin_Approved as Plugin_Approved_Email;
     9use WordPressdotorg\Plugin_Directory\Email\Plugin_Rejected as Plugin_Rejected_Email;
    810
    911/**
     
    236238
    237239        // Send email.
    238         $subject = sprintf( __( '[WordPress Plugin Directory] %s has been approved!', 'wporg-plugins' ), $post->post_title );
    239 
    240         /* translators: 1: plugin name, 2: plugin author's username, 3: plugin slug */
    241         $content = sprintf(
    242             __(
    243                 'Congratulations, your plugin hosting request for %1$s has been approved.
    244 
    245 Within one (1) hour your account will be granted commit access to your Subversion (SVN) repository. Your username is %2$s and your password is the one you already use to log in to WordPress.org. Keep in mind, your username is case sensitive and you cannot use your email address to log in to SVN.
    246 
    247 https://plugins.svn.wordpress.org/%3$s
    248 
    249 Once your account has been added, you will need to upload your code using a SVN client of your choice. We are unable to upload or maintain your code for you.
    250 
    251 Using Subversion with the WordPress Plugin Directory:
    252 https://developer.wordpress.org/plugins/wordpress-org/how-to-use-subversion/
    253 
    254 FAQ about the WordPress Plugin Directory:
    255 https://developer.wordpress.org/plugins/wordpress-org/plugin-developer-faq/
    256 
    257 WordPress Plugin Directory readme.txt standard:
    258 https://wordpress.org/plugins/developers/#readme
    259 
    260 A readme.txt validator:
    261 https://wordpress.org/plugins/developers/readme-validator/
    262 
    263 Plugin Assets (header images, etc):
    264 https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/
    265 
    266 WordPress Plugin Directory Guidelines:
    267 https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/
    268 
    269 If you have issues or questions, please reply to this email and let us know.
    270 
    271 Enjoy!
    272 
    273 --
    274 The WordPress Plugin Directory Team
    275 https://make.wordpress.org/plugins', 'wporg-plugins'
    276             ),
    277             $post->post_title,
    278             $plugin_author->user_login,
    279             $post->post_name
    280         );
     240        $email = new Plugin_Approved_Email( $post, $plugin_author );
     241        $email->send();
    281242
    282243        Tools::audit_log( 'Plugin approved.', $post_id );
    283         wp_mail( $plugin_author->user_email, $subject, $content, 'From: plugins@wordpress.org' );
    284244    }
    285245
     
    307267        ) );
    308268
    309         // Send email.
    310         $email   = get_user_by( 'id', $post->post_author )->user_email;
    311         $subject = sprintf( __( '[WordPress Plugin Directory] %s has been rejected', 'wporg-plugins' ), $post->post_title );
    312 
    313         /* translators: 1: plugin name, 2: plugin permalink, 3: date of submission, 4: plugins@wordpress.org */
    314         $content = sprintf(
    315             __(
    316                 'Unfortunately your plugin submission for %1$s (%2$s), submitted on %3$s, has been rejected from the WordPress Plugin Directory.
    317 
    318 Plugins are rejected after six months when there has not been significant progress made on the review. If this is not the case for your plugin, you will receive a followup email explaining the reason for this decision within the next 24 hours.
    319 
    320 If you believe this to be in error, please email %4$s with your plugin attached as a zip and explain why you feel your plugin should be accepted.
    321 
    322 --
    323 The WordPress Plugin Directory Team
    324 https://make.wordpress.org/plugins', 'wporg-plugins'
    325             ),
    326             $post->post_title,
    327             $original_permalink,
    328             $submission_date,
    329             'plugins@wordpress.org'
    330         );
    331 
    332269        // Update last_updated to now.
    333270        update_post_meta( $post_id, 'last_updated', gmdate( 'Y-m-d H:i:s' ) );
    334271
    335         // Log rejection.
    336         Tools::audit_log( 'Plugin rejected.', $post_id );
    337 
    338272        // Send email.
    339         wp_mail( $email, $subject, $content, 'From: plugins@wordpress.org' );
     273        $email = new Plugin_Rejected_Email(
     274            $post,
     275            $post->post_author,
     276            [
     277                'slug'            => $original_permalink,
     278                'submission_date' => $submission_date,
     279            ]
     280        );
     281        // ..and log rejection.
     282        if ( $email->send() ) {
     283            Tools::audit_log( 'Plugin rejected.', $post_id );
     284        } else {
     285            Tools::audit_log( 'Plugin rejected. Email not sent.', $post_id );
     286        }
    340287    }
    341288
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/email/class-base.php

    r10121 r10124  
    3131    public function __construct( $plugin, $users, $args = array() ) {
    3232        $this->plugin = Plugin_Directory::get_plugin_post( $plugin );
     33
     34        // Don't cast an object to an array, but rather an array of object.
     35        if ( is_object( $users ) ) {
     36            $users = [ $users ];
     37        }
    3338
    3439        foreach ( (array) $users as $user ) {
     
    109114
    110115        // Blocked users don't need emails.
    111         if ( !empty( $this->user->caps[ 'bbp_blocked'] ) ) {
     116        if ( ! empty( $this->user->caps[ 'bbp_blocked'] ) ) {
    112117            return false;
    113118        }
Note: See TracChangeset for help on using the changeset viewer.