I am trying to:
Add a custom button or style select field to the WYSIWYG editor using either code in the functions.php files or via the TinyMCE Custom Styles plugin.
Link to a page where the issue can be seen:
I expected to see:
I can see the custom style and/or button in the WYSIWYG editor for a custom field but not a custom field inside of a repeatable field group.
Instead, I got:
Repeatable Field Groups are under the hood Fields attached to a post each repeatable item, so that could be the reason you cannot see the quick tag on the WYSIWYG on RFG (Repeatable Field Groups).
I don't see the custom code you apply, and could help only limitedly with that, since adding quick tags to Toolset Fields is not within the supported things Toolset does or offers, however, it might also be due to the particular aspect of that WYSIWYG, you surely noticed it has not the same quick tags as WordPress Main editor does or other WYSIWYG do, that is because it's customized/adapted to the repeatable field groups.
I assume your code/plugin adds the quick tag by post/post type where the WYSIWYG is seen, in an RFG that would not be the edited post (or type), but the slug of the Repeatable Field Group, as a post type.
Please let me know if you could solve the issue with this information
Note, natively this is not supported in the Toolset RFG WYSIWYG, this means, that it may change at any time and then, eventual code hooking to it might require some updates as well.
Beda,
Thanks for the reply. We've had success using the TinyMCE Custom Styles plugin with other sites but as you mentioned, hooking into the WYSIWYG editor within a RFG is the issue.
When using the plugin, we add a Custom Styles option to the Formats menu in the editor. By default, the Formats menu is disabled for the editor in WP. With the plugin enabled and our settings installed, we see the Formats menu in all WYSIWYG editors (including the RFG ones) however our Custom Styles option is in the RFG and the options are different (see images attached).
I've also tried to add code to the functions.php file to customize the editor. Again, this works fine for any normal custom field using WYSIWYG but not for the RFG versions.
// Callback function to insert 'styleselect' into the $buttons array
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
// Register our callback to the appropriate filter
add_filter( 'mce_buttons_2', 'my_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
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' );
Do you have any insight as to how to manipulate the Formats menu within a RFG WYSIWYG editor?
Please can you send me that Plugin so I can test with it?
This looks like a compatibility issue, since we do not support or offer any integration for such features.
As mentioned, Toolset WYSIWYG Field in Repeatable Field Groups is not a "normal" Meta Field. It might need some work on this to support it, I will see what we can do.