Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sheabunge committed May 9, 2015
2 parents 7abd623 + b01b4af commit bc1241b
Show file tree
Hide file tree
Showing 15 changed files with 294 additions and 184 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 2.1.0
* Added additional setting descriptions
* Added settings for code and description editor height
* Updated CodeMirror to version 5.2
* Fixed not escaping the request URL when using query arg functions
* Improved efficiency of settings component

## 2.0.3
* Updated German translation by [Joerg Knoerchen](http://www.sensorgrafie.de/)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Code Snippets [![Build Status](https://travis-ci.org/sheabunge/code-snippets.png?branch=develop)](https://travis-ci.org/sheabunge/code-snippets)

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

An easy, clean and simple way to add code snippets to your site.
Expand Down
6 changes: 3 additions & 3 deletions code-snippets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* contribute to the localization, please see http://code-snippets.bungeshea.com
*
* @package Code_Snippets
* @version 2.0.3
* @version 2.1.0
* @author Shea Bunge <http://bungeshea.com/>
* @copyright Copyright (c) 2012-2014, Shea Bunge
* @link http://code-snippets.bungeshea.com
Expand All @@ -20,7 +20,7 @@
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!
Author: Shea Bunge
Author URI: http://bungeshea.com
Version: 2.0.3
Version: 2.1.0
License: MIT
License URI: license.txt
Text Domain: code-snippets
Expand All @@ -42,7 +42,7 @@
* @since 2.0
* @var string A PHP-standardized version number string
*/
define( 'CODE_SNIPPETS_VERSION', '2.0.2' );
define( 'CODE_SNIPPETS_VERSION', '2.1.0' );

/**
* The full path to the main file of this plugin
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"require": {
"php": ">=5.2.7",
"codemirror": "5.0"
"codemirror": "5.2"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
Expand All @@ -32,9 +32,9 @@
"type": "package",
"package": {
"name": "codemirror",
"version": "5.0",
"version": "5.2",
"dist": {
"url": "http://codemirror.net/codemirror-5.0.zip",
"url": "http://codemirror.net/codemirror-5.2.zip",
"type": "zip"
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function code_snippets_survey_message() {
<?php _e( 'Take the survey now', 'code-snippets' ); ?>
</a>

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

</p></div>

Expand Down
6 changes: 6 additions & 0 deletions includes/edit/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,11 @@
?>;
var editor = CodeMirror.fromTextArea(document.getElementById('snippet_code'), atts);

jQuery('.CodeMirror').resizable({
resize: function() {
editor.setSize( jQuery(this).width(), jQuery(this).height() );
}
});

})();
</script>
15 changes: 9 additions & 6 deletions includes/edit/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function code_snippets_load_single_menu() {
/* Delete the snippet if the button was clicked */
elseif ( isset( $_POST['snippet_id'], $_POST['delete_snippet'] ) ) {
delete_snippet( $_POST['snippet_id'] );
wp_redirect( add_query_arg( 'delete', true, $this->manage_url ) );
wp_redirect( add_query_arg( 'delete', true, code_snippets_get_menu_url( 'manage' ) ) );
}

/* Export the snippet if the button was clicked */
Expand All @@ -169,7 +169,8 @@ function code_snippets_load_single_menu() {
* @param object $snippet The snippet being used for this page
*/
function code_snippets_description_editor_box( $snippet ) {

$settings = code_snippets_get_settings();
$settings = $settings['description_editor']
?>

<label for="snippet_description">
Expand All @@ -185,9 +186,9 @@ function code_snippets_description_editor_box( $snippet ) {
'description',
apply_filters( 'code_snippets/admin/description_editor_settings', array(
'textarea_name' => 'snippet_description',
'textarea_rows' => 10,
'teeny' => true,
'media_buttons' => false,
'textarea_rows' => $settings['rows'],
'teeny' => ! $settings['use_full_mce'],
'media_buttons' => $settings['media_buttons'],
) )
);
}
Expand Down Expand Up @@ -241,7 +242,7 @@ function code_snippets_enqueue_codemirror() {

/* CodeMirror */

$codemirror_version = '5.0';
$codemirror_version = '5.2';
$codemirror_url = plugins_url( 'vendor/codemirror/', CODE_SNIPPETS_FILE );

wp_enqueue_style(
Expand Down Expand Up @@ -367,4 +368,6 @@ function code_snippets_enqueue_codemirror() {
$tagit_version
);

/* Needed for resizable editor functionality */
wp_enqueue_script( 'jquery-ui-resizable' );
}
7 changes: 2 additions & 5 deletions includes/import/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ function code_snippets_load_import_menu() {
$result = import_snippets( $_FILES['code_snippets_import_file']['tmp_name'], $network );

/* Send the amount of imported snippets to the page */
if ( false === $result ) {
wp_redirect( add_query_arg( 'error', true ) );
} else {
wp_redirect( add_query_arg( 'imported', $result ) );
}
$query_args = ( false === $result ) ? array( 'error' => true ) : array( 'imported' => $result );
wp_redirect( esc_url_raw( $query_args ) );
}

/* Load the screen help tabs */
Expand Down
39 changes: 17 additions & 22 deletions includes/manage/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ function column_name( $snippet ) {
$actions['deactivate'] = sprintf(
'<a href="%2$s">%1$s</a>',
$screen->is_network ? __( 'Network Deactivate', 'code-snippets' ) : __( 'Deactivate', 'code-snippets' ),
add_query_arg( array(
esc_url( add_query_arg( array(
'action' => 'deactivate',
'id' => $snippet->id
) )
) ) )
);
} else {
$actions['activate'] = sprintf(
'<a href="%2$s">%1$s</a>',
$screen->is_network ? __( 'Network Activate', 'code-snippets' ) : __( 'Activate', 'code-snippets' ),
add_query_arg( array(
esc_url( add_query_arg( array(
'action' => 'activate',
'id' => $snippet->id
) )
) ) )
);
}

Expand All @@ -137,19 +137,19 @@ function column_name( $snippet ) {
$actions['export'] = sprintf(
'<a href="%2$s">%1$s</a>',
__( 'Export', 'code-snippets' ),
add_query_arg( array(
esc_url( add_query_arg( array(
'action' => 'export',
'id' => $snippet->id
) )
) ) )
);

$actions['delete'] = sprintf(
'<a href="%2$s" class="delete" onclick="%3$s">%1$s</a>',
__( 'Delete', 'code-snippets' ),
add_query_arg( array(
esc_url( add_query_arg( array(
'action' => 'delete',
'id' => $snippet->id
) ),
) ) ),
esc_js( sprintf(
'return confirm("%s");',
__("You are about to permanently delete the selected item.
Expand Down Expand Up @@ -202,7 +202,7 @@ function column_tags( $snippet ) {

foreach ( $snippet->tags as $tag ) {
$out[] = sprintf( '<a href="%s">%s</a>',
add_query_arg( 'tag', esc_attr( $tag ) ),
esc_url( add_query_arg( 'tag', esc_attr( $tag ) ) ),
esc_html( $tag )
);
}
Expand Down Expand Up @@ -314,7 +314,7 @@ function get_views() {
}

$status_links[$type] = sprintf( '<a href="%s"%s>%s</a>',
add_query_arg( 'status', $type ),
esc_url( add_query_arg( 'status', $type ) ),
( $type === $status ) ? ' class="current"' : '',
sprintf( $text, number_format_i18n( $count ) )
);
Expand Down Expand Up @@ -479,7 +479,7 @@ function process_bulk_actions() {
if ( ! in_array( $action, array( 'export', 'export-php' ) ) ) {
wp_redirect( apply_filters(
"code_snippets/{$action}_redirect",
add_query_arg( $action, true )
esc_url_raw( add_query_arg( $action, true ) )
) );
}

Expand All @@ -499,14 +499,14 @@ function process_bulk_actions() {
foreach ( $ids as $id ) {
activate_snippet( $id, $network );
}
wp_redirect( add_query_arg( 'activate-multi', true ) );
wp_redirect( esc_url_raw( add_query_arg( 'activate-multi', true ) ) );
break;

case 'deactivate-selected':
foreach ( $ids as $id ) {
deactivate_snippet( $id, $network );
}
wp_redirect( add_query_arg( 'deactivate-multi', true ) );
wp_redirect( esc_url_raw( add_query_arg( 'deactivate-multi', true ) ) );
break;

case 'export-selected':
Expand All @@ -521,7 +521,7 @@ function process_bulk_actions() {
foreach( $ids as $id ) {
delete_snippet( $id, $network );
}
wp_redirect( add_query_arg( 'delete-multi', true ) );
wp_redirect( esc_url_raw( add_query_arg( 'delete-multi', true ) ) );
break;

case 'clear-recent-list':
Expand Down Expand Up @@ -568,13 +568,8 @@ function prepare_items() {

/* Filter snippets by tag */
if ( isset( $_POST['tag'] ) ) {

if ( ! empty( $_POST['tag'] ) ) {
wp_redirect( add_query_arg( 'tag', $_POST['tag'] ) );
}
else {
wp_redirect( remove_query_arg( 'tag' ) );
}
$location = empty( $_POST['tag'] ) ? remove_query_arg( 'tag' ) : add_query_arg( 'tag', $_POST['tag'] );
wp_redirect( esc_url_raw( $location ) );
}

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

printf (
'&nbsp;<a class="button clear-filters" href="%s">' . __( 'Clear Filters', 'code-snippets' ) . '</a>',
remove_query_arg( array( 's', 'tag' ) )
esc_url( remove_query_arg( array( 's', 'tag' ) ) )
);
}
}
Expand Down
Loading

0 comments on commit bc1241b

Please sign in to comment.