WC_Admin_Attributes

WC_Admin_Attributes Class.

Defined (1)

The class is defined in the following location(s).

/includes/admin/class-wc-admin-attributes.php  
  1. class WC_Admin_Attributes { 
  2.  
  3. /** 
  4. * Handles output of the attributes page in admin. 
  5. * Shows the created attributes and lets you add new ones or edit existing ones. 
  6. * The added attributes are stored in the database and can be used for layered navigation. 
  7. */ 
  8. public static function output() { 
  9. $result = ''; 
  10. $action = ''; 
  11.  
  12. // Action to perform: add, edit, delete or none 
  13. if ( ! empty( $_POST['add_new_attribute'] ) ) { 
  14. $action = 'add'; 
  15. } elseif ( ! empty( $_POST['save_attribute'] ) && ! empty( $_GET['edit'] ) ) { 
  16. $action = 'edit'; 
  17. } elseif ( ! empty( $_GET['delete'] ) ) { 
  18. $action = 'delete'; 
  19.  
  20. switch ( $action ) { 
  21. case 'add' : 
  22. $result = self::process_add_attribute(); 
  23. break; 
  24. case 'edit' : 
  25. $result = self::process_edit_attribute(); 
  26. break; 
  27. case 'delete' : 
  28. $result = self::process_delete_attribute(); 
  29. break; 
  30.  
  31. if ( is_wp_error( $result ) ) { 
  32. echo '<div id="woocommerce_errors" class="error"><p>' . $result->get_error_message() . '</p></div>'; 
  33.  
  34. // Show admin interface 
  35. if ( ! empty( $_GET['edit'] ) ) { 
  36. self::edit_attribute(); 
  37. } else { 
  38. self::add_attribute(); 
  39.  
  40. /** 
  41. * Get and sanitize posted attribute data. 
  42. * @return array 
  43. */ 
  44. private static function get_posted_attribute() { 
  45. $attribute = array( 
  46. 'attribute_label' => isset( $_POST['attribute_label'] ) ? wc_clean( stripslashes( $_POST['attribute_label'] ) ) : '',  
  47. 'attribute_name' => isset( $_POST['attribute_name'] ) ? wc_sanitize_taxonomy_name( stripslashes( $_POST['attribute_name'] ) ) : '',  
  48. 'attribute_type' => isset( $_POST['attribute_type'] ) ? wc_clean( $_POST['attribute_type'] ) : 'select',  
  49. 'attribute_orderby' => isset( $_POST['attribute_orderby'] ) ? wc_clean( $_POST['attribute_orderby'] ) : '',  
  50. 'attribute_public' => isset( $_POST['attribute_public'] ) ? 1 : 0 
  51. ); 
  52.  
  53. if ( empty( $attribute['attribute_type'] ) ) { 
  54. $attribute['attribute_type'] = 'select'; 
  55. if ( empty( $attribute['attribute_label'] ) ) { 
  56. $attribute['attribute_label'] = ucfirst( $attribute['attribute_name'] ); 
  57. if ( empty( $attribute['attribute_name'] ) ) { 
  58. $attribute['attribute_name'] = wc_sanitize_taxonomy_name( $attribute['attribute_label'] ); 
  59.  
  60. return $attribute; 
  61.  
  62. /** 
  63. * See if an attribute name is valid. 
  64. * @param string $attribute_name 
  65. * @return bool|WP_error result 
  66. */ 
  67. private static function valid_attribute_name( $attribute_name ) { 
  68. if ( strlen( $attribute_name ) >= 28 ) { 
  69. return new WP_Error( 'error', sprintf( __( 'Slug "%s" is too long (28 characters max). Shorten it, please.', 'woocommerce' ), sanitize_title( $attribute_name ) ) ); 
  70. } elseif ( wc_check_if_attribute_name_is_reserved( $attribute_name ) ) { 
  71. return new WP_Error( 'error', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term. Change it, please.', 'woocommerce' ), sanitize_title( $attribute_name ) ) ); 
  72.  
  73. return true; 
  74.  
  75. /** 
  76. * Add an attribute. 
  77. * @return bool|WP_Error 
  78. */ 
  79. private static function process_add_attribute() { 
  80. global $wpdb; 
  81. check_admin_referer( 'woocommerce-add-new_attribute' ); 
  82.  
  83. $attribute = self::get_posted_attribute(); 
  84.  
  85. if ( empty( $attribute['attribute_name'] ) || empty( $attribute['attribute_label'] ) ) { 
  86. return new WP_Error( 'error', __( 'Please, provide an attribute name and slug.', 'woocommerce' ) ); 
  87. } elseif ( ( $valid_attribute_name = self::valid_attribute_name( $attribute['attribute_name'] ) ) && is_wp_error( $valid_attribute_name ) ) { 
  88. return $valid_attribute_name; 
  89. } elseif ( taxonomy_exists( wc_attribute_taxonomy_name( $attribute['attribute_name'] ) ) ) { 
  90. return new WP_Error( 'error', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), sanitize_title( $attribute['attribute_name'] ) ) ); 
  91.  
  92. $wpdb->insert( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute ); 
  93.  
  94. do_action( 'woocommerce_attribute_added', $wpdb->insert_id, $attribute ); 
  95.  
  96. flush_rewrite_rules(); 
  97. delete_transient( 'wc_attribute_taxonomies' ); 
  98.  
  99. return true; 
  100.  
  101. /** 
  102. * Edit an attribute. 
  103. * @return bool|WP_Error 
  104. */ 
  105. private static function process_edit_attribute() { 
  106. global $wpdb; 
  107. $attribute_id = absint( $_GET['edit'] ); 
  108. check_admin_referer( 'woocommerce-save-attribute_' . $attribute_id ); 
  109.  
  110. $attribute = self::get_posted_attribute(); 
  111.  
  112. if ( empty( $attribute['attribute_name'] ) || empty( $attribute['attribute_label'] ) ) { 
  113. return new WP_Error( 'error', __( 'Please, provide an attribute name and slug.', 'woocommerce' ) ); 
  114. } elseif ( ( $valid_attribute_name = self::valid_attribute_name( $attribute['attribute_name'] ) ) && is_wp_error( $valid_attribute_name ) ) { 
  115. return $valid_attribute_name; 
  116.  
  117. $taxonomy_exists = taxonomy_exists( wc_attribute_taxonomy_name( $attribute['attribute_name'] ) ); 
  118. $old_attribute_name = $wpdb->get_var( "SELECT attribute_name FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = $attribute_id" ); 
  119. if ( $old_attribute_name != $attribute['attribute_name'] && wc_sanitize_taxonomy_name( $old_attribute_name ) != $attribute['attribute_name'] && $taxonomy_exists ) { 
  120. return new WP_Error( 'error', sprintf( __( 'Slug "%s" is already in use. Change it, please.', 'woocommerce' ), sanitize_title( $attribute['attribute_name'] ) ) ); 
  121.  
  122. $wpdb->update( $wpdb->prefix . 'woocommerce_attribute_taxonomies', $attribute, array( 'attribute_id' => $attribute_id ) ); 
  123.  
  124. do_action( 'woocommerce_attribute_updated', $attribute_id, $attribute, $old_attribute_name ); 
  125.  
  126. if ( $old_attribute_name != $attribute['attribute_name'] && ! empty( $old_attribute_name ) ) { 
  127. // Update taxonomies in the wp term taxonomy table 
  128. $wpdb->update( 
  129. $wpdb->term_taxonomy,  
  130. array( 'taxonomy' => wc_attribute_taxonomy_name( $attribute['attribute_name'] ) ),  
  131. array( 'taxonomy' => 'pa_' . $old_attribute_name ) 
  132. ); 
  133.  
  134. // Update taxonomy ordering term meta 
  135. if ( get_option( 'db_version' ) < 34370 ) { 
  136. $wpdb->update( 
  137. $wpdb->prefix . 'woocommerce_termmeta',  
  138. array( 'meta_key' => 'order_pa_' . sanitize_title( $attribute['attribute_name'] ) ),  
  139. array( 'meta_key' => 'order_pa_' . sanitize_title( $old_attribute_name ) ) 
  140. ); 
  141. } else { 
  142. $wpdb->update( 
  143. $wpdb->termmeta,  
  144. array( 'meta_key' => 'order_pa_' . sanitize_title( $attribute['attribute_name'] ) ),  
  145. array( 'meta_key' => 'order_pa_' . sanitize_title( $old_attribute_name ) ) 
  146. ); 
  147.  
  148. // Update product attributes which use this taxonomy 
  149. $old_attribute_name_length = strlen( $old_attribute_name ) + 3; 
  150. $attribute_name_length = strlen( $attribute['attribute_name'] ) + 3; 
  151.  
  152. $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_value = REPLACE( meta_value, %s, %s ) WHERE meta_key = '_product_attributes'",  
  153. 's:' . $old_attribute_name_length . ':"pa_' . $old_attribute_name . '"',  
  154. 's:' . $attribute_name_length . ':"pa_' . $attribute['attribute_name'] . '"' 
  155. ) ); 
  156.  
  157. // Update variations which use this taxonomy 
  158. $wpdb->update( 
  159. $wpdb->postmeta,  
  160. array( 'meta_key' => 'attribute_pa_' . sanitize_title( $attribute['attribute_name'] ) ),  
  161. array( 'meta_key' => 'attribute_pa_' . sanitize_title( $old_attribute_name ) ) 
  162. ); 
  163.  
  164. echo '<div class="updated"><p>' . __( 'Attribute updated successfully', 'woocommerce' ) . '</p></div>'; 
  165.  
  166. flush_rewrite_rules(); 
  167. delete_transient( 'wc_attribute_taxonomies' ); 
  168.  
  169. return true; 
  170.  
  171. /** 
  172. * Delete an attribute. 
  173. * @return bool 
  174. */ 
  175. private static function process_delete_attribute() { 
  176. global $wpdb; 
  177.  
  178. $attribute_id = absint( $_GET['delete'] ); 
  179.  
  180. check_admin_referer( 'woocommerce-delete-attribute_' . $attribute_id ); 
  181.  
  182. $attribute_name = $wpdb->get_var( "SELECT attribute_name FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = $attribute_id" ); 
  183. $taxonomy = wc_attribute_taxonomy_name( $attribute_name ); 
  184.  
  185. do_action( 'woocommerce_before_attribute_delete', $attribute_id, $attribute_name, $taxonomy ); 
  186.  
  187. if ( $attribute_name && $wpdb->query( "DELETE FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = $attribute_id" ) ) { 
  188. if ( taxonomy_exists( $taxonomy ) ) { 
  189. $terms = get_terms( $taxonomy, 'orderby=name&hide_empty=0' ); 
  190. foreach ( $terms as $term ) { 
  191. wp_delete_term( $term->term_id, $taxonomy ); 
  192.  
  193. do_action( 'woocommerce_attribute_deleted', $attribute_id, $attribute_name, $taxonomy ); 
  194. delete_transient( 'wc_attribute_taxonomies' ); 
  195. return true; 
  196.  
  197. return false; 
  198.  
  199. /** 
  200. * Edit Attribute admin panel. 
  201. * Shows the interface for changing an attributes type between select and text. 
  202. */ 
  203. public static function edit_attribute() { 
  204. global $wpdb; 
  205.  
  206. $edit = absint( $_GET['edit'] ); 
  207.  
  208. $attribute_to_edit = $wpdb->get_row( "SELECT * FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies WHERE attribute_id = '$edit'" ); 
  209.  
  210. ?> 
  211. <div class="wrap woocommerce"> 
  212. <div class="icon32 icon32-attributes" id="icon-woocommerce"><br/></div> 
  213. <h1><?php _e( 'Edit Attribute', 'woocommerce' ) ?></h1> 
  214.  
  215. <?php 
  216.  
  217. if ( ! $attribute_to_edit ) { 
  218. echo '<div id="woocommerce_errors" class="error"><p>' . __( 'Error: non-existing attribute ID.', 'woocommerce' ) . '</p></div>'; 
  219. } else { 
  220. $att_type = $attribute_to_edit->attribute_type; 
  221. $att_label = $attribute_to_edit->attribute_label; 
  222. $att_name = $attribute_to_edit->attribute_name; 
  223. $att_orderby = $attribute_to_edit->attribute_orderby; 
  224. $att_public = $attribute_to_edit->attribute_public; 
  225.  
  226. ?> 
  227.  
  228. <form action="edit.php?post_type=product&page=product_attributes&edit=<?php echo absint( $edit ); ?>" method="post"> 
  229. <table class="form-table"> 
  230. <tbody> 
  231. <tr class="form-field form-required"> 
  232. <th scope="row" valign="top"> 
  233. <label for="attribute_label"><?php _e( 'Name', 'woocommerce' ); ?></label> 
  234. </th> 
  235. <td> 
  236. <input name="attribute_label" id="attribute_label" type="text" value="<?php echo esc_attr( $att_label ); ?>" /> 
  237. <p class="description"><?php _e( 'Name for the attribute (shown on the front-end).', 'woocommerce' ); ?></p> 
  238. </td> 
  239. </tr> 
  240. <tr class="form-field form-required"> 
  241. <th scope="row" valign="top"> 
  242. <label for="attribute_name"><?php _e( 'Slug', 'woocommerce' ); ?></label> 
  243. </th> 
  244. <td> 
  245. <input name="attribute_name" id="attribute_name" type="text" value="<?php echo esc_attr( $att_name ); ?>" maxlength="28" /> 
  246. <p class="description"><?php _e( 'Unique slug/reference for the attribute; must be shorter than 28 characters.', 'woocommerce' ); ?></p> 
  247. </td> 
  248. </tr> 
  249. <tr class="form-field form-required"> 
  250. <th scope="row" valign="top"> 
  251. <label for="attribute_public"><?php _e( 'Enable Archives?', 'woocommerce' ); ?></label> 
  252. </th> 
  253. <td> 
  254. <input name="attribute_public" id="attribute_public" type="checkbox" value="1" <?php checked( $att_public, 1 ); ?> /> 
  255. <p class="description"><?php _e( 'Enable this if you want this attribute to have product archives in your store.', 'woocommerce' ); ?></p> 
  256. </td> 
  257. </tr> 
  258. <tr class="form-field form-required"> 
  259. <th scope="row" valign="top"> 
  260. <label for="attribute_type"><?php _e( 'Type', 'woocommerce' ); ?></label> 
  261. </th> 
  262. <td> 
  263. <select name="attribute_type" id="attribute_type"> 
  264. <?php foreach ( wc_get_attribute_types() as $key => $value ) : ?> 
  265. <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $att_type, $key ); ?>><?php echo esc_attr( $value ); ?></option> 
  266. <?php endforeach; ?> 
  267.  
  268. <?php 
  269.  
  270. /** 
  271. * Deprecated action in favor of product_attributes_type_selector filter. 
  272. * @deprecated 2.4.0 
  273. */ 
  274. do_action( 'woocommerce_admin_attribute_types' ); 
  275. ?> 
  276. </select> 
  277. <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> 
  278. </td> 
  279. </tr> 
  280. <tr class="form-field form-required"> 
  281. <th scope="row" valign="top"> 
  282. <label for="attribute_orderby"><?php _e( 'Default sort order', 'woocommerce' ); ?></label> 
  283. </th> 
  284. <td> 
  285. <select name="attribute_orderby" id="attribute_orderby"> 
  286. <option value="menu_order" <?php selected( $att_orderby, 'menu_order' ); ?>><?php _e( 'Custom ordering', 'woocommerce' ); ?></option> 
  287. <option value="name" <?php selected( $att_orderby, 'name' ); ?>><?php _e( 'Name', 'woocommerce' ); ?></option> 
  288. <option value="name_num" <?php selected( $att_orderby, 'name_num' ); ?>><?php _e( 'Name (numeric)', 'woocommerce' ); ?></option> 
  289. <option value="id" <?php selected( $att_orderby, 'id' ); ?>><?php _e( 'Term ID', 'woocommerce' ); ?></option> 
  290. </select> 
  291. <p class="description"><?php _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> 
  292. </td> 
  293. </tr> 
  294. </tbody> 
  295. </table> 
  296. <p class="submit"><input type="submit" name="save_attribute" id="submit" class="button-primary" value="<?php esc_attr_e( 'Update', 'woocommerce' ); ?>"></p> 
  297. <?php wp_nonce_field( 'woocommerce-save-attribute_' . $edit ); ?> 
  298. </form> 
  299. <?php } ?> 
  300. </div> 
  301. <?php 
  302.  
  303. /** 
  304. * Add Attribute admin panel. 
  305. * Shows the interface for adding new attributes. 
  306. */ 
  307. public static function add_attribute() { 
  308. ?> 
  309. <div class="wrap woocommerce"> 
  310. <div class="icon32 icon32-attributes" id="icon-woocommerce"><br/></div> 
  311. <h1><?php _e( 'Attributes', 'woocommerce' ); ?></h1> 
  312. <br class="clear" /> 
  313. <div id="col-container"> 
  314. <div id="col-right"> 
  315. <div class="col-wrap"> 
  316. <table class="widefat attributes-table wp-list-table ui-sortable" style="width:100%"> 
  317. <thead> 
  318. <tr> 
  319. <th scope="col"><?php _e( 'Name', 'woocommerce' ); ?></th> 
  320. <th scope="col"><?php _e( 'Slug', 'woocommerce' ); ?></th> 
  321. <th scope="col"><?php _e( 'Type', 'woocommerce' ); ?></th> 
  322. <th scope="col"><?php _e( 'Order by', 'woocommerce' ); ?></th> 
  323. <th scope="col" colspan="2"><?php _e( 'Terms', 'woocommerce' ); ?></th> 
  324. </tr> 
  325. </thead> 
  326. <tbody> 
  327. <?php 
  328. if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) : 
  329. foreach ( $attribute_taxonomies as $tax ) : 
  330. ?><tr> 
  331.  
  332. <td> 
  333. <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> 
  334.  
  335. <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 _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 _e( 'Delete', 'woocommerce' ); ?></a></span></div> 
  336. </td> 
  337. <td><?php echo esc_html( $tax->attribute_name ); ?></td> 
  338. <td><?php echo esc_html( ucfirst( $tax->attribute_type ) ); ?> <?php echo $tax->attribute_public ? '(' . __( 'Public', 'woocommerce' ) . ')' : ''; ?></td> 
  339. <td><?php 
  340. switch ( $tax->attribute_orderby ) { 
  341. case 'name' : 
  342. _e( 'Name', 'woocommerce' ); 
  343. break; 
  344. case 'name_num' : 
  345. _e( 'Name (numeric)', 'woocommerce' ); 
  346. break; 
  347. case 'id' : 
  348. _e( 'Term ID', 'woocommerce' ); 
  349. break; 
  350. default: 
  351. _e( 'Custom ordering', 'woocommerce' ); 
  352. break; 
  353. ?></td> 
  354. <td class="attribute-terms"><?php 
  355. $taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name ); 
  356.  
  357. if ( taxonomy_exists( $taxonomy ) ) { 
  358. $terms = get_terms( $taxonomy, 'hide_empty=0' ); 
  359.  
  360. switch ( $tax->attribute_orderby ) { 
  361. case 'name_num' : 
  362. usort( $terms, '_wc_get_product_terms_name_num_usort_callback' ); 
  363. break; 
  364. case 'parent' : 
  365. usort( $terms, '_wc_get_product_terms_parent_usort_callback' ); 
  366. break; 
  367.  
  368. $terms_string = implode( ', ', wp_list_pluck( $terms, 'name' ) ); 
  369. if ( $terms_string ) { 
  370. echo $terms_string; 
  371. } else { 
  372. echo '<span class="na">–</span>'; 
  373. } else { 
  374. echo '<span class="na">–</span>'; 
  375. ?></td> 
  376. <td class="attribute-actions"><a href="edit-tags.php?taxonomy=<?php echo esc_html( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&post_type=product" class="button alignright tips configure-terms" data-tip="<?php esc_attr_e( 'Configure terms', 'woocommerce' ); ?>"><?php _e( 'Configure terms', 'woocommerce' ); ?></a></td> 
  377. </tr><?php 
  378. endforeach; 
  379. else : 
  380. ?><tr><td colspan="6"><?php _e( 'No attributes currently exist.', 'woocommerce' ) ?></td></tr><?php 
  381. endif; 
  382. ?> 
  383. </tbody> 
  384. </table> 
  385. </div> 
  386. </div> 
  387. <div id="col-left"> 
  388. <div class="col-wrap"> 
  389. <div class="form-wrap"> 
  390. <h2><?php _e( 'Add New Attribute', 'woocommerce' ); ?></h2> 
  391. <p><?php _e( 'Attributes let you define extra product data, such as size or colour. 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> 
  392. <form action="edit.php?post_type=product&page=product_attributes" method="post"> 
  393. <div class="form-field"> 
  394. <label for="attribute_label"><?php _e( 'Name', 'woocommerce' ); ?></label> 
  395. <input name="attribute_label" id="attribute_label" type="text" value="" /> 
  396. <p class="description"><?php _e( 'Name for the attribute (shown on the front-end).', 'woocommerce' ); ?></p> 
  397. </div> 
  398.  
  399. <div class="form-field"> 
  400. <label for="attribute_name"><?php _e( 'Slug', 'woocommerce' ); ?></label> 
  401. <input name="attribute_name" id="attribute_name" type="text" value="" maxlength="28" /> 
  402. <p class="description"><?php _e( 'Unique slug/reference for the attribute; must be shorter than 28 characters.', 'woocommerce' ); ?></p> 
  403. </div> 
  404.  
  405. <div class="form-field"> 
  406. <label for="attribute_public"><input name="attribute_public" id="attribute_public" type="checkbox" value="1" /> <?php _e( 'Enable Archives?', 'woocommerce' ); ?></label> 
  407.  
  408. <p class="description"><?php _e( 'Enable this if you want this attribute to have product archives in your store.', 'woocommerce' ); ?></p> 
  409. </div> 
  410.  
  411. <div class="form-field"> 
  412. <label for="attribute_type"><?php _e( 'Type', 'woocommerce' ); ?></label> 
  413. <select name="attribute_type" id="attribute_type"> 
  414. <?php foreach ( wc_get_attribute_types() as $key => $value ) : ?> 
  415. <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_attr( $value ); ?></option> 
  416. <?php endforeach; ?> 
  417.  
  418. <?php 
  419.  
  420. /** 
  421. * Deprecated action in favor of product_attributes_type_selector filter. 
  422. * @deprecated 2.4.0 
  423. */ 
  424. do_action( 'woocommerce_admin_attribute_types' ); 
  425. ?> 
  426. </select> 
  427. <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> 
  428. </div> 
  429.  
  430. <div class="form-field"> 
  431. <label for="attribute_orderby"><?php _e( 'Default sort order', 'woocommerce' ); ?></label> 
  432. <select name="attribute_orderby" id="attribute_orderby"> 
  433. <option value="menu_order"><?php _e( 'Custom ordering', 'woocommerce' ); ?></option> 
  434. <option value="name"><?php _e( 'Name', 'woocommerce' ); ?></option> 
  435. <option value="name_num"><?php _e( 'Name (numeric)', 'woocommerce' ); ?></option> 
  436. <option value="id"><?php _e( 'Term ID', 'woocommerce' ); ?></option> 
  437. </select> 
  438. <p class="description"><?php _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> 
  439. </div> 
  440.  
  441. <p class="submit"><input type="submit" name="add_new_attribute" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Add Attribute', 'woocommerce' ); ?>"></p> 
  442. <?php wp_nonce_field( 'woocommerce-add-new_attribute' ); ?> 
  443. </form> 
  444. </div> 
  445. </div> 
  446. </div> 
  447. </div> 
  448. <script type="text/javascript"> 
  449. /* <![CDATA[ */ 
  450.  
  451. jQuery( 'a.delete' ).click( function() { 
  452. if ( window.confirm( '<?php _e( "Are you sure you want to delete this attribute?", "woocommerce" ); ?>' ) ) { 
  453. return true; 
  454. return false; 
  455. }); 
  456.  
  457. /* ]]> */ 
  458. </script> 
  459. </div> 
  460. <?php