Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Styles still not displaying in Format dropdown within Unyson wp-editor. #2454

Open
noesteijver opened this issue Mar 15, 2017 · 7 comments

Comments

@noesteijver
Copy link

This problem was previously mentioned in this issue: #1932

I thought my problem was fixed, but the problem is still (or again) occuring.

When I read the comments above, I can't seem to find a 'real solution'. Everything that I've seen above, I've tried and isn't working for me now.

Does it have to do with the location of the code? Mine is in my functions.php file, at the bottom.

I tried debugging this by printing the $init_array, this gives back the array of the TinyMCE editor which does contain the added styles. But for some reason this array doesn't reach the TinyMCE display function or something like that.

Anyone else still having problems with this?

@noesteijver
Copy link
Author

I've tried fixing this on my own, but I can't really find a solution/workaround..

Anybody else experiencing the same behaviour and found a solution?

@yura-x
Copy link
Contributor

yura-x commented Apr 20, 2017

I also have same issue.
I've add following code at the end of "functions.php" in "twentyseventeen" theme (took it from codex and from github)

if ( ! function_exists( '_filter_mce_theme_format_insert_button' ) ) :
	function _filter_mce_theme_format_insert_button( $buttons ) {
		array_unshift( $buttons, 'styleselect' );

		return $buttons;
	} //_filter_mce_theme_format_insert_button()
endif;
add_filter( 'mce_buttons_2', '_filter_mce_theme_format_insert_button' );

// 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
		array(  
			'title' => '.translation',  
			'block' => 'blockquote',  
			'classes' => 'translation',
			'wrapper' => true,
			
		),  
		array(  
			'title' => '.rtl',  
			'block' => 'blockquote',  
			'classes' => 'rtl',
			'wrapper' => true,
		),
		array(  
			'title' => '.ltr',  
			'block' => 'blockquote',  
			'classes' => 'ltr',
			'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', 1 );

It works in default editor: http://prntscr.com/eynkqm
But not in "Text block" shortcode: http://prntscr.com/eynlfa

I'm using WordPress Version 4.7.3 and Unyson Version 2.6.16

@andreiglingeanu
Copy link
Collaborator

andreiglingeanu commented May 4, 2017

Hey @yura-x!

I just tried your code snippet and it worked, both for Text Block and for default editor.

I'm on Unyson 2.6.16 too and WordPress 4.7.4.

Can someone give proper reproduction steps for that problem?

@danyj
Copy link
Contributor

danyj commented May 19, 2017

4.7.5 does not work anymore , @andreiglingeanu testing why , it worked until latest update

@danyj
Copy link
Contributor

danyj commented May 19, 2017

they are in style_format but not displaying in wp-editor option type
screenshot_1

this is default post editor
screenshot_2

digging

@danyj
Copy link
Contributor

danyj commented May 19, 2017

These dont see the tiny_mce_before_init filter settings modifciations and coming back without anything custom

https://github.com/ThemeFuse/Unyson/blob/master/framework/includes/option-types/wp-editor/includes/class-fw-wp-editor-settings.php#L257

https://github.com/ThemeFuse/Unyson/blob/master/framework/includes/option-types/wp-editor/includes/class-fw-wp-editor-settings.php#L148-L162

compare this to image above and you will see that 3 keys are missing, so seems like all the attach_filters() fires to early all of a sudden.

screenshot_3

@danyj
Copy link
Contributor

danyj commented May 19, 2017

@andreiglingeanu , found the issue ,

on php 5.6.5 custom styles are not visible , on 7.x they are there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants