• Resolved jlgallego99

    (@jlgallego99)


    Hello,

    I am currently developing a plugin that, among other things, defines various shortcodes for people to use. The thing is, these shortcodes have their own style (defined in a .css which is loaded by the plugin). This CSS defines all the necessary classes to style the shortcodes, and that is the “default” style that comes right out of the box when installing the plugin.

    My question is: is there a way for others that use my plugin to extend or modify this style? for example, my shortcodes define a set of red colors, but an user wants to use the exact same styling but with blue colors, maintaining all other styles. I want to do this in a way similar to themes, so that the plugin comes with a default theme, and others can extend that (make a child) and then have the two themes, only for the shortcodes. Is this possible? I don’t specifically need a full response as I know it may be a bit long, it’s enough to know where direction should I go in order to achieve this and what should I look for.

    Thank you for your time

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    If you’ve enqueued your plugin’s stylesheet as is usually done, site owners can add overriding CSS to the Additional CSS section of the customizer or style book. Since styles added this way occur on the page as inline CSS, any rules will have precedence over rules in enqueued external files.

    If you wanted to, you could develop an Additional CSS type of section for your own plugin, separate from the style book or customizer. Instead of directly adding CSS code (or in addition to), there could be a user style dialog where users select preferred styles in a form. When your plugin processes the form, it could save for later output its own inline CSS styling based on user selections. This would save novice users from needing to know how to write CSS code.

    Thread Starter jlgallego99

    (@jlgallego99)

    Hi, thank you for your response, I think I will go with the additional CSS way as I didn’t know that will take precedence over my own stylesheet without discarding it and that’s exactly what I wanted. I also thought the user can define its own CSS file on its WP theme, and the plugin only needs to search for it and enqueue it after the main CSS file. I’ll mark this as resolved

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Is there a way for others to extend or modify the style of plugin’s shortcodes?’ is closed to new replies.