@@ -115,49 +115,49 @@ public static function initialize_latest_version() {
115
115
* @return string
116
116
*/
117
117
public function active_source () {
118
- $ file = __FILE__ ;
119
- $ dir = __DIR__ ;
120
- $ themes = (array ) search_theme_directories ();
118
+ $ file = __FILE__ ;
119
+ $ dir = __DIR__ ;
120
+ $ plugins = get_plugins ();
121
+ $ plugin_files = array_keys ( $ plugins );
121
122
122
- foreach ( $ themes as $ slug => $ data ) {
123
- $ needle = trailingslashit ( $ data ['theme_root ' ] ) . $ slug . '/ ' ;
123
+ foreach ( $ plugin_files as $ plugin_file ) {
124
+ $ plugin_path = trailingslashit ( WP_PLUGIN_DIR ) . dirname ( $ plugin_file );
125
+ $ plugin_file = trailingslashit ( WP_PLUGIN_DIR ) . $ plugin_file ;
124
126
125
- if ( 0 !== strpos ( $ file , $ needle ) ) {
127
+ if ( 0 !== strpos ( dirname ( $ dir ) , $ plugin_path ) ) {
126
128
continue ;
127
129
}
128
130
129
- $ theme = wp_get_theme ( $ slug );
131
+ $ plugin_data = get_plugin_data ( $ plugin_file );
130
132
131
- if ( ! is_object ( $ theme ) || ! is_a ( $ theme , \WP_Theme::class ) ) {
133
+ if ( ! is_array ( $ plugin_data ) || empty ( $ plugin_data [ ' Name ' ] ) ) {
132
134
continue ;
133
135
}
134
136
135
137
return array (
136
- 'type ' => 'theme ' ,
137
- 'name ' => $ theme -> Name ,
138
+ 'type ' => 'plugin ' ,
139
+ 'name ' => $ plugin_data [ ' Name ' ] ,
138
140
);
139
141
}
140
142
141
- $ plugins = get_plugins ();
142
- $ plugin_files = array_keys ( $ plugins );
143
+ $ themes = (array ) search_theme_directories ();
143
144
144
- foreach ( $ plugin_files as $ plugin_file ) {
145
- $ plugin_path = trailingslashit ( WP_PLUGIN_DIR ) . dirname ( $ plugin_file );
146
- $ plugin_file = trailingslashit ( WP_PLUGIN_DIR ) . $ plugin_file ;
145
+ foreach ( $ themes as $ slug => $ data ) {
146
+ $ needle = trailingslashit ( $ data ['theme_root ' ] ) . $ slug . '/ ' ;
147
147
148
- if ( 0 !== strpos ( dirname ( $ dir ) , $ plugin_path ) ) {
148
+ if ( 0 !== strpos ( $ file , $ needle ) ) {
149
149
continue ;
150
150
}
151
151
152
- $ plugin_data = get_plugin_data ( $ plugin_file );
152
+ $ theme = wp_get_theme ( $ slug );
153
153
154
- if ( ! is_array ( $ plugin_data ) || empty ( $ plugin_data [ ' Name ' ] ) ) {
154
+ if ( ! is_object ( $ theme ) || ! is_a ( $ theme , \WP_Theme::class ) ) {
155
155
continue ;
156
156
}
157
157
158
158
return array (
159
- 'type ' => 'plugin ' ,
160
- 'name ' => $ plugin_data [ ' Name ' ] ,
159
+ 'type ' => 'theme ' ,
160
+ 'name ' => $ theme -> Name ,
161
161
);
162
162
}
163
163
0 commit comments