Changeset 57545 for trunk/src/wp-admin/includes/plugin.php
- Timestamp:
- 02/06/2024 11:44:09 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/plugin.php
r57337 r57545 46 46 * @since 5.3.0 Added support for `Requires at least` and `Requires PHP` headers. 47 47 * @since 5.8.0 Added support for `Update URI` header. 48 * @since 6.5.0 Added support for `Requires Plugins` header. 48 49 * 49 50 * @param string $plugin_file Absolute path to the main plugin file. … … 54 55 * Plugin data. Values will be empty if not supplied by the plugin. 55 56 * 56 * @type string $Name Name of the plugin. Should be unique. 57 * @type string $PluginURI Plugin URI. 58 * @type string $Version Plugin version. 59 * @type string $Description Plugin description. 60 * @type string $Author Plugin author's name. 61 * @type string $AuthorURI Plugin author's website address (if set). 62 * @type string $TextDomain Plugin textdomain. 63 * @type string $DomainPath Plugin's relative directory path to .mo files. 64 * @type bool $Network Whether the plugin can only be activated network-wide. 65 * @type string $RequiresWP Minimum required version of WordPress. 66 * @type string $RequiresPHP Minimum required version of PHP. 67 * @type string $UpdateURI ID of the plugin for update purposes, should be a URI. 68 * @type string $Title Title of the plugin and link to the plugin's site (if set). 69 * @type string $AuthorName Plugin author's name. 57 * @type string $Name Name of the plugin. Should be unique. 58 * @type string $PluginURI Plugin URI. 59 * @type string $Version Plugin version. 60 * @type string $Description Plugin description. 61 * @type string $Author Plugin author's name. 62 * @type string $AuthorURI Plugin author's website address (if set). 63 * @type string $TextDomain Plugin textdomain. 64 * @type string $DomainPath Plugin's relative directory path to .mo files. 65 * @type bool $Network Whether the plugin can only be activated network-wide. 66 * @type string $RequiresWP Minimum required version of WordPress. 67 * @type string $RequiresPHP Minimum required version of PHP. 68 * @type string $UpdateURI ID of the plugin for update purposes, should be a URI. 69 * @type string $RequiresPlugins Comma separated list of dot org plugin slugs. 70 * @type string $Title Title of the plugin and link to the plugin's site (if set). 71 * @type string $AuthorName Plugin author's name. 70 72 * } 71 73 */ … … 73 75 74 76 $default_headers = array( 75 'Name' => 'Plugin Name', 76 'PluginURI' => 'Plugin URI', 77 'Version' => 'Version', 78 'Description' => 'Description', 79 'Author' => 'Author', 80 'AuthorURI' => 'Author URI', 81 'TextDomain' => 'Text Domain', 82 'DomainPath' => 'Domain Path', 83 'Network' => 'Network', 84 'RequiresWP' => 'Requires at least', 85 'RequiresPHP' => 'Requires PHP', 86 'UpdateURI' => 'Update URI', 77 'Name' => 'Plugin Name', 78 'PluginURI' => 'Plugin URI', 79 'Version' => 'Version', 80 'Description' => 'Description', 81 'Author' => 'Author', 82 'AuthorURI' => 'Author URI', 83 'TextDomain' => 'Text Domain', 84 'DomainPath' => 'Domain Path', 85 'Network' => 'Network', 86 'RequiresWP' => 'Requires at least', 87 'RequiresPHP' => 'Requires PHP', 88 'UpdateURI' => 'Update URI', 89 'RequiresPlugins' => 'Requires Plugins', 87 90 // Site Wide Only is deprecated in favor of Network. 88 '_sitewide' => 'Site Wide Only',91 '_sitewide' => 'Site Wide Only', 89 92 ); 90 93 … … 331 334 } 332 335 336 $new_plugin_data = array(); 333 337 foreach ( $plugin_files as $plugin_file ) { 334 338 if ( ! is_readable( "$plugin_root/$plugin_file" ) ) { … … 343 347 } 344 348 349 $new_plugin_file = str_replace( 350 trailingslashit( WP_PLUGIN_DIR ), 351 '', 352 "$plugin_root/$plugin_file" 353 ); 354 355 $new_plugin_data[ $new_plugin_file ] = $plugin_data; 345 356 $wp_plugins[ plugin_basename( $plugin_file ) ] = $plugin_data; 346 357 } … … 350 361 $cache_plugins[ $plugin_folder ] = $wp_plugins; 351 362 wp_cache_set( 'plugins', $cache_plugins, 'plugins' ); 363 update_option( 'plugin_data', $new_plugin_data ); 352 364 353 365 return $wp_plugins; … … 952 964 953 965 $plugin_translations = wp_get_installed_translations( 'plugins' ); 966 $all_plugin_data = get_option( 'plugin_data', array() ); 954 967 955 968 $errors = array(); … … 996 1009 continue; 997 1010 } 1011 unset( $all_plugin_data[ $plugin_file ] ); 998 1012 999 1013 $plugin_slug = dirname( $plugin_file ); … … 1044 1058 return new WP_Error( 'could_not_remove_plugin', sprintf( $message, implode( ', ', $errors ) ) ); 1045 1059 } 1060 update_option( 'plugin_data', $all_plugin_data ); 1046 1061 1047 1062 return true; … … 1115 1130 * Validates the plugin requirements for WordPress version and PHP version. 1116 1131 * 1117 * Uses the information from `Requires at least` and `Requires PHP` headers1132 * Uses the information from `Requires at least`, `Requires PHP` and `Requires Plugins` headers 1118 1133 * defined in the plugin's main PHP file. 1119 1134 * … … 1122 1137 * main PHP file, with `readme.txt` as a fallback. 1123 1138 * @since 5.8.0 Removed support for using `readme.txt` as a fallback. 1139 * @since 6.5.0 Added support for the 'Requires Plugins' header. 1124 1140 * 1125 1141 * @param string $plugin Path to the plugin file relative to the plugins directory. … … 1130 1146 1131 1147 $requirements = array( 1132 'requires' => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '', 1133 'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '', 1148 'requires' => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '', 1149 'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '', 1150 'requires_plugins' => ! empty( $plugin_headers['RequiresPlugins'] ) ? $plugin_headers['RequiresPlugins'] : '', 1134 1151 ); 1135 1152 … … 1186 1203 } 1187 1204 1205 if ( WP_Plugin_Dependencies::has_unmet_dependencies( $plugin ) ) { 1206 $dependencies = WP_Plugin_Dependencies::get_dependencies( $plugin ); 1207 $unmet_dependencies = array(); 1208 1209 foreach ( $dependencies as $dependency ) { 1210 $dependency_file = WP_Plugin_Dependencies::get_dependency_filepath( $dependency ); 1211 1212 if ( false === $dependency_file ) { 1213 $unmet_dependencies['not_installed'][] = $dependency; 1214 } elseif ( is_plugin_inactive( $dependency_file ) ) { 1215 $unmet_dependencies['inactive'][] = $dependency; 1216 } 1217 } 1218 1219 return new WP_Error( 1220 'plugin_missing_dependencies', 1221 '<p>' . sprintf( 1222 /* translators: %s: Plugin name. */ 1223 _x( '<strong>Error:</strong> %s requires plugins that are not installed or activated.', 'plugin' ), 1224 $plugin_headers['Name'] 1225 ) . '</p>', 1226 $unmet_dependencies 1227 ); 1228 } 1229 1188 1230 return true; 1189 1231 }
Note: See TracChangeset
for help on using the changeset viewer.