Activity Log - Version 2.3.5

Version Description

  • Fix! - Added comparability for WordPress 4.8.2 & 4.7.6
Download this release

Release Info

Developer KingYes
Plugin Icon 128x128 Activity Log
Version 2.3.5
Comparing to
See all releases

Code changes from version 2.3.4 to 2.3.5

aryo-activity-log.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://wordpress.org/plugins/aryo-activity-log/
5
  Description: Get aware of any activities that are taking place on your dashboard! Imagine it like a black-box for your WordPress site. e.g. post was deleted, plugin was activated, user logged in or logged out - it's all these for you to see.
6
  Author: Yakir Sitbon, Maor Chasen, Ariel Klikstein
7
  Author URI: http://pojo.me/
8
- Version: 2.3.4
9
  Text Domain: aryo-activity-log
10
  License: GPLv2 or later
11
 
5
  Description: Get aware of any activities that are taking place on your dashboard! Imagine it like a black-box for your WordPress site. e.g. post was deleted, plugin was activated, user logged in or logged out - it's all these for you to see.
6
  Author: Yakir Sitbon, Maor Chasen, Ariel Klikstein
7
  Author URI: http://pojo.me/
8
+ Version: 2.3.5
9
  Text Domain: aryo-activity-log
10
  License: GPLv2 or later
11
 
classes/class-aal-activity-log-list-table.php CHANGED
@@ -17,7 +17,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
17
  if ( empty( $this->_allow_caps ) ) {
18
  $user = get_user_by( 'id', get_current_user_id() );
19
  if ( ! $user )
20
- wp_die( 'No allowed here.' );
21
 
22
  $user_cap = strtolower( key( $user->caps ) );
23
  $allow_caps = array();
@@ -34,7 +34,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
34
  $allow_caps = $this->_caps['administrator'];
35
 
36
  if ( empty( $allow_caps ) )
37
- wp_die( 'No allowed here.' );
38
 
39
  $this->_allow_caps = array_unique( $allow_caps );
40
  }
@@ -51,7 +51,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
51
  }
52
 
53
  if ( empty( $allow_modules ) )
54
- wp_die( 'No allowed here.' );
55
 
56
  $allow_modules = array_unique( $allow_modules );
57
 
@@ -258,27 +258,23 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
258
 
259
  echo '<div class="alignleft actions">';
260
 
261
- $users = $wpdb->get_results( $wpdb->prepare(
262
- 'SELECT DISTINCT %1$s FROM `%2$s`
263
  WHERE 1 = 1
264
  ' . $this->_get_where_by_role() . '
265
- GROUP BY `%1$s`
266
- ORDER BY `%1$s`
267
- ;',
268
- 'user_id',
269
- $wpdb->activity_log
270
- ) );
271
 
272
- $types = $wpdb->get_results( $wpdb->prepare(
273
- 'SELECT DISTINCT %1$s FROM `%2$s`
274
  WHERE 1 = 1
275
  ' . $this->_get_where_by_role() . '
276
- GROUP BY `%1$s`
277
- ORDER BY `%1$s`
278
- ;',
279
- 'object_type',
280
- $wpdb->activity_log
281
- ) );
282
 
283
  // Make sure we get items for filter.
284
  if ( $users || $types ) {
@@ -294,7 +290,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
294
  );
295
  echo '<select name="dateshow" id="hs-filter-date">';
296
  foreach ( $date_options as $key => $value )
297
- printf( '<option value="%1$s"%2$s>%3$s</option>', $key, selected( $_REQUEST['dateshow'], $key, false ), $value );
298
  echo '</select>';
299
 
300
  submit_button( __( 'Filter', 'aryo-activity-log' ), 'button', false, false, array( 'id' => 'activity-query-submit' ) );
@@ -349,7 +345,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
349
 
350
  $output = array();
351
  foreach ( $types as $type )
352
- $output[] = sprintf( '<option value="%1$s"%2$s>%3$s</option>', $type->object_type, selected( $_REQUEST['typeshow'], $type->object_type, false ), __( $type->object_type, 'aryo-activity-log' ) );
353
 
354
  echo '<select name="typeshow" id="hs-filter-typeshow">';
355
  printf( '<option value="">%s</option>', __( 'All Types', 'aryo-activity-log' ) );
@@ -358,16 +354,14 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
358
  }
359
 
360
 
