| @@ -8,195 +8,212 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | namespace MainWP\Dashboard; |
| 11 | 11 | |
| 12 | +// Exit if accessed directly. | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 16 | + | |
| 12 | 17 | /** |
| 13 | 18 | * Class MainWP_Site_Info |
| 14 | 19 | * |
| 15 | 20 | * Grab Child Site info and build widget. |
| 16 | 21 | */ |
| 17 | -class MainWP_Site_Info { | |
| 22 | +class MainWP_Site_Info { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. | |
| 18 | 23 | |
| 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 | - } | |
| 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 | + } | |
| 27 | 32 | |
| 28 | - /** | |
| 29 | - * Method render() | |
| 30 | - * | |
| 31 | - * @return mixed render_site_info() | |
| 32 | - */ | |
| 33 | - public static function render() { | |
| 34 | - self::render_site_info(); | |
| 35 | - } | |
| 33 | + /** | |
| 34 | + * Method render() | |
| 35 | + * | |
| 36 | + * @return mixed render_site_info() | |
| 37 | + */ | |
| 38 | + public static function render() { | |
| 39 | + static::render_site_info(); | |
| 40 | + } | |
| 36 | 41 | |
| 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 | - } | |
| 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 | + } | |
| 52 | 57 | |
| 53 | - $website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true ); | |
| 58 | + $website = MainWP_DB::instance()->get_website_by_id( $current_wpid, true ); | |
| 54 | 59 | |
| 55 | - $website_info = MainWP_DB::instance()->get_website_option( $website, 'site_info' ); | |
| 56 | - $website_info = ! empty( $website_info ) ? json_decode( $website_info, true ) : array(); | |
| 60 | + $website_info = MainWP_DB::instance()->get_website_option( $website, 'site_info' ); | |
| 61 | + $website_info = ! empty( $website_info ) ? json_decode( $website_info, true ) : array(); | |
| 57 | 62 | |
| 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 | - } | |
| 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; | |
| 66 | 70 | |
| 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' ), | |
| 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 | + } | |
| 79 | 76 | |
| 80 | - ); | |
| 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 | + ); | |
| 81 | 93 | |
| 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 ); | |
| 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 ); | |
| 90 | 102 | |
| 91 | - self::render_info( $website, $website_info, $child_site_info ); | |
| 92 | - } | |
| 103 | + static::render_info( $website, $website_info, $child_site_info ); | |
| 104 | + } | |
| 93 | 105 | |
| 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> | |
| 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> | |
| 120 | 132 | |
| 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 { | |
| 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 { | |
| 138 | 150 | |
| 139 | - $website_info['group'] = empty( $website->wpgroups ) ? 'None' : $website->wpgroups; | |
| 151 | + $website_info['group'] = empty( $website->wpgroups ) ? 'None' : $website->wpgroups; | |
| 140 | 152 | |
| 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 | - } | |
| 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 | + } | |
| 202 | 219 | } |