siteorigin / so-css

SiteOrigin CSS is the simple, yet powerful CSS editor for WordPress. It gives you visual controls that let you edit the look and feel of your site in real-time.
https://siteorigin.com/css/
GNU General Public License v2.0
46 stars 10 forks source link

Allow Custom CSS File Editing #161

Closed AlexGStapleton closed 1 year ago

AlexGStapleton commented 2 years ago

Resolves https://github.com/siteorigin/so-css/issues/160

This is done by introducing the siteorigin_custom_css_file filter which allows you to specify the URI for a custom CSS file (will be created if it doesn't exist) and URL for the file for SiteOrigin CSS to load - if the URL is empty, the developer will need to manually load the CSS file.

siteorigin_custom_css_file example::

add_filter( 'siteorigin_custom_css_file', function( $file ) {
    return array(
        'file' => get_template_directory() . '/rtl.css',
        'url' => get_template_directory_uri() . '/rtl.css',
    );
} );

(test using Vantage or any other theme that includes rtl.css)

This PR also introduces siteorigin_css_enqueue_css which controls whether SiteOrigin CSS will enqueue the custom CSS file. It can also be used by the user to force the CSS to output the CSS on the page directly if they would prefer.

add_filter( 'siteorigin_css_enqueue_css', '__return_false' );

AlexGStapleton commented 2 years ago

@Misplon I've updated the PR description and snippet examples.