361
- $actions = $wpdb->get_results( $wpdb->prepare(
362
- 'SELECT DISTINCT %1$s FROM `%2$s`
363
  WHERE 1 = 1
364
  ' . $this->_get_where_by_role() . '
365
- GROUP BY `%1$s`
366
- ORDER BY `%1$s`
367
- ;',
368
- 'action',
369
- $wpdb->activity_log
370
- ) );
371
 
372
  if ( $actions ) {
373
  if ( ! isset( $_REQUEST['showaction'] ) )
@@ -391,7 +385,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
391
 
392
  $items_per_page = $this->get_items_per_page( 'edit_aal_logs_per_page', 20 );
393
  $this->_column_headers = array( $this->get_columns(), get_hidden_columns( $this->screen ), $this->get_sortable_columns() );
394
- $where = ' WHERE 1=1';
395
 
396
  if ( ! isset( $_REQUEST['order'] ) || ! in_array( $_REQUEST['order'], array( 'desc', 'asc' ) ) ) {
397
  $_REQUEST['order'] = 'DESC';
@@ -401,11 +395,11 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
401
  }
402
 
403
  if ( ! empty( $_REQUEST['typeshow'] ) ) {
404
- $where .= $wpdb->prepare( ' AND `object_type` = \'%s\'', $_REQUEST['typeshow'] );
405
  }
406
 
407
  if ( isset( $_REQUEST['showaction'] ) && '' !== $_REQUEST['showaction'] ) {
408
- $where .= $wpdb->prepare( ' AND `action` = \'%s\'', $_REQUEST['showaction'] );
409
  }
410
 
411
  if ( isset( $_REQUEST['usershow'] ) && '' !== $_REQUEST['usershow'] ) {
@@ -413,7 +407,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
413
  }
414
 
415
  if ( isset( $_REQUEST['capshow'] ) && '' !== $_REQUEST['capshow'] ) {
416
- $where .= $wpdb->prepare( ' AND `user_caps` = \'%s\'', strtolower( $_REQUEST['capshow'] ) );
417
  }
418
 
419
  if ( isset( $_REQUEST['dateshow'] ) && in_array( $_REQUEST['dateshow'], array( 'today', 'yesterday', 'week', 'month' ) ) ) {
@@ -432,43 +426,47 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
432
  $start_time = strtotime( '-1 month', $start_time );
433
  }
434
 
435
- $where .= $wpdb->prepare( ' AND `hist_time` > %1$d AND `hist_time` < %2$d', $start_time, $end_time );
436
  }
437
 
438
  if ( isset( $_REQUEST['s'] ) ) {
439
  // Search only searches 'description' fields.
440
- $where .= $wpdb->prepare( ' AND `object_name` LIKE \'%%%s%%\'', '%' . $wpdb->esc_like( $_REQUEST['s'] ) . '%' );
441
  }
442
 
443
  $offset = ( $this->get_pagenum() - 1 ) * $items_per_page;
444
 
445
 
446
- $total_items = $wpdb->get_var( $wpdb->prepare(
447
- 'SELECT COUNT(`histid`) FROM `%1$s`
448
  ' . $where . '
449
- ' . $this->_get_where_by_role(),
450
- $wpdb->activity_log,
451
- $offset,
452
- $items_per_page
453
- ) );
454
-
 
 
 
 
 
 
 
455
  $this->items = $wpdb->get_results( $wpdb->prepare(
456
- 'SELECT * FROM `%1$s`
457
  ' . $where . '
458
  ' . $this->_get_where_by_role() . '
459
- ORDER BY `%2$s` %3$s
460
- LIMIT %4$d, %5$d;',
461
- $wpdb->activity_log,
462
- $_REQUEST['orderby'],
463
- $_REQUEST['order'],
464
  $offset,
465
  $items_per_page
466
  ) );
467
 
468
  $this->set_pagination_args( array(
469
  'total_items' => $total_items,
470
- 'per_page' => $items_per_page,
471
- 'total_pages' => ceil( $total_items / $items_per_page )
472
  ) );
473
  }
474
 
17
  if ( empty( $this->_allow_caps ) ) {
18
  $user = get_user_by( 'id', get_current_user_id() );
19
  if ( ! $user )
20
+ wp_die( 'Not allowed here.' );
21
 
22
  $user_cap = strtolower( key( $user->caps ) );
23
  $allow_caps = array();
34
  $allow_caps = $this->_caps['administrator'];
35
 
36
  if ( empty( $allow_caps ) )
37
+ wp_die( 'Not allowed here.' );
38
 
39
  $this->_allow_caps = array_unique( $allow_caps );
40
  }
