Skip to content

Commit

Permalink
Add download button to edit snippet page
Browse files Browse the repository at this point in the history
  • Loading branch information
sheabunge committed Jan 18, 2018
1 parent d3a1bfe commit cccafa0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions php/admin-menus/class-edit-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ private function process_actions() {
if ( isset( $_POST['export_snippet'] ) ) {
export_snippets( $_POST['snippet_id'] );
}

/* Download the snippet if the button was clicked */
if ( isset( $_POST['download_snippet'] ) ) {
export_snippets( $_POST['snippet_id'], null, 'php' );
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions php/views/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@

submit_button( __( 'Export', 'code-snippets' ), 'secondary', 'export_snippet', false );

/* Download button */

if ( apply_filters( 'code_snippets/enable_downloads', true ) ) {
submit_button( __( 'Download', 'code-snippets' ), 'secondary', 'download_snippet', false );
}

/* Delete button */

$confirm_delete_js = esc_js(
Expand Down

0 comments on commit cccafa0

Please sign in to comment.