protected function _edit($content, $title) { $content = apply_filters('the_editor_content', $content); $output = \WP_CLI\Utils\launch_editor_for_input($content, $title); return is_string($output) ? apply_filters('content_save_pre', $output) : $output; }
/** * Edit a release's changelog. * * ## Options * * <ID> * : Release ID's changelog to edit * * [<file>] * : Read changelog from <file> Passing `-` as the filename will cause * changelog to be read from STDIN * * [--changes=<changes>] * : Text of changes. HTML is allowed. * * [--mode=<mode>] * : Mode to use when editing. Accepted values: replace, append. Default: * replace * * [--edit] * : Immediately open system's editor to write or edit changelog. * * * @param $args * @param $assoc_args * * @subcommand edit-changelog * @alias edit-changes */ public function edit_changelog($args, $assoc_args) { list($ID) = $args; $release = $this->fetcher->get_check($ID); if (isset($args[1])) { $changes = $this->read_from_file_or_stdin($args[1]); } else { $changes = \WP_CLI\Utils\get_flag_value($assoc_args, 'changes', ''); } if (\WP_CLI\Utils\get_flag_value($assoc_args, 'edit')) { if (empty($changes)) { $changes = $release->get_changelog(); } $output = \WP_CLI\Utils\launch_editor_for_input($changes, 'WP-CLI: Edit Release Changelog'); if ($output) { $changes = $output; } } $mode = \WP_CLI\Utils\get_flag_value($assoc_args, 'mode', 'replace'); if (!in_array($mode, array('replace', 'append'))) { WP_CLI::error("Invalid value for mode"); } $release->set_changelog($changes, $mode); WP_CLI::success("Changelog updated."); }