简体   繁体   English

在安装子主题时,是否可以自动安装wordpress父主题?

[英]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). (类似于TGM插件激活,但适用于主题)。

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 我之所以这么问是因为我有很多客户忘记了安装父主题,然后就如何安装主题与我联系,尽管我在readme.txt中明确说明了这一点

When a theme is installed it is run through the check_parent_theme_filter() function which ensures that the parent theme is installed. 安装主题后,将通过check_parent_theme_filter()函数运行该主题,以确保已安装父主题。 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 . 如果不是,并且无法从WordPress存储库中获取,则安装将失败,并在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. 如果未在WordPress资源库上安装此父主题,则需要使用themes_api()可用的钩子,WP使用该钩子来自动安装父主题。 The initial request is failing, however the response is passed through the themes_api_result filter with three arguments: $res, $action, $args . 初始请求失败,但是响应通过带有三个参数的themes_api_result过滤器传递: $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. 您可以使用此方法作为连接到此过滤器的函数类型的示例,如果能够成功下载并安装父主题,则返回true否则返回false

Unclear on how to hook to these using a child theme, perhaps a custom plugin would do it? 不清楚如何使用子主题与这些主题挂钩,也许自定义插件可以做到?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM