• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_term_by函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_term_by函数的典型用法代码示例。如果您正苦于以下问题:PHP get_term_by函数的具体用法?PHP get_term_by怎么用?PHP get_term_by使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_term_by函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wpml_save_term

 /**
  * Ajax handler for adding a term via Ajax.
  */
 public static function wpml_save_term()
 {
     if (!wpml_is_action_authenticated('wpml_save_term')) {
         wp_send_json_error('Wrong Nonce');
     }
     global $sitepress;
     $lang = filter_input(INPUT_POST, 'term_language_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
     $taxonomy = filter_input(INPUT_POST, 'taxonomy');
     $slug = filter_input(INPUT_POST, 'slug');
     $name = filter_input(INPUT_POST, 'name');
     $trid = filter_input(INPUT_POST, 'trid', FILTER_SANITIZE_NUMBER_INT);
     $description = filter_input(INPUT_POST, 'description');
     $new_term_object = false;
     if ($name !== "" && $taxonomy && $trid && $lang) {
         $args = array('taxonomy' => $taxonomy, 'lang_code' => $lang, 'term' => $name, 'trid' => $trid, 'overwrite' => true);
         if ($slug) {
             $args['slug'] = $slug;
         }
         if ($description) {
             $args['description'] = $description;
         }
         $res = WPML_Terms_Translations::create_new_term($args);
         if ($res && isset($res['term_taxonomy_id'])) {
             /* res holds the term taxonomy id, we return the whole term objects to the ajax call */
             $new_term_object = get_term_by('term_taxonomy_id', (int) $res['term_taxonomy_id'], $taxonomy);
             $lang_details = $sitepress->get_element_language_details($new_term_object->term_taxonomy_id, 'tax_' . $new_term_object->taxonomy);
             $new_term_object->trid = $lang_details->trid;
             $new_term_object->language_code = $lang_details->language_code;
             WPML_Terms_Translations::icl_save_term_translation_action($taxonomy, $res);
         }
     }
     wp_send_json_success($new_term_object);
 }
开发者ID:edgarter,项目名称:wecare,代码行数:36,代码来源:wpml-post-edit-ajax.class.php


示例2: jm_fix_admin_bar

/**
 * Will remove the normal edit button, and add one with a proper link
 */
function jm_fix_admin_bar()
{
    global $wp_admin_bar, $post;
    $wp_admin_bar->remove_menu('edit');
    $term = get_term_by('slug', $_GET['product_cat'], 'product_cat');
    $wp_admin_bar->add_menu(array('parent' => false, 'title' => 'Edit Category', 'href' => admin_url('edit-tags.php?action=edit&taxonomy=product_cat&tag_ID=' . $term->term_id . '&post_type=product'), 'id' => 'edit'));
}
开发者ID:eddiewilson,项目名称:new-ke,代码行数:10,代码来源:jm-cat-fix.php


示例3: get_unit_object

 public function get_unit_object($key, $by = 'slug')
 {
     if ($term = get_term_by($by, $key, $this->taxonomy)) {
         return $term;
     }
     return false;
 }
开发者ID:ronzeiller,项目名称:woocommerce-germanized,代码行数:7,代码来源:class-wc-gzd-units.php


示例4: wpml_link_to_element

function wpml_link_to_element($element_id, $element_type = 'post', $link_text = '', $optional_parameters = array(), $anchor = '', $echoit = true)
{
    if (!function_exists('icl_link_to_element')) {
        switch ($element_type) {
            case 'post':
            case 'page':
                $ret = '<a href="' . get_permalink($element_id) . '">';
                if ($anchor) {
                    $ret .= $anchor;
                } else {
                    $ret .= get_the_title($element_id);
                }
                $ret .= '<a>';
                break;
            case 'tag':
            case 'post_tag':
                $tag = get_term_by('id', $element_id, 'tag', ARRAY_A);
                $ret = '<a href="' . get_tag_link($element_id) . '">' . $tag->name . '</a>';
            case 'category':
                $ret = '<a href="' . get_tag_link($element_id) . '">' . get_the_category_by_ID($element_id) . '</a>';
            default:
                $ret = '';
        }
        if ($echoit) {
            echo $ret;
        } else {
            return $ret;
        }
    } else {
        return icl_link_to_element($element_id, $element_type, $link_text, $optional_parameters, $anchor, $echoit);
    }
}
开发者ID:StudioCreate,项目名称:Uncle-Hummer-WordPress-Theme,代码行数:32,代码来源:wpml-integration.php


示例5: init

 function init()
 {
     global $pagenow;
     if ($pagenow == 'edit.php' && !empty($_REQUEST['post_type']) && $_REQUEST['post_type'] == EM_POST_TYPE_EVENT) {
         //only needed for events list
         if (!empty($_REQUEST['category_id']) && is_numeric($_REQUEST['category_id'])) {
             $term = get_term_by('id', $_REQUEST['category_id'], EM_TAXONOMY_CATEGORY);
             if (!empty($term->slug)) {
                 $_REQUEST['category_id'] = $term->slug;
             }
         }
         //hide some cols by default:
         $screen = 'edit-' . EM_POST_TYPE_EVENT;
         $hidden = get_user_option('manage' . $screen . 'columnshidden');
         if (!$hidden) {
             $hidden = array('event-id');
             update_user_option(get_current_user_id(), "manage{$screen}columnshidden", $hidden, true);
         }
         //deal with actions
         $row_action_type = is_post_type_hierarchical(EM_POST_TYPE_EVENT) ? 'page_row_actions' : 'post_row_actions';
         add_filter($row_action_type, array('EM_Event_Posts_Admin', 'row_actions'), 10, 2);
         add_action('admin_head', array('EM_Event_Posts_Admin', 'admin_head'));
         //collumns
         add_filter('manage_edit-' . EM_POST_TYPE_EVENT . '_columns', array('EM_Event_Posts_Admin', 'columns_add'));
         add_filter('manage_' . EM_POST_TYPE_EVENT . '_posts_custom_column', array('EM_Event_Posts_Admin', 'columns_output'), 10, 2);
         //TODO alter views of locations, events and recurrences, specifically find a good way to alter the wp_count_posts method to force user owned posts only
         //add_filter('views_edit-'.EM_POST_TYPE_EVENT, array('EM_Event_Posts_Admin','views'),10,1);
     }
     add_action('restrict_manage_posts', array('EM_Event_Posts_Admin', 'restrict_manage_posts'));
 }
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:30,代码来源:em-event-posts-admin.php


示例6: save

 function save()
 {
     $term_slugs = array();
     foreach ($this->categories as $EM_Category) {
         /* @var $EM_Category EM_Category */
         if (!empty($EM_Category->slug)) {
             $term_slugs[] = $EM_Category->slug;
         }
         //save of category will soft-fail if slug is empty
     }
     if (count($term_slugs) == 0 && get_option('dbem_default_category') > 0) {
         $default_term = get_term_by('id', get_option('dbem_default_category'), EM_TAXONOMY_CATEGORY);
         if ($default_term) {
             $term_slugs[] = $default_term->slug;
         }
     }
     if (count($term_slugs) > 0) {
         if (is_multisite()) {
             //In MS Global mode, we also save category meta information for global lookups
             if (EM_MS_GLOBAL && !empty($this->event_id)) {
                 //delete categories
                 $this->save_index();
             }
             if (!EM_MS_GLOBAL || is_main_site()) {
                 wp_set_object_terms($this->post_id, $term_slugs, EM_TAXONOMY_CATEGORY);
             }
         } else {
             wp_set_object_terms($this->post_id, $term_slugs, EM_TAXONOMY_CATEGORY);
         }
     }
     do_action('em_categories_save', $this);
 }
开发者ID:mpaskew,项目名称:isc-dev,代码行数:32,代码来源:em-categories.php


示例7: handle

 /**
  * Handles shortcode
  * @param $atts
  * @param null $content
  * @return string
  */
 public function handle($atts, $content = null)
 {
     $attributes = shortcode_atts($this->extractShortcodeAttributes($atts), $atts);
     extract($attributes);
     $products = $this->getCollection($attributes, array('post_type' => 'product'));
     $counter = 0;
     $categories = get_term_by('slug', $cat_name, 'product_category');
     if (!$categories) {
         return __('Product category slug not found: ', 'ct_theme') . $cat_name;
     }
     $categoryName = $categories->name;
     $category_description = $categories->description;
     $icons = $this->getDefaultIcons();
     if (isset($icons[$category_image])) {
         $category_image = $icons[$category_image];
     }
     $menuBoxHtml = '[menu_box style="' . $style . '" title="' . $categoryName . '" image="' . $category_image . '" description="' . $category_description . '"]';
     foreach ($products as $p) {
         $custom = get_post_custom($p->ID);
         $counter++;
         $imageSrc = $images == "yes" ? ct_get_feature_image_src($p->ID, 'full') : '';
         $thumb = $images == 'yes' ? ct_product_featured_image2_src($p->ID, 'product_thumb') : '';
         $price = str_replace('.', ',', $custom['price'][0]);
         $productPrice = explode(",", $price);
         $menuBoxHtml .= $this->embedShortcode('menu_box_item', array('thumb' => $thumb, 'image' => $imageSrc, 'separator' => $counter == count($products) ? 'no' : 'yes', 'title' => $p->post_title, 'price' => $productPrice[0], 'subprice' => isset($productPrice[1]) ? $productPrice[1] : ''), $p->post_content) . "\n";
     }
     $menuBoxHtml .= '[/menu_box]';
     return do_shortcode($menuBoxHtml);
 }
开发者ID:clevervaughn,项目名称:dottiesbiscuitbarn,代码行数:35,代码来源:ctMenuShortcode.class.php


示例8: avfr_calc_remaining_votes

 function avfr_calc_remaining_votes()
 {
     check_ajax_referer('feature_request', 'nonce');
     if (isset($_POST['post_id'])) {
         $postid = $_POST['post_id'];
         // get votes
         $voted_group = $_POST['cfg'];
         $term = get_term_by('slug', $voted_group, $taxonomy = 'groups');
         $term_id = $term->term_id;
         // Get limit for users from option in voted category
         $user_vote_limit = get_term_meta($term_id, 'avfr_total_votes', true);
         $limit_time = avfr_get_option('avfr_votes_limitation_time', 'avfr_settings_main');
         //Get user ID
         $userid = get_current_user_id();
         $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 0;
         $get_voter_email = get_userdata($userid);
         $voter_email = !is_user_logged_in() && isset($_POST['voter_email']) ? $_POST['voter_email'] : $get_voter_email->user_email;
         //Get related function to time limitation
         $fun = 'avfr_total_votes_' . $limit_time;
         global $avfr_db;
         $user_total_voted = $avfr_db->{$fun}($ip, $userid, $voter_email, $voted_group);
         if (!$user_total_voted) {
             $user_total_voted = 0;
         }
         $remaining_votes = $user_vote_limit - $user_total_voted;
         $response_array = array('response' => $remaining_votes);
         wp_send_json($response_array);
     }
     wp_die();
 }
开发者ID:averta-lab,项目名称:feature-request,代码行数:30,代码来源:class-avfr-votes.php


示例9: get_tag_link

 public function get_tag_link($tag)
 {
     if ($term = get_term_by('slug', $tag['slug'], $tag['taxonomy'])) {
         return scriblio()->facets()->permalink(scriblio()->facets()->_tax_to_facet[$term->taxonomy], $term);
     }
     return '';
 }
开发者ID:nrporter,项目名称:scriblio,代码行数:7,代码来源:compatibility.php


示例10: render

 function render($args, $instance)
 {
     global $gantry, $post;
     ob_start();
     $show_description = $instance['description'];
     $show_name = $instance['name'];
     $show_rating = $instance['rating'];
     $show_images = $instance['images'];
     $catid = get_term_by('slug', $instance['category'], 'link_category');
     $menu_class = $instance['menu_class'];
     if ($menu_class != '') {
         $menu_class = $menu_class . ' ';
     } else {
         $menu_class = '';
     }
     $links = array();
     $links = wp_list_bookmarks(apply_filters('widget_links_args', array('title_before' => $args['before_title'], 'title_after' => $args['after_title'], 'category_before' => '<div class="' . $instance['category_class'] . '">', 'category_after' => '</div>', 'show_images' => $show_images, 'show_description' => $show_description, 'show_name' => $show_name, 'show_rating' => $show_rating, 'category' => $catid->term_id, 'class' => 'linkcat widget', 'category_orderby' => $instance['category_orderby'], 'orderby' => $instance['links_orderby'], 'categorize' => $instance['categorize'], 'title_li' => '', 'limit' => $instance['limit'], 'link_before' => '<span>', 'link_after' => '</span>')));
     $links = ob_get_clean();
     $lines = explode("\n", $links);
     $out = '';
     foreach ($lines as $line) {
         $line = trim($line);
         if (substr($line, 0, 11) == "<ul class='") {
             $line = str_replace("<ul class='", "<ul class='" . $menu_class, $line);
         }
         $out .= $line . "\n";
     }
     if (!$instance['categorize']) {
         echo '<ul class="' . trim($menu_class) . '">';
     }
     echo $out;
     if (!$instance['categorize']) {
         echo '</ul>';
     }
 }
开发者ID:rotoballer,项目名称:emily,代码行数:35,代码来源:links.php


示例11: getMainTerm

function getMainTerm($term)
{
    while ($term->parent != 0) {
        $term = get_term_by("id", $term->parent, "categoria_projecto");
    }
    return $term;
}
开发者ID:eralha,项目名称:wp_theme_base,代码行数:7,代码来源:functions.php


示例12: get_item_data

 function get_item_data($other_data, $cart_item)
 {
     if (isset($cart_item["wpb_cart_items"])) {
         $wpb_cart_items = $cart_item["wpb_cart_items"];
         $other_data = array();
         $variation_data = $cart_item["variation"];
         if (!empty($variation_data)) {
             foreach ($variation_data as $attribute => $variation) {
                 $taxonomy = wc_attribute_taxonomy_name(str_replace('attribute_pa_', '', urldecode($attribute)));
                 $term = get_term_by('slug', $variation, $taxonomy);
                 $attribute_type = WPB_Common_Functions::get_variation_attribute_type($taxonomy);
                 if ($attribute_type == "carousel") {
                     $other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $term->name, 'value' => '', 'hidden' => false);
                 }
                 if ($attribute_type == "extra") {
                     $extra_options = $wpb_cart_items["extra"];
                     $display_label = !empty($extra_options[$taxonomy]) ? $term->name . '(' . $extra_options[$taxonomy] . ')' : $term->name;
                     $other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $display_label, 'value' => '', 'hidden' => false);
                 }
                 if ($attribute_type == "size") {
                     $size_options = $wpb_cart_items["size"];
                     $display_label = !empty($size_options[$taxonomy]) ? $size_options[$taxonomy] : "";
                     $other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $display_label, 'value' => '', 'hidden' => false);
                 }
             }
         }
     }
     return $other_data;
 }
