diff --git a/Aeria/Field/Fields/TermsField.php b/Aeria/Field/Fields/TermsField.php index 55f9efe..f0545c9 100644 --- a/Aeria/Field/Fields/TermsField.php +++ b/Aeria/Field/Fields/TermsField.php @@ -15,15 +15,17 @@ class TermsField extends SelectField { protected $original_config; + /** * Transform the config array; note that this does not operate on - * `$this->config`: this way it can be called from outside + * `$this->config`: this way it can be called from outside. * - * @param array $config the field's config + * @param array $config the field's config * - * @return array the transformed config + * @return array the transformed config */ - public static function transformConfig(array $config) { + public static function transformConfig(array $config) + { $config['type'] = 'select'; $taxonomy = (isset($config['taxonomy'])) ? $config['taxonomy'] : 'category'; @@ -34,19 +36,25 @@ public static function transformConfig(array $config) { 'hide_empty' => $hide_empty, )); - $config['options'] = array_map( - function ($term) { - return array( - 'label' => $term->name, - 'value' => $term->term_id, - ); - }, - array_values($terms) - ); + $config['options'] = []; + + if (!empty($terms) && !is_wp_error($terms)) { + $config['options'] = array_map( + function ($term) { + return array( + 'label' => $term->name, + 'value' => $term->term_id, + ); + }, + array_values($terms) + ); + } unset($config['taxonomy']); + return parent::transformConfig($config); } + /** * Constructs the field. * diff --git a/Aeria/Kernel/Tasks/CreateTaxonomy.php b/Aeria/Kernel/Tasks/CreateTaxonomy.php index d2acb67..7920029 100644 --- a/Aeria/Kernel/Tasks/CreateTaxonomy.php +++ b/Aeria/Kernel/Tasks/CreateTaxonomy.php @@ -6,25 +6,24 @@ /** * This task is in charge of creating the taxonomies. - * + * * @category Kernel - * @package Aeria + * * @author Simone Montali * @license https://github.com/caffeinalab/aeria/blob/master/LICENSE MIT license - * @link https://github.com/caffeinalab/aeria + * + * @see https://github.com/caffeinalab/aeria */ class CreateTaxonomy extends Task { - public $priority = 3; + public $priority = 1; public $admin_only = false; + /** * The main task method. It registers the needed taxonomies. * * @param array $args the arguments to be passed to the Task * - * @return void - * - * @access public * @since Method available since Release 3.0.0 */ public function do(array $args) @@ -40,5 +39,4 @@ public function do(array $args) } } } - -} \ No newline at end of file +}