Example #1
0
 protected function _save($term_id)
 {
     $taxonomy_meta = TaxonomyMeta::get_instance();
     if (!$this->get_field()->is_disabled()) {
         $this->get_field()->set_value($_POST[$this->get_key()]);
         $value = $this->get_field()->get_value();
         if ($value) {
             $taxonomy_meta->update($term_id, $this->get_key(), $value);
         } else {
             $taxonomy_meta->delete($term_id, $this->get_key());
         }
     }
 }
Example #2
0
 /**
  * Get taxonomy field value
  *
  * @param int $term_id
  * @param string $key
  * @return mixed
  */
 public static function get($term_id, $key)
 {
     /**
      * Migrate from custom db table if exists to core due to termmeta support since WordPress 4.4.0
      */
     TaxonomyMeta::get_instance();
     return get_term_meta($term_id, sanitize_key($key), true);
 }