2013-08-06 15:56:15 +00:00
< ? php
/**
2015-11-03 13:53:50 +00:00
* Attributes Page
2013-08-06 15:56:15 +00:00
*
* The attributes section lets users add custom attributes to assign to products - they can also be used in the layered nav widget .
*
2014-11-27 16:49:19 +00:00
* @ author WooThemes
* @ category Admin
* @ package WooCommerce / Admin
* @ version 2.3 . 0
2013-08-06 15:56:15 +00:00
*/
2014-09-20 19:52:30 +00:00
if ( ! defined ( 'ABSPATH' ) ) {
2014-11-27 16:49:19 +00:00
exit ;
2014-09-20 19:52:30 +00:00
}
2013-08-06 15:56:15 +00:00
/**
2015-11-03 12:28:01 +00:00
* WC_Admin_Attributes Class .
2013-08-06 15:56:15 +00:00
*/
class WC_Admin_Attributes {
/**
* Handles output of the attributes page in admin .
*
* Shows the created attributes and lets you add new ones or edit existing ones .
2014-11-27 16:49:19 +00:00
* The added attributes are stored in the database and can be used for layered navigation .
2013-08-06 15:56:15 +00:00
*/
2014-06-04 10:16:19 +00:00
public static function output () {
2015-01-15 16:32:10 +00:00
$result = '' ;
$action = '' ;
2013-08-06 15:56:15 +00:00
2017-11-06 10:58:57 +00:00
// Action to perform: add, edit, delete or none.
2013-08-06 15:56:15 +00:00
if ( ! empty ( $_POST [ 'add_new_attribute' ] ) ) {
$action = 'add' ;
} elseif ( ! empty ( $_POST [ 'save_attribute' ] ) && ! empty ( $_GET [ 'edit' ] ) ) {
$action = 'edit' ;
} elseif ( ! empty ( $_GET [ 'delete' ] ) ) {
$action = 'delete' ;
}
2015-01-15 16:32:10 +00:00
switch ( $action ) {
case 'add' :
$result = self :: process_add_attribute ();
break ;
case 'edit' :
$result = self :: process_edit_attribute ();
break ;
case 'delete' :
$result = self :: process_delete_attribute ();
break ;
}
2013-08-06 15:56:15 +00:00
2015-01-15 16:32:10 +00:00
if ( is_wp_error ( $result ) ) {
2017-01-06 12:45:26 +00:00
echo '<div id="woocommerce_errors" class="error"><p>' . wp_kses_post ( $result -> get_error_message () ) . '</p></div>' ;
2015-01-15 16:32:10 +00:00
}
2013-08-06 15:56:15 +00:00
2017-11-06 10:58:57 +00:00
// Show admin interface.
2015-01-15 16:32:10 +00:00
if ( ! empty ( $_GET [ 'edit' ] ) ) {
self :: edit_attribute ();
} else {
self :: add_attribute ();
}
}
2013-08-06 15:56:15 +00:00
2015-01-15 16:32:10 +00:00
/**
2015-11-03 12:28:01 +00:00
* Get and sanitize posted attribute data .
2017-11-06 10:58:57 +00:00
*
2015-01-15 16:32:10 +00:00
* @ return array
*/
private static function get_posted_attribute () {
$attribute = array (
'attribute_label' => isset ( $_POST [ 'attribute_label' ] ) ? wc_clean ( stripslashes ( $_POST [ 'attribute_label' ] ) ) : '' ,
'attribute_name' => isset ( $_POST [ 'attribute_name' ] ) ? wc_sanitize_taxonomy_name ( stripslashes ( $_POST [ 'attribute_name' ] ) ) : '' ,
'attribute_type' => isset ( $_POST [ 'attribute_type' ] ) ? wc_clean ( $_POST [ 'attribute_type' ] ) : 'select' ,
'attribute_orderby' => isset ( $_POST [ 'attribute_orderby' ] ) ? wc_clean ( $_POST [ 'attribute_orderby' ] ) : '' ,
2016-08-27 01:46:45 +00:00
'attribute_public' => isset ( $_POST [ 'attribute_public' ] ) ? 1 : 0 ,
2015-01-15 16:32:10 +00:00
);
if ( empty ( $attribute [ 'attribute_type' ] ) ) {
$attribute [ 'attribute_type' ] = 'select' ;
}
if ( empty ( $attribute [ 'attribute_label' ] ) ) {
$attribute [ 'attribute_label' ] = ucfirst ( $attribute [ 'attribute_name' ] );
}
2015-02-12 23:25:10 +00:00
if ( empty ( $attribute [ 'attribute_name' ] ) ) {
2015-01-15 16:32:10 +00:00
$attribute [ 'attribute_name' ] = wc_sanitize_taxonomy_name ( $attribute [ 'attribute_label' ] );
}
2013-08-06 15:56:15 +00:00
2015-01-15 16:32:10 +00:00
return $attribute ;
}
2013-08-06 15:56:15 +00:00
2015-01-15 16:32:10 +00:00
/**
2015-11-03 12:28:01 +00:00
* Add an attribute .
2017-08-08 00:42:56 +00:00
*
2015-01-15 16:32:10 +00:00
* @ return bool | WP_Error
*/
private static function process_add_attribute () {
check_admin_referer ( 'woocommerce-add-new_attribute' );
2013-08-06 15:56:15 +00:00
2015-01-15 16:32:10 +00:00
$attribute = self :: get_posted_attribute ();
2017-08-08 00:42:56 +00:00
$args = array (
2017-08-08 01:33:57 +00:00
'name' => $attribute [ 'attribute_label' ],
'slug' => $attribute [ 'attribute_name' ],
'type' => $attribute [ 'attribute_type' ],
'order_by' => $attribute [ 'attribute_orderby' ],
'has_archives' => $attribute [ 'attribute_public' ],
);
2013-08-06 15:56:15 +00:00
2017-08-08 01:33:57 +00:00
$id = wc_create_attribute ( $args );
2013-08-06 15:56:15 +00:00
2017-08-08 01:33:57 +00:00
if ( is_wp_error ( $id ) ) {
return $id ;
}
2013-08-06 15:56:15 +00:00
2015-01-15 16:32:10 +00:00
return true ;
}
2013-08-06 15:56:15 +00:00
2015-01-15 16:32:10 +00:00
/**
2015-11-03 12:28:01 +00:00
* Edit an attribute .
2017-08-08 00:42:56 +00:00
*
2015-01-15 16:32:10 +00:00
* @ return bool | WP_Error
*/
private static function process_edit_attribute () {
$attribute_id = absint ( $_GET [ 'edit' ] );
check_admin_referer ( 'woocommerce-save-attribute_' . $attribute_id );
$attribute = self :: get_posted_attribute ();
2017-08-08 00:42:56 +00:00
$args = array (
2017-08-08 01:33:57 +00:00
'name' => $attribute [ 'attribute_label' ],
'slug' => $attribute [ 'attribute_name' ],
'type' => $attribute [ 'attribute_type' ],
'order_by' => $attribute [ 'attribute_orderby' ],
'has_archives' => $attribute [ 'attribute_public' ],
);
$id = wc_update_attribute ( $attribute_id , $args );
if ( is_wp_error ( $id ) ) {
return $id ;
2013-08-06 15:56:15 +00:00
}
2017-05-25 10:15:57 +00:00
echo '<div class="updated"><p>' . __ ( 'Attribute updated successfully' , 'woocommerce' ) . '</p><p><a href="' . esc_url ( admin_url ( 'edit.php?post_type=product&page=product_attributes' ) ) . '">' . __ ( 'Back to Attributes' , 'woocommerce' ) . '</a></p></div>' ;
2015-01-15 16:32:10 +00:00
return true ;
}
/**
2015-11-03 12:28:01 +00:00
* Delete an attribute .
2017-08-08 00:42:56 +00:00
*
2015-01-15 16:32:10 +00:00
* @ return bool
*/
private static function process_delete_attribute () {
$attribute_id = absint ( $_GET [ 'delete' ] );
check_admin_referer ( 'woocommerce-delete-attribute_' . $attribute_id );
2017-08-08 00:42:56 +00:00
return wc_delete_attribute ( $attribute_id );
2013-08-06 15:56:15 +00:00
}
/**
2015-11-03 12:28:01 +00:00
* Edit Attribute admin panel .
2013-08-06 15:56:15 +00:00
*
2015-11-03 12:28:01 +00:00
* Shows the interface for changing an attributes type between select and text .
2013-08-06 15:56:15 +00:00
*/
2014-06-04 10:16:19 +00:00
public static function edit_attribute () {
2013-08-06 15:56:15 +00:00
global $wpdb ;
$edit = absint ( $_GET [ 'edit' ] );
2017-02-13 12:58:42 +00:00
$attribute_to_edit = $wpdb -> get_row ( " SELECT attribute_type, attribute_label, attribute_name, attribute_orderby, attribute_public FROM " . $wpdb -> prefix . " woocommerce_attribute_taxonomies WHERE attribute_id = ' $edit ' " );
2013-08-06 15:56:15 +00:00
?>
< div class = " wrap woocommerce " >
2017-11-06 10:58:57 +00:00
< h1 >< ? php esc_html_e ( 'Edit attribute' , 'woocommerce' ) ?> </h1>
2015-05-27 16:19:44 +00:00
< ? php
2017-11-06 10:58:57 +00:00
if ( ! $attribute_to_edit ) {
echo '<div id="woocommerce_errors" class="error"><p>' . esc_html__ ( 'Error: non-existing attribute ID.' , 'woocommerce' ) . '</p></div>' ;
} else {
$att_type = $attribute_to_edit -> attribute_type ;
$att_label = $attribute_to_edit -> attribute_label ;
$att_name = $attribute_to_edit -> attribute_name ;
$att_orderby = $attribute_to_edit -> attribute_orderby ;
$att_public = $attribute_to_edit -> attribute_public ;
?>
2015-05-27 16:19:44 +00:00
< form action = " edit.php?post_type=product&page=product_attributes&edit=<?php echo absint( $edit ); ?> " method = " post " >
< table class = " form-table " >
< tbody >
2016-08-01 09:27:15 +00:00
< ? php do_action ( 'woocommerce_before_edit_attribute_fields' ); ?>
< tr class = " form-field form-required " >
2015-05-27 16:19:44 +00:00
< th scope = " row " valign = " top " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_label " >< ? php esc_html_e ( 'Name' , 'woocommerce' ); ?> </label>
2015-05-27 16:19:44 +00:00
</ th >
< td >
< input name = " attribute_label " id = " attribute_label " type = " text " value = " <?php echo esc_attr( $att_label ); ?> " />
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_e ( 'Name for the attribute (shown on the front-end).' , 'woocommerce' ); ?> </p>
2015-05-27 16:19:44 +00:00
</ td >
</ tr >
< tr class = " form-field form-required " >
< th scope = " row " valign = " top " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_name " >< ? php esc_html_e ( 'Slug' , 'woocommerce' ); ?> </label>
2015-05-27 16:19:44 +00:00
</ th >
< td >
< input name = " attribute_name " id = " attribute_name " type = " text " value = " <?php echo esc_attr( $att_name ); ?> " maxlength = " 28 " />
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_e ( 'Unique slug/reference for the attribute; must be no more than 28 characters.' , 'woocommerce' ); ?> </p>
2015-05-27 16:19:44 +00:00
</ td >
</ tr >
< tr class = " form-field form-required " >
< th scope = " row " valign = " top " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_public " >< ? php esc_html_e ( 'Enable archives?' , 'woocommerce' ); ?> </label>
2015-05-27 16:19:44 +00:00
</ th >
< td >
< input name = " attribute_public " id = " attribute_public " type = " checkbox " value = " 1 " < ? php checked ( $att_public , 1 ); ?> />
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_e ( 'Enable this if you want this attribute to have product archives in your store.' , 'woocommerce' ); ?> </p>
2015-05-27 16:19:44 +00:00
</ td >
</ tr >
< tr class = " form-field form-required " >
< th scope = " row " valign = " top " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_type " >< ? php esc_html_e ( 'Type' , 'woocommerce' ); ?> </label>
2015-05-27 16:19:44 +00:00
</ th >
< td >
< select name = " attribute_type " id = " attribute_type " >
< ? php foreach ( wc_get_attribute_types () as $key => $value ) : ?>
< option value = " <?php echo esc_attr( $key ); ?> " < ? php selected ( $att_type , $key ); ?> ><?php echo esc_attr( $value ); ?></option>
< ? php endforeach ; ?>
< ? php
/**
2015-11-03 12:28:01 +00:00
* Deprecated action in favor of product_attributes_type_selector filter .
2015-05-27 16:19:44 +00:00
*
* @ deprecated 2.4 . 0
*/
do_action ( 'woocommerce_admin_attribute_types' );
?>
</ select >
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_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>
2015-05-27 16:19:44 +00:00
</ td >
</ tr >
< tr class = " form-field form-required " >
< th scope = " row " valign = " top " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_orderby " >< ? php esc_html_e ( 'Default sort order' , 'woocommerce' ); ?> </label>
2015-05-27 16:19:44 +00:00
</ th >
< td >
< select name = " attribute_orderby " id = " attribute_orderby " >
2017-11-06 10:58:57 +00:00
< option value = " menu_order " < ? php selected ( $att_orderby , 'menu_order' ); ?> ><?php esc_html_e( 'Custom ordering', 'woocommerce' ); ?></option>
< option value = " name " < ? php selected ( $att_orderby , 'name' ); ?> ><?php esc_html_e( 'Name', 'woocommerce' ); ?></option>
< option value = " name_num " < ? php selected ( $att_orderby , 'name_num' ); ?> ><?php esc_html_e( 'Name (numeric)', 'woocommerce' ); ?></option>
< option value = " id " < ? php selected ( $att_orderby , 'id' ); ?> ><?php esc_html_e( 'Term ID', 'woocommerce' ); ?></option>
2015-05-27 16:19:44 +00:00
</ select >
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_e ( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.' , 'woocommerce' ); ?> </p>
2015-05-27 16:19:44 +00:00
</ td >
</ tr >
2016-08-01 09:27:15 +00:00
< ? php do_action ( 'woocommerce_after_edit_attribute_fields' ) ?>
2015-05-27 16:19:44 +00:00
</ tbody >
</ table >
2017-11-06 10:45:14 +00:00
< p class = " submit " >< button type = " submit " name = " save_attribute " id = " submit " class = " button-primary " value = " <?php esc_attr_e( 'Update', 'woocommerce' ); ?> " >< ? php esc_html_e ( 'Update' , 'woocommerce' ); ?> </button></p>
2015-05-27 16:19:44 +00:00
< ? php wp_nonce_field ( 'woocommerce-save-attribute_' . $edit ); ?>
</ form >
< ? php } ?>
2013-08-06 15:56:15 +00:00
</ div >
< ? php
}
/**
2015-11-03 12:28:01 +00:00
* Add Attribute admin panel .
2013-08-06 15:56:15 +00:00
*
2015-11-03 12:28:01 +00:00
* Shows the interface for adding new attributes .
2013-08-06 15:56:15 +00:00
*/
2014-06-04 10:16:19 +00:00
public static function add_attribute () {
2013-08-06 15:56:15 +00:00
?>
< div class = " wrap woocommerce " >
2017-11-06 10:58:57 +00:00
< h1 >< ? php echo esc_html ( get_admin_page_title () ); ?> </h1>
2016-10-13 16:34:48 +00:00
2014-11-27 16:49:19 +00:00
< br class = " clear " />
< div id = " col-container " >
< div id = " col-right " >
< div class = " col-wrap " >
< table class = " widefat attributes-table wp-list-table ui-sortable " style = " width:100% " >
< thead >
< tr >
2017-11-06 10:58:57 +00:00
< th scope = " col " >< ? php esc_html_e ( 'Name' , 'woocommerce' ); ?> </th>
< th scope = " col " >< ? php esc_html_e ( 'Slug' , 'woocommerce' ); ?> </th>
< th scope = " col " >< ? php esc_html_e ( 'Type' , 'woocommerce' ); ?> </th>
< th scope = " col " >< ? php esc_html_e ( 'Order by' , 'woocommerce' ); ?> </th>
< th scope = " col " >< ? php esc_html_e ( 'Terms' , 'woocommerce' ); ?> </th>
2014-11-27 16:49:19 +00:00
</ tr >
</ thead >
< tbody >
< ? php
2017-11-06 10:58:57 +00:00
if ( $attribute_taxonomies = wc_get_attribute_taxonomies () ) :
foreach ( $attribute_taxonomies as $tax ) :
?> <tr>
2014-11-27 17:29:52 +00:00
< td >
< strong >< a href = " edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&post_type=product " >< ? php echo esc_html ( $tax -> attribute_label ); ?> </a></strong>
2014-11-27 16:49:19 +00:00
2017-11-06 10:58:57 +00:00
< div class = " row-actions " >< span class = " edit " >< a href = " <?php echo esc_url( add_query_arg( 'edit', $tax->attribute_id , 'edit.php?post_type=product&page=product_attributes' ) ); ?> " >< ? php esc_html_e ( 'Edit' , 'woocommerce' ); ?> </a> | </span><span class="delete"><a class="delete" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'delete', $tax->attribute_id, 'edit.php?post_type=product&page=product_attributes' ), 'woocommerce-delete-attribute_' . $tax->attribute_id ) ); ?>"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a></span></div>
2014-11-27 16:49:19 +00:00
</ td >
< td >< ? php echo esc_html ( $tax -> attribute_name ); ?> </td>
2017-11-06 10:58:57 +00:00
< td >< ? php echo esc_html ( wc_get_attribute_type_label ( $tax -> attribute_type ) ); ?> <?php echo $tax->attribute_public ? esc_html__( '(Public)', 'woocommerce' ) : ''; ?></td>
2014-11-27 16:49:19 +00:00
< td >< ? php
2017-11-06 10:58:57 +00:00
switch ( $tax -> attribute_orderby ) {
case 'name' :
esc_html_e ( 'Name' , 'woocommerce' );
break ;
case 'name_num' :
esc_html_e ( 'Name (numeric)' , 'woocommerce' );
break ;
case 'id' :
esc_html_e ( 'Term ID' , 'woocommerce' );
break ;
default :
esc_html_e ( 'Custom ordering' , 'woocommerce' );
break ;
}
?>
</ td >
< td class = " attribute-terms " >
< ? php
$taxonomy = wc_attribute_taxonomy_name ( $tax -> attribute_name );
if ( taxonomy_exists ( $taxonomy ) ) {
if ( 'menu_order' === wc_attribute_orderby ( $taxonomy ) ) {
$terms = get_terms ( $taxonomy , 'hide_empty=0&menu_order=ASC' );
} else {
$terms = get_terms ( $taxonomy , 'hide_empty=0&menu_order=false' );
}
2014-11-27 16:49:19 +00:00
switch ( $tax -> attribute_orderby ) {
case 'name_num' :
2017-11-06 10:58:57 +00:00
usort ( $terms , '_wc_get_product_terms_name_num_usort_callback' );
2014-11-27 16:49:19 +00:00
break ;
2017-11-06 10:58:57 +00:00
case 'parent' :
usort ( $terms , '_wc_get_product_terms_parent_usort_callback' );
2014-11-27 16:49:19 +00:00
break ;
}
2017-11-06 10:58:57 +00:00
$terms_string = implode ( ', ' , wp_list_pluck ( $terms , 'name' ) );
if ( $terms_string ) {
echo esc_html ( $terms_string );
2014-11-27 14:48:58 +00:00
} else {
2013-08-06 15:56:15 +00:00
echo '<span class="na">–</span>' ;
2014-11-27 14:48:58 +00:00
}
2017-11-06 10:58:57 +00:00
} else {
echo '<span class="na">–</span>' ;
}
2016-08-18 03:02:18 +00:00
?>
2017-11-06 10:58:57 +00:00
< br />< a href = " edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&post_type=product " class = " configure-terms " >< ? php esc_html_e ( 'Configure terms' , 'woocommerce' ); ?> </a>
2016-08-18 03:02:18 +00:00
</ td >
2017-11-06 10:58:57 +00:00
</ tr >
< ? php
2014-11-27 16:49:19 +00:00
endforeach ;
else :
2017-11-06 10:58:57 +00:00
?> <tr><td colspan="6"><?php esc_html_e( 'No attributes currently exist.', 'woocommerce' ) ?></td></tr><?php
2014-11-27 16:49:19 +00:00
endif ;
?>
</ tbody >
</ table >
</ div >
</ div >
< div id = " col-left " >
< div class = " col-wrap " >
< div class = " form-wrap " >
2017-11-06 10:58:57 +00:00
< h2 >< ? php esc_html_e ( 'Add new attribute' , 'woocommerce' ); ?> </h2>
< p >< ? php esc_html_e ( 'Attributes let you define extra product data, such as size or color. You can use these attributes in the shop sidebar using the "layered nav" widgets. Please note: you cannot rename an attribute later on.' , 'woocommerce' ); ?> </p>
2014-11-27 16:49:19 +00:00
< form action = " edit.php?post_type=product&page=product_attributes " method = " post " >
2016-08-01 09:27:15 +00:00
< ? php do_action ( 'woocommerce_before_add_attribute_fields' ) ?>
2013-08-06 15:56:15 +00:00
< div class = " form-field " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_label " >< ? php esc_html_e ( 'Name' , 'woocommerce' ); ?> </label>
2013-08-06 15:56:15 +00:00
< input name = " attribute_label " id = " attribute_label " type = " text " value = " " />
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_e ( 'Name for the attribute (shown on the front-end).' , 'woocommerce' ); ?> </p>
2013-08-06 15:56:15 +00:00
</ div >
< div class = " form-field " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_name " >< ? php esc_html_e ( 'Slug' , 'woocommerce' ); ?> </label>
2013-08-06 15:56:15 +00:00
< input name = " attribute_name " id = " attribute_name " type = " text " value = " " maxlength = " 28 " />
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_e ( 'Unique slug/reference for the attribute; must be no more than 28 characters.' , 'woocommerce' ); ?> </p>
2013-08-06 15:56:15 +00:00
</ div >
< div class = " form-field " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_public " >< input name = " attribute_public " id = " attribute_public " type = " checkbox " value = " 1 " /> < ? php esc_html_e ( 'Enable Archives?' , 'woocommerce' ); ?> </label>
2014-12-19 17:58:49 +00:00
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_e ( 'Enable this if you want this attribute to have product archives in your store.' , 'woocommerce' ); ?> </p>
2014-12-19 17:58:49 +00:00
</ div >
< div class = " form-field " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_type " >< ? php esc_html_e ( 'Type' , 'woocommerce' ); ?> </label>
2013-08-06 15:56:15 +00:00
< select name = " attribute_type " id = " attribute_type " >
2015-04-27 15:31:34 +00:00
< ? php foreach ( wc_get_attribute_types () as $key => $value ) : ?>
< option value = " <?php echo esc_attr( $key ); ?> " >< ? php echo esc_attr ( $value ); ?> </option>
< ? php endforeach ; ?>
< ? php
/**
2015-11-03 12:28:01 +00:00
* Deprecated action in favor of product_attributes_type_selector filter .
2015-04-27 15:31:34 +00:00
*
* @ deprecated 2.4 . 0
*/
do_action ( 'woocommerce_admin_attribute_types' );
?>
2013-08-06 15:56:15 +00:00
</ select >
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php esc_html_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>
2013-08-06 15:56:15 +00:00
</ div >
< div class = " form-field " >
2017-11-06 10:58:57 +00:00
< label for = " attribute_orderby " >< ? php esc_html_e ( 'Default sort order' , 'woocommerce' ); ?> </label>
2013-08-06 15:56:15 +00:00
< select name = " attribute_orderby " id = " attribute_orderby " >
2017-11-06 10:58:57 +00:00
< option value = " menu_order " >< ? php esc_html_e ( 'Custom ordering' , 'woocommerce' ); ?> </option>
< option value = " name " >< ? php esc_html_e ( 'Name' , 'woocommerce' ); ?> </option>
< option value = " name_num " >< ? php esc_html_e ( 'Name (numeric)' , 'woocommerce' ); ?> </option>
< option value = " id " >< ? php esc_html_e ( 'Term ID' , 'woocommerce' ); ?> </option>
2013-08-06 15:56:15 +00:00
</ select >
2017-11-06 10:58:57 +00:00
< p class = " description " >< ? php _esc_html_e ( 'Determines the sort order of the terms on the frontend shop product pages. If using custom ordering, you can drag and drop the terms in this attribute.' , 'woocommerce' ); ?> </p>
2013-08-06 15:56:15 +00:00
</ div >
2016-08-01 09:27:15 +00:00
< ? php do_action ( 'woocommerce_after_add_attribute_fields' ) ?>
2017-11-06 10:45:14 +00:00
< p class = " submit " >< button type = " submit " name = " add_new_attribute " id = " submit " class = " button button-primary " value = " <?php esc_attr_e( 'Add attribute', 'woocommerce' ); ?> " >< ? php esc_html_e ( 'Add attribute' , 'woocommerce' ); ?> </button></p>
2013-08-06 15:56:15 +00:00
< ? php wp_nonce_field ( 'woocommerce-add-new_attribute' ); ?>
2014-11-27 16:49:19 +00:00
</ form >
</ div >
</ div >
</ div >
</ div >
< script type = " text/javascript " >
2013-08-06 15:56:15 +00:00
/* <![CDATA[ */
2014-11-27 16:49:19 +00:00
jQuery ( 'a.delete' ) . click ( function () {
2017-11-06 10:58:57 +00:00
if ( window . confirm ( '<?php esc_html_e( ' Are you sure you want to delete this attribute ? ', ' woocommerce ' ); ?>' ) ) {
2014-11-27 16:49:19 +00:00
return true ;
}
2013-08-06 15:56:15 +00:00
return false ;
2014-11-27 16:49:19 +00:00
});
2013-08-06 15:56:15 +00:00
/* ]]> */
</ script >
</ div >
< ? php
}
2014-09-20 19:52:30 +00:00
}