Changeset 11950 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-profiles/profiles.php
- Timestamp:
- 07/07/2022 09:55:43 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-profiles/profiles.php
r11943 r11950 27 27 function register_callbacks() : void { 28 28 // Ignore programmatic actions, only notify for user-initiated actions. 29 if ( empty( $_POST ) || ! is_user_logged_in() ) {29 if ( empty( $_POST ) || ! is_user_logged_in() || ! wp_using_themes() ) { 30 30 return; 31 31 } … … 40 40 */ 41 41 function add_single_translation_activity( GP_Translation $new_translation, GP_Translation $previous_translation = null ) : void { 42 $bulk_request = gp_post( 'bulk', null ); 43 $import_request = isset( $_FILES['import-file'] ); 44 45 // Bulk actions are handled by `add_bulk_translation_activity()`. Importing is blocked by 46 // https://github.com/GlotPress/GlotPress/issues/1467. 47 if ( $bulk_request || $import_request ) { 48 return; 49 } 50 51 if ( ! get_userdata( $new_translation->user_id ) ) { 42 if ( ! should_notify( $new_translation->user_id ) ) { 52 43 return; 53 44 } … … 86 77 87 78 Profiles_API\api( $request_body ); 79 } 80 81 /** 82 * Determine if a notification should be sent for the current `gp_translation_{created|saved}` action. 83 * 84 * This isn't needed for `gp_translation_set_bulk_action_post` callbacks, since that only gets triggered by the 85 * normal UI flow. 86 */ 87 function should_notify( int $user_id ) : bool { 88 $notify = true; 89 90 /* 91 * `GP_Route_Translation::translations_post()` runs at `template_redirect:10`, and processes user-initiated 92 * actions. After that point, other code -- like 93 * `WordPressdotorg\GlotPress\Plugin_Directory\Sync\Translation_Sync\sync_translations` -- may create 94 * translations programmatically. 95 */ 96 if ( did_action( 'get_header' ) || did_action( 'shutdown' ) ) { 97 $notify = false; 98 } 99 100 $bulk_request = gp_post( 'bulk', null ); 101 $import_request = isset( $_FILES['import-file'] ); 102 103 // Bulk actions are handled by `add_bulk_translation_activity()`. Importing is blocked by 104 // https://github.com/GlotPress/GlotPress/issues/1467. 105 if ( $bulk_request || $import_request ) { 106 $notify = false; 107 } 108 109 if ( ! get_userdata( $user_id ) ) { 110 $notify = false; 111 } 112 113 return $notify; 88 114 } 89 115
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)