Custom Styles doesn’t work
-
Hello.
I would like to replace default formats styles with my custom styles. I add code to functions.php and I see this class names in dropdown format, but when I chose them, nothing happend – tags are not replaced. I don’t what is wrong. I check ‘create css classes menu’, I remove cached…thank you.
My code:/* personalizacja TinyMCE WYSIWYG */ function wpb_mce_buttons_2($buttons) { array_unshift($buttons, 'styleselect'); return $buttons; } add_filter('mce_buttons_2', 'wpb_mce_buttons_2'); /* * Callback function to filter the MCE settings */ function my_mce_before_init_insert_formats( $init_array ) { // Define the style_formats array $style_formats = array( /* * Each array child is a format with it's own settings * Notice that each array has title, block, classes, and wrapper arguments * Title is the label which will be visible in Formats menu * Block defines whether it is a span, div, selector, or inline style * Classes allows you to define CSS classes * Wrapper whether or not to add a new block-level element around any selected elements */ array( 'title' => 'Podtytu? do sekcji H4', 'block' => 'h4', 'classes' => 'podtytul-sekcji-h4', 'wrapper' => true, ), array( 'title' => '?ródtytu? do sekcji H5', 'block' => 'h5', 'classes' => 'srodtytul-sekcji-h5', 'wrapper' => true, ), array( 'title' => 'Tytu? zdj?cia', 'block' => 'h6', 'classes' => 'tytul-zdjecia', 'wrapper' => true, ), array( 'title' => 'Tytu? tabelki', 'block' => 'h6', 'classes' => 'tytul-tabelki', 'wrapper' => true, ), array( 'title' => '?ród?o', 'block' => 'h6', 'classes' => 'zrodlo', 'wrapper' => true, ), array( 'title' => 'Tekst wyró?niony', 'block' => 'blockqoute', 'classes' => 'tekst-wyrozniony', 'wrapper' => true, ), ); // Insert the array, JSON ENCODED, into 'style_formats' $init_array['style_formats'] = json_encode( $style_formats ); return $init_array; } // Attach callback to 'tiny_mce_before_init' add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' ); // Add custom_editor_style to theme function my_theme_add_editor_styles() { add_editor_style( 'css/custom-editor-style.css' ); } add_action( 'init', 'my_theme_add_editor_styles' );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Styles doesn’t work’ is closed to new replies.