Just created this topic so I can move a post from a different topic here
-
textformats issues and more
-
@mariusjopen I am replying to this topic in the hope it is the same issue?
I have just purchased and installed LayGridder on an existing website, and it works fine.
However, when I try to use a text format I only see the old, existing text formats of the website, rather than my newly added LayGridder text formats.
Do I need to add the source code you mention above somewhere? And if so, is there a more detailed, step-by-step description for someone less savvy, like myself?
This is what appears currently when I try to use formats (all formats being the old, existing ones...)
And this is one of my new LayGridder text formats that doesn't appear..
-
hey @billykioso
- The text formats I create don't appear in the formats button.
I'm guessing you have inserted your own formats via your theme's code.
This filter is used to pass in custom textformats using code:
https://developer.wordpress.org/reference/hooks/tiny_mce_before_init/The filter "tiny_mce_before_init" passes in an array. That array has a ['style_formats'] array key that we add LayGridder's textformats to.
Like this:
$in['style_formats'] = json_encode( $style_formats ); return $in;
In case you use that filter too or a similar one, in your theme's code you'd need to do something like:
$in['style_formats'] = array_merge( $in['style_formats'], $my_formats );
This way you'd merge your style formats and LayGridder's without replacing LayGridder's formats.
Here's some example code of how your code could look:
function my_formats($in){ $myformats = array(…); $in['style_formats'] = array_merge( $in['style_formats'], $my_formats ); return $in; } // use priority 11 to make sure this is run after lagridder's function add_filter( 'tiny_mce_before_init', 'my_formats', 11, 1 );