fixed some coding standards in includes/admin/settings/class-wc-settings-general.php
This commit is contained in:
parent
a0ac62efca
commit
31cb09aec6
|
@ -8,7 +8,9 @@
|
|||
* @version 2.1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Settings_General' ) ) :
|
||||
|
||||
|
@ -28,8 +30,9 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
|
||||
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
|
||||
|
||||
if ( ( $styles = WC_Frontend_Scripts::get_styles() ) && array_key_exists( 'woocommerce-general', $styles ) )
|
||||
if ( ( $styles = WC_Frontend_Scripts::get_styles() ) && array_key_exists( 'woocommerce-general', $styles ) ) {
|
||||
add_action( 'woocommerce_admin_field_frontend_styles', array( $this, 'frontend_styles_setting' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,8 +43,9 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
public function get_settings() {
|
||||
$currency_code_options = get_woocommerce_currencies();
|
||||
|
||||
foreach ( $currency_code_options as $code => $name )
|
||||
foreach ( $currency_code_options as $code => $name ) {
|
||||
$currency_code_options[ $code ] = $name . ' (' . get_woocommerce_currency_symbol( $code ) . ')';
|
||||
}
|
||||
|
||||
return apply_filters( 'woocommerce_general_settings', array(
|
||||
|
||||
|
@ -113,7 +117,7 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
|
||||
array(
|
||||
'title' => __( 'Currency', 'woocommerce' ),
|
||||
'desc' => __( "This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.", 'woocommerce' ),
|
||||
'desc' => __( 'This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_currency',
|
||||
'css' => 'min-width:350px;',
|
||||
'default' => 'GBP',
|
||||
|
@ -202,7 +206,7 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
|
||||
array( 'type' => 'sectionend', 'id' => 'script_styling_options' ),
|
||||
|
||||
)); // End general settings
|
||||
) ); // End general settings
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,10 +220,10 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
<th scope="row" class="titledesc">
|
||||
<?php _e( 'Frontend Styles', 'woocommerce' ); ?>
|
||||
</th>
|
||||
<td class="forminp"><?php
|
||||
<td class="forminp"><?php
|
||||
|
||||
$base_file = WC()->plugin_path() . '/assets/css/woocommerce-base.less';
|
||||
$css_file = WC()->plugin_path() . '/assets/css/woocommerce.css';
|
||||
$base_file = WC()->plugin_path() . '/assets/css/woocommerce-base.less';
|
||||
$css_file = WC()->plugin_path() . '/assets/css/woocommerce.css';
|
||||
|
||||
if ( is_writable( $base_file ) && is_writable( $css_file ) ) {
|
||||
|
||||
|
@ -227,24 +231,34 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
$colors = array_map( 'esc_attr', (array) get_option( 'woocommerce_frontend_css_colors' ) );
|
||||
|
||||
// Defaults
|
||||
if ( empty( $colors['primary'] ) ) $colors['primary'] = '#ad74a2';
|
||||
if ( empty( $colors['secondary'] ) ) $colors['secondary'] = '#f7f6f7';
|
||||
if ( empty( $colors['highlight'] ) ) $colors['highlight'] = '#85ad74';
|
||||
if ( empty( $colors['content_bg'] ) ) $colors['content_bg'] = '#ffffff';
|
||||
if ( empty( $colors['subtext'] ) ) $colors['subtext'] = '#777777';
|
||||
if ( empty( $colors['primary'] ) ) {
|
||||
$colors['primary'] = '#ad74a2';
|
||||
}
|
||||
if ( empty( $colors['secondary'] ) ) {
|
||||
$colors['secondary'] = '#f7f6f7';
|
||||
}
|
||||
if ( empty( $colors['highlight'] ) ) {
|
||||
$colors['highlight'] = '#85ad74';
|
||||
}
|
||||
if ( empty( $colors['content_bg'] ) ) {
|
||||
$colors['content_bg'] = '#ffffff';
|
||||
}
|
||||
if ( empty( $colors['subtext'] ) ) {
|
||||
$colors['subtext'] = '#777777';
|
||||
}
|
||||
|
||||
// Show inputs
|
||||
$this->color_picker( __( 'Primary', 'woocommerce' ), 'woocommerce_frontend_css_primary', $colors['primary'], __( 'Call to action buttons/price slider/layered nav UI', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Secondary', 'woocommerce' ), 'woocommerce_frontend_css_secondary', $colors['secondary'], __( 'Buttons and tabs', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Highlight', 'woocommerce' ), 'woocommerce_frontend_css_highlight', $colors['highlight'], __( 'Price labels and Sale Flashes', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Content', 'woocommerce' ), 'woocommerce_frontend_css_content_bg', $colors['content_bg'], __( 'Your themes page background - used for tab active states', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Subtext', 'woocommerce' ), 'woocommerce_frontend_css_subtext', $colors['subtext'], __( 'Used for certain text and asides - breadcrumbs, small text etc.', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Primary', 'woocommerce' ), 'woocommerce_frontend_css_primary', $colors['primary'], __( 'Call to action buttons/price slider/layered nav UI', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Secondary', 'woocommerce' ), 'woocommerce_frontend_css_secondary', $colors['secondary'], __( 'Buttons and tabs', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Highlight', 'woocommerce' ), 'woocommerce_frontend_css_highlight', $colors['highlight'], __( 'Price labels and Sale Flashes', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Content', 'woocommerce' ), 'woocommerce_frontend_css_content_bg', $colors['content_bg'], __( 'Your themes page background - used for tab active states', 'woocommerce' ) );
|
||||
$this->color_picker( __( 'Subtext', 'woocommerce' ), 'woocommerce_frontend_css_subtext', $colors['subtext'], __( 'Used for certain text and asides - breadcrumbs, small text etc.', 'woocommerce' ) );
|
||||
|
||||
} else {
|
||||
echo '<span class="description">' . __( 'To edit colours <code>woocommerce/assets/css/woocommerce-base.less</code> and <code>woocommerce.css</code> need to be writable. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.', 'woocommerce' ) . '</span>';
|
||||
}
|
||||
} else {
|
||||
echo '<span class="description">' . __( 'To edit colours <code>woocommerce/assets/css/woocommerce-base.less</code> and <code>woocommerce.css</code> need to be writable. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.', 'woocommerce' ) . '</span>';
|
||||
}
|
||||
|
||||
?></td>
|
||||
?></td>
|
||||
</tr><?php
|
||||
}
|
||||
|
||||
|
@ -260,8 +274,8 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
*/
|
||||
function color_picker( $name, $id, $value, $desc = '' ) {
|
||||
echo '<div class="color_box"><strong><img class="help_tip" data-tip="' . esc_attr( $desc ) . '" src="' . WC()->plugin_url() . '/assets/images/help.png" height="16" width="16" /> ' . esc_html( $name ) . '</strong>
|
||||
<input name="' . esc_attr( $id ). '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
|
||||
</div>';
|
||||
<input name="' . esc_attr( $id ). '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -275,18 +289,18 @@ class WC_Settings_General extends WC_Settings_Page {
|
|||
if ( isset( $_POST['woocommerce_frontend_css_primary'] ) ) {
|
||||
|
||||
// Save settings
|
||||
$primary = ( ! empty( $_POST['woocommerce_frontend_css_primary'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_primary'] ) : '';
|
||||
$secondary = ( ! empty( $_POST['woocommerce_frontend_css_secondary'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_secondary'] ) : '';
|
||||
$highlight = ( ! empty( $_POST['woocommerce_frontend_css_highlight'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_highlight'] ) : '';
|
||||
$content_bg = ( ! empty( $_POST['woocommerce_frontend_css_content_bg'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_content_bg'] ) : '';
|
||||
$subtext = ( ! empty( $_POST['woocommerce_frontend_css_subtext'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_subtext'] ) : '';
|
||||
$primary = ( ! empty( $_POST['woocommerce_frontend_css_primary'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_primary'] ) : '';
|
||||
$secondary = ( ! empty( $_POST['woocommerce_frontend_css_secondary'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_secondary'] ) : '';
|
||||
$highlight = ( ! empty( $_POST['woocommerce_frontend_css_highlight'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_highlight'] ) : '';
|
||||
$content_bg = ( ! empty( $_POST['woocommerce_frontend_css_content_bg'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_content_bg'] ) : '';
|
||||
$subtext = ( ! empty( $_POST['woocommerce_frontend_css_subtext'] ) ) ? wc_format_hex( $_POST['woocommerce_frontend_css_subtext'] ) : '';
|
||||
|
||||
$colors = array(
|
||||
'primary' => $primary,
|
||||
'secondary' => $secondary,
|
||||
'highlight' => $highlight,
|
||||
'content_bg' => $content_bg,
|
||||
'subtext' => $subtext
|
||||
'primary' => $primary,
|
||||
'secondary' => $secondary,
|
||||
'highlight' => $highlight,
|
||||
'content_bg' => $content_bg,
|
||||
'subtext' => $subtext
|
||||
);
|
||||
|
||||
// Check the colors.
|
||||
|
|
Loading…
Reference in New Issue