| 1 |
<?php |
| 2 |
/** |
| 3 |
* MainWP Logs Widget |
| 4 |
* |
| 5 |
* Displays the Logs Info. |
| 6 |
* |
| 7 |
* @package MainWP/Dashboard |
| 8 |
* @version 4.6 |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace MainWP\Dashboard\Module\Log; |
| 12 |
|
| 13 |
use MainWP\Dashboard\MainWP_Utility; |
| 14 |
use MainWP\Dashboard\MainWP_UI; |
| 15 |
use MainWP\Dashboard\MainWP_DB; |
| 16 |
|
| 17 |
// Exit if accessed directly. |
| 18 |
if ( ! defined( 'ABSPATH' ) ) { |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* Class Log_Recent_Events_Widget |
| 25 |
* |
| 26 |
* Displays the Logs info. |
| 27 |
*/ |
| 28 |
class Log_Recent_Events_Widget { |
| 29 |
|
| 30 |
/** |
| 31 |
* Protected static variable to hold the single instance of the class. |
| 32 |
* |
| 33 |
* @var mixed Default null |
| 34 |
*/ |
| 35 |
protected static $instance = null; |
| 36 |
|
| 37 |
/** |
| 38 |
* Private static variable to hold the table type value. |
| 39 |
* |
| 40 |
* @var mixed Default null |
| 41 |
*/ |
| 42 |
private $table_id_prefix = 'widget-insight'; |
| 43 |
|
| 44 |
/** |
| 45 |
* Return the single instance of the class. |
| 46 |
* |
| 47 |
* @return mixed $instance The single instance of the class. |
| 48 |
*/ |
| 49 |
public static function instance() { |
| 50 |
if ( is_null( static::$instance ) ) { |
| 51 |
static::$instance = new self(); |
| 52 |
} |
| 53 |
return static::$instance; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Method get_class_name() |
| 58 |
* |
| 59 |
* @return string __CLASS__ Class name. |
| 60 |
*/ |
| 61 |
public static function get_class_name() { |
| 62 |
return __CLASS__; |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Method render() |
| 67 |
* |
| 68 |
* @return mixed render_site_info() |
| 69 |
*/ |
| 70 |
public function render() { |
| 71 |
$this->render_recent_events(); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
/** |
| 76 |
* Render client overview Info. |
| 77 |
*/ |
| 78 |
public function render_recent_events() { |
| 79 |
$manager = Log_Manager::instance(); |
| 80 |
$list_table = new Log_Events_List_Table( $manager, $this->table_id_prefix ); |
| 81 |
$sites_count = MainWP_DB::instance()->get_websites_count(); |
| 82 |
?> |
| 83 |
<div class="mainwp-widget-header"> |
| 84 |
<h2 class="ui header handle-drag"> |
| 85 |
<?php esc_html_e( 'Recent Activity', 'mainwp' ); ?> |
| 86 |
<div class="sub header"> |
| 87 |
<?php esc_html_e( 'Chronological log of the latest activities performed on the system.', 'mainwp' ); ?> |
| 88 |
</div> |
| 89 |
</h2> |
| 90 |
</div> |
| 91 |
|
| 92 |
<div class="mainwp-scrolly-overflow"> |
| 93 |
<?php |
| 94 |
/** |
| 95 |
* Actoin: mainwp_logs_widget_top |
| 96 |
* |
| 97 |
* Fires at the top of the widget. |
| 98 |
* |
| 99 |
* @since 4.6 |
| 100 |
*/ |
| 101 |
do_action( 'mainwp_logs_widget_top', 'recent_events' ); |
| 102 |
?> |
| 103 |
<div id="mainwp-message-zone" style="display:none;" class="ui message"></div> |
| 104 |
<?php |
| 105 |
MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); |
| 106 |
if ( 0 < intval( $sites_count ) ) { |
| 107 |
$list_table->display(); |
| 108 |
} else { |
| 109 |
MainWP_UI::render_empty_element_placeholder( __( 'No Avtivity Data Yet', 'mainwp' ), '<a href="admin.php?page=managesites&do=new">' . __( 'Start connecting your sites now', 'mainwp' ) . '</a>', '<em data-emoji=":bar_chart:" class="medium"></em>' ); |
| 110 |
} |
| 111 |
?> |
| 112 |
<?php |
| 113 |
/** |
| 114 |
* Action: mainwp_logs_widget_bottom |
| 115 |
* |
| 116 |
* Fires at the bottom of the widget. |
| 117 |
* |
| 118 |
* @since 4.6 |
| 119 |
*/ |
| 120 |
do_action( 'mainwp_logs_widget_bottom', 'recent_events' ); |
| 121 |
?> |
| 122 |
</div> |
| 123 |
<div class="mainwp-widget-footer ui four columns stackable grid"> |
| 124 |
<div class="column"> |
| 125 |
</div> |
| 126 |
<div class="column"> |
| 127 |
</div> |
| 128 |
</div> |
| 129 |
<?php |
| 130 |
} |
| 131 |
} |
| 132 |
|