Skip to content

Commit 1b91b0e

Browse files
author
cristian-ungureanu
authored
Merge pull request #869 from Codeinwp/feature/855
Improve CSS performance
2 parents 4f298fd + 5ed1171 commit 1b91b0e

File tree

3 files changed

+17
-47
lines changed

3 files changed

+17
-47
lines changed

classes/Visualizer/Module.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -604,30 +604,29 @@ protected function load_chart_class_name( $chart_id ) {
604604
protected function get_inline_custom_css( $id, $settings ) {
605605
$css = '';
606606

607-
$arguments = array( '', $settings );
608-
if ( ! isset( $settings['customcss'] ) ) {
609-
return $arguments;
610-
}
611-
612607
$classes = array();
613608
$css = '<style type="text/css" name="visualizer-custom-css" id="customcss-' . $id . '">';
614-
foreach ( $settings['customcss'] as $name => $element ) {
615-
$attributes = array();
616-
foreach ( $element as $property => $value ) {
617-
$attributes[] = $this->handle_css_property( $property, $value );
618-
}
619-
$class_name = $id . $name;
620-
$properties = implode( ' !important; ', array_filter( $attributes ) );
621-
if ( ! empty( $properties ) ) {
622-
$css .= '.' . $class_name . ' {' . $properties . ' !important;}';
623-
$classes[ $name ] = $class_name;
609+
if ( ! empty( $settings['customcss'] ) ) {
610+
foreach ( $settings['customcss'] as $name => $element ) {
611+
$attributes = array();
612+
foreach ( $element as $property => $value ) {
613+
$attributes[] = $this->handle_css_property( $property, $value );
614+
}
615+
$class_name = $id . $name;
616+
$properties = implode( ' !important; ', array_filter( $attributes ) );
617+
if ( ! empty( $properties ) ) {
618+
$css .= '.' . $class_name . ' {' . $properties . ' !important;}';
619+
$classes[ $name ] = $class_name;
620+
}
624621
}
622+
$settings['cssClassNames'] = $classes;
625623
}
626-
$css .= '</style>';
627624

628-
$settings['cssClassNames'] = $classes;
625+
$img_path = VISUALIZER_ABSURL . 'images';
626+
$css .= ".locker,.locker-loader{position:absolute;top:0;left:0;width:100%;height:100%}.locker{z-index:1000;opacity:.8;background-color:#fff;-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)\";filter:alpha(opacity=80)}.locker-loader{z-index:1001;background:url($img_path/ajax-loader.gif) no-repeat center center}.dt-button{display:none!important}";
627+
$css .= '</style>';
629628

630-
$arguments = array( $css, $settings );
629+
$arguments = array( $css, $settings );
631630
apply_filters_ref_array( 'visualizer_inline_css', array( &$arguments ) );
632631

633632
return $arguments;

classes/Visualizer/Module/Frontend.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ public function perform_action( WP_REST_Request $params ) {
244244
*/
245245
public function enqueueScripts() {
246246
wp_register_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
247-
wp_register_style( 'visualizer-front', VISUALIZER_ABSURL . 'css/front.css', array(), Visualizer_Plugin::VERSION );
248247
do_action( 'visualizer_pro_frontend_load_resources' );
249248
}
250249

@@ -435,7 +434,6 @@ public function renderChart( $atts ) {
435434
)
436435
);
437436
}
438-
wp_enqueue_style( 'visualizer-front' );
439437

440438
// return placeholder div
441439
return $actions_div . '<div id="' . $id . '"' . $this->getHtmlAttributes( $attributes ) . '></div>' . $this->addSchema( $chart->ID );

css/front.css

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)