本文整理汇总了PHP中wc_get_attribute_types函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_attribute_types函数的具体用法?PHP wc_get_attribute_types怎么用?PHP wc_get_attribute_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_get_attribute_types函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: add_attribute
//.........这里部分代码省略.........
</div>
<div class="form-field">
<label for="attribute_name"><?php
_e('Slug', 'woocommerce');
?>
</label>
<input name="attribute_name" id="attribute_name" type="text" value="" maxlength="28" />
<p class="description"><?php
_e('Unique slug/reference for the attribute; must be shorter than 28 characters.', 'woocommerce');
?>
</p>
</div>
<div class="form-field">
<label for="attribute_public"><input name="attribute_public" id="attribute_public" type="checkbox" value="1" /> <?php
_e('Enable Archives?', 'woocommerce');
?>
</label>
<p class="description"><?php
_e('Enable this if you want this attribute to have product archives in your store.', 'woocommerce');
?>
</p>
</div>
<div class="form-field">
<label for="attribute_type"><?php
_e('Type', 'woocommerce');
?>
</label>
<select name="attribute_type" id="attribute_type">
<?php
foreach (wc_get_attribute_types() as $key => $value) {
?>
<option value="<?php
echo esc_attr($key);
?>
"><?php
echo esc_attr($value);
?>
</option>
<?php
}
?>
<?php
/**
* Deprecated action in favor of product_attributes_type_selector filter
*
* @deprecated 2.4.0
*/
do_action('woocommerce_admin_attribute_types');
?>
</select>
<p class="description"><?php
_e('Determines how you select attributes for products. Under admin panel -> products -> product data -> attributes -> values, <strong>Text</strong> allows manual entry whereas <strong>select</strong> allows pre-configured terms in a drop-down list.', 'woocommerce');
?>
</p>
</div>
<div class="form-field">
<label for="attribute_orderby"><?php
_e('Default sort order', 'woocommerce');
?>
</label>
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:67,代码来源:class-wc-admin-attributes.php
示例2: validate_attribute_data
/**
* Validate attribute data.
*
* @since 2.4.0
* @param string $name
* @param string $slug
* @param string $type
* @param string $order_by
* @param bool $new_data
* @return bool
*/
protected function validate_attribute_data($name, $slug, $type, $order_by, $new_data = true)
{
if (empty($name)) {
throw new WC_API_Exception('woocommerce_api_missing_product_attribute_name', sprintf(__('Missing parameter %s', 'woocommerce'), 'name'), 400);
}
if (strlen($slug) >= 28) {
throw new WC_API_Exception('woocommerce_api_invalid_product_attribute_slug_too_long', sprintf(__('Slug "%s" is too long (28 characters max). Shorten it, please.', 'woocommerce'), $slug), 400);
} else {
if (wc_check_if_attribute_name_is_reserved($slug)) {
throw new WC_API_Exception('woocommerce_api_invalid_product_attribute_slug_reserved_name', sprintf(__('Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce'), $slug), 400);
} else {
if ($new_data && taxonomy_exists(wc_attribute_taxonomy_name($slug))) {
throw new WC_API_Exception('woocommerce_api_invalid_product_attribute_slug_already_exists', sprintf(__('Slug "%s" is already in use. Change it, please.', 'woocommerce'), $slug), 400);
}
}
}
// Validate the attribute type
if (!in_array(wc_clean($type), array_keys(wc_get_attribute_types()))) {
throw new WC_API_Exception('woocommerce_api_invalid_product_attribute_type', sprintf(__('Invalid product attribute type - the product attribute type must be any of these: %s', 'woocommerce'), implode(', ', array_keys(wc_get_attribute_types()))), 400);
}
// Validate the attribute order by
if (!in_array(wc_clean($order_by), array('menu_order', 'name', 'name_num', 'id'))) {
throw new WC_API_Exception('woocommerce_api_invalid_product_attribute_order_by', sprintf(__('Invalid product attribute order_by type - the product attribute order_by type must be any of these: %s', 'woocommerce'), implode(', ', array('menu_order', 'name', 'name_num', 'id'))), 400);
}
return true;
}
开发者ID:haltaction,项目名称:woocommerce,代码行数:37,代码来源:class-wc-api-products.php
示例3: get_item_schema
/**
* Get the Attribute's schema, conforming to JSON Schema.
*
* @return array
*/
public function get_item_schema()
{
$schema = array('$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => 'product_attribute', 'type' => 'object', 'properties' => array('id' => array('description' => __('Unique identifier for the resource.', 'woocommerce'), 'type' => 'integer', 'context' => array('view', 'edit'), 'readonly' => true), 'name' => array('description' => __('Attribute name.', 'woocommerce'), 'type' => 'string', 'context' => array('view', 'edit'), 'arg_options' => array('sanitize_callback' => 'sanitize_text_field')), 'slug' => array('description' => __('An alphanumeric identifier for the resource unique to its type.', 'woocommerce'), 'type' => 'string', 'context' => array('view', 'edit'), 'arg_options' => array('sanitize_callback' => 'sanitize_title')), 'type' => array('description' => __('Type of attribute.', 'woocommerce'), 'type' => 'string', 'default' => 'select', 'enum' => array_keys(wc_get_attribute_types()), 'context' => array('view', 'edit')), 'order_by' => array('description' => __('Default sort order.', 'woocommerce'), 'type' => 'string', 'default' => 'menu_order', 'enum' => array('menu_order', 'name', 'name_num', 'id'), 'context' => array('view', 'edit')), 'has_archives' => array('description' => __('Enable/Disable attribute archives.', 'woocommerce'), 'type' => 'boolean', 'default' => false, 'context' => array('view', 'edit'))));
return $this->add_additional_fields_schema($schema);
}
开发者ID:tlovett1,项目名称:woocommerce,代码行数:10,代码来源:class-wc-rest-product-attributes-controller.php
注:本文中的wc_get_attribute_types函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论