• Resolved fidoboy

    (@fidoboy)


    When cutom CSS rules are being added with the plugin editor, they are not rendered on frontpage correctly. There are multiple issues:

    • If there is multiple selectors, separated by commas, then the html.wp-dark-mode-active part should be added on each one, not only the first one. Right now it’s being added to the first only. So there is a bug.
    • When there are selectors using the > symbol (greater than) it’s being displayed encoded on frontend, so it’s not working. Where the symbol > should appear, there is a > There is another bug.

    Can you please solve these issues?

    • This topic was modified 1 year ago by fidoboy.
    • This topic was modified 1 year ago by fidoboy.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter fidoboy

    (@fidoboy)

    Problem is with class FixCSS. The code there is wrong. It doesn’t consider if there are multiple selectors for the same section between curly braces. So when there is something like this:

    .selector1, .selector2, .selector3 {color:#000;margin:0 5px}

    it fails because it only adds the new custom selector to the first one, in this case .selector1. This should be fixed.

    Thread Starter fidoboy

    (@fidoboy)

    This is the fixed function:

    public function add_selector( $css, $custom_selector ) {
            $css = $this->minify( $css );
            // Split the CSS string into an array of individual rules.
            $css_rules = preg_split('/}/', $css);
            // Initialize the new CSS string.
            $new_css = '';
            // Loop through each rule.
            foreach ( $css_rules as $rule ) {
                // Split the rule into the selector and properties.
                $parts = preg_split('/{/', $rule, 2);
                // If the rule has a selector and properties.
                if ( count($parts) == 2 ) {
                    // Check if $parts[0] has multiple selectors
                    if (strpos($parts[0], ",") !== false) {
                        $selectors = preg_split('/,/', $parts[0]);
                        $count = count($selectors);
                        foreach ( $selectors as $selector ) {
                            // Add the selector to the new CSS string.
                            $new_css .= $custom_selector . ' ' . trim($selector);
                            // Add comma only if it's not the last one
                            if (--$count > 0) $new_css .= ", ";
                        }
                        // Add newline and curly brace at end
                        $new_css .= " {\n";
                    } else {
                        // Add the selector to the new CSS string, followed by a newline.
                        $new_css .= $custom_selector . ' ' . trim($parts[0]) . " {\n";
                    }
                    // Add the properties to the new CSS string, indented by one tab.
                    $new_css .= "\t" . trim($parts[1]) . "\n";
                    // Add the closing curly brace for the rule.
                    $new_css .= "}\n";
                }
            }
            $new_css = $this->minify( $new_css );
            return $new_css;
        }

    • This reply was modified 1 year ago by fidoboy.
    Plugin Support Md. Ibrahim Khalil

    (@mdibrahimk48)

    Hi,

    Sorry for the inconvenience. We would like to inform you that “Custom CSS” is a premium feature of our plugin. According to the forum guidelines, support for commercial products is not permitted in the forums. To get support for the premium version of our plugin, kindly contact us through our official support channel.

    Thanks for sharing functions! Have a nice day!

    Plugin Support Md. Ibrahim Khalil

    (@mdibrahimk48)

    Hi there,

    A big thanks for letting us know about this bug. We appreciate your input and the time you took to give us a solution.

    Our team is cooking a completely revamped version of the plugin. It will bring plenty of enhancements and fixes many issues.
    Stay tuned! A big thanks for sticking with us.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘There is a bug rendering the custom CSS rules’ is closed to new replies.