Skip to content

Commit d1afe94

Browse files
committed
Deprecate and add warnings as needed, for functionality that is now exposed via ActionScheduler_SystemInformation.
1 parent 61e6de2 commit d1afe94

File tree

1 file changed

+14
-49
lines changed

1 file changed

+14
-49
lines changed

classes/ActionScheduler_Versions.php

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public function get_versions() {
5555
/**
5656
* Get registered sources.
5757
*
58+
* Use with caution: this method is only available as of Action Scheduler's 3.9.1
59+
* release and, owing to the way Action Scheduler is loaded, it's possible that the
60+
* class definition used at runtime will belong to an earlier version.
61+
*
62+
* @since 3.9.1
63+
*
5864
* @return array<string, string>
5965
*/
6066
public function get_sources() {
@@ -122,65 +128,24 @@ public static function initialize_latest_version() {
122128
* 'name' => 'Name',
123129
* ]
124130
*
131+
* @deprecated 3.9.1 Use ActionScheduler_SystemInformation::active_source().
132+
*
125133
* @return array
126134
*/
127135
public function active_source(): array {
128-
$file = __FILE__;
129-
$dir = __DIR__;
130-
$plugins = get_plugins();
131-
$plugin_files = array_keys( $plugins );
132-
133-
foreach ( $plugin_files as $plugin_file ) {
134-
$plugin_path = trailingslashit( WP_PLUGIN_DIR ) . dirname( $plugin_file );
135-
$plugin_file = trailingslashit( WP_PLUGIN_DIR ) . $plugin_file;
136-
137-
if ( 0 !== strpos( dirname( $dir ), $plugin_path ) ) {
138-
continue;
139-
}
140-
141-
$plugin_data = get_plugin_data( $plugin_file );
142-
143-
if ( ! is_array( $plugin_data ) || empty( $plugin_data['Name'] ) ) {
144-
continue;
145-
}
146-
147-
return array(
148-
'type' => 'plugin',
149-
'name' => $plugin_data['Name'],
150-
);
151-
}
152-
153-
$themes = (array) search_theme_directories();
154-
155-
foreach ( $themes as $slug => $data ) {
156-
$needle = trailingslashit( $data['theme_root'] ) . $slug . '/';
157-
158-
if ( 0 !== strpos( $file, $needle ) ) {
159-
continue;
160-
}
161-
162-
$theme = wp_get_theme( $slug );
163-
164-
if ( ! is_object( $theme ) || ! is_a( $theme, \WP_Theme::class ) ) {
165-
continue;
166-
}
167-
168-
return array(
169-
'type' => 'theme',
170-
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
171-
'name' => $theme->Name,
172-
);
173-
}
174-
175-
return array();
136+
_deprecated_function( __METHOD__, '3.9.1', 'ActionScheduler_SystemInformation::active_source()' );
137+
return ActionScheduler_SystemInformation::active_source();
176138
}
177139

178140
/**
179141
* Returns the directory path for the currently active installation of Action Scheduler.
180142
*
143+
* @deprecated 3.9.2 Use ActionScheduler_SystemInformation::active_source_path().
144+
*
181145
* @return string
182146
*/
183147
public function active_source_path(): string {
184-
return trailingslashit( dirname( __DIR__ ) );
148+
_deprecated_function( __METHOD__, '3.9.1', 'ActionScheduler_SystemInformation::active_source_path()' );
149+
return ActionScheduler_SystemInformation::active_source_path();
185150
}
186151
}

0 commit comments

Comments
 (0)