Skip to content

Commit ecf726c

Browse files
crstaufbarryhughes
authored andcommitted
save
1 parent 903e424 commit ecf726c

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

classes/ActionScheduler_AdminView.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,19 @@ public function add_help_tabs() {
250250
return;
251251
}
252252

253-
$as_version = ActionScheduler_Versions::instance()->latest_version();
254-
$as_source = ActionScheduler_Versions::instance()->active_source();
253+
$as_version = ActionScheduler_Versions::instance()->latest_version();
254+
$as_source = ActionScheduler_Versions::instance()->active_source();
255+
$as_source_path = ActionScheduler_Versions::instance()->active_source_path();
256+
$as_source_markup = sprintf( '<code>%s</code>', esc_html( $as_source_path ) );
257+
258+
if ( ! empty( $as_source ) ) {
259+
$as_source_markup = sprintf(
260+
'%s: <abbr title="%s">%s</abbr>',
261+
ucfirst( $as_source['type'] ),
262+
esc_attr( $as_source_path ),
263+
esc_html( $as_source['name'] )
264+
);
265+
}
255266

256267
$screen->add_help_tab(
257268
array(
@@ -267,7 +278,7 @@ public function add_help_tabs() {
267278
'<p>' .
268279
esc_html__( 'Action Scheduler is currently being loaded from the following location. This can be useful when debugging, or if requested by the support team.', 'action-scheduler' ) .
269280
'</p>' .
270-
'<p><code>' . esc_html( $as_source ) . '</code></p>' .
281+
'<p>' . $as_source_markup . '</p>' .
271282
'<h3>' . esc_html__( 'WP CLI', 'action-scheduler' ) . '</h3>' .
272283
'<p>' .
273284
sprintf(

classes/ActionScheduler_Versions.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,58 @@ public static function initialize_latest_version() {
115115
* @return string
116116
*/
117117
public function active_source() {
118+
$file = __FILE__;
119+
$dir = __DIR__;
120+
$path = $this->active_source_path();
121+
$themes = (array) search_theme_directories();
122+
123+
foreach ( $themes as $slug => $data ) {
124+
$needle = trailingslashit( $data['theme_root'] ) . $slug . '/';
125+
126+
if ( 0 !== strpos( $file, $needle ) ) {
127+
continue;
128+
}
129+
130+
$theme = wp_get_theme( $slug );
131+
132+
if ( ! is_object( $theme ) || ! is_a( $theme, \WP_Theme::class ) ) {
133+
continue;
134+
}
135+
136+
return array(
137+
'type' => 'theme',
138+
'name' => $theme->Name,
139+
);
140+
}
141+
142+
$plugins = get_plugins();
143+
$plugin_files = array_keys( $plugins );
144+
$plugin_paths = array();
145+
146+
foreach ( $plugin_files as $plugin_file ) {
147+
$plugin_path = trailingslashit( WP_PLUGIN_DIR ) . dirname( $plugin_file );
148+
$plugin_file = trailingslashit( WP_PLUGIN_DIR ) . $plugin_file;
149+
150+
if ( 0 !== strpos( dirname( $dir ), $plugin_path ) ) {
151+
continue;
152+
}
153+
154+
$plugin_data = get_plugin_data( $plugin_file );
155+
156+
if ( ! is_array( $plugin_data ) || empty( $plugin_data['Name'] ) ) {
157+
continue;
158+
}
159+
160+
return array(
161+
'type' => 'plugin',
162+
'name' => $plugin_data['Name'],
163+
);
164+
}
165+
166+
return array();
167+
}
168+
169+
public function active_source_path() {
118170
return trailingslashit( dirname( __DIR__ ) );
119171
}
120172
}

0 commit comments

Comments
 (0)