开发者ID:shirso,项目名称:wc-product-builder,代码行数:29,代码来源:class-product-cart.php


示例13: dw_timeline_title

/**
 * Page titles
 */
function dw_timeline_title()
{
    if (is_home()) {
        if (get_option('page_for_posts', true)) {
            return get_the_title(get_option('page_for_posts', true));
        } else {
            return get_bloginfo('name');
        }
    } elseif (is_archive()) {
        $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
        if ($term) {
            return apply_filters('single_term_title', $term->name);
        } elseif (is_post_type_archive()) {
            return apply_filters('the_title', get_queried_object()->labels->name);
        } elseif (is_day()) {
            return sprintf(__('Daily Archives: %s', 'dw-timeline'), get_the_date());
        } elseif (is_month()) {
            return sprintf(__('Monthly Archives: %s', 'dw-timeline'), get_the_date('F Y'));
        } elseif (is_year()) {
            return sprintf(__('Yearly Archives: %s', 'dw-timeline'), get_the_date('Y'));
        } elseif (is_author()) {
            $author = get_queried_object();
            return sprintf(__('Author Archives: %s', 'dw-timeline'), $author->display_name);
        } else {
            return single_cat_title('', false);
        }
    } elseif (is_search()) {
        return sprintf(__('Search Results for %s', 'dw-timeline'), get_search_query());
    } elseif (is_404()) {
        return __('Not Found', 'dw-timeline');
    } else {
        return get_the_title();
    }
}
开发者ID:wenqingyu,项目名称:timeline-post,代码行数:37,代码来源:titles.php


