@@ -55,6 +55,12 @@ public function get_versions() {
55
55
/**
56
56
* Get registered sources.
57
57
*
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
+ *
58
64
* @return array<string, string>
59
65
*/
60
66
public function get_sources () {
@@ -122,65 +128,24 @@ public static function initialize_latest_version() {
122
128
* 'name' => 'Name',
123
129
* ]
124
130
*
131
+ * @deprecated 3.9.1 Use ActionScheduler_SystemInformation::active_source().
132
+ *
125
133
* @return array
126
134
*/
127
135
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 ();
176
138
}
177
139
178
140
/**
179
141
* Returns the directory path for the currently active installation of Action Scheduler.
180
142
*
143
+ * @deprecated 3.9.2 Use ActionScheduler_SystemInformation::active_source_path().
144
+ *
181
145
* @return string
182
146
*/
183
147
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 ();
185
150
}
186
151
}
0 commit comments