Changeset 12976
- Timestamp:
- 02/05/2010 09:33:53 PM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin.php
r12975 r12976 30 30 * must have the first slash. Defaults to the base folder the plugin is 31 31 * located in. 32 * Network: Optional. Specify "Network: true" to require that a plugin is activated 33 * across all sites in an installation. This will prevent a plugin from being 34 * activated on a single site when Multisite is enabled. 32 35 * * / # Remove the space to close comment 33 36 * </code> … … 44 47 * 'TextDomain' - Plugin's text domain for localization. 45 48 * 'DomainPath' - Plugin's relative directory path to .mo files. 49 * 'Network' - Boolean. Whether the plugin can only be activated network wide. 46 50 * 47 51 * Some users have issues with opening large files and manipulating the contents … … 76 80 'AuthorURI' => 'Author URI', 77 81 'TextDomain' => 'Text Domain', 78 'DomainPath' => 'Domain Path' 79 ); 82 'DomainPath' => 'Domain Path', 83 'Network' => 'Network', 84 // Site Wide Only is deprecated in favor of Network. 85 '_sitewide' => 'Site Wide Only', 86 ); 80 87 81 88 $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' ); 89 90 // Site Wide Only is the old header for Network 91 if ( empty( $plugin_data['Network'] ) && ! empty( $plugin_data['_sitewide'] ) ) { 92 _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.' ), 'Site Wide Only: true', 'Network: true' ) ); 93 $plugin_data['Network'] = $plugin_data['_sitewide']; 94 } 95 $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ) ? true : false; 96 unset( $plugin_data['_sitewide'] ); 82 97 83 98 //For backward compatibility by default Title is the same as Name. … … 92 107 function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { 93 108 94 //Translate fields 109 //Translate fields30 95 110 if ( $translate && ! empty($plugin_data['TextDomain']) ) { 96 111 if ( ! empty( $plugin_data['DomainPath'] ) ) … … 283 298 284 299 /** 285 * Checks for "Site Wide Only: true" in the plugin header to see if this should 286 * be activated as a network wide MU plugin. 300 * Checks for "Network: true" in the plugin header to see if this should 301 * be activated only as a network wide plugin. The plugin would also work 302 * when Multisite is not enabled. 303 * 304 * Checks for "Site Wide Only: true" for backwards compatibility. 287 305 * 288 306 * @since 3.0.0 289 *290 * @todo Use API for getting arbitrary plugin headers.291 307 * 292 308 * @param $file Plugin to check 293 309 * $return bool True if plugin is network only, false otherwise. 294 310 */ 295 function is_network_only_plugin( $file ) { 296 /* Open the plugin file for reading to check if this is a ms-plugin. */ 297 $fp = @fopen( WP_PLUGIN_DIR . '/' . $file, 'r' ); 298 299 /* Pull only the first 8kiB of the file in. */ 300 $plugin_data = @fread( $fp, 8192 ); 301 302 /* PHP will close file handle, but we are good citizens. */ 303 @fclose($fp); 304 305 if ( preg_match( '/(Network|Site Wide Only):(.*)true$/mi', $plugin_data ) ) 306 return true; 307 311 function is_network_only_plugin( $plugin ) { 312 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 313 if ( $plugin_data ) 314 return $plugin_data['Network']; 308 315 return false; 309 316 } -
trunk/wp-admin/plugins.php
r12974 r12976 492 492 } 493 493 } else { 494 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>'; 494 if ( is_network_only_plugin( $plugin_file ) ) 495 $actions[] = '<span title="' . __('This plugin can only be activated for all sites in a network') . '">' . __('Network Only') . '</span>'; 496 else 497 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>'; 495 498 if ( is_multisite() && is_super_admin() ) 496 499 $actions[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
Note: See TracChangeset
for help on using the changeset viewer.