Changeset 59479 for trunk/src/wp-admin/includes/plugin.php
- Timestamp:
- 12/02/2024 05:08:19 PM (7 months ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.