Skip to content

Commit

Permalink
Merge pull request #539 from WPWhiteSecurity/develop
Browse files Browse the repository at this point in the history
Release 4.1.3.2
  • Loading branch information
DannyWPWS authored Aug 14, 2020
2 parents cf9bc65 + 6decb9a commit 2838a8a
Show file tree
Hide file tree
Showing 22 changed files with 21,004 additions and 2,592 deletions.
2 changes: 1 addition & 1 deletion classes/Adapters/MySQL/ActiveRecordAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ public function GetReportGrouped( $_site_id, $_start_timestamp, $_end_timestamp,
AND (@endTimestamp is NULL OR occ.created_on <= @endTimestamp)
AND (@ipAddress is NULL OR (meta.name = 'ClientIP' AND find_in_set(meta.value, @ipAddress) > 0))
HAVING user_login IS NOT NULL) ip_logins
WHERE user_login NOT IN ('Website Visitor', 'Plugins', 'Plugin')
WHERE user_login NOT IN ('Unregistered user', 'Plugins', 'Plugin')
ORDER BY user_login ASC
";
$_wpdb->query( "SET @siteId = $_site_id" );
Expand Down
4 changes: 2 additions & 2 deletions classes/AlertManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,8 @@ public function get_event_user_data( $username ) {
$user_data->username = 'Plugin';
} elseif ( 'Plugins' === $username ) {
$user_data->username = 'Plugins';
} elseif ( 'Website Visitor' === $username ) {
$user_data->username = 'Website Visitor';
} elseif ( 'Website Visitor' === $username || 'Unregistered user' === $username ) {
$user_data->username = 'Unregistered user';
} else {
// Check WP user.
if ( isset( $this->wp_users[ $username ] ) ) {
Expand Down
4 changes: 2 additions & 2 deletions classes/AuditLogGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ public function column_default( $item, $column_name ) {
} elseif ( 'Plugins' == $username ) {
$uhtml = '<i>' . __( 'Plugins', 'wp-security-audit-log' ) . '</i>';
$roles = '';
} elseif ( 'Website Visitor' == $username ) {
$uhtml = '<i>' . __( 'Website Visitor', 'wp-security-audit-log' ) . '</i>';
} elseif ( 'Website Visitor' == $username || 'Unregistered user' == $username ) {
$uhtml = '<i>' . __( 'Unregistered user', 'wp-security-audit-log' ) . '</i>';
$roles = '';
} else {
$uhtml = '<i>' . __( 'System', 'wp-security-audit-log' ) . '</i>';
Expand Down
4 changes: 2 additions & 2 deletions classes/AuditLogListView.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ public function column_default( $item, $column_name ) {
$image = '<span class="dashicons dashicons-wordpress wsal-system-icon"></span>';
$uhtml = '<i>' . __( 'Plugins', 'wp-security-audit-log' ) . '</i>';
$roles = '';
} elseif ( 'Website Visitor' == $username ) {
} elseif ( 'Website Visitor' == $username || 'Unregistered user' == $username ) {
$image = '<span class="dashicons dashicons-wordpress wsal-system-icon"></span>';
$uhtml = '<i>' . __( 'Website Visitor', 'wp-security-audit-log' ) . '</i>';
$uhtml = '<i>' . __( 'Unregistered user', 'wp-security-audit-log' ) . '</i>';
$roles = '';
} else {
$image = '<span class="dashicons dashicons-wordpress wsal-system-icon"></span>';
Expand Down
4 changes: 2 additions & 2 deletions classes/Sensors/FrontendSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function event_404() {
$ip = $this->plugin->settings()->GetMainClientIP();

if ( ! is_user_logged_in() ) {
$username = 'Website Visitor';
$username = 'Unregistered user';
} else {
$username = wp_get_current_user()->user_login;
}
Expand All @@ -67,7 +67,7 @@ public function event_404() {
return;
}

if ( 'Website Visitor' === $username ) {
if ( 'Website Visitor' === $username || 'Unregistered user' === $username ) {
// Check if the alert is disabled from the "Enable/Disable Alerts" section.
if ( ! $this->plugin->alerts->IsEnabled( 6023 ) ) {
return;
Expand Down
4 changes: 2 additions & 2 deletions classes/Sensors/FrontendWooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function product_stock_changed( $product ) {
// Set username.
$username = '';
if ( ! is_user_logged_in() ) {
$username = 'Website Visitor';
$username = 'Unregistered user';
} else {
$username = wp_get_current_user()->user_login;
}
Expand All @@ -174,7 +174,7 @@ public function product_stock_changed( $product ) {
$wc_all_stock_changes = $this->plugin->GetGlobalBooleanSetting( 'wc-all-stock-changes', true );

// If stock has changed then trigger the alert.
if ( ( $old_stock !== $new_stock ) && ( 'on' === $wc_all_stock_changes ) ) {
if ( ( $old_stock !== $new_stock ) && ( $wc_all_stock_changes ) ) {
$editor_link = $this->get_editor_link( $post );

// Check if this was done via an order by looking for event 9035.
Expand Down
8 changes: 7 additions & 1 deletion classes/Sensors/MetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public function EventPostMetaCreated( $object_id, $meta_key, $meta_value ) {
return;
}

// Remove WC coupons from ignored array.
if ( ( $key = array_search( 'shop_coupon', $this->plugin->alerts->ignored_cpts ) ) !== false) {
unset( $this->plugin->alerts->ignored_cpts[$key] );
}

// Ignore updates from ignored custom post types.
if ( in_array( $post->post_type, $this->plugin->alerts->ignored_cpts, true ) ) {
return;
Expand All @@ -108,6 +113,7 @@ public function EventPostMetaCreated( $object_id, $meta_key, $meta_value ) {
* @param WP_Post $post - Post object.
*/
$log_meta_event = apply_filters( 'wsal_before_post_meta_create_event', true, $meta_key, $meta_value, $post );

if ( $log_meta_event ) {
$editor_link = $this->GetEditorLink( $post );
$this->plugin->alerts->Trigger(
Expand Down Expand Up @@ -304,7 +310,7 @@ public function EventPostMetaDeleted( $meta_ids, $object_id, $meta_key, $meta_va
if ( in_array( $post->post_type, $this->plugin->alerts->ignored_cpts, true ) ) {
return;
}

// If not allowed to log meta event then skip it.
if ( ! $log_meta_event ) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions classes/Sensors/Public.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public function product_stock_changed( $product ) {
// Set username.
$username = '';
if ( ! is_user_logged_in() ) {
$username = 'Website Visitor';
$username = 'Unregistered user';
} else {
$username = wp_get_current_user()->user_login;
}
Expand All @@ -358,7 +358,7 @@ public function product_stock_changed( $product ) {
$wc_all_stock_changes = $this->plugin->GetGlobalBooleanSetting( 'wc-all-stock-changes', true );

// If stock has changed then trigger the alert.
if ( ( $old_stock !== $new_stock ) && ( 'on' === $wc_all_stock_changes ) ) {
if ( ( $old_stock !== $new_stock ) && ( $wc_all_stock_changes ) ) {
$editor_link = $this->get_editor_link( $post );

// Check if this was done via an order by looking for event 9035.
Expand Down
4 changes: 2 additions & 2 deletions classes/Sensors/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function Event404() {
$ip = $this->plugin->settings()->GetMainClientIP();

if ( ! is_user_logged_in() ) {
$username = 'Website Visitor';
$username = 'Unregistered user';
} else {
$username = wp_get_current_user()->user_login;
}
Expand All @@ -257,7 +257,7 @@ public function Event404() {
return;
}

if ( 'Website Visitor' !== $username ) {
if ( 'Unregistered user' !== $username ) {
// Check if the alert is disabled from the "Enable/Disable Alerts" section.
if ( ! $this->plugin->alerts->IsEnabled( 6007 ) ) {
return;
Expand Down
12 changes: 6 additions & 6 deletions classes/Utilities/PluginInstallAndActivate.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ public function render() {
$our_plugins = $this->get_installable_plugins();
?>
<table id="tab-third-party-plugins" class="form-table wp-list-table wsal-tab widefat fixed" style="display: table;" cellspacing="0">
<p class="description"><?php esc_html_e( 'WP Activity Log can keep a log of changes done on other plugins. Install the relevant extension from the below list to keep a log of changes done on that plugin.', 'wp-security-audit-log' ); ?></p>
<tbody>
<tr>
<td class="addon-td">
<p class="description"><?php esc_html_e( 'WP Activity Log can keep a log of changes done on other plugins. Install the relevant extension from the below list to keep a log of changes done on that plugin.', 'wp-security-audit-log' ); ?></p></br>
<?php
// Create a nonce to pass through via data attr.
$nonce = wp_create_nonce( 'wsal-install-addon' );
Expand Down Expand Up @@ -132,7 +132,7 @@ public static function get_installable_plugins() {
$plugins = array(
array(
'addon_for' => 'bbpress',
'title' => 'BBPress Extension',
'title' => 'BBPress',
'image_filename' => 'bbpress.png',
'plugin_slug' => 'wp-security-audit-log-add-on-for-bbpress/wsal-bbpress.php',
'plugin_url' => 'https://downloads.wordpress.org/plugin/wp-security-audit-log-add-on-for-bbpress.latest-stable.zip',
Expand All @@ -141,21 +141,21 @@ public static function get_installable_plugins() {
),
array(
'addon_for' => 'wpforms',
'title' => 'WPForms Extension',
'title' => 'WPForms',
'image_filename' => 'wpforms.png',
'plugin_slug' => 'wp-security-audit-log-add-on-for-wpforms/wsal-wpforms.php',
'plugin_url' => 'https://downloads.wordpress.org/plugin/wp-security-audit-log-add-on-for-wpforms.latest-stable.zip',
'event_tab_id' => '#tab-wpforms',
'plugin_description' => 'Keep a record of when someone adds, modified or delete forms, entries and more in the WPForms plugin.',
'plugin_description' => 'Keep a record of when someone adds, modifies or deletes forms, entries and more in the WPForms plugin.',
),
array(
'addon_for' => 'woocommerce',
'title' => 'WooCommerce Extension',
'title' => 'WooCommerce',
'image_filename' => 'woocommerce.png',
'plugin_slug' => 'wp-activity-log-for-woocommerce/wsal-woocommerce.php',
'plugin_url' => 'https://downloads.wordpress.org/plugin/wp-activity-log-for-woocommerce.latest-stable.zip',
'event_tab_id' => '#tab-woocommerce',
'plugin_description' => 'Keep a record of when someone adds, modified or delete products, orders and more in the WooCommerce plugin.',
'plugin_description' => 'Keep a log of your team\'s store settings, products, orders, coupons and any other changes they might do on your eCommerce store.',
),
array(
'addon_for' => 'wfcm',
Expand Down
29 changes: 19 additions & 10 deletions classes/Views/AuditLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,27 +247,36 @@ public function AdminNoticesPremium() {
$screen = get_current_screen();
$notice_already_dismissed = $this->_plugin->GetGlobalSetting( 'addon_available_notice_dismissed' );
if ( $screen->base === 'toplevel_page_wsal-auditlog' && $is_current_view && ! $notice_already_dismissed || $screen->base === 'toplevel_page_wsal-auditlog-network' && $is_current_view && ! $notice_already_dismissed ) {
$addons_available = $this->_plugin->GetGlobalSetting( 'installed_plugin_addon_available' );
$all_plugins = get_plugins();
$all_plugins = array_keys( $all_plugins );
// Grab list of installed plugins.
$all_plugins = get_plugins();
$plugin_filenames = array();
foreach ( $all_plugins as $plugin => $info ) {
// here we strip all of the plugin slug, leaving just the filename itself. Neat!
$plugin_filenames[] = preg_replace( '/\\.[^.\\s]{3,4}$/', '', substr( basename( json_encode( $plugin ) ), 0, -1 ) );
}

// Grab list of plugins we have addons for.
$predefined_plugins = WSAL_PluginInstallAndActivate::get_installable_plugins();
$predefined_plugins_slugs = array_column( $predefined_plugins, 'plugin_slug' );
$is_addon_installed = array_intersect( $all_plugins, $predefined_plugins_slugs );
$predefined_plugins_check = array_column( $predefined_plugins, 'addon_for' );

// Loop through plugins and create an array of slugs, we will compare these agains the plugins we have addons for.
$we_have_addon = array_intersect( $plugin_filenames, $predefined_plugins_check );

$display_notice = false;

if ( isset( $addons_available ) && is_array( $addons_available ) ) {
if ( isset( $we_have_addon ) && is_array( $we_have_addon ) ) {
$addon_names = '';
$i = 0;
foreach ( $addons_available as $addon ) {
$addon_slug = array( array_search( $addon, array_column( $predefined_plugins, 'addon_for', 'plugin_slug' ) ) );
$is_addon_installed = array_intersect( $all_plugins, $addon_slug );
foreach ( $we_have_addon as $addon ) {
$addon_slug = array_search( $addon, array_column( $predefined_plugins, 'addon_for', 'plugin_slug' ) );
$is_addon_installed = is_plugin_active( $addon_slug );

// Check if a function from the addon exists, just in case.
if ( $addon === 'wpforms' && function_exists( 'wsal_wpforms_init_actions' ) || $addon === 'bbpress' && function_exists( 'wsal_bbpress_init_actions' ) ) {
continue;
}

if ( empty( $is_addon_installed ) ) {
if ( ! $is_addon_installed ) {
$addon = str_replace( '-', ' ', $addon);
if ( $addon === 'bbpress' ) {
$addon = 'bbPress';
Expand Down
6 changes: 4 additions & 2 deletions classes/Views/ToggleAlerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function Render() {
$is_custom = ! empty( $events_diff ) ? true : false; // If difference is not empty then mode is custom.
$log_details = $this->_plugin->GetGlobalSetting( 'details-level', false ); // Get log level option.

$subcat_alerts = array( 1004, 2010, 2111, 9007, 9047 );
$subcat_alerts = array( 1004, 2010, 2111, 9007, 9105, 9047 );
$obsolete_events = array( 9999, 2126, 6023, 9011, 9070, 9075, 4013 );
?>
<p>
Expand Down Expand Up @@ -408,6 +408,8 @@ class="nav-tab"
esc_html_e( 'Post Settings', 'wp-security-audit-log' );
} elseif ( 9007 === $alert->type ) {
esc_html_e( 'Product Admin', 'wp-security-audit-log' );
} elseif ( 9105 === $alert->type ) {
esc_html_e( 'Product Stock Changes', 'wp-security-audit-log' );
} elseif ( 9047 === $alert->type ) {
esc_html_e( 'Product Attributes', 'wp-security-audit-log' );
}
Expand Down Expand Up @@ -527,7 +529,7 @@ class="alert"
<tr>
<td></td>
<td>
<input name="wc_all_stock_changes" type="checkbox" id="wc_all_stock_changes" value="1" <?php checked( $wc_all_stock_changes, 'on' ); ?> />
<input name="wc_all_stock_changes" type="checkbox" id="wc_all_stock_changes" value="1" <?php checked( $wc_all_stock_changes ); ?> />
</td>
<td colspan="2"><?php esc_html_e( 'Log all stock changes. Disable this setting to only keep a log of stock changes done manually via the WooCommerce dashboard. Therefore automated stock changes typically done via customers placing orders or via other plugins will not be logged.', 'wp-security-audit-log' ); ?></td>
</tr>
Expand Down
Loading

0 comments on commit 2838a8a

Please sign in to comment.