Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

After i add these codes to functions.php:

add_editor_style();

function childtheme_mce_btns2($orig) {
return array('formatselect','styleselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' );
}
add_filter( 'mce_buttons_2', 'childtheme_mce_btns2', 999 );

function childtheme_tiny_mce_before_init( $init_array ) {
$init_array['theme_advanced_styles'] = "box note=box_note;box info=box_info;box warning=box_warning;box download=box_download";
return $init_array;
}
add_filter( 'tiny_mce_before_init', 'childtheme_tiny_mce_before_init' );

I had a style drop down menu in Wordpress Visual Editor with "box note,box info,box warning,box download" options. I created editor-style.css so i got css support for those classes in visual editor.

If i select "box note" style example, wordpress putting it as <p class="box_note"></p> Problem is when i push enter button for line breaking, wordpress putting <p></p> automatically.

Basically how can i change those styles using <div> <span> or anything except <p>?

Update: I create some screenshots for you. This is when i select style from style list: http://www.unsalkorkmaz.com/sorun/sorun1.jpg This is when i push enter button for line breaking: http://www.unsalkorkmaz.com/sorun/sorun2.jpg Wordpress basically creating different <p>

I tried;

remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
remove_filter('the_content', 'convert_smilies');
remove_filter('the_content', 'convert_chars');

before i create this question but its not the solution seems.

Update 2: Well.. I tried shift+enter to line-break and it works! So i dont know what is difference with enter vs shift+enter in TinyMCE but i want shift+enter function as default of enter button.

share|improve this question
    
and.. i found interesting solution in there: tinymce.moxiecode.com/punbb/viewtopic.php?id=3360 last msg –  Ünsal Korkmaz Nov 20 '10 at 23:18
    
This probably is a bug or missing feature in wordpress. From what I write I have the feeling that the editor is just not working in a way you expect it. Probably it's worth to report this to the wordpress hackers list or to open a ticket in trac. –  hakre Nov 20 '10 at 23:23
    
i opened a ticket: core.trac.wordpress.org/ticket/15526 they are working on tinymce these days i see, maybe they will add this too –  Ünsal Korkmaz Nov 20 '10 at 23:43
    
shift+enter and enter is not specific for this editor. It is also that way e.g. in ms word, excel, outlook, livewriter, etc... etc... it is a convention. the difference between a linefeed and a carriage return... this makes the difference. People even requested this change for microsoft word... : tech-archive.net/Archive/Word/microsoft.public.word.conversions/… see also : en.wikipedia.org/wiki/Carriage_return .... –  edelwater Nov 21 '10 at 2:04
    
show 1 more comment

2 Answers 2

up vote 2 down vote accepted

If you always want <br/> instead of <p> for newlines you can change the TinyMCE configuration:

forced_root_block: false,
force_br_newlines: true,
force_p_newlines : false,

I think you cannot do this based on the context (use <br/> when in class="box_note", <p> otherwise), but it is an interesting question for the TinyMCE forum. Shift+Enter is indeed the standard way to differentiate between paragraph and line endings.

share|improve this answer
    
i found those too but when i try to add these as "wordpress" way with filters without editing core, they just didnt work.. can you write wordpress code working? maybe i can found what i am doing wrong –  Ünsal Korkmaz Nov 26 '10 at 21:55
    
basically problem was wordpress adding "" to false/true sections –  Ünsal Korkmaz Nov 26 '10 at 21:56
    
@Ünsal: Indeed, stupid WordPress does not accept non-string values. Unless you trick it. –  Jan Fabry Nov 26 '10 at 22:24
    
i accept your answer mate. thanks a lot. esspecially your comment link answer is the trick –  Ünsal Korkmaz Nov 27 '10 at 3:23
    
@Ünsal: Good news: in WP 3.1 boolean values can pass without being wrapped in quotes, because of an extra check when writing the JS config variable. –  Jan Fabry Nov 27 '10 at 19:47
add comment

Is this your quesion:

  1. http://www.orphicpixel.com/common-wordpress-annoyance/
  2. Line breaks not showing up properly
  3. How can I improve the line break handling in the WYSIWYG editor?
  4. Why is WordPress WYSIWYMG and how do I make it WYSIWYG?

?

share|improve this answer
    
i updated question.. i am talking about TinyMce live edit, those problems are "after" save post seems. Thanks for help btw :) –  Ünsal Korkmaz Nov 20 '10 at 22:16
    
And.. i tried Tiny MCE Advanced with "Stop Removing the <p>and <br/> tags when saving and show them in the HTML editor" –  Ünsal Korkmaz Nov 20 '10 at 22:36
    
and.. update 2: I tried shift+enter to line-break and it works! So i dont know what is difference with enter vs shift+enter in TinyMCE but i want shift+enter function as default of enter button. –  Ünsal Korkmaz Nov 20 '10 at 22:43
    
The problem is that the content replacement is hard-coded into the editor javascript, when you switch editor modes(visual/html) you envoke a replacement script that runs over the content, which can't account for your custom styles.. –  t31os Nov 20 '10 at 23:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.