Is there a way to automatically install a wordpress parent theme when installing a child theme?

I have a rather odd question. Is it somehow possible that when I install a child theme, to automatically install the parent theme? (Similar to TGM Plugin Activation, but for themes).

I’m asking because I have many customers who forget to install my parent theme and then contact me on how to install the theme, although I clearly explain that in the readme.txt

Related posts

Leave a Reply

1 comment

  1. When a theme is installed it is run through the check_parent_theme_filter() function which ensures that the parent theme is installed. If it is not and it cannot be fetched from the WordPress repository then the install fails with the message keyed on parent_theme_not_found.

    If this parent theme is not installed on the WordPress repository, you will need to use the hooks available in themes_api() which is the function WP uses to automatically install parent themes. The initial request is failing, however the response is passed through the themes_api_result filter with three arguments: $res, $action, $args. You can use this method as an example of the type of function that you would hook to this filter, returning true if you were able to successfully download and install the parent theme, false if it fails.

    Unclear on how to hook to these using a child theme, perhaps a custom plugin would do it?