Changeset 59479
- Timestamp:
- 12/02/2024 05:08:19 PM (7 months ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/plugin.php
r59461 r59479 303 303 304 304 return $dropins; 305 }306 307 /**308 * Determines whether a plugin is active.309 *310 * Only plugins installed in the plugins/ folder can be active.311 *312 * Plugins in the mu-plugins/ folder can't be "activated," so this function will313 * return false for those plugins.314 *315 * For more information on this and similar theme functions, check out316 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/317 * Conditional Tags} article in the Theme Developer Handbook.318 *319 * @since 2.5.0320 *321 * @param string $plugin Path to the plugin file relative to the plugins directory.322 * @return bool True, if in the active plugins list. False, not in the list.323 */324 function is_plugin_active( $plugin ) {325 return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );326 }327 328 /**329 * Determines whether the plugin is inactive.330 *331 * Reverse of is_plugin_active(). Used as a callback.332 *333 * For more information on this and similar theme functions, check out334 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/335 * Conditional Tags} article in the Theme Developer Handbook.336 *337 * @since 3.1.0338 *339 * @see is_plugin_active()340 *341 * @param string $plugin Path to the plugin file relative to the plugins directory.342 * @return bool True if inactive. False if active.343 */344 function is_plugin_inactive( $plugin ) {345 return ! is_plugin_active( $plugin );346 }347 348 /**349 * Determines whether the plugin is active for the entire network.350 *351 * Only plugins installed in the plugins/ folder can be active.352 *353 * Plugins in the mu-plugins/ folder can't be "activated," so this function will354 * return false for those plugins.355 *356 * For more information on this and similar theme functions, check out357 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/358 * Conditional Tags} article in the Theme Developer Handbook.359 *360 * @since 3.0.0361 *362 * @param string $plugin Path to the plugin file relative to the plugins directory.363 * @return bool True if active for the network, otherwise false.364 */365 function is_plugin_active_for_network( $plugin ) {366 if ( ! is_multisite() ) {367 return false;368 }369 370 $plugins = get_site_option( 'active_sitewide_plugins' );371 if ( isset( $plugins[ $plugin ] ) ) {372 return true;373 }374 375 return false;376 }377 378 /**379 * Checks for "Network: true" in the plugin header to see if this should380 * be activated only as a network wide plugin. The plugin would also work381 * when Multisite is not enabled.382 *383 * Checks for "Site Wide Only: true" for backward compatibility.384 *385 * @since 3.0.0386 *387 * @param string $plugin Path to the plugin file relative to the plugins directory.388 * @return bool True if plugin is network only, false otherwise.389 */390 function is_network_only_plugin( $plugin ) {391 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );392 if ( $plugin_data ) {393 return $plugin_data['Network'];394 }395 return false;396 305 } 397 306 -
trunk/src/wp-includes/functions.php
r59471 r59479 7147 7147 7148 7148 /** 7149 * Determines whether a plugin is active. 7150 * 7151 * Only plugins installed in the plugins/ folder can be active. 7152 * 7153 * Plugins in the mu-plugins/ folder can't be "activated," so this function will 7154 * return false for those plugins. 7155 * 7156 * For more information on this and similar theme functions, check out 7157 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 7158 * Conditional Tags} article in the Theme Developer Handbook. 7159 * 7160 * @since 2.5.0 7161 * 7162 * @param string $plugin Path to the plugin file relative to the plugins directory. 7163 * @return bool True, if in the active plugins list. False, not in the list. 7164 */ 7165 function is_plugin_active( $plugin ) { 7166 return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin ); 7167 } 7168 7169 /** 7170 * Determines whether the plugin is inactive. 7171 * 7172 * Reverse of is_plugin_active(). Used as a callback. 7173 * 7174 * For more information on this and similar theme functions, check out 7175 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 7176 * Conditional Tags} article in the Theme Developer Handbook. 7177 * 7178 * @since 3.1.0 7179 * 7180 * @see is_plugin_active() 7181 * 7182 * @param string $plugin Path to the plugin file relative to the plugins directory. 7183 * @return bool True if inactive. False if active. 7184 */ 7185 function is_plugin_inactive( $plugin ) { 7186 return ! is_plugin_active( $plugin ); 7187 } 7188 7189 /** 7190 * Determines whether the plugin is active for the entire network. 7191 * 7192 * Only plugins installed in the plugins/ folder can be active. 7193 * 7194 * Plugins in the mu-plugins/ folder can't be "activated," so this function will 7195 * return false for those plugins. 7196 * 7197 * For more information on this and similar theme functions, check out 7198 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 7199 * Conditional Tags} article in the Theme Developer Handbook. 7200 * 7201 * @since 3.0.0 7202 * 7203 * @param string $plugin Path to the plugin file relative to the plugins directory. 7204 * @return bool True if active for the network, otherwise false. 7205 */ 7206 function is_plugin_active_for_network( $plugin ) { 7207 if ( ! is_multisite() ) { 7208 return false; 7209 } 7210 7211 $plugins = get_site_option( 'active_sitewide_plugins' ); 7212 if ( isset( $plugins[ $plugin ] ) ) { 7213 return true; 7214 } 7215 7216 return false; 7217 } 7218 7219 /** 7220 * Checks for "Network: true" in the plugin header to see if this should 7221 * be activated only as a network wide plugin. The plugin would also work 7222 * when Multisite is not enabled. 7223 * 7224 * Checks for "Site Wide Only: true" for backward compatibility. 7225 * 7226 * @since 3.0.0 7227 * 7228 * @param string $plugin Path to the plugin file relative to the plugins directory. 7229 * @return bool True if plugin is network only, false otherwise. 7230 */ 7231 function is_network_only_plugin( $plugin ) { 7232 $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 7233 if ( $plugin_data ) { 7234 return $plugin_data['Network']; 7235 } 7236 return false; 7237 } 7238 7239 /** 7149 7240 * Returns true. 7150 7241 *
Note: See TracChangeset
for help on using the changeset viewer.