PHP file automatically deleted

Well, that’s an interesting way to describe a lot of configuration in one, big PHP file!

In it, I see one PHP class td_config with many different static functions, each returning some hard coded or almost hard coded data.

To split this file, I would probably do the following:

Create a file like td_config_part1.php. In it, create a PHP class like so:


class td_config_part1 {
// put functions here

Within this class, you can paste roughly half of the functions of the original file. It doesn’t really matter which ones you use, as long as you copy only the whole functions.

Then, you can create a second file td_config_part2.php. This file should be slightly different from the first part, and look like:


class td_config_part2 extends td_config_part2 {
// put functions here

Paste the other half of the functions in this file.

You’ll now have a class td_config_part2 which has both it’s own functions and the functions which it inherited from td_config_part1.

Finally, you’ll want to edit the original td_config.php so it uses the functions from the part files. So you’ll want to replace this part:

 * speed booster v 3.0 hooks - prepare the framework for the theme
 * is also used by td_deploy - that's why it's a static class
 * Class td_wp_booster_hooks
class td_config {
// all of the functions

With something like:

require_once 'td_config_part1.php';
require_once 'td_config_part2.php';

class td_config extends td_config_part2 {
// nothing here

This should give you a PHP class td_config which has all the same functions as the original class, but now split over multiple files.

And if you need to add more functions, you can simply add parts 3, 4, etc. by chaining them just like you chained part 2, with part 3 extending 2 and 2 extending 1.