cleverness / widget-css-classes Goto Github PK
View Code? Open in Web Editor NEWWordPress Plugin to add CSS classes to Widgets
License: GNU General Public License v3.0
WordPress Plugin to add CSS classes to Widgets
License: GNU General Public License v3.0
Default capability: edit_theme_options
Option to change for
Hi, I'd like to be able to import widget class settings via theme level.
Can you provide an example of how this might be done and still allow the user to modify the settings? Would you recommend attaching this to after_theme_setup? Thanks!
update_option( 'WCSSC_options', $options );
Predefined widget class groups / radio buttons.
I have a set of classes that affect different CSS properties, and would like them to be grouped since they are mutually exclusive:
Group 1 ( text color )
Group 2 ( background color )
Group 3 ( text alignment )
It would be great to have 2 additional features with predefined classes:
If I could define Groups in my $theme_classes array like so:
add_filter( 'widget_css_classes_set_settings', 'mytheme_css_classes_default_settings' );
function mytheme_css_classes_default_settings( $settings ) {
$theme_classes = [
'group_1' => [
'background-color--gray',
'background-color--white',
'background-color--black',
],
'group_2' => [
'text-color--gray',
'text-color--white',
'text-color--black',
],
'group_3' => [
'align--left',
'align--right',
'align--center'
],
];
// Append your classes.
$settings['defined_classes'] = array_merge( $settings['defined_classes'], $theme_classes );
// Or Prepend your classes.
$settings['defined_classes'] = array_merge( $theme_classes, $settings['defined_classes'] );
// Allways remove possible duplicates
$settings['defined_classes'] = array_unique( $settings['defined_classes'] );
// And return modified settings array
return $settings;
}
Then on the Widget form, the options within each group would be converted to an array of radio buttons ( or select options ). This would help prevent users from setting more than one background color, etc. They would be able to set 1 background color, 1 text color, 1 alignment, and not have to worry about setting conflicting styles ( which could have unpredictable results ).
A further enhancement could be to add titles to each group:
$theme_classes = [
'group_1' => [
'title' => "Background Color",
"styles" => [
'background-color--gray',
'background-color--white',
'background-color--black',
],
],
];
And to make it even nicer for users, the classes themselves could be given labels:
$theme_classes = [
'group_1' => [
'title' => "Background Color",
"styles" => [
'background-color--gray' => 'Gray',
'background-color--white' => 'White,
'background-color--black' => 'Black',
],
],
];
I think this would be a kick ass addition. This feature could even be exposed in the UI.
Related: https://wordpress.org/support/topic/consider-wrapping-in-div-with-clear-both/
Add clear: both;
The plugin is not working when I add widgets in Storefront Mega Menu but works with the widgets in the sidebar.
Currently the classes are simply prepended to the class
attribute with a preg_replace
.
I've created a method in my order (similar) plugin that can handle duplicates and both qouble and single quotes.
See: https://github.com/JoryHogeveen/genesis-widget-column-classes/blob/1.2.2/genesis-widget-column-classes.php#L389-L458
Lets patch it over along with it's unit tests!
When using the widget_content
filter option the Widget Logic compatibility isn't working anymore.
Custom classes can be added to widgets.
Custom classes (text or predefined) do not get written out to html, but are displayed in Widget UI. Even custom widget css classes built into theme no longer work. The standard ones do get written out to html successfully (widget-first, widget-last, etc)
Since the code relies on properly registered sidebars with the class
and id
parameters set it might be a good idea to add an option to let this plugin try and fix the invalid ones.
If the before_widget
and after_widget
content isn't correct we can add a wrapper div with only this plugin's data.
Only add this as an option in the setting page, not by default.
Related: https://wordpress.org/support/topic/prepend-class-names-option/
Currently it's possible to sort the predefined classes in the settings page.
Related topic: https://wordpress.org/support/topic/feature-request-add-support-for-siteorigin-panels/
Not sure whether this is something this plugin should do or if it's better that the SO Panels plugin adds compatibility with the dynamic_sidebar_params
filter..
get_the_ID()
throws a notice here when no post is present, i.e. on searches without a result.
Notice: Trying to get property of non-object in /โฆ/wp-includes/post-template.php on line 29
See #37
v1.5.4 prevents the warning but might be an idea to support these widgets as well.
Good morning!
PHP Notice: Undefined index: classes in /home/unlocked/website/html/static/plugins/widget-css-classes/includes/widget-css-classes.class.php on line 104
Could you check whether it is empty?
https://github.com/cleverness/widget-css-classes/blob/master/includes/widget-css-classes.class.php#L104
These files aren't needed anymore.
We should copy it to translate.wordpress.org and remove the files once the translations are accepted.
Existing languages
Available on wp.org and removed in plugin are marked as complete
https://translate.wordpress.org/projects/wp-plugins/widget-css-classes
Report: https://wordpress.org/support/topic/plugin-spanish-translation/#post-9427244
The first
, last
, odd
, even
and number
widgets are translated which seems a little weird. Translations are normally for text only, not for code.
Since this plugin has 90k+ users we can't just remove it. I'd say make it an option so the users can turn it off/on.
On a fresh install: Don't enable it.
On an update with the classes enabled: Enable it to prevent issues.
@cleverness
I'd like to hear your thoughts on the ideas below for the readme file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.