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 20, 2015
2 parents 5b22b0a + 92971d8 commit 77ad257
Show file tree
Hide file tree
Showing 21 changed files with 808 additions and 452 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2.3.0
* Removed nested functions
* Added icons for admin and front-end snippets to manage table
* Improved settings retrieval by caching settings
* Updated Russian translation by [Alexey Chumakov](http://chumakov.ru/)
* Added filter switch to prevent a snippet from executing ([#25](https://github.com/sheabunge/code-snippets/issues/25))
* Fixed errors in string translation
* Fixed bug in import process ([#32](https://github.com/sheabunge/code-snippets/issues/32))

## 2.2.3
* Fixed broken call to `export_snippet()` function
* Added support for importing and exporting snippet scope
Expand Down
8 changes: 7 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ module.exports = function(grunt) {
options:{
text_domain: 'code-snippets',
dest: 'languages/',
keywords: ['__','_e','esc_html__','esc_html_e','esc_attr__', 'esc_attr_e', 'esc_attr_x', 'esc_html_x', 'ngettext', '_n', '_ex', '_nx'],
keywords: [
'__:1', '_e:1', '_x:1,2c',
'esc_html__:1', 'esc_html_e:1', 'esc_html_x:1,2c',
'esc_attr__:1', 'esc_attr_e:1', 'esc_attr_x:1,2c',
'_ex:1,2c', '_n:1,2', '_nx:1,2,4c',
'_n_noop:1,2', '_nx_noop:1,2,3c'
],
},
files: {
src: [ 'code-snippets.php', 'includes/**/*.php' ],
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

Code Snippets is an easy, clean and simple way to add code snippets to your site. It removes the need to add custom snippets to your theme theme's `functions.php` file.
Expand Down
8 changes: 4 additions & 4 deletions code-snippets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* contribute to the localization, please see https://github.com/sheabunge/code-snippets
*
* @package Code_Snippets
* @version 2.2.3
* @version 2.3.0
* @author Shea Bunge <http://bungeshea.com/>
* @copyright Copyright (c) 2012-2014, Shea Bunge
* @copyright Copyright (c) 2012-2015, Shea Bunge
* @link http://bungeshea.com/plugins/code-snippets/
* @license http://opensource.org/licenses/MIT
*/
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.2.3
Version: 2.3.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.2.3' );
define( 'CODE_SNIPPETS_VERSION', '2.3.0' );

/**
* The full path to the main file of this plugin
Expand Down
21 changes: 21 additions & 0 deletions css/manage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
* Custom styling for the snippets table
*/

.column-name > a {

%icon-after {
padding-left: 5px;
font-family: "dashicons";
vertical-align: top;
}

.admin-scope &:after {
@extend %icon-after;
font-size: 14px;
content: "\f111";
}

.frontend-scope &:after {
@extend %icon-after;
font-size: 16px;
content: "\f177";
}
}

.snippets {

th, td {
Expand Down
11 changes: 4 additions & 7 deletions includes/edit/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@
<h2><?php
if ( $edit_id ) {
esc_html_e( 'Edit Snippet', 'code-snippets' );

if ( current_user_can( get_snippets_cap() ) ) {
printf( ' <a href="%1$s" class="add-new-h2">%2$s</a>',
code_snippets_get_menu_url( 'add' ),
esc_html_x( 'Add New', 'snippet', 'code-snippets' )
);
}
printf( ' <a href="%1$s" class="add-new-h2">%2$s</a>',
code_snippets_get_menu_url( 'add' ),
esc_html_x( 'Add New', 'snippet', 'code-snippets' )
);
} else {
esc_html_e( 'Add New Snippet', 'code-snippets' );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/edit/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ function code_snippets_tags_editor( $snippet ) {
</label>

<input type="text" id="snippet_tags" name="snippet_tags" style="width: 100%;"
placeholder="Enter a list of tags; separated by commas" value="<?php echo implode( ', ', $snippet->tags ); ?>" />
placeholder="<?php esc_html_e( 'Enter a list of tags; separated by commas', 'code-snippets' ); ?>" value="<?php echo implode( ', ', $snippet->tags ); ?>" />

<script type="text/javascript">
jQuery('#snippet_tags').tagit({
Expand Down
4 changes: 2 additions & 2 deletions includes/import/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +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 */
$query_args = ( false === $result ) ? array( 'error' => true ) : array( 'imported' => $result );
wp_redirect( esc_url_raw( $query_args ) );
$url = add_query_arg( false === $result ? array( 'error' => true ) : array( 'imported' => $result ) );
wp_redirect( esc_url_raw( $url ) );
}

/* Load the screen help tabs */
Expand Down
11 changes: 4 additions & 7 deletions includes/manage/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
<h2><?php
esc_html_e( 'Snippets', 'code-snippets' );

if ( current_user_can( get_snippets_cap() ) ) {

printf( '<a href="%2$s" class="add-new-h2">%1$s</a>',
esc_html_x( 'Add New', 'snippet', 'code-snippets' ),
code_snippets_get_menu_url( 'add' )
);
}
printf( '<a href="%2$s" class="add-new-h2">%1$s</a>',
esc_html_x( 'Add New', 'snippet', 'code-snippets' ),
code_snippets_get_menu_url( 'add' )
);

$code_snippets_list_table->search_notice();
?></h2>
Expand Down
2 changes: 1 addition & 1 deletion includes/manage/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ public function search_notice() {

/**
* Retrieve the string representation of a snippet scope number
* @since [NEXT_VERSION]
* @since 2.3.0
* @param int $scope the scope number
* @return string the scope name
*/
Expand Down
28 changes: 16 additions & 12 deletions includes/settings/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ class Code_Snippets_Settings {
private static $fields = array();
private static $defaults = array();

public static function setup() {
self::set_fields();
self::set_defaults();
}

/**
* Retrieve the defined fields
* @return array
*/
public static function get_fields() {
if ( empty( self::$fields ) ) {
self::set_fields();
}

return self::$fields;
}

Expand All @@ -27,14 +26,19 @@ public static function get_fields() {
* @return array the default field values, keyed by ID
*/
public static function get_defaults() {
if ( empty( self::$defaults ) ) {
self::set_defaults();
}

return self::$defaults;
}

/**
* Loop through the settings fields and extract the default values
*/
private static function set_defaults() {
foreach ( self::$fields as $section_id => $section_fields ) {

foreach ( self::get_fields() as $section_id => $section_fields ) {
self::$defaults[ $section_id ] = wp_list_pluck( $section_fields, 'default', 'id' );
}
}
Expand Down Expand Up @@ -64,26 +68,26 @@ private static function set_fields() {

array(
'id' => 'rows',
'name' => 'Row Height',
'name' => __( 'Row Height', 'code-snippets' ),
'type' => 'number',
'label' => 'rows',
'label' => __( 'rows', 'code-snippets' ),
'default' => 5,
'min' => 0,
),

array(
'id' => 'use_full_mce',
'name' => 'Use Full Editor',
'name' => __( 'Use Full Editor', 'code-snippets' ),
'type' => 'checkbox',
'label' => 'Enable all features of the visual editor',
'label' => __( 'Enable all features of the visual editor', 'code-snippets' ),
'default' => false,
),

array(
'id' => 'media_buttons',
'name' => 'Media Buttons',
'name' => __( 'Media Buttons', 'code-snippets' ),
'type' => 'checkbox',
'label' => 'Enable the add media buttons',
'label' => __( 'Enable the add media buttons', 'code-snippets' ),
'default' => false,
),
);
Expand Down
1 change: 0 additions & 1 deletion includes/settings/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

require plugin_dir_path( __FILE__ ) . '/class-settings.php';
Code_Snippets_Settings::setup();

/**
* Retrieve the default setting values
Expand Down
10 changes: 6 additions & 4 deletions includes/snippet-ops.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ function execute_snippet( $code ) {
$output = ob_get_contents();
ob_end_clean();

do_action( 'code_snippets/execute_snippet', $code );
return $result;
}

Expand Down Expand Up @@ -487,9 +486,12 @@ function execute_active_snippets() {
/* Grab the active snippets from the database */
$active_snippets = $wpdb->get_col( $sql );

foreach ( $active_snippets as $snippet_code ) {
/* Execute the PHP code */
execute_snippet( $snippet_code );
foreach ( $active_snippets as $snippet_id => $snippet_code ) {

if ( apply_filters( 'code_snippets/allow_execute_snippet', true, $snippet_id ) ) {
/* Execute the PHP code */
execute_snippet( $snippet_code );
}
}

return true;
Expand Down
Binary file modified languages/code-snippets-fr_FR.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion languages/code-snippets-fr_FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-05-11 08:58+1000\n"
"PO-Revision-Date: 2015-05-11 10:08+1000\n"
"Last-Translator: \n"
"Last-Translator: Shea Bunge <[email protected]>"
"Language-Team: oWEB <[email protected]>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
Expand Down
Binary file modified languages/code-snippets-ru_RU.mo
Binary file not shown.
Loading

0 comments on commit 77ad257

Please sign in to comment.