0

In the user profile I provide some wp_editor() for user can insert some extra information the the problem happen

 foreach ($condition as $b) {
                $check = $b.$lang;
                ?>
            <div id="tabs-<?php echo $i ?>">
            <?php wp_editor(get_the_author_meta($b . $lang, $profile_id), $check, $settings = array('textarea_name' => $b . $lang, 'textarea_rows' => 10));
            ?>
            </div>
        <?php

I'm using tab to switch between these wp_editor(), the problem is the 'textarea_rows' => 10 not apply for all wp_editor() it just apply for the first editor() .In research I found out that this bug just happen when I using foreach with wp_editor() to create some editor if i do it manualy like

    <?php wp_editor('', 'test1', $settings = array('textarea_rows' => 10));
 wp_editor('', 'test2', $settings = array('textarea_rows' => 5));
                    ?>

then the wp_editor work nomarlly. Please help why textarea_rows not work properly when using foreach ?

  • Please don't shout. :-) – Pieter Goosen Aug 1 '14 at 12:48
  • Sry i'm new here so forgive me :) – Vu Lam Chi Tai Aug 1 '14 at 14:06
  • LOL, no problem. Use bold words wisely. Welcome to WPSE – Pieter Goosen Aug 1 '14 at 14:12
  • Is the number of textarea_rows equal to the default 20 for everything but the first editor? Can you refer me to your previous research. I just looked at the source of wp_editor() and it seems that your code should have worked as intended. – user27457 Aug 2 '14 at 22:02
  • I may partially understand what is happening - the wp_editor sets its height in two different ways 1) using the value of 'textarea_rows' or 2) using a value from the cookie 'TinyMCE_content_size' which apparently the wp_editor is storing on the client browser. Can you use 'inspect element' and tell me if the textarea element has style.height set in 'px' units. That would come from the cookie. I still don't understand why these two values are not in sync. The cookie has precedence. – user27457 Aug 2 '14 at 23:31
0

I am unable to duplicate your problem.

add_action( 'admin_menu', function () {
    add_menu_page( 'Multiple Editor Test', 'Multiple Editor Test', 'edit_posts',
       'multiple-editor-test', function () {
        foreach ( ['a', 'b', 'c' ] as $i ) {
            wp_editor( '', 'multiple_editor_test_' . $i, [
                'textarea_name' => 'multiple_editor_test_' . $i,
                'textarea_rows' => 2
            ] );
        }
    } );
} );

I tested the above code and it worked perfectly - all editors have 2 rows.

Please try above code and see if it works in your environment. Put it in you functions.php and look for the menu item in the dashboard.

There is something interesting going on here! I really would like to understand this.

If the above works for you try removing the tabs.

  • Thank you for your help Magenta,the code work perfectly it self (wp_editor() + foreach()) but not with tabs exactly with mce's iframe, the 1st iframe can use the 'textarea_rows' value but the other dont,the interesting thing is the rows attribute in the <textarea> is the same for all the editor.I think i will try to fix this because i need these tabs to make userprofile page more clean not alot of editor – Vu Lam Chi Tai Aug 3 '14 at 23:20
0

So here is the alternative way to solve this,i'm using this js:

Query(document).ready(function($) {
      window.onload = function() { // textarea_rows
    var lang = ['en', 'vi'];
    var condition = ['add_', 'edu_', 'res_', 'ref_', 'awa_', 'hob_', 'emp_'];
    for (i = 0; i < condition.length; i++)
        for (j = 0; j < lang.length; j++)
        {

            if (document.getElementById(condition[i] + lang[j] + '_ifr') != undefined)
            {
                document.getElementById(condition[i] + lang[j] + '_ifr').style.height = '300px';
            }
        }
     }
    jQuery("#tabs").tabs();

});

This is just the other way to set the size the main problem is why 'textarea_rows' not affect the other iframe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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