Skip to content

Commit b8eaf34

Browse files
committed
Updated to version 1.1
1 parent c1438e5 commit b8eaf34

File tree

3 files changed

+74
-38
lines changed

3 files changed

+74
-38
lines changed

code-snippets.php

+50-27
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<?php
22

3-
/**
4-
* Plugin Name: Code Snippets
5-
* Plugin URI: http://wordpress.org/extend/plugins/code-snippets
6-
* Description: Provides an easy-to-manage GUI interface for adding code snippets to your blog.
7-
* Author: Shea Bunge
8-
* Version: 1.0
9-
* Author URI: http://bungeshea.wordpress.com/plugins/code-snippets/
10-
* License: GPLv3 or later
11-
*
12-
* Code Snippets - WordPress Plugin
13-
* Copyright (C) 2012 Shea Bunge
14-
*
15-
* This program is free software: you can redistribute it and/or modify
16-
* it under the terms of the GNU General Public License as published by
17-
* the Free Software Foundation, either version 3 of the License, or
18-
* (at your option) any later version.
19-
*
20-
* This program is distributed in the hope that it will be useful,
21-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23-
* GNU General Public License for more details.
24-
*
25-
* You should have received a copy of the GNU General Public License
26-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
27-
*/
3+
/*
4+
Plugin Name: Code Snippets
5+
Plugin URI: http://wordpress.org/extend/plugins/code-snippets
6+
Description: Provides an easy-to-manage GUI interface for adding code snippets to your blog.
7+
Author: Shea Bunge
8+
Version: 1.1
9+
Author URI: http://bungeshea.wordpress.com/plugins/code-snippets/
10+
License: GPLv3 or later
11+
12+
Code Snippets - WordPress Plugin
13+
Copyright (C) 2012 Shea Bunge
14+
15+
This program is free software: you can redistribute it and/or modify
16+
it under the terms of the GNU General Public License as published by
17+
the Free Software Foundation, either version 3 of the License, or
18+
(at your option) any later version.
19+
20+
This program is distributed in the hope that it will be useful,
21+
but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+
GNU General Public License for more details.
24+
25+
You should have received a copy of the GNU General Public License
26+
along with this program. If not, see <http://www.gnu.org/licenses/>.
27+
*/
2828

2929
// Exit if accessed directly
3030
if ( !defined( 'ABSPATH' ) ) exit;
@@ -109,9 +109,9 @@ function uninstall() {
109109
}
110110