51
  }
52
 
53
  if ( empty( $allow_modules ) )
54
+ wp_die( 'Not allowed here.' );
55
 
56
  $allow_modules = array_unique( $allow_modules );
57
 
258
 
259
  echo '<div class="alignleft actions">';
260
 
261
+ $users = $wpdb->get_results(
262
+ 'SELECT DISTINCT `user_id` FROM `' . $wpdb->activity_log . '`
263
  WHERE 1 = 1
264
  ' . $this->_get_where_by_role() . '
265
+ GROUP BY `user_id`
266
+ ORDER BY `user_id`
267
+ ;'
268
+ );
 
 
269
 
270
+ $types = $wpdb->get_results(
271
+ 'SELECT DISTINCT `object_type` FROM `' . $wpdb->activity_log . '`
272
  WHERE 1 = 1
273
  ' . $this->_get_where_by_role() . '
274
+ GROUP BY `object_type`
275
+ ORDER BY `object_type`
276
+ ;'
277
+ );
 
 
278
 
279
  // Make sure we get items for filter.
280
  if ( $users || $types ) {
290
  );
291
  echo '<select name="dateshow" id="hs-filter-date">';
292
  foreach ( $date_options as $key => $value )
293
+ printf( '<option value="%s"%s>%s</option>', $key, selected( $_REQUEST['dateshow'], $key, false ), $value );
294
  echo '</select>';
295
 
296
  submit_button( __( 'Filter', 'aryo-activity-log' ), 'button', false, false, array( 'id' => 'activity-query-submit' ) );
345
 
346
  $output = array();
347
  foreach ( $types as $type )
348
+ $output[] = sprintf( '<option value="%s"%s>%s</option>', $type->object_type, selected( $_REQUEST['typeshow'], $type->object_type, false ), __( $type->object_type, 'aryo-activity-log' ) );
349
 
350
  echo '<select name="typeshow" id="hs-filter-typeshow">';
351
  printf( '<option value="">%s</option>', __( 'All Types', 'aryo-activity-log' ) );
354
  }
355
 
356
 
357
+ $actions = $wpdb->get_results(
358
+ 'SELECT DISTINCT `action` FROM `' . $wpdb->activity_log . '`
359
  WHERE 1 = 1
360
  ' . $this->_get_where_by_role() . '
361
+ GROUP BY `action`
362
+ ORDER BY `action`
363
+ ;'
364
+ );
 
 
365
 
366
  if ( $actions ) {
367
  if ( ! isset( $_REQUEST['showaction'] ) )
385
 
386
  $items_per_page = $this->get_items_per_page( 'edit_aal_logs_per_page', 20 );
387
  $this->_column_headers = array( $this->get_columns(), get_hidden_columns( $this->screen ), $this->get_sortable_columns() );
388
+ $where = ' WHERE 1 = 1';
389
 
390
  if ( ! isset( $_REQUEST['order'] ) || ! in_array( $_REQUEST['order'], array( 'desc', 'asc' ) ) ) {
391
  $_REQUEST['order'] = 'DESC';
395
  }
396
 
397
  if ( ! empty( $_REQUEST['typeshow'] ) ) {
398
+ $where .= $wpdb->prepare( ' AND `object_type` = %s', $_REQUEST['typeshow'] );
399
  }
400
 
401
  if ( isset( $_REQUEST['showaction'] ) && '' !== $_REQUEST['showaction'] ) {
402
+ $where .= $wpdb->prepare( ' AND `action` = %s', $_REQUEST['showaction'] );
403
  }
404
 
405
  if ( isset( $_REQUEST['usershow'] ) && '' !== $_REQUEST['usershow'] ) {
407
  }
408
 
409
  if ( isset( $_REQUEST['capshow'] ) && '' !== $_REQUEST['capshow'] ) {
410
+ $where .= $wpdb->prepare( ' AND `user_caps` = %s', strtolower( $_REQUEST['capshow'] ) );
411
  }
412
 
413
  if ( isset( $_REQUEST['dateshow'] ) && in_array( $_REQUEST['dateshow'], array( 'today', 'yesterday', 'week', 'month' ) ) ) {
426
  $start_time = strtotime( '-1 month', $start_time );
427
  }
428
 
429
+ $where .= $wpdb->prepare( ' AND `hist_time` > %d AND `hist_time` < %d', $start_time, $end_time );
430
  }
