根据this answer.
不能放置任何循环或控制结构if/else
像array
值或其中的任何位置array()
.
示例
$contact_list = [];
$contact_list[\'url\'] = \'Website\';
foreach ( wp_get_user_contact_methods() as $value => $label ) {
$contact_list[$value] = $label;
}
$settings_fields = array( // Parent array
\'dsbl_basics\' => array( // Child array
array( // Child\'s child array
\'name\' => \'text_val\',
\'label\' => \'Text Input\'
)
),
\'dsbl_profile\' => array( // Child array
array( // Child\'s child array
\'name\' => \'name\',
\'label\' => \'dsbl\',
\'options\' => array(
\'first_name\' => \'First Name\',
\'last_name\' => \'Last Name\'
)
),
array( // Child\'s child array
\'name\' => \'contact_info\',
\'label\' => \'Contact Info\',
\'options\' => $contact_list
)
)
);
$yoast_plugin = array( // Child\'s child array
\'name\' => \'yoast_seo\',
\'label\' => \'Yoast SEO\',
\'options\' => array(
\'wpseo_author_title\' => \'Title to use for Author page\',
\'wpseo_author_metadesc\' => \'Meta description to use for Author page\'
)
);
if ( is_plugin_active( \'wordpress-seo/wp-seo.php\' ) ) {
$settings_fields[\'dsbl_profile\'][1] = $yoast_plugin;
}