Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(includes): logging-functions exclude wp_login action from logging #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 20 additions & 23 deletions includes/logging-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,29 @@


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);
}
}
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;
}
Expand Down Expand Up @@ -118,4 +115,4 @@ function add_clear_log_button( $which ) {
}
}
}
add_action( 'manage_posts_extra_tablenav', 'add_clear_log_button' );
add_action( 'manage_posts_extra_tablenav', 'add_clear_log_button' );