wpseek.com
				Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
			_get_plugin_from_callback is private and should not be used in themes or plugins directly.
_get_plugin_from_callback › WordPress Function
Seit5.0.0
Veraltetn/v
› _get_plugin_from_callback ( $callback )
| Zugriff: | 
 | 
| Parameter: | 
 | 
| Gibt zurück: | 
 | 
| Definiert in: | 
 | 
| Codex: | 
Internal helper function to find the plugin from a meta box callback.
Ähnliche Funktionen: wp_targeted_link_rel_callback, _sort_uname_callback, get_plugin_data, wp_get_plugin_error, _sort_name_callback
	Quellcode
function _get_plugin_from_callback( $callback ) {
	try {
		if ( is_array( $callback ) ) {
			$reflection = new ReflectionMethod( $callback[0], $callback[1] );
		} elseif ( is_string( $callback ) && str_contains( $callback, '::' ) ) {
			$reflection = new ReflectionMethod( $callback );
		} else {
			$reflection = new ReflectionFunction( $callback );
		}
	} catch ( ReflectionException $exception ) {
		// We could not properly reflect on the callable, so we abort here.
		return null;
	}
	// Don't show an error if it's an internal PHP function.
	if ( ! $reflection->isInternal() ) {
		// Only show errors if the meta box was registered by a plugin.
		$filename   = wp_normalize_path( $reflection->getFileName() );
		$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
		if ( str_starts_with( $filename, $plugin_dir ) ) {
			$filename = str_replace( $plugin_dir, '', $filename );
			$filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename );
			$plugins = get_plugins();
			foreach ( $plugins as $name => $plugin ) {
				if ( str_starts_with( $name, $filename ) ) {
					return $plugin;
				}
			}
		}
	}
	return null;
}