111111
function add_admin_menus() {
112-
$this->manage_snippets_page = add_menu_page( 'Snippets', 'Snippets', 'activate_plugins', 'snippets', array( &$this, 'manage_snippets' ), $this->plugin_url . 'img/icon16.png', 67 );
112+
$this->manage_snippets_page = add_menu_page( 'Snippets', 'Snippets', 'install_plugins', 'snippets', array( &$this, 'manage_snippets' ), $this->plugin_url . 'img/icon16.png', 67 );
113113
add_submenu_page('snippets', 'Snippets', 'Manage Snippets' , 'install_plugins', 'snippets', array( &$this, 'manage_snippets') );
114-
$this->edit_snippets_page = add_submenu_page( 'snippets', 'Add New Snippet', 'Add New', 'edit_plugins', 'snippet-new', array( &$this, 'edit_snippets' ) );
114+
$this->edit_snippets_page = add_submenu_page( 'snippets', 'Add New Snippet', 'Add New', 'install_plugins', 'snippet-new', array( &$this, 'edit_snippets' ) );
115115
$this->uninstall_plugin_page = add_submenu_page( 'snippets', 'Uninstall Code Snippets', 'Uninstall', 'install_plugins', 'uninstall-cs', array( &$this, 'uninstall_plugin' ) );
116116

117117
add_action( 'admin_print_styles-' . $this->manage_snippets_page, array( $this, 'load_stylesheet' ), 5 );
@@ -156,6 +156,10 @@ function manage_snippets_help() {
156156
}
157157

158158
function edit_snippets_help() {
159+
160+
if( isset( $_GET['action'] ) && @$_GET['action'] == 'edit' )
161+
add_filter('admin_title', array( &$this, 'edit_snippets_title' ), 10, 2);
162+
159163
$screen = get_current_screen();
160164
$screen->add_help_tab( array(
161165
'id' => 'overview',
@@ -320,6 +324,25 @@ function edit_snippets() {
320324
require_once( $this->dirname . '/inc/edit-snippets.php');
321325
}
322326

327+
function edit_snippets_title( $admin_title, $title ) {
328+
329+
$title = 'Edit Snippet';
330+
331+
if ( is_network_admin() )
332+
$admin_title = __( 'Network Admin' );
333+
elseif ( is_user_admin() )
334+
$admin_title = __( 'Global Dashboard' );
335+
else
336+
$admin_title = get_bloginfo( 'name' );
337+
338+
if ( $admin_title == $title )
339+
$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), $title );
340+
else
341+
$admin_title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress' ), $title, $admin_title );
342+
343+
return $admin_title;
344+
}
345+
323346
function uninstall_plugin(){
324347
$msg = '';
325348
if( isset( $_POST['uninstall'] ) ) {

inc/edit-snippets.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
<?php $id = intval( @$_GET['id'] ); ?>
1+
<?php
2+
$edit = isset( $_GET['action'] ) && $_GET['action'] == 'edit';
3+
if( $edit )
4+
$id = intval( $_GET['id'] );
5+
?>
26
<div class="wrap">
37
<div id="icon-snippets" class="icon32"><br /></div><h2><?php
4-
if( $_GET['action'] == 'edit' ) :
8+
if( $edit ) :
59
?>Edit Snippet<a href="<?php echo $this->edit_snippets_url; ?>" class="add-new-h2">Add New</a></h2><?php
610
else:
711
?>Add New Snippet</h2>
812
<?php endif; ?>
9-
<?php if ( strlen($msg) ) : ?>
13+
<?php if ( strlen( $msg ) ) : ?>
1014
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
1115
<?php else: ?>
1216
<br />
1317
<?php endif; ?>
1418
<form method="post" action="">
15-
<?php if( $_GET['action'] == 'edit' ) : ?>
19+
<?php if( $edit ) : ?>
1620
<?php $record = $wpdb->get_row( "SELECT * FROM `$this->table_name` WHERE `id` = '$id';" ); ?>
1721
<input type="hidden" name="edit_id" value="<?php echo $id;?>" />
1822
<?php else: ?>

readme.txt

+16-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Contributors: bungeshea
33
Donate link: http://bungeshea.wordpress.com/donate/
44
Tags: snippets, code, php
55
Requires at least: 3.3
6-
Tested up to: 3.4.1
7-
Stable tag: 1.0
6+
Tested up to: 3.4
7+
Stable tag: 1.1
88
License: GPLv3 or later
99
License URI: http://www.gnu.org/copyleft/gpl.html
1010

@@ -20,17 +20,19 @@ Snippets are stored in the `wp_snippets` table in the WordPress database (the ta
2020

2121
Code Snippets includes an option to clean up its data when deactivated. Each screen includes a help tab just in case you get stuck.
2222

23-
Further information and screenshots are available on the plugin homepage at http://bungeshea.wordpress.com/plugins/code-snippets.
23+
Further information and screenshots are available on the [plugin homepage]( http://bungeshea.wordpress.com/plugins/code-snippets).
2424

25-
If you have any feedback, issues or suggestions for improvements please leave start a topic in the [Support Forum](http://wordpress.org/support/plugin/code-snippets) and if you like the plugin please give it a rating at http://wordpress.org/extend/plugins/code-snippets :-)
25+
Code Snippets was featured on WPMU.org - [WordPress Code Snippets: Keep them Organized with this Plugin!](http://wpmu.org/wordpress-code-snippets/)
26+
27+
If you have any feedback, issues or suggestions for improvements please start a topic in the [Support Forum](http://wordpress.org/support/plugin/code-snippets) and if you like the plugin please give it a rating at [WordPress.org](http://wordpress.org/extend/plugins/code-snippets) :-)
2628

2729
== Installation ==
2830

2931
1. Download the `code-snippets.zip` file to your local machine.
30-
2. Either use the automatic plugin installer *(Plugins - Add New)* or Unzip the file and upload the **code-snippets** folder to your `/wp-content/plugins/` directory.
32+
2. Either use the automatic plugin installer *(Plugins > Add New)* or Unzip the file and upload the **code-snippets** folder to your `/wp-content/plugins/` directory.
3133
3. Activate the plugin through the Plugins menu
32-
4. Visit the Add New Snippet menu page **(Snippets > Add New)** to add or edit Snippets.
33-
5. Activate your snippets through the Manage Snippets page **(Snippets > Manage Snippets)**
34+
4. Visit the Add New Snippet menu page *(Snippets > Add New)* to add or edit Snippets.
35+
5. Activate your snippets through the Manage Snippets page *(Snippets > Manage Snippets)*
3436

3537
== Frequently Asked Questions ==
3638

@@ -62,7 +64,14 @@ The import/export feature is currently in development. You can however, use the
6264

6365
== Changelog ==
6466

67+
= 1.1 =
68+
* Fixed a permissions bug with `DISALLOW_FILE_EDIT` being set to true
69+
* Fixed a bug with the page title reading 'Add New Snippet' on the 'Edit Snippets' page
70+
6571
= 1.0 =
6672
* Stable version released.
6773

6874
== Upgrade Notice ==
75+
76+
= 1.1 =
77+
* Minor bug fixes and improvments on the the 'Edit Snippet' page

0 commit comments

Comments
 (0)