Premium theme licensing of php called through AJAX

The data generating PHP, if it truly stands alone and doesn’t use any WordPress code or WordPress’ data layer, can be licensed as a standalone library. You can use any license you want here without any problems.

The only issues come when you start distributing your code. If you want your theme hosted in the theme repository on WordPress.org, it must be GPL-compatible. That means you have to use either GPL or a more permissible license on your extra library …

If you’re distributing things yourself, you just have to make a very clear distinction between the parts of the theme that are GPL and the parts that aren’t. But since you’ll be bundling a part that’s not GPL, you can’t distribute the entire package as GPL.

So no, all PHP does not have to be GPL unless you’re distributing the entire package under the terms of the GPL.