@@ -116,40 +116,37 @@ function code_snippets_load_single_menu() {
116116 }
117117
118118 /* Save the snippet to the database */
119- $ network = get_current_screen ()->is_network ;
120- $ result = save_snippet ( stripslashes_deep ( $ _POST ), $ network );
121-
122- /* Strip old status query vars from URL */
123- $ _SERVER ['REQUEST_URI ' ] = remove_query_arg ( array ( 'added ' , 'updated ' , 'activated ' , 'deactivated ' , 'invalid ' ) );
124-
125- /* Change the redirect URL to the edit snippet page if a new snippet was successfully added */
126- if ( $ result && $ result > 1 && ! isset ( $ _POST ['snippet_id ' ] ) ) {
127- $ _SERVER ['REQUEST_URI ' ] = code_snippets_get_menu_url ( 'edit ' );
128- }
119+ $ result = save_snippet ( stripslashes_deep ( $ _POST ) );
129120
130121 /* Build the status message and redirect */
122+ $ query_args = array ();
131123
132124 if ( $ result && isset ( $ _POST ['save_snippet_activate ' ] ) ) {
133125 /* Snippet was activated addition to saving*/
134- $ _SERVER [ ' REQUEST_URI ' ] = add_query_arg ( ' activated ' , true ) ;
126+ $ query_args [ ' activated ' ] = true ;
135127 }
136128 elseif ( $ result && isset ( $ _POST ['save_snippet_deactivate ' ] ) ) {
137129 /* Snippet was deactivated addition to saving*/
138- $ _SERVER [ ' REQUEST_URI ' ] = add_query_arg ( ' deactivated ' , true ) ;
130+ $ query_args [ ' deactivated ' ] = true ;
139131 }
140132
141133 if ( ! $ result || $ result < 1 ) {
142134 /* An error occurred */
143- wp_redirect ( add_query_arg ( 'invalid ' , true ) ) ;
135+ $ query_args [ 'invalid ' ] = true ;
144136 }
145137 elseif ( isset ( $ _POST ['snippet_id ' ] ) ) {
146138 /* Existing snippet was updated */
147- wp_redirect ( add_query_arg ( array ( 'id ' => $ result , 'updated ' => true ) ) );
139+ $ query_args ['id ' ] = $ result ;
140+ $ query_args ['updated ' ] = true ;
148141 }
149142 else {
150143 /* New snippet was added */
151- wp_redirect ( add_query_arg ( array ( 'id ' => $ result , 'added ' => true ) ) );
144+ $ query_args ['id ' ] = $ result ;
145+ $ query_args ['added ' ] = true ;
152146 }
147+
148+ /* Redirect to edit snippet page */
149+ wp_redirect ( add_query_arg ( $ query_args , code_snippets_get_menu_url ( 'edit ' ) ) );
153150 }
154151
155152 /* Delete the snippet if the button was clicked */
0 commit comments