Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support launching system editor with specific temp file extension #4691

Merged
merged 3 commits into from Feb 20, 2018
Merged
Diff settings

Always

Just for now

@@ -351,9 +351,11 @@ function pick_fields( $item, $fields ) {
* @category Input
*
* @param string $content Some form of text to edit (e.g. post content)
* @param string $title Title to display in the editor.
* @param string $ext Extension to use with the temp file.
* @return string|bool Edited text, if file is saved from editor; false, if no change to file.
*/
function launch_editor_for_input( $input, $filename = 'WP-CLI' ) {
function launch_editor_for_input( $input, $filename = 'WP-CLI', $ext = 'tmp' ) {

This comment has been minimized.

Copy link
@schlessera

schlessera Feb 19, 2018

Member

$filename => $title

This comment has been minimized.

Copy link
@danielbachhuber

danielbachhuber Feb 19, 2018

Author Member

Updated in 847de9a

check_proc_available( 'launch_editor_for_input' );
@@ -363,7 +365,7 @@ function launch_editor_for_input( $input, $filename = 'WP-CLI' ) {
$tmpfile = basename( $filename );
$tmpfile = preg_replace( '|\.[^.]*$|', '', $tmpfile );
$tmpfile .= '-' . substr( md5( mt_rand() ), 0, 6 );
$tmpfile = $tmpdir . $tmpfile . '.tmp';
$tmpfile = $tmpdir . $tmpfile . '.' . $ext;
$fp = fopen( $tmpfile, 'xb' );
if ( ! $fp && is_writable( $tmpdir ) && file_exists( $tmpfile ) ) {
$tmpfile = '';
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.