Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_editor_style();
- add_filter( 'mce_buttons_2', 'wpmidia_mce_buttons_2' );
- function wpmidia_mce_buttons_2( $buttons ) {
- array_unshift( $buttons, 'styleselect' );
- return $buttons;
- }
- add_filter( 'tiny_mce_before_init', 'wpmidia_mce_before_init' );
- function wpmidia_mce_before_init( $settings ) {
- $style_formats = array(
- array(
- 'title' => 'Button',
- 'selector' => 'a',
- 'classes' => 'button'
- ),
- array(
- 'title' => 'Callout Box',
- 'block' => 'div',
- 'classes' => 'callout',
- 'wrapper' => true
- ),
- array(
- 'title' => 'Bold Red Text',
- 'inline' => 'span',
- 'styles' => array(
- 'color' => '#f00',
- 'fontWeight' => 'bold'
- )
- )
- );
- $settings['style_formats'] = json_encode( $style_formats );
- return $settings;
- }
- /* Style Format Options
- title [required] label for this dropdown item
- selector|block|inline selector limits the style to a specific HTML
- [required] tag, and will apply the style to an existing tag
- instead of creating one
- block creates a new block-level element with the
- style applied, and will replace the existing block
- element around the cursor
- inline creates a new inline element with the style
- applied, and will wrap whatever is selected in the
- editor, not replacing any tags
- classes [optional] space-separated list of classes to apply to the
- element
- styles [optional] array of inline styles to apply to the element
- (two-word attributes, like font-weight, are written
- in Javascript-friendly camel case: fontWeight)
- attributes [optional] assigns attributes to the element (same syntax as styles)
- wrapper [optional, if set to true, creates a new block-level element
- default = false] around any selected block-level elements
- exact [optional, disables the “merge similar styles” feature, needed
- default = false] for some CSS inheritance issues
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement