Changeset 44978 for trunk/src/wp-admin/includes/plugin.php
- Timestamp:
- 03/22/2019 12:36:30 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/plugin.php
r44973 r44978 598 598 * 599 599 * @since 2.5.0 600 * @since 5.2.0 Test for WordPress version and PHP version compatibility. 600 601 * 601 602 * @param string $plugin Path to the plugin file relative to the plugins directory. … … 620 621 if ( is_wp_error( $valid ) ) { 621 622 return $valid; 623 } 624 625 $requirements = validate_plugin_requirements( $plugin ); 626 if ( is_wp_error( $requirements ) ) { 627 return $requirements; 622 628 } 623 629 … … 1059 1065 } 1060 1066 return 0; 1067 } 1068 1069 /** 1070 * Validate the plugin requirements for WP version and PHP version. 1071 * 1072 * @since 5.2.0 1073 * 1074 * @param string $plugin Path to the plugin file relative to the plugins directory. 1075 * @return true|WP_Error True if requirements are met, WP_Error on failure. 1076 */ 1077 function validate_plugin_requirements( $plugin ) { 1078 $readme_file = WP_PLUGIN_DIR . '/' . dirname( $plugin ) . '/readme.txt'; 1079 1080 if ( file_exists( $readme_file ) ) { 1081 $plugin_data = get_file_data( 1082 $readme_file, 1083 array( 1084 'requires' => 'Requires at least', 1085 'requires_php' => 'Requires PHP', 1086 ), 1087 'plugin' 1088 ); 1089 } else { 1090 return true; 1091 } 1092 1093 $plugin_data['wp_compatible'] = wp_is_wp_compatible( $plugin_data['requires'] ); 1094 $plugin_data['php_compatible'] = wp_is_php_compatible( $plugin_data['requires_php'] ); 1095 1096 $plugin_data = array_merge( $plugin_data, get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) ); 1097 1098 if ( ! $plugin_data['wp_compatible'] && ! $plugin_data['php_compatible'] ) { 1099 return new WP_Error( 'plugin_wp_php_incompatible', sprintf( 1100 /* translators: %s: plugin name */ 1101 __( '<strong>Error:</strong> Current WordPress and PHP versions do not meet minimum requirements for %s.' ), $plugin_data['Name'] ) 1102 ); 1103 } elseif ( ! $plugin_data['php_compatible'] ) { 1104 return new WP_Error( 'plugin_php_incompatible', sprintf( 1105 /* translators: %s: plugin name */ 1106 __( '<strong>Error:</strong> Current PHP version does not meet minimum requirements for %s.' ), $plugin_data['Name'] ) 1107 ); 1108 } elseif ( ! $plugin_data['wp_compatible'] ) { 1109 return new WP_Error( 'plugin_wp_incompatible', sprintf( 1110 /* translators: %s: plugin name */ 1111 __( '<strong>Error:</strong> Current WordPress version does not meet minimum requirements for %s.' ), $plugin_data['Name'] ) 1112 ); 1113 } 1114 1115 return true; 1061 1116 } 1062 1117
Note: See TracChangeset
for help on using the changeset viewer.