Changeset 9682 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
- Timestamp:
- 04/02/2020 02:23:28 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.