Skip to content

Commit

Permalink
Enqueue customize css
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancisBoundlessWorpdress committed Feb 6, 2024
1 parent aa5a0f8 commit ba218ef
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions php/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,42 +566,21 @@ public function admin_page() {
public function check_options_and_implement() {
$options = Options::get_options();
if ( $options['loadCustomizerCSSBlockEditor'] ) {
add_action('customize_register', array( $this, 'theme_customize_register' ) );
add_action('enqueue_block_assets', array( $this, 'enqueue_custom_css' ) );
add_action('enqueue_block_editor_assets', array( $this, 'enqueue_custom_css' ), PHP_INT_MAX );

Check failure on line 569 in php/Admin.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 spaces after opening parenthesis; 0 found
add_action('wp_footer', array( $this, 'enqueue_custom_css' ), PHP_INT_MAX );

Check failure on line 570 in php/Admin.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 spaces after opening parenthesis; 0 found
}
}

Check failure on line 572 in php/Admin.php

View workflow job for this annotation

GitHub Actions / WPCS

Line indented incorrectly; expected 1 tabs, found 1 tabs and 1 spaces

/**
* Function theme customizer for custom css
*/

public function theme_customize_register($wp_customize) {
$wp_customize->add_section('custom_css_section', array(
'title' => __('Custom CSS', 'dlx-theme'),
'priority' => 30,
));

$wp_customize->add_setting('custom_css', array(
'default' => '',
'sanitize_callback' => 'wp_kses_post', // Use a proper sanitization function
));

$wp_customize->add_control('custom_css', array(
'label' => __('Custom CSS', 'dlx-theme'),
'section' => 'custom_css_section',
'type' => 'textarea',
));
}

/**
* Function enqueue the custom css from theme customizer using enqueue block assets
*/

Check failure on line 576 in php/Admin.php

View workflow job for this annotation

GitHub Actions / WPCS

There must be no blank lines after the function comment

public function enqueue_custom_css() {
$custom_css = get_theme_mod('custom_css', '');

if ($custom_css) {
wp_add_inline_style('your-theme-stylesheet', $custom_css);
}
$custom_css = wp_get_custom_css();
if (!empty($custom_css)) {

Check failure on line 580 in php/Admin.php

View workflow job for this annotation

GitHub Actions / WPCS

Tabs must be used to indent lines; spaces are not allowed

Check failure on line 580 in php/Admin.php

View workflow job for this annotation

GitHub Actions / WPCS

No space after opening parenthesis is prohibited

Check failure on line 580 in php/Admin.php

View workflow job for this annotation

GitHub Actions / WPCS

Expected 1 space before "!"; 0 found
$theme = wp_get_theme(); // Get the current theme object
$theme_handle = $theme->get_stylesheet();
wp_add_inline_style($theme_handle, $custom_css);
}
}
}

0 comments on commit ba218ef

Please sign in to comment.