Example #1
1
function wp_term_like_callback()
{
    $id = $_POST['actionId'];
    $num = get_term_meta($id, '_term_like', true) ? get_term_meta($id, '_term_like', true) : 0;
    $domain = $_SERVER['HTTP_HOST'] != 'localhost' ? $_SERVER['HTTP_HOST'] : false;
    // make cookies work with localhost
    setcookie('_term_like_' . $id, $id, $expire, '/', $domain, false);
    update_term_meta($id, '_term_like', $num + 1);
    echo json_encode(array('status' => 200, 'data' => $num + 1));
    die;
}
function cstmstff_cat_public()
{
    $taxonomies = array('cstmstff-cat-public');
    $args = array('hide_empty' => 0);
    $terms = get_terms($taxonomies, $args);
    echo '<h3>' . __('Display Category Public', 'custom-stuff') . '</h3>';
    echo '<ul>';
    foreach ($terms as $term) {
        echo '<li>' . esc_html($term->name) . '</li>';
        echo '<li>' . esc_html($term->term_id) . '</li>';
        echo '<li>' . esc_html($term->slug) . '</li>';
        echo '<li>' . esc_html($term->description) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-text', true)) . '</li>';
        echo '<li>' . esc_url(get_term_meta($term->term_id, 'cstmstff-url', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-multitext01', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-multitext02', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-multitext03', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-multitext04', true)) . '</li>';
        echo '<li>' . wpautop(esc_textarea(get_term_meta($term->term_id, 'cstmstff-textarea', true))) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-select', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-radio', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-checkbox', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-multicheck01', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-multicheck02', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-multicheck03', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-multicheck04', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-color', true)) . '</li>';
        echo '<li>' . esc_url(get_term_meta($term->term_id, 'cstmstff-image', true)) . '</li>';
        echo '<li>' . esc_html(get_term_meta($term->term_id, 'cstmstff-editor', true)) . '</li>';
    }
    echo '</ul>';
    echo '<hr />';
}
Example #3
0
/**
 * Add custom headline and / or description to category / tag / taxonomy archive pages.
 *
 * If the page is not a category, tag or taxonomy term archive, or there's no term, or
 * no term meta set, then nothing extra is displayed.
 *
 * If there's a title to display, it is marked up as a level 1 heading.
 *
 * If there's a description to display, it runs through `wpautop()` before being added to a div.
 *
 * @since 1.3.0
 *
 * @global WP_Query $wp_query Query object.
 *
 * @return null Return early if not the correct archive page, not page one, or no term meta is set.
 */
function genesis_do_taxonomy_title_description()
{
    global $wp_query;
    if (!is_category() && !is_tag() && !is_tax()) {
        return;
    }
    $term = is_tax() ? get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')) : $wp_query->get_queried_object();
    if (!$term) {
        return;
    }
    $headline = $intro_text = '';
    if ($headline = get_term_meta($term->term_id, 'headline', true)) {
        $headline = sprintf('<h1 %s>%s</h1>', genesis_attr('archive-title'), strip_tags($headline));
    } else {
        if (genesis_a11y('headings')) {
            $headline = sprintf('<h1 %s>%s</h1>', genesis_attr('archive-title'), strip_tags($term->name));
        }
    }
    if ($intro_text = get_term_meta($term->term_id, 'intro_text', true)) {
        $intro_text = apply_filters('genesis_term_intro_text_output', $intro_text);
    }
    if ($headline || $intro_text) {
        printf('<div %s>%s</div>', genesis_attr('taxonomy-archive-description'), $headline . $intro_text);
    }
}
Example #4
0
/**
 * Load the entry type id on a taxonomy.
 *
 * @param  string $entry_type_id
 * @param  string $type
 *
 * @return string
 */
