Why can’t I call a function from inside my registered AJAX function?

My one and only idea is that when I’m inside my wp_ajax hook’d
function, parsePluginInstallRequest, it simply is too early to call
the install, put it this way:

I don’t think so, when the wp_ajax hook is called, your class and methods are loaded. That can’t be it.

Your ajax looks good, but i always use this approach: (setting nonce is easier)

<?php
add_action( 'admin_footer', 'my_action_javascript' );
function my_action_javascript() {
  //Set Your Nonce
  $ajax_nonce = wp_create_nonce( "my-special-string" );
  ?>
  <script>
  jQuery( document ).ready( function( $ ) {
    var data = {
      action: 'my_action',
      security: '<?php echo $ajax_nonce; ?>',
      whatever: 1234
    };
    // Since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
    $.post( ajaxurl, data, function( response ) {
      alert( 'Got this from the server: ' + response );
    });
  });
  </script>
<?php } ?>

Is the debug log telling you anything?


$data = json_decode( stripslashes( $_POST['plugin_install_request_data'] ), true );

I guess you debugged this, but just to be sure, are you certain the $data array is correct after json_decode()?

If the array key is not found, it will result in an error and the function will not run, but this would be visible in the debug log…

EDIT:

Ok, you mention:

TGMPA fires on init.

I’m not that familiar with the TGMPA source code (i know what it does), but if it has the following (or something like this) it will never work:

if( ! wp_doing_ajax() ) {}

Did you check?

I’ve called many functions from wp_ajax that are only available after the init hook.

p.s. after a (quick) search i cannot find any conclusive info when the wp_ajax hook runs :S..