Support desc_tip in settings api Closes #2251.

This commit is contained in:
Mike Jolley 2013-01-18 12:10:19 +00:00
parent ec0408286b
commit 2a462edc33
12 changed files with 232 additions and 44 deletions

View File

@ -206,6 +206,8 @@ abstract class WC_Settings_API {
* @return string * @return string
*/ */
public function generate_text_html( $key, $data ) { public function generate_text_html( $key, $data ) {
global $woocommerce;
$html = ''; $html = '';
$data['title'] = isset( $data['title'] ) ? $data['title'] : ''; $data['title'] = isset( $data['title'] ) ? $data['title'] : '';
@ -214,6 +216,22 @@ abstract class WC_Settings_API {
$data['css'] = isset( $data['css'] ) ? $data['css'] : ''; $data['css'] = isset( $data['css'] ) ? $data['css'] : '';
$data['placeholder'] = isset( $data['placeholder'] ) ? $data['placeholder'] : ''; $data['placeholder'] = isset( $data['placeholder'] ) ? $data['placeholder'] : '';
$data['type'] = isset( $data['type'] ) ? $data['type'] : 'text'; $data['type'] = isset( $data['type'] ) ? $data['type'] : 'text';
$data['desc_tip'] = isset( $data['desc_tip'] ) ? $data['desc_tip'] : false;
$data['description'] = isset( $data['description'] ) ? $data['description'] : '';
// Description handling
if ( $data['desc_tip'] === true ) {
$description = '';
$tip = $data['description'];
} elseif ( ! empty( $data['desc_tip'] ) ) {
$description = $data['description'];
$tip = $data['desc_tip'];
} elseif ( ! empty( $data['description'] ) ) {
$description = $data['description'];
$tip = '';
} else {
$description = $tip = '';
}
// Custom attribute handling // Custom attribute handling
$custom_attributes = array(); $custom_attributes = array();
@ -225,11 +243,18 @@ abstract class WC_Settings_API {
$html .= '<tr valign="top">' . "\n"; $html .= '<tr valign="top">' . "\n";
$html .= '<th scope="row" class="titledesc">'; $html .= '<th scope="row" class="titledesc">';
$html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>'; $html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>';
if ( $tip )
$html .= '<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
$html .= '</th>' . "\n"; $html .= '</th>' . "\n";
$html .= '<td class="forminp">' . "\n"; $html .= '<td class="forminp">' . "\n";
$html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n"; $html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n";
$html .= '<input class="input-text regular-input ' . esc_attr( $data['class'] ) . '" type="' . esc_attr( $data['type'] ) . '" name="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" id="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" style="' . esc_attr( $data['css'] ) . '" value="' . esc_attr( $this->get_option( $key ) ) . '" placeholder="' . esc_attr( $data['placeholder'] ) . '" ' . disabled( $data['disabled'], true, false ) . ' ' . implode( ' ', $custom_attributes ) . ' />'; $html .= '<input class="input-text regular-input ' . esc_attr( $data['class'] ) . '" type="' . esc_attr( $data['type'] ) . '" name="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" id="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" style="' . esc_attr( $data['css'] ) . '" value="' . esc_attr( $this->get_option( $key ) ) . '" placeholder="' . esc_attr( $data['placeholder'] ) . '" ' . disabled( $data['disabled'], true, false ) . ' ' . implode( ' ', $custom_attributes ) . ' />';
if ( isset( $data['description'] ) && $data['description'] != '' ) { $html .= ' <p class="description">' . wp_kses_post( $data['description'] ) . '</p>' . "\n"; }
if ( $description )
$html .= ' <p class="description">' . wp_kses_post( $description ) . '</p>' . "\n";
$html .= '</fieldset>'; $html .= '</fieldset>';
$html .= '</td>' . "\n"; $html .= '</td>' . "\n";
$html .= '</tr>' . "\n"; $html .= '</tr>' . "\n";
@ -247,12 +272,30 @@ abstract class WC_Settings_API {
* @return string * @return string
*/ */
public function generate_password_html( $key, $data ) { public function generate_password_html( $key, $data ) {
global $woocommerce;
$html = ''; $html = '';
$data['title'] = isset( $data['title'] ) ? $data['title'] : ''; $data['title'] = isset( $data['title'] ) ? $data['title'] : '';
$data['disabled'] = empty( $data['disabled'] ) ? false : true; $data['disabled'] = empty( $data['disabled'] ) ? false : true;
$data['class'] = isset( $data['class'] ) ? $data['class'] : ''; $data['class'] = isset( $data['class'] ) ? $data['class'] : '';
$data['css'] = isset( $data['css'] ) ? $data['css'] : ''; $data['css'] = isset( $data['css'] ) ? $data['css'] : '';
$data['desc_tip'] = isset( $data['desc_tip'] ) ? $data['desc_tip'] : false;
$data['description'] = isset( $data['description'] ) ? $data['description'] : '';
// Description handling
if ( $data['desc_tip'] === true ) {
$description = '';
$tip = $data['description'];
} elseif ( ! empty( $data['desc_tip'] ) ) {
$description = $data['description'];
$tip = $data['desc_tip'];
} elseif ( ! empty( $data['description'] ) ) {
$description = $data['description'];
$tip = '';
} else {
$description = $tip = '';
}
// Custom attribute handling // Custom attribute handling
$custom_attributes = array(); $custom_attributes = array();
@ -264,11 +307,18 @@ abstract class WC_Settings_API {
$html .= '<tr valign="top">' . "\n"; $html .= '<tr valign="top">' . "\n";
$html .= '<th scope="row" class="titledesc">'; $html .= '<th scope="row" class="titledesc">';
$html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>'; $html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>';
if ( $tip )
$html .= '<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
$html .= '</th>' . "\n"; $html .= '</th>' . "\n";
$html .= '<td class="forminp">' . "\n"; $html .= '<td class="forminp">' . "\n";
$html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n"; $html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n";
$html .= '<input class="input-text regular-input ' . esc_attr( $data['class'] ) . '" type="password" name="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" id="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" style="' . esc_attr( $data['css'] ) . '" value="' . esc_attr( $this->get_option( $key ) ) . '" ' . disabled( $data['disabled'], true, false ) . ' ' . implode( ' ', $custom_attributes ) . ' />'; $html .= '<input class="input-text regular-input ' . esc_attr( $data['class'] ) . '" type="password" name="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" id="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" style="' . esc_attr( $data['css'] ) . '" value="' . esc_attr( $this->get_option( $key ) ) . '" ' . disabled( $data['disabled'], true, false ) . ' ' . implode( ' ', $custom_attributes ) . ' />';
if ( isset( $data['description'] ) && $data['description'] != '' ) { $html .= ' <p class="description">' . wp_kses_post( $data['description'] ) . '</p>' . "\n"; }
if ( $description )
$html .= ' <p class="description">' . wp_kses_post( $description ) . '</p>' . "\n";
$html .= '</fieldset>'; $html .= '</fieldset>';
$html .= '</td>' . "\n"; $html .= '</td>' . "\n";
$html .= '</tr>' . "\n"; $html .= '</tr>' . "\n";
@ -286,12 +336,31 @@ abstract class WC_Settings_API {
* @return string * @return string
*/ */
public function generate_textarea_html( $key, $data ) { public function generate_textarea_html( $key, $data ) {
global $woocommerce;
$html = ''; $html = '';
$data['title'] = isset( $data['title'] ) ? $data['title'] : ''; $data['title'] = isset( $data['title'] ) ? $data['title'] : '';
$data['disabled'] = empty( $data['disabled'] ) ? false : true; $data['disabled'] = empty( $data['disabled'] ) ? false : true;
$data['class'] = isset( $data['class'] ) ? $data['class'] : ''; $data['class'] = isset( $data['class'] ) ? $data['class'] : '';
$data['css'] = isset( $data['css'] ) ? $data['css'] : ''; $data['css'] = isset( $data['css'] ) ? $data['css'] : '';
$data['desc_tip'] = isset( $data['desc_tip'] ) ? $data['desc_tip'] : false;
$data['description'] = isset( $data['description'] ) ? $data['description'] : '';
$data['placeholder'] = isset( $data['placeholder'] ) ? $data['placeholder'] : '';
// Description handling
if ( $data['desc_tip'] === true ) {
$description = '';
$tip = $data['description'];
} elseif ( ! empty( $data['desc_tip'] ) ) {
$description = $data['description'];
$tip = $data['desc_tip'];
} elseif ( ! empty( $data['description'] ) ) {
$description = $data['description'];
$tip = '';
} else {
$description = $tip = '';
}
// Custom attribute handling // Custom attribute handling
$custom_attributes = array(); $custom_attributes = array();
@ -303,11 +372,18 @@ abstract class WC_Settings_API {
$html .= '<tr valign="top">' . "\n"; $html .= '<tr valign="top">' . "\n";
$html .= '<th scope="row" class="titledesc">'; $html .= '<th scope="row" class="titledesc">';
$html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>'; $html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>';
if ( $tip )
$html .= '<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
$html .= '</th>' . "\n"; $html .= '</th>' . "\n";
$html .= '<td class="forminp">' . "\n"; $html .= '<td class="forminp">' . "\n";
$html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n"; $html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n";
$html .= '<textarea rows="3" cols="20" class="input-text wide-input ' . esc_attr( $data['class'] ) . '" name="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" id="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" style="' . esc_attr( $data['css'] ) . '" ' . disabled( $data['disabled'], true, false ) . ' ' . implode( ' ', $custom_attributes ) . '>' . esc_textarea( $this->get_option( $key ) ) . '</textarea>'; $html .= '<textarea rows="3" cols="20" class="input-text wide-input ' . esc_attr( $data['class'] ) . '" placeholder="' . esc_attr( $data['placeholder'] ) . '" name="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" id="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" style="' . esc_attr( $data['css'] ) . '" ' . disabled( $data['disabled'], true, false ) . ' ' . implode( ' ', $custom_attributes ) . '>' . esc_textarea( $this->get_option( $key ) ) . '</textarea>';
if ( isset( $data['description'] ) && $data['description'] != '' ) { $html .= ' <p class="description">' . wp_kses_post( $data['description'] ) . '</p>' . "\n"; }
if ( $description )
$html .= ' <p class="description">' . wp_kses_post( $description ) . '</p>' . "\n";
$html .= '</fieldset>'; $html .= '</fieldset>';
$html .= '</td>' . "\n"; $html .= '</td>' . "\n";
$html .= '</tr>' . "\n"; $html .= '</tr>' . "\n";
@ -325,13 +401,31 @@ abstract class WC_Settings_API {
* @return string * @return string
*/ */
public function generate_checkbox_html( $key, $data ) { public function generate_checkbox_html( $key, $data ) {
global $woocommerce;
$html = ''; $html = '';
$data['title'] = isset( $data['title'] ) ? $data['title'] : ''; $data['title'] = isset( $data['title'] ) ? $data['title'] : '';
$data['label'] = isset( $data['label'] ) ? $data['label'] : $data['title']; $data['label'] = isset( $data['label'] ) ? $data['label'] : $data['title'];
$data['disabled'] = empty( $data['disabled'] ) ? false : true; $data['disabled'] = empty( $data['disabled'] ) ? false : true;
$data['class'] = isset( $data['class'] ) ? $data['class'] : ''; $data['class'] = isset( $data['class'] ) ? $data['class'] : '';
$data['css'] = isset( $data['css'] ) ? $data['css'] : ''; $data['css'] = isset( $data['css'] ) ? $data['css'] : '';
$data['desc_tip'] = isset( $data['desc_tip'] ) ? $data['desc_tip'] : false;
$data['description'] = isset( $data['description'] ) ? $data['description'] : '';
// Description handling
if ( $data['desc_tip'] === true ) {
$description = '';
$tip = $data['description'];
} elseif ( ! empty( $data['desc_tip'] ) ) {
$description = $data['description'];
$tip = $data['desc_tip'];
} elseif ( ! empty( $data['description'] ) ) {
$description = $data['description'];
$tip = '';
} else {
$description = $tip = '';
}
// Custom attribute handling // Custom attribute handling
$custom_attributes = array(); $custom_attributes = array();
@ -341,12 +435,20 @@ abstract class WC_Settings_API {
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
$html .= '<tr valign="top">' . "\n"; $html .= '<tr valign="top">' . "\n";
$html .= '<th scope="row" class="titledesc">' . $data['title'] . '</th>' . "\n"; $html .= '<th scope="row" class="titledesc">' . $data['title'];
if ( $tip )
$html .= '<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
$html .= '</th>' . "\n";
$html .= '<td class="forminp">' . "\n"; $html .= '<td class="forminp">' . "\n";
$html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n"; $html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n";
$html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">'; $html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">';
$html .= '<input style="' . esc_attr( $data['css'] ) . '" name="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" id="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" type="checkbox" value="1" ' . checked( $this->get_option( $key ), 'yes', false ) . ' class="' . esc_attr( $data['class'] ).'" ' . disabled( $data['disabled'], true, false ) . ' ' . implode( ' ', $custom_attributes ) . ' /> ' . wp_kses_post( $data['label'] ) . '</label><br />' . "\n"; $html .= '<input style="' . esc_attr( $data['css'] ) . '" name="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" id="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '" type="checkbox" value="1" ' . checked( $this->get_option( $key ), 'yes', false ) . ' class="' . esc_attr( $data['class'] ).'" ' . disabled( $data['disabled'], true, false ) . ' ' . implode( ' ', $custom_attributes ) . ' /> ' . wp_kses_post( $data['label'] ) . '</label><br />' . "\n";
if ( isset( $data['description'] ) && $data['description'] != '' ) { $html .= ' <p class="description">' . wp_kses_post( $data['description'] ) . '</p>' . "\n"; }
if ( $description )
$html .= ' <p class="description">' . wp_kses_post( $description ) . '</p>' . "\n";
$html .= '</fieldset>'; $html .= '</fieldset>';
$html .= '</td>' . "\n"; $html .= '</td>' . "\n";
$html .= '</tr>' . "\n"; $html .= '</tr>' . "\n";
@ -364,6 +466,8 @@ abstract class WC_Settings_API {
* @return string * @return string
*/ */
public function generate_select_html( $key, $data ) { public function generate_select_html( $key, $data ) {
global $woocommerce;
$html = ''; $html = '';
$data['title'] = isset( $data['title'] ) ? $data['title'] : ''; $data['title'] = isset( $data['title'] ) ? $data['title'] : '';
@ -371,6 +475,22 @@ abstract class WC_Settings_API {
$data['options'] = isset( $data['options'] ) ? (array) $data['options'] : array(); $data['options'] = isset( $data['options'] ) ? (array) $data['options'] : array();
$data['class'] = isset( $data['class'] ) ? $data['class'] : ''; $data['class'] = isset( $data['class'] ) ? $data['class'] : '';
$data['css'] = isset( $data['css'] ) ? $data['css'] : ''; $data['css'] = isset( $data['css'] ) ? $data['css'] : '';
$data['desc_tip'] = isset( $data['desc_tip'] ) ? $data['desc_tip'] : false;
$data['description'] = isset( $data['description'] ) ? $data['description'] : '';
// Description handling
if ( $data['desc_tip'] === true ) {
$description = '';
$tip = $data['description'];
} elseif ( ! empty( $data['desc_tip'] ) ) {
$description = $data['description'];
$tip = $data['desc_tip'];
} elseif ( ! empty( $data['description'] ) ) {
$description = $data['description'];
$tip = '';
} else {
$description = $tip = '';
}
// Custom attribute handling // Custom attribute handling
$custom_attributes = array(); $custom_attributes = array();
@ -382,6 +502,10 @@ abstract class WC_Settings_API {
$html .= '<tr valign="top">' . "\n"; $html .= '<tr valign="top">' . "\n";
$html .= '<th scope="row" class="titledesc">'; $html .= '<th scope="row" class="titledesc">';
$html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>'; $html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>';
if ( $tip )
$html .= '<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
$html .= '</th>' . "\n"; $html .= '</th>' . "\n";
$html .= '<td class="forminp">' . "\n"; $html .= '<td class="forminp">' . "\n";
$html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n"; $html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n";
@ -392,7 +516,10 @@ abstract class WC_Settings_API {
endforeach; endforeach;
$html .= '</select>'; $html .= '</select>';
if ( isset( $data['description'] ) && $data['description'] != '' ) { $html .= ' <p class="description">' . wp_kses_post( $data['description'] ) . '</p>' . "\n"; }
if ( $description )
$html .= ' <p class="description">' . wp_kses_post( $description ) . '</p>' . "\n";
$html .= '</fieldset>'; $html .= '</fieldset>';
$html .= '</td>' . "\n"; $html .= '</td>' . "\n";
$html .= '</tr>' . "\n"; $html .= '</tr>' . "\n";
@ -410,6 +537,8 @@ abstract class WC_Settings_API {
* @return string * @return string
*/ */
public function generate_multiselect_html( $key, $data ) { public function generate_multiselect_html( $key, $data ) {
global $woocommerce;
$html = ''; $html = '';
$data['title'] = isset( $data['title'] ) ? $data['title'] : ''; $data['title'] = isset( $data['title'] ) ? $data['title'] : '';
@ -417,6 +546,22 @@ abstract class WC_Settings_API {
$data['options'] = isset( $data['options'] ) ? (array) $data['options'] : array(); $data['options'] = isset( $data['options'] ) ? (array) $data['options'] : array();
$data['class'] = isset( $data['class'] ) ? $data['class'] : ''; $data['class'] = isset( $data['class'] ) ? $data['class'] : '';
$data['css'] = isset( $data['css'] ) ? $data['css'] : ''; $data['css'] = isset( $data['css'] ) ? $data['css'] : '';
$data['desc_tip'] = isset( $data['desc_tip'] ) ? $data['desc_tip'] : false;
$data['description'] = isset( $data['description'] ) ? $data['description'] : '';
// Description handling
if ( $data['desc_tip'] === true ) {
$description = '';
$tip = $data['description'];
} elseif ( ! empty( $data['desc_tip'] ) ) {
$description = $data['description'];
$tip = $data['desc_tip'];
} elseif ( ! empty( $data['description'] ) ) {
$description = $data['description'];
$tip = '';
} else {
$description = $tip = '';
}
// Custom attribute handling // Custom attribute handling
$custom_attributes = array(); $custom_attributes = array();
@ -428,6 +573,10 @@ abstract class WC_Settings_API {
$html .= '<tr valign="top">' . "\n"; $html .= '<tr valign="top">' . "\n";
$html .= '<th scope="row" class="titledesc">'; $html .= '<th scope="row" class="titledesc">';
$html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>'; $html .= '<label for="' . esc_attr( $this->plugin_id . $this->id . '_' . $key ) . '">' . wp_kses_post( $data['title'] ) . '</label>';
if ( $tip )
$html .= '<img class="help_tip" data-tip="' . esc_attr( $tip ) . '" src="' . $woocommerce->plugin_url() . '/assets/images/help.png" height="16" width="16" />';
$html .= '</th>' . "\n"; $html .= '</th>' . "\n";
$html .= '<td class="forminp">' . "\n"; $html .= '<td class="forminp">' . "\n";
$html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n"; $html .= '<fieldset><legend class="screen-reader-text"><span>' . wp_kses_post( $data['title'] ) . '</span></legend>' . "\n";
@ -438,7 +587,10 @@ abstract class WC_Settings_API {
} }
$html .= '</select>'; $html .= '</select>';
if ( isset( $data['description'] ) && $data['description'] != '' ) { $html .= '<p class="description">' . wp_kses_post( $data['description'] ) . '</p>' . "\n"; }
if ( $description )
$html .= ' <p class="description">' . wp_kses_post( $description ) . '</p>' . "\n";
$html .= '</fieldset>'; $html .= '</fieldset>';
$html .= '</td>' . "\n"; $html .= '</td>' . "\n";
$html .= '</tr>' . "\n"; $html .= '</tr>' . "\n";

View File

@ -1578,13 +1578,15 @@ class WC_Cart {
// Packages array for storing 'carts' // Packages array for storing 'carts'
$packages = array(); $packages = array();
$packages[0]['contents'] = $this->get_cart(); // Items in the package $packages[0]['contents'] = $this->get_cart(); // Items in the package
$packages[0]['contents_cost'] = 0; // Cost of items in the package, set below $packages[0]['contents_cost'] = 0; // Cost of items in the package, set below
$packages[0]['applied_coupons'] = $this->applied_coupons; // Applied coupons - some, like free shipping, affect costs $packages[0]['applied_coupons'] = $this->applied_coupons; // Applied coupons - some, like free shipping, affect costs
$packages[0]['destination']['country'] = $woocommerce->customer->get_shipping_country(); $packages[0]['destination']['country'] = $woocommerce->customer->get_shipping_country();
$packages[0]['destination']['state'] = $woocommerce->customer->get_shipping_state(); $packages[0]['destination']['state'] = $woocommerce->customer->get_shipping_state();
$packages[0]['destination']['postcode'] = $woocommerce->customer->get_shipping_postcode(); $packages[0]['destination']['postcode'] = $woocommerce->customer->get_shipping_postcode();
$packages[0]['destination']['city'] = $woocommerce->customer->get_shipping_city(); $packages[0]['destination']['city'] = $woocommerce->customer->get_shipping_city();
$packages[0]['destination']['address'] = $woocommerce->customer->get_shipping_address();
$packages[0]['destination']['address_2'] = $woocommerce->customer->get_shipping_address_2();
foreach ( $this->get_cart() as $item ) foreach ( $this->get_cart() as $item )
if ( $item['data']->needs_shipping() ) if ( $item['data']->needs_shipping() )

View File

@ -69,7 +69,8 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
'title' => __( 'Title', 'woocommerce' ), 'title' => __( 'Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Direct Bank Transfer', 'woocommerce' ) 'default' => __( 'Direct Bank Transfer', 'woocommerce' ),
'desc_tip' => true,
), ),
'description' => array( 'description' => array(
'title' => __( 'Customer Message', 'woocommerce' ), 'title' => __( 'Customer Message', 'woocommerce' ),
@ -110,13 +111,11 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
'iban' => array( 'iban' => array(
'title' => __( 'IBAN', 'woocommerce' ), 'title' => __( 'IBAN', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'Your bank may require this for international payments','woocommerce'),
'default' => '' 'default' => ''
), ),
'bic' => array( 'bic' => array(
'title' => __( 'BIC (formerly Swift)', 'woocommerce' ), 'title' => __( 'BIC (formerly Swift)', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __('Your bank may require this for international payments','woocommerce'),
'default' => '' 'default' => ''
), ),

View File

@ -63,7 +63,8 @@ class WC_Gateway_Cheque extends WC_Payment_Gateway {
'title' => __( 'Title', 'woocommerce' ), 'title' => __( 'Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Cheque Payment', 'woocommerce' ) 'default' => __( 'Cheque Payment', 'woocommerce' ),
'desc_tip' => true,
), ),
'description' => array( 'description' => array(
'title' => __( 'Customer Message', 'woocommerce' ), 'title' => __( 'Customer Message', 'woocommerce' ),

View File

@ -87,13 +87,14 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
'title' => __( 'Title', 'woocommerce' ), 'title' => __( 'Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'Payment method title that the customer will see on your website.', 'woocommerce' ), 'description' => __( 'Payment method title that the customer will see on your website.', 'woocommerce' ),
'default' => __( 'Cash on Delivery', 'woocommerce' ) 'default' => __( 'Cash on Delivery', 'woocommerce' ),
'desc_tip' => true,
), ),
'description' => array( 'description' => array(
'title' => __( 'Description', 'woocommerce' ), 'title' => __( 'Description', 'woocommerce' ),
'type' => 'textarea', 'type' => 'textarea',
'description' => __( 'Payment method description that the customer will see on your website.', 'woocommerce' ), 'description' => __( 'Payment method description that the customer will see on your website.', 'woocommerce' ),
'default' => 'Pay with cash upon delivery.' 'default' => 'Pay with cash upon delivery.',
), ),
'instructions' => array( 'instructions' => array(
'title' => __( 'Instructions', 'woocommerce' ), 'title' => __( 'Instructions', 'woocommerce' ),
@ -108,7 +109,8 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
'css' => 'width: 450px;', 'css' => 'width: 450px;',
'default' => '', 'default' => '',
'description' => __( 'If COD is only available for certain methods, set it up here. Leave blank to enable for all methods.', 'woocommerce' ), 'description' => __( 'If COD is only available for certain methods, set it up here. Leave blank to enable for all methods.', 'woocommerce' ),
'options' => $shipping_methods 'options' => $shipping_methods,
'desc_tip' => true,
) )
); );
} }

View File

@ -164,13 +164,15 @@ class WC_Gateway_Mijireh extends WC_Payment_Gateway {
'title' => __( 'Access Key', 'woocommerce' ), 'title' => __( 'Access Key', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'The Mijireh access key for your store.', 'woocommerce' ), 'description' => __( 'The Mijireh access key for your store.', 'woocommerce' ),
'default' => '' 'default' => '',
'desc_tip' => true,
), ),
'title' => array( 'title' => array(
'title' => __( 'Title', 'woocommerce' ), 'title' => __( 'Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Credit Card', 'woocommerce' ) 'default' => __( 'Credit Card', 'woocommerce' ),
'desc_tip' => true,
), ),
'description' => array( 'description' => array(
'title' => __( 'Description', 'woocommerce' ), 'title' => __( 'Description', 'woocommerce' ),

View File

@ -125,7 +125,8 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
'title' => __( 'Title', 'woocommerce' ), 'title' => __( 'Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'PayPal', 'woocommerce' ) 'default' => __( 'PayPal', 'woocommerce' ),
'desc_tip' => true,
), ),
'description' => array( 'description' => array(
'title' => __( 'Description', 'woocommerce' ), 'title' => __( 'Description', 'woocommerce' ),
@ -137,13 +138,16 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
'title' => __( 'PayPal Email', 'woocommerce' ), 'title' => __( 'PayPal Email', 'woocommerce' ),
'type' => 'email', 'type' => 'email',
'description' => __( 'Please enter your PayPal email address; this is needed in order to take payment.', 'woocommerce' ), 'description' => __( 'Please enter your PayPal email address; this is needed in order to take payment.', 'woocommerce' ),
'default' => '' 'default' => '',
'desc_tip' => true,
'placeholder' => 'you@youremail.com'
), ),
'invoice_prefix' => array( 'invoice_prefix' => array(
'title' => __( 'Invoice Prefix', 'woocommerce' ), 'title' => __( 'Invoice Prefix', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unqiue as PayPal will not allow orders with the same invoice number.', 'woocommerce' ), 'description' => __( 'Please enter a prefix for your invoice numbers. If you use your PayPal account for multiple stores ensure this prefix is unqiue as PayPal will not allow orders with the same invoice number.', 'woocommerce' ),
'default' => 'WC-' 'default' => 'WC-',
'desc_tip' => true,
), ),
'form_submission_method' => array( 'form_submission_method' => array(
'title' => __( 'Submission method', 'woocommerce' ), 'title' => __( 'Submission method', 'woocommerce' ),
@ -156,7 +160,9 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
'title' => __( 'Page Style', 'woocommerce' ), 'title' => __( 'Page Style', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'Optionally enter the name of the page style you wish to use. These are defined within your PayPal account.', 'woocommerce' ), 'description' => __( 'Optionally enter the name of the page style you wish to use. These are defined within your PayPal account.', 'woocommerce' ),
'default' => '' 'default' => '',
'desc_tip' => true,
'placeholder' => __( 'Optional', 'woocommerce' )
), ),
'shipping' => array( 'shipping' => array(
'title' => __( 'Shipping options', 'woocommerce' ), 'title' => __( 'Shipping options', 'woocommerce' ),

View File

@ -85,6 +85,7 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Flat Rate', 'woocommerce' ), 'default' => __( 'Flat Rate', 'woocommerce' ),
'desc_tip' => true
), ),
'cost_per_order' => array( 'cost_per_order' => array(
'title' => __( 'Cost per order', 'woocommerce' ), 'title' => __( 'Cost per order', 'woocommerce' ),
@ -95,6 +96,8 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
), ),
'description' => __( 'Enter a cost (excluding tax) per order, e.g. 5.00. Leave blank to disable.', 'woocommerce' ), 'description' => __( 'Enter a cost (excluding tax) per order, e.g. 5.00. Leave blank to disable.', 'woocommerce' ),
'default' => '', 'default' => '',
'desc_tip' => true,
'placeholder' => '0.00'
), ),
'availability' => array( 'availability' => array(
'title' => __( 'Method availability', 'woocommerce' ), 'title' => __( 'Method availability', 'woocommerce' ),
@ -117,7 +120,6 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
'type' => array( 'type' => array(
'title' => __( 'Calculation Type', 'woocommerce' ), 'title' => __( 'Calculation Type', 'woocommerce' ),
'type' => 'select', 'type' => 'select',
'description' => '',
'default' => 'order', 'default' => 'order',
'options' => array( 'options' => array(
'order' => __( 'Per Order - charge shipping for the entire order as a whole', 'woocommerce' ), 'order' => __( 'Per Order - charge shipping for the entire order as a whole', 'woocommerce' ),
@ -128,7 +130,6 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
'tax_status' => array( 'tax_status' => array(
'title' => __( 'Tax Status', 'woocommerce' ), 'title' => __( 'Tax Status', 'woocommerce' ),
'type' => 'select', 'type' => 'select',
'description' => '',
'default' => 'taxable', 'default' => 'taxable',
'options' => array( 'options' => array(
'taxable' => __( 'Taxable', 'woocommerce' ), 'taxable' => __( 'Taxable', 'woocommerce' ),
@ -144,12 +145,16 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
), ),
'description' => __( 'Cost excluding tax. Enter an amount, e.g. 2.50.', 'woocommerce' ), 'description' => __( 'Cost excluding tax. Enter an amount, e.g. 2.50.', 'woocommerce' ),
'default' => '', 'default' => '',
'desc_tip' => true,
'placeholder' => '0.00'
), ),
'fee' => array( 'fee' => array(
'title' => __( 'Default Handling Fee', 'woocommerce' ), 'title' => __( 'Default Handling Fee', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'Fee excluding tax. Enter an amount, e.g. 2.50, or a percentage, e.g. 5%. Leave blank to disable.', 'woocommerce' ), 'description' => __( 'Fee excluding tax. Enter an amount, e.g. 2.50, or a percentage, e.g. 5%. Leave blank to disable.', 'woocommerce' ),
'default' => '', 'default' => '',
'desc_tip' => true,
'placeholder' => '0.00'
), ),
'minimum_fee' => array( 'minimum_fee' => array(
'title' => __( 'Minimum Fee', 'woocommerce' ), 'title' => __( 'Minimum Fee', 'woocommerce' ),
@ -160,12 +165,16 @@ class WC_Shipping_Flat_Rate extends WC_Shipping_Method {
), ),
'description' => __( 'Enter a minimum fee amount. Fee\'s less than this will be increased. Leave blank to disable.', 'woocommerce' ), 'description' => __( 'Enter a minimum fee amount. Fee\'s less than this will be increased. Leave blank to disable.', 'woocommerce' ),
'default' => '', 'default' => '',
'desc_tip' => true,
'placeholder' => '0.00'
), ),
'options' => array( 'options' => array(
'title' => __( 'Shipping Options', 'woocommerce' ), 'title' => __( 'Shipping Options', 'woocommerce' ),
'type' => 'textarea', 'type' => 'textarea',
'description' => __( 'Optional extra shipping options with additional costs (one per line). Example: <code>Option Name|Cost|Per-order (yes or no)</code>. Example: <code>Priority Mail|6.95|yes</code>. If per-order is set to no, it will use the "Calculation Type" setting.', 'woocommerce' ), 'description' => __( 'Optional extra shipping options with additional costs (one per line). Example: <code>Option Name|Cost|Per-order (yes or no)</code>. Example: <code>Priority Mail|6.95|yes</code>. If per-order is set to no, it will use the "Calculation Type" setting.', 'woocommerce' ),
'default' => '', 'default' => '',
'desc_tip' => true,
'placeholder' => __( 'Option Name|Cost|Per-order (yes or no)', 'woocommerce' )
), ),
); );

View File

@ -81,7 +81,8 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
'title' => __( 'Method Title', 'woocommerce' ), 'title' => __( 'Method Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Free Shipping', 'woocommerce' ) 'default' => __( 'Free Shipping', 'woocommerce' ),
'desc_tip' => true,
), ),
'availability' => array( 'availability' => array(
'title' => __( 'Method availability', 'woocommerce' ), 'title' => __( 'Method availability', 'woocommerce' ),
@ -121,7 +122,9 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
'min' => '0' 'min' => '0'
), ),
'description' => __( 'Users will need to spend this amount to get free shipping (if enabled above).', 'woocommerce' ), 'description' => __( 'Users will need to spend this amount to get free shipping (if enabled above).', 'woocommerce' ),
'default' => '0' 'default' => '0',
'desc_tip' => true,
'placeholder' => '0.00'
) )
); );

View File

@ -58,7 +58,8 @@ class WC_Shipping_International_Delivery extends WC_Shipping_Flat_Rate {
'title' => __( 'Method Title', 'woocommerce' ), 'title' => __( 'Method Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'International Delivery', 'woocommerce' ) 'default' => __( 'International Delivery', 'woocommerce' ),
'desc_tip' => true,
), ),
'availability' => array( 'availability' => array(
'title' => __( 'Availability', 'woocommerce' ), 'title' => __( 'Availability', 'woocommerce' ),
@ -81,7 +82,6 @@ class WC_Shipping_International_Delivery extends WC_Shipping_Flat_Rate {
'type' => array( 'type' => array(
'title' => __( 'Calculation Type', 'woocommerce' ), 'title' => __( 'Calculation Type', 'woocommerce' ),
'type' => 'select', 'type' => 'select',
'description' => '',
'default' => 'order', 'default' => 'order',
'options' => array( 'options' => array(
'order' => __( 'Per Order - charge shipping for the entire order as a whole', 'woocommerce' ), 'order' => __( 'Per Order - charge shipping for the entire order as a whole', 'woocommerce' ),
@ -92,7 +92,6 @@ class WC_Shipping_International_Delivery extends WC_Shipping_Flat_Rate {
'tax_status' => array( 'tax_status' => array(
'title' => __( 'Tax Status', 'woocommerce' ), 'title' => __( 'Tax Status', 'woocommerce' ),
'type' => 'select', 'type' => 'select',
'description' => '',
'default' => 'taxable', 'default' => 'taxable',
'options' => array( 'options' => array(
'taxable' => __( 'Taxable', 'woocommerce' ), 'taxable' => __( 'Taxable', 'woocommerce' ),
@ -107,13 +106,17 @@ class WC_Shipping_International_Delivery extends WC_Shipping_Flat_Rate {
'min' => '0' 'min' => '0'
), ),
'description' => __( 'Cost excluding tax. Enter an amount, e.g. 2.50.', 'woocommerce' ), 'description' => __( 'Cost excluding tax. Enter an amount, e.g. 2.50.', 'woocommerce' ),
'default' => '' 'default' => '',
'desc_tip' => true,
'placeholder' => '0.00'
), ),
'fee' => array( 'fee' => array(
'title' => __( 'Default Handling Fee', 'woocommerce' ), 'title' => __( 'Default Handling Fee', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'Fee excluding tax. Enter an amount, e.g. 2.50, or a percentage, e.g. 5%. Leave blank to disable.', 'woocommerce' ), 'description' => __( 'Fee excluding tax. Enter an amount, e.g. 2.50, or a percentage, e.g. 5%. Leave blank to disable.', 'woocommerce' ),
'default' => '' 'default' => '',
'desc_tip' => true,
'placeholder' => '0.00'
), ),
); );

View File

@ -104,7 +104,8 @@ class WC_Shipping_Local_Delivery extends WC_Shipping_Method {
'title' => __( 'Title', 'woocommerce' ), 'title' => __( 'Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Local Delivery', 'woocommerce' ) 'default' => __( 'Local Delivery', 'woocommerce' ),
'desc_tip' => true,
), ),
'type' => array( 'type' => array(
'title' => __( 'Fee Type', 'woocommerce' ), 'title' => __( 'Fee Type', 'woocommerce' ),
@ -116,6 +117,7 @@ class WC_Shipping_Local_Delivery extends WC_Shipping_Method {
'percent' => __( 'Percentage of cart total', 'woocommerce' ), 'percent' => __( 'Percentage of cart total', 'woocommerce' ),
'product' => __( 'Fixed amount per product', 'woocommerce' ), 'product' => __( 'Fixed amount per product', 'woocommerce' ),
), ),
'desc_tip' => true,
), ),
'fee' => array( 'fee' => array(
'title' => __( 'Delivery Fee', 'woocommerce' ), 'title' => __( 'Delivery Fee', 'woocommerce' ),
@ -125,13 +127,17 @@ class WC_Shipping_Local_Delivery extends WC_Shipping_Method {
'min' => '0' 'min' => '0'
), ),
'description' => __( 'What fee do you want to charge for local delivery, disregarded if you choose free. Leave blank to disable.', 'woocommerce' ), 'description' => __( 'What fee do you want to charge for local delivery, disregarded if you choose free. Leave blank to disable.', 'woocommerce' ),
'default' => '' 'default' => '',
'desc_tip' => true,
'placeholder' => '0.00'
), ),
'codes' => array( 'codes' => array(
'title' => __( 'Zip/Post Codes', 'woocommerce' ), 'title' => __( 'Zip/Post Codes', 'woocommerce' ),
'type' => 'textarea', 'type' => 'textarea',
'description' => __( 'What zip/post codes would you like to offer delivery to? Separate codes with a comma. Accepts wildcards, e.g. P* will match a postcode of PE30.', 'woocommerce' ), 'description' => __( 'What zip/post codes would you like to offer delivery to? Separate codes with a comma. Accepts wildcards, e.g. P* will match a postcode of PE30.', 'woocommerce' ),
'default' => '' 'default' => '',
'desc_tip' => true,
'placeholder' => '12345, 56789 etc'
), ),
'availability' => array( 'availability' => array(
'title' => __( 'Method availability', 'woocommerce' ), 'title' => __( 'Method availability', 'woocommerce' ),

View File

@ -84,13 +84,16 @@ class WC_Shipping_Local_Pickup extends WC_Shipping_Method {
'title' => __( 'Title', 'woocommerce' ), 'title' => __( 'Title', 'woocommerce' ),
'type' => 'text', 'type' => 'text',
'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ), 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
'default' => __( 'Local Pickup', 'woocommerce' ) 'default' => __( 'Local Pickup', 'woocommerce' ),
'desc_tip' => true,
), ),
'codes' => array( 'codes' => array(
'title' => __( 'Zip/Post Codes', 'woocommerce' ), 'title' => __( 'Zip/Post Codes', 'woocommerce' ),
'type' => 'textarea', 'type' => 'textarea',
'description' => __( 'What zip/post codes would you like to offer delivery to? Separate codes with a comma. Accepts wildcards, e.g. P* will match a postcode of PE30.', 'woocommerce' ), 'description' => __( 'What zip/post codes would you like to offer delivery to? Separate codes with a comma. Accepts wildcards, e.g. P* will match a postcode of PE30.', 'woocommerce' ),
'default' => '' 'default' => '',
'desc_tip' => true,
'placeholder' => '12345, 56789 etc'
), ),
'availability' => array( 'availability' => array(
'title' => __( 'Method availability', 'woocommerce' ), 'title' => __( 'Method availability', 'woocommerce' ),