Better filter. Closes #3249

This commit is contained in:
Mike Jolley 2013-05-31 16:44:04 +01:00
parent 48edab0837
commit 304f006566
3 changed files with 37 additions and 28 deletions

View File

@ -161,6 +161,7 @@ function woocommerce_create_page( $slug, $option, $page_title = '', $page_conten
return; return;
$page_found = null; $page_found = null;
if ( strlen( $page_content ) > 0 ) { if ( strlen( $page_content ) > 0 ) {
// Search for an existing page with the specified page content (typically a shortcode) // Search for an existing page with the specified page content (typically a shortcode)
$page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type='page' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) ); $page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type='page' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );

View File

@ -31,24 +31,32 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
$this->init_form_fields(); $this->init_form_fields();
$this->init_settings(); $this->init_settings();
// Define user set variables
$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->account_name = $this->get_option( 'account_name' );
$this->account_number = $this->get_option( 'account_number' );
$this->sort_code = $this->get_option( 'sort_code' );
$this->bank_name = $this->get_option( 'bank_name' );
$this->iban = $this->get_option( 'iban' );
$this->bic = $this->get_option( 'bic' );
// BACS account fields shown on the thanks page and in emails // BACS account fields shown on the thanks page and in emails
$this->account_fields = array( $this->account_fields = array(
'account_name' => __( 'Account Name', 'woocommerce' ), 'account_name' => array(
'account_number'=> __( 'Account Number', 'woocommerce' ), 'label' => __( 'Account Name', 'woocommerce' ),
'sort_code' => __( 'Sort Code', 'woocommerce' ), 'value' => $this->get_option( 'account_name' )
'bank_name' => __( 'Bank Name', 'woocommerce' ), ),
'iban' => __( 'IBAN', 'woocommerce' ), 'account_number'=> array(
'bic' => __( 'BIC', 'woocommerce' ) 'label' => __( 'Account Number', 'woocommerce' ),
'value' => $this->get_option( 'account_number' )
),
'sort_code' => array(
'label' => __( 'Sort Code', 'woocommerce' ),
'value' => $this->get_option( 'sort_code' )
),
'bank_name' => array(
'label' => __( 'Bank Name', 'woocommerce' ),
'value' => $this->get_option( 'bank_name' )
),
'iban' => array(
'label' => __( 'IBAN', 'woocommerce' ),
'value' => $this->get_option( 'iban' )
),
'bic' => array(
'label' => __( 'BIC', 'woocommerce' ),
'value' => $this->get_option( 'bic' )
)
); );
// Actions // Actions
@ -171,9 +179,9 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
$fields = apply_filters( 'woocommerce_bacs_fields', $this->account_fields, $order_id ); $fields = apply_filters( 'woocommerce_bacs_fields', $this->account_fields, $order_id );
foreach ( $fields as $key=>$value ) { foreach ( $fields as $field_key => $field ) {
if ( ! empty( $this->$key ) ) { if ( ! empty( $field['value'] ) ) {
echo '<li class="' . esc_attr( $key ) . '">' . esc_attr( $value ) . ': <strong>' . wptexturize( $this->$key ) . '</strong></li>'; echo '<li class="' . esc_attr( $field_key ) . '">' . esc_attr( $field['label'] ) . ': <strong>' . wptexturize( $field['value'] ) . '</strong></li>';
} }
} }
@ -204,11 +212,11 @@ class WC_Gateway_BACS extends WC_Payment_Gateway {
$fields = apply_filters( 'woocommerce_bacs_fields', $this->account_fields, $order->id ); $fields = apply_filters( 'woocommerce_bacs_fields', $this->account_fields, $order->id );
foreach ($fields as $key=>$value) : foreach ( $fields as $field_key => $field ) {
if(!empty($this->$key)) : if ( ! empty( $field['value'] ) ) {
echo '<li class="'.$key.'">'.$value.': <strong>'.wptexturize($this->$key).'</strong></li>'; echo '<li class="' . esc_attr( $field_key ) . '">' . esc_attr( $field['label'] ) . ': <strong>' . wptexturize( $field['value'] ) . '</strong></li>';
endif; }
endforeach; }
?></ul><?php ?></ul><?php
} }

View File

@ -193,7 +193,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Refactor - Removed pay and thanks pages. Endpoints are used instead. * Refactor - Removed pay and thanks pages. Endpoints are used instead.
* Localization - Portugese locale by jpBenfica * Localization - Portugese locale by jpBenfica
* Localization - Swedish translation by Björn Sennbrink * Localization - Swedish translation by Björn Sennbrink
* Localization - Spanish, Romanian, Danish updates. * Localization - Spanish, Romanian, Danish, Korean updates.
= 2.0.10 - 15/05/2013 = = 2.0.10 - 15/05/2013 =
* Tweak - Searching for SKU in admin panel can also be done via lowercase 'sku:' instead of just 'SKU:' * Tweak - Searching for SKU in admin panel can also be done via lowercase 'sku:' instead of just 'SKU:'