PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.3.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.3.2
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 5.2.2 5.3 All 153 releases
mainwp / widgets / widget-mainwp-site-info.php

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

203 lines 5.6 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 /**
13 * Class MainWP_Site_Info
14 *
15 * Grab Child Site info and build widget.
16 */
17 class MainWP_Site_Info {
18
19 /**
20 * Method get_class_name()
21 *
22 * @return string __CLASS__ Class name.
23 */
24 public static function get_class_name() {
25 return __CLASS__;
26 }
27
28 /**
29 * Method render()
30 *
31 * @return mixed render_site_info()
32 */
33 public static function render() {
34 self::render_site_info();
35 }
36
37 /**
38 * Method render_site_info()
39 *
40 * Grab Child Site Info and render.
41 *
42 * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
43 * @uses \MainWP\Dashboard\MainWP_DB::get_website_option()
44 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_current_wpid()
45 * @uses \MainWP\Dashboard\MainWP_Utility::ctype_digit()
46 */
47 public static function render_site_info() {
48 $current_wpid = MainWP_System_Utility::get_current_wpid();
49 if ( empty( $current_wpid ) ) {
50 return;
51 }
52
53 $website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true );
54
55 $website_info = MainWP_DB::instance()->get_website_option( $website, 'site_info' );
56 $website_info = ! empty( $website_info ) ? json_decode( $website_info, true ) : array();
57
58 if ( is_array( $website_info ) ) {
59 $code = $website->http_response_code;
60 $code_string = MainWP_Utility::get_http_codes( $code );
61 if ( ! empty( $code_string ) ) {
62 $code .= ' - ' . $code_string;
63 }
64 $website_info['last_status'] = $code;
65 }
66
67 $child_site_info = array(
68 'wpversion' => esc_html__( 'WordPress Version', 'mainwp' ),
69 'debug_mode' => esc_html__( 'Debug Mode', 'mainwp' ),
70 'phpversion' => esc_html__( 'PHP Version', 'mainwp' ),
71 'child_version' => esc_html__( 'MainWP Child Version', 'mainwp' ),
72 'memory_limit' => esc_html__( 'PHP Memory Limit', 'mainwp' ),
73 'mysql_version' => esc_html__( 'MySQL Version', 'mainwp' ),
74 'child_curl_version' => esc_html__( 'cURL version', 'mainwp' ),
75 'child_openssl_version' => esc_html__( 'OpenSSL version', 'mainwp' ),
76 'ip' => esc_html__( 'Server IP', 'mainwp' ),
77 'group' => esc_html__( 'Tags', 'mainwp' ),
78 'last_status' => esc_html__( 'Last Check Status', 'mainwp' ),
79
80 );
81
82 /**
83 * Filter: mainwp_child_site_info_widget_content
84 *
85 * Filters the Child Info array for the Site Info widget.
86 *
87 * @since 4.1
88 */
89 $child_site_info = apply_filters( 'mainwp_child_site_info_widget_content', $child_site_info );
90
91 self::render_info( $website, $website_info, $child_site_info );
92 }
93
94 /**
95 * Render Sites Info.
96 *
97 * @param object $website Object containing the child site info.
98 * @param array $website_info Website data.
99 * @param array $child_site_info Website info to display.
100 */
101 public static function render_info( $website, $website_info, $child_site_info ) {
102 ?>
103 <div class="mainwp-widget-header">
104 <h3 class="ui header handle-drag">
105 <?php
106 /**
107 * Filter: mainwp_site_info_widget_title
108 *
109 * Filters the Site info widget title text.
110 *
111 * @param object $website Object containing the child site info.
112 *
113 * @since 4.1
114 */
115 echo esc_html( apply_filters( 'mainwp_site_info_widget_title', esc_html__( 'Site Info', 'mainwp' ), $website ) );
116 ?>
117 <div class="sub header"><?php esc_html_e( 'Basic child site system information', 'mainwp' ); ?></div>
118 </h3>
119 </div>
120
121 <div class="mainwp-widget-site-info mainwp-scrolly-overflow">
122 <?php
123 /**
124 * Actoin: mainwp_site_info_widget_top
125 *
126 * Fires at the top of the Site Info widget on the Individual site overview page.
127 *
128 * @param object $website Object containing the child site info.
129 *
130 * @since 4.0
131 */
132 do_action( 'mainwp_site_info_widget_top', $website );
133 ?>
134 <?php
135 if ( ! is_array( $website_info ) || ! isset( $website_info['wpversion'] ) ) {
136 MainWP_UI::render_empty_element_placeholder();
137 } else {
138
139 $website_info['group'] = empty( $website->wpgroups ) ? 'None' : $website->wpgroups;
140
141 ?>
142 <table class="ui celled striped table">
143 <tbody>
144 <?php
145 /**
146 * Action: mainwp_site_info_table_top
147 *
148 * Fires at the top of the Site Info table in Site Info widget on the Individual site overview page.
149 *
150 * @param object $website Object containing the child site info.
151 *
152 * @since 4.0
153 */
154 do_action( 'mainwp_site_info_table_top', $website );
155 ?>
156 <?php
157 foreach ( $child_site_info as $index => $title ) {
158 $val = '';
159 if ( isset( $website_info[ $index ] ) ) {
160 if ( 'debug_mode' === $index ) {
161 $val = ( 1 === (int) $website_info[ $index ] ) ? 'Enabled' : 'Disabled';
162 } else {
163 $val = $website_info[ $index ];
164 }
165 }
166 ?>
167 <tr>
168 <td><?php echo esc_html( $title ); ?></td>
169 <td><?php echo esc_html( $val ); ?></td>
170 </tr>
171 <?php } ?>
172 <?php
173 /**
174 * Action: mainwp_site_info_table_bottom
175 *
176 * Fires at the bottom of the Site Info table in Site Info widget on the Individual site overview page.
177 *
178 * @param object $website Object containing the child site info.
179 *
180 * @since 4.0
181 */
182 do_action( 'mainwp_site_info_table_bottom', $website );
183 ?>
184 </tbody>
185 </table>
186 <?php } ?>
187 <?php
188 /**
189 * Action: mainwp_site_info_widget_bottom
190 *
191 * Fires at the bottom of the Site Info widget on the Individual site overview page.
192 *
193 * @param object $website Object containing the child site info.
194 *
195 * @since 4.0
196 */
197 do_action( 'mainwp_site_info_widget_bottom', $website );
198 ?>
199 </div>
200 <?php
201 }
202 }
203