Modals first pass

This commit is contained in:
Mike Jolley 2016-03-24 17:26:40 +00:00
parent bea3c66777
commit d3ac3f4073
19 changed files with 281 additions and 69 deletions

File diff suppressed because one or more lines are too long

View File

@ -2484,6 +2484,12 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
li:last-child {
display: block;
}
li:first-child {
margin: 0 !important;
}
li.wc-shipping-zone-methods-add-row {
margin: .5em 0 0;
}
}
.button {
display: inline-block;
@ -2497,11 +2503,16 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
float: right;
padding: .5em;
cursor: pointer;
line-height: 24px;
&:before {
@include icon;
font-family: 'Dashicons';
color: #999;
vertical-align: middle;
line-height: 24px;
font-size: 16px;
margin: 0;
}
&:hover {
&:before {
@ -2512,7 +2523,8 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
a.wc-shipping-zone-delete, a.wc-shipping-zone-method-delete, a.wc-shipping-class-delete {
&:before {
content: "\e013";
content: "\f158";
margin-top: 1px;
}
&:hover {
&:before {
@ -2529,9 +2541,7 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
a.wc-shipping-zone-method-settings {
&:before {
@include icon("\f111");
font-family: 'Dashicons';
line-height: 2.26;
content: "\f111";
}
}
}
@ -2557,6 +2567,50 @@ table.wc-shipping-zones, table.wc-shipping-zone-methods, table.wc-shipping-class
}
}
.wc-modal-shipping-method-settings {
background: #f8f8f8;
padding: 1em !important;
form {
.form-table {
width: 100%;
background: #fff;
margin: 0 0 1.5em;
tr {
th {
width: 30%;
position: relative;
.woocommerce-help-tip {
float: right;
margin: -8px -.5em 0 0;
vertical-align: middle;
right: 0;
top: 50%;
position: absolute;
}
}
td {
input, select, textarea {
width: 100%;
}
input[type="checkbox"] {
width: auto;
}
}
td, th {
vertical-align: middle;
margin: 0;
line-height: 24px;
padding: 1em;
border-bottom: 1px solid #f8f8f8;
}
}
&:last-of-type {
margin-bottom: 0;
}
}
}
}
.wc-backbone-modal .wc-shipping-zone-method-selector {
padding: 2px;
.wc-shipping-zone-method-description {

View File

@ -79,6 +79,10 @@
$( window ).on( 'beforeunload', { view: this }, this.unloadConfirmation );
$save_button.on( 'click', { view: this }, this.onSubmit );
$('.wc-shipping-zone-add-method').on( 'click', { view: this }, this.onAdd );
// Settings modal
$( document.body ).on( 'click', '.wc-shipping-zone-method-settings', { view: this }, this.onConfigureShippingMethod );
$( document.body ).on( 'wc_backbone_modal_response', this.onConfigureShippingMethodSubmitted );
},
block: function() {
$( this.el ).block({
@ -229,6 +233,59 @@
if ( _.size( changes ) ) {
model.logChanges( changes );
}
},
onConfigureShippingMethod: function( event ) {
var instance_id = $( this ).closest( 'tr' ).data( 'id' ),
model = event.data.view.model,
methods = _.indexBy( model.get( 'methods' ), 'instance_id' ),
method = methods[ instance_id ];
event.preventDefault();
$( this ).WCBackboneModal({
template : 'wc-modal-shipping-method-settings',
variable : {
instance_id : instance_id,
method : method
},
data : {
instance_id : instance_id,
method : method
}
});
$( document.body ).trigger( 'init_tooltips' );
},
onConfigureShippingMethodSubmitted: function( event, target, posted_data ) {
if ( 'wc-modal-shipping-method-settings' === target ) {
shippingMethodView.block();
// Save method settings via ajax call
$.post( ajaxurl + '?action=woocommerce_shipping_zone_methods_save_settings', {
wc_shipping_zones_nonce : data.wc_shipping_zones_nonce,
instance_id : posted_data.instance_id,
data : posted_data
}, function( response, textStatus ) {
if ( 'success' === textStatus && response.success ) {
$( 'table.wc-shipping-zone-methods' ).parent().find( '#woocommerce_errors' ).remove();
// If there were errors, prepend the form.
if ( response.data.errors.length > 0 ) {
var error_html = '<div id="woocommerce_errors" class="error notice is-dismissible">';
$( response.data.errors ).each( function( index, value ) {
error_html = error_html + '<p>' + value + '</p>';
} );
error_html = error_html + '</div>';
$( 'table.wc-shipping-zone-methods' ).before( error_html );
}
// Method was saved. Re-render.
shippingMethodView.model.set( 'methods', response.data.methods );
shippingMethodView.render();
}
shippingMethodView.unblock();
}, 'json' );
}
}
} ),
shippingMethod = new ShippingMethod({

File diff suppressed because one or more lines are too long

View File

@ -129,6 +129,7 @@
// Make the rows function
this.$el.find('.view').show();
this.$el.find('.edit').hide();
this.$el.find('.wc-shipping-zone-save-changes-notice').hide();
this.$el.find( '.wc-shipping-zone-edit' ).on( 'click', { view: this }, this.onEditRow );
this.$el.find( '.wc-shipping-zone-delete' ).on( 'click', { view: this }, this.onDeleteRow );
this.$el.find( '.wc-shipping-zone-postcodes-toggle' ).on( 'click', { view: this }, this.onTogglePostcodes );
@ -150,7 +151,7 @@
var $tr = $( '.wc-shipping-zones tr[data-id="' + zone_id + '"]');
var $method_list = $tr.find('.wc-shipping-zone-methods ul');
$method_list.empty();
$method_list.find( '.wc-shipping-zone-method' ).remove();
if ( _.size( shipping_methods ) ) {
_.each( shipping_methods, function( shipping_method, instance_id ) {
@ -160,11 +161,9 @@
class_name = 'method_enabled';
}
$method_list.append( '<li><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id=' + instance_id + '" class="' + class_name + '">' + shipping_method.title + '</a></li>' );
$method_list.prepend( '<li class="wc-shipping-zone-method"><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id=' + instance_id + '" class="' + class_name + '">' + shipping_method.title + '</a></li>' );
} );
$method_list.append( '<li>' + data.strings.add_another_method + '</li>' );
} else {
$method_list.append( '<li>' + data.strings.no_methods + '</li>' );
}
},
initTooltips: function() {
@ -219,6 +218,8 @@
$( this ).closest('tr').find('.edit').show();
$( '.wc-shipping-zone-region-select:not(.enhanced)' ).select2( select2_args );
$( '.wc-shipping-zone-region-select:not(.enhanced)' ).addClass('enhanced');
$( this ).closest('tr').find('.add_shipping_method').attr( 'disabled', 'disabled' ).addClass( 'tips' );
event.data.view.initTooltips();
event.data.view.model.trigger( 'change:zones' );
},
onDeleteRow: function( event ) {

File diff suppressed because one or more lines are too long

View File

@ -79,21 +79,25 @@ jQuery( function ( $ ) {
} else {
$( document.body ).triggerHandler( 'wc_remove_error_tip', [ $(this), 'i18_sale_less_than_regular_error' ] );
}
})
.on( 'init_tooltips', function() {
var tiptip_args = {
'attribute': 'data-tip',
'fadeIn': 50,
'fadeOut': 50,
'delay': 200
};
$( '.tips, .help_tip, .woocommerce-help-tip' ).tipTip( tiptip_args );
// Add tiptip to parent element for widefat tables
$( '.parent-tips' ).each( function() {
$( this ).closest( 'a, th' ).attr( 'data-tip', $( this ).data( 'tip' ) ).tipTip( tiptip_args ).css( 'cursor', 'help' );
});
});
// Tooltips
var tiptip_args = {
'attribute': 'data-tip',
'fadeIn': 50,
'fadeOut': 50,
'delay': 200
};
$( '.tips, .help_tip, .woocommerce-help-tip' ).tipTip( tiptip_args );
// Add tiptip to parent element for widefat tables
$( '.parent-tips' ).each( function() {
$( this ).closest( 'a, th' ).attr( 'data-tip', $( this ).data( 'tip' ) ).tipTip( tiptip_args ).css( 'cursor', 'help' );
});
$( document.body ).trigger( 'init_tooltips' );
// wc_input_table tables
$( '.wc_input_table.sortable tbody' ).sortable({

File diff suppressed because one or more lines are too long

View File

@ -97,12 +97,16 @@ abstract class WC_Settings_API {
/**
* Get a field's posted and validated value.
* @param string $key
* @param array $field
* @param array $post_data
* @return string
*/
public function get_field_value( $key, $field ) {
public function get_field_value( $key, $field, $post_data = array() ) {
$type = $this->get_field_type( $field );
$field_key = $this->get_field_key( $key );
$value = isset( $_POST[ $field_key ] ) ? $_POST[ $field_key ] : null;
$post_data = empty( $post_data ) ? $_POST : $post_data;
$value = isset( $post_data[ $field_key ] ) ? $post_data[ $field_key ] : null;
// Look for a validate_FIELDID_field method for special handling
if ( is_callable( array( $this, 'validate_' . $key . '_field' ) ) ) {
@ -121,15 +125,20 @@ abstract class WC_Settings_API {
/**
* Processes and saves options.
* If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
* @param array $post_data Defaults to $_POST but can be passed in.
* @return bool was anything saved?
*/
public function process_admin_options() {
public function process_admin_options( $post_data = array() ) {
$this->init_settings();
if ( empty( $post_data ) ) {
$post_data = $_POST;
}
foreach ( $this->get_form_fields() as $key => $field ) {
if ( 'title' !== $this->get_field_type( $field ) ) {
try {
$this->settings[ $key ] = $this->get_field_value( $key, $field );
$this->settings[ $key ] = $this->get_field_value( $key, $field, $post_data );
} catch ( Exception $e ) {
$this->add_error( $e->getMessage() );
}
@ -147,13 +156,20 @@ abstract class WC_Settings_API {
$this->errors[] = $error;
}
/**
* Get admin error messages.
*/
public function get_errors() {
return $this->errors;
}
/**
* Display admin error messages.
*/
public function display_errors() {
if ( count( $this->errors ) > 0 ) {
if ( $this->get_errors() ) {
echo '<div id="woocommerce_errors" class="error notice is-dismissible">';
foreach ( $this->errors as $error ) {
foreach ( $this->get_errors() as $error ) {
echo '<p>' . wp_kses_post( $error ) . '</p>';
}
echo '</div>';

View File

@ -355,18 +355,31 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
return $this->instance_id ? $this->supports( 'instance-settings' ) : $this->supports( 'settings' );
}
/**
* Return admin options as a html string.
* @return string
*/
public function get_admin_options_html() {
$settings_html = '';
if ( $this->instance_id ) {
$settings_html .= '<table class="form-table">' . $this->generate_settings_html( $this->get_instance_form_fields(), false ) . '</table>';
} else {
$settings_html .= '<table class="form-table">' . $this->generate_settings_html( $this->get_form_fields(), false ) . '</table>';
}
return $settings_html;
}
/**
* Output the shipping settings screen.
*/
public function admin_options() {
if ( $this->instance_id ) {
echo wp_kses_post( wpautop( $this->get_method_description() ) );
echo '<table class="form-table">' . $this->generate_settings_html( $this->get_instance_form_fields(), false ) . '</table>';
} else {
if ( ! $this->instance_id ) {
echo '<h2>' . esc_html( $this->get_method_title() ) . '</h2>';
echo wp_kses_post( wpautop( $this->get_method_description() ) );
echo '<table class="form-table">' . $this->generate_settings_html( $this->get_form_fields(), false ) . '</table>';
}
echo wp_kses_post( wpautop( $this->get_method_description() ) );
echo $this->get_admin_options_html();
}
/**
@ -450,16 +463,21 @@ abstract class WC_Shipping_Method extends WC_Settings_API {
* Processes and saves options.
* If there is an error thrown, will continue to save and validate fields, but will leave the erroring field out.
* @since 2.6.0
* @param array $post_data Defaults to $_POST but can be passed in.
* @return bool was anything saved?
*/
public function process_admin_options() {
public function process_admin_options( $post_data = array() ) {
if ( $this->instance_id ) {
$this->init_instance_settings();
if ( empty( $post_data ) ) {
$post_data = $_POST;
}
foreach ( $this->get_instance_form_fields() as $key => $field ) {
if ( 'title' !== $this->get_field_type( $field ) ) {
try {
$this->instance_settings[ $key ] = $this->get_field_value( $key, $field );
$this->instance_settings[ $key ] = $this->get_field_value( $key, $field, $post_data );
} catch ( Exception $e ) {
$this->add_error( $e->getMessage() );
}

View File

@ -104,7 +104,7 @@ class WC_Admin_Assets {
wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
wp_register_script( 'wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array( 'underscore', 'backbone', 'wp-util' ), WC_VERSION );
wp_register_script( 'wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal' ), WC_VERSION );
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable' ), WC_VERSION );
wp_register_script( 'wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal' ), WC_VERSION );
wp_register_script( 'wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION );
wp_register_script( 'select2', WC()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), '3.5.4' );
wp_register_script( 'wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array( 'jquery', 'select2' ), WC_VERSION );

View File

@ -241,8 +241,6 @@ class WC_Settings_Shipping extends WC_Settings_Page {
'strings' => array(
'unload_confirmation_msg' => __( 'Your changed data will be lost if you leave this page without saving.', 'woocommerce' ),
'save_failed' => __( 'Your changes were not saved. Please retry.', 'woocommerce' ),
'no_methods' => '<a href="#" class="add_shipping_method button">' . __( 'Add Shipping Method', 'woocommerce' ) . '</a>',
'add_another_method' => '<a href="#" class="add_shipping_method button">' . __( 'Add Shipping Method', 'woocommerce' ) . '</a>'
),
) );
wp_enqueue_script( 'wc-shipping-zones' );

View File

@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<table class="wc-shipping-zone-methods widefat">
<thead>
<tr>
<th class="wc-shipping-zone-method-sort">&nbsp;</th>
<th class="wc-shipping-zone-method-sort"><?php echo wc_help_tip( __( 'Drag and drop to re-order your Shipping Methods. This is the order in which they will display during checkout.', 'woocommerce' ) ); ?></th>
<th class="wc-shipping-zone-method-title"><?php esc_html_e( 'Title', 'woocommerce' ); ?></th>
<th class="wc-shipping-zone-method-type"><?php esc_html_e( 'Type', 'woocommerce' ); ?></th>
<th class="wc-shipping-zone-method-enabled"><?php esc_html_e( 'Enabled', 'woocommerce' ); ?></th>
@ -62,3 +62,30 @@ if ( ! defined( 'ABSPATH' ) ) {
</td>
</tr>
</script>
<script type="text/template" id="tmpl-wc-modal-shipping-method-settings">
<div class="wc-backbone-modal">
<div class="wc-backbone-modal-content">
<section class="wc-backbone-modal-main" role="main">
<header class="wc-backbone-modal-header">
<h1><?php echo esc_html( sprintf( __( '%s Settings', 'Shipping Method Settings', 'woocommerce' ), '{{{ data.method.title }}}' ) ); ?></h1>
<button class="modal-close modal-close-link dashicons dashicons-no-alt">
<span class="screen-reader-text"><?php _e( 'Close modal panel', 'woocommerce' ); ?></span>
</button>
</header>
<article class="wc-modal-shipping-method-settings">
<form action="" method="post">
{{{ data.method.settings_html }}}
<input type="hidden" name="instance_id" value="{{{ data.instance_id }}}" />
</form>
</article>
<footer>
<div class="inner">
<button id="btn-ok" class="button button-primary button-large"><?php _e( 'Save changes', 'woocommerce' ); ?></button>
</div>
</footer>
</section>
</div>
</div>
<div class="wc-backbone-modal-backdrop modal-close"></div>
</script>

View File

@ -36,22 +36,20 @@ if ( ! defined( 'ABSPATH' ) ) {
</td>
<td class="wc-shipping-zone-region"><?php esc_html_e( 'Shipping Methods added here will apply to shipping addresses that aren&lsquo;t included in any other Shipping Zone.', 'woocommerce' ); ?></td>
<td class="wc-shipping-zone-methods">
<?php
$worldwide = new WC_Shipping_Zone( 0 );
$methods = $worldwide->get_shipping_methods();
<ul>
<?php
$worldwide = new WC_Shipping_Zone( 0 );
$methods = $worldwide->get_shipping_methods();
if ( ! $methods ) {
echo '<ul><li><a href="#" class="add_shipping_method button">' . __( 'Add Shipping Method', 'woocommerce' ) . '</a></li></ul>';
} else {
echo '<ul>';
foreach ( $methods as $method ) {
$class_name = 'yes' === $method->enabled ? 'method_enabled' : 'method_disabled';
echo '<li><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id=' . absint( $method->instance_id ) . '" class="' . esc_attr( $class_name ) . '">' . esc_html( $method->get_title() ) . '</a></li>';
if ( $methods ) {
foreach ( $methods as $method ) {
$class_name = 'yes' === $method->enabled ? 'method_enabled' : 'method_disabled';
echo '<li class="wc-shipping-zone-method"><a href="admin.php?page=wc-settings&amp;tab=shipping&amp;instance_id=' . absint( $method->instance_id ) . '" class="' . esc_attr( $class_name ) . '">' . esc_html( $method->get_title() ) . '</a></li>';
}
}
echo '<li><a href="#" class="add_shipping_method button">' . __( 'Add Shipping Method', 'woocommerce' ) . '</a></li>';
echo '</ul>';
}
?>
?>
<li class="wc-shipping-zone-methods-add-row"><a href="#" class="add_shipping_method button" data-tip="<?php esc_attr_e( 'Save changes to continue adding Shipping Methods to this zone.', 'woocommerce' ); ?>"><?php _e( 'Add Shipping Method', 'woocommerce' ); ?></a></li>
</ul>
</td>
<td class="wc-shipping-zone-actions"></td>
</tr>
@ -111,10 +109,11 @@ if ( ! defined( 'ABSPATH' ) ) {
</div>
</td>
<td class="wc-shipping-zone-methods">
<div class="view">
<ul></ul>
<div>
<ul>
<li class="wc-shipping-zone-methods-add-row"><a href="#" class="add_shipping_method button" data-tip="<?php esc_attr_e( 'Save changes to continue adding Shipping Methods to this zone.', 'woocommerce' ); ?>"><?php _e( 'Add Shipping Method', 'woocommerce' ); ?></a></li>
</ul>
</div>
<div class="edit"><?php _e( '<a href="#" class="wc-shipping-zone-save-changes">Save changes</a> to start adding Shipping Methods to this zone.', 'woocommerce' ); ?></div>
</td>
<td class="wc-shipping-zone-actions">
<a class="wc-shipping-zone-delete tips" data-tip="<?php _e( 'Delete', 'woocommerce' ); ?>" href="#"><?php _e( 'Delete', 'woocommerce' ); ?></a>

View File

@ -93,7 +93,7 @@ if ( ! defined( 'ABSPATH' ) ) {
} else {
?>
<p class="submit">
<?php submit_button( __( 'Save Changes', 'woocommerce' ), 'primary', 'update_api_key', false ); ?>
<?php submit_button( __( 'Save changes', 'woocommerce' ), 'primary', 'update_api_key', false ); ?>
<a style="color: #a00; text-decoration: none; margin-left: 10px;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'revoke-key' => $key_id ), admin_url( 'admin.php?page=wc-settings&tab=api&section=keys' ) ), 'revoke' ) ); ?>"><?php _e( 'Revoke Key', 'woocommerce' ); ?></a>
</p>
<?php

View File

@ -60,6 +60,6 @@ if ( ! defined( 'ABSPATH' ) ) {
</tbody>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'woocommerce' ) ?>" />
<input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save changes', 'woocommerce' ) ?>" />
</p>
</form>

View File

@ -145,6 +145,7 @@ class WC_AJAX {
'shipping_zones_save_changes' => false,
'shipping_zone_add_method' => false,
'shipping_zone_methods_save_changes' => false,
'shipping_zone_methods_save_settings' => false,
'shipping_classes_save_changes' => false,
);
@ -3207,6 +3208,38 @@ class WC_AJAX {
) );
}
/**
* Save method settings
*/
public static function shipping_zone_methods_save_settings() {
if ( ! isset( $_POST['wc_shipping_zones_nonce'], $_POST['instance_id'], $_POST['data'] ) ) {
wp_send_json_error( 'missing_fields' );
exit;
}
if ( ! wp_verify_nonce( $_POST['wc_shipping_zones_nonce'], 'wc_shipping_zones_nonce' ) ) {
wp_send_json_error( 'bad_nonce' );
exit;
}
if ( ! current_user_can( 'manage_woocommerce' ) ) {
wp_send_json_error( 'missing_capabilities' );
exit;
}
$instance_id = absint( $_POST['instance_id'] );
$zone = WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id );
$shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
$data = $_POST['data'];
$shipping_method->process_admin_options( $data );
wp_send_json_success( array(
'methods' => $zone->get_shipping_methods(),
'errors' => $shipping_method->get_errors(),
) );
}
/**
* Handle submissions from assets/js/wc-shipping-classes.js Backbone model.
*/

View File

@ -238,9 +238,10 @@ class WC_Shipping_Zone extends WC_Data {
// Let's make sure that we have an instance before setting its attributes
if ( is_object( $methods[ $raw_method->instance_id ] ) ) {
$methods[ $raw_method->instance_id ]->method_order = absint( $raw_method->method_order );
$methods[ $raw_method->instance_id ]->enabled = $raw_method->is_enabled ? 'yes' : 'no';
$methods[ $raw_method->instance_id ]->has_settings = $methods[ $raw_method->instance_id ]->has_settings();
$methods[ $raw_method->instance_id ]->method_order = absint( $raw_method->method_order );
$methods[ $raw_method->instance_id ]->enabled = $raw_method->is_enabled ? 'yes' : 'no';
$methods[ $raw_method->instance_id ]->has_settings = $methods[ $raw_method->instance_id ]->has_settings();
$methods[ $raw_method->instance_id ]->settings_html = $methods[ $raw_method->instance_id ]->get_admin_options_html();
}
}
}

View File

@ -529,16 +529,20 @@ class WC_Email extends WC_Settings_API {
/**
* Admin Panel Options Processing.
*/
public function process_admin_options() {
public function process_admin_options( $post_data = array() ) {
if ( empty( $post_data ) ) {
$post_data = $_POST;
}
// Save regular options
parent::process_admin_options();
parent::process_admin_options( $post_data );
// Save templates
if ( isset( $_POST['template_html_code'] ) ) {
$this->save_template( $_POST['template_html_code'], $this->template_html );
$this->save_template( $post_data['template_html_code'], $this->template_html );
}
if ( isset( $_POST['template_plain_code'] ) ) {
$this->save_template( $_POST['template_plain_code'], $this->template_plain );
$this->save_template( $post_data['template_plain_code'], $this->template_plain );
}
}