示例14: pbl_year_filter_dropdown

function pbl_year_filter_dropdown($pub, $category)
{
    global $wp_query;
    $year = isset($wp_query->query['year']) ? $wp_query->query['year'] : date('Y');
    ?>
    <select id="QuRepYear" name="QuRepYear"><?php 
    global $wpdb;
    $term_id = get_term_by('slug', $pub, 'pubcode')->term_id;
    $category_id = get_category_by_slug($category)->term_id;
    $datePosts = $wpdb->get_results($wpdb->prepare("\r\n                    SELECT DISTINCT YEAR( {$wpdb->posts}.post_date ) AS year\r\n                        FROM wp_term_relationships\r\n                        INNER JOIN wp_term_relationships as wptr ON wp_term_relationships.object_id=wptr.object_id and wp_term_relationships.term_taxonomy_id <> wptr.term_taxonomy_id\r\n                        inner join wp_posts on wp_posts.ID = wp_term_relationships.object_id\r\n                        inner join wp_term_taxonomy on wp_term_taxonomy.term_taxonomy_id  = wp_term_relationships.term_taxonomy_id\r\n                        inner join wp_term_taxonomy as wptt on wptt.term_taxonomy_id  = wptr.term_taxonomy_id\r\n                        where (wp_term_taxonomy.term_id = %s and wp_term_taxonomy.taxonomy = 'category')\r\n                            and (wptt.term_id = %s and wptt.taxonomy = 'pubcode')\r\n                            and (wp_posts.post_status = 'publish')\r\n                            ORDER BY year DESC\r\n                ", $category_id, $term_id));
    foreach ($datePosts as $datePost) {
        ?>
        <option <?php 
        echo $datePost->year == $year ? 'selected="selected"' : '';
        ?>
 value="<?php 
        echo $datePost->year;
        ?>
"><?php 
        echo $datePost->year;
        ?>
</option>
    <?php 
    }
    ?>
</select><?php 
}
开发者ID:GabeDiaz,项目名称:responsive-child,代码行数:27,代码来源:functions.php


