From 00c625aadc48a164f4a0ab2370947d5dd9ff8e54 Mon Sep 17 00:00:00 2001 From: paulkirspuu Date: Fri, 29 Dec 2023 12:18:54 +0200 Subject: [PATCH 1/2] refactor(includes): logging-functions exclude wp_login action from logging GH repo version vs live is different, my proposed version is what would go live. We should probably first update repo, recommit and go from there. For now commited so we can move fast with what's important. --- includes/logging-functions.php | 41 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/includes/logging-functions.php b/includes/logging-functions.php index 9eb3f740..448bbb1d 100644 --- a/includes/logging-functions.php +++ b/includes/logging-functions.php @@ -22,32 +22,27 @@ function badgeos_post_log_entry( $object_id, $user_id = 0, $action = 'unlocked', $title = '' ) { + if ( false !== strpos( $title, 'wp_login' ) ) { + return 0; + } + // Get the current user if no ID specified + if ( empty( $user_id ) ) + $user_id = get_current_user_id(); - $plugin_setts = badgeos_utilities::get_option( 'badgeos_settings' ); - $log_post_id = 0; - - if( isset( $plugin_setts['log_entries'] ) ) { - if ('enabled' == $plugin_setts['log_entries']) { - // Get the current user if no ID specified - if (empty($user_id)) - $user_id = get_current_user_id(); - - // Setup our args to easily pass through a filter - $args = array( - 'user_id' => $user_id, - 'action' => $action, - 'object_id' => $object_id, - 'title' => $title - ); + // Setup our args to easily pass through a filter + $args = array( + 'user_id' => $user_id, + 'action' => $action, + 'object_id' => $object_id, + 'title' => $title + ); - // Write log entry via filter so it can be modified by third-parties - $log_post_id = apply_filters('badgeos_post_log_entry', 0, $args); + // Write log entry via filter so it can be modified by third-parties + $log_post_id = apply_filters( 'badgeos_post_log_entry', 0, $args ); - // Available action for other processes - do_action('badgeos_create_log_entry', $log_post_id, $object_id, $user_id, $action); - } - } + // Available action for other processes + do_action( 'badgeos_create_log_entry', $log_post_id, $object_id, $user_id, $action ); return $log_post_id; } @@ -118,4 +113,4 @@ function add_clear_log_button( $which ) { } } } -add_action( 'manage_posts_extra_tablenav', 'add_clear_log_button' ); \ No newline at end of file +add_action( 'manage_posts_extra_tablenav', 'add_clear_log_button' ); From 4c9627b7c4586bbbbb55e3c15c1b17e472b7e5d7 Mon Sep 17 00:00:00 2001 From: paulkirspuu Date: Fri, 12 Jan 2024 14:00:13 +0200 Subject: [PATCH 2/2] refactor(includes): logging-functions stop empty meta logging Note: GH repo version vs live is different, my proposed version is what matches live. --- includes/logging-functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/logging-functions.php b/includes/logging-functions.php index 448bbb1d..023253f6 100644 --- a/includes/logging-functions.php +++ b/includes/logging-functions.php @@ -41,8 +41,10 @@ function badgeos_post_log_entry( $object_id, $user_id = 0, $action = 'unlocked', // Write log entry via filter so it can be modified by third-parties $log_post_id = apply_filters( 'badgeos_post_log_entry', 0, $args ); - // Available action for other processes - do_action( 'badgeos_create_log_entry', $log_post_id, $object_id, $user_id, $action ); + if ( $object_id ) { + // Available action for other processes + do_action( 'badgeos_create_log_entry', $log_post_id, $object_id, $user_id, $action ); + } return $log_post_id; }