Changeset 9682
- Timestamp:
- 04/02/2020 02:23:28 AM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-status-transitions.php
r9094 r9682 280 280 ); 281 281 282 $this->audit_log( 'Plugin approved.', $post_id );282 Tools::audit_log( 'Plugin approved.', $post_id ); 283 283 wp_mail( $plugin_author->user_email, $subject, $content, 'From: plugins@wordpress.org' ); 284 284 } … … 322 322 ); 323 323 324 $this->audit_log( 'Plugin rejected.', $post_id );324 Tools::audit_log( 'Plugin rejected.', $post_id ); 325 325 wp_mail( $email, $subject, $content, 'From: plugins@wordpress.org' ); 326 326 } … … 362 362 $post = get_post( $post_id ); 363 363 if ( $post && 'approved' != $post->post_status ) { 364 $this->audit_log( 'Plugin reopened.', $post_id );364 Tools::audit_log( 'Plugin reopened.', $post_id ); 365 365 } 366 366 } … … 385 385 update_post_meta( $post_id, 'plugin_closed_date', current_time( 'mysql' ) ); 386 386 387 $this->audit_log( sprintf( 'Plugin closed. Reason: %s', $close_reason ), $post_id );387 Tools::audit_log( sprintf( 'Plugin closed. Reason: %s', $close_reason ), $post_id ); 388 388 } 389 389 … … 406 406 $new_owner = get_userdata( $post_after->post_author ); 407 407 408 $this->audit_log( sprintf(408 Tools::audit_log( sprintf( 409 409 'Ownership transferred to <a href="%s">%s</a>.', 410 esc_url( ' //profiles.wordpress.org/' . $new_owner->user_nicename),410 esc_url( 'https://profiles.wordpress.org/' . $new_owner->user_nicename .'/' ), 411 411 $new_owner->user_login 412 412 ), $post_id ); 413 413 } 414 414 415 /**416 * Saves an audit_log comment for the plugin.417 *418 * @param string $message The message for the audit log.419 * @param integer $post_id The Post ID.420 */421 public function audit_log( $message, $post_id ) {422 $user = wp_get_current_user();423 424 $comment = array(425 'comment_author' => $user->display_name,426 'comment_author_email' => $user->user_email,427 'comment_author_url' => $user->user_url,428 'comment_type' => 'internal-note',429 'comment_post_ID' => $post_id,430 'user_id' => get_current_user_id(),431 'comment_content' => $message,432 );433 wp_insert_comment( $comment );434 }435 415 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-internal-notes.php
r6403 r9682 47 47 * @param string $action Action to perform. 48 48 */ 49 function get_notes( $action ) {49 public static function get_notes( $action ) { 50 50 global $post_id; 51 51 if ( empty( $action ) ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin-self-close.php
r9674 r9682 74 74 75 75 // Add an audit-log entry as to why this has happened. 76 $user = wp_get_current_user(); 77 wp_insert_comment( [ 78 'comment_author' => $user->display_name, 79 'comment_author_email' => $user->user_email, 80 'comment_author_url' => $user->user_url, 81 'comment_type' => 'internal-note', 82 'comment_post_ID' => $plugin->ID, 83 'user_id' => get_current_user_id(), 84 'comment_content' => sprintf( 'Plugin closed. Reason: Author Self-close Request from %s', $_SERVER['REMOTE_ADDR'] ), 85 ] ); 76 Tools::audit_log( 77 $plugin, 78 sprintf( 'Plugin closed. Reason: Author Self-close Request from %s', $_SERVER['REMOTE_ADDR'] ) 79 ); 86 80 87 81 // Email all Plugin Committers. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
r9650 r9682 197 197 Tools::sync_plugin_committers_with_taxonomy( $plugin_slug ); 198 198 199 Tools::audit_log( 200 sprintf( 201 'Added <a href="%s">%s</a> as a committer.', 202 esc_url( 'https://profiles.wordpress.org/' . $user->user_nicename . '/' ), 203 $user->user_login 204 ), 205 $plugin_slug 206 ); 207 199 208 return $result; 200 209 } … … 229 238 wp_cache_delete( $user->user_login, 'committer-plugins' ); 230 239 Tools::sync_plugin_committers_with_taxonomy( $plugin_slug ); 240 241 Tools::audit_log( 242 sprintf( 243 'Removed <a href="%s">%s</a> as a committer.', 244 esc_url( 'https://profiles.wordpress.org/' . $user->user_nicename . '/' ), 245 $user->user_login 246 ), 247 $plugin_slug 248 ); 231 249 232 250 return $result; … … 326 344 wp_cache_delete( $user->user_nicename, 'support-rep-plugins' ); 327 345 346 Tools::audit_log( 347 sprintf( 348 'Added <a href="%s">%s</a> as a support rep.', 349 esc_url( 'https://profiles.wordpress.org/' . $user->user_nicename . '/' ), 350 $user->user_login 351 ), 352 $plugin_slug 353 ); 354 328 355 return $result; 329 356 } … … 357 384 wp_cache_delete( $plugin_slug, 'plugin-support-reps' ); 358 385 wp_cache_delete( $user->user_nicename, 'support-rep-plugins' ); 386 387 Tools::audit_log( 388 sprintf( 389 'Removed <a href="%s">%s</a> as a support rep.', 390 esc_url( 'https://profiles.wordpress.org/' . $user->user_nicename . '/' ), 391 $user->user_login 392 ), 393 $plugin_slug 394 ); 359 395 360 396 return $result; … … 557 593 } 558 594 } 595 596 /** 597 * Add an Audit Internal Note for a plugin. 598 * 599 * @param int|string|WP_Post $plugin A Post ID, Plugin Slug or, WP_Post object. 600 * @param string $note The note to audit log entry to add. 601 * @param WP_User $user The user which performed the action. Optional. 602 */ 603 public static function audit_log( $note, $plugin = null, $user = false ) { 604 if ( is_string( $plugin ) && ! is_numeric( $plugin ) ) { 605 $plugin = Plugin_Directory::get_plugin_post( $plugin ); 606 } else { 607 $plugin = get_post( $plugin ); 608 } 609 610 if ( ! $note || ! $plugin ) { 611 return false; 612 } 613 if ( ! $user || ! ( $user instanceof \WP_User ) ) { 614 $user = wp_get_current_user(); 615 } 616 617 return wp_insert_comment( [ 618 'comment_author' => $user->display_name, 619 'comment_author_email' => $user->user_email, 620 'comment_author_url' => $user->user_url, 621 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 622 'comment_type' => 'internal-note', 623 'comment_post_ID' => $plugin->ID, 624 'user_id' => $user->ID, 625 'comment_content' => $note, 626 ] ); 627 } 559 628 }
Note: See TracChangeset
for help on using the changeset viewer.