Changeset 11943
- Timestamp:
- 07/06/2022 05:47:25 PM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-profiles
- Files:
-
- 2 edited
-
profiles.php (modified) (2 diffs)
-
tests/e2e.php (modified) (1 diff)
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; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-profiles/tests/e2e.php
r11938 r11943 47 47 GlotPress_Profiles\add_single_translation_activity( $translation ); 48 48 49 $previous_translation = new GP_Translation( array( 50 'user_id' => $user->ID, 51 'status' => 'waiting', 52 ) ); 49 53 $translation = new GP_Translation( array( 50 54 'user_id' => $user->ID, 51 55 'status' => 'current', 52 56 ) ); 53 GlotPress_Profiles\add_single_translation_activity( $translation );57 GlotPress_Profiles\add_single_translation_activity( $translation, $previous_translation ); 54 58 55 59 echo "\nThe daily digest count should have been bumped on https://profiles.wordpress.org/$user->user_nicename/ \n";
Note: See TracChangeset
for help on using the changeset viewer.