Skip to content

Commit

Permalink
Updated to version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sheabunge committed Jun 17, 2013
1 parent c1438e5 commit b8eaf34
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 38 deletions.
77 changes: 50 additions & 27 deletions code-snippets.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<?php

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

// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
Expand Down Expand Up @@ -109,9 +109,9 @@ function uninstall() {
}

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

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

function edit_snippets_help() {

if( isset( $_GET['action'] ) && @$_GET['action'] == 'edit' )
add_filter('admin_title', array( &$this, 'edit_snippets_title' ), 10, 2);

$screen = get_current_screen();
$screen->add_help_tab( array(
'id' => 'overview',
Expand Down Expand Up @@ -320,6 +324,25 @@ function edit_snippets() {
require_once( $this->dirname . '/inc/edit-snippets.php');
}

function edit_snippets_title( $admin_title, $title ) {

$title = 'Edit Snippet';

if ( is_network_admin() )
$admin_title = __( 'Network Admin' );
elseif ( is_user_admin() )
$admin_title = __( 'Global Dashboard' );
else
$admin_title = get_bloginfo( 'name' );

if ( $admin_title == $title )
$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), $title );
else
$admin_title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress' ), $title, $admin_title );

return $admin_title;
}

function uninstall_plugin(){
$msg = '';
if( isset( $_POST['uninstall'] ) ) {
Expand Down
12 changes: 8 additions & 4 deletions inc/edit-snippets.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?php $id = intval( @$_GET['id'] ); ?>
<?php
$edit = isset( $_GET['action'] ) && $_GET['action'] == 'edit';
if( $edit )
$id = intval( $_GET['id'] );
?>
<div class="wrap">
<div id="icon-snippets" class="icon32"><br /></div><h2><?php
if( $_GET['action'] == 'edit' ) :
if( $edit ) :
?>Edit Snippet<a href="<?php echo $this->edit_snippets_url; ?>" class="add-new-h2">Add New</a></h2><?php
else:
?>Add New Snippet</h2>
<?php endif; ?>
<?php if ( strlen($msg) ) : ?>
<?php if ( strlen( $msg ) ) : ?>
<div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
<?php else: ?>
<br />
<?php endif; ?>
<form method="post" action="">
<?php if( $_GET['action'] == 'edit' ) : ?>
<?php if( $edit ) : ?>
<?php $record = $wpdb->get_row( "SELECT * FROM `$this->table_name` WHERE `id` = '$id';" ); ?>
<input type="hidden" name="edit_id" value="<?php echo $id;?>" />
<?php else: ?>
Expand Down
23 changes: 16 additions & 7 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: bungeshea
Donate link: http://bungeshea.wordpress.com/donate/
Tags: snippets, code, php
Requires at least: 3.3
Tested up to: 3.4.1
Stable tag: 1.0
Tested up to: 3.4
Stable tag: 1.1
License: GPLv3 or later
License URI: http://www.gnu.org/copyleft/gpl.html

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

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

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

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 :-)
Code Snippets was featured on WPMU.org - [WordPress Code Snippets: Keep them Organized with this Plugin!](http://wpmu.org/wordpress-code-snippets/)

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) :-)

== Installation ==

1. Download the `code-snippets.zip` file to your local machine.
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.
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.
3. Activate the plugin through the Plugins menu
4. Visit the Add New Snippet menu page **(Snippets > Add New)** to add or edit Snippets.
5. Activate your snippets through the Manage Snippets page **(Snippets > Manage Snippets)**
4. Visit the Add New Snippet menu page *(Snippets > Add New)* to add or edit Snippets.
5. Activate your snippets through the Manage Snippets page *(Snippets > Manage Snippets)*

== Frequently Asked Questions ==

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

== Changelog ==

= 1.1 =
* Fixed a permissions bug with `DISALLOW_FILE_EDIT` being set to true
* Fixed a bug with the page title reading 'Add New Snippet' on the 'Edit Snippets' page

= 1.0 =
* Stable version released.

== Upgrade Notice ==

= 1.1 =
* Minor bug fixes and improvments on the the 'Edit Snippet' page

0 comments on commit b8eaf34

Please sign in to comment.