Skip to content

Commit bc1241b

Browse files
committed
Merge branch 'develop'
2 parents 7abd623 + b01b4af commit bc1241b

File tree

15 files changed

+294
-184
lines changed

15 files changed

+294
-184
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 2.1.0
4+
* Added additional setting descriptions
5+
* Added settings for code and description editor height
6+
* Updated CodeMirror to version 5.2
7+
* Fixed not escaping the request URL when using query arg functions
8+
* Improved efficiency of settings component
9+
310
## 2.0.3
411
* Updated German translation by [Joerg Knoerchen](http://www.sensorgrafie.de/)
512

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# Code Snippets [![Build Status](https://travis-ci.org/sheabunge/code-snippets.png?branch=develop)](https://travis-ci.org/sheabunge/code-snippets)
33

44
* __Requires at least:__ [WordPress 3.3](http://wordpress.org/download/) or later
5-
* __Tested up to:__ WordPress 4.1.1
6-
* __Stable version:__ [2.0.3](http://downloads.wordpress.org/plugin/code-snippets.latest-stable.zip)
5+
* __Tested up to:__ WordPress 4.2.2
6+
* __Stable version:__ [2.1.0](http://downloads.wordpress.org/plugin/code-snippets.latest-stable.zip)
77
* __License:__ [MIT](license.txt)
88

99
An easy, clean and simple way to add code snippets to your site.

code-snippets.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* contribute to the localization, please see http://code-snippets.bungeshea.com
88
*
99
* @package Code_Snippets
10-
* @version 2.0.3
10+
* @version 2.1.0
1111
* @author Shea Bunge <http://bungeshea.com/>
1212
* @copyright Copyright (c) 2012-2014, Shea Bunge
1313
* @link http://code-snippets.bungeshea.com
@@ -20,7 +20,7 @@
2020
Description: An easy, clean and simple way to add code snippets to your site. No need to edit to your theme's functions.php file again!
2121
Author: Shea Bunge
2222
Author URI: http://bungeshea.com
23-
Version: 2.0.3
23+
Version: 2.1.0
2424
License: MIT
2525
License URI: license.txt
2626
Text Domain: code-snippets
@@ -42,7 +42,7 @@
4242
* @since 2.0
4343
* @var string A PHP-standardized version number string
4444
*/
45-
define( 'CODE_SNIPPETS_VERSION', '2.0.2' );
45+
define( 'CODE_SNIPPETS_VERSION', '2.1.0' );
4646

4747
/**
4848
* The full path to the main file of this plugin

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"require": {
2424
"php": ">=5.2.7",
25-
"codemirror": "5.0"
25+
"codemirror": "5.2"
2626
},
2727
"require-dev": {
2828
"phpunit/phpunit": "3.7.*"
@@ -32,9 +32,9 @@
3232
"type": "package",
3333
"package": {
3434
"name": "codemirror",
35-
"version": "5.0",
35+
"version": "5.2",
3636
"dist": {
37-
"url": "http://codemirror.net/codemirror-5.0.zip",
37+
"url": "http://codemirror.net/codemirror-5.2.zip",
3838
"type": "zip"
3939
}
4040
}

includes/admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function code_snippets_survey_message() {
197197
<?php _e( 'Take the survey now', 'code-snippets' ); ?>
198198
</a>
199199

200-
<a href="<?php echo wp_nonce_url( add_query_arg( $key, true ), $key ); ?>">Dismiss</a>
200+
<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( $key, true ), $key ) ); ?>">Dismiss</a>
201201

202202
</p></div>
203203

includes/edit/admin.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,11 @@
142142
?>;
143143
var editor = CodeMirror.fromTextArea(document.getElementById('snippet_code'), atts);
144144

145+
jQuery('.CodeMirror').resizable({
146+
resize: function() {
147+
editor.setSize( jQuery(this).width(), jQuery(this).height() );
148+
}
149+
});
150+
145151
})();
146152
</script>

includes/edit/edit.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function code_snippets_load_single_menu() {
152152
/* Delete the snippet if the button was clicked */
153153
elseif ( isset( $_POST['snippet_id'], $_POST['delete_snippet'] ) ) {
154154
delete_snippet( $_POST['snippet_id'] );
155-
wp_redirect( add_query_arg( 'delete', true, $this->manage_url ) );
155+
wp_redirect( add_query_arg( 'delete', true, code_snippets_get_menu_url( 'manage' ) ) );
156156
}
157157

158158
/* Export the snippet if the button was clicked */
@@ -169,7 +169,8 @@ function code_snippets_load_single_menu() {
169169
* @param object $snippet The snippet being used for this page
170170
*/
171171
function code_snippets_description_editor_box( $snippet ) {
172-
172+
$settings = code_snippets_get_settings();
173+
$settings = $settings['description_editor']
173174
?>
174175

175176
<label for="snippet_description">
@@ -185,9 +186,9 @@ function code_snippets_description_editor_box( $snippet ) {
185186
'description',
186187
apply_filters( 'code_snippets/admin/description_editor_settings', array(
187188
'textarea_name' => 'snippet_description',
188-
'textarea_rows' => 10,
189-
'teeny' => true,
190-
'media_buttons' => false,
189+
'textarea_rows' => $settings['rows'],
190+
'teeny' => ! $settings['use_full_mce'],
191+
'media_buttons' => $settings['media_buttons'],
191192
) )
192193
);
193194
}
@@ -241,7 +242,7 @@ function code_snippets_enqueue_codemirror() {
241242

242243
/* CodeMirror */
243244

244-
$codemirror_version = '5.0';
245+
$codemirror_version = '5.2';
245246
$codemirror_url = plugins_url( 'vendor/codemirror/', CODE_SNIPPETS_FILE );
246247

247248
wp_enqueue_style(
@@ -367,4 +368,6 @@ function code_snippets_enqueue_codemirror() {
367368
$tagit_version
368369
);
369370

371+
/* Needed for resizable editor functionality */
372+
wp_enqueue_script( 'jquery-ui-resizable' );
370373
}

includes/import/import.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,8 @@ function code_snippets_load_import_menu() {
103103
$result = import_snippets( $_FILES['code_snippets_import_file']['tmp_name'], $network );
104104

105105
/* Send the amount of imported snippets to the page */
106-
if ( false === $result ) {
107-
wp_redirect( add_query_arg( 'error', true ) );
108-
} else {
109-
wp_redirect( add_query_arg( 'imported', $result ) );
110-
}
106+
$query_args = ( false === $result ) ? array( 'error' => true ) : array( 'imported' => $result );
107+
wp_redirect( esc_url_raw( $query_args ) );
111108
}
112109

113110
/* Load the screen help tabs */

includes/manage/class-list-table.php

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,19 @@ function column_name( $snippet ) {
112112
$actions['deactivate'] = sprintf(
113113
'<a href="%2$s">%1$s</a>',
114114
$screen->is_network ? __( 'Network Deactivate', 'code-snippets' ) : __( 'Deactivate', 'code-snippets' ),
115-
add_query_arg( array(
115+
esc_url( add_query_arg( array(
116116
'action' => 'deactivate',
117117
'id' => $snippet->id
118-
) )
118+
) ) )
119119
);
120120
} else {
121121
$actions['activate'] = sprintf(
122122
'<a href="%2$s">%1$s</a>',
123123
$screen->is_network ? __( 'Network Activate', 'code-snippets' ) : __( 'Activate', 'code-snippets' ),
124-
add_query_arg( array(
124+
esc_url( add_query_arg( array(
125125
'action' => 'activate',
126126
'id' => $snippet->id
127-
) )
127+
) ) )
128128
);
129129
}
130130

@@ -137,19 +137,19 @@ function column_name( $snippet ) {
137137
$actions['export'] = sprintf(
138138
'<a href="%2$s">%1$s</a>',
139139
__( 'Export', 'code-snippets' ),
140-
add_query_arg( array(
140+
esc_url( add_query_arg( array(
141141
'action' => 'export',
142142
'id' => $snippet->id
143-
) )
143+
) ) )
144144
);
145145

146146
$actions['delete'] = sprintf(
147147
'<a href="%2$s" class="delete" onclick="%3$s">%1$s</a>',
148148
__( 'Delete', 'code-snippets' ),
149-
add_query_arg( array(
149+
esc_url( add_query_arg( array(
150150
'action' => 'delete',
151151
'id' => $snippet->id
152-
) ),
152+
) ) ),
153153
esc_js( sprintf(
154154
'return confirm("%s");',
155155
__("You are about to permanently delete the selected item.
@@ -202,7 +202,7 @@ function column_tags( $snippet ) {
202202

203203
foreach ( $snippet->tags as $tag ) {
204204
$out[] = sprintf( '<a href="%s">%s</a>',
205-
add_query_arg( 'tag', esc_attr( $tag ) ),
205+
esc_url( add_query_arg( 'tag', esc_attr( $tag ) ) ),
206206
esc_html( $tag )
207207
);
208208
}
@@ -314,7 +314,7 @@ function get_views() {
314314
}
315315

316316
$status_links[$type] = sprintf( '<a href="%s"%s>%s</a>',
317-
add_query_arg( 'status', $type ),
317+
esc_url( add_query_arg( 'status', $type ) ),
318318
( $type === $status ) ? ' class="current"' : '',
319319
sprintf( $text, number_format_i18n( $count ) )
320320
);
@@ -479,7 +479,7 @@ function process_bulk_actions() {
479479
if ( ! in_array( $action, array( 'export', 'export-php' ) ) ) {
480480
wp_redirect( apply_filters(
481481
"code_snippets/{$action}_redirect",
482-
add_query_arg( $action, true )
482+
esc_url_raw( add_query_arg( $action, true ) )
483483
) );
484484
}
485485

@@ -499,14 +499,14 @@ function process_bulk_actions() {
499499
foreach ( $ids as $id ) {
500500
activate_snippet( $id, $network );
501501
}
502-
wp_redirect( add_query_arg( 'activate-multi', true ) );
502+
wp_redirect( esc_url_raw( add_query_arg( 'activate-multi', true ) ) );
503503
break;
504504

505505
case 'deactivate-selected':
506506
foreach ( $ids as $id ) {
507507
deactivate_snippet( $id, $network );
508508
}
509-
wp_redirect( add_query_arg( 'deactivate-multi', true ) );
509+
wp_redirect( esc_url_raw( add_query_arg( 'deactivate-multi', true ) ) );
510510
break;
511511

512512
case 'export-selected':
@@ -521,7 +521,7 @@ function process_bulk_actions() {
521521
foreach( $ids as $id ) {
522522
delete_snippet( $id, $network );
523523
}
524-
wp_redirect( add_query_arg( 'delete-multi', true ) );
524+
wp_redirect( esc_url_raw( add_query_arg( 'delete-multi', true ) ) );
525525
break;
526526

527527
case 'clear-recent-list':
@@ -568,13 +568,8 @@ function prepare_items() {
568568

569569
/* Filter snippets by tag */
570570
if ( isset( $_POST['tag'] ) ) {
571-
572-
if ( ! empty( $_POST['tag'] ) ) {
573-
wp_redirect( add_query_arg( 'tag', $_POST['tag'] ) );
574-
}
575-
else {
576-
wp_redirect( remove_query_arg( 'tag' ) );
577-
}
571+
$location = empty( $_POST['tag'] ) ? remove_query_arg( 'tag' ) : add_query_arg( 'tag', $_POST['tag'] );
572+
wp_redirect( esc_url_raw( $location ) );
578573
}
579574

580575
if ( ! empty( $_GET['tag'] ) ) {
@@ -777,7 +772,7 @@ public function search_notice() {
777772

778773
printf (
779774
'&nbsp;<a class="button clear-filters" href="%s">' . __( 'Clear Filters', 'code-snippets' ) . '</a>',
780-
remove_query_arg( array( 's', 'tag' ) )
775+
esc_url( remove_query_arg( array( 's', 'tag' ) ) )
781776
);
782777
}
783778
}

0 commit comments

Comments
 (0)