• When using custom page templates in a child theme to build out certain functionality, is it possible to move PHP code out into its own class?

    class AIS_Rest {
    	private $rest_domain;
    	public function __construct() {
    		$this->rest_domain = 'https://something:8080/rest';
    	}
    	more functions…

    Now lets say in the page template itself we want to instantiate that class:

    $ais_rest = new AIS_Rest();
    get_header();
    do stuff with $ais_rest...

    What is the proper way to require and use that class? It assumes this is brand new functionality that does not belong to the parent theme.

  • The topic ‘PHP classes in child themes’ is closed to new replies.