| @@ -7,697 +7,29 @@ | ||
| 7 | 7 | * @since 1.0.20 |
| 8 | 8 | */ |
| 9 | 9 | class UsersWP_Status { |
| 10 | 10 | |
| 11 | - public function uwp_status_wrap_error_message($message, $class) { | |
| 12 | - ob_start(); | |
| 13 | - ?> | |
| 14 | - <div class="notice inline notice-<?php echo $class; ?> notice-alt"> | |
| 15 | - <p><?php echo $message; ?></p> | |
| 16 | - </div> | |
| 17 | - <?php | |
| 18 | - $html = ob_get_clean(); | |
| 19 | - return $html; | |
| 11 | + /** | |
| 12 | + * Outputs status page content | |
| 13 | + * | |
| 14 | + * @since 1.0.0 | |
| 15 | + * @package userswp | |
| 16 | + */ | |
| 17 | + public static function output() { | |
| 18 | + include_once( USERSWP_PATH . '/admin/views/html-admin-page-status.php' ); | |
| 20 | 19 | } |
| 21 | 20 | |
| 22 | - /** | |
| 23 | - * Adds the status settings page menu as submenu. | |
| 24 | - * | |
| 25 | - * @since 1.0.20 | |
| 26 | - * @package userswp | |
| 27 | - * | |
| 28 | - * @param callable $settings_page The function to be called to output the content for this page. | |
| 29 | - * | |
| 30 | - * @return void | |
| 31 | - */ | |
| 32 | - public function uwp_add_admin_status_sub_menu($settings_page) { | |
| 33 | - | |
| 34 | - add_submenu_page( | |
| 35 | - "userswp", | |
| 36 | - __('Status', 'userswp'), | |
| 37 | - __('Status', 'userswp'), | |
| 38 | - 'manage_options', | |
| 39 | - 'uwp_status', | |
| 40 | - $settings_page | |
| 41 | - ); | |
| 42 | - | |
| 21 | + /** | |
| 22 | + * Displays status report | |
| 23 | + * | |
| 24 | + * @since 1.0.0 | |
| 25 | + * @package userswp | |
| 26 | + * | |
| 27 | + */ | |
| 28 | + public static function status_report() { | |
| 29 | + include_once( USERSWP_PATH . '/admin/views/html-admin-page-status-report.php' ); | |
| 43 | 30 | } |
| 44 | 31 | |
| 45 | - public function uwp_status_main_tab_content() { | |
| 46 | - global $wpdb; | |
| 47 | - $environment = $this->uwp_get_environment_info(); | |
| 48 | - $database = $this->uwp_get_database_info(); | |
| 49 | - $active_plugins = $this->uwp_get_active_plugins(); | |
| 50 | - $theme = $this->uwp_get_theme_info(); | |
| 51 | - $security = $this->uwp_get_security_info(); | |
| 52 | - $pages = $this->uwp_get_pages(); | |
| 53 | - ?> | |
| 54 | - <style type="text/css"> | |
| 55 | - table.uwp-status-table { | |
| 56 | - margin-bottom: 1em; | |
| 57 | - } | |
| 58 | - table.uwp-status-table th { | |
| 59 | - font-weight: 700; | |
| 60 | - padding: 9px; | |
| 61 | - } | |
| 62 | - table.uwp-status-table td, | |
| 63 | - table.uwp-status-table th { | |
| 64 | - font-size: 1.1em; | |
| 65 | - font-weight: 400; | |
| 66 | - } | |
| 67 | - table.uwp-status-table h2 { | |
| 68 | - font-size: 14px; | |
| 69 | - margin: 0; | |
| 70 | - } | |
| 71 | - table.uwp-status-table td:first-child { | |
| 72 | - width: 33%; | |
| 73 | - } | |
| 74 | - table.uwp-status-table td mark, | |
| 75 | - table.uwp-status-table th mark { | |
| 76 | - background: transparent none; | |
| 77 | - } | |
| 78 | - table.uwp-status-table td mark.yes, | |
| 79 | - table.uwp-status-table th mark.yes { | |
| 80 | - color: #7ad03a; | |
| 81 | - } | |
| 82 | - p.submit { | |
| 83 | - margin: .5em 0; | |
| 84 | - padding: 2px; | |
| 85 | - } | |
| 86 | - #debug-report { | |
| 87 | - display: none; | |
| 88 | - margin: 10px 0; | |
| 89 | - padding: 0; | |
| 90 | - position: relative; | |
| 91 | - } | |
| 92 | - #debug-report textarea { | |
| 93 | - font-family: monospace; | |
| 94 | - width: 100%; | |
| 95 | - margin: 0; | |
| 96 | - height: 300px; | |
| 97 | - padding: 20px; | |
| 98 | - border-radius: 0; | |
| 99 | - resize: none; | |
| 100 | - font-size: 12px; | |
| 101 | - line-height: 20px; | |
| 102 | - outline: 0; | |
| 103 | - } | |
| 104 | - </style> | |
| 105 | - <div class="notice"> | |
| 106 | - <p><?php _e( 'Please copy and paste this information in your ticket when contacting support:', 'userswp' ); ?> </p> | |
| 107 | - <p class="submit"><a href="javascript:void" class="button-primary debug-report"><?php _e( 'Get system report', 'userswp' ); ?></a></p> | |
| 108 | - <div id="debug-report"> | |
| 109 | - <textarea readonly="readonly"></textarea> | |
| 110 | - <p class="submit"><button id="copy-for-support" class="button-primary" href="javascript:void"><?php _e( 'Copy for Support', 'userswp' ); ?></button></p> | |
| 111 | - <p class="copy-error hidden"><?php _e( 'Copying to clipboard failed. Please press Ctrl/Cmd+C to copy.', 'userswp' ); ?></p> | |
| 112 | - </div> | |
| 113 | - </div> | |
| 114 | - <table class="uwp-status-table widefat"> | |
| 115 | - <thead> | |
| 116 | - <tr> | |
| 117 | - <th colspan="3" data-export-label="WordPress Environment"><h2><?php _e( 'WordPress Environment', 'userswp' ); ?></h2></th> | |
| 118 | - </tr> | |
| 119 | - </thead> | |
| 120 | - <tbody> | |
| 121 | - <tr> | |
| 122 | - <td data-export-label="Home URL"><?php _e( 'Home URL', 'userswp' ); ?>:</td> | |
| 123 | - <td><?php echo esc_html( $environment['home_url'] ) ?></td> | |
| 124 | - </tr> | |
| 125 | - <tr> | |
| 126 | - <td data-export-label="Site URL"><?php _e( 'Site URL', 'userswp' ); ?>:</td> | |
| 127 | - <td><?php echo esc_html( $environment['site_url'] ) ?></td> | |
| 128 | - </tr> | |
| 129 | - <tr> | |
| 130 | - <td data-export-label="UWP Version"><?php _e( 'UWP version', 'userswp' ); ?>:</td> | |
| 131 | - <td><?php echo esc_html( $environment['version'] ) ?></td> | |
| 132 | - </tr> | |
| 133 | - <tr> | |
| 134 | - <td data-export-label="WP Version"><?php _e( 'WP version', 'userswp' ); ?>:</td> | |
| 135 | - <td><?php echo esc_html( $environment['wp_version'] ) ?></td> | |
| 136 | - </tr> | |
| 137 | - <tr> | |
| 138 | - <td data-export-label="WP Multisite"><?php _e( 'WP multisite', 'userswp' ); ?>:</td> | |
| 139 | - <td><?php echo ( $environment['wp_multisite'] ) ? '<span class="dashicons dashicons-yes"></span>' : '–'; ?></td> | |
| 140 | - </tr> | |
| 141 | - <tr> | |
| 142 | - <td data-export-label="WP Memory Limit"><?php _e( 'WP memory limit', 'userswp' ); ?>:</td> | |
| 143 | - <td><?php | |
| 144 | - if ( $environment['wp_memory_limit'] < 67108864 ) { | |
| 145 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'userswp' ), size_format( $environment['wp_memory_limit'] ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . __( 'Increasing memory allocated to PHP', 'userswp' ) . '</a>' ) . '</mark>'; | |
| 146 | - } else { | |
| 147 | - echo '<mark class="yes">' . size_format( $environment['wp_memory_limit'] ) . '</mark>'; | |
| 148 | - } | |
| 149 | - ?></td> | |
| 150 | - </tr> | |
| 151 | - <tr> | |
| 152 | - <td data-export-label="WP Debug Mode"><?php _e( 'WP debug mode', 'userswp' ); ?>:</td> | |
| 153 | - <td> | |
| 154 | - <?php if ( $environment['wp_debug_mode'] ) : ?> | |
| 155 | - <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> | |
| 156 | - <?php else : ?> | |
| 157 | - <mark class="no">–</mark> | |
| 158 | - <?php endif; ?> | |
| 159 | - </td> | |
| 160 | - </tr> | |
| 161 | - <tr> | |
| 162 | - <td data-export-label="WP Cron"><?php _e( 'WP cron', 'userswp' ); ?>:</td> | |
| 163 | - <td> | |
| 164 | - <?php if ( $environment['wp_cron'] ) : ?> | |
| 165 | - <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> | |
| 166 | - <?php else : ?> | |
| 167 | - <mark class="no">–</mark> | |
| 168 | - <?php endif; ?> | |
| 169 | - </td> | |
| 170 | - </tr> | |
| 171 | - <tr> | |
| 172 | - <td data-export-label="Language"><?php _e( 'Language', 'userswp' ); ?>:</td> | |
| 173 | - <td><?php echo esc_html( $environment['language'] ); ?></td> | |
| 174 | - </tr> | |
| 175 | - <tr> | |
| 176 | - <td data-export-label="UWP Mode"><?php _e( 'UWP Installation Mode', 'userswp' ); ?>:</td> | |
| 177 | - <?php $install_type = uwp_get_installation_type(); | |
| 178 | - switch ($install_type) { | |
| 179 | - case "multi_na_all": | |
| 180 | - $mode = __('UsersWP is Network Activate for All Site', 'userswp'); | |
| 181 | - break; | |
| 182 | - case "multi_na_site_id": | |
| 183 | - $mode = __('UsersWP is Network Activate for Specific Site', 'userswp'); | |
| 184 | - break; | |
| 185 | - case "multi_na_default": | |
| 186 | - $mode = __('UsersWP is Activate for Main Site', 'userswp'); | |
| 187 | - break; | |
| 188 | - case "multi_not_na": | |
| 189 | - case "single": | |
| 190 | - default: | |
| 191 | - $mode = __('UsersWP is Activate for Single Site', 'userswp'); | |
| 192 | - } | |
| 193 | - ?> | |
| 194 | - <td><?php echo $mode; ?></td> | |
| 195 | - </tr> | |
| 196 | - </tbody> | |
| 197 | - </table> | |
| 198 | - | |
| 199 | - <table class="uwp-status-table widefat" cellspacing="0"> | |
| 200 | - <thead> | |
| 201 | - <tr> | |
| 202 | - <th colspan="3" data-export-label="Server Environment"><h2><?php _e( 'Server Environment', 'userswp' ); ?></h2></th> | |
| 203 | - </tr> | |
| 204 | - </thead> | |
| 205 | - <tbody> | |
| 206 | - <tr> | |
| 207 | - <td data-export-label="Server Info"><?php _e( 'Server info', 'userswp' ); ?>:</td> | |
| 208 | - <td><?php echo esc_html( $environment['server_info'] ); ?></td> | |
| 209 | - </tr> | |
| 210 | - <tr> | |
| 211 | - <td data-export-label="PHP Version"><?php _e( 'PHP version', 'userswp' ); ?>:</td> | |
| 212 | - <td><?php | |
| 213 | - if ( version_compare( $environment['php_version'], '5.6', '<' ) ) { | |
| 214 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend a minimum PHP version of 5.6.', 'userswp' ), esc_html( $environment['php_version'] ) ) . '</mark>'; | |
| 215 | - } else { | |
| 216 | - echo '<mark class="yes">' . esc_html( $environment['php_version'] ) . '</mark>'; | |
| 217 | - } | |
| 218 | - ?></td> | |
| 219 | - </tr> | |
| 220 | - <?php if ( function_exists( 'ini_get' ) ) : ?> | |
| 221 | - <tr> | |
| 222 | - <td data-export-label="PHP Post Max Size"><?php _e( 'PHP post max size', 'userswp' ); ?>:</td> | |
| 223 | - <td><?php echo esc_html( size_format( $environment['php_post_max_size'] ) ) ?></td> | |
| 224 | - </tr> | |
| 225 | - <tr> | |
| 226 | - <td data-export-label="PHP Time Limit"><?php _e( 'PHP time limit', 'userswp' ); ?>:</td> | |
| 227 | - <td><?php echo esc_html( $environment['php_max_execution_time'] ) ?></td> | |
| 228 | - </tr> | |
| 229 | - <tr> | |
| 230 | - <td data-export-label="PHP Max Input Vars"><?php _e( 'PHP max input vars', 'userswp' ); ?>:</td> | |
| 231 | - <td><?php echo esc_html( $environment['php_max_input_vars'] ) ?></td> | |
| 232 | - </tr> | |
| 233 | - <tr> | |
| 234 | - <td data-export-label="cURL Version"><?php _e( 'cURL version', 'userswp' ); ?>:</td> | |
| 235 | - <td><?php echo esc_html( $environment['curl_version'] ) ?></td> | |
| 236 | - </tr> | |
| 237 | - <tr> | |
| 238 | - <td data-export-label="SUHOSIN Installed"><?php _e( 'SUHOSIN installed', 'userswp' ); ?>:</td> | |
| 239 | - <td><?php echo $environment['suhosin_installed'] ? '<span class="dashicons dashicons-yes"></span>' : '–'; ?></td> | |
| 240 | - </tr> | |
| 241 | - <?php endif; | |
| 242 | - if ( $wpdb->use_mysqli ) { | |
| 243 | - $ver = mysqli_get_server_info( $wpdb->dbh ); | |
| 244 | - } else { | |
| 245 | - $ver = mysql_get_server_info(); | |
| 246 | - } | |
| 247 | - if ( ! empty( $wpdb->is_mysql ) && ! stristr( $ver, 'MariaDB' ) ) : ?> | |
| 248 | - <tr> | |
| 249 | - <td data-export-label="MySQL Version"><?php _e( 'MySQL version', 'userswp' ); ?>:</td> | |
| 250 | - <td> | |
| 251 | - <?php | |
| 252 | - if ( version_compare( $environment['mysql_version'], '5.6', '<' ) ) { | |
| 253 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'userswp' ), esc_html( $environment['mysql_version'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'WordPress requirements', 'userswp' ) . '</a>' ) . '</mark>'; | |
| 254 | - } else { | |
| 255 | - echo '<mark class="yes">' . esc_html( $environment['mysql_version'] ) . '</mark>'; | |
| 256 | - } | |
| 257 | - ?> | |
| 258 | - </td> | |
| 259 | - </tr> | |
| 260 | - <?php endif; ?> | |
| 261 | - <tr> | |
| 262 | - <td data-export-label="Max Upload Size"><?php _e( 'Max upload size', 'userswp' ); ?>:</td> | |
| 263 | - <td><?php echo size_format( $environment['max_upload_size'] ) ?></td> | |
| 264 | - </tr> | |
| 265 | - <tr> | |
| 266 | - <td data-export-label="Default Timezone is UTC"><?php _e( 'Default timezone is UTC', 'userswp' ); ?>:</td> | |
| 267 | - <td><?php | |
| 268 | - if ( 'UTC' !== $environment['default_timezone'] ) { | |
| 269 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'userswp' ), $environment['default_timezone'] ) . '</mark>'; | |
| 270 | - } else { | |
| 271 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 272 | - } ?> | |
| 273 | - </td> | |
| 274 | - </tr> | |
| 275 | - <tr> | |
| 276 | - <td data-export-label="fsockopen/cURL"><?php _e( 'fsockopen/cURL', 'userswp' ); ?>:</td> | |
| 277 | - <td><?php | |
| 278 | - if ( $environment['fsockopen_or_curl_enabled'] ) { | |
| 279 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 280 | - } else { | |
| 281 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'userswp' ) . '</mark>'; | |
| 282 | - } ?> | |
| 283 | - </td> | |
| 284 | - </tr> | |
| 285 | - <tr> | |
| 286 | - <td data-export-label="SoapClient"><?php _e( 'SoapClient', 'userswp' ); ?>:</td> | |
| 287 | - <td><?php | |
| 288 | - if ( $environment['soapclient_enabled'] ) { | |
| 289 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 290 | - } else { | |
| 291 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'userswp' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' ) . '</mark>'; | |
| 292 | - } ?> | |
| 293 | - </td> | |
| 294 | - </tr> | |
| 295 | - <tr> | |
| 296 | - <td data-export-label="DOMDocument"><?php _e( 'DOMDocument', 'userswp' ); ?>:</td> | |
| 297 | - <td><?php | |
| 298 | - if ( $environment['domdocument_enabled'] ) { | |
| 299 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 300 | - } else { | |
| 301 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'userswp' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' ) . '</mark>'; | |
| 302 | - } ?> | |
| 303 | - </td> | |
| 304 | - </tr> | |
| 305 | - <tr> | |
| 306 | - <td data-export-label="GZip"><?php _e( 'GZip', 'userswp' ); ?>:</td> | |
| 307 | - <td><?php | |
| 308 | - if ( $environment['gzip_enabled'] ) { | |
| 309 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 310 | - } else { | |
| 311 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'userswp' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' ) . '</mark>'; | |
| 312 | - } ?> | |
| 313 | - </td> | |
| 314 | - </tr> | |
| 315 | - <tr> | |
| 316 | - <td data-export-label="GD Library"><?php _e( 'GD Library', 'userswp' ); ?>:</td> | |
| 317 | - <td><?php | |
| 318 | - if ( $environment['gd_library'] ) { | |
| 319 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 320 | - } else { | |
| 321 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have enabled %s - this is required for image processing.', 'userswp' ), '<a href="https://secure.php.net/manual/en/image.installation.php">GD Library</a>' ) . '</mark>'; | |
| 322 | - } ?> | |
| 323 | - </td> | |
| 324 | - </tr> | |
| 325 | - <tr> | |
| 326 | - <td data-export-label="Multibyte String"><?php _e( 'Multibyte string', 'userswp' ); ?>:</td> | |
| 327 | - <td><?php | |
| 328 | - if ( $environment['mbstring_enabled'] ) { | |
| 329 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 330 | - } else { | |
| 331 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'userswp' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>'; | |
| 332 | - } ?> | |
| 333 | - </td> | |
| 334 | - </tr> | |
| 335 | - <tr> | |
| 336 | - <td data-export-label="Remote Post"><?php _e( 'Remote POST', 'userswp' ); ?>:</td> | |
| 337 | - <td><?php | |
| 338 | - if ( $environment['remote_post_successful'] ) { | |
| 339 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 340 | - } else { | |
| 341 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'userswp' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>'; | |
| 342 | - } ?> | |
| 343 | - </td> | |
| 344 | - </tr> | |
| 345 | - <tr> | |
| 346 | - <td data-export-label="Remote Get"><?php _e( 'Remote GET', 'userswp' ); ?>:</td> | |
| 347 | - <td><?php | |
| 348 | - if ( $environment['remote_get_successful'] ) { | |
| 349 | - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; | |
| 350 | - } else { | |
| 351 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%s failed. Contact your hosting provider.', 'userswp' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>'; | |
| 352 | - } ?> | |
| 353 | - </td> | |
| 354 | - </tr> | |
| 355 | - <?php | |
| 356 | - $rows = apply_filters( 'uwp_system_status_environment_rows', array() ); | |
| 357 | - if(count($rows) > 0) { | |
| 358 | - foreach ($rows as $row) { | |
| 359 | - if (!empty($row['success'])) { | |
| 360 | - $css_class = 'yes'; | |
| 361 | - $icon = '<span class="dashicons dashicons-yes"></span>'; | |
| 362 | - } else { | |
| 363 | - $css_class = 'error'; | |
| 364 | - $icon = '<span class="dashicons dashicons-no-alt"></span>'; | |
| 365 | - } | |
| 366 | - ?> | |
| 367 | - <tr> | |
| 368 | - <td data-export-label="<?php echo esc_attr($row['name']); ?>"><?php echo esc_html($row['name']); ?> | |
| 369 | - : | |
| 370 | - </td> | |
| 371 | - <td> | |
| 372 | - <mark class="<?php echo esc_attr($css_class); ?>"> | |
| 373 | - <?php echo $icon; ?><?php echo !empty($row['note']) ? wp_kses_data($row['note']) : ''; ?> | |
| 374 | - </mark> | |
| 375 | - </td> | |
| 376 | - </tr><?php | |
| 377 | - } | |
| 378 | - }?> | |
| 379 | - </tbody> | |
| 380 | - </table> | |
| 381 | - <table class="widefat" cellspacing="0"> | |
| 382 | - <thead> | |
| 383 | - <tr> | |
| 384 | - <th colspan="3" data-export-label="User Platform"><h2><?php _e( 'User Platform', 'userswp' ); ?></h2></th> | |
| 385 | - </tr> | |
| 386 | - </thead> | |
| 387 | - <tbody> | |
| 388 | - <tr> | |
| 389 | - <td data-export-label="Platform"><?php _e( 'Platform', 'userswp' ); ?>:</td> | |
| 390 | - <td><?php echo esc_html( $environment['platform'] ); ?></td> | |
| 391 | - </tr> | |
| 392 | - <tr> | |
| 393 | - <td data-export-label="Browser name"><?php _e( 'Browser name', 'userswp' ); ?>:</td> | |
| 394 | - <td><?php echo esc_html( $environment['browser_name'] ); ?></td> | |
| 395 | - </tr> | |
| 396 | - <tr> | |
| 397 | - <td data-export-label="Browser version"><?php _e( 'Browser version', 'userswp' ); ?>:</td> | |
| 398 | - <td><?php echo esc_html( $environment['browser_version'] ); ?></td> | |
| 399 | - </tr> | |
| 400 | - <tr> | |
| 401 | - <td data-export-label="User agent"><?php _e( 'User agent', 'userswp' ); ?>:</td> | |
| 402 | - <td><?php echo esc_html( $environment['user_agent'] ); ?></td> | |
| 403 | - </tr> | |
| 404 | - </tbody> | |
| 405 | - </table> | |
| 406 | - <table class="uwp-status-table widefat" cellspacing="0"> | |
| 407 | - <thead> | |
| 408 | - <tr> | |
| 409 | - <th colspan="3" data-export-label="Database"><h2><?php _e( 'Database', 'userswp' ); ?></h2></th> | |
| 410 | - </tr> | |
| 411 | - </thead> | |
| 412 | - <tbody> | |
| 413 | - <tr> | |
| 414 | - <td data-export-label="UWP Database Version"><?php _e( 'UWP database version', 'userswp' ); ?>:</td> | |
| 415 | - <td><?php echo esc_html( $database['uwp_db_version'] ); ?></td> | |
| 416 | - </tr> | |
| 417 | - <tr> | |
| 418 | - <td data-export-label="UWP Database Prefix"><?php _e( 'Database Prefix', 'userswp' ); ?></td> | |
| 419 | - <td><?php | |
| 420 | - if ( strlen( $database['database_prefix'] ) > 20 ) { | |
| 421 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters.', 'userswp' ), esc_html( $database['database_prefix'] ) ) . '</mark>'; | |
| 422 | - } else { | |
| 423 | - echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>'; | |
| 424 | - } | |
| 425 | - ?> | |
| 426 | - </td> | |
| 427 | - </tr> | |
| 428 | - <tr> | |
| 429 | - <td><?php _e( 'Total Database Size', 'userswp' ); ?></td> | |
| 430 | - <td><?php printf( '%.2fMB', $database['database_size']['data'] + $database['database_size']['index'] ); ?></td> | |
| 431 | - </tr> | |
| 432 | - | |
| 433 | - <tr> | |
| 434 | - <td><?php _e( 'Database Data Size', 'userswp' ); ?></td> | |
| 435 | - <td><?php printf( '%.2fMB', $database['database_size']['data'] ); ?></td> | |
| 436 | - </tr> | |
| 437 | - | |
| 438 | - <tr> | |
| 439 | - <td><?php _e( 'Database Index Size', 'userswp' ); ?></td> | |
| 440 | - <td><?php printf( '%.2fMB', $database['database_size']['index'] ); ?></td> | |
| 441 | - </tr> | |
| 442 | - | |
| 443 | - <?php foreach ( $database['database_tables']['userswp'] as $table => $table_data ) { ?> | |
| 444 | - <tr> | |
| 445 | - <td><?php echo esc_html( $table ); ?></td> | |
| 446 | - <td> | |
| 447 | - <?php if( ! $table_data ) { | |
| 448 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Table does not exist', 'userswp' ) . '</mark>'; | |
| 449 | - } else { | |
| 450 | - printf( __( 'Data: %.2fMB + Index: %.2fMB', 'userswp' ), uwp_format_decimal( $table_data['data'], 2 ), uwp_format_decimal( $table_data['index'], 2 ) ); | |
| 451 | - } ?> | |
| 452 | - </td> | |
| 453 | - </tr> | |
| 454 | - <?php } ?> | |
| 455 | - | |
| 456 | - <?php foreach ( $database['database_tables']['other'] as $table => $table_data ) { ?> | |
| 457 | - <tr> | |
| 458 | - <td><?php echo esc_html( $table ); ?></td> | |
| 459 | - <td> | |
| 460 | - <?php printf( __( 'Data: %.2fMB + Index: %.2fMB', 'userswp' ), uwp_format_decimal( $table_data['data'], 2 ), uwp_format_decimal( $table_data['index'], 2 ) ); ?> | |
| 461 | - </td> | |
| 462 | - </tr> | |
| 463 | - <?php } ?> | |
| 464 | - </tbody> | |
| 465 | - </table> | |
| 466 | - <table class="uwp-status-table widefat" cellspacing="0"> | |
| 467 | - <thead> | |
| 468 | - <tr> | |
| 469 | - <th colspan="3" data-export-label="Security"><h2><?php _e( 'Security', 'userswp' ); ?></h2></th> | |
| 470 | - </tr> | |
| 471 | - </thead> | |
| 472 | - <tbody> | |
| 473 | - <tr> | |
| 474 | - <td data-export-label="Secure connection (HTTPS)"><?php _e( 'Secure connection (HTTPS)', 'userswp' ); ?>:</td> | |
| 475 | - <td> | |
| 476 | - <?php if ( $security['secure_connection'] ) : ?> | |
| 477 | - <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> | |
| 478 | - <?php else : ?> | |
| 479 | - <mark class="error"><span class="dashicons dashicons-warning"></span><?php echo __( 'Your site is not using HTTPS.', 'userswp' ); ?></mark> | |
| 480 | - <?php endif; ?> | |
| 481 | - </td> | |
| 482 | - </tr> | |
| 483 | - <tr> | |
| 484 | - <td data-export-label="Hide errors from visitors"><?php _e( 'Hide errors from visitors', 'userswp' ); ?></td> | |
| 485 | - <td> | |
| 486 | - <?php if ( $security['hide_errors'] ) : ?> | |
| 487 | - <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> | |
| 488 | - <?php else : ?> | |
| 489 | - <mark class="error"><span class="dashicons dashicons-warning"></span><?php _e( 'Error messages should not be shown to visitors.', 'userswp' ); ?></mark> | |
| 490 | - <?php endif; ?> | |
| 491 | - </td> | |
| 492 | - </tr> | |
| 493 | - </tbody> | |
| 494 | - </table> | |
| 495 | - <table class="uwp-status-table widefat" cellspacing="0"> | |
| 496 | - <thead> | |
| 497 | - <tr> | |
| 498 | - <th colspan="3" data-export-label="Active Plugins (<?php echo count( $active_plugins ) ?>)"><h2><?php _e( 'Active Plugins', 'userswp' ); ?> (<?php echo count( $active_plugins ) ?>)</h2></th> | |
| 499 | - </tr> | |
| 500 | - </thead> | |
| 501 | - <tbody> | |
| 502 | - <?php | |
| 503 | - foreach ( $active_plugins as $plugin ) { | |
| 504 | - if ( ! empty( $plugin['name'] ) ) { | |
| 505 | - $dirname = dirname( $plugin['plugin'] ); | |
| 506 | - | |
| 507 | - // Link the plugin name to the plugin url if available. | |
| 508 | - $plugin_name = esc_html( $plugin['name'] ); | |
| 509 | - if ( ! empty( $plugin['url'] ) ) { | |
| 510 | - $plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage' , 'userswp' ) . '" target="_blank">' . $plugin_name . '</a>'; | |
| 511 | - } | |
| 512 | - | |
| 513 | - $version_string = ''; | |
| 514 | - $network_string = ''; | |
| 515 | - if ( ! empty( $plugin['latest_verison'] ) && version_compare( $plugin['latest_verison'], $plugin['version'], '>' ) ) { | |
| 516 | - /* translators: %s: plugin latest version */ | |
| 517 | - $version_string = ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'userswp' ), $plugin['latest_verison'] ) . '</strong>'; | |
| 518 | - } | |
| 519 | - | |
| 520 | - if ( false != $plugin['network_activated'] ) { | |
| 521 | - $network_string = ' – <strong style="color:black;">' . __( 'Network enabled', 'userswp' ) . '</strong>'; | |
| 522 | - } | |
| 523 | - ?> | |
| 524 | - <tr> | |
| 525 | - <td><?php echo $plugin_name; ?></td> | |
| 526 | - <td><?php | |
| 527 | - /* translators: %s: plugin author */ | |
| 528 | - printf( __( 'by %s', 'userswp' ), $plugin['author_name'] ); | |
| 529 | - echo ' – ' . esc_html( $plugin['version'] ) . $version_string . $network_string; | |
| 530 | - ?></td> | |
| 531 | - </tr> | |
| 532 | - <?php | |
| 533 | - } | |
| 534 | - } | |
| 535 | - ?> | |
| 536 | - </tbody> | |
| 537 | - </table> | |
| 538 | - | |
| 539 | - <table class="uwp-status-table widefat" cellspacing="0"> | |
| 540 | - <thead> | |
| 541 | - <tr> | |
| 542 | - <th colspan="3" data-export-label="UWP Pages"><h2><?php _e( 'UWP Pages', 'userswp' ); ?></h2></th> | |
| 543 | - </tr> | |
| 544 | - </thead> | |
| 545 | - <tbody> | |
| 546 | - <?php | |
| 547 | - foreach ( $pages as $page ) { | |
| 548 | - $error = false; | |
| 549 | - | |
| 550 | - if ( $page['page_id'] ) { | |
| 551 | - $page_name = '<a href="' . get_edit_post_link( $page['page_id'] ) . '" aria-label="' . sprintf( __( 'Edit %s page', 'userswp' ), esc_html( $page['page_name'] ) ) . '">' . esc_html( $page['page_name'] ) . '</a>'; | |
| 552 | - } else { | |
| 553 | - $page_name = esc_html( $page['page_name'] ); | |
| 554 | - } | |
| 555 | - | |
| 556 | - echo '<tr><td data-export-label="' . esc_attr( $page_name ) . '">' . $page_name . ':</td><td>'; | |
| 557 | - // Page ID check. | |
| 558 | - if ( ! $page['page_set'] ) { | |
| 559 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page not set', 'userswp' ) . '</mark>'; | |
| 560 | - $error = true; | |
| 561 | - } elseif ( ! $page['page_exists'] ) { | |
| 562 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . __( 'Page ID is set, but the page does not exist', 'userswp' ) . '</mark>'; | |
| 563 | - $error = true; | |
| 564 | - } elseif ( ! $page['page_visible'] ) { | |
| 565 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page visibility should be <a href="%s" target="_blank">public</a>', 'userswp' ), 'https://codex.wordpress.org/Content_Visibility' ) . '</mark>'; | |
| 566 | - $error = true; | |
| 567 | - } else { | |
| 568 | - // Shortcode check | |
| 569 | - if ( $page['shortcode_required'] ) { | |
| 570 | - if ( ! $page['shortcode_present'] ) { | |
| 571 | - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Page does not contains the shortcode.', 'userswp' ), $page['shortcode'] ) . '</mark>'; | |
| 572 | - $error = true; | |
| 573 | - } | |
| 574 | - } | |
| 575 | - } | |
| 576 | - | |
| 577 | - if ( ! $error ) { | |
| 578 | - echo '<mark class="yes">#' . absint( $page['page_id'] ) . ' - ' . str_replace( home_url(), '', get_permalink( $page['page_id'] ) ) . '</mark>'; | |
| 579 | - } | |
| 580 | - | |
| 581 | - echo '</td></tr>'; | |
| 582 | - } | |
| 583 | - ?> | |
| 584 | - </tbody> | |
| 585 | - </table> | |
| 586 | - <table class="uwp-status-table widefat" cellspacing="0"> | |
| 587 | - <thead> | |
| 588 | - <tr> | |
| 589 | - <th colspan="3" data-export-label="Theme"><h2><?php _e( 'Theme', 'userswp' ); ?></h2></th> | |
| 590 | - </tr> | |
| 591 | - </thead> | |
| 592 | - <tbody> | |
| 593 | - <tr> | |
| 594 | - <td data-export-label="Name"><?php _e( 'Name', 'userswp' ); ?>:</td> | |
| 595 | - <td><?php echo esc_html( $theme['name'] ) ?></td> | |
| 596 | - </tr> | |
| 597 | - <tr> | |
| 598 | - <td data-export-label="Version"><?php _e( 'Version', 'userswp' ); ?>:</td> | |
| 599 | - <td><?php | |
| 600 | - echo esc_html( $theme['version'] ); | |
| 601 | - if ( version_compare( $theme['version'], $theme['latest_verison'], '<' ) ) { | |
| 602 | - /* translators: %s: theme latest version */ | |
| 603 | - echo ' – <strong style="color:red;">' . sprintf( __( '%s is available', 'userswp' ), esc_html( $theme['latest_verison'] ) ) . '</strong>'; | |
| 604 | - } | |
| 605 | - ?></td> | |
| 606 | - </tr> | |
| 607 | - <tr> | |
| 608 | - <td data-export-label="Author URL"><?php _e( 'Author URL', 'userswp' ); ?>:</td> | |
| 609 | - <td><?php echo esc_html( $theme['author_url'] ) ?></td> | |
| 610 | - </tr> | |
| 611 | - <tr> | |
| 612 | - <td data-export-label="Child Theme"><?php _e( 'Child theme', 'userswp' ); ?>:</td> | |
| 613 | - <td><?php | |
| 614 | - echo $theme['is_child_theme'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> – ' . sprintf( __( 'If you are modifying userswp on a parent theme that you did not build personally we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', 'userswp' ), 'https://codex.wordpress.org/Child_Themes' ); | |
| 615 | - ?></td> | |
| 616 | - </tr> | |
| 617 | - <?php | |
| 618 | - if ( $theme['is_child_theme'] ) : | |
| 619 | - ?> | |
| 620 | - <tr> | |
| 621 | - <td data-export-label="Parent Theme Name"><?php _e( 'Parent theme name', 'userswp' ); ?>:</td> | |
| 622 | - <td><?php echo esc_html( $theme['parent_name'] ); ?></td> | |
| 623 | - </tr> | |
| 624 | - <tr> | |
| 625 | - <td data-export-label="Parent Theme Version"><?php _e( 'Parent theme version', 'userswp' ); ?>:</td> | |
| 626 | - <td><?php | |
| 627 | - echo esc_html( $theme['parent_version'] ); | |
| 628 | - if ( version_compare( $theme['parent_version'], $theme['parent_latest_verison'], '<' ) ) { | |
| 629 | - /* translators: %s: parant theme latest version */ | |
| 630 | - echo ' – <strong style="color:red;">' . sprintf( __( '%s is available', 'userswp' ), esc_html( $theme['parent_latest_verison'] ) ) . '</strong>'; | |
| 631 | - } | |
| 632 | - ?></td> | |
| 633 | - </tr> | |
| 634 | - <tr> | |
| 635 | - <td data-export-label="Parent Theme Author URL"><?php _e( 'Parent theme author URL', 'userswp' ); ?>:</td> | |
| 636 | - <td><?php echo esc_html( $theme['parent_author_url'] ) ?></td> | |
| 637 | - </tr> | |
| 638 | - <?php endif ?> | |
| 639 | - </tbody> | |
| 640 | - </table> | |
| 641 | - <table class="uwp-status-table widefat" cellspacing="0"> | |
| 642 | - <thead> | |
| 643 | - <tr> | |
| 644 | - <th colspan="3" data-export-label="Templates"><h2><?php _e( 'Templates', 'userswp' ); ?></h2></th> | |
| 645 | - </tr> | |
| 646 | - </thead> | |
| 647 | - <tbody> | |
| 648 | - <?php | |
| 649 | - if ( ! empty( $theme['overrides'] ) ) { ?> | |
| 650 | - <tr> | |
| 651 | - <td data-export-label="Overrides"><?php _e( 'Overrides', 'userswp' ); ?></td> | |
| 652 | - <td> | |
| 653 | - <?php | |
| 654 | - $total_overrides = count( $theme['overrides'] ); | |
| 655 | - for ( $i = 0; $i < $total_overrides; $i++ ) { | |
| 656 | - $override = $theme['overrides'][ $i ]; | |
| 657 | - if ( $override['core_version'] && ( empty( $override['version'] ) || version_compare( $override['version'], $override['core_version'], '<' ) ) ) { | |
| 658 | - $current_version = $override['version'] ? $override['version'] : '-'; | |
| 659 | - printf( | |
| 660 | - __( '%1$s version %2$s is out of date. The core version is %3$s', 'userswp' ), | |
| 661 | - '<code>' . $override['file'] . '</code>', | |
| 662 | - '<strong style="color:red">' . $current_version . '</strong>', | |
| 663 | - $override['core_version'] | |
| 664 | - ); | |
| 665 | - } else { | |
| 666 | - echo esc_html( $override['file'] ); | |
| 667 | - } | |
| 668 | - if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) { | |
| 669 | - echo ', '; | |
| 670 | - } | |
| 671 | - echo '<br />'; | |
| 672 | - } | |
| 673 | - ?> | |
| 674 | - </td> | |
| 675 | - </tr> | |
| 676 | - <?php | |
| 677 | - } else { | |
| 678 | - ?> | |
| 679 | - <tr> | |
| 680 | - <td data-export-label="Overrides"><?php _e( 'Overrides', 'userswp' ); ?>:</td> | |
| 681 | - <td>–</td> | |
| 682 | - </tr> | |
| 683 | - <?php | |
| 684 | - } | |
| 685 | - | |
| 686 | - if ( true === $theme['has_outdated_templates'] ) { | |
| 687 | - ?> | |
| 688 | - <tr> | |
| 689 | - <td data-export-label="Outdated Templates"><?php _e( 'Outdated templates', 'userswp' ); ?>:</td> | |
| 690 | - <td><mark class="error"><span class="dashicons dashicons-warning"></span></mark></td> | |
| 691 | - </tr> | |
| 692 | - <?php | |
| 693 | - } | |
| 694 | - ?> | |
| 695 | - </tbody> | |
| 696 | - </table> | |
| 697 | - <?php | |
| 698 | - } | |
| 699 | - | |
| 700 | 32 | /** |
| 701 | 33 | * Get array of environment information. Includes thing like software |
| 702 | 34 | * versions, and various server settings. |
| 703 | 35 | * |
| @@ -702,9 +34,9 @@ | ||
| 702 | 34 | * versions, and various server settings. |
| 703 | 35 | * |
| 704 | 36 | * @return array |
| 705 | 37 | */ |
| 706 | - public function uwp_get_environment_info() { | |
| 38 | + public static function get_environment_info() { | |
| 707 | 39 | global $wpdb; |
| 708 | 40 | |
| 709 | 41 | // Figure out cURL version, if installed. |
| 710 | 42 | $curl_version = ''; |
| @@ -787,9 +119,17 @@ | ||
| 787 | 119 | 'user_agent' => $user_agent |
| 788 | 120 | ); |
| 789 | 121 | } |
| 790 | 122 | |
| 791 | - public function uwp_get_database_info(){ | |
| 123 | + /** | |
| 124 | + * Returns database information | |
| 125 | + * | |
| 126 | + * @since 1.0.0 | |
| 127 | + * @package userswp | |
| 128 | + * | |
| 129 | + * @return array | |
| 130 | + */ | |
| 131 | + public static function get_database_info(){ | |
| 792 | 132 | global $wpdb; |
| 793 | 133 | |
| 794 | 134 | $database_table_sizes = $wpdb->get_results( $wpdb->prepare( " |
| 795 | 135 | SELECT |
| @@ -804,11 +144,9 @@ | ||
| 804 | 144 | $core_tables = array( |
| 805 | 145 | 'uwp_usermeta', |
| 806 | 146 | 'uwp_form_fields', |
| 807 | 147 | 'uwp_form_extras', |
| 808 | - 'uwp_activity', | |
| 809 | - 'uwp_followers', | |
| 810 | - 'uwp_friends', | |
| 148 | + 'uwp_profile_tabs', | |
| 811 | 149 | ); |
| 812 | 150 | |
| 813 | 151 | $core_tables = apply_filters( 'uwp_database_tables', $core_tables ); |
| 814 | 152 | |
| @@ -816,9 +154,9 @@ | ||
| 816 | 154 | * Adding the prefix to the tables array, for backwards compatibility. |
| 817 | 155 | * |
| 818 | 156 | * If we changed the tables above to include the prefix, then any filters against that table could break. |
| 819 | 157 | */ |
| 820 | - $core_tables = array_map( array( $this, 'uwp_add_db_table_prefix' ), $core_tables ); | |
| 158 | + $core_tables = array_map( array( 'UsersWP_Status', 'add_db_table_prefix' ), $core_tables ); | |
| 821 | 159 | |
| 822 | 160 | /** |
| 823 | 161 | * Organize UWP and non-UWP tables separately for display purposes later. |
| 824 | 162 | * |
| @@ -854,9 +192,17 @@ | ||
| 854 | 192 | 'database_size' => $database_size, |
| 855 | 193 | ); |
| 856 | 194 | } |
| 857 | 195 | |
| 858 | - public function uwp_get_active_plugins(){ | |
| 196 | + /** | |
| 197 | + * Returns active plugins | |
| 198 | + * | |
| 199 | + * @since 1.0.0 | |
| 200 | + * @package userswp | |
| 201 | + * | |
| 202 | + * @return array | |
| 203 | + */ | |
| 204 | + public static function get_active_plugins(){ | |
| 859 | 205 | require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 860 | 206 | require_once( ABSPATH . 'wp-admin/includes/update.php' ); |
| 861 | 207 | |
| 862 | 208 | if ( ! function_exists( 'get_plugin_updates' ) ) { |
| @@ -891,9 +237,17 @@ | ||
| 891 | 237 | |
| 892 | 238 | return $active_plugins_data; |
| 893 | 239 | } |
| 894 | 240 | |
| 895 | - public function uwp_get_theme_info(){ | |
| 241 | + /** | |
| 242 | + * Returns theme info | |
| 243 | + * | |
| 244 | + * @since 1.0.0 | |
| 245 | + * @package userswp | |
| 246 | + * | |
| 247 | + * @return array | |
| 248 | + */ | |
| 249 | + public static function get_theme_info(){ | |
| 896 | 250 | $active_theme = wp_get_theme(); |
| 897 | 251 | |
| 898 | 252 | // Get parent theme info if this theme is a child theme, otherwise |
| 899 | 253 | // pass empty info in the response. |
| @@ -901,9 +255,9 @@ | ||
| 901 | 255 | $parent_theme = wp_get_theme( $active_theme->Template ); |
| 902 | 256 | $parent_theme_info = array( |
| 903 | 257 | 'parent_name' => $parent_theme->Name, |
| 904 | 258 | 'parent_version' => $parent_theme->Version, |
| 905 | - 'parent_latest_verison' => $this->get_latest_theme_version( $parent_theme ), | |
| 259 | + 'parent_latest_verison' => self::get_latest_theme_version( $parent_theme ), | |
| 906 | 260 | 'parent_author_url' => $parent_theme->{'Author URI'}, |
| 907 | 261 | ); |
| 908 | 262 | } else { |
| 909 | 263 | $parent_theme_info = array( 'parent_name' => '', 'parent_version' => '', 'parent_latest_verison' => '', 'parent_author_url' => '' ); |
| @@ -914,9 +268,9 @@ | ||
| 914 | 268 | * overrides any of them. |
| 915 | 269 | */ |
| 916 | 270 | $override_files = array(); |
| 917 | 271 | $outdated_templates = false; |
| 918 | - $scan_files = $this->scan_template_files( USERSWP_PATH . 'templates/' ); | |
| 272 | + $scan_files = self::scan_template_files( USERSWP_PATH . 'templates/' ); | |
| 919 | 273 | |
| 920 | 274 | foreach ( $scan_files as $file ) { |
| 921 | 275 | if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { |
| 922 | 276 | $theme_file = get_stylesheet_directory() . '/' . $file; |
| @@ -930,10 +284,10 @@ | ||
| 930 | 284 | $theme_file = false; |
| 931 | 285 | } |
| 932 | 286 | |
| 933 | 287 | if ( ! empty( $theme_file ) ) { |
| 934 | - $core_version = $this->get_file_version( USERSWP_PATH . '/templates/' . $file ); | |
| 935 | - $theme_version = $this->get_file_version( $theme_file ); | |
| 288 | + $core_version = self::get_file_version( USERSWP_PATH . '/templates/' . $file ); | |
| 289 | + $theme_version = self::get_file_version( $theme_file ); | |
| 936 | 290 | if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) { |
| 937 | 291 | if ( ! $outdated_templates ) { |
| 938 | 292 | $outdated_templates = true; |
| 939 | 293 | } |
| @@ -948,9 +302,9 @@ | ||
| 948 | 302 | |
| 949 | 303 | $active_theme_info = array( |
| 950 | 304 | 'name' => $active_theme->Name, |
| 951 | 305 | 'version' => $active_theme->Version, |
| 952 | - 'latest_verison' => $this->get_latest_theme_version( $active_theme ), | |
| 306 | + 'latest_verison' => self::get_latest_theme_version( $active_theme ), | |
| 953 | 307 | 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), |
| 954 | 308 | 'is_child_theme' => is_child_theme(), |
| 955 | 309 | 'has_outdated_templates' => $outdated_templates, |
| 956 | 310 | 'overrides' => $override_files, |
| @@ -958,9 +312,17 @@ | ||
| 958 | 312 | |
| 959 | 313 | return array_merge( $active_theme_info, $parent_theme_info ); |
| 960 | 314 | } |
| 961 | 315 | |
| 962 | - public function uwp_get_security_info(){ | |
| 316 | + /** | |
| 317 | + * Returns security info | |
| 318 | + * | |
| 319 | + * @since 1.0.0 | |
| 320 | + * @package userswp | |
| 321 | + * | |
| 322 | + * @return array | |
| 323 | + */ | |
| 324 | + public static function get_security_info(){ | |
| 963 | 325 | $check_page = get_home_url(); |
| 964 | 326 | return array( |
| 965 | 327 | 'secure_connection' => 'https' === substr( $check_page, 0, 5 ), |
| 966 | 328 | 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), |
| @@ -966,9 +328,17 @@ | ||
| 966 | 328 | 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), |
| 967 | 329 | ); |
| 968 | 330 | } |
| 969 | 331 | |
| 970 | - public function uwp_get_pages(){ | |
| 332 | + /** | |
| 333 | + * Returns pages | |
| 334 | + * | |
| 335 | + * @since 1.0.0 | |
| 336 | + * @package userswp | |
| 337 | + * | |
| 338 | + * @return array | |
| 339 | + */ | |
| 340 | + public static function get_pages(){ | |
| 971 | 341 | $check_pages = array( |
| 972 | 342 | _x( 'Profile Page', 'Page setting', 'userswp' ) => array( |
| 973 | 343 | 'option' => 'profile_page', |
| 974 | 344 | 'shortcode' => '[uwp_profile]', |
| @@ -1009,12 +379,13 @@ | ||
| 1009 | 379 | foreach ( $check_pages as $page_name => $values ) { |
| 1010 | 380 | $page_id = uwp_get_page_id( $values['option'], '' ); |
| 1011 | 381 | $page_set = $page_exists = $page_visible = false; |
| 1012 | 382 | $shortcode_present = $shortcode_required = false; |
| 1013 | - $page = get_post( $page_id ); | |
| 383 | + $page = false; | |
| 1014 | 384 | // Page checks |
| 1015 | 385 | if ( $page_id ) { |
| 1016 | 386 | $page_set = true; |
| 387 | + $page = get_post( $page_id ); | |
| 1017 | 388 | } |
| 1018 | 389 | if ( $page ) { |
| 1019 | 390 | $page_exists = true; |
| 1020 | 391 | } |
| @@ -1051,9 +422,9 @@ | ||
| 1051 | 422 | * |
| 1052 | 423 | * @param string $table table name |
| 1053 | 424 | * @return string |
| 1054 | 425 | */ |
| 1055 | - protected function uwp_add_db_table_prefix( $table ) { | |
| 426 | + protected static function add_db_table_prefix( $table ) { | |
| 1056 | 427 | return uwp_get_table_prefix() . $table; |
| 1057 | 428 | } |
| 1058 | 429 | |
| 1059 | 430 | /** |
| @@ -1063,9 +434,9 @@ | ||
| 1063 | 434 | * |
| 1064 | 435 | * @param object $theme WP_Theme object. |
| 1065 | 436 | * @return string Version number if found. |
| 1066 | 437 | */ |
| 1067 | - public function get_latest_theme_version( $theme ) { | |
| 438 | + public static function get_latest_theme_version( $theme ) { | |
| 1068 | 439 | include_once( ABSPATH . 'wp-admin/includes/theme.php' ); |
| 1069 | 440 | |
| 1070 | 441 | $api = themes_api( 'theme_information', array( |
| 1071 | 442 | 'slug' => $theme->get_stylesheet(), |
| @@ -1090,9 +461,9 @@ | ||
| 1090 | 461 | * |
| 1091 | 462 | * @param string $template_path Path to the template directory. |
| 1092 | 463 | * @return array |
| 1093 | 464 | */ |
| 1094 | - public function scan_template_files( $template_path ) { | |
| 465 | + public static function scan_template_files( $template_path ) { | |
| 1095 | 466 | $files = @scandir( $template_path ); // @codingStandardsIgnoreLine. |
| 1096 | 467 | $result = array(); |
| 1097 | 468 | |
| 1098 | 469 | if ( ! empty( $files ) ) { |
| @@ -1101,9 +472,9 @@ | ||
| 1101 | 472 | |
| 1102 | 473 | if ( ! in_array( $value, array( '.', '..' ), true ) ) { |
| 1103 | 474 | |
| 1104 | 475 | if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) { |
| 1105 | - $sub_files = $this->scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); | |
| 476 | + $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); | |
| 1106 | 477 | foreach ( $sub_files as $sub_file ) { |
| 1107 | 478 | $result[] = $value . DIRECTORY_SEPARATOR . $sub_file; |
| 1108 | 479 | } |
| 1109 | 480 | } else { |
| @@ -1121,9 +492,9 @@ | ||
| 1121 | 492 | * @since 1.0.20 |
| 1122 | 493 | * @param string $file Path to the file. |
| 1123 | 494 | * @return string |
| 1124 | 495 | */ |
| 1125 | - public function get_file_version( $file ) { | |
| 496 | + public static function get_file_version( $file ) { | |
| 1126 | 497 | |
| 1127 | 498 | // Avoid notices if file does not exist. |
| 1128 | 499 | if ( ! file_exists( $file ) ) { |
| 1129 | 500 | return ''; |