Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#48235 closed defect (bug) (invalid)

get_option('activate_plugins') not return Array()

Reported by: khoipro Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords:
Focuses: template Cc:

Description (last modified by SergeyBiryukov)


When switching a default theme (Twenty Nineteen) to a custom theme (made by me).

The Problem

The plugin advanced-custom-fields-pro isn't activated so it displays an error.

I tried to fix it without touching a database by adding activate_plugin() function.

if (!function_exists('get_field') ) {

Following those documents:


The error returns

Warning: in_array() expects parameter 2 to be array, string given in /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-admin/includes/plugin.php on line 630
Fatal error: Uncaught Error: [] operator not supported for strings in /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-admin/includes/plugin.php:681
Stack trace:
#0 /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-content/themes/caruso-retail/lib/class-theme-init.php(74): activate_plugin('advanced-custom...')
#1 /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-includes/class-wp-hook.php(286): Caruso_Retail_Theme->required_plugins('')
#2 /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#3 /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-includes/plugin.php(465): WP_Hook->do_action(Array)
#4 /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-settings.php(525): do_action('init')
#5 /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-config.php(38): require_once('/srv/bindings/a...')
#6 /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-load.php(37): require_once('/srv/bindings/a...')
#7 /srv/bindings/abe0a5b9a447426d in /srv/bindings/abe0a5b9a447426da8fb4ba7cd7f9471/code/wp-admin/includes/plugin.php on line 681


The debug returns get_field('activate_plugins') doesn't return an Array as it described there (https://codex.wordpress.org/Option_Reference). It returns string with i and s looks like a direct query from database row.

So I wish to know how exactly to activate a plugin correctly?

Change History (2)

#1 @knutsp
2 years ago

  • Keywords close added

There is no core option 'activate_plugins', the closest is 'active_plugins'. It will return an array unless the database options table is tampered with.

I see no core bug here, and as this Trac is for core bugs and enhancements, not support, I suggest asking in Support or Stack Exchange.

#2 @SergeyBiryukov
2 years ago

  • Description modified (diff)
  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

The debug returns get_field('activate_plugins') doesn't return an Array

get_field() is not a WordPress core function. As noted above, please try the support forums.

Note: See TracTickets for help on using tickets.