WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Plugin not working when moved to new site (5 posts)

  1. jrm213
    Member
    Posted 6 years ago #

    Hi,

    I wrote a custom plugin and I created a test wordpress installation to develop it on. I got it working and moved it to my live site. It displays just fine using my custom template files for the pages I needed. But all of the administration functionality I created is not working properly.

    They are on the same version of wordpress so I don't understand what is going on.

    When I activate the plugin it correctly creates the database tables, makes an administration menu for the plugin under options, and when I click the administration menu it displays the administration screen.

    However, when I try to add new records through the admin interface it fails. I don't understand what is going wrong.

    It doesn't throw an error in javascript and my webserver error log is empty. Usually if I have a php error it is listed in the error log. The browser makes the call to admin-ajax.php but has a response of -1.

    I am running the database inserts and deletes through wp_ajax

    in the admin page the submit button is this:
    It works in the test setup, but does not work on my live site. Any help is greatly appreciated, it is driving me up the wall.

  2. jrm213
    Member
    Posted 6 years ago #

    It didn't seem to want to let me post with this in the original so here is the rest of what I wanted to post:

    <input id="add_loc_submit" type="button" onclick="sec_add_new_loc()" value="Add Location" name="add_loc_submit"/>
    
    in my admin page I have:
    this javascript:
    function sec_add_new_loc()
    {
    var locname = document.getElementById("sec_add_loc").value;
    
    var mysack = new sack("<?php bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php" );
    mysack.execute = 1;
    mysack.method = 'POST';
    mysack.setVar( "action", "sec_add_new_location" );
    mysack.setVar( "new_loc", locname);
    
    mysack.onError = function() { alert('Error Contacting Server' )};
    
    mysack.runAJAX();
    }
    
    and in the php I have this:
    
    function sec_save_new_event()
    {
    global $wpdb;
    //query info here
    }
    
    add_action('wp_ajax_sec_add_new_location','sec_add_new_location');
  3. jrm213
    Member
    Posted 6 years ago #

    Also just noticed this, it does throw an error when I click my delete links, but still no error on my submit buttons.

    uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMHTMLTableSectionElement.removeChild]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: http://wbsite.com/wp-admin/options-general.php?page=mylocplugin.php :: sec_del_location :: line 155"  data: no]
    
    Line 0
  4. jrm213
    Member
    Posted 6 years ago #

    Well I am not sure why...

    I replaced the admin-ajax.php page from my live site with the one from my test site and now the plugin works. If they are the same wordpress versions shouldn't those files have been the same anyway?

  5. jrm213
    Member
    Posted 6 years ago #

    ok I figured out why now, so I will resolve this.

    the ajax_check_referer function was commented out in the one file and not in the other.

    In the plugin tutorial for AJAX I missed that you need to send
    mysack.encVar( "cookie", document.cookie, false );

    with the sack call or it will fail authentication for admin modules.

    so that resolved it for me. Hope this helps someone else out in the future.

Topic Closed

This topic has been closed to new replies.

About this Topic