PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.6.0.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.6.0.1
6.2.3 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 All 156 releases
mainwp / widgets / widget-mainwp-site-info.php

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

211 lines 5.9 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 ?>
137 <h2 class="ui icon header">
138 <i class="info circle icon"></i>
139 <div class="content">
140 <?php esc_html_e( 'No info found!', 'mainwp' ); ?>
141 <div class="sub header"><?php esc_html_e( 'Site information could not be found. Make sure your site is properly connected and syncs correctly.', 'mainwp' ); ?></div>
142 </div>
143 </h2>
144 <?php
145 } else {
146
147 $website_info['group'] = empty( $website->wpgroups ) ? 'None' : $website->wpgroups;
148
149 ?>
150 <table class="ui celled striped table">
151 <tbody>
152 <?php
153 /**
154 * Action: mainwp_site_info_table_top
155 *
156 * Fires at the top of the Site Info table in Site Info widget on the Individual site overview page.
157 *
158 * @param object $website Object containing the child site info.
159 *
160 * @since 4.0
161 */
162 do_action( 'mainwp_site_info_table_top', $website );
163 ?>
164 <?php
165 foreach ( $child_site_info as $index => $title ) {
166 $val = '';
167 if ( isset( $website_info[ $index ] ) ) {
168 if ( 'debug_mode' === $index ) {
169 $val = ( 1 === (int) $website_info[ $index ] ) ? 'Enabled' : 'Disabled';
170 } else {
171 $val = $website_info[ $index ];
172 }
173 }
174 ?>
175 <tr>
176 <td><?php echo esc_html( $title ); ?></td>
177 <td><?php echo esc_html( $val ); ?></td>
178 </tr>
179 <?php } ?>
180 <?php
181 /**
182 * Action: mainwp_site_info_table_bottom
183 *
184 * Fires at the bottom of the Site Info table in Site Info widget on the Individual site overview page.
185 *
186 * @param object $website Object containing the child site info.
187 *
188 * @since 4.0
189 */
190 do_action( 'mainwp_site_info_table_bottom', $website );
191 ?>
192 </tbody>
193 </table>
194 <?php } ?>
195 <?php
196 /**
197 * Action: mainwp_site_info_widget_bottom
198 *
199 * Fires at the bottom of the Site Info widget on the Individual site overview page.
200 *
201 * @param object $website Object containing the child site info.
202 *
203 * @since 4.0
204 */
205 do_action( 'mainwp_site_info_widget_bottom', $website );
206 ?>
207 </div>
208 <?php
209 }
210 }
211