admin管理员组文章数量:1130349
I have a front end built with Gatsby, connecting to WordPress via the REST API.
Each time I update a post, I need run a command to compile. Below is my attempt at automating this using the save_post filter function:
<?php
function li_rebuild_gatsby( $id, $post, $update ) {
$command_one = "cd /home/web/public/website425";
$command_two = "gatsby build";
@exec( $command_one . "&& " . $command_two );
}
add_filter( 'save_post' , 'li_rebuild_gatsby' , 10, 3 );
It seems I need to change into a sudo'er and supply a password.
What is the right way to run this command?
I have a front end built with Gatsby, connecting to WordPress via the REST API.
Each time I update a post, I need run a command to compile. Below is my attempt at automating this using the save_post filter function:
<?php
function li_rebuild_gatsby( $id, $post, $update ) {
$command_one = "cd /home/web/public/website425";
$command_two = "gatsby build";
@exec( $command_one . "&& " . $command_two );
}
add_filter( 'save_post' , 'li_rebuild_gatsby' , 10, 3 );
It seems I need to change into a sudo'er and supply a password.
What is the right way to run this command?
本文标签: hooksTrying to run a compile command while saving post
版权声明:本文标题:hooks - Trying to run a compile command while saving post 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749065073a2310687.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论