This code does not work because we can not have access to the admin.
I found another code on : http://www.wpexplorer.com/wordpress-tinymce-tweaks/
// Add new styles to the TinyMCE "formats" menu dropdown
if ( ! function_exists( 'wpex_styles_dropdown' ) ) {
function wpex_styles_dropdown( $settings ) {
// Create array of new styles
$new_styles = array(
array(
'title' => __( 'Custom Styles', 'wpex' ),
'items' => array(
array(
'title' => __('Theme Button','wpex'),
'selector' => 'a',
'classes' => 'theme-button'
),
array(
'title' => __('Highlight','wpex'),
'inline' => 'span',
'classes' => 'text-highlight',
),
),
),
);
// Merge old & new styles
$settings['style_formats_merge'] = true;
// Add new styles
$settings['style_formats'] = json_encode( $new_styles );
// Return New Settings
return $settings;
}
}
add_filter( 'tiny_mce_before_init', 'wpex_styles_dropdown' );
The custom style menu appears fine but I do not know where it should define css style so that they appear in the style submenu.
Attachments:
You must be
logged in to view attached files.