431
 
432
  if ( isset( $_REQUEST['s'] ) ) {
433
  // Search only searches 'description' fields.
434
+ $where .= $wpdb->prepare( ' AND `object_name` LIKE %%%s%%', '%' . $wpdb->esc_like( $_REQUEST['s'] ) . '%' );
435
  }
436
 
437
  $offset = ( $this->get_pagenum() - 1 ) * $items_per_page;
438
 
439
 
440
+ $total_items = $wpdb->get_var(
441
+ 'SELECT COUNT(`histid`) FROM `' . $wpdb->activity_log . '`
442
  ' . $where . '
443
+ ' . $this->_get_where_by_role()
444
+ );
445
+
446
+ $items_orderby = filter_input( INPUT_GET, 'orderby', FILTER_SANITIZE_STRING );
447
+ if ( empty( $items_orderby ) ) {
448
+ $items_orderby = 'hist_time'; // Sort by time by default.
449
+ }
450
+
451
+ $items_order = strtoupper( $_REQUEST['order'] );
452
+ if ( empty( $items_order ) || ! in_array( $items_order, array( 'DESC', 'ASC' ) ) ) {
453
+ $items_order = 'DESC'; // Descending order by default.
454
+ }
455
+
456
  $this->items = $wpdb->get_results( $wpdb->prepare(
457
+ 'SELECT * FROM `' . $wpdb->activity_log . '`
458
  ' . $where . '
459
  ' . $this->_get_where_by_role() . '
460
+ ORDER BY ' . $items_orderby . ' ' . $items_order . '
461
+ LIMIT %d, %d;',
 
 
 
462
  $offset,
463
  $items_per_page
464
  ) );
465
 
466
  $this->set_pagination_args( array(
467
  'total_items' => $total_items,
468
+ 'per_page' => $items_per_page,
469
+ 'total_pages' => ceil( $total_items / $items_per_page ),
470
  ) );
471
  }
472
 
