0

I'm want to run a wp_cli command from my php script.

for example: sudo -u www-data wp search-replace "foo" "bar" --all-tables && sudo -u www-data wp cache flush

Is there any way to do that but from inside a php script function?

Thanks.

2
  • you could, using e.G. exec. But there will be problems with the permissions (you can't sudo) and you should never! pass any arguments to you shell. Proably you should ask for help for your real problem, and don't take the wp_cli-way! Commented Apr 7, 2016 at 11:01
  • You would probably to better to have a cron that runs to do that every x rather than have it callable from a web page. Commented Apr 7, 2016 at 11:39

1 Answer 1

1

For wordpress, You can try plugin "Better Search Replace" for search-replace functionality and also i have one script in php for search and replace functionality which is you can download from "https://www.dropbox.com/s/xbizw2su90ndz9j/script.php?dl=0".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.