| 1 |
<?php |
| 2 |
/** |
| 3 |
* Module Compact connector class. |
| 4 |
* |
| 5 |
* @package MainWP\Dashboard |
| 6 |
* @version 4.5.1 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace MainWP\Dashboard\Module\Log; |
| 10 |
|
| 11 |
defined( 'ABSPATH' ) || exit; |
| 12 |
|
| 13 |
/** |
| 14 |
* Class Connector_User |
| 15 |
*/ |
| 16 |
class Connector_Compact extends Log_Connector { |
| 17 |
/** |
| 18 |
* Connector slug |
| 19 |
* |
| 20 |
* @var string |
| 21 |
*/ |
| 22 |
public $name = 'compact'; |
| 23 |
|
| 24 |
|
| 25 |
/** |
| 26 |
* Actions registered for this connector |
| 27 |
* |
| 28 |
* @var array |
| 29 |
*/ |
| 30 |
public $actions = array( |
| 31 |
'mainwp_compact_action', |
| 32 |
); |
| 33 |
|
| 34 |
/** |
| 35 |
* Return translated connector label |
| 36 |
* |
| 37 |
* @return string Translated connector label |
| 38 |
*/ |
| 39 |
public function get_label() { |
| 40 |
return esc_html__( 'Compact', 'mainwp' ); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Return translated action term labels |
| 45 |
* |
| 46 |
* @return array Action terms label translation |
| 47 |
*/ |
| 48 |
public function get_action_labels() { |
| 49 |
return array( |
| 50 |
'saved' => esc_html__( 'Saved', 'mainwp' ), |
| 51 |
); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Return translated context labels |
| 56 |
* |
| 57 |
* @return array Context label translations |
| 58 |
*/ |
| 59 |
public function get_context_labels() { |
| 60 |
return array( |
| 61 |
'compact' => esc_html__( 'Compact', 'mainwp' ), |
| 62 |
); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Log compact actions. |
| 67 |
* |
| 68 |
* @action mainwp_compact_action |
| 69 |
* |
| 70 |
* @param string $action post action. |
| 71 |
* @param int $year compact year. |
| 72 |
* @param array $data data array. |
| 73 |
* @param array $start_time data array. |
| 74 |
* @param array $end_time data array. |
| 75 |
*/ |
| 76 |
public function callback_mainwp_compact_action( $action, $year, $data, $start_time, $end_time ) { |
| 77 |
|
| 78 |
if ( 'saved' !== $action || empty( $year ) || ! is_numeric( $year ) || ! is_array( $data ) ) { |
| 79 |
return; |
| 80 |
} |
| 81 |
|
| 82 |
// translators: %s: Compact log item name. |
| 83 |
$message = esc_html__( 'Compact log: %s', 'mainwp' ); |
| 84 |
|
| 85 |
$context = $year; |
| 86 |
|
| 87 |
$args = array( |
| 88 |
'item' => esc_html__( 'Compact Logs', 'mainwp' ), |
| 89 |
'start_time' => $start_time, |
| 90 |
'end_time' => $end_time, |
| 91 |
'compact_logs' => wp_json_encode( $data ), |
| 92 |
); |
| 93 |
|
| 94 |
$state = 1; |
| 95 |
|
| 96 |
$this->log( |
| 97 |
$message, |
| 98 |
$args, |
| 99 |
0, |
| 100 |
$context, |
| 101 |
$action, |
| 102 |
$state |
| 103 |
); |
| 104 |
} |
| 105 |
} |
| 106 |
|