Changeset 13107
- Timestamp:
- 01/15/2024 02:40:00 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/bin/bounced-emails.php
r12762 r13107 61 61 if ( 'live' == OPERATION_MODE ) { 62 62 echo "Running in live mode. Changes will be made.\nProceeding in 10s...\n"; 63 sleep( 10 ); 63 64 } else { 64 echo "Running in dry-run mode. No changes will be made. Pass --doit parameter to make changes.\n Proceeding in 10s...\n";65 } 66 sleep( 10 ); 65 echo "Running in dry-run mode. No changes will be made. Pass --doit parameter to make changes.\n"; 66 } 67 67 68 68 69 // Load the HelpScout API helper methods. … … 161 162 'closed' => 0, 162 163 'revoked-commit' => 0, 164 'hs-closed' => 0, 163 165 ]; 164 166 … … 174 176 */ 175 177 ]; 178 $just_close_it = []; // The HS tickets to just close. 176 179 177 180 foreach ( get_bounces()->_embedded->conversations as $bounce ) { … … 191 194 }, 192 195 $slugs 196 ); 197 198 $closed_plugins = array_filter( 199 $plugins, 200 function( $plugin ) { 201 return 'closed' === get_post_status( $plugin ) || 'disabled' === get_post_status( $plugin ); 202 } 193 203 ); 194 204 … … 219 229 ); 220 230 221 if ( ! $email || ! $user || ! $slugs || ! $plugins) {231 if ( ! $email || ! $user || ! $slugs || ( ! $plugins && ! $closed_plugins ) ) { 222 232 echo "\tNo user or plugins found.\n"; 223 233 $stats['error']++; … … 231 241 echo "\tSingular committer (or owns): " . implode( ', ', wp_list_pluck( $single_committer_plugins, 'post_name' ) ) . "\n"; 232 242 echo "\tJust a committer: " . implode( ', ', wp_list_pluck( $multiple_committer_plugins, 'post_name' ) ) . "\n"; 243 echo "\tClosed plugins: " . implode( ', ', wp_list_pluck( $closed_plugins, 'post_name' ) ) . "\n"; 233 244 234 245 echo "\tBounce Message:\n\t\t> " . ( str_replace( "\n", "\n\t\t> ", $bounce_message ) ?: 'Unable to determine bounce reason' ) . "\n"; … … 239 250 $actions_to_take[ $plugin->ID ]['id'][] = $bounce->id; 240 251 $actions_to_take[ $plugin->ID ]['users'][ $user->ID ] = $bounce_message; 252 } 253 254 if ( ! $plugins && $closed_plugins ) { 255 $just_close_it[] = $bounce->id; 241 256 } 242 257 … … 394 409 } 395 410 411 // Close those HS tickets. 412 foreach ( $just_close_it as $hs_id ) { 413 $stats['hs-closed']++; 414 415 echo "Marking https://secure.helpscout.net/conversation/{$hs_id} as closed as all plugins are closed.\n"; 416 417 if ( 'live' == OPERATION_MODE ) { 418 HelpScout::instance()->api( 419 '/v2/conversations/' . $hs_id, 420 [ 421 'op' => 'replace', 422 'path' => '/status', 423 'value' => 'closed', 424 ], 425 'PATCH' 426 ); 427 } 428 } 429 396 430 echo "\nAll Done! Stats:\n"; 397 431 var_dump( $stats );
Note: See TracChangeset
for help on using the changeset viewer.