Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../includes/admin
File: class-wc-admin-attributes.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Attributes Page
[2] Fix | Delete
*
[3] Fix | Delete
* The attributes section lets users add custom attributes to assign to products - they can also be used in the "Filter Products by Attribute" widget.
[4] Fix | Delete
*
[5] Fix | Delete
* @package WooCommerce\Admin
[6] Fix | Delete
* @version 2.3.0
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
defined( 'ABSPATH' ) || exit;
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* WC_Admin_Attributes Class.
[13] Fix | Delete
*/
[14] Fix | Delete
class WC_Admin_Attributes {
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Edited attribute ID.
[18] Fix | Delete
*
[19] Fix | Delete
* @var int
[20] Fix | Delete
*/
[21] Fix | Delete
private static $edited_attribute_id;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Handles output of the attributes page in admin.
[25] Fix | Delete
*
[26] Fix | Delete
* Shows the created attributes and lets you add new ones or edit existing ones.
[27] Fix | Delete
* The added attributes are stored in the database and can be used for layered navigation.
[28] Fix | Delete
*/
[29] Fix | Delete
public static function output() {
[30] Fix | Delete
$result = '';
[31] Fix | Delete
$action = '';
[32] Fix | Delete
[33] Fix | Delete
// Action to perform: add, edit, delete or none.
[34] Fix | Delete
if ( ! empty( $_POST['add_new_attribute'] ) ) { // WPCS: CSRF ok.
[35] Fix | Delete
$action = 'add';
[36] Fix | Delete
} elseif ( ! empty( $_POST['save_attribute'] ) && ! empty( $_GET['edit'] ) ) { // WPCS: CSRF ok.
[37] Fix | Delete
$action = 'edit';
[38] Fix | Delete
} elseif ( ! empty( $_GET['delete'] ) ) {
[39] Fix | Delete
$action = 'delete';
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
switch ( $action ) {
[43] Fix | Delete
case 'add':
[44] Fix | Delete
$result = self::process_add_attribute();
[45] Fix | Delete
break;
[46] Fix | Delete
case 'edit':
[47] Fix | Delete
$result = self::process_edit_attribute();
[48] Fix | Delete
break;
[49] Fix | Delete
case 'delete':
[50] Fix | Delete
$result = self::process_delete_attribute();
[51] Fix | Delete
break;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
if ( is_wp_error( $result ) ) {
[55] Fix | Delete
echo '<div id="woocommerce_errors" class="error"><p>' . wp_kses_post( $result->get_error_message() ) . '</p></div>';
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
// Show admin interface.
[59] Fix | Delete
if ( ! empty( $_GET['edit'] ) ) {
[60] Fix | Delete
self::edit_attribute();
[61] Fix | Delete
} else {
[62] Fix | Delete
self::add_attribute();
[63] Fix | Delete
}
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Get and sanitize posted attribute data.
[68] Fix | Delete
*
[69] Fix | Delete
* @return array
[70] Fix | Delete
*/
[71] Fix | Delete
private static function get_posted_attribute() {
[72] Fix | Delete
$attribute = array(
[73] Fix | Delete
'attribute_label' => isset( $_POST['attribute_label'] ) ? wc_clean( wp_unslash( $_POST['attribute_label'] ) ) : '', // WPCS: input var ok, CSRF ok.
[74] Fix | Delete
'attribute_name' => isset( $_POST['attribute_name'] ) ? wc_sanitize_taxonomy_name( wp_unslash( $_POST['attribute_name'] ) ) : '', // WPCS: input var ok, CSRF ok, sanitization ok.
[75] Fix | Delete
'attribute_type' => isset( $_POST['attribute_type'] ) ? wc_clean( wp_unslash( $_POST['attribute_type'] ) ) : 'select', // WPCS: input var ok, CSRF ok.
[76] Fix | Delete
'attribute_orderby' => isset( $_POST['attribute_orderby'] ) ? wc_clean( wp_unslash( $_POST['attribute_orderby'] ) ) : '', // WPCS: input var ok, CSRF ok.
[77] Fix | Delete
'attribute_public' => isset( $_POST['attribute_public'] ) ? 1 : 0, // WPCS: input var ok, CSRF ok.
[78] Fix | Delete
);
[79] Fix | Delete
[80] Fix | Delete
if ( empty( $attribute['attribute_type'] ) ) {
[81] Fix | Delete
$attribute['attribute_type'] = 'select';
[82] Fix | Delete
}
[83] Fix | Delete
if ( empty( $attribute['attribute_label'] ) ) {
[84] Fix | Delete
$attribute['attribute_label'] = ucfirst( $attribute['attribute_name'] );
[85] Fix | Delete
}
[86] Fix | Delete
if ( empty( $attribute['attribute_name'] ) ) {
[87] Fix | Delete
$attribute['attribute_name'] = wc_sanitize_taxonomy_name( $attribute['attribute_label'] );
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
return $attribute;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Add an attribute.
[95] Fix | Delete
*
[96] Fix | Delete
* @return bool|WP_Error
[97] Fix | Delete
*/
[98] Fix | Delete
private static function process_add_attribute() {
[99] Fix | Delete
check_admin_referer( 'woocommerce-add-new_attribute' );
[100] Fix | Delete
[101] Fix | Delete
$attribute = self::get_posted_attribute();
[102] Fix | Delete
$args = array(
[103] Fix | Delete
'name' => $attribute['attribute_label'],
[104] Fix | Delete
'slug' => $attribute['attribute_name'],
[105] Fix | Delete
'type' => $attribute['attribute_type'],
[106] Fix | Delete
'order_by' => $attribute['attribute_orderby'],
[107] Fix | Delete
'has_archives' => $attribute['attribute_public'],
[108] Fix | Delete
);
[109] Fix | Delete
[110] Fix | Delete
$id = wc_create_attribute( $args );
[111] Fix | Delete
[112] Fix | Delete
if ( is_wp_error( $id ) ) {
[113] Fix | Delete
return $id;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
return true;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Edit an attribute.
[121] Fix | Delete
*
[122] Fix | Delete
* @return bool|WP_Error
[123] Fix | Delete
*/
[124] Fix | Delete
private static function process_edit_attribute() {
[125] Fix | Delete
$attribute_id = isset( $_GET['edit'] ) ? absint( $_GET['edit'] ) : 0;
[126] Fix | Delete
check_admin_referer( 'woocommerce-save-attribute_' . $attribute_id );
[127] Fix | Delete
[128] Fix | Delete
$attribute = self::get_posted_attribute();
[129] Fix | Delete
$args = array(
[130] Fix | Delete
'name' => $attribute['attribute_label'],
[131] Fix | Delete
'slug' => $attribute['attribute_name'],
[132] Fix | Delete
'type' => $attribute['attribute_type'],
[133] Fix | Delete
'order_by' => $attribute['attribute_orderby'],
[134] Fix | Delete
'has_archives' => $attribute['attribute_public'],
[135] Fix | Delete
);
[136] Fix | Delete
[137] Fix | Delete
$id = wc_update_attribute( $attribute_id, $args );
[138] Fix | Delete
[139] Fix | Delete
if ( is_wp_error( $id ) ) {
[140] Fix | Delete
return $id;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
self::$edited_attribute_id = $id;
[144] Fix | Delete
[145] Fix | Delete
return true;
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Delete an attribute.
[150] Fix | Delete
*
[151] Fix | Delete
* @return bool
[152] Fix | Delete
*/
[153] Fix | Delete
private static function process_delete_attribute() {
[154] Fix | Delete
$attribute_id = isset( $_GET['delete'] ) ? absint( $_GET['delete'] ) : 0;
[155] Fix | Delete
check_admin_referer( 'woocommerce-delete-attribute_' . $attribute_id );
[156] Fix | Delete
[157] Fix | Delete
return wc_delete_attribute( $attribute_id );
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
/**
[161] Fix | Delete
* Edit Attribute admin panel.
[162] Fix | Delete
*
[163] Fix | Delete
* Shows the interface for changing an attributes type between select and text.
[164] Fix | Delete
*/
[165] Fix | Delete
public static function edit_attribute() {
[166] Fix | Delete
global $wpdb;
[167] Fix | Delete
[168] Fix | Delete
$edit = isset( $_GET['edit'] ) ? absint( $_GET['edit'] ) : 0;
[169] Fix | Delete
[170] Fix | Delete
$attribute_to_edit = $wpdb->get_row(
[171] Fix | Delete
$wpdb->prepare(
[172] Fix | Delete
"
[173] Fix | Delete
SELECT attribute_type, attribute_label, attribute_name, attribute_orderby, attribute_public
[174] Fix | Delete
FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = %d
[175] Fix | Delete
",
[176] Fix | Delete
$edit
[177] Fix | Delete
)
[178] Fix | Delete
);
[179] Fix | Delete
[180] Fix | Delete
?>
[181] Fix | Delete
<div class="wrap woocommerce">
[182] Fix | Delete
<h1><?php esc_html_e( 'Edit attribute', 'woocommerce' ); ?></h1>
[183] Fix | Delete
[184] Fix | Delete
<?php
[185] Fix | Delete
if ( ! $attribute_to_edit ) {
[186] Fix | Delete
echo '<div id="woocommerce_errors" class="error"><p>' . esc_html__( 'Error: non-existing attribute ID.', 'woocommerce' ) . '</p></div>';
[187] Fix | Delete
} else {
[188] Fix | Delete
if ( self::$edited_attribute_id > 0 ) {
[189] Fix | Delete
echo '<div id="message" class="updated"><p>' . esc_html__( 'Attribute updated successfully', 'woocommerce' ) . '</p><p><a href="' . esc_url( admin_url( 'edit.php?post_type=product&amp;page=product_attributes' ) ) . '">' . esc_html__( 'Back to Attributes', 'woocommerce' ) . '</a></p></div>';
[190] Fix | Delete
self::$edited_attribute_id = null;
[191] Fix | Delete
}
[192] Fix | Delete
$att_type = $attribute_to_edit->attribute_type;
[193] Fix | Delete
$att_label = format_to_edit( $attribute_to_edit->attribute_label );
[194] Fix | Delete
$att_name = $attribute_to_edit->attribute_name;
[195] Fix | Delete
$att_orderby = $attribute_to_edit->attribute_orderby;
[196] Fix | Delete
$att_public = $attribute_to_edit->attribute_public;
[197] Fix | Delete
?>
[198] Fix | Delete
<form action="edit.php?post_type=product&amp;page=product_attributes&amp;edit=<?php echo absint( $edit ); ?>" method="post">
[199] Fix | Delete
<table class="form-table">
[200] Fix | Delete
<tbody>
[201] Fix | Delete
<?php do_action( 'woocommerce_before_edit_attribute_fields' ); ?>
[202] Fix | Delete
<tr class="form-field form-required">
[203] Fix | Delete
<th scope="row" valign="top">
[204] Fix | Delete
<label for="attribute_label"><?php esc_html_e( 'Name', 'woocommerce' ); ?></label>
[205] Fix | Delete
</th>
[206] Fix | Delete
<td>
[207] Fix | Delete
<input name="attribute_label" id="attribute_label" type="text" value="<?php echo esc_attr( $att_label ); ?>" />
[208] Fix | Delete
<p class="description"><?php esc_html_e( 'Name for the attribute (shown on the front-end).', 'woocommerce' ); ?></p>
[209] Fix | Delete
</td>
[210] Fix | Delete
</tr>
[211] Fix | Delete
<tr class="form-field form-required">
[212] Fix | Delete
<th scope="row" valign="top">
[213] Fix | Delete
<label for="attribute_name"><?php esc_html_e( 'Slug', 'woocommerce' ); ?></label>
[214] Fix | Delete
</th>
[215] Fix | Delete
<td>
[216] Fix | Delete
<input name="attribute_name" id="attribute_name" type="text" value="<?php echo esc_attr( $att_name ); ?>" maxlength="28" />
[217] Fix | Delete
<p class="description"><?php esc_html_e( 'Unique slug/reference for the attribute; must be no more than 28 characters.', 'woocommerce' ); ?></p>
[218] Fix | Delete
</td>
[219] Fix | Delete
</tr>
[220] Fix | Delete
<tr class="form-field form-required">
[221] Fix | Delete
<th scope="row" valign="top">
[222] Fix | Delete
<label for="attribute_public"><?php esc_html_e( 'Enable archives?', 'woocommerce' ); ?></label>
[223] Fix | Delete
</th>
[224] Fix | Delete
<td>
[225] Fix | Delete
<input name="attribute_public" id="attribute_public" type="checkbox" value="1" <?php checked( $att_public, 1 ); ?> />
[226] Fix | Delete
<p class="description"><?php esc_html_e( 'Enable this if you want this attribute to have product archives in your store.', 'woocommerce' ); ?></p>
[227] Fix | Delete
</td>
[228] Fix | Delete
</tr>
[229] Fix | Delete
<?php
[230] Fix | Delete
/**
[231] Fix | Delete
* Attribute types can change the way attributes are displayed on the frontend and admin.
[232] Fix | Delete
*
[233] Fix | Delete
* By Default WooCommerce only includes the `select` type. Others can be added with the
[234] Fix | Delete
* `product_attributes_type_selector` filter. If there is only the default type registered,
[235] Fix | Delete
* this setting will be hidden.
[236] Fix | Delete
*/
[237] Fix | Delete
if ( wc_has_custom_attribute_types() ) {
[238] Fix | Delete
?>
[239] Fix | Delete
<tr class="form-field form-required">
[240] Fix | Delete
<th scope="row" valign="top">
[241] Fix | Delete
<label for="attribute_type"><?php esc_html_e( 'Type', 'woocommerce' ); ?></label>
[242] Fix | Delete
</th>
[243] Fix | Delete
<td>
[244] Fix | Delete
<select name="attribute_type" id="attribute_type">
[245] Fix | Delete
<?php foreach ( wc_get_attribute_types() as $key => $value ) : ?>
[246] Fix | Delete
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $att_type, $key ); ?>><?php echo esc_html( $value ); ?></option>
[247] Fix | Delete
<?php endforeach; ?>
[248] Fix | Delete
<?php
[249] Fix | Delete
/**
[250] Fix | Delete
* Deprecated action in favor of product_attributes_type_selector filter.
[251] Fix | Delete
*
[252] Fix | Delete
* @todo Remove in 4.0.0
[253] Fix | Delete
* @deprecated 2.4.0
[254] Fix | Delete
*/
[255] Fix | Delete
do_action( 'woocommerce_admin_attribute_types' );
[256] Fix | Delete
?>
[257] Fix | Delete
</select>
[258] Fix | Delete
<p class="description"><?php esc_html_e( "Determines how this attribute's values are displayed.", 'woocommerce' ); ?></p>
[259] Fix | Delete
</td>
[260] Fix | Delete
</tr>
[261] Fix | Delete
<?php
[262] Fix | Delete
}
[263] Fix | Delete
?>
[264] Fix | Delete
<tr class="form-field form-required">
[265] Fix | Delete
<th scope="row" valign="top">
[266] Fix | Delete
<label for="attribute_orderby"><?php esc_html_e( 'Default sort order', 'woocommerce' ); ?></label>
[267] Fix | Delete
</th>
[268] Fix | Delete
<td>
[269] Fix | Delete
<select name="attribute_orderby" id="attribute_orderby">
[270] Fix | Delete
<option value="menu_order" <?php selected( $att_orderby, 'menu_order' ); ?>><?php esc_html_e( 'Custom ordering', 'woocommerce' ); ?></option>
[271] Fix | Delete
<option value="name" <?php selected( $att_orderby, 'name' ); ?>><?php esc_html_e( 'Name', 'woocommerce' ); ?></option>
[272] Fix | Delete
<option value="name_num" <?php selected( $att_orderby, 'name_num' ); ?>><?php esc_html_e( 'Name (numeric)', 'woocommerce' ); ?></option>
[273] Fix | Delete
<option value="id" <?php selected( $att_orderby, 'id' ); ?>><?php esc_html_e( 'Term ID', 'woocommerce' ); ?></option>
[274] Fix | Delete
</select>
[275] Fix | Delete
<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>
[276] Fix | Delete
</td>
[277] Fix | Delete
</tr>
[278] Fix | Delete
<?php do_action( 'woocommerce_after_edit_attribute_fields' ); ?>
[279] Fix | Delete
</tbody>
[280] Fix | Delete
</table>
[281] Fix | Delete
<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>
[282] Fix | Delete
<?php wp_nonce_field( 'woocommerce-save-attribute_' . $edit ); ?>
[283] Fix | Delete
</form>
[284] Fix | Delete
<?php } ?>
[285] Fix | Delete
</div>
[286] Fix | Delete
<?php
[287] Fix | Delete
}
[288] Fix | Delete
[289] Fix | Delete
/**
[290] Fix | Delete
* Add Attribute admin panel.
[291] Fix | Delete
*
[292] Fix | Delete
* Shows the interface for adding new attributes.
[293] Fix | Delete
*/
[294] Fix | Delete
public static function add_attribute() {
[295] Fix | Delete
?>
[296] Fix | Delete
<div class="wrap woocommerce">
[297] Fix | Delete
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
[298] Fix | Delete
[299] Fix | Delete
<br class="clear" />
[300] Fix | Delete
<div id="col-container">
[301] Fix | Delete
<div id="col-right">
[302] Fix | Delete
<div class="col-wrap">
[303] Fix | Delete
<table class="widefat attributes-table wp-list-table ui-sortable" style="width:100%">
[304] Fix | Delete
<thead>
[305] Fix | Delete
<tr>
[306] Fix | Delete
<th scope="col"><?php esc_html_e( 'Name', 'woocommerce' ); ?></th>
[307] Fix | Delete
<th scope="col"><?php esc_html_e( 'Slug', 'woocommerce' ); ?></th>
[308] Fix | Delete
<?php if ( wc_has_custom_attribute_types() ) : ?>
[309] Fix | Delete
<th scope="col"><?php esc_html_e( 'Type', 'woocommerce' ); ?></th>
[310] Fix | Delete
<?php endif; ?>
[311] Fix | Delete
<th scope="col"><?php esc_html_e( 'Order by', 'woocommerce' ); ?></th>
[312] Fix | Delete
<th scope="col"><?php esc_html_e( 'Terms', 'woocommerce' ); ?></th>
[313] Fix | Delete
</tr>
[314] Fix | Delete
</thead>
[315] Fix | Delete
<tbody>
[316] Fix | Delete
<?php
[317] Fix | Delete
$attribute_taxonomies = wc_get_attribute_taxonomies();
[318] Fix | Delete
if ( $attribute_taxonomies ) {
[319] Fix | Delete
/**
[320] Fix | Delete
* Filters the maximum number of terms that will be displayed for each taxonomy in the Attributes page.
[321] Fix | Delete
*
[322] Fix | Delete
* @param int @default_max_terms_to_display Default value.
[323] Fix | Delete
* @returns int Actual value to use, may be zero.
[324] Fix | Delete
*
[325] Fix | Delete
* @since 6.9.0
[326] Fix | Delete
*/
[327] Fix | Delete
$max_terms_to_display = apply_filters( 'woocommerce_max_terms_displayed_in_attributes_page', 100 );
[328] Fix | Delete
foreach ( $attribute_taxonomies as $tax ) :
[329] Fix | Delete
?>
[330] Fix | Delete
<tr>
[331] Fix | Delete
<td>
[332] Fix | Delete
<strong><a href="edit-tags.php?taxonomy=<?php echo esc_attr( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&amp;post_type=product"><?php echo esc_html( $tax->attribute_label ); ?></a></strong>
[333] Fix | Delete
[334] Fix | Delete
<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&amp;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&amp;page=product_attributes' ), 'woocommerce-delete-attribute_' . $tax->attribute_id ) ); ?>"><?php esc_html_e( 'Delete', 'woocommerce' ); ?></a></span></div>
[335] Fix | Delete
</td>
[336] Fix | Delete
<td><?php echo esc_html( $tax->attribute_name ); ?></td>
[337] Fix | Delete
<?php if ( wc_has_custom_attribute_types() ) : ?>
[338] Fix | Delete
<td><?php echo esc_html( wc_get_attribute_type_label( $tax->attribute_type ) ); ?> <?php echo $tax->attribute_public ? esc_html__( '(Public)', 'woocommerce' ) : ''; ?></td>
[339] Fix | Delete
<?php endif; ?>
[340] Fix | Delete
<td>
[341] Fix | Delete
<?php
[342] Fix | Delete
switch ( $tax->attribute_orderby ) {
[343] Fix | Delete
case 'name':
[344] Fix | Delete
esc_html_e( 'Name', 'woocommerce' );
[345] Fix | Delete
break;
[346] Fix | Delete
case 'name_num':
[347] Fix | Delete
esc_html_e( 'Name (numeric)', 'woocommerce' );
[348] Fix | Delete
break;
[349] Fix | Delete
case 'id':
[350] Fix | Delete
esc_html_e( 'Term ID', 'woocommerce' );
[351] Fix | Delete
break;
[352] Fix | Delete
default:
[353] Fix | Delete
esc_html_e( 'Custom ordering', 'woocommerce' );
[354] Fix | Delete
break;
[355] Fix | Delete
}
[356] Fix | Delete
?>
[357] Fix | Delete
</td>
[358] Fix | Delete
<td class="attribute-terms">
[359] Fix | Delete
<?php
[360] Fix | Delete
$taxonomy = wc_attribute_taxonomy_name( $tax->attribute_name );
[361] Fix | Delete
[362] Fix | Delete
if ( taxonomy_exists( $taxonomy ) ) {
[363] Fix | Delete
$total_count = (int) get_terms(
[364] Fix | Delete
array(
[365] Fix | Delete
'taxonomy' => $taxonomy,
[366] Fix | Delete
'fields' => 'count',
[367] Fix | Delete
'hide_empty' => false,
[368] Fix | Delete
)
[369] Fix | Delete
);
[370] Fix | Delete
if ( 0 === $total_count ) {
[371] Fix | Delete
echo '<span class="na">&ndash;</span>';
[372] Fix | Delete
} elseif ( $max_terms_to_display > 0 ) {
[373] Fix | Delete
$terms = get_terms(
[374] Fix | Delete
array(
[375] Fix | Delete
'taxonomy' => $taxonomy,
[376] Fix | Delete
'number' => $max_terms_to_display,
[377] Fix | Delete
'fields' => 'names',
[378] Fix | Delete
'hide_empty' => false,
[379] Fix | Delete
)
[380] Fix | Delete
);
[381] Fix | Delete
$terms_string = implode( ', ', $terms );
[382] Fix | Delete
if ( $total_count > $max_terms_to_display ) {
[383] Fix | Delete
$remaining = $total_count - $max_terms_to_display;
[384] Fix | Delete
/* translators: 1: Comma-separated terms list, 2: how many terms are hidden */
[385] Fix | Delete
$terms_string = sprintf( __( '%1$s... (%2$s more)', 'woocommerce' ), $terms_string, $remaining );
[386] Fix | Delete
}
[387] Fix | Delete
echo esc_html( $terms_string );
[388] Fix | Delete
} elseif ( 1 === $total_count ) {
[389] Fix | Delete
echo esc_html( __( '1 term', 'woocommerce' ) );
[390] Fix | Delete
} else {
[391] Fix | Delete
/* translators: %s: Total count of terms available for the attribute */
[392] Fix | Delete
echo esc_html( sprintf( __( '%s terms', 'woocommerce' ), $total_count ) );
[393] Fix | Delete
}
[394] Fix | Delete
} else {
[395] Fix | Delete
echo '<span class="na">&ndash;</span><br />';
[396] Fix | Delete
}
[397] Fix | Delete
?>
[398] Fix | Delete
<br /><a href="edit-tags.php?taxonomy=<?php echo esc_attr( wc_attribute_taxonomy_name( $tax->attribute_name ) ); ?>&amp;post_type=product" class="configure-terms"><?php esc_html_e( 'Configure terms', 'woocommerce' ); ?></a>
[399] Fix | Delete
</td>
[400] Fix | Delete
</tr>
[401] Fix | Delete
<?php
[402] Fix | Delete
endforeach;
[403] Fix | Delete
} else {
[404] Fix | Delete
?>
[405] Fix | Delete
<tr>
[406] Fix | Delete
<td colspan="6"><?php esc_html_e( 'No attributes currently exist.', 'woocommerce' ); ?></td>
[407] Fix | Delete
</tr>
[408] Fix | Delete
<?php
[409] Fix | Delete
}
[410] Fix | Delete
?>
[411] Fix | Delete
</tbody>
[412] Fix | Delete
</table>
[413] Fix | Delete
</div>
[414] Fix | Delete
</div>
[415] Fix | Delete
<div id="col-left">
[416] Fix | Delete
<div class="col-wrap">
[417] Fix | Delete
<div class="form-wrap">
[418] Fix | Delete
<h2><?php esc_html_e( 'Add new attribute', 'woocommerce' ); ?></h2>
[419] Fix | Delete
<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.', 'woocommerce' ); ?></p>
[420] Fix | Delete
<form action="edit.php?post_type=product&amp;page=product_attributes" method="post">
[421] Fix | Delete
<?php do_action( 'woocommerce_before_add_attribute_fields' ); ?>
[422] Fix | Delete
[423] Fix | Delete
<div class="form-field">
[424] Fix | Delete
<label for="attribute_label"><?php esc_html_e( 'Name', 'woocommerce' ); ?></label>
[425] Fix | Delete
<input name="attribute_label" id="attribute_label" type="text" value="" />
[426] Fix | Delete
<p class="description"><?php esc_html_e( 'Name for the attribute (shown on the front-end).', 'woocommerce' ); ?></p>
[427] Fix | Delete
</div>
[428] Fix | Delete
[429] Fix | Delete
<div class="form-field">
[430] Fix | Delete
<label for="attribute_name"><?php esc_html_e( 'Slug', 'woocommerce' ); ?></label>
[431] Fix | Delete
<input name="attribute_name" id="attribute_name" type="text" value="" maxlength="28" />
[432] Fix | Delete
<p class="description"><?php esc_html_e( 'Unique slug/reference for the attribute; must be no more than 28 characters.', 'woocommerce' ); ?></p>
[433] Fix | Delete
</div>
[434] Fix | Delete
[435] Fix | Delete
<div class="form-field">
[436] Fix | Delete
<label for="attribute_public"><input name="attribute_public" id="attribute_public" type="checkbox" value="1" /> <?php esc_html_e( 'Enable Archives?', 'woocommerce' ); ?></label>
[437] Fix | Delete
[438] Fix | Delete
<p class="description"><?php esc_html_e( 'Enable this if you want this attribute to have product archives in your store.', 'woocommerce' ); ?></p>
[439] Fix | Delete
</div>
[440] Fix | Delete
[441] Fix | Delete
<?php
[442] Fix | Delete
/**
[443] Fix | Delete
* Attribute types can change the way attributes are displayed on the frontend and admin.
[444] Fix | Delete
*
[445] Fix | Delete
* By Default WooCommerce only includes the `select` type. Others can be added with the
[446] Fix | Delete
* `product_attributes_type_selector` filter. If there is only the default type registered,
[447] Fix | Delete
* this setting will be hidden.
[448] Fix | Delete
*/
[449] Fix | Delete
if ( wc_has_custom_attribute_types() ) {
[450] Fix | Delete
?>
[451] Fix | Delete
<div class="form-field">
[452] Fix | Delete
<label for="attribute_type"><?php esc_html_e( 'Type', 'woocommerce' ); ?></label>
[453] Fix | Delete
<select name="attribute_type" id="attribute_type">
[454] Fix | Delete
<?php foreach ( wc_get_attribute_types() as $key => $value ) : ?>
[455] Fix | Delete
<option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value ); ?></option>
[456] Fix | Delete
<?php endforeach; ?>
[457] Fix | Delete
<?php
[458] Fix | Delete
/**
[459] Fix | Delete
* Deprecated action in favor of product_attributes_type_selector filter.
[460] Fix | Delete
*
[461] Fix | Delete
* @todo Remove in 4.0.0
[462] Fix | Delete
* @deprecated 2.4.0
[463] Fix | Delete
*/
[464] Fix | Delete
do_action( 'woocommerce_admin_attribute_types' );
[465] Fix | Delete
?>
[466] Fix | Delete
</select>
[467] Fix | Delete
<p class="description"><?php esc_html_e( "Determines how this attribute's values are displayed.", 'woocommerce' ); ?></p>
[468] Fix | Delete
</div>
[469] Fix | Delete
<?php
[470] Fix | Delete
}
[471] Fix | Delete
?>
[472] Fix | Delete
[473] Fix | Delete
<div class="form-field">
[474] Fix | Delete
<label for="attribute_orderby"><?php esc_html_e( 'Default sort order', 'woocommerce' ); ?></label>
[475] Fix | Delete
<select name="attribute_orderby" id="attribute_orderby">
[476] Fix | Delete
<option value="menu_order"><?php esc_html_e( 'Custom ordering', 'woocommerce' ); ?></option>
[477] Fix | Delete
<option value="name"><?php esc_html_e( 'Name', 'woocommerce' ); ?></option>
[478] Fix | Delete
<option value="name_num"><?php esc_html_e( 'Name (numeric)', 'woocommerce' ); ?></option>
[479] Fix | Delete
<option value="id"><?php esc_html_e( 'Term ID', 'woocommerce' ); ?></option>
[480] Fix | Delete
</select>
[481] Fix | Delete
<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>
[482] Fix | Delete
</div>
[483] Fix | Delete
[484] Fix | Delete
<?php do_action( 'woocommerce_after_add_attribute_fields' ); ?>
[485] Fix | Delete
[486] Fix | Delete
<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>
[487] Fix | Delete
<?php wp_nonce_field( 'woocommerce-add-new_attribute' ); ?>
[488] Fix | Delete
</form>
[489] Fix | Delete
</div>
[490] Fix | Delete
</div>
[491] Fix | Delete
</div>
[492] Fix | Delete
</div>
[493] Fix | Delete
<script type="text/javascript">
[494] Fix | Delete
/* <![CDATA[ */
[495] Fix | Delete
[496] Fix | Delete
jQuery( 'a.delete' ).on( 'click', function() {
[497] Fix | Delete
if ( window.confirm( '<?php esc_html_e( 'Are you sure you want to delete this attribute?', 'woocommerce' ); ?>' ) ) {
[498] Fix | Delete
return true;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function