| 1 | <?php |
|---|
| 2 | /* Plugin Name: Style Formats Test */ |
|---|
| 3 | |
|---|
| 4 | add_filter( 'tiny_mce_before_init', 'styleformatstest_tiny_mce_buttons' ); |
|---|
| 5 | |
|---|
| 6 | function styleformatstest_tiny_mce_buttons( $init ) { |
|---|
| 7 | $init['theme_advanced_buttons2_add_before'] = 'styleselect'; |
|---|
| 8 | |
|---|
| 9 | $style_formats = array( |
|---|
| 10 | array( |
|---|
| 11 | 'title' => 'Button', |
|---|
| 12 | 'inline' => 'a', |
|---|
| 13 | 'classes' => 'btn', |
|---|
| 14 | |
|---|
| 15 | // Adding this will overwrite an existing href attribute. |
|---|
| 16 | |
|---|
| 17 | // Without it, if the style is applied to any text that isn't already wrapped in an <a> tag, |
|---|
| 18 | // it will be wrapped in an <a> tag without an href attribute and can't be updated. |
|---|
| 19 | |
|---|
| 20 | /* |
|---|
| 21 | 'attributes' => array( |
|---|
| 22 | 'href' => '#' |
|---|
| 23 | ) |
|---|
| 24 | */ |
|---|
| 25 | ) |
|---|
| 26 | ); |
|---|
| 27 | |
|---|
| 28 | $init['style_formats'] = json_encode( $style_formats ); |
|---|
| 29 | |
|---|
| 30 | return $init; |
|---|
| 31 | } |
|---|
| 32 | ?> |
|---|