function papi_load_taxonomy_type_id($entry_type_id = '', $type = 'term')
{
    if ($type !== 'term') {
        return $entry_type_id;
    }
    $key = papi_get_page_type_key();
    $term_id = papi_get_term_id();
    $taxonomy = papi_get_taxonomy($term_id);
    // Try to load the entry type id from only taxonomy type filter.
    if (empty($entry_type_id)) {
        $entry_type_id = papi_filter_settings_only_taxonomy_type($taxonomy);
    }
    // If we have a term id we can load the entry type id from the term.
    if (empty($entry_type_id) && $term_id > 0 && papi_supports_term_meta()) {
        $meta_value = get_term_meta($term_id, $key, true);
        $entry_type_id = empty($meta_value) ? '' : $meta_value;
    }
    // Load entry type id from the container if it exists.
    if (empty($entry_type_id)) {
        $key = sprintf('entry_type_id.taxonomy.%s', $taxonomy);
        if (papi()->exists($key)) {
            return papi()->make($key);
        }
    }
    return $entry_type_id;
}
Example #5
0
    function bottom_text_taxonomy_edit_meta_field($term)
    {
        // put the term ID into a variable
        $t_id = $term->term_id;
        // retrieve the existing value(s) for this meta field. This returns an array
        $term_meta = get_term_meta($t_id, 'cat_meta');
        if (!$term_meta) {
            $term_meta = add_term_meta($t_id, 'cat_meta', '');
        }
        ?>
  <tr class="form-field">
  <th scope="row" valign="top"><label for="term_meta[cat_footer]"><?php 
        _e('Bottom Content', 'flatsome');
        ?>
</label></th>
    <td>        
        <?php 
        $content = isset($term_meta[0]['cat_footer']) ? esc_attr($term_meta[0]['cat_footer']) : '';
        echo '<textarea id="term_meta[cat_footer]" name="term_meta[cat_footer]">' . $content . '</textarea>';
        ?>
      <p class="description"><?php 
        _e('Enter a value for this field. Shortcodes are allowed. This will be displayed at bottom of the category.', 'flatsome');
        ?>
</p>
    </td>
  </tr>
<?php 
    }
 function tax_detail_map($atts, $template = '', $code = "")
 {
     global $term_id;
     $address = get_term_meta($term_id, 'gaddress', true);
     if (trim($address) == '') {
         $address = get_term_meta($term_id, 'address', true);
         foreach (array('city', 'state', 'zip', 'country') as $field) {
             ${$field} = get_term_meta($term_id, $field, true);
         }
         if ($zip != '' || $state != '') {
             $address .= ", {$state} {$zip}";
         }
         if ($country != '') {
             $address .= ", {$country}";
         }
     }
     $atts['address'] = $address;
     foreach (array('ginfo' => 'info_windows', 'glat' => 'glat', 'glon' => 'glon') as $meta => $att) {
         $val = get_term_meta($term_id, $meta, true);
         if (!empty($val)) {
             $atts[$att] = $val;
         }
     }
     $all_empty = true;
     foreach (array('address', 'glat', 'glon') as $field) {
         if ('' != trim($atts[$field])) {
             $all_empty = false;
             break;
         }
     }
     if ($all_empty) {
         return '';
     }
     return $this->google_map($atts, $template, $code);
 }
function edit_category_template_field($term)
{
    $cat_template = get_term_meta($term->term_id, 'wsi_prodcut_cat_template', true);
    $templates = array('tempalte1' => 'Template1', 'tempalte2' => 'Template2', 'tempalte3' => 'Template3');
    ?>
    <tr class="form-field">
        <th scope="row" valign="top">
            <label for="wsi_prodcut_cat_template"><?php 
    _e('Category template', 'wsigenesis');
    ?>
</label>
        </th>
        <td>
            <select name="wsi_prodcut_cat_template" id="wsi_prodcut_cat_template">
                <?php 
    foreach ($templates as $val => $label) {
        if ($cat_template == $val) {
            echo '<option value="' . $val . '" selected>' . $label . '</option>';
        } else {
            echo '<option value="' . $val . '">' . $label . '</option>';
        }
    }
    ?>
            </select>
            <p class="description"><?php 
    _e('Select the template which will be applied to all category products', 'wsigenesis');
    ?>
</p>
        </td>
    </tr>
    <?php 
}
Example #8
0
 public function get_raw_value()
 {
     // Since meta data (for posts and users, anyway) was historically loaded by get_*_meta() with $single = false,
     // it always returned an array even for single fields. Keeping that for compatibility with toolset-forms and
     // simplicity.
     return get_term_meta($this->object_id, $this->meta_key, false);
 }
             delete_term_meta($term_id, $ashu_feild['id']);
         }
     }
 }
 function save_taxonomy_metadata($term_id)
 {
     foreach ($this->ashu_feild as $ashu_feild) {
         if (isset($ashu_feild['id']) && $ashu_feild['id'] && isset($_POST[$ashu_feild['id']])) {
             if (!current_user_can('manage_categories')) {
                 return;
             }
             $old_data = get_term_meta($term_id, $ashu_feild['id'], true);
             if ($ashu_feild['type'] == 'tinymce') {
                 $data = stripslashes($_POST[$ashu_feild['id']]);
             } elseif ($ashu_feild['type'] == 'checkbox') {
                 $data = $_POST[$ashu_feild['id']];
             } elseif ($ashu_feild['type'] == 'numbers_array' || $ashu_feild['type'] == 'gallery') {
                 $data = explode(',', $_POST[$ashu_feild['id']]);
                 $data = array_filter($data);
             } elseif (in_array($ashu_feild['type'], array('open', 'close', 'title'))) {
                 continue;
             } else {
                 $data = htmlspecialchars($_POST[$ashu_feild['id']], ENT_QUOTES, "UTF-8");
             }
             if ($data == "") {
                 delete_term_meta($term_id, $ashu_feild['id'], $data);
             } else {
                 update_term_meta($term_id, $ashu_feild['id'], $data);
Example #10
0
function edit_category_seo_field($term)
{
    global $feature_groups;
    ?>
<tr class="form-field term-group-wrap">
        <th scope="row"><label for="meta-title"><?php 
    _e('Meta Title', 'jkc');
    ?>
</label></th>
        <td><input name="meta-title" id="meta-title" type="text" value="<?php 
    echo get_term_meta($term->term_id, 'meta-title', true);
    ?>
" /><p class="description">This meta title will be used in category listing pages as title tag. </p></td>
    </tr><tr class="form-field term-group-wrap">
        <th scope="row"><label for="meta-keywords"><?php 
    _e('Meta Keywords', 'jkc');
    ?>
</label></th>
        <td><textarea name="meta-keywords" rows="3" id="meta-keywords"><?php 
    echo get_term_meta($term->term_id, 'meta-keywords', true);
    ?>
</textarea><p class="description">This meta keywords will be used in category listing pages.</p></td>
    </tr><tr class="form-field term-group-wrap">
        <th scope="row"><label for="meta-keywords"><?php 
    _e('Meta Description', 'jkc');
    ?>
</label></th>
        <td><textarea name="meta-description" rows="3" id="meta-description"><?php 
    echo get_term_meta($term->term_id, 'meta-description', true);
    ?>
</textarea><p class="description">This meta description will be used in category listing pages.</p></td>
    </tr><?php 
}
 function render_edit_tags($meta)
 {
     $tab = null;
     require_once "taxonomy-metadata.php";
     //require_once $this->pluginpath.'options-panel/class.pop_input.php';
     foreach ($meta as $i => $o) {
         $o->type = property_exists($o, 'type') ? $o->type : 'text';
         if (in_array($o->type, array('subtitle'))) {
             $method = "__" . $o->type;
             $this->{$method}($tab, $i, $o);
             continue;
         }
         if (false !== $this->term_id && $this->term_id > 0) {
             $o->load_option = property_exists($o, 'load_option') ? $o->load_option : true;
             if ($o->load_option) {
                 $o->value = get_term_meta($this->term_id, $this->get_meta_key(null, $i, $o), true);
             }
         }
         $output = $this->template;
         $output = str_replace("{required}", property_exists($o, 'required') && $o->required ? $this->required_class : '', $output);
         $output = str_replace("{class}", $this->get_id(null, $i, $o), $output);
         $output = str_replace("{label}", $this->label(null, $i, $o), $output);
         $output = str_replace("{input}", $this->input(null, $i, $o), $output);
         $output = str_replace("{description}", $this->description(null, $i, $o), $output);
         echo $output;
     }
 }
 /**
  * Get post image.
  *
  * @since  1.0.0
  * @return string
  */
 public function get_image($args = array(), $type = 'post', $ID = 0)
 {
     $object = call_user_func(array($this, 'get_' . $type . '_object'), $ID);
     if ('post' === $type && empty($object->ID) || 'term' === $type && empty($object->term_id)) {
         return false;
     }
     $default_args = array('size' => apply_filters('cherry_normal_image_size', 'post-thumbnail'), 'mobile_size' => apply_filters('cherry_mobile_image_size', 'post-thumbnail'), 'class' => 'wp-image', 'html' => '<img src="%1$s" alt="%2$s" %3$s %4$s >', 'placeholder_background' => '000', 'placeholder_foreground' => 'fff', 'placeholder_title' => '', 'html_tag_suze' => true);
     $args = array_merge($default_args, $args);
     $size = wp_is_mobile() ? $args['mobile_size'] : $args['size'];
     $size_array = $this->get_thumbnail_size_array($size);
     $class = $args['class'] ? 'class="' . $args['class'] . '"' : '';
     $html_tag_suze = $args['html_tag_suze'] ? 'width="' . $size_array['width'] . 'px" height="' . $size_array['height'] . 'px"' : '';
     if ('post' === $type) {
         $ID = $object->ID;
         $thumbnail_id = get_post_thumbnail_id($ID);
         $alt = esc_attr($object->post_title);
     } else {
         $ID = $object->term_id;
         $thumbnail_id = get_term_meta($ID, $this->args['meta_key']['term_thumb'], true);
         $alt = esc_attr($object->name);
     }
     if ($thumbnail_id) {
         $src = wp_get_attachment_image_url($thumbnail_id, $size);
     } else {
         // Place holder defaults attr
         $title = $args['placeholder_title'] ? $args['placeholder_title'] : $size_array['width'] . 'x' . $size_array['height'];
         $attr = array('width' => $size_array['width'], 'height' => $size_array['height'], 'background' => $args['placeholder_background'], 'foreground' => $args['placeholder_foreground'], 'title' => $title);
         $attr = array_map('esc_attr', $attr);
         $src = 'http://fakeimg.pl/' . $attr['width'] . 'x' . $attr['height'] . '/' . $attr['background'] . '/' . $attr['foreground'] . '/?text=' . $attr['title'] . '';
     }
     $html = sprintf($args['html'], $src, $alt, $class, $html_tag_suze);
     return $html;
 }
Example #13
0
 public static function category_custom_columns($content, $column_name, $term_id)
 {
     switch ($column_name) {
         case "xicolor":
             echo "<div class=\"xi_admin_color_box\">\r\n                        <div class=\"inner\" style=\"background: " . get_term_meta($term_id, 'xi_category_color', true) . "\">\r\n                        </div>\r\n                    </div>";
             break;
     }
 }
function fsi_term_meta_replace($term_id, $data)
{
    $meta_keys = array_keys(get_term_meta($term_id));
    foreach ($meta_keys as $meta_key) {
        delete_term_meta($term_id, $meta_key);
    }
    fsi_term_meta_update($term_id, $data);
}
Example #15
0
function hocwp_term_get_meta($term_id, $meta_key, $single = true)
{
    $version = hocwp_get_wp_version();
    if (version_compare($version, '4.4', '>=')) {
        return get_term_meta($term_id, $meta_key, $single);
    }
    hocwp_term_register_termmeta_table();
    return get_metadata('term', $term_id, $meta_key, $single);
}
 /**
  * Get post image.
  *
  * @return string
  */
 public function get_image($args = array(), $type = 'post', $id = 0)
 {
     if (is_callable(array($this, 'get_' . $type . '_object'))) {
         $object = call_user_func(array($this, 'get_' . $type . '_object'), $id);
         if ('post' === $type && empty($object->ID) || 'term' === $type && empty($object->term_id)) {
             return '';
         }
     }
     $default_args = array('visible' => true, 'size' => apply_filters('cherry_normal_image_size', 'post-thumbnail'), 'mobile_size' => apply_filters('cherry_mobile_image_size', 'post-thumbnail'), 'html' => '<a href="%1$s" %2$s ><img src="%3$s" alt="%4$s" %5$s ></a>', 'class' => 'wp-image', 'placeholder' => true, 'placeholder_background' => '000', 'placeholder_foreground' => 'fff', 'placeholder_title' => '', 'html_tag_suze' => true, 'echo' => false);
     $args = wp_parse_args($args, $default_args);
     $html = '';
     if (filter_var($args['visible'], FILTER_VALIDATE_BOOLEAN)) {
         $size = wp_is_mobile() ? $args['mobile_size'] : $args['size'];
         $size = in_array($size, get_intermediate_image_sizes()) ? $size : 'post-thumbnail';
         // Place holder defaults attr
         $size_array = $this->get_thumbnail_size_array($size);
         switch ($type) {
             case 'post':
                 $id = $object->ID;
                 $thumbnail_id = get_post_thumbnail_id($id);
                 $alt = esc_attr($object->post_title);
                 $link = $this->get_post_permalink();
                 break;
             case 'term':
                 $id = $object->term_id;
                 $thumbnail_id = get_term_meta($id, $this->args['meta_key']['term_thumb'], true);
                 $alt = esc_attr($object->name);
                 $link = $this->get_term_permalink($id);
                 break;
             case 'attachment':
                 $thumbnail_id = $id;
                 $alt = get_the_title($thumbnail_id);
                 $link = wp_get_attachment_image_url($thumbnail_id, $size);
                 break;
         }
         if ($thumbnail_id) {
             $image_data = wp_get_attachment_image_src($thumbnail_id, $size);
             $src = $image_data[0];
             $size_array['width'] = $image_data[1];
             $size_array['height'] = $image_data[2];
         } elseif (filter_var($args['placeholder'], FILTER_VALIDATE_BOOLEAN)) {
             $title = $args['placeholder_title'] ? $args['placeholder_title'] : $size_array['width'] . 'x' . $size_array['height'];
             $attr = array('width' => $size_array['width'], 'height' => $size_array['height'], 'background' => $args['placeholder_background'], 'foreground' => $args['placeholder_foreground'], 'title' => $title);
             $attr = array_map('esc_attr', $attr);
             $width = 4000 < intval($attr['width']) ? 4000 : intval($attr['width']);
             $height = 4000 < intval($attr['height']) ? 4000 : intval($attr['height']);
             $src = $this->get_placeholder_url(array('width' => $width, 'height' => $height, 'background' => $attr['background'], 'foreground' => $attr['foreground'], 'title' => $attr['title']));
         }
         $class = $args['class'] ? 'class="' . $args['class'] . '"' : '';
         $html_tag_suze = filter_var($args['html_tag_suze'], FILTER_VALIDATE_BOOLEAN) ? 'width="' . $size_array['width'] . '" height="' . $size_array['height'] . '"' : '';
         if (isset($src)) {
             $html = sprintf($args['html'], $link, $class, $src, $alt, $html_tag_suze);
         }
     }
     return $this->output_method($html, $args['echo']);
 }
 function handle_delete_taxonomy_term($term, $tt_id)
 {
     require_once "taxonomy-metadata.php";
     $meta_to_remove = get_term_meta($term, '');
     if (is_array($meta_to_remove) && count($meta_to_remove) > 0) {
         foreach ($meta_to_remove as $meta_key => $meta) {
             delete_term_meta($term, $meta_key);
         }
     }
 }
Example #18
0
function fifu_cat_column_content($internal_image, $column, $term_id)
{
    if ($column == 'featured_image') {
        $url = get_term_meta($term_id, 'fifu_image_url', true);
        if ($url != '') {
            echo sprintf('<img src="%s" width="100"/>', $url);
        }
    } else {
        echo $internal_image;
    }
}
Example #19
0
 function edit_category_form_fields($term)
 {
     echo '<tr class="form-field form-required term-order-wrap">';
     echo '<th scope="row">' . __('Order', 'asgaros-forum') . '</th>';
     echo '<td>';
     $order = get_term_meta($term->term_id, 'order', true);
     echo '<input type="text" name="category_order" value="' . $order . '" />';
     echo '</td>';
     echo '</tr>';
     do_action('asgarosforum_action_edit_category_form_fields', $term);
 }
Example #20
0
 protected function import_wp_object($wp_term_id, $taxonomy)
 {
     $wp_term = get_term($wp_term_id, $taxonomy);
     $this->wp_term = $wp_term;
     $this->wp_id = $wp_term_id;
     $this->grape_href = get_term_meta($wp_term_id, '_grape_href', true);
     $this->grape_indexed = get_term_meta($wp_term_id, '_grape_indexed', true);
     $this->wp_type = $taxonomy;
     $this->url = '';
     $this->title = html_entity_decode(strip_tags(get_the_title($wp_term_id)));
     $this->description = term_description($wp_term_id, $taxonomy);
 }
Example #21
0
File: pack.php Project: bigfa/Puma
/**
 * Term like button
 *
 *
 * @since Puma 2.1.0
 *
 * @param text prefix
 * @return Term like button
 */
function wp_term_like($prefix = null)
{
    global $wp_query;
    if (!is_tax() && !is_category() && !is_tag()) {
        return;
    }
    $tax = $wp_query->get_queried_object();
    $id = $tax->term_id;
    $num = get_term_meta($id, '_term_like', true) ? get_term_meta($id, '_term_like', true) : 0;
    $active = isset($_COOKIE['_term_like_' . $id]) ? ' is-active' : '';
    $output = '<button class="button termlike' . $active . '" data-action="termlike" data-action-id="' . $id . '">' . $prefix . '<span class="count">' . $num . '</span></button>';
    return $output;
}
 public function get(array $args = array())
 {
     $result = array();
     foreach ($this->places as $id) {
         $gp_id = get_term_meta($id, 'google_id', true);
         if (empty($gp_id)) {
             continue;
         }
         $url = $this->get_google_url($gp_id);
         $data = wp_remote_get($url, $args);
         $result[$id] = $this->parse_result($data);
     }
     return $result;
 }
Example #23
0
function fifu_cat_show_box($term)
{
    $margin = 'margin-top:10px;';
    $width = 'width:100%;';
    $height = 'height:266px;';
    $align = 'text-align:left;';
    $url = get_term_meta($term->term_id, 'fifu_image_url', true);
    $alt = get_term_meta($term->term_id, 'fifu_image_alt', true);
    if ($url) {
        $show_url = $show_button = 'display:none;';
    } else {
        $show_alt = $show_image = $show_link = 'display:none;';
    }
    include 'html/category.html';
    include 'html/category-advertisement.html';
}
Example #24
0
function wpjam_get_term_thumbnail_uri($term = null)
{
    if (!$term) {
        $term = get_queried_object();
    }
    if (!$term) {
        return false;
    }
    if (is_object($term)) {
        $term_id = $term->term_id;
    } else {
        $term_id = $term;
    }
    if ($term_thumbnail = get_term_meta($term_id, 'thumbnail', true)) {
        return $term_thumbnail;
    }
}
Example #25
0
 private function get_meta($key, $name = null, $single = false)
 {
     $name = is_null($name) ? $key : $name;
     if (isset($this->data[$name])) {
         return;
     }
     switch ($this->object_type) {
         case 'post':
         case 'user':
         case 'comment':
             $this->data[$name] = get_metadata($this->object_type, $this->object_id, $key, $single);
             break;
         case 'term':
             $this->data[$name] = get_term_meta($this->object_id, $key, $single);
             break;
     }
 }
Example #26
0
 public function getMeta($key = null, $single = false)
 {
     $value = null;
     if (function_exists('get_term_meta')) {
         $value = get_term_meta($this->_term->term_id, $key, $single);
     }
     if (empty($value)) {
         empty($this->_meta) and $this->_meta = stripslashes_deep(get_option('taxonomy_term_' . $this->_term->term_id));
         if (empty($key)) {
             $value = $this->_meta;
         }
         if (isset($this->_meta[$key])) {
             $value = $this->_meta[$key];
         }
     }
     return $value;
 }
function mbdb_tax_grid_content($attr, $content)
{
    $attr = shortcode_atts(array('taxonomy' => '', 'term' => ''), $attr);
    global $wp_query;
    if (isset($wp_query->query_vars['the-term'])) {
        $term = trim(urldecode($wp_query->query_vars['the-term']), '/');
    } else {
        $term = $attr['term'];
    }
    if (isset($wp_query->query_vars['the-taxonomy'])) {
        $taxonomy = trim(urldecode($wp_query->query_vars['the-taxonomy']), '/');
    } else {
        $taxonomy = $attr['taxonomy'];
    }
    if ($taxonomy == '' || $term == '') {
        return __('There was an error!', 'mooberry-book-manager');
    }
    $selection = str_replace('mbdb_', '', $taxonomy);
    //$groups[1] = $selection;
    $groups[1] = 'none';
    $groups[2] = 'none';
    //$current_group = array($selection => 0, 'none' => 0);
    $current_group = array('none' => 0);
    $sort = mbdb_set_sort($groups, 'titleA');
    // set sort varialbles
    //list( $orderby, $order ) = MBDB()->books->get_sort_fields( $sort );
    // get id
    $term_obj = get_term_by('slug', $term, $taxonomy);
    if ($term_obj != null) {
        $selected_ids = array((int) $term_obj->term_id);
    } else {
        $selected_ids = null;
    }
    $books = apply_filters('mbdb_tax_grid_get_group', mbdb_get_group(1, $groups, $current_group, $selection, $selected_ids, $sort, null), $groups, $current_group, $selection, $selected_ids, $sort, $term);
    //$orderby, $order, null);
    /********************* term meta ***************************************/
    if (function_exists('get_term_meta')) {
        $content = '<p>' . get_term_meta($selected_ids[0], $taxonomy . '_book_grid_description', true) . '</p>';
        $content2 = '<p>' . get_term_meta($selected_ids[0], $taxonomy . '_book_grid_description_bottom', true) . '</p>';
    } else {
        $content = '';
        $content2 = '';
    }
    return $content . mbdb_display_grid($books, 0) . $content2;
}
Example #28
0
 public function get($name, $default = null)
 {
     if (!$this->object->raw) {
         return;
     }
     if (!isset($this->cache[$name])) {
         if ($this->object->raw instanceof \WP_Post) {
             $this->cache[$name] = get_post_meta($this->object->raw->ID, $name, true);
         }
         if ($this->object->raw instanceof \WP_Term) {
             $this->cache[$name] = get_term_meta($this->object->raw->term_id, $name, true);
         }
         if ($this->object->raw instanceof \WP_User) {
             $this->cache[$name] = get_user_meta($this->object->raw->ID, $name, true);
         }
     }
     return !isset($this->cache[$name]) or (is_null($this->cache[$name]) or empty($this->cache[$name])) ? $default : $this->cache[$name];
 }
Example #29
0
 public function get_meta($field = '', $single = false, $formatted = false)
 {
     $use_wpptd = null === $single || $formatted;
     if ($field) {
         if ($use_wpptd && function_exists('wpptd_get_term_meta_value')) {
             return wpptd_get_term_meta_value($this->item->term_id, $field, $single, $formatted);
         }
         if (!$single) {
             $single = false;
         }
         return get_term_meta($this->item->term_id, $field, $single);
     } else {
         if ($use_wpptd && function_exists('wpptd_get_term_meta_values')) {
             return wpptd_get_term_meta_values($this->item->term_id, $single, $formatted);
         }
         return get_term_meta($this->item->term_id);
     }
 }
Example #30
-1
 public function save($term_id)
 {
     foreach ($this->fields as $id => $field) {
         if ($field) {
             add_term_meta($term_id, MI_PREFIX . $id, $_POST[$id], true) or update_term_meta($term_id, MI_PREFIX . $id, $_POST[$id], get_term_meta($term_id, MI_PREFIX . $id, true));
         }
     }
 }