← All changes
|
modules/logs/widgets/widget-log-recent-events-widget.php
+103
-83
5.0
→
6.2.1
View file →
| @@ -10,9 +10,17 @@ | ||
| 10 | 10 | |
| 11 | 11 | namespace MainWP\Dashboard\Module\Log; |
| 12 | 12 | |
| 13 | 13 | use MainWP\Dashboard\MainWP_Utility; |
| 14 | +use MainWP\Dashboard\MainWP_UI; | |
| 15 | +use MainWP\Dashboard\MainWP_DB; | |
| 14 | 16 | |
| 17 | +// Exit if accessed directly. | |
| 18 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 19 | + exit; | |
| 20 | +} | |
| 21 | + | |
| 22 | + | |
| 15 | 23 | /** |
| 16 | 24 | * Class Log_Recent_Events_Widget |
| 17 | 25 | * |
| 18 | 26 | * Displays the Logs info. |
| @@ -18,94 +26,106 @@ | ||
| 18 | 26 | * Displays the Logs info. |
| 19 | 27 | */ |
| 20 | 28 | class Log_Recent_Events_Widget { |
| 21 | 29 | |
| 22 | - /** | |
| 23 | - * Protected static variable to hold the single instance of the class. | |
| 24 | - * | |
| 25 | - * @var mixed Default null | |
| 26 | - */ | |
| 27 | - protected static $instance = null; | |
| 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; | |
| 28 | 36 | |
| 29 | - /** | |
| 30 | - * Return the single instance of the class. | |
| 31 | - * | |
| 32 | - * @return mixed $instance The single instance of the class. | |
| 33 | - */ | |
| 34 | - public static function instance() { | |
| 35 | - if ( is_null( self::$instance ) ) { | |
| 36 | - self::$instance = new self(); | |
| 37 | - } | |
| 38 | - return self::$instance; | |
| 39 | - } | |
| 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'; | |
| 40 | 43 | |
| 41 | - /** | |
| 42 | - * Method get_class_name() | |
| 43 | - * | |
| 44 | - * @return string __CLASS__ Class name. | |
| 45 | - */ | |
| 46 | - public static function get_class_name() { | |
| 47 | - return __CLASS__; | |
| 48 | - } | |
| 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 | + } | |
| 49 | 55 | |
| 50 | - /** | |
| 51 | - * Method render() | |
| 52 | - * | |
| 53 | - * @return mixed render_site_info() | |
| 54 | - */ | |
| 55 | - public function render() { | |
| 56 | - $this->render_recent_events(); | |
| 57 | - } | |
| 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 | + } | |
| 58 | 64 | |
| 65 | + /** | |
| 66 | + * Method render() | |
| 67 | + * | |
| 68 | + * @return mixed render_site_info() | |
| 69 | + */ | |
| 70 | + public function render() { | |
| 71 | + $this->render_recent_events(); | |
| 72 | + } | |
| 59 | 73 | |
| 60 | - /** | |
| 61 | - * Render client overview Info. | |
| 62 | - */ | |
| 63 | - public function render_recent_events() { | |
| 64 | - $manager = Log_Manager::instance(); | |
| 65 | - $list_table = new Log_Events_List_Table( $manager ); | |
| 66 | - ?> | |
| 67 | - <div class="mainwp-widget-header"> | |
| 68 | - <h3 class="ui header handle-drag"> | |
| 69 | - <?php esc_html_e( 'Recent Activity Log', 'mainwp' ); ?> | |
| 70 | - <div class="sub header"> | |
| 71 | - <?php esc_html_e( 'Chronological log of the latest activities performed on the system.', 'mainwp' ); ?> | |
| 72 | - </div> | |
| 73 | - </h3> | |
| 74 | - </div> | |
| 75 | 74 | |
| 76 | - <div class="mainwp-scrolly-overflow"> | |
| 77 | - <?php | |
| 78 | - /** | |
| 79 | - * Actoin: mainwp_logs_widget_top | |
| 80 | - * | |
| 81 | - * Fires at the top of the widget. | |
| 82 | - * | |
| 83 | - * @since 4.6 | |
| 84 | - */ | |
| 85 | - do_action( 'mainwp_logs_widget_top', 'recent_events' ); | |
| 86 | - ?> | |
| 87 | - <div id="mainwp-message-zone" style="display:none;" class="ui message"></div> | |
| 88 | - <?php | |
| 89 | - wp_nonce_field( 'mainwp-admin-nonce' ); | |
| 90 | - $list_table->display(); | |
| 91 | - ?> | |
| 92 | - <?php | |
| 93 | - /** | |
| 94 | - * Action: mainwp_logs_widget_bottom | |
| 95 | - * | |
| 96 | - * Fires at the bottom of the widget. | |
| 97 | - * | |
| 98 | - * @since 4.6 | |
| 99 | - */ | |
| 100 | - do_action( 'mainwp_logs_widget_bottom', 'recent_events' ); | |
| 101 | - ?> | |
| 102 | - </div> | |
| 103 | - <div class="mainwp-widget-footer ui four columns stackable grid"> | |
| 104 | - <div class="column"> | |
| 105 | - </div> | |
| 106 | - <div class="column"> | |
| 107 | - </div> | |
| 108 | - </div> | |
| 109 | - <?php | |
| 110 | - } | |
| 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 | + } | |
| 111 | 131 | } |