本文整理汇总了PHP中wc_sanitize_taxonomy_name函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_sanitize_taxonomy_name函数的具体用法?PHP wc_sanitize_taxonomy_name怎么用?PHP wc_sanitize_taxonomy_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_sanitize_taxonomy_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_wc_sanitize_taxonomy_name
/**
* Test wc_sanitize_taxonomy_name().
*
* @since 2.2
*/
public function test_wc_sanitize_taxonomy_name()
{
$this->assertEquals('name-with-spaces', wc_sanitize_taxonomy_name('Name With Spaces'));
$this->assertEquals('namewithtabs', wc_sanitize_taxonomy_name('Name With Tabs'));
$this->assertEquals('specialchars', wc_sanitize_taxonomy_name('special!@#$%^&*()chars'));
$this->assertEquals('look-of-ಠ_ಠ', wc_sanitize_taxonomy_name('Look Of ಠ_ಠ'));
}
示例2: woocommerce_layered_nav_init
/**
* Layered Nav Init
*
* @package WooCommerce/Widgets
* @access public
* @return void
*/
public function woocommerce_layered_nav_init()
{
if (is_active_widget(false, false, 'yith-woo-ajax-navigation', true) && !is_admin()) {
global $_chosen_attributes, $woocommerce;
$_chosen_attributes = array();
/* FIX TO WOOCOMMERCE 2.1 */
$attibute_taxonomies = function_exists('wc_get_attribute_taxonomies') ? $attribute_taxonomies = wc_get_attribute_taxonomies() : ($attribute_taxonomies = $woocommerce->get_attribute_taxonomies());
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$attribute = wc_sanitize_taxonomy_name($tax->attribute_name);
/* FIX TO WOOCOMMERCE 2.1 */
if (function_exists('wc_attribute_taxonomy_name')) {
$taxonomy = wc_attribute_taxonomy_name($attribute);
} else {
$taxonomy = $woocommerce->attribute_taxonomy_name($attribute);
}
$name = 'filter_' . $attribute;
$query_type_name = 'query_type_' . $attribute;
if (!empty($_GET[$name]) && taxonomy_exists($taxonomy)) {
$_chosen_attributes[$taxonomy]['terms'] = explode(',', $_GET[$name]);
if (empty($_GET[$query_type_name]) || !in_array(strtolower($_GET[$query_type_name]), array('and', 'or'))) {
$_chosen_attributes[$taxonomy]['query_type'] = apply_filters('woocommerce_layered_nav_default_query_type', 'and');
} else {
$_chosen_attributes[$taxonomy]['query_type'] = strtolower($_GET[$query_type_name]);
}
}
}
}
if (version_compare(preg_replace('/-beta-([0-9]+)/', '', $woocommerce->version), '2.1', '<')) {
add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
} else {
add_filter('loop_shop_post_in', array(WC()->query, 'layered_nav_query'));
}
}
}
示例3: color_layered_nav_init
public function color_layered_nav_init()
{
if (!is_active_widget(false, false, 'woocommerce_layered_nav', true) && !is_admin()) {
global $_chosen_attributes;
$_chosen_attributes = array();
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
if ($tax->attribute_name == "color") {
$attribute = wc_sanitize_taxonomy_name($tax->attribute_name);
$taxonomy = wc_attribute_taxonomy_name($attribute);
$name = 'filter_' . $attribute;
$query_type_name = 'query_type_' . $attribute;
$taxonomy_exists = in_array($taxonomy, wc_get_attribute_taxonomy_names());
if (!empty($_GET[$name]) && $taxonomy_exists) {
$_chosen_attributes[$taxonomy]['terms'] = explode(',', $_GET[$name]);
if (empty($_GET[$query_type_name]) || !in_array(strtolower($_GET[$query_type_name]), array('and', 'or'))) {
$_chosen_attributes[$taxonomy]['query_type'] = apply_filters('woocommerce_layered_nav_default_query_type', 'and');
} else {
$_chosen_attributes[$taxonomy]['query_type'] = strtolower($_GET[$query_type_name]);
}
}
}
}
}
$wc_query = new WC_Query();
add_filter('loop_shop_post_in', array($wc_query, 'layered_nav_query'));
}
}
示例4: output_csv
/**
* Sort the data for CSV output first
*
* @param int $product_id
* @param array $headers
* @param array $body
* @param array $items
*/
public static function output_csv($product_id, $headers, $body, $items)
{
$headers['quantity'] = __('Quantity', 'wcvendors');
$new_body = array();
foreach ($body as $i => $order) {
// Remove comments
unset($body[$i]['comments']);
// Remove all numeric keys in each order (these are the meta values we are redoing into new lines)
foreach ($order as $key => $col) {
if (is_int($key)) {
unset($order[$key]);
}
}
// New order row
$new_row = $body[$i];
// Remove order to redo
unset($body[$i]);
$order = new WC_Order($i);
foreach ($items[$i]['items'] as $item) {
$product_id = !empty($item['variation_id']) ? $item['variation_id'] : $item['product_id'];
$new_row_with_meta = $new_row;
// Add the qty row
$new_row_with_meta[] = $item['qty'];
$item_meta = $item['name'];
if ($metadata = $order->has_meta($item['product_id'])) {
foreach ($metadata as $meta) {
// Skip hidden core fields
if (in_array($meta['meta_key'], apply_filters('woocommerce_hidden_order_itemmeta', array('_qty', '_tax_class', '_product_id', '_variation_id', '_line_subtotal', '_line_subtotal_tax', '_line_total', '_line_tax', WC_Vendors::$pv_options->get_option('sold_by_label'))))) {
continue;
}
// Skip serialised meta
if (is_serialized($meta['meta_value'])) {
continue;
}
// Get attribute data
if (taxonomy_exists(wc_sanitize_taxonomy_name($meta['meta_key']))) {
$term = get_term_by('slug', $meta['meta_value'], wc_sanitize_taxonomy_name($meta['meta_key']));
$meta['meta_key'] = wc_attribute_label(wc_sanitize_taxonomy_name($meta['meta_key']));
$meta['meta_value'] = isset($term->name) ? $term->name : $meta['meta_value'];
} else {
$meta['meta_key'] = apply_filters('woocommerce_attribute_label', wc_attribute_label($meta['meta_key'], $_product), $meta['meta_key']);
}
$item_meta .= wp_kses_post(rawurldecode($meta['meta_key'])) . ':' . wp_kses_post(wpautop(make_clickable(rawurldecode($meta['meta_value']))));
}
}
$new_row_with_meta['product'] = $item_meta;
$new_body[] = $new_row_with_meta;
}
}
$headers = apply_filters('wcvendors_csv_headers', $headers, $product_id, $items);
$body = apply_filters('wcvendors_csv_body', $new_body, $product_id, $items);
WCV_Export_CSV::download($headers, $body, $product_id);
}
示例5: wc_attribute_label
/**
* Get a product attributes label.
*
* @param mixed $name
* @return string
*/
function wc_attribute_label($name)
{
global $wpdb;
if (taxonomy_is_product_attribute($name)) {
$name = wc_sanitize_taxonomy_name(str_replace('pa_', '', $name));
$label = $wpdb->get_var($wpdb->prepare("SELECT attribute_label FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name = %s;", $name));
if (!$label) {
$label = ucfirst($name);
}
} else {
$label = ucwords(str_replace('-', ' ', $name));
}
return apply_filters('woocommerce_attribute_label', $label, $name);
}
示例6: wc_attribute_label
/**
* Get a product attributes label.
*
* @param string $name
* @param object $product object Optional
* @return string
*/
function wc_attribute_label($name, $product = '')
{
global $wpdb;
if (taxonomy_is_product_attribute($name)) {
$name = wc_sanitize_taxonomy_name(str_replace('pa_', '', $name));
$label = $wpdb->get_var($wpdb->prepare("SELECT attribute_label FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name = %s;", $name));
if (!$label) {
$label = $name;
}
} elseif ($product && ($attributes = $product->get_attributes()) && isset($attributes[sanitize_title($name)]['name'])) {
// Attempt to get label from product, as entered by the user
$label = $attributes[sanitize_title($name)]['name'];
} else {
$label = str_replace('-', ' ', $name);
}
return apply_filters('woocommerce_attribute_label', $label, $name, $product);
}
示例7: post_importer_compatibility
/**
* When running the WP importer, ensure attributes exist.
*
* WordPress import should work - however, it fails to import custom product attribute taxonomies.
* This code grabs the file before it is imported and ensures the taxonomies are created.
*/
public function post_importer_compatibility()
{
global $wpdb;
if (empty($_POST['import_id']) || !class_exists('WXR_Parser')) {
return;
}
$id = absint($_POST['import_id']);
$file = get_attached_file($id);
$parser = new WXR_Parser();
$import_data = $parser->parse($file);
if (isset($import_data['posts'])) {
$posts = $import_data['posts'];
if ($posts && sizeof($posts) > 0) {
foreach ($posts as $post) {
if ('product' === $post['post_type']) {
if (!empty($post['terms'])) {
foreach ($post['terms'] as $term) {
if (strstr($term['domain'], 'pa_')) {
if (!taxonomy_exists($term['domain'])) {
$attribute_name = wc_sanitize_taxonomy_name(str_replace('pa_', '', $term['domain']));
// Create the taxonomy
if (!in_array($attribute_name, wc_get_attribute_taxonomies())) {
$attribute = array('attribute_label' => $attribute_name, 'attribute_name' => $attribute_name, 'attribute_type' => 'select', 'attribute_orderby' => 'menu_order', 'attribute_public' => 0);
$wpdb->insert($wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute);
delete_transient('wc_attribute_taxonomies');
}
// Register the taxonomy now so that the import works!
register_taxonomy($term['domain'], apply_filters('woocommerce_taxonomy_objects_' . $term['domain'], array('product')), apply_filters('woocommerce_taxonomy_args_' . $term['domain'], array('hierarchical' => true, 'show_ui' => false, 'query_var' => true, 'rewrite' => false)));
}
}
}
}
}
}
}
}
}
示例8: wcj_get_order_item_meta_info
/**
* wcj_get_order_item_meta_info.
*
* from woocommerce\includes\admin\meta-boxes\views\html-order-item-meta.php
*
* @version 2.5.9
* @since 2.5.9
*/
function wcj_get_order_item_meta_info($item_id, $item, $_order, $exclude_wcj_meta = false, $_product = null)
{
$meta_info = '';
if ($metadata = $_order->has_meta($item_id)) {
$meta_info = array();
foreach ($metadata as $meta) {
// Skip hidden core fields
if (in_array($meta['meta_key'], apply_filters('woocommerce_hidden_order_itemmeta', array('_qty', '_tax_class', '_product_id', '_variation_id', '_line_subtotal', '_line_subtotal_tax', '_line_total', '_line_tax', 'method_id', 'cost')))) {
continue;
}
if ($exclude_wcj_meta && ('wcj' === substr($meta['meta_key'], 0, 3) || '_wcj' === substr($meta['meta_key'], 0, 4))) {
continue;
}
// Skip serialised meta
if (is_serialized($meta['meta_value'])) {
continue;
}
// Get attribute data
if (taxonomy_exists(wc_sanitize_taxonomy_name($meta['meta_key']))) {
$term = get_term_by('slug', $meta['meta_value'], wc_sanitize_taxonomy_name($meta['meta_key']));
$meta['meta_key'] = wc_attribute_label(wc_sanitize_taxonomy_name($meta['meta_key']));
$meta['meta_value'] = isset($term->name) ? $term->name : $meta['meta_value'];
} else {
$the_product = null;
if (is_object($_product)) {
$the_product = $_product;
} elseif (is_object($item)) {
$the_product = $_order->get_product_from_item($item);
}
$meta['meta_key'] = is_object($the_product) ? wc_attribute_label($meta['meta_key'], $the_product) : $meta['meta_key'];
}
$meta_info[] = wp_kses_post(rawurldecode($meta['meta_key'])) . ': ' . wp_kses_post(rawurldecode($meta['meta_value']));
}
$meta_info = implode(', ', $meta_info);
}
return $meta_info;
}
示例9: layeredNavInit
/**
* Layered Nav Init
*
* @global array $_chosen_attributes
*
* @return false if not layered nav filter
*/
public function layeredNavInit()
{
if (!(is_active_widget(false, false, 'woocommerce_layered_nav', true) && !is_admin())) {
return false;
}
global $_chosen_attributes;
$attributes = wc_get_attribute_taxonomies();
foreach ($attributes as $tax) {
$attribute = wc_sanitize_taxonomy_name($tax->attribute_name);
$taxonomy = wc_attribute_taxonomy_name($attribute);
$name = 'filter_' . $attribute;
if (!(!empty($_GET[$name]) && taxonomy_exists($taxonomy))) {
continue;
}
$terms = explode(',', $_GET[$name]);
$termsTranslations = array();
foreach ($terms as $ID) {
$translation = pll_get_term($ID);
$termsTranslations[] = $translation ? $translation : $ID;
}
$_GET[$name] = implode(',', $termsTranslations);
$_chosen_attributes[$taxonomy]['terms'] = $termsTranslations;
}
}
示例10: USING
$wpdb->query("\r\n\tUPDATE {$wpdb->posts} as posts\r\n\tLEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID\r\n\tLEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )\r\n\tLEFT JOIN {$wpdb->terms} AS term USING( term_id )\r\n\tSET posts.post_status = 'wc-on-hold'\r\n\tWHERE posts.post_type = 'shop_order'\r\n\tAND posts.post_status = 'publish'\r\n\tAND tax.taxonomy = 'shop_order_status'\r\n\tAND\tterm.slug LIKE 'on-hold%';\r\n\t");
$wpdb->query("\r\n\tUPDATE {$wpdb->posts} as posts\r\n\tLEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID\r\n\tLEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )\r\n\tLEFT JOIN {$wpdb->terms} AS term USING( term_id )\r\n\tSET posts.post_status = 'wc-completed'\r\n\tWHERE posts.post_type = 'shop_order'\r\n\tAND posts.post_status = 'publish'\r\n\tAND tax.taxonomy = 'shop_order_status'\r\n\tAND\tterm.slug LIKE 'completed%';\r\n\t");
$wpdb->query("\r\n\tUPDATE {$wpdb->posts} as posts\r\n\tLEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID\r\n\tLEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )\r\n\tLEFT JOIN {$wpdb->terms} AS term USING( term_id )\r\n\tSET posts.post_status = 'wc-cancelled'\r\n\tWHERE posts.post_type = 'shop_order'\r\n\tAND posts.post_status = 'publish'\r\n\tAND tax.taxonomy = 'shop_order_status'\r\n\tAND\tterm.slug LIKE 'cancelled%';\r\n\t");
$wpdb->query("\r\n\tUPDATE {$wpdb->posts} as posts\r\n\tLEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID\r\n\tLEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )\r\n\tLEFT JOIN {$wpdb->terms} AS term USING( term_id )\r\n\tSET posts.post_status = 'wc-refunded'\r\n\tWHERE posts.post_type = 'shop_order'\r\n\tAND posts.post_status = 'publish'\r\n\tAND tax.taxonomy = 'shop_order_status'\r\n\tAND\tterm.slug LIKE 'refunded%';\r\n\t");
$wpdb->query("\r\n\tUPDATE {$wpdb->posts} as posts\r\n\tLEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID\r\n\tLEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )\r\n\tLEFT JOIN {$wpdb->terms} AS term USING( term_id )\r\n\tSET posts.post_status = 'wc-failed'\r\n\tWHERE posts.post_type = 'shop_order'\r\n\tAND posts.post_status = 'publish'\r\n\tAND tax.taxonomy = 'shop_order_status'\r\n\tAND\tterm.slug LIKE 'failed%';\r\n\t");
// Update variations which manage stock
$update_variations = $wpdb->get_results("\r\n\tSELECT DISTINCT posts.ID AS variation_id, posts.post_parent AS variation_parent FROM {$wpdb->posts} as posts\r\n\tLEFT OUTER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id AND postmeta.meta_key = '_stock'\r\n\tLEFT OUTER JOIN {$wpdb->postmeta} as postmeta2 ON posts.ID = postmeta2.post_id AND postmeta2.meta_key = '_manage_stock'\r\n\tWHERE posts.post_type = 'product_variation'\r\n\tAND postmeta.meta_value IS NOT NULL\r\n\tAND postmeta.meta_value != ''\r\n\tAND postmeta2.meta_value IS NULL\r\n");
foreach ($update_variations as $variation) {
$parent_backorders = get_post_meta($variation->variation_parent, '_backorders', true);
add_post_meta($variation->variation_id, '_manage_stock', 'yes', true);
add_post_meta($variation->variation_id, '_backorders', $parent_backorders ? $parent_backorders : 'no', true);
}
// Update taxonomy names with correct sanitized names
$attribute_taxonomies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies");
foreach ($attribute_taxonomies as $attribute_taxonomy) {
$sanitized_attribute_name = wc_sanitize_taxonomy_name($attribute_taxonomy->attribute_name);
if ($sanitized_attribute_name !== $attribute_taxonomy->attribute_name) {
if (!$wpdb->get_var($wpdb->prepare("SELECT 1 FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name = %s;", $sanitized_attribute_name))) {
// Update attribute
$wpdb->update("{$wpdb->prefix}woocommerce_attribute_taxonomies", array('attribute_name' => $sanitized_attribute_name), array('attribute_id' => $attribute_taxonomy->attribute_id));
// Update terms
$wpdb->update($wpdb->term_taxonomy, array('taxonomy' => wc_attribute_taxonomy_name($sanitized_attribute_name)), array('taxonomy' => 'pa_' . $attribute_taxonomy->attribute_name));
}
}
}
// add webhook capabilities to shop_manager/administrator role
global $wp_roles;
if (class_exists('WP_Roles')) {
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
示例11: woocommerce_sanitize_taxonomy_name
/**
* @deprecated
*/
function woocommerce_sanitize_taxonomy_name($taxonomy)
{
return wc_sanitize_taxonomy_name($taxonomy);
}
示例12: process_edit_attribute
/**
* Edit an attribute
* @return bool|WP_Error
*/
private static function process_edit_attribute()
{
global $wpdb;
$attribute_id = absint($_GET['edit']);
check_admin_referer('woocommerce-save-attribute_' . $attribute_id);
$attribute = self::get_posted_attribute();
if (empty($attribute['attribute_name']) || empty($attribute['attribute_label'])) {
return new WP_Error('error', __('Please, provide an attribute name and slug.', 'woocommerce'));
} elseif (($valid_attribute_name = self::valid_attribute_name($attribute['attribute_name'])) && is_wp_error($valid_attribute_name)) {
return $valid_attribute_name;
}
$taxonomy_exists = taxonomy_exists(wc_attribute_taxonomy_name($attribute['attribute_name']));
$old_attribute_name = $wpdb->get_var("SELECT attribute_name FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = {$attribute_id}");
if ($old_attribute_name != $attribute['attribute_name'] && wc_sanitize_taxonomy_name($old_attribute_name) != $attribute['attribute_name'] && $taxonomy_exists) {
return new WP_Error('error', sprintf(__('Slug "%s" is already in use. Change it, please.', 'woocommerce'), sanitize_title($attribute['attribute_name'])));
}
$wpdb->update($wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute, array('attribute_id' => $attribute_id));
do_action('woocommerce_attribute_updated', $attribute_id, $attribute, $old_attribute_name);
if ($old_attribute_name != $attribute['attribute_name'] && !empty($old_attribute_name)) {
// Update taxonomies in the wp term taxonomy table
$wpdb->update($wpdb->term_taxonomy, array('taxonomy' => wc_attribute_taxonomy_name($attribute['attribute_name'])), array('taxonomy' => 'pa_' . $old_attribute_name));
// Update taxonomy ordering term meta
$wpdb->update($wpdb->prefix . 'woocommerce_termmeta', array('meta_key' => 'order_pa_' . sanitize_title($attribute['attribute_name'])), array('meta_key' => 'order_pa_' . sanitize_title($old_attribute_name)));
// Update product attributes which use this taxonomy
$old_attribute_name_length = strlen($old_attribute_name) + 3;
$attribute_name_length = strlen($attribute['attribute_name']) + 3;
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE( meta_value, %s, %s ) WHERE meta_key = '_product_attributes'", 's:' . $old_attribute_name_length . ':"pa_' . $old_attribute_name . '"', 's:' . $attribute_name_length . ':"pa_' . $attribute['attribute_name'] . '"'));
// Update variations which use this taxonomy
$wpdb->update($wpdb->postmeta, array('meta_key' => 'attribute_pa_' . sanitize_title($attribute['attribute_name'])), array('meta_key' => 'attribute_pa_' . sanitize_title($old_attribute_name)));
}
echo '<div class="updated"><p>' . __('Attribute updated successfully', 'woocommerce') . '</p></div>';
flush_rewrite_rules();
delete_transient('wc_attribute_taxonomies');
return true;
}
示例13: wcs_get_line_item_name
/**
* Get the full name for a order/subscription line item, including the items non hidden meta
* (i.e. attributes), as a flat string.
*
* @param array
* @return string
*/
function wcs_get_line_item_name($line_item)
{
$item_meta_strings = array();
foreach ($line_item['item_meta'] as $meta_key => $meta_value) {
$meta_value = $meta_value[0];
// Skip hidden core fields
if (in_array($meta_key, apply_filters('woocommerce_hidden_order_itemmeta', array('_qty', '_tax_class', '_product_id', '_variation_id', '_line_subtotal', '_line_subtotal_tax', '_line_total', '_line_tax', '_line_tax_data')))) {
continue;
}
// Skip serialised meta
if (is_serialized($meta_value)) {
continue;
}
// Get attribute data
if (taxonomy_exists(wc_sanitize_taxonomy_name($meta_key))) {
$term = get_term_by('slug', $meta_value, wc_sanitize_taxonomy_name($meta_key));
$meta_key = wc_attribute_label(wc_sanitize_taxonomy_name($meta_key));
$meta_value = isset($term->name) ? $term->name : $meta_value;
} else {
$meta_key = apply_filters('woocommerce_attribute_label', wc_attribute_label($meta_key), $meta_key);
}
$item_meta_strings[] = sprintf('%s: %s', rawurldecode($meta_key), rawurldecode($meta_value));
}
if (!empty($item_meta_strings)) {
$line_item_name = sprintf('%s (%s)', $line_item['name'], implode(', ', $item_meta_strings));
} else {
$line_item_name = $line_item['name'];
}
return apply_filters('wcs_line_item_name', $line_item_name, $line_item);
}
示例14: foreach
<?php
foreach ($product_attributes as $attribute) {
?>
<tr class="dokan-attribute-options">
<td width="20%">
<?php
if ($attribute['is_taxonomy']) {
?>
<?php
$tax = get_taxonomy($attribute['name']);
?>
<input type="text" disabled="disabled" value="<?php
echo $tax->label;
?>
" class="dokan-form-control dokan-attribute-option-name-label" data-attribute_name="<?php
echo wc_sanitize_taxonomy_name(str_replace('pa_', '', $attribute['name']));
?>
">
<input type="hidden" name="attribute_names[]" value="<?php
echo esc_attr($attribute['name']);
?>
" class="dokan-attribute-option-name">
<?php
} else {
?>
<input type="text" name="attribute_names[]" value="<?php
echo $attribute['name'];
?>
" class="dokan-form-control dokan-attribute-option-name">
<?php
}
示例15: add_predefined_attribute
/**
* Add Predefined Attribute
*
* @since 2.3
*
* @return json success|$content (array)
*/
function add_predefined_attribute()
{
$attr_name = $_POST['name'];
$single = isset($_POST['from']) && $_POST['from'] == 'popup' ? 'single-' : '';
$remove_btn = isset($_POST['from']) && $_POST['from'] == 'popup' ? 'single_' : '';
$attribute_taxonomy_name = wc_attribute_taxonomy_name($attr_name);
$tax = get_taxonomy($attribute_taxonomy_name);
$options = get_terms($attribute_taxonomy_name, 'orderby=name&hide_empty=0');
$att_val = wp_list_pluck($options, 'name');
ob_start();
?>
<tr class="dokan-<?php
echo $single;
?>
attribute-options">
<td width="20%">
<input type="text" disabled="disabled" value="<?php
echo $attr_name;
?>
" class="dokan-form-control dokan-<?php
echo $single;
?>
attribute-option-name-label" data-attribute_name="<?php
echo wc_sanitize_taxonomy_name(str_replace('pa_', '', $attribute_taxonomy_name));
?>
">
<input type="hidden" name="attribute_names[]" value="<?php
echo esc_attr($attribute_taxonomy_name);
?>
" class="dokan-<?php
echo $single;
?>
attribute-option-name">
<input type="hidden" name="attribute_is_taxonomy[]" value="1">
</td>
<td colspan="3"><input type="text" name="attribute_values[]" value="<?php
echo implode(',', $att_val);
?>
" class="dokan-form-control dokan-<?php
echo $single;
?>
attribute-option-values"></td>
<td><button class="dokan-btn dokan-btn-theme remove_<?php
echo $remove_btn;
?>
attribute"><i class="fa fa-trash-o"></i></button></td>
</tr>
<?php
$content = ob_get_clean();
wp_send_json_success($content);
}