Skip to content

Commit

Permalink
In a significant architectural change, we've decided to remove settin…
Browse files Browse the repository at this point in the history
…gs for dequeueing CSS.

These settings have a bit of an unweildy UI, and as it stands, they can easily be overriden by a theme adding the files to their stack, or by a one-line filter to remove them without overriding them.

 will do the trick for those that want it.
We have also added a filter flag,  for those that only want to remove inline styles.

In addition, we've changed the wording a bit in the settings now that there are barely any.  See #516, #1983.
  • Loading branch information
JustinSainton committed May 24, 2016
1 parent 1640335 commit 8b1af55
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private function show_total_style() {
}
}

protected function column_image( $item, $key ) {
protected function column_image( $item ) {
if ( $this->show_thumbnails ) : ?>
<div class="wpsc-thumbnail wpsc-product-thumbnail">
<?php if ( wpsc_has_product_thumbnail( $item->product_id ) ) : ?>
Expand Down
22 changes: 3 additions & 19 deletions wpsc-components/theme-engine-v2/classes/settings-presentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ public function _filter_field_category_filter( $output, $field_array ) {

public function display() {
?>
<h3><?php _e( 'Wondering where all the old presentation settings have gone?', 'wp-e-commerce' ); ?></h3>
<p><?php _e( "Do not worry. We're taking this opportunity to rewrite them properly using the new WordPress settings API throughout this beta phase.", 'wp-e-commerce' ); ?></p>
<p><?php _e( "We'll either add them right back or release mini Plugins. To help us decide what goes back into core and what will become a Plugin, please <a href='https://github.com/wp-e-commerce/WP-e-Commerce/issues/516'>let us know on Github</a> what your most important setting is.", 'wp-e-commerce' ); ?></p>
<h3><?php _e( 'Presentation Settings', 'wp-e-commerce' ); ?></h3>
<p><?php _e( 'Most presentational settings have now been moved to the Customizer. Click the <em>Manage in Customizer</em> button above to modify your settings.', 'wp-e-commerce' ); ?></p>
<?php

parent::display();
Expand All @@ -85,12 +84,6 @@ private function populate_form_array() {
$this->sections = apply_filters(
'wpsc_settings_presentation_sections',
array(
'default_styles' => array(
'title' => _x( 'Default styling', 'presentation settings', 'wp-e-commerce' ),
'fields' => array(
'default_styles'
),
),
'category_filter' => array(
'title' => _x( 'Category filter', 'presentation settings', 'wp-e-commerce' ),
'fields' => array(
Expand Down Expand Up @@ -127,18 +120,9 @@ private function populate_form_array() {
0 => _x( 'No', 'settings', 'wp-e-commerce' ),
),
),

'default_styles' => array(
'type' => 'checkboxes',
'title' => _x( 'Use the following default stylesheets', 'presentation settings', 'wp-e-commerce' ),
'options' => apply_filters( 'wpsc_default_styles_options', array(
'wpsc-common' => _x( '<code>wpsc-common</code>: Common CSS for all pages', 'default styles options', 'wp-e-commerce' ),
'wpsc-common-inline' => _x( '<code>wpsc-common-inline</code>: Inline CSS for all pages', 'default styles options', 'wp-e-commerce' ),
) ),
),
)
);

$this->extra_fields = array( 'categories_to_filter_custom' );
}
}
}
15 changes: 0 additions & 15 deletions wpsc-components/theme-engine-v2/classes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ private function __construct() {
'login_page_title' => _x( 'Login', 'login page title', 'wp-e-commerce' ),
'password_reminder_page_title' => _x( 'Reset Password', 'password reminder page title', 'wp-e-commerce' ),
'register_page_title' => _x( 'Register', 'register page title', 'wp-e-commerce' ),
'default_styles' => array( 'wpsc-common', 'wpsc-common-inline' ),
)
);
}
Expand All @@ -71,17 +70,3 @@ public function set( $setting, $value ) {
return update_option( 'wpsc_' . $setting, $value );
}
}

// patch for beta sites which uses 'default_style' option
add_filter( 'wpsc_default_settings', '_wpsc_filter_default_styles_setting' );

function _wpsc_filter_default_styles_setting( $settings ) {
// prevent infinite loop
remove_filter( 'wpsc_default_settings', '_wpsc_filter_default_styles_setting' );

if ( ! wpsc_get_option( 'default_style' ) ) {
$settings['default_styles'] = array();
}

return $settings;
}
43 changes: 6 additions & 37 deletions wpsc-components/theme-engine-v2/helpers/css.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,18 @@
<?php

add_action( 'wp_enqueue_scripts' , '_wpsc_te2_enqueue_styles', 1 );
add_filter( 'option_wpsc_default_styles', '_wpsc_te2_filter_default_styles' );

function _wpsc_te2_filter_default_styles( $value ) {

if ( empty( $value ) ) {
return $value;
}

$value = (array) $value;

// if wpsc-common is not enabled, then disable wpsc-common-inline as well
if ( ! in_array( 'wpsc-common', $value ) && in_array( 'wpsc-common-inline', $value ) ) {
$key = array_search( 'wpsc-common-inline', $value );
unset( $value[ $key ] );
}

return $value;
}


function wpsc_is_style_enabled( $style ) {
return in_array( $style, (array) wpsc_get_option( 'default_styles' ) );
}

function wpsc_enqueue_style( $handle ) {
if ( wpsc_is_style_enabled( $handle ) ) {
wp_enqueue_style( $handle );
}
}

function wpsc_add_inline_style( $handle, $output ) {
if ( wpsc_is_style_enabled( $handle . '-inline' ) ) {
wp_add_inline_style( $handle, $output );
}
}

function _wpsc_te2_enqueue_styles() {
wp_register_style( 'wpsc-common', wpsc_locate_asset_uri( 'css/common.css' ), array(), WPSC_VERSION );

do_action( 'wpsc_register_styles' );

wpsc_enqueue_style( 'wpsc-common' );
wpsc_add_inline_style( 'wpsc-common', _wpsc_get_inline_style() );

if ( apply_filters( 'wpsc_add_inline_style', true ) ) {
wp_add_inline_style( 'wpsc-common', _wpsc_get_inline_style() );
}

do_action( 'wpsc_enqueue_styles' );
}

Expand Down Expand Up @@ -83,4 +53,3 @@ function _wpsc_get_inline_style() {
<?php
return ob_get_clean();
}

0 comments on commit 8b1af55

Please sign in to comment.