global $product;
$attributes = $product->get_attributes();
if ( ! $attributes ) {
return;
}
$out = '<ul class="custom-attributes">';
foreach ( $attributes as $attribute ) {
// skip variations
if ( $attribute->get_variation() ) {
continue;
}
$name = $attribute->get_name();
if ( $attribute->is_taxonomy() ) {
$terms = wp_get_post_terms( $product->get_id(), $name, 'all' );
// get the taxonomy
$tax = $terms[0]->taxonomy;
// get the tax object
$tax_object = get_taxonomy($tax);
// get tax label
if ( isset ( $tax_object->labels->singular_name ) ) {
$tax_label = $tax_object->labels->singular_name;
} elseif ( isset( $tax_object->label ) ) {
$tax_label = $tax_object->label;
// Trim label prefix since WC 3.0
if ( 0 === strpos( $tax_label, 'Product ' ) ) {
$tax_label = substr( $tax_label, 8 );
}
}
$out .= '<li class="' . esc_attr( $name ) . '">';
$out .= '<span class="attribute-label">' . esc_html( $tax_label ) . ': </span> ';
$out .= '<span class="attribute-value">';
$tax_terms = array();
foreach ( $terms as $term ) {
$single_term = esc_html( $term->name );
// Insert extra code here if you want to show terms as links.
array_push( $tax_terms, $single_term );
}
$out .= implode(', ', $tax_terms);
$out .= '</span></li>';
} else {
$value_string = implode( ', ', $attribute->get_options() );
$out .= '<li class="' . sanitize_title($name) . ' ' . sanitize_title( $value_string ) . '">';
$out .= '<span class="attribute-label">' . $name . ': </span> ';
$out .= '<span class="attribute-value">' . esc_html( $value_string ) . '</span></li>';
}
}
$out .= '</ul>';
echo $out;
body * {
box-shadow: 0 0 5px 1px #FF0000;
}
import pug from 'pug';
//...
template: pug.render(`span {{ tr(lang).title }} `)
navigator.userAgent
.if(window.matchMedia("only screen and (max-width: 760px)").matches) {
//mobile device
} else {
//not mobile device
}
var gyroPresent = false;
window.addEventListener("devicemotion", function(event){
if(event.rotationRate.alpha || event.rotationRate.beta || event.rotationRate.gamma)
gyroPresent = true;
});
function add_se_roles() {
$es_admin = add_role('es_admin','Администратор Системы Мероприятий',array( 'read'=>true,'level_7'=>true));
if ( null !== $es_admin ) {
$es_administrator = get_role('es_admin'); // Для CPT
$es_administrator->add_cap('edit_es_event_content');
$es_administrator->add_cap('edit_es_event_contents');
$es_administrator->add_cap('read_es_event_content');
$es_administrator->add_cap('read_private_es_event_content');
$es_administrator->add_cap('delete_es_event_content');
$es_administrator->add_cap('delete_es_event_contents');
$es_administrator->add_cap('edit_published_es_event_contents');
$es_administrator->add_cap('delete_published_es_event_contents');
$es_administrator->add_cap('edit_other_es_event_content');
$es_administrator->add_cap('manage_es_event_type'); // <-Права таксономии вопроса
$es_administrator->add_cap('edit_es_event_type');
$es_administrator->add_cap('delete_es_event_type');
$es_administrator->add_cap('assign_es_event_type');
$es_administrator->add_cap('manage_es_event_operation');
$es_administrator->add_cap('edit_es_event_operation');
$es_administrator->add_cap('delete_es_event_operation');
$es_administrator->add_cap('assign_es_event_operation');
$es_administrator->add_cap('manage_es_event_location');
$es_administrator->add_cap('edit_es_event_location');
$es_administrator->add_cap('delete_es_event_location');
$es_administrator->add_cap('assign_es_event_location');
$es_administrator->add_cap('manage_es_event_team');
$es_administrator->add_cap('edit_es_event_team');
$es_administrator->add_cap('delete_es_event_team');
$es_administrator->add_cap('assign_es_event_team');
$es_administrator->add_cap('manage_event_service');
}
}
// Легче создать относительно пустую, со стандартными возможностями роль и по итогам создания напичкать ее всем, чем нужно.
// Все, что нужно прописывается в функциях создания таксономий и произвольного типа записи.
<?php $terms = get_terms( array(
'taxonomy' => 'product_cat',
'hide_empty' => true,
'pad_counts'=> true,
'orderby' => 'name',
'parent' => 0
) ); ?>
<?php if($terms) : ?>
<?php foreach($terms as $term) : ?>
<h2 class="subcategory-title"><a href="<?php echo get_term_link($term->term_id);?>"><?php echo $term->name;?></a></h2>
<!--<div class="subcategory-descripton"><p><?php //if($term->description) : ?><?php //echo $term->description; ?><?php //else: ?>Описание термина таксономии<?php //endif; ?></p></div>-->
<?php // Создаем массив терминов детей текущего термина текущей таксономии
$tax = $term->taxonomy;
$children_terms = get_terms( array(
'taxonomy' => $tax,
'hide_empty' => false,
'parent' => $term->term_id
) ); ?>
<?php if($children_terms): // если есть дочерние категории ?>
<ul><?php foreach ($children_terms as $children_term) : ?>
<?php $link = get_term_link($children_term); ?>
<li style="margin-left: 10px;"><a href="<?php echo $link ?>";><?php echo $children_term->name ?></a></li>
<!--<p class="count"><?php //echo $children_term->count ?></p>-->
<?php endforeach; ?></ul>
<?php endif; // конец условия - если есть дочерние термины таксономии ?>
<?php endforeach; ?>
<?php endif; ?>
<p class="count"><?php if ($term->count > 0) : ?><?php echo $term->count; ?><?php else: ?>0<?php endif; ?></p>