-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Edi Amin edited this page Oct 4, 2025
·
4 revisions
Hello!
Welcome to the CSS Class Manager wiki!
Use css_class_manager_filtered_class_names
filter to add class names from a PHP file.
Example:
<?php
use CSSClassManager\ClassPreset;
function plugin_prefix_add_css_classes( $class_names ) {
$additional_css_names = [
new ClassPreset( 'flex' ),
new ClassPreset( 'hidden', __( 'Hide element', 'textdomain' ) ),
];
return array_merge( $class_names, $additional_css_names );
}
add_filter( 'css_class_manager_filtered_class_names', 'plugin_prefix_add_css_classes' );
Use the css_class_manager_theme_classes_css
filter to add your CSS from which you want to extract the class names and show them in the Class names dropdown list.
Example:
<?php
function plugin_prefix_add_custom_css( $css ) {
// Additional CSS code as a string.
$custom_css = '
.custom-class {
background-color: #f0f0f0;
color: #333;
padding: 10px;
border-radius: 5px;
}
.another-class {
font-size: 16px;
font-weight: bold;
text-align: center;
}';
// Load CSS from a file.
$css_from_file = file_get_contents( __DIR__ . '/my-custom-css.css' );
// Load CSS from a saved option. Usefule to get any custom CSS saved by any other plugin.
$css_from_saved_option = get_option( 'my_custom_css_option', '' );
// Add styles from anywhere you want.
return $css . $custom_css . $css_from_file . $css_from_saved_option;
}
add_filter( 'css_class_manager_theme_classes_css', 'plugin_prefix_add_custom_css' );