Overriding the vantage theme 'includes'
Hi all,
So like any good Wordpress 'developer' I have created a child theme 'apothems-vantage-child' and it works fine for the most part, except when trying to override theme files in the /includes/ folder of the theme.
Now, on the Wordpress codex there is information on how to normally do this:
Code:
require_once( get_stylesheet_directory(). '/includes/customizedfile.php' );
inside your child themes functions.php file.. But in the case of Vantage, this does not work, instead causing the theme/site to stop working.
In my case, I am trying to make changes to /includes/listings/class-business-listing-builder.php to add
Code:
'show_in_rest' => true
to the register_post_type() so that 'listing' is a valid endpoint in the
WP-JSON API.
I believe the problem with my overriding it stems from how the parent theme loads the files in question. It seems to use the following:
Code:
appthemes_load_files( dirname( __FILE__ ) . '/', array(
'class-business-listing-builder.php',
'class-business-listing-caps.php',
'class-business-listing-form.php',
'class-business-listing-geocode.php',
// TODO: remove following classes since they just added for smooth
// transition from Vantage classes to Listing module classes.
'class-business-listing-process-new.php',
'class-business-listing-process-renew.php',
'class-business-listing-process-edit.php',
'class-business-listing-step-edit-info.php',
) );
utilising appthemes_load_files instead of a more traditional 'include' or 'require'.
My question is, is there an easier way to make the 'listing' post type appear in the
WP-JSON API, or do I have to keep editing the main Vantage files after every update?
Or, perhaps the Vantage devs can add an option to expose the data via the API?
- - - Updated - - -
On closer inspection, I see that "appthemes_load_files" is defined like this:
Code:
function appthemes_load_files( $path, $files = array() ) {
foreach ( $files as $file_path ) {
require_once $path . $file_path;
}
}
so the require_once would be causing the issue I believe.