/** * Test behavior when using the term meta fields. */ public function test_save_term_meta() { $term_option = new Fieldmanager_Textfield(array('name' => 'term_option')); // check normal save and fetch behavior $text = rand_str(); $this->save_values($term_option, $this->term, $text); $data = fm_get_term_meta($this->term->term_id, $this->term->taxonomy, 'term_option', true); $this->assertEquals($text, $data); $data = fm_get_term_meta($this->term->term_id, $this->term->taxonomy, 'term_option', false); $this->assertEquals(array($text), $data); // check update and fetch $text_updated = rand_str(); $this->save_values($term_option, $this->term, $text_updated); $data = fm_get_term_meta($this->term->term_id, $this->term->taxonomy, 'term_option', true); $this->assertEquals($text_updated, $data); $this->assertInternalType('int', Fieldmanager_Util_Term_Meta()->get_term_meta_post_id($this->term->term_id, $this->term->taxonomy)); $cache_key = Fieldmanager_Util_Term_Meta()->get_term_meta_post_id_cache_key($this->term->term_id, $this->term->taxonomy); $this->assertNotEquals(false, wp_cache_get($cache_key)); fm_delete_term_meta($this->term->term_id, $this->term->taxonomy, 'term_option'); // post id not cached right after removal of only meta value, which results in deletion of the post $this->assertEquals(false, wp_cache_get($cache_key)); // checking that the post id is reported as false when it doesn't exist now $this->assertEquals(false, Fieldmanager_Util_Term_Meta()->get_term_meta_post_id($this->term->term_id, $this->term->taxonomy)); // checking that the post id is cached now to return false since it doesn't exist $this->assertNotEquals(false, wp_cache_get($cache_key)); }
esc_html_e('Do you — or your students — have important stories to tell? Are you reporting on topics that you believe deserve a larger audience? Do you want to sharpen your multimedia skills?', 'hsinsider'); ?> </p> </div> </section> </div> </header> <?php /** * Collect the school address markers in an array */ $terms = get_terms('school', array('hide_empty' => 0)); $markers = array(); foreach ($terms as $term) { $school_info = Fieldmanager_Util_Term_Meta()->get_term_meta($term->term_id, 'school', 'school_info', false); if (!empty($school_info[0]['address']) && '' != $school_info[0]['address']) { $school_marker = array('school' => $term->name, 'address' => $school_info[0]['address']); array_push($markers, $school_marker); } } $markers = json_encode($markers); ?> <?php if (!empty($markers)) { ?> <section class="row"> <div class="map col-sm-12 hidden-xs"> <div id="gmap" data-marker='<?php esc_attr($markers); ?>
function hsinsider_get_author_school_meta($meta_key = null) { $school_id = hsinsider_get_the_author_meta('school'); if (empty($school_id)) { return false; } $meta = Fieldmanager_Util_Term_Meta()->get_term_meta($school_id, 'school', 'school_info', true); if (empty($meta_key)) { return $meta; } if (isset($meta[$meta_key])) { return $meta[$meta_key]; } return false; }
/** * Saves custom fields for the sport taxonomy. * * @deprecated Fieldmanager-1.0.0-beta.3 This is not necessary if you're * using core's term meta. * * @access public * * @param int $term_id * @param int $tt_id * @param string $taxonomy * @param WP_term $deleted_term */ public function delete_term_fields($term_id, $tt_id, $taxonomy, $deleted_term) { // Get an instance of the term meta class $term_meta = Fieldmanager_Util_Term_Meta(); // Delete any instance of this field for the term that was deleted $term_meta->delete_term_meta($term_id, $taxonomy, $this->fm->name); }
/** * Shortcut helper for Fieldmanager_Util_Term_Meta::delete_term_meta(). * * @see Fieldmanager_Util_Term_Meta::delete_term_meta() */ function fm_delete_term_meta($term_id, $taxonomy, $meta_key, $meta_value = '') { return Fieldmanager_Util_Term_Meta()->delete_term_meta($term_id, $taxonomy, $meta_key, $meta_value); }