WordPress.org

Ready to get started?Download WordPress

Forums

Custom quicktag button conflict debugging help please (8 posts)

  1. kaat
    Member
    Posted 8 years ago #

    I find that various combinations of plugin-added custom quicktag buttons disrupt each other's functioning.

    For example, with contact-form's button active, custom buttons before it, like say iimage-browser and ca-cpicker, no longer open their popup windows, or do anything.

    Ditto with photopress and other custom buttons. Perhaps the autors are not implementing their buttons 100% correctly, but how might I investigate myself? I can't see the custom buttons in quicktags.js, so where should I look?

    Thanks.

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    If you download the file 'quicktags.js' the structure is laid out and explained at the top of that file. That may help you to find a problem ?
    If it's just popups, could it be your browser ?

  3. kaat
    Member
    Posted 8 years ago #

    Thanks podz. Yes, I've looked at my live quicktags.js but I don't see code in it specific to some of the custom quicktags, e.g.: ca-cpicker. I don't know Javascript that well - I assume there's either a routine in there to check for which buttons to create, OR, there's another way to interface with quicktags that I'm not aware of. Either way, where would it be looking to know which buttons to create? I figure that's where I might debug.

    I don't believe it's a popup-stopping issue, since I can get all buttons to work as long as their "conflicters" are deactivated.

  4. kaat
    Member
    Posted 8 years ago #

    Okay, I'm onto something now ... my statement "there's another way to interface with quicktags" is correct. The plugins mentioned each add their button using DOM and amending the quciktags elements. And they each do it in quite different ways. So now I just need to try and figure out why one breaks the other ...

  5. kaat
    Member
    Posted 8 years ago #

    Okay, maybe a coder can help ...

    Why does button (B) break button (A)?

    (A) via PHP, as used in ca-cpicker:

    var colorButton = document.createElement('input');
    colorButton.type = 'button';
    colorButton.value = '<?php echo $caption; ?>';
    colorButton.onclick = <?php echo $js_onclick; ?>;
    colorButton.className = 'ed_button';
    colorButton.title = "<?php echo $title; ?>";
    colorButton.id = "<?php echo "ed_{$caption}"; ?>";
    toolbar.appendChild(colorButton);

    (B) via JS, as used in photopress:

    <script language="JavaScript" type="text/javascript">
    <!--
    document.getElementById("quicktags").innerHTML += "<input type=\"button\" class=\"ed_button\" id=\"ed_upload\" value=\"Browse\" onclick=\"return pp_browse_popup();\" /><input type=\"button\" class=\"ed_button\" id=\"ed_upload\" value=\"Upload\" onclick=\"return pp_upload_popup();\" />";
    //-->
    </script>

    Thanks for any help.

  6. kaat
    Member
    Posted 8 years ago #

    Success! My first little wp hack. I just changed (B) above to work in the same way as (A), and now both buttons work. This should work for any quicktags buttons that cause malfunction that were written in the style of (B).

    If anyone wants more detail, speak up!

  7. lcf
    Member
    Posted 8 years ago #

    Yes, I want more details. Please.

  8. Ryan Duff
    Member
    Posted 8 years ago #

    kaat, out of curiosity, did you try to make b work like a also? B seems a bit sloppy. A is the way Owen's Edit Button template is made... here's part...

    function edit_insert_button($caption, $js_onclick, $title = '')
    {
    ?>
    if(toolbar)
    {
    var theButton = document.createElement('input');
    theButton.type = 'button';
    theButton.value = '<?php echo $caption; ?>';
    theButton.onclick = <?php echo $js_onclick; ?>;
    theButton.className = 'ed_button';
    theButton.title = "<?php echo $title; ?>";
    theButton.id = "<?php echo "ed_{$caption}"; ?>";
    toolbar.appendChild(theButton);
    }
    <?php
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.