PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.1.5
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.1.5
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
mainwp / widgets / widget-mainwp-site-info.php

widget-mainwp-site-info.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.1.5, at widgets/widget-mainwp-site-info.php

220 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Site Info Widget
4 *
5 * Build the Child Site Info Widget.
6 *
7 * @package MainWP/Dashboard
8 */
9
10 namespace MainWP\Dashboard;
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class MainWP_Site_Info
19 *
20 * Grab Child Site info and build widget.
21 */
22 class MainWP_Site_Info { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
23
24 /**
25 * Method get_class_name()
26 *
27 * @return string __CLASS__ Class name.
28 */
29 public static function get_class_name() {
30 return __CLASS__;
31 }
32
33 /**
34 * Method render()
35 *
36 * @return mixed render_site_info()
37 */
38 public static function render() {
39 static::render_site_info();
40 }
41
42 /**
43 * Method render_site_info()
44 *
45 * Grab Child Site Info and render.
46 *
47 * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
48 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
49 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
50 * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
51 */
52 public static function render_site_info() {
53 $current_wpid = MainWP_System_Utility::get_current_wpid();
54 if ( empty( $current_wpid ) ) {
55 return;
56 }
57
58 $website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true );
59
60 $website_info = MainWP_DB::instance()->get_website_option( $website, 'site_info' );
61 $website_info = ! empty( $website_info ) ? json_decode( $website_info, true ) : array();
62
63 if ( is_array( $website_info ) ) {
64 $code = $website->http_response_code;
65 $code_string = MainWP_Utility::get_http_codes( $code );
66 if ( ! empty( $code_string ) ) {
67 $code .= ' - ' . $code_string;
68 }
69 $website_info['last_status'] = $code;
70
71 $dbsize = MainWP_DB::instance()->get_website_option( $website, 'dbsize_activitylogs' );
72 if ( '' !== $dbsize && false !== $dbsize ) {
73 $website_info['dbsize_activitylogs'] = size_format( intval( $dbsize ) );
74 }
75 }
76
77 $child_site_info = array(
78 'wpversion' => esc_html__( 'WordPress Version', 'mainwp' ),
79 'debug_mode' => esc_html__( 'Debug Mode', 'mainwp' ),
80 'phpversion' => esc_html__( 'PHP Version', 'mainwp' ),
81 'child_version' => esc_html__( 'MainWP Child Version', 'mainwp' ),
82 'memory_limit' => esc_html__( 'PHP Memory Limit', 'mainwp' ),
83 'mysql_version' => esc_html__( 'MySQL Version', 'mainwp' ),
84 'child_curl_version' => esc_html__( 'cURL Cersion', 'mainwp' ),
85 'child_openssl_version' => esc_html__( 'OpenSSL Cersion', 'mainwp' ),
86 'ip' => esc_html__( 'Server IP', 'mainwp' ),
87 'site_lang' => esc_html__( 'Site Language', 'mainwp' ),
88 'site_public' => esc_html__( 'Search Engine Visibility', 'mainwp' ),
89 'group' => esc_html__( 'Tags', 'mainwp' ),
90 'last_status' => esc_html__( 'Last Check Status', 'mainwp' ),
91 'dbsize_activitylogs' => esc_html__( 'Network Activity Table Size', 'mainwp' ),
92 );
93
94 /**
95 * Filter: mainwp_child_site_info_widget_content
96 *
97 * Filters the Child Info array for the Site Info widget.
98 *
99 * @since 4.1
100 */
101 $child_site_info = apply_filters( 'mainwp_child_site_info_widget_content', $child_site_info );
102
103 static::render_info( $website, $website_info, $child_site_info );
104 }
105
106 /**
107 * Render Sites Info.
108 *
109 * @param object $website Object containing the child site info.
110 * @param array $website_info Website data.
111 * @param array $child_site_info Website info to display.
112 */
113 public static function render_info( $website, $website_info, $child_site_info ) { // phpcs:ignore -- NOSONAR - complex.
114 ?>
115 <div class="mainwp-widget-header">
116 <h2 class="ui header handle-drag">
117 <?php
118 /**
119 * Filter: mainwp_site_info_widget_title
120 *
121 * Filters the Site info widget title text.
122 *
123 * @param object $website Object containing the child site info.
124 *
125 * @since 4.1
126 */
127 echo esc_html( apply_filters( 'mainwp_site_info_widget_title', esc_html__( 'Site Info', 'mainwp' ), $website ) );
128 ?>
129 <div class="sub header"><?php esc_html_e( 'Basic child site system information', 'mainwp' ); ?></div>
130 </h2>
131 </div>
132
133 <div class="mainwp-widget-site-info mainwp-scrolly-overflow">
134 <?php
135 /**
136 * Actoin: mainwp_site_info_widget_top
137 *
138 * Fires at the top of the Site Info widget on the Individual site overview page.
139 *
140 * @param object $website Object containing the child site info.
141 *
142 * @since 4.0
143 */
144 do_action( 'mainwp_site_info_widget_top', $website );
145 ?>
146 <?php
147 if ( ! is_array( $website_info ) || ! isset( $website_info['wpversion'] ) ) {
148 MainWP_UI::render_empty_element_placeholder( __( 'View Site Details', 'mainwp' ), __( 'No site information available.', 'mainwp' ), '<em data-emoji=":globe_with_meridians:" class="medium"></em>' );
149 } else {
150
151 $website_info['group'] = empty( $website->wpgroups ) ? 'None' : $website->wpgroups;
152
153 ?>
154 <table class="ui mini very compact table">
155 <tbody>
156 <?php
157 /**
158 * Action: mainwp_site_info_table_top
159 *
160 * Fires at the top of the Site Info table in Site Info widget on the Individual site overview page.
161 *
162 * @param object $website Object containing the child site info.
163 *
164 * @since 4.0
165 */
166 do_action( 'mainwp_site_info_table_top', $website );
167 ?>
168 <?php
169 foreach ( $child_site_info as $index => $title ) {
170 $val = '';
171 if ( isset( $website_info[ $index ] ) ) {
172 $val = $website_info[ $index ];
173 if ( 'debug_mode' === $index ) {
174 $val = ( 1 === (int) $website_info[ $index ] ) ? __( 'Enabled', 'mainwp' ) : __( 'Disabled', 'mainwp' );
175 } elseif ( 'site_public' === $index ) {
176 $val = ( 1 === (int) $website_info[ $index ] ) ? __( 'Visible', 'mainwp' ) : __( 'Blocking', 'mainwp' );
177 } elseif ( 'site_lang' === $index ) {
178 if ( function_exists( 'locale_get_display_name' ) ) {
179 $val = locale_get_display_name( $val );
180 }
181 }
182 }
183 ?>
184 <tr>
185 <td><?php echo esc_html( $title ); ?></td>
186 <td class="right aligned"><?php echo esc_html( $val ); ?></td>
187 </tr>
188 <?php } ?>
189 <?php
190 /**
191 * Action: mainwp_site_info_table_bottom
192 *
193 * Fires at the bottom of the Site Info table in Site Info widget on the Individual site overview page.
194 *
195 * @param object $website Object containing the child site info.
196 *
197 * @since 4.0
198 */
199 do_action( 'mainwp_site_info_table_bottom', $website );
200 ?>
201 </tbody>
202 </table>
203 <?php } ?>
204 <?php
205 /**
206 * Action: mainwp_site_info_widget_bottom
207 *
208 * Fires at the bottom of the Site Info widget on the Individual site overview page.
209 *
210 * @param object $website Object containing the child site info.
211 *
212 * @since 4.0
213 */
214 do_action( 'mainwp_site_info_widget_bottom', $website );
215 ?>
216 </div>
217 <?php
218 }
219 }
220