Changeset 59479 for trunk/src/wp-includes/functions.php
- Timestamp:
- 12/02/2024 05:08:19 PM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.