Changeset 11943 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-profiles/profiles.php
- Timestamp:
- 07/06/2022 05:47:25 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
r11942 r11943 23 23 } 24 24 25 add_action( 'gp_translation_created', __NAMESPACE__ . '\add_single_translation_activity' ); 26 add_action( 'gp_translation_saved', __NAMESPACE__ . '\add_single_translation_activity', 10, 2 ); 27 add_action( 'gp_translation_set_bulk_action_post', __NAMESPACE__ . '\add_bulk_translation_activity', 10, 4 ); 25 add_action( 'plugins_loaded', __NAMESPACE__ . '\register_callbacks' ); 26 27 function register_callbacks() : void { 28 // Ignore programmatic actions, only notify for user-initiated actions. 29 if ( empty( $_POST ) || ! is_user_logged_in() ) { 30 return; 31 } 32 33 add_action( 'gp_translation_created', __NAMESPACE__ . '\add_single_translation_activity' ); 34 add_action( 'gp_translation_saved', __NAMESPACE__ . '\add_single_translation_activity', 10, 2 ); 35 add_action( 'gp_translation_set_bulk_action_post', __NAMESPACE__ . '\add_bulk_translation_activity', 10, 4 ); 36 } 28 37 29 38 /** … … 51 60 52 61 /* 62 * Regular user is suggesting a string. 63 * 53 64 * `GP_Route_Translation::translations_post` saves the translation as `waiting` for all users. Then, if the 54 * user is an editor, it saves it second time to update the status to `current`. We can ignore the first save55 * since two avoid two bumps for a single action.65 * user is an editor, it saves it a second time to update the status to `current`. We can ignore the first save, 66 * to avoid two notifications for a single action. 56 67 */ 57 68 if ( 'waiting' === $new_translation->status && ! $current_user_is_editor ) { 58 69 $type = 'glotpress_translation_suggested'; 59 } elseif ( 'current' === $new_translation->status && 'current' !== $previous_translation->status ) { 70 71 // Editor is approving a suggested string. 72 // Avoid sending a notification when a `current` post is re-saved, like when dismissing warnings. 73 } elseif ( 'current' === $new_translation->status && isset( $previous_translation->status ) && 'current' !== $previous_translation->status ) { 60 74 $type = 'glotpress_translation_approved'; 75 61 76 } else { 62 77 return;
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)