mirror of
https://ghproxy.net/https://github.com/elementor/activity-log.git
synced 2025-10-04 01:30:46 +08:00
CSV Exporter review
This commit is contained in:
parent
90f637c9e8
commit
ed4e9ffbe0
6 changed files with 43 additions and 31 deletions
|
@ -5,7 +5,7 @@ Plugin URI: http://wordpress.org/plugins/aryo-activity-log/
|
|||
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.
|
||||
Author: Yakir Sitbon, Maor Chasen, Ariel Klikstein
|
||||
Author URI: http://pojo.me/
|
||||
Version: 2.3.7
|
||||
Version: 2.3.6
|
||||
Text Domain: aryo-activity-log
|
||||
License: GPLv2 or later
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
abstract class AAL_Exporter {
|
||||
/**
|
||||
|
@ -22,5 +23,5 @@ abstract class AAL_Exporter {
|
|||
* @param array $columns Column names included in data set.
|
||||
* @return void
|
||||
*/
|
||||
public abstract function write( $data, $columns );
|
||||
abstract public function write( $data, $columns );
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
|
|||
return 'AND (' . implode( ' OR ', $where ) . ') AND (' . implode( ' OR ', $where_caps ) . ')';
|
||||
}
|
||||
|
||||
public function _get_action_label( $action ) {
|
||||
public function get_action_label( $action ) {
|
||||
return ucwords( str_replace( '_', ' ', __( $action, 'aryo-activity-log' ) ) );
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
|
|||
|
||||
switch ( $column_name ) {
|
||||
case 'action' :
|
||||
$return = $this->_get_action_label( $item->action );
|
||||
$return = $this->get_action_label( $item->action );
|
||||
break;
|
||||
case 'date' :
|
||||
$return = sprintf( '<strong>' . __( '%s ago', 'aryo-activity-log' ) . '</strong>', human_time_diff( $item->hist_time, current_time( 'timestamp' ) ) );
|
||||
|
@ -263,7 +263,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
|
|||
*/
|
||||
$actions = apply_filters( 'aal_record_actions', array() );
|
||||
?>
|
||||
<?php if ( $multiple_exporters = ( count( $actions ) > 1 ) ) : ?>
|
||||
<?php if ( count( $actions ) > 1 ) : ?>
|
||||
<div class="alignleft actions recordactions">
|
||||
<select name="aal-record-action">
|
||||
<option value=""><?php echo esc_attr__( 'Export File Format', 'aryo-activity-log' ); ?></option>
|
||||
|
@ -297,7 +297,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
|
|||
public function extra_tablenav( $which ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( 'bottom' == $which ) {
|
||||
if ( 'bottom' === $which ) {
|
||||
$this->extra_tablenav_footer();
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ class AAL_Activity_Log_List_Table extends WP_List_Table {
|
|||
|
||||
$output = array();
|
||||
foreach ( $actions as $type )
|
||||
$output[] = sprintf( '<option value="%s"%s>%s</option>', $type->action, selected( $_REQUEST['showaction'], $type->action, false ), $this->_get_action_label( $type->action ) );
|
||||
$output[] = sprintf( '<option value="%s"%s>%s</option>', $type->action, selected( $_REQUEST['showaction'], $type->action, false ), $this->get_action_label( $type->action ) );
|
||||
|
||||
echo '<select name="showaction" id="hs-filter-showaction">';
|
||||
printf( '<option value="">%s</option>', __( 'All Actions', 'aryo-activity-log' ) );
|
||||
|
|
|
@ -6,7 +6,7 @@ class AAL_Export {
|
|||
|
||||
public function __construct() {
|
||||
add_action( 'aal_admin_page_load', array( $this, 'admin_register_exporters' ), 10 );
|
||||
add_action( 'aal_admin_page_load', array( $this, 'admin_capture_action' ), 20 );
|
||||
add_action( 'aal_admin_page_load', array( $this, 'admin_capture_action' ), 20 );
|
||||
|
||||
add_filter( 'aal_record_actions', array( $this, 'filter_register_actions' ) );
|
||||
}
|
||||
|
@ -24,22 +24,22 @@ class AAL_Export {
|
|||
}
|
||||
|
||||
if ( empty( $_GET['aal_actions_nonce'] ) ) {
|
||||
return $this->redirect_back();
|
||||
$this->redirect_back();
|
||||
}
|
||||
|
||||
if ( empty( $_GET['aal-record-action'] ) || ! wp_verify_nonce( $_GET['aal_actions_nonce'], 'aal_actions_nonce' ) ) {
|
||||
return $this->redirect_back();
|
||||
if ( empty( $_GET['aal-record-action'] ) || ! wp_verify_nonce( $_GET['aal_actions_nonce'], 'aal_actions_nonce' ) ) {
|
||||
$this->redirect_back();
|
||||
}
|
||||
|
||||
if ( isset( $_GET['page'] ) && $_GET['page'] != 'activity_log_page' ) {
|
||||
return $this->redirect_back();
|
||||
if ( isset( $_GET['page'] ) && 'activity_log_page' !== $_GET['page'] ) {
|
||||
$this->redirect_back();
|
||||
}
|
||||
|
||||
$exporter_selected = $_GET['aal-record-action'];
|
||||
|
||||
// If exporter doesn't exist or isn't registered, bail
|
||||
if ( ! array_key_exists( $exporter_selected, $this->get_exporters() ) ) {
|
||||
return $this->redirect_back();
|
||||
$this->redirect_back();
|
||||
}
|
||||
|
||||
// Disable row limit
|
||||
|
@ -49,8 +49,8 @@ class AAL_Export {
|
|||
$list_table->prepare_items();
|
||||
$items = $list_table->items;
|
||||
$columns = $list_table->get_columns();
|
||||
|
||||
$op = array();
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
$op[] = $this->prep_row( $item, $columns, $list_table );
|
||||
}
|
||||
|
@ -60,13 +60,18 @@ class AAL_Export {
|
|||
}
|
||||
|
||||
protected function redirect_back() {
|
||||
wp_redirect(
|
||||
menu_page_url( 'activity_log_page', false )
|
||||
);
|
||||
wp_redirect( menu_page_url( 'activity_log_page', false ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
private function prep_row( $item, $columns, &$list_table ) {
|
||||
|
||||
/**
|
||||
* @param stdClass $item
|
||||
* @param array $columns
|
||||
* @param AAL_Activity_Log_List_Table $list_table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function prep_row( $item, $columns, $list_table ) {
|
||||
$row = array();
|
||||
|
||||
foreach ( array_keys( $columns ) as $column ) {
|
||||
|
@ -75,22 +80,28 @@ class AAL_Export {
|
|||
$created = date( 'Y-m-d H:i:s', strtotime( $item->hist_time ) );
|
||||
$row[ $column ] = get_date_from_gmt( $created, 'Y/m/d h:i:s A' );
|
||||
break;
|
||||
|
||||
case 'author':
|
||||
$user = get_userdata( $item->user_id );
|
||||
$row[ $column ] = isset( $user->display_name ) ? $user->display_name : 'unknown';
|
||||
break;
|
||||
|
||||
case 'ip':
|
||||
$row[ $column ] = $item->hist_ip;
|
||||
break;
|
||||
|
||||
case 'type':
|
||||
$row[ $column ] = $item->object_type;
|
||||
break;
|
||||
|
||||
case 'label':
|
||||
$row[ $column ] = $item->object_subtype;
|
||||
break;
|
||||
|
||||
case 'action':
|
||||
$row[ $column ] = $list_table->_get_action_label( $item->action );
|
||||
$row[ $column ] = $list_table->get_action_label( $item->action );
|
||||
break;
|
||||
|
||||
case 'description':
|
||||
$row[ $column ] = $item->object_name;
|
||||
break;
|
||||
|
@ -108,11 +119,7 @@ class AAL_Export {
|
|||
$exporter_instances = array();
|
||||
|
||||
foreach ( $builtin_exporters as $exporter ) {
|
||||
include_once sprintf(
|
||||
'%s/exporters/%s',
|
||||
dirname( ACTIVITY_LOG__FILE__ ),
|
||||
'class-aal-exporter-' . $exporter . '.php'
|
||||
);
|
||||
include_once sprintf( '%s/exporters/%s', dirname( ACTIVITY_LOG__FILE__ ), 'class-aal-exporter-' . $exporter . '.php' );
|
||||
|
||||
$classname = sprintf( 'AAL_Exporter_%s', str_replace( '-', '_', $exporter ) );
|
||||
if ( ! class_exists( $classname ) ) {
|
||||
|
@ -148,8 +155,10 @@ class AAL_Export {
|
|||
* Increase throughput
|
||||
*
|
||||
* @param int $records_per_page Old limit of records
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function increase_throughput( $records_per_page ) {
|
||||
return PHP_INT_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
class AAL_Exporter_csv {
|
||||
/**
|
||||
|
@ -36,8 +37,9 @@ class AAL_Exporter_csv {
|
|||
}
|
||||
|
||||
echo $output; // @codingStandardsIgnoreLine text-only output
|
||||
|
||||
if ( $is_test_mode_off ) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ Contributors: pojo.me, KingYes, ariel.k, maor
|
|||
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
|
||||
Requires at least: 4.4
|
||||
Tested up to: 4.8
|
||||
Stable tag: 2.3.7
|
||||
Stable tag: 2.3.6
|
||||
License: GPLv2 or later
|
||||
|
||||
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.
|
||||
|
@ -105,8 +105,8 @@ Would you like to like to contribute to Activity Log? You are more than welcome
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 2.3.7 =
|
||||
* New! Export your Activity Log data records to CSV
|
||||
= 2.4.0 =
|
||||
* New! Export your Activity Log data records to CSV ([#70](https://github.com/pojome/elementor/issues/70))
|
||||
|
||||
= 2.3.6 =
|
||||
* Fix! - Admin table filters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue