/** * Hook building custom fields for Post types. * * @param number $term_id Contain term ID * @return number|void * @uses update_post_meta() * * @since 3.3.0 */ public function hookFieldsSave($term_id) { //Admin panel if (!TTO_IS_ADMIN) { return; } //Check term if (!isset($term_id) || empty($term_id)) { return; } //Get all requests $request = isset($_REQUEST) ? $_REQUEST : array(); //Check request if (empty($request)) { return; } //Check if we have some terms if (empty($this->terms)) { return; } //Check integrity if (!isset($request['taxonomy'])) { return; } //Get current saved taxonomy $slug = $request['taxonomy']; $contents = array(); //Check if tax exists or if its contents are empty if (!isset($this->terms[$slug])) { return; } /** * Build term contents. * * @var string $slug * @param array $contents * @return array $contents * * @since 3.3.0 */ $contents = apply_filters('tto_term_' . $slug . '_contents', $contents); //Make it works! foreach ($contents as $ctn) { $value = isset($request[$ctn['id']]) ? $request[$ctn['id']] : ''; $prefix = str_replace(array('%TERM%', '%SLUG%'), array($term_id, $slug), Engine::getPrefix()); //WP 4.4 if (function_exists('update_term_meta')) { update_term_meta($term_id, $slug . '-' . $ctn['id'], $value); } else { TeaThemeOptions::updateOption($prefix . '-' . $ctn['id'], $value); } } return; }