| 1 |
<?php |
| 2 |
/** |
| 3 |
* UsersWP status functions |
| 4 |
* |
| 5 |
* All UsersWP status related functions can be found here. |
| 6 |
* |
| 7 |
* @since 1.0.20 |
| 8 |
*/ |
| 9 |
class UsersWP_Status { |
| 10 |
|
| 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' ); |
| 19 |
} |
| 20 |
|
| 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' ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Get array of environment information. Includes thing like software |
| 34 |
* versions, and various server settings. |
| 35 |
* |
| 36 |
* @return array |
| 37 |
*/ |
| 38 |
public static function get_environment_info() { |
| 39 |
global $wpdb; |
| 40 |
|
| 41 |
// Figure out cURL version, if installed. |
| 42 |
$curl_version = ''; |
| 43 |
if ( function_exists( 'curl_version' ) ) { |
| 44 |
$curl_version = curl_version(); |
| 45 |
$curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version']; |
| 46 |
} |
| 47 |
|
| 48 |
// WP memory limit |
| 49 |
$wp_memory_limit = uwp_let_to_num( WP_MEMORY_LIMIT ); |
| 50 |
if ( function_exists( 'memory_get_usage' ) ) { |
| 51 |
$wp_memory_limit = max( $wp_memory_limit, uwp_let_to_num( @ini_get( 'memory_limit' ) ) ); |
| 52 |
} |
| 53 |
|
| 54 |
// User agent |
| 55 |
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
| 56 |
|
| 57 |
// Test POST requests |
| 58 |
$post_response = wp_safe_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', array( |
| 59 |
'timeout' => 10, |
| 60 |
'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url(), |
| 61 |
'httpversion' => '1.1', |
| 62 |
'body' => array( |
| 63 |
'useragent' => $user_agent, |
| 64 |
), |
| 65 |
) ); |
| 66 |
|
| 67 |
$post_response_body = NULL; |
| 68 |
$post_response_successful = false; |
| 69 |
if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { |
| 70 |
$post_response_successful = true; |
| 71 |
$post_response_body = json_decode( wp_remote_retrieve_body( $post_response ), true ); |
| 72 |
} |
| 73 |
|
| 74 |
// Test GET requests |
| 75 |
$get_response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/userswp/trunk/readme.txt', array( |
| 76 |
'timeout' => 10, |
| 77 |
'user-agent' => 'UsersWP/' . USERSWP_VERSION, |
| 78 |
'httpversion' => '1.1' |
| 79 |
) ); |
| 80 |
$get_response_successful = false; |
| 81 |
if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { |
| 82 |
$get_response_successful = true; |
| 83 |
} |
| 84 |
|
| 85 |
// Return all environment info. Described by JSON Schema. |
| 86 |
return array( |
| 87 |
'home_url' => get_option( 'home' ), |
| 88 |
'site_url' => get_option( 'siteurl' ), |
| 89 |
'version' => USERSWP_VERSION, |
| 90 |
'wp_version' => get_bloginfo( 'version' ), |
| 91 |
'wp_multisite' => is_multisite(), |
| 92 |
'wp_memory_limit' => $wp_memory_limit, |
| 93 |
'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), |
| 94 |
'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ), |
| 95 |
'language' => get_locale(), |
| 96 |
'server_info' => $_SERVER['SERVER_SOFTWARE'], |
| 97 |
'php_version' => phpversion(), |
| 98 |
'php_post_max_size' => uwp_let_to_num( ini_get( 'post_max_size' ) ), |
| 99 |
'php_max_execution_time' => ini_get( 'max_execution_time' ), |
| 100 |
'php_max_input_vars' => ini_get( 'max_input_vars' ), |
| 101 |
'curl_version' => $curl_version, |
| 102 |
'suhosin_installed' => extension_loaded( 'suhosin' ), |
| 103 |
'max_upload_size' => wp_max_upload_size(), |
| 104 |
'mysql_version' => ( ! empty( $wpdb->is_mysql ) ? $wpdb->db_version() : '' ), |
| 105 |
'default_timezone' => date_default_timezone_get(), |
| 106 |
'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ), |
| 107 |
'soapclient_enabled' => class_exists( 'SoapClient' ), |
| 108 |
'domdocument_enabled' => class_exists( 'DOMDocument' ), |
| 109 |
'gzip_enabled' => is_callable( 'gzopen' ), |
| 110 |
'gd_library' => extension_loaded( 'gd' ), |
| 111 |
'mbstring_enabled' => extension_loaded( 'mbstring' ), |
| 112 |
'remote_post_successful' => $post_response_successful, |
| 113 |
'remote_post_response' => ( is_wp_error( $post_response ) ? $post_response->get_error_message() : $post_response['response']['code'] ), |
| 114 |
'remote_get_successful' => $get_response_successful, |
| 115 |
'remote_get_response' => ( is_wp_error( $get_response ) ? $get_response->get_error_message() : $get_response['response']['code'] ), |
| 116 |
'platform' => ! empty( $post_response_body['platform'] ) ? $post_response_body['platform'] : '-', |
| 117 |
'browser_name' => ! empty( $post_response_body['name'] ) ? $post_response_body['name'] : '-', |
| 118 |
'browser_version' => ! empty( $post_response_body['version'] ) ? $post_response_body['version'] : '-', |
| 119 |
'user_agent' => $user_agent |
| 120 |
); |
| 121 |
} |
| 122 |
|
| 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(){ |
| 132 |
global $wpdb; |
| 133 |
|
| 134 |
$database_table_sizes = $wpdb->get_results( $wpdb->prepare( " |
| 135 |
SELECT |
| 136 |
table_name AS 'name', |
| 137 |
round( ( data_length / 1024 / 1024 ), 2 ) 'data', |
| 138 |
round( ( index_length / 1024 / 1024 ), 2 ) 'index' |
| 139 |
FROM information_schema.TABLES |
| 140 |
WHERE table_schema = %s |
| 141 |
ORDER BY name ASC; |
| 142 |
", DB_NAME ) ); |
| 143 |
|
| 144 |
$core_tables = array( |
| 145 |
'uwp_usermeta', |
| 146 |
'uwp_form_fields', |
| 147 |
'uwp_form_extras', |
| 148 |
'uwp_profile_tabs', |
| 149 |
); |
| 150 |
|
| 151 |
$core_tables = apply_filters( 'uwp_database_tables', $core_tables ); |
| 152 |
|
| 153 |
/** |
| 154 |
* Adding the prefix to the tables array, for backwards compatibility. |
| 155 |
* |
| 156 |
* If we changed the tables above to include the prefix, then any filters against that table could break. |
| 157 |
*/ |
| 158 |
$core_tables = array_map( array( 'UsersWP_Status', 'add_db_table_prefix' ), $core_tables ); |
| 159 |
|
| 160 |
/** |
| 161 |
* Organize UWP and non-UWP tables separately for display purposes later. |
| 162 |
* |
| 163 |
* To ensure we include all UWP tables, even if they do not exist, pre-populate the UWP array with all the tables. |
| 164 |
*/ |
| 165 |
$tables = array( |
| 166 |
'userswp' => array_fill_keys( $core_tables, false ), |
| 167 |
'other' => array() |
| 168 |
); |
| 169 |
|
| 170 |
$database_size = array( |
| 171 |
'data' => 0, |
| 172 |
'index' => 0 |
| 173 |
); |
| 174 |
|
| 175 |
foreach ( $database_table_sizes as $table ) { |
| 176 |
$table_type = in_array( $table->name, $core_tables ) ? 'userswp' : 'other'; |
| 177 |
|
| 178 |
$tables[ $table_type ][ $table->name ] = array( |
| 179 |
'data' => $table->data, |
| 180 |
'index' => $table->index |
| 181 |
); |
| 182 |
|
| 183 |
$database_size[ 'data' ] += $table->data; |
| 184 |
$database_size[ 'index' ] += $table->index; |
| 185 |
} |
| 186 |
|
| 187 |
// Return all database info. Described by JSON Schema. |
| 188 |
return array( |
| 189 |
'uwp_db_version' => get_option( 'uwp_db_version' ), |
| 190 |
'database_prefix' => $wpdb->prefix, |
| 191 |
'database_tables' => $tables, |
| 192 |
'database_size' => $database_size, |
| 193 |
); |
| 194 |
} |
| 195 |
|
| 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(){ |
| 205 |
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 206 |
require_once( ABSPATH . 'wp-admin/includes/update.php' ); |
| 207 |
|
| 208 |
if ( ! function_exists( 'get_plugin_updates' ) ) { |
| 209 |
return array(); |
| 210 |
} |
| 211 |
|
| 212 |
// Get both site plugins and network plugins |
| 213 |
$active_plugins = (array) get_option( 'active_plugins', array() ); |
| 214 |
if ( is_multisite() ) { |
| 215 |
$network_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
| 216 |
$active_plugins = array_merge( $active_plugins, $network_activated_plugins ); |
| 217 |
} |
| 218 |
|
| 219 |
$active_plugins_data = array(); |
| 220 |
$available_updates = get_plugin_updates(); |
| 221 |
|
| 222 |
foreach ( $active_plugins as $plugin ) { |
| 223 |
$data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
| 224 |
|
| 225 |
// convert plugin data to json response format. |
| 226 |
$active_plugins_data[] = array( |
| 227 |
'plugin' => $plugin, |
| 228 |
'name' => $data['Name'], |
| 229 |
'version' => $data['Version'], |
| 230 |
'url' => $data['PluginURI'], |
| 231 |
'author_name' => $data['AuthorName'], |
| 232 |
'author_url' => esc_url_raw( $data['AuthorURI'] ), |
| 233 |
'network_activated' => $data['Network'], |
| 234 |
'latest_verison' => ( array_key_exists( $plugin, $available_updates ) ) ? $available_updates[$plugin]->update->new_version : $data['Version'] |
| 235 |
); |
| 236 |
} |
| 237 |
|
| 238 |
return $active_plugins_data; |
| 239 |
} |
| 240 |
|
| 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(){ |
| 250 |
$active_theme = wp_get_theme(); |
| 251 |
|
| 252 |
// Get parent theme info if this theme is a child theme, otherwise |
| 253 |
// pass empty info in the response. |
| 254 |
if ( is_child_theme() ) { |
| 255 |
$parent_theme = wp_get_theme( $active_theme->Template ); |
| 256 |
$parent_theme_info = array( |
| 257 |
'parent_name' => $parent_theme->Name, |
| 258 |
'parent_version' => $parent_theme->Version, |
| 259 |
'parent_latest_verison' => self::get_latest_theme_version( $parent_theme ), |
| 260 |
'parent_author_url' => $parent_theme->{'Author URI'}, |
| 261 |
); |
| 262 |
} else { |
| 263 |
$parent_theme_info = array( 'parent_name' => '', 'parent_version' => '', 'parent_latest_verison' => '', 'parent_author_url' => '' ); |
| 264 |
} |
| 265 |
|
| 266 |
/** |
| 267 |
* Scan the theme directory for all UWP templates to see if our theme |
| 268 |
* overrides any of them. |
| 269 |
*/ |
| 270 |
$override_files = array(); |
| 271 |
$outdated_templates = false; |
| 272 |
$scan_files = self::scan_template_files( USERSWP_PATH . 'templates/' ); |
| 273 |
|
| 274 |
foreach ( $scan_files as $file ) { |
| 275 |
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { |
| 276 |
$theme_file = get_stylesheet_directory() . '/' . $file; |
| 277 |
} elseif ( file_exists( get_stylesheet_directory() . '/userswp/' . $file ) ) { |
| 278 |
$theme_file = get_stylesheet_directory() . '/userswp/' . $file; |
| 279 |
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) { |
| 280 |
$theme_file = get_template_directory() . '/' . $file; |
| 281 |
} elseif ( file_exists( get_template_directory() . '/userswp/' . $file ) ) { |
| 282 |
$theme_file = get_template_directory() . '/userswp/' . $file; |
| 283 |
} else { |
| 284 |
$theme_file = false; |
| 285 |
} |
| 286 |
|
| 287 |
if ( ! empty( $theme_file ) ) { |
| 288 |
$core_version = self::get_file_version( USERSWP_PATH . '/templates/' . $file ); |
| 289 |
$theme_version = self::get_file_version( $theme_file ); |
| 290 |
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) { |
| 291 |
if ( ! $outdated_templates ) { |
| 292 |
$outdated_templates = true; |
| 293 |
} |
| 294 |
} |
| 295 |
$override_files[] = array( |
| 296 |
'file' => str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), |
| 297 |
'version' => $theme_version, |
| 298 |
'core_version' => $core_version, |
| 299 |
); |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
$active_theme_info = array( |
| 304 |
'name' => $active_theme->Name, |
| 305 |
'version' => $active_theme->Version, |
| 306 |
'latest_verison' => self::get_latest_theme_version( $active_theme ), |
| 307 |
'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), |
| 308 |
'is_child_theme' => is_child_theme(), |
| 309 |
'has_outdated_templates' => $outdated_templates, |
| 310 |
'overrides' => $override_files, |
| 311 |
); |
| 312 |
|
| 313 |
return array_merge( $active_theme_info, $parent_theme_info ); |
| 314 |
} |
| 315 |
|
| 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(){ |
| 325 |
$check_page = get_home_url(); |
| 326 |
return array( |
| 327 |
'secure_connection' => 'https' === substr( $check_page, 0, 5 ), |
| 328 |
'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), |
| 329 |
); |
| 330 |
} |
| 331 |
|
| 332 |
/** |
| 333 |
* Returns pages |
| 334 |
* |
| 335 |
* @since 1.0.0 |
| 336 |
* @package userswp |
| 337 |
* |
| 338 |
* @return array |
| 339 |
*/ |
| 340 |
public static function get_pages(){ |
| 341 |
$check_pages = array( |
| 342 |
_x( 'Profile Page', 'Page setting', 'userswp' ) => array( |
| 343 |
'option' => 'profile_page', |
| 344 |
'shortcode' => '[uwp_profile]', |
| 345 |
), |
| 346 |
_x( 'Register Page', 'Page setting', 'userswp' ) => array( |
| 347 |
'option' => 'register_page', |
| 348 |
'shortcode' => '[uwp_register]', |
| 349 |
), |
| 350 |
_x( 'Login Page', 'Page setting', 'userswp' ) => array( |
| 351 |
'option' => 'login_page', |
| 352 |
'shortcode' => '[uwp_login]', |
| 353 |
), |
| 354 |
_x( 'Account Page', 'Page setting', 'userswp' ) => array( |
| 355 |
'option' => 'account_page', |
| 356 |
'shortcode' => '[uwp_account]', |
| 357 |
), |
| 358 |
_x( 'Change Password Page', 'Page setting', 'userswp' ) => array( |
| 359 |
'option' => 'change_page', |
| 360 |
'shortcode' => '[uwp_change]', |
| 361 |
), |
| 362 |
_x( 'Forgot Password Page', 'Page setting', 'userswp' ) => array( |
| 363 |
'option' => 'forgot_page', |
| 364 |
'shortcode' => '[uwp_forgot]', |
| 365 |
), |
| 366 |
_x( 'Reset Password Page', 'Page setting', 'userswp' ) => array( |
| 367 |
'option' => 'reset_page', |
| 368 |
'shortcode' => '[uwp_reset]', |
| 369 |
), |
| 370 |
_x( 'Users List Page', 'Page setting', 'userswp' ) => array( |
| 371 |
'option' => 'users_page', |
| 372 |
'shortcode' => '[uwp_users]', |
| 373 |
), |
| 374 |
); |
| 375 |
|
| 376 |
$check_pages = apply_filters('uwp_status_check_pages', $check_pages); |
| 377 |
|
| 378 |
$pages_output = array(); |
| 379 |
foreach ( $check_pages as $page_name => $values ) { |
| 380 |
$page_id = uwp_get_page_id( $values['option'], '' ); |
| 381 |
$page_set = $page_exists = $page_visible = false; |
| 382 |
$shortcode_present = $shortcode_required = false; |
| 383 |
$page = false; |
| 384 |
// Page checks |
| 385 |
if ( $page_id ) { |
| 386 |
$page_set = true; |
| 387 |
$page = get_post( $page_id ); |
| 388 |
} |
| 389 |
if ( $page ) { |
| 390 |
$page_exists = true; |
| 391 |
} |
| 392 |
if ( 'publish' === get_post_status( $page_id ) ) { |
| 393 |
$page_visible = true; |
| 394 |
} |
| 395 |
|
| 396 |
// Shortcode checks |
| 397 |
if ( $values['shortcode'] && $page ) { |
| 398 |
$shortcode_required = true; |
| 399 |
if ( strstr( $page->post_content, $values['shortcode'] ) ) { |
| 400 |
$shortcode_present = true; |
| 401 |
} |
| 402 |
} |
| 403 |
|
| 404 |
// Wrap up our findings into an output array |
| 405 |
$pages_output[] = array( |
| 406 |
'page_name' => $page_name, |
| 407 |
'page_id' => $page_id, |
| 408 |
'page_set' => $page_set, |
| 409 |
'page_exists' => $page_exists, |
| 410 |
'page_visible' => $page_visible, |
| 411 |
'shortcode' => $values['shortcode'], |
| 412 |
'shortcode_required' => $shortcode_required, |
| 413 |
'shortcode_present' => $shortcode_present, |
| 414 |
); |
| 415 |
} |
| 416 |
|
| 417 |
return $pages_output; |
| 418 |
} |
| 419 |
|
| 420 |
/** |
| 421 |
* Add prefix to table. |
| 422 |
* |
| 423 |
* @param string $table table name |
| 424 |
* @return string |
| 425 |
*/ |
| 426 |
protected static function add_db_table_prefix( $table ) { |
| 427 |
return uwp_get_table_prefix() . $table; |
| 428 |
} |
| 429 |
|
| 430 |
/** |
| 431 |
* Get latest version of a theme by slug. |
| 432 |
* |
| 433 |
* @since 2.0.0 |
| 434 |
* |
| 435 |
* @param object $theme WP_Theme object. |
| 436 |
* @return string Version number if found. |
| 437 |
*/ |
| 438 |
public static function get_latest_theme_version( $theme ) { |
| 439 |
include_once( ABSPATH . 'wp-admin/includes/theme.php' ); |
| 440 |
|
| 441 |
$api = themes_api( 'theme_information', array( |
| 442 |
'slug' => $theme->get_stylesheet(), |
| 443 |
'fields' => array( |
| 444 |
'sections' => false, |
| 445 |
'tags' => false, |
| 446 |
), |
| 447 |
) ); |
| 448 |
|
| 449 |
$update_theme_version = 0; |
| 450 |
|
| 451 |
// Check .org for updates. |
| 452 |
if ( is_object( $api ) && ! is_wp_error( $api ) ) { |
| 453 |
$update_theme_version = $api->version; |
| 454 |
} |
| 455 |
|
| 456 |
return $update_theme_version; |
| 457 |
} |
| 458 |
|
| 459 |
/** |
| 460 |
* Scan the template files. |
| 461 |
* |
| 462 |
* @param string $template_path Path to the template directory. |
| 463 |
* @return array |
| 464 |
*/ |
| 465 |
public static function scan_template_files( $template_path ) { |
| 466 |
$files = @scandir( $template_path ); // @codingStandardsIgnoreLine. |
| 467 |
$result = array(); |
| 468 |
|
| 469 |
if ( ! empty( $files ) ) { |
| 470 |
|
| 471 |
foreach ( $files as $key => $value ) { |
| 472 |
|
| 473 |
if ( ! in_array( $value, array( '.', '..' ), true ) ) { |
| 474 |
|
| 475 |
if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) { |
| 476 |
$sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value ); |
| 477 |
foreach ( $sub_files as $sub_file ) { |
| 478 |
$result[] = $value . DIRECTORY_SEPARATOR . $sub_file; |
| 479 |
} |
| 480 |
} else { |
| 481 |
$result[] = $value; |
| 482 |
} |
| 483 |
} |
| 484 |
} |
| 485 |
} |
| 486 |
return $result; |
| 487 |
} |
| 488 |
|
| 489 |
/** |
| 490 |
* Retrieve metadata from a file. Based on WP Core's get_file_data function. |
| 491 |
* |
| 492 |
* @since 1.0.20 |
| 493 |
* @param string $file Path to the file. |
| 494 |
* @return string |
| 495 |
*/ |
| 496 |
public static function get_file_version( $file ) { |
| 497 |
|
| 498 |
// Avoid notices if file does not exist. |
| 499 |
if ( ! file_exists( $file ) ) { |
| 500 |
return ''; |
| 501 |
} |
| 502 |
|
| 503 |
// We don't need to write to the file, so just open for reading. |
| 504 |
$fp = fopen( $file, 'r' ); // @codingStandardsIgnoreLine. |
| 505 |
|
| 506 |
// Pull only the first 8kiB of the file in. |
| 507 |
$file_data = fread( $fp, 8192 ); // @codingStandardsIgnoreLine. |
| 508 |
|
| 509 |
// PHP will close file handle, but we are good citizens. |
| 510 |
fclose( $fp ); // @codingStandardsIgnoreLine. |
| 511 |
|
| 512 |
// Make sure we catch CR-only line endings. |
| 513 |
$file_data = str_replace( "\r", "\n", $file_data ); |
| 514 |
$version = ''; |
| 515 |
|
| 516 |
if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) { |
| 517 |
$version = _cleanup_header_comment( $match[1] ); |
| 518 |
} |
| 519 |
|
| 520 |
return $version; |
| 521 |
} |
| 522 |
} |