Created
April 28, 2022 21:24
-
-
Save kumaxim/4ab087b4eb4ded64e6a8e17819efad41 to your computer and use it in GitHub Desktop.
Run WP_CLI command from PHP code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Import image to media library using WP_CLI | |
| // Call the code from your own WP CLI custom command | |
| $image_id = \WP_CLI::runcommand( | |
| sprintf('media import "%s" --preserve-filetime --porcelain',$thumbnail), | |
| ['return' => true, 'launch' => false] | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment