/**
  * Returns a single specified meta value for a term.
  *
  * This function is basically a wrapper for the WordPress core function `get_term_meta()`
  * when calling it with specification of a meta key. If the required field meta value is not available,
  * the function will automatically return its default value.
  *
  * Furthermore the $single parameter can be used to force an array or no array to be returned for the
  * meta field. You should generally leave it set to null.
  *
  * @since 0.6.0
  * @param integer $id the term ID to get the meta value for
  * @param string $meta_key the meta key (field slug) to get the meta value for
  * @param null|boolean $single whether to force an array or no array being returned (default is not to force anything)
  * @param boolean $formatted whether to return an automatically formatted value, ready for output (default is false)
  * @return mixed the meta value
  */
 function wpptd_get_term_meta_value($id, $meta_key, $single = null, $formatted = false)
 {
     if (!wpptd_supports_termmeta()) {
         if ($single) {
             return null;
         }
         return array();
     }
     $_meta_value = get_term_meta($id, $meta_key, false);
     if (doing_action('wpptd') || !did_action('wpptd')) {
         if ($single) {
             if (count($_meta_value) > 0) {
                 return $_meta_value[0];
             }
             return null;
         } else {
             return $_meta_value;
         }
     }
     $meta_value = null;
     $field = \WPDLib\Components\Manager::get('*.*.' . wpptd_get_taxonomy($id) . '.*.' . $meta_key, 'WPDLib\\Components\\Menu.WPPTD\\Components\\PostType.WPPTD\\Components\\Taxonomy.WPPTD\\Components\\TermMetabox', true);
     if ($field) {
         $meta_value = \WPPTD\Utility::parse_meta_value($_meta_value, $field, $single, $formatted);
     }
     return $meta_value;
 }