示例15: get_category_meta

function get_category_meta($post_id = NULL, $cat_id = NULL)
{
    // Return array
    $final = array();
    // All category IDs
    $categories = wp_get_post_categories($post_id);
    if (isset($categories[0]) || !is_null($cat_id)) {
        $has_category = true;
        // Get the TERM for the category
        if (isset($categories[0])) {
            $term = get_term_by('id', $categories[0], "category");
            $final['cat_id'] = $categories[0];
        } else {
            $term = get_term_by('id', $cat_id, "category");
            $final['cat_id'] = $cat_id;
        }
        // Get all meta data for the Category
        $getTaxMeta = get_tax_meta($term);
        // Grab the Category COLOR
        $cat_color = $getTaxMeta['wish_dish_color'];
        // Append a # to the beginning of the color if it doesn't have one
        if (strpos($cat_color, "#") === false) {
            $cat_color = "#" . $cat_color;
        }
        $final['cat_meta'] = $getTaxMeta;
        $final['cat_color'] = $cat_color;
        $final['cat_bg_image'] = isset($getTaxMeta['wish_dish_image'][0]) ? wp_get_attachment_url($getTaxMeta['wish_dish_image'][0]) : NULL;
        return $final;
    } else {
        return false;
    }
}
开发者ID:chrislafay,项目名称:cccwd,代码行数:32,代码来源:functions.php


示例16: wpjam_related_posts_shortcode

function wpjam_related_posts_shortcode($atts, $content = '')
{
    extract(shortcode_atts(array('tag' => '0'), $atts));
    if ($tag) {
        if (isset($_GET['update'])) {
            wp_cache_delete(md5($tag), 'related_posts_query');
        }
        $related_posts_query = wp_cache_get(md5($tag), 'related_posts_query');
        if ($related_posts_query === false) {
            $tags = explode(",", $tag);
            $tag_id_array = array();
            foreach ($tags as $a_tag) {
                $tag_object = get_term_by('name', trim($a_tag), 'post_tag');
                $tag_id_array[] = $tag_object->term_id;
            }
            $post_types = apply_filters('wpjam_related_posts_post_types', array(get_post_type()));
            if (count($tag_id_array) > 1) {
                $related_posts_query = new WP_Query(array('post_type' => get_post_type(), 'post_status' => 'publish', 'tag__and' => $tag_id_array, 'post__not_in' => array(get_the_ID())));
            } else {
                $related_posts_query = new WP_Query(array('post_type' => get_post_type(), 'post_status' => 'publish', 'tag_id' => $tag_id_array[0], 'post__not_in' => array(get_the_ID())));
            }
            wp_cache_set(md5($tag), $related_posts_query, 'related_posts_query', 3600);
        }
        return wpjam_get_post_list($related_posts_query, array('thumb' => false, 'class' => 'related_posts'));
    }
}
开发者ID:yszar,项目名称:linuxwp,代码行数:26,代码来源:wpjam-posts.php


示例17: setUp

 function setUp()
 {
     global $wp_rewrite;
     parent::setUp();
     set_current_screen('front');
     $GLOBALS['wp_the_query'] = new WP_Query();
     $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
     $wp_rewrite->init();
     $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     create_initial_taxonomies();
     register_taxonomy('testtax', 'post', array('public' => true));
     $wp_rewrite->flush_rules();
     $this->tag_id = $this->factory->tag->create(array('slug' => 'tag-slug'));
     $this->cat_id = $this->factory->category->create(array('slug' => 'cat-slug'));
     $this->tax_id = $this->factory->term->create(array('taxonomy' => 'testtax', 'slug' => 'tax-slug'));
     $this->tax_id2 = $this->factory->term->create(array('taxonomy' => 'testtax', 'slug' => 'tax-slug2'));
     $this->post_id = $this->factory->post->create();
     wp_set_object_terms($this->post_id, $this->cat_id, 'category');
     wp_set_object_terms($this->post_id, array($this->tax_id, $this->tax_id2), 'testtax');
     $this->cat = get_term($this->cat_id, 'category');
     _make_cat_compat($this->cat);
     $this->tag = get_term($this->tag_id, 'post_tag');
     $this->uncat = get_term_by('slug', 'uncategorized', 'category');
     _make_cat_compat($this->uncat);
     add_action('pre_get_posts', array($this, 'pre_get_posts_tax_category_tax_query'));
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:26,代码来源:taxQuery.php


示例18: colabsthemes_script_and_style

 function colabsthemes_script_and_style()
 {
     // Styles
     wp_enqueue_style('framework', get_template_directory_uri() . '/includes/css/framework.css');
     wp_enqueue_style('style', get_stylesheet_directory_uri() . '/style.css', array('framework'));
     wp_enqueue_style('mmenu-style', get_stylesheet_directory_uri() . '/includes/css/jquery.mmenu.css');
     // Scripts
     wp_enqueue_script('jquery');
     wp_enqueue_script('jquery-ui-slider');
     // Only load fancybox on single property
     if ('property' == get_post_type()) {
         wp_enqueue_script('fancybox', get_template_directory_uri() . '/includes/js/fancybox/jquery.fancybox-1.3.4.pack.js', array('jquery'), '', true);
         wp_enqueue_style('fancybox', get_template_directory_uri() . '/includes/js/fancybox/jquery.fancybox-1.3.4.css');
     }
     wp_enqueue_script('plugins', trailingslashit(get_template_directory_uri()) . 'includes/js/plugins.js', array('jquery'), '', true);
     wp_enqueue_script('scripts', trailingslashit(get_template_directory_uri()) . 'includes/js/scripts.js', array('jquery'), '', true);
     /* Script for threaded comments. */
     if (is_singular() && get_option('thread_comments')) {
         wp_enqueue_script('comment-reply');
     }
     wp_localize_script('scripts', 'translationstring', array('nomorepost' => __('No More Post', 'colabsthemes')));
     // Translatable string for form builder
     $rent_term_obj = get_term_by('slug', 'rent', COLABS_TAX_STATUS);
     $term_id = isset($rent_term_obj->term_id) ? $rent_term_obj->term_id : '';
     $formbuilder_string = array('media_upload' => array('title' => __('Upload', 'colabsthemes'), 'button_text' => __('Use this file', 'colabsthemes')), 'gallery_upload' => array('title' => __('Add Images to Gallery', 'colabsthemes'), 'button_text' => __('Add to gallery', 'colabsthemes')), 'file_upload' => array('title' => __('Choose a File', 'colabsthemes'), 'button_text' => __('Insert file URL', 'colabsthemes')), 'validator' => array('required' => __('This field is required', 'colabsthemes'), 'terms' => __('You need to aggree with our terms', 'colabsthemes')), 'delete_confirm' => __("Are your sure you want to delete this? It can't be undone.", 'colabsthemes'), 'cancel_order_confirm' => __("Are you sure you want to cancel this order? It can't be undone.", 'colabsthemes'), 'rent_term_id' => $term_id);
     wp_localize_script('scripts', 'formbuilder_string', $formbuilder_string);
     if (is_page_template('template-profile.php')) {
         wp_enqueue_script('password-strength-meter');
         wp_enqueue_script('zxcvbn-async');
         wp_enqueue_script('custom-strengthmeter', trailingslashit(get_template_directory_uri()) . 'includes/js/custom-strengthmeter.js');
     }
 }
开发者ID:nickwoodland,项目名称:easysitges,代码行数:32,代码来源:theme-js.php


示例19: ubik_terms_tag_shortcode

function ubik_terms_tag_shortcode($atts, $content = '')
{
    // Setup variables
    $args = shortcode_atts(array('slug' => ''), $atts);
    $slug = (string) $args['slug'];
    $taxonomy = 'post_tag';
    $term = $link = '';
    // If the slug is not empty try to fetch the term and generate a link
    if (!empty($slug)) {
        $term = get_term_by('slug', $slug, $taxonomy);
    } elseif (empty($slug) && !empty($content)) {
        $term = get_term_by('slug', strtolower($content), $taxonomy);
    }
    // Try to generate a link
    if (!empty($term)) {
        $link = get_term_link($term);
    }
    // Assemble the HTML
    if (!empty($link)) {
        if (!empty($content)) {
            $content = '<a href="' . $link . '" rel="tag">' . $content . '</a>';
        } elseif (empty($content)) {
            $content = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';
            // Allows for [tag slug=example/] to fill content
        }
    }
    return apply_filters('ubik_terms_tag_shortcode', $content);
}
开发者ID:synapticism,项目名称:ubik-terms,代码行数:28,代码来源:ubik-terms-tag-shortcode.php


示例20: maybe_install

 /**
  * Set installed option and default settings / terms
  *
  * @since 1.0
  */
 private function maybe_install()
 {
     global $woocommerce;
     $installed_version = get_option('wc_pre_orders_version');
     // install
     if (!$installed_version) {
         // add 'pre-order' shop order status term
         $woocommerce->init_taxonomy();
         if (!get_term_by('slug', 'pre-ordered', 'shop_order_status')) {
             wp_insert_term('pre-ordered', 'shop_order_status');
         }
         // install default settings
         foreach ($this->get_settings() as $setting) {
             if (isset($setting['default'])) {
                 update_option($setting['id'], $setting['default']);
             }
         }
     }
     // upgrade - installed version lower than plugin version?
     if (-1 === version_compare($installed_version, WC_Pre_Orders::VERSION)) {
         $this->upgrade($installed_version);
         // new version number
         update_option('wc_pre_orders_version', WC_Pre_Orders::VERSION);
     }
 }
开发者ID:shahadat014,项目名称:geleyi,代码行数:30,代码来源:class-wc-pre-orders-admin.php



注:本文中的get_term_by函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_term_children函数代码示例发布时间:2022-05-15
下一篇:
PHP get_term函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap