3030 \update_option ('extendify_insights_stop ' , true , true );
3131
3232 // Initialize the active plugins option as an empty array
33- foreach (get_custom_plugins () as $ plugin_info ) {
33+ foreach (get_installed_custom_plugins () as $ plugin_info ) {
3434 // Activate all custom plugins by default on first run
3535 // @TODO: activate all in one update_option call
3636 activate_custom_plugin ($ plugin_info ['key ' ]);
@@ -127,10 +127,9 @@ function deactivate_custom_plugin($plugin_key)
127127}
128128
129129/**
130- * Get all custom plugins from the custom plugins directory (excluding deleted ones)
131- * Returns an array of plugin info: ['key' => plugin_key, 'file' => plugin_file, 'data' => plugin_data]
130+ * Get all custom plugins from the custom plugins directory
132131 */
133- function get_custom_plugins ( bool $ include_deleted = false ): array
132+ function get_all_custom_plugins ( ): array
134133{
135134 static $ all_custom_plugins = null ;
136135
@@ -139,10 +138,15 @@ function get_custom_plugins(bool $include_deleted = false): array
139138 $ all_custom_plugins = $ bundle_config ['plugins ' ];
140139 }
141140
142- if ($ include_deleted ) {
143- return $ all_custom_plugins ;
144- }
141+ return $ all_custom_plugins ;
142+ }
145143
144+ /**
145+ * Get installed (not deleted) custom plugins
146+ */
147+ function get_installed_custom_plugins (): array
148+ {
149+ $ all_custom_plugins = get_all_custom_plugins ();
146150 // Filter out deleted plugins
147151 $ deleted_plugins = get_deleted_custom_plugins ();
148152 return array_filter ($ all_custom_plugins , function ($ plugin_info ) use ($ deleted_plugins ) {
@@ -154,7 +158,7 @@ function get_custom_plugins(bool $include_deleted = false): array
154158 * Inject activated custom plugins
155159 */
156160\add_action ('plugins_loaded ' , function () {
157- $ custom_plugins = get_custom_plugins ();
161+ $ custom_plugins = get_installed_custom_plugins ();
158162 $ active_plugins = get_active_custom_plugins ();
159163
160164 foreach ($ custom_plugins as $ plugin_info ) {
@@ -194,7 +198,7 @@ function get_custom_plugins(bool $include_deleted = false): array
194198
195199 switch ($ pagenow ) {
196200 case 'plugins.php ' :
197- $ custom_plugins = get_custom_plugins ();
201+ $ custom_plugins = get_installed_custom_plugins ();
198202 $ deleted_plugins = get_deleted_custom_plugins ();
199203
200204 foreach ($ custom_plugins as $ plugin_info ) {
@@ -226,7 +230,7 @@ function get_custom_plugins(bool $include_deleted = false): array
226230 return $ result ;
227231 }
228232
229- $ custom_plugins = get_custom_plugins ();
233+ $ custom_plugins = get_installed_custom_plugins ();
230234 $ custom_installed_plugin_slugs = array_column ($ custom_plugins , 'slug ' );
231235 $ custom_installed_plugin_slugs = array_merge (
232236 array_map (fn ($ slug ) => basename (dirname ($ slug )), get_deleted_custom_plugins ()),
@@ -265,7 +269,7 @@ function get_custom_plugins(bool $include_deleted = false): array
265269 */
266270\add_filter ('upgrader_pre_install ' , function ($ response , $ hook_extra ) {
267271 if (isset ($ hook_extra ['plugin ' ])) {
268- $ custom_plugins = get_custom_plugins ();
272+ $ custom_plugins = get_installed_custom_plugins ();
269273 $ custom_slugs = array_column ($ custom_plugins , 'slug ' );
270274
271275 // Extract slug from plugin path
@@ -520,7 +524,7 @@ function get_custom_plugins(bool $include_deleted = false): array
520524 'slug ' => $ slug ,
521525 ];
522526
523- $ custom_plugin = array_find (get_custom_plugins (), fn ($ _ ) => $ _ ['slug ' ] === $ slug );
527+ $ custom_plugin = array_find (get_installed_custom_plugins (), fn ($ _ ) => $ _ ['slug ' ] === $ slug );
524528
525529 if ($ custom_plugin ===null ) {
526530 // not a custom plugin, fallback to default handler
@@ -576,7 +580,7 @@ function get_custom_plugins(bool $include_deleted = false): array
576580
577581 $ slug = \wp_unslash ($ _POST ['slug ' ]);
578582
579- $ custom_plugin = array_find (get_custom_plugins (), fn ($ _ ) => $ _ ['slug ' ] === $ slug );
583+ $ custom_plugin = array_find (get_installed_custom_plugins (), fn ($ _ ) => $ _ ['slug ' ] === $ slug );
580584
581585 if ($ custom_plugin ===null ) {
582586 // not a custom plugin, fallback to default handler
@@ -644,7 +648,7 @@ function get_custom_plugins(bool $include_deleted = false): array
644648*/
645649\add_filter ('plugin_install_action_links ' , function ($ links , $ plugin ) {
646650 $ custom_plugin = array_find (
647- get_custom_plugins (),
651+ get_installed_custom_plugins (),
648652 // CAVEAT: we cannot name it $custom plugin since rector will name it also $custom_plugin_*
649653 // fn ($custom_plugin) => $custom_plugin['slug'] === $plugin['slug'],
650654 fn ($ _ ) => $ _ ['slug ' ] === $ plugin ['slug ' ],
0 commit comments