classes/class-aal-admin-ui.php CHANGED
@@ -13,7 +13,7 @@ class AAL_Admin_Ui {
13
  public function create_admin_menu() {
14
  $menu_capability = current_user_can( 'view_all_aryo_activity_log' ) ? 'view_all_aryo_activity_log' : 'edit_pages';
15
 
16
- $this->_screens['main'] = add_menu_page( __( 'Activity Log', 'aryo-activity-log' ), __( 'Activity Log', 'aryo-activity-log' ), $menu_capability, 'activity_log_page', array( &$this, 'activity_log_page_func' ), '', '2.1' );
17
 
18
  // Just make sure we are create instance.
19
  add_action( 'load-' . $this->_screens['main'], array( &$this, 'get_list_table' ) );
@@ -23,7 +23,7 @@ class AAL_Admin_Ui {
23
  $this->get_list_table()->prepare_items();
24
  ?>
25
  <div class="wrap">
26
- <h1 class="aal-page-title"><?php _e( 'Activity Log', 'aryo-activity-log' ); ?></h1>
27
 
28
  <form id="activity-filter" method="get">
29
  <input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
13
  public function create_admin_menu() {
14
  $menu_capability = current_user_can( 'view_all_aryo_activity_log' ) ? 'view_all_aryo_activity_log' : 'edit_pages';
15
 
16
+ $this->_screens['main'] = add_menu_page( _x( 'Activity Log', 'Page and Menu Title', 'aryo-activity-log' ), _x( 'Activity Log', 'Page and Menu Title', 'aryo-activity-log' ), $menu_capability, 'activity_log_page', array( &$this, 'activity_log_page_func' ), '', '2.1' );
17
 
18
  // Just make sure we are create instance.
19
  add_action( 'load-' . $this->_screens['main'], array( &$this, 'get_list_table' ) );
23
  $this->get_list_table()->prepare_items();
24
  ?>
25
  <div class="wrap">
26
+ <h1 class="aal-page-title"><?php _ex( 'Activity Log', 'Page and Menu Title', 'aryo-activity-log' ); ?></h1>
27
 
28
  <form id="activity-filter" method="get">
29
  <input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>" />
classes/class-aal-api.php CHANGED
@@ -17,9 +17,8 @@ class AAL_API {
17
 
18
  $wpdb->query(
19
  $wpdb->prepare(
20
- 'DELETE FROM `%1$s`
21
- WHERE `hist_time` < %2$d',
22
- $wpdb->activity_log,
23
  strtotime( '-' . $logs_lifespan . ' days', current_time( 'timestamp' ) )
24
  )
25
  );
@@ -60,12 +59,7 @@ class AAL_API {
60
  public function erase_all_items() {
61
  global $wpdb;
62
 
63
- $wpdb->query(
64
- $wpdb->prepare(
65
- 'TRUNCATE %1$s',
66
- $wpdb->activity_log
67
- )
68
- );
69
  }
70
 
71
  /**
@@ -109,17 +103,16 @@ class AAL_API {
109
  // Make sure for non duplicate.
110
  $check_duplicate = $wpdb->get_row(
111
  $wpdb->prepare(
112
- 'SELECT `histid` FROM %1$s
113
- WHERE `user_caps` = \'%2$s\'
114
- AND `action` = \'%3$s\'
115
- AND `object_type` = \'%4$s\'
116
- AND `object_subtype` = \'%5$s\'
117
- AND `object_name` = \'%6$s\'
118
- AND `user_id` = \'%7$s\'
119
- AND `hist_ip` = \'%8$s\'
120
- AND `hist_time` = \'%9$s\'
121
  ;',
122
- $wpdb->activity_log,
123
  $args['user_caps'],
124
  $args['action'],
125
  $args['object_type'],
17
 
18
  $wpdb->query(
19
  $wpdb->prepare(
20
+ 'DELETE FROM `' . $wpdb->activity_log . '`
21
+ WHERE `hist_time` < %d',
 
22
  strtotime( '-' . $logs_lifespan . ' days', current_time( 'timestamp' ) )
23
  )
24
  );
59
  public function erase_all_items() {
60
  global $wpdb;
61
 
62
+ $wpdb->query( 'TRUNCATE `' . $wpdb->activity_log . '`' );
 
 
 
 
 
63
  }
64
 
65
  /**
103
  // Make sure for non duplicate.
104
  $check_duplicate = $wpdb->get_row(
105
  $wpdb->prepare(
106
+ 'SELECT `histid` FROM `' . $wpdb->activity_log . '`
107
+ WHERE `user_caps` = %s
108
+ AND `action` = %s
109
+ AND `object_type` = %s
110
+ AND `object_subtype` = %s
111
+ AND `object_name` = %s
112
+ AND `user_id` = %s
113
+ AND `hist_ip` = %s
114
+ AND `hist_time` = %s
115
  ;',
 
116
  $args['user_caps'],
117
  $args['action'],
118
  $args['object_type'],
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: pojo.me, KingYes, ariel.k, maor
3
  Tags: automation, actions, activity, Activity Log, admin, admin actions, administration, analytics, audit, audit log, audit logs, bbPress, changes, dashboard, email notifications, event, event log, log, logger, Logs, monitor, multi-users, multisite, notifications, security, security audit trail, security event log, stats, stream, tracking, troubleshooting, user activity report, user tracking, woocommerce, bbPress
4
  Requires at least: 4.4
5
  Tested up to: 4.8
6
- Stable tag: 2.3.4
7
  License: GPLv2 or later
8
 
9
  The #1 Activity Log plugin helps you monitor & log all changes and activities on your site, so you can run a safer, more organized WordPress site.
@@ -100,6 +100,9 @@ Would you like to like to contribute to Activity Log? You are more than welcome
100
 
101
  == Changelog ==
102
 
 
 
 
103
  = 2.3.4 =
104
  * Tweak! - Change Guest user to "N/A"
105
 
3
  Tags: automation, actions, activity, Activity Log, admin, admin actions, administration, analytics, audit, audit log, audit logs, bbPress, changes, dashboard, email notifications, event, event log, log, logger, Logs, monitor, multi-users, multisite, notifications, security, security audit trail, security event log, stats, stream, tracking, troubleshooting, user activity report, user tracking, woocommerce, bbPress
4
  Requires at least: 4.4
5
  Tested up to: 4.8
6
+ Stable tag: 2.3.5
7
  License: GPLv2 or later
8
 
9
  The #1 Activity Log plugin helps you monitor & log all changes and activities on your site, so you can run a safer, more organized WordPress site.
100
 
101
  == Changelog ==
102
 
103
+ = 2.3.5 =
104
+ * Fix! - Added comparability for WordPress 4.8.2 & 4.7.6
105
+
106
  = 2.3.4 =
107
  * Tweak! - Change Guest user to "N/A"
108