Skip to content

Commit

Permalink
Merge pull request #321 from threadi/feature/optimizedUsageOnPosition…
Browse files Browse the repository at this point in the history
…Deletion

optimized usage on position deletion via WP CLI
  • Loading branch information
threadi authored Dec 18, 2024
2 parents 1e911b9 + d3e57e5 commit d81ce62
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/PersonioIntegration/PostTypes/PersonioPosition.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ public function delete( int $post_id ): void {
$user = wp_get_current_user();

// if no user could be found, check if we are running on WP CLI.
if ( empty( $user ) ) {
if ( is_null( $user ) ) {
$username = 'WP CLI';
} else {
$username = $user->display_name;
Expand Down Expand Up @@ -1786,9 +1786,16 @@ public function delete_positions(): void {
// get current user for logging.
$user = wp_get_current_user();

if( is_null( $user ) ) {
$username = 'WP CLI';
}
else {
$username = $user->display_name;
}

// log this event.
$logs = new Log();
$logs->add_log( sprintf( 'Positions has been deleted by %1$s.', esc_html( $user->display_name ) ), 'success', 'import' );
$logs->add_log( sprintf( 'Positions has been deleted by %1$s.', esc_html( $username ) ), 'success', 'import' );

/**
* Run custom actions after deletion of all positions has been done.
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- plugin version number is now automatically generated in readme.txt during plugin release build
- Cleaned up third party support from unused code
- Moved changelog from readme.txt in GitHub-repository
- Optimized documentation of deleted position via WP CLI
- Extended help for debug mode
- Colored the helper tab for better visibility

Expand Down

0 comments on commit d81ce62

Please sign in to comment.