WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Gallery Shortcode problems with multiple tinyMCE editors in 3.5 (2 posts)

  1. xsonic
    Member
    Posted 1 year ago #

    If you have a metabox with a richtext editor in it, inserted galleries get mixed up.

    If I insert a gallery in the main editor, the edit and delete buttons won't work.
    If I insert a gallery in the metabox-editor, it all works as expected.

    If there is a gallery in the main-editor AND in the metabox-editor, a click on the edit-icon on the main-editor opens the gallery-modal with the settings of the gallery from the metabox-editor.

    Steps to reproduce:
    Insert this code into functions.php and then insert a gallery in the editor:

    //call our hooks
    add_action('admin_init', 'yourplugin_metabox');
    add_action('save_post', 'yourplugin_metabox_save');
    
    //return the custom blurb
    function yourplugin_secondary_blurb($id = '') {
      $id = (empty($id)) ? get_the_ID() : intval($id);
      $custom = get_post_custom($id);
      return @$custom['secondary_blurb'][0];
    }
    
    // add metabox to 'page' post type
    function yourplugin_metabox() {
      global $hys;
      if ( current_user_can('manage_options') )
       add_meta_box( 'secondary_blurb_box_id',
       __('Secondary Blurb', 'yourplugin_sec_blurb' ),
       'secondary_blurb_box', 'page' );
    }
    
    //secondary blurb metabox HTML
    function secondary_blurb_box() {
      global $post;
      echo '<input type="hidden" name="yourplugin_noncename"'.
       ' id="yourplugin_noncename" value="' .
      wp_create_nonce( 'aunqiueyourpluginid' ) . '" />
      <style type="text/css">
      #ed_toolbar { display:none; }
      </style><div>';
      the_editor(yourplugin_secondary_blurb(), "secondary_blurb");
      echo "</div>";
    }
    
    // save the secondary blurb value. verify and permission
    function yourplugin_metabox_save( $post_id ) {
      global $hys;
      if (!isset($_POST['yourplugin_noncename']) ||
       !wp_verify_nonce( $_POST['yourplugin_noncename'],
       'aunqiueyourpluginid' ))
         return $post_id;
      if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
        return $post_id;
      if ( 'page' == $_POST['post_type'] ) {
        if ( !current_user_can( 'edit_page', $post_id ) )
          return $post_id;
      }
      //save the secondary blurb text if applic..
      if (isset($_POST['secondary_blurb'])) {
        update_post_meta($post_id,'secondary_blurb',$_POST['secondary_blurb']) or
        add_post_meta($post_id,'secondary_blurb',$_POST['secondary_blurb']);
      }
    }

    Same misbehaviour with meta-box plugins like Rilwis Metabox

    NOTE:
    This misbehaviour didn't appear in 3.5 - Beta 3

  2. Helen Hou-Sandi
    WordPress Dev
    Posted 1 year ago #

    I'm actually able to reproduce this behavior in 3.4.2, whether or not both editors have galleries. It happens in a pretty specific series of events, so I would guess that it was there in 3.5b3, just unnoticed.

    It looks like the buttons can appear overlaid on the wrong editor, and if you go and click those buttons that appeared in the wrong place, you get the set associated with the placeholder that you first clicked. 3.4.2 doesn't show anything differently in the media modal, so it's not noticeably wrong (although I presume it would actually change settings for the wrong one), but 3.5 does show differently, so it's much more noticeable.

    I've written up and submitted a Trac ticket for it: http://core.trac.wordpress.org/ticket/22785. For the time being, double-clicking the placeholder you wanted seems to do the trick consistently.

Topic Closed

This topic has been closed to new replies.

About this Topic