本文整理汇总了PHP中get_woocommerce_term_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP get_woocommerce_term_meta函数的具体用法?PHP get_woocommerce_term_meta怎么用?PHP get_woocommerce_term_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_woocommerce_term_meta函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: woocommerce_subcategory_thumbnail
function woocommerce_subcategory_thumbnail($category)
{
// Vars
$title = get_the_title();
$thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
$attachment_url = wp_get_attachment_url($thumbnail_id);
$width = wpex_option('woo_cat_entry_width', '9999');
$height = wpex_option('woo_cat_entry_height', '9999');
$crop = $height == '9999' ? false : true;
// Echo Image
echo '<img src="' . aq_resize($attachment_url, $width, $height, $crop) . '" alt="' . $title . '" />';
}
开发者ID:nhatnam1102,项目名称:wp-content,代码行数:12,代码来源:woo-image-edits.php
示例2: brands
/**
* List multiple brands shortcode
*
* @access public
* @param array $atts
* @return string
*/
public static function brands($atts)
{
global $woocommerce_loop;
if (empty($atts)) {
return '';
}
extract(shortcode_atts(array('orderby' => 'title', 'columns' => '6', 'order' => 'asc', 'per_page' => '6', 'carousel' => 'true'), $atts));
$brands = get_categories(array('hide_empty' => 0, 'taxonomy' => 'product_brand', 'orderby' => $orderby, 'order' => $order, 'number' => $per_page));
$output = '';
$columns = intval($columns);
$columns = 12 / $columns;
foreach ($brands as $brand) {
$thumbnail_id = get_woocommerce_term_meta($brand->term_id, 'thumbnail_id');
$image_src = wp_get_attachment_image_src($thumbnail_id, 'full');
$brand_link = get_term_link($brand, 'product_brand');
$brand_item = '<div class="brand-item">';
$brand_item .= "\t" . '<a href="' . $brand_link . '"><img alt="' . $brand->cat_name . '" src="' . $image_src[0] . '" width="144" height="36" /></a>';
$brand_item .= '</div>';
if ($carousel === 'false') {
$output .= '<div class="col-xs-12 col-sm-' . $columns . '">' . $brand_item . '</div>';
} else {
$output .= $brand_item;
}
}
return $output;
}
开发者ID:Qualitair,项目名称:ecommerce,代码行数:33,代码来源:class-mc-brand-shortcodes.php
示例3: ml_get_categories_with_thumbnails_loop
function ml_get_categories_with_thumbnails_loop()
{
$taxonomy = 'product_cat';
$orderby = 'name';
$show_count = 0;
// 1 for yes, 0 for no
$pad_counts = 0;
// 1 for yes, 0 for no
$hierarchical = 1;
// 1 for yes, 0 for no
$title = '';
$empty = 0;
$args = array('taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title, 'hide_empty' => $empty);
$all_categories = get_categories($args);
foreach ($all_categories as $cat) {
if ($cat->category_parent == 0) {
$category_id = $cat->term_id;
echo '<br /><a href="' . get_term_link($cat->slug, 'product_cat') . '">' . $cat->name . '</a>';
$thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
if ($image) {
echo '<img src="' . $image . '" alt="" />';
}
}
}
}
开发者ID:pixelstorm,项目名称:woocommerce,代码行数:26,代码来源:get_categories_with_thumbnails_loop.php
示例4: edit_category_fields
/**
* extra fields while editing category.
*
* @author Lukas Juhas
* @date 2016-02-04
*
* @param [type] $term [description]
*
* @return [type] [description]
*/
public function edit_category_fields($term)
{
$wcl_cat_password_protected = absint(get_woocommerce_term_meta($term->term_id, 'wcl_cat_password_protected', true));
$wcl_cat_password = get_woocommerce_term_meta($term->term_id, 'wcl_cat_password', true);
?>
<tr class="form-field">
<th scope="row" valign="top">
Password Protection
</th>
<td>
<label id="wcl_cat_password_protected">
<input type="checkbox" name="wcl_cat_password_protected" value="1" <?php
if ($wcl_cat_password_protected) {
echo 'checked="checked"';
}
?>
/>
<?php
_e('Password Protected', WCL_PLUGIN_DOMAIN);
?>
</label>
<div class="clear"></div>
<div id="wcl_cat_password" style="<?php
if (!$wcl_cat_password_protected) {
echo 'display:none;';
}
?>
float: left;">
<label>
<?php
_e('Password:', WCL_PLUGIN_DOMAIN);
?>
<input type="text" name="wcl_cat_password" value="<?php
echo $wcl_cat_password;
?>
" <?php
if (!$wcl_cat_password_protected) {
echo 'disabled="disabled"';
}
?>
required="required" />
</label>
</div>
<script>
jQuery('#wcl_cat_password_protected').on('click', function() {
var $checked = jQuery('input[name="wcl_cat_password_protected"]:checkbox:checked').length > 0;
if($checked) {
jQuery('#wcl_cat_password').find('input').prop('disabled', false);
jQuery('#wcl_cat_password').slideDown();
} else {
jQuery('#wcl_cat_password').find('input').prop('disabled', true);
jQuery('#wcl_cat_password').slideUp();
}
});
</script>
<div class="clear"></div>
</td>
</tr>
<?php
}
开发者ID:benchmarkstudios,项目名称:wc-category-locker,代码行数:70,代码来源:admin.php
示例5: on_init
public function on_init()
{
global $woocommerce, $_wp_additional_image_sizes;
$this->init_size($this->size);
$type = get_woocommerce_term_meta($this->term_id, $this->meta_key() . '_type', true);
$color = get_woocommerce_term_meta($this->term_id, $this->meta_key() . '_color', true);
$this->thumbnail_id = get_woocommerce_term_meta($this->term_id, $this->meta_key() . '_photo', true);
$this->type = $type;
$this->thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
$this->color = '#FFFFFF';
if ($type == 'photo') {
if ($this->thumbnail_id) {
$imgsrc = wp_get_attachment_image_src($this->thumbnail_id, $this->size);
if ($imgsrc && is_array($imgsrc)) {
$this->thumbnail_src = current($imgsrc);
} else {
$this->thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
}
} else {
$this->thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
}
} elseif ($type == 'color') {
$this->color = $color;
}
}
开发者ID:epiii,项目名称:aros,代码行数:25,代码来源:class-wc-swatch-term.php
示例6: prepare_item_for_response
/**
* Prepare a single product category output for response.
*
* @param WP_Term $item Term object.
* @param WP_REST_Request $request
* @return WP_REST_Response $response
*/
public function prepare_item_for_response($item, $request)
{
// Get category display type.
$display_type = get_woocommerce_term_meta($item->term_id, 'display_type');
// Get category order.
$menu_order = get_woocommerce_term_meta($item->term_id, 'order');
$data = array('id' => (int) $item->term_id, 'name' => $item->name, 'slug' => $item->slug, 'parent' => (int) $item->parent, 'description' => $item->description, 'display' => $display_type ? $display_type : 'default', 'image' => array(), 'menu_order' => (int) $menu_order, 'count' => (int) $item->count);
// Get category image.
if ($image_id = get_woocommerce_term_meta($item->term_id, 'thumbnail_id')) {
$attachment = get_post($image_id);
$data['image'] = array('id' => (int) $image_id, 'date_created' => wc_rest_prepare_date_response($attachment->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($attachment->post_modified_gmt), 'src' => wp_get_attachment_url($image_id), 'title' => get_the_title($attachment), 'alt' => get_post_meta($image_id, '_wp_attachment_image_alt', true));
}
$context = !empty($request['context']) ? $request['context'] : 'view';
$data = $this->add_additional_fields_to_object($data, $request);
$data = $this->filter_response_by_context($data, $context);
$response = rest_ensure_response($data);
$response->add_links($this->prepare_links($item, $request));
/**
* Filter a term item returned from the API.
*
* Allows modification of the term data right before it is returned.
*
* @param WP_REST_Response $response The response object.
* @param object $item The original term object.
* @param WP_REST_Request $request Request used to generate the response.
*/
return apply_filters("woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request);
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:35,代码来源:class-wc-rest-product-categories-controller.php
示例7: dhwc_get_product_brand_thumbnail_url
/**
* get thumbnail product brand by id
* @param int $brand_id
* @param string $size
*/
function dhwc_get_product_brand_thumbnail_url($brand_id, $size = 'full')
{
$thumbnail_id = get_woocommerce_term_meta($brand_id, 'thumbnail_id', true);
if ($thumbnail_id) {
return current(wp_get_attachment_image_src($thumbnail_id, $size));
}
}
开发者ID:jmead,项目名称:trucell-cms,代码行数:12,代码来源:dhwc-brand-functions.php
示例8: panel
/**
* Renders our panel.
*/
public static function panel($tag = null)
{
global $post, $wpdb;
global $wp_roles;
if (class_exists('WP_Roles')) {
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
}
$output = '';
$term_id = isset($tag->term_id) ? $tag->term_id : null;
$output .= '<div class="form-field">';
$pricing_options = array();
foreach ($wp_roles->role_objects as $role) {
$pricing_options['value_' . $role->name] = get_woocommerce_term_meta($term_id, 'role_pricing_value_' . $role->name, true);
}
$output .= '<div class="options_role" style="border: 1px solid #ccc; padding:10px;">';
$output .= '<h4>' . __('Woocommerce Role Pricing', WOO_ROLE_PRICING_DOMAIN) . '</h4>';
$output .= '<p class="description">';
$output .= __('Leave empty if no custom role discount should be applied to this category.', WOO_ROLE_PRICING_DOMAIN);
$output .= '</p>';
foreach ($wp_roles->role_objects as $role) {
$output .= '<p>';
$output .= '<label style="width:120px;float:left;">' . ucwords($role->name) . '</label>';
$output .= '<input type="text" style="width:auto;" size="10" name="role_pricing_value_' . $role->name . '" value="' . @$pricing_options['value_' . $role->name] . '" />';
$output .= '</p>';
}
$output .= '</div>';
$output .= '</div>';
// .form-field
echo $output;
}
开发者ID:pellio11,项目名称:ns-select-project,代码行数:35,代码来源:class-wrp-categories-admin.php
示例9: wc1c_manage_taxonomy_custom_column
function wc1c_manage_taxonomy_custom_column($columns, $column, $id)
{
if ($column == 'wc1c_guid') {
$guid = get_woocommerce_term_meta($id, 'wc1c_guid');
list($taxonomy, $guid) = explode('::', $guid);
$columns .= $guid ? "<small>{$guid}</small>" : '<span class="na">–</span>';
}
return $columns;
}
开发者ID:anderpo,项目名称:himik,代码行数:9,代码来源:admin.php
示例10: get_categories
public static function get_categories()
{
global $wp_query;
$defaults = array('before' => '', 'after' => '', 'force_display' => false);
$args = array();
$args = wp_parse_args($args, $defaults);
extract($args);
$term = get_queried_object();
$parent_id = empty($term->term_id) ? 0 : $term->term_id;
if (is_product_category()) {
$display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true);
switch ($display_type) {
case 'products':
return;
break;
case '':
if (get_option('woocommerce_category_archive_display') == '') {
return;
}
break;
}
}
$product_categories = get_categories(apply_filters('woocommerce_product_subcategories_args', array('parent' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' => 1)));
if (!apply_filters('woocommerce_product_subcategories_hide_empty', false)) {
$product_categories = wp_list_filter($product_categories, array('count' => 0), 'NOT');
}
if ($product_categories) {
echo $before;
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
}
if (is_product_category()) {
$display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true);
switch ($display_type) {
case 'subcategories':
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
break;
case '':
if (get_option('woocommerce_category_archive_display') == 'subcategories') {
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
}
break;
}
}
if (is_shop() && get_option('woocommerce_shop_page_display') == 'subcategories') {
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
}
echo $after;
return true;
}
}
开发者ID:hikaram,项目名称:wee,代码行数:54,代码来源:pf-shortcode.php
示例11: wcl_get_locked_categories
/**
* ID list of categories that are locked
* @author Lukas Juhas
* @date 2016-02-08
* @return [type] [description]
*/
function wcl_get_locked_categories()
{
$locked = array();
$shop_terms = get_terms('product_cat');
foreach ($shop_terms as $term) {
$is_password_protected = get_woocommerce_term_meta($term->term_id, 'wcl_cat_password_protected');
if ($is_password_protected) {
$locked[] = $term->term_id;
}
}
return $locked;
}
开发者ID:benchmarkstudios,项目名称:wc-category-locker,代码行数:18,代码来源:functions.php
示例12: woocommerce_category_image
function woocommerce_category_image()
{
if (is_product_category()) {
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
if ($image) {
echo '<img src="' . $image . '" alt="" class="img-responsive" />';
}
}
}
开发者ID:kupoback,项目名称:Custom-Code-Work,代码行数:12,代码来源:functions-mod.php
示例13: widget
function widget($args, $instance)
{
extract($args);
$title = $instance['title'];
echo $before_widget;
if (!$title == '') {
echo $before_title;
echo $title;
echo $after_title;
}
$current_term = get_queried_object();
$args = array('hide_empty' => false);
$terms = get_terms('brand', $args);
$count = count($terms);
$i = 0;
if ($count > 0) {
?>
<ul>
<?php
foreach ($terms as $term) {
$i++;
$curr = false;
$thumbnail_id = absint(get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true));
if (isset($current_term->term_id) && $current_term->term_id == $term->term_id) {
$curr = true;
}
?>
<li>
<a href="<?php
echo get_term_link($term);
?>
" title="<?php
echo sprintf(__('View all products from %s', ETHEME_DOMAIN), $term->name);
?>
"><?php
if ($curr) {
echo '<strong>';
}
echo $term->name;
if ($curr) {
echo '</strong>';
}
?>
</a>
</li>
<?php
}
?>
</ul>
<?php
}
echo $after_widget;
}
开发者ID:baridavid,项目名称:themes,代码行数:53,代码来源:widgets.php
示例14: woocommerce_taxonomy_archive_description
/**
* Overrides the default woocommerce_taxonomy_archive_description() function
*/
function woocommerce_taxonomy_archive_description()
{
if (is_tax(array('product_cat', 'product_tag')) && get_query_var('paged') == 0) {
global $wp_query;
$term = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
$image_class = $image ? ' has-term-image' : null;
$description = wc_format_content(term_description());
if ($description) {
echo '<div class="term-description' . $image_class . '">' . $description . '</div>';
}
}
}
开发者ID:Wordpress-Development,项目名称:ornea,代码行数:17,代码来源:extras.php
示例15: start_lvl
/**
* @see Walker::start_lvl()
*
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of page. Used for padding.
*/
public function start_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$class = '';
$after = '';
if ($this->product_category) {
if ($image_id = get_woocommerce_term_meta($this->product_category, 'thumbnail_id', true)) {
$image_attributes = wp_get_attachment_image_src($image_id, 'thumbnail');
$after = sprintf('<img src="%s" class="pull-right">', $image_attributes[0]);
$class = 'has-image';
}
}
$output .= "\n{$indent}<ul role=\"menu\" class=\" dropdown-menu {$class}\">\n{$after}";
}
开发者ID:brasadesign,项目名称:aboaterra-theme,代码行数:20,代码来源:class-bootstrap-nav-boaterra.php
示例16: get_cats
function get_cats()
{
$catTerms = get_terms('product_cat', array('hide_empty' => 0, 'include' => '1422, 1344, 984, 1446, 1000, 1050, 996, 975, 987, 1016, 994, 564, 1186, 1048, 654, 1135, 645, 1445'));
$ch_n = 0;
if ($catTerms) {
echo '<ul class="ch-grid">';
foreach ($catTerms as $catTerm) {
$thumbnail_id = get_woocommerce_term_meta($catTerm->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_thumb_url($thumbnail_id);
$ch_n++;
echo '<li><a title="Перейти" href="/products/' . $catTerm->slug . '"><div class="ch-item" style="background-image: url(' . $image . '); background-size: 80%; background-repeat: no-repeat; background-color: white;"><div class="ch-info"><h3>' . $catTerm->name . '</h3></div></div></a></li>';
}
wp_reset_query();
echo '</ul>';
}
}
开发者ID:almone,项目名称:wc_hacks,代码行数:16,代码来源:wc_hacks.php
示例17: woocommerce_subcategory_thumbnail
function woocommerce_subcategory_thumbnail($category)
{
$thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
if ($thumbnail_id) {
$image = wp_get_attachment_image_src($thumbnail_id, 'full');
$image = $image[0];
} else {
$image = wc_placeholder_img_src();
}
if ($image) {
// Prevent esc_url from breaking spaces in urls for image embeds
// Ref: http://core.trac.wordpress.org/ticket/23605
$image = str_replace(' ', '%20', $image);
echo '<img alt="' . esc_attr($category->name) . '" src="' . esc_url($image) . '" />';
}
}
开发者ID:abhishek6986,项目名称:mmaterial,代码行数:16,代码来源:functions.php
示例18: woocommerce_subcategory_thumbnail
function woocommerce_subcategory_thumbnail($category)
{
// Figure
$figure = \Drone\HTML::figure()->class('featured full-width');
// Hyperlink
$a = $figure->addNew('a')->attr(Everything::getImageAttrs('a', array('fancybox' => false)))->href(get_term_link($category->slug, 'product_cat'));
// Thumbnail
$thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
$thumbnail_size = apply_filters('single_product_small_thumbnail_size', 'shop_catalog');
if ($thumbnail_id) {
$a->add(wp_get_attachment_image($thumbnail_id, $thumbnail_size));
} elseif (woocommerce_placeholder_img_src()) {
$a->add(woocommerce_placeholder_img($thumbnail_size));
}
echo $figure->html();
}
开发者ID:xpander54,项目名称:wp-drz,代码行数:16,代码来源:woocommerce.php
示例19: import_category_object
function import_category_object($product_category)
{
try {
$thumbnail_id = get_woocommerce_term_meta($product_category->cat_ID, "thumbnail_id", true);
$image = wp_get_attachment_url($thumbnail_id);
$this->set_value("id", $product_category->cat_ID);
$this->set_value("slug", $product_category->slug);
$this->set_value("description", $product_category->category_description);
$this->set_value("feature", $image ? "<div class=\"img\" style=\"background: url('{$image}') no-repeat center center; background-size: cover; min-height: 150px;\"></div>" : "<div src=\"" . get_template_directory_uri() . "/library/img/default.jpg\" class=\"no-image\" ></div>");
$this->set_value("ui_sref_id", "home.shop.products({CategoryID: '" . $product_category->cat_ID . "'})");
//$this->products = new JSON_API_Products_Model($product_category->term_taxonomy_id);
//print_r($product_category);
} catch (WC_API_Exception $e) {
return new WP_Error($e->getErrorCode(), $e->getMessage(), array("status" => $e->getCode()));
}
}
开发者ID:benshez,项目名称:DreamWeddingCeremonies,代码行数:16,代码来源:category.php
示例20: get_categories
public static function get_categories()
{
global $wp_query, $prdctfltr_global;
$defaults = array('before' => '', 'after' => '', 'force_display' => false);
$args = array();
$args = wp_parse_args($args, $defaults);
extract($args);
$selected_term = isset($prdctfltr_global['active_taxonomies']['product_cat'][0]) ? $prdctfltr_global['active_taxonomies']['product_cat'][0] : '';
if ($selected_term !== '') {
if (term_exists($selected_term, 'product_cat')) {
$term = get_term_by('slug', $selected_term, 'product_cat');
}
}
if (!isset($term)) {
$term = (object) array('term_id' => 0);
}
$parent_id = $term->term_id == 0 ? 0 : $term->term_id;
$product_categories = get_categories(apply_filters('woocommerce_product_subcategories_args', array('parent' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' => 1)));
if ($product_categories) {
echo $before;
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
}
if ($term->term_id !== 0) {
$display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true);
switch ($display_type) {
case 'subcategories':
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
break;
case '':
if (get_option('woocommerce_category_archive_display') == 'subcategories') {
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
}
break;
}
}
if ($term->term_id == 0 && get_option('woocommerce_shop_page_display') == 'subcategories') {
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
}
echo $after;
return true;
}
}
开发者ID:arobbins,项目名称:spellestate,代码行数:46,代码来源:pf-shortcode.php
注:本文中的get_woocommerce_term_meta函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论