ActionScheduler_SystemInformation::active_sourcepublic staticWC 1.0

Returns information about the plugin or theme which contains the current active version of Action Scheduler.

If this cannot be determined, or if Action Scheduler is being loaded via some other method, then it will return an empty array. Otherwise, if populated, the array will look like the following:

[
	'type' => 'plugin', # or 'theme'
	'name' => 'Name',
]

Метод класса: ActionScheduler_SystemInformation{}

Хуков нет.

Возвращает

Массив.

Использование

$result = ActionScheduler_SystemInformation::active_source(): array;

Код ActionScheduler_SystemInformation::active_source() WC 10.0.2

public static function active_source(): array {
	$plugins      = get_plugins();
	$plugin_files = array_keys( $plugins );

	foreach ( $plugin_files as $plugin_file ) {
		$plugin_path = trailingslashit( WP_PLUGIN_DIR ) . dirname( $plugin_file );
		$plugin_file = trailingslashit( WP_PLUGIN_DIR ) . $plugin_file;

		if ( 0 !== strpos( dirname( __DIR__ ), $plugin_path ) ) {
			continue;
		}

		$plugin_data = get_plugin_data( $plugin_file );

		if ( ! is_array( $plugin_data ) || empty( $plugin_data['Name'] ) ) {
			continue;
		}

		return array(
			'type' => 'plugin',
			'name' => $plugin_data['Name'],
		);
	}

	$themes = (array) search_theme_directories();

	foreach ( $themes as $slug => $data ) {
		$needle = trailingslashit( $data['theme_root'] ) . $slug . '/';

		if ( 0 !== strpos( __FILE__, $needle ) ) {
			continue;
		}

		$theme = wp_get_theme( $slug );

		if ( ! is_object( $theme ) || ! is_a( $theme, \WP_Theme::class ) ) {
			continue;
		}

		return array(
			'type' => 'theme',
			// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
			'name' => $theme->Name,
		);
	}

	return array();
}