Autor Zpráva
piiiiiiiip
Profil
Dobrý den.
Vytvořil jsem si jednoduchý shourbox WordPress plugin na WP 3.8.4 a fungoval mi perfektně. Když jsem ale wp upgradoval na verzi 3.9.2 tak už nefunguje (js část). Plugin se skládá ze dvou souborů a tohle jsou jejich js části:
shoutbox.php
<script type="text/javascript">
                var plugin_path = "<?php echo $plugin_path; ?>";
                var reload_time = <?php echo $options['shoutbox_reload'];?>;
                jQuery(function($){sb_reload();
                                   $("div#sb_messages").mouseover(function(){
                                       $("span#sb_status").html("")});
                                   $("input#sb_addmessage").click(function(){
                                       var b=$("input#sb_name").val();
                                       var d=$("textarea#sb_message").val();
                                       $("input#sb_addmessage").attr("disabled","disabled");
                                       var e="&";$.ajax({
                                           type:"POST",
                                           url:plugin_path+"shoutbox_process.php",
                                           cache:false,
                                           data:"op=add"+e+"user="+b+e+"message="+d+e,
                                           success:function(a){
                                           $("div#sb_messages").prepend(a);
$("div#sb_new_message").show("slow");
                                          
                                           $("textarea#sb_message").val("");
                                           $("input#sb_addmessage").removeAttr("disabled")                                           
                                       },
                                                        error:function(a){$("span#sb_status").html("Request error")}})});
    $("img#sb_showsmiles").click(function(){
        $("div#sb_smiles").fadeIn("slow")
    })
    $("a#sb_closesmiles").click(function(){

        $("div#sb_smiles").fadeOut("slow")
        })
    });
    function add_item(a){
        var b=jQuery("textarea#sb_message").val()+a;jQuery("textarea#sb_message").val(b)
    }
    function sb_reload(){
        jQuery("div#sb_messages").load(plugin_path+"shoutbox_process.php?"+new Date().getTime());
        jQuery("span#sb_status").ajaxSend(function(a,b,c){
            jQuery(this).html("Reloading..").show()
        });
        jQuery("div#sb_messages").ajaxError(function(a,b,c){
            jQuery(this).html("<div class='error_message' align='center'>Chyba</div>");
            jQuery("span#sb_status").fadeOut("slow")
        });
        jQuery("span#sb_status").ajaxSuccess(function(a,b,c){
            jQuery(this).fadeOut("slow")
        });
        setTimeout("sb_reload()",reload_time*1000)
    }
    function delete_message(c){
        if(!confirm("Opravdu chcete odstranit tuto zprávu?"))return false;
        var d="&";
        jQuery.ajax({
            type:"POST",
            url:plugin_path+"shoutbox_process.php",
            cache:false,
            data:"op=delete"+d+"m_id="+c,
            success:function(a,b){
            if(parseInt(a)>0)
            jQuery('div#sb_message_'+a).hide('slow');
            jQuery('textarea#sb_message').val('');
        }
                    })
    }
</script>
shoutboc_process.php
<script>
    $(function(){
        //Call the edit function
        $('.edit').click(function(){
            // Get the id name
            var element=this;
            var id=element.id;

            //New text box with id and name according to position
            var textboxs='<textarea name="'+id+'" id="text'+id+'" class="textbox"></textarea>'
            
            //Place textbox in page to enter value 
            $('#'+id).html('').html(textboxs);
            //Set value of hidden field
            $('#hidden').val(id);

            //Focus the newly created textbox
            $('#text'+id).focus();
        });

        // Even to save the data - When user clicks out side of textbox

        $('.edit').focusout(function(){
            //Get the value of hidden field (Currently editing field)
            var field = $('#hidden').val();

            //get the value on text box (New value entred by user)
        var value = $('#text'+field).val();
                var testid = "";
    
                var opp = "edit";
            //Update if the value in not empty
            if(value!='')
            {
                //Post to a php file - To update at backend

                $.post(
                plugin_path+'shoutbox_process.php',
                {

                    op:opp,action:this.id,value:value,
                }, 
                function(response){
                }
            );
    

            
                //Set the data attribue with new value
                $(this).html(value).attr('data',value);
                
            }

            // If user exists with out making any changs
            $(".edit").each(function(){
            //set the default value
            $(this).text($(this).attr('data'));
            }); 

        });
    })
</script>
echo"<div class='edit' id='$m_id' data='$m_text' title='Click to edit'>$m_text</div>\n";                

Už si s tím vážně nevím rady a potřeboval bych poradit.

Vaše odpověď

Mohlo by se hodit

Neumíte-li správně určit příčinu chyby, vkládejte odkazy na živé ukázky.
Užíváte-li nějakou cizí knihovnu, ukažte odpovídajícím, kde jste ji vzali.

Užitečné odkazy:

Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0