Forums

AJAX of plugin on frontend returns 0 or -1, depending if logged in or not (1 post)

  1. kazuo1231
    Member
    Posted 3 months ago #

    I have this plugin installed called "My Domain List".

    I have been experiencing problems when on random times, the domain list would suddenly just disappear and turn into a "-1".

    I tried logging in. By then I'd be able to see the table, but when I check it via an incognito window, I see that it still is a "-1".

    I tried commenting out the parts in the plugin that initialize the ajax and see the modifications appear when I'm logged in, but I see just a "-1" when I am not.

    So I tried editing the page (it was a shortcode thing) and republished it. It worked.. temporarily. It'd turn into a "-1" again in a few hours.

    So what can be the problem with this? Here's the initialization code that I've been toying around with:

    add_action('init', array("MyDomainListPlugin", 'loadAssets'), 1);
    add_filter('plugin_action_links', array("MyDomainListPlugin", 'loadActionLinks'), 10, 2);
    if ( is_admin() ){
    	require_once dirname( __FILE__ ) . '/my-domain-list-admin.php';
    	require_once dirname( __FILE__ ) . '/my-domain-list-dashboard.php';
    	add_action( 'admin_init', array("AdminFacing", "initializeScript") );
    	add_action('admin_menu', array("AdminFacing", 'addAdminPage'));
    	add_action('wp_ajax_my-domain-list-table',  array("AdminFacing", "displayAdminTable"));
    	add_action('wp_ajax_nopriv_my-domain-list-table',  array("AdminFacing", "displayAdminTable"));
    	add_action('wp_ajax_my-domain-list-dismiss-offer',  array("DashboardFacing", "dismissOffer"));
    	add_action('wp_ajax_nopriv_my-domain-list-dismiss-offer',  array("DashboardFacing", "dismissOffer"));
    	add_action('wp_dashboard_setup', array("MyDomainListPlugin","add_dashboard_widget") );
    	wp_localize_script( 'my-domain-list-ajax-request', 'my_domain_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
    
    }
    require_once dirname(__FILE__)."/my-domain-list-user-shortcode.php";
    add_action('wp_ajax_my-domain-list-user-table', array("UserFacing", "displayUserTable"));
    add_action('wp_ajax_nopriv_my-domain-list-user-table', array("UserFacing", "displayUserTable"));
    add_shortcode( 'my-domain-list-portfolio',array("UserFacing", "shortcodeHandler"));

Reply

You must log in to post.

About this Topic