Code Snippets - Version 1.1

Version Description

  • 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
Download this release

Release Info

Developer bungeshea
Plugin Icon Code Snippets
Version 1.1
Comparing to
See all releases

Version 1.1

code-snippets.php ADDED
@@ -0,0 +1,391 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
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
+ */
28
+
29
+ // Exit if accessed directly
30
+ if ( !defined( 'ABSPATH' ) ) exit;
31
+
32
+ if( !class_exists('code_snippets') ) :
33
+
34
+ class code_snippets {
35
+
36
+ public $table_name = '';
37
+ public $version = '0.1';
38
+ public $current_version = '';
39
+ public $plugin_url = '';
40
+ public $plugin_dir = '';
41
+ public $dirname = '';
42
+
43
+ public $manage_snippets_url = '';
44
+ public $edit_snippets_url = '';
45
+ public $uninstall_plugin_url = '';
46
+
47
+ public $manage_snippets_page;
48
+ public $edit_snippets_page;
49
+ public $uninstall_plugin_page;
50
+
51
+ public function code_snippets(){
52
+ $this->__construct();
53
+ }
54
+
55
+ function __construct() {
56
+ $this->setup_vars(); // initialise the varables
57
+ $this->setup_actions(); // run the actions and filters
58
+ $this->run_snippets(); // execute the snippets
59
+ }
60
+
61
+ function setup_vars(){
62
+ global $wpdb;
63
+ $this->table_name = $wpdb->prefix . 'snippets';
64
+ $this->current_version = get_option( 'cs_db_version' );
65
+ $this->file = __FILE__;
66
+ $this->basename = plugin_basename( $this->file );
67
+ $this->plugin_dir = plugin_dir_path( $this->file );
68
+ $this->plugin_url = plugin_dir_url ( $this->file );
69
+ $this->dirname = dirname( $this->file );
70
+ $this->manage_snippets_url = admin_url( 'admin.php?page=snippets' );
71
+ $this->edit_snippets_url = admin_url( 'admin.php?page=snippet-new' );
72
+ $this->uninstall_plugin_url = admin_url( 'admin.php?page=uninstall-cs' );
73
+ }
74
+
75
+ private function setup_actions(){
76
+ add_action( 'activate_' . $this->basename, array( &$this, 'install' ) );
77
+ add_action( 'deactivate_' . $this->basename, array( &$this, 'uninstall' ) );
78
+ add_action( 'admin_menu', array( &$this, 'add_admin_menus' ) );
79
+ add_filter( 'plugin_action_links', array( $this, 'settings_link' ), 10, 2 );
80
+ }
81
+
82
+ function install() {
83
+ global $wpdb;
84
+ if($wpdb->get_var("SHOW TABLES LIKE '$this->table_name'") != $this->table_name) {
85
+ $sql = 'CREATE TABLE ' . $this->table_name . ' (
86
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
87
+ name varchar(36) NOT NULL,
88
+ description text NOT NULL,
89
+ code text NOT NULL,
90
+ active tinyint(1) NOT NULL DEFAULT 0,
91
+ UNIQUE KEY id (id)
92
+ );';
93
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
94
+ dbDelta( $sql );
95
+ add_option( 'cs_db_version', $this->version );
96
+ }
97
+ }
98
+
99
+ function uninstall() {
100
+ if( get_option( 'cs_complete_uninstall', 0 ) == 1 ) {
101
+ global $wpdb;
102
+ if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name ) {
103
+ $sql = 'DROP TABLE ' . $table_name;
104
+ $wpdb->query( $sql );
105
+ delete_option( 'cs_db_version' );
106
+ delete_option( 'cs_complete_uninstall' );
107
+ }
108
+ }
109
+ }
110
+
111
+ function add_admin_menus() {
112
+ $this->manage_snippets_page = add_menu_page( 'Snippets', 'Snippets', 'install_plugins', 'snippets', array( &$this, 'manage_snippets' ), $this->plugin_url . 'img/icon16.png', 67 );
113
+ 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', 'install_plugins', 'snippet-new', array( &$this, 'edit_snippets' ) );
115
+ $this->uninstall_plugin_page = add_submenu_page( 'snippets', 'Uninstall Code Snippets', 'Uninstall', 'install_plugins', 'uninstall-cs', array( &$this, 'uninstall_plugin' ) );
116
+
117
+ add_action( 'admin_print_styles-' . $this->manage_snippets_page, array( $this, 'load_stylesheet' ), 5 );
118
+ add_action( 'admin_print_styles-' . $this->edit_snippets_page, array( $this, 'load_stylesheet' ), 5 );
119
+ add_action( 'admin_print_styles-' . $this->uninstall_plugin_page, array( $this, 'load_stylesheet' ), 5 );
120
+ add_action( 'admin_print_scripts-' . $this->edit_snippets_page, array( $this, 'load_tabby' ), 5 );
121
+ add_action( 'load-' . $this->manage_snippets_page, array( $this, 'manage_snippets_help' ), 5 );
122
+ add_action( 'load-' . $this->edit_snippets_page, array( $this, 'edit_snippets_help' ), 5 );
123
+ add_action( 'load-' . $this->uninstall_plugin_page, array( $this, 'uninstall_plugin_help' ), 5 );
124
+ }
125
+
126
+ function load_stylesheet() {
127
+ wp_enqueue_style('code-snippets-admin-style', plugins_url( 'css/style.css', $this->file), false, $this->version );
128
+ }
129
+
130
+ function load_tabby() {
131
+ wp_enqueue_script( 'tabby', plugins_url( 'js/jquery.textarea.js', $this->file), array( 'jquery' ), 0.12 );
132
+ }
133
+
134
+ function manage_snippets_help() {
135
+ $screen = get_current_screen();
136
+ $screen->add_help_tab( array(
137
+ 'id' => 'overview',
138
+ 'title' => 'Overview',
139
+ 'content' =>
140
+ "<p>Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. Here you can manage your existing snippets and preform tasks on them such as activating, deactivating, deleting and exporting.</p>"
141
+ ) );
142
+ $screen->add_help_tab( array(
143
+ 'id' => 'compatibility-problems',
144
+ 'title' => 'Troubleshooting',
145
+ 'content' =>
146
+ "<p>Be sure to check your snippets for errors before you activate them as a faulty snippet could bring your whole blog down. If your site starts doing strange things, deactivate all your snippets and activate them one at a time.</p>" .
147
+ "<p>If something goes wrong with a snippet and you can&#8217;t use WordPress, you can use a database manager like phpMyAdmin to access the <code>$this->table_name</code> table in your WordPress database. Locate the offending snippet (if you know which one is the trouble) and change the 1 in the 'active' column into a 0. If this doesn't work try doing this for all snippets.</p>"
148
+ ) );
149
+
150
+ $screen->set_help_sidebar(
151
+ "<p><strong>For more information:</strong></p>" .
152
+ "<p><a href='http://wordpress.org/extend/plugins/code-snippets' target='_blank'>WordPress Extend</a></p>" .
153
+ "<p><a href='http://wordpress.org/support/plugin/code-snippets' target='_blank'>Support Forums</a></p>" .
154
+ "<p><a href='http://bungeshea.wordpress.org/plugins/code-snippets' target='_blank'>SheaPress</a></p>"
155
+ );
156
+ }
157
+
158
+ 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
+
163
+ $screen = get_current_screen();
164
+ $screen->add_help_tab( array(
165
+ 'id' => 'overview',
166
+ 'title' => 'Overview',
167
+ 'content' =>
168
+ "<p>Snippets are similar to plugins - they both extend and expand the functionality of WordPress. Snippets are more light-weight, just a few lines of code, and do not put as much load on your server. Here you can add a new snippet or edit an existing one.</p>"
169
+ ) );
170
+ $screen->add_help_tab( array(
171
+ 'id' => 'finding',
172
+ 'title' => 'Finding Snippets',
173
+ 'content' =>
174
+ "<p>Here are some links to websites which host a large number of snippets that you can add to your site.
175
+ <ul>
176
+ <li><a href='http://code-snippets.com'>WordPress Snippets</a></li>
177
+ <li><a href='http://wpsnipp.com'>WP Snipp</a></li>
178
+ <li><a href='http://catswhocode.com/blog/snippets'>Cats Who Code Snippet Library</a></li>
179
+ <li><a href='http://wpmu.org'>WPMU - The WordPress Experts</a></li>
180
+ </ul>
181
+ Snippets can be installed through the <a href='$this->edit_snippets_url'>Add New Snippet</a> page or by addng them to the <code>$this->table_name</code> table in the database (Warning: for advanced users only). Once a snippet has been installed, you can activate it here.</p>"
182
+ ) );
183
+ $screen->add_help_tab( array(
184
+ 'id' => 'adding',
185
+ 'title' => 'Adding Snippets',
186
+ 'content' =>
187
+ "<p>You need to fill out the name and code fields for your snippet to be added. While the description field will add more information about how your snippet works, what is does and where you found it, it is completely optional.</p>" .
188
+ "<p>Make sure that you don't add the <code>&lt;?php</code>, <code>&lt;?</code> or <code>?&gt;</code> the beginning and end of the code. You can however use these tags in the code to stop and start PHP sections</p>" .
189
+ "<p>Please be sure to check thst your snippet is valid PHP code and will not produce errors before adding it through this page. While doing so will not become active straght away, it will help to minimise the chance of a faulty snippet becoming active on your site.</p>"
190
+ ) );
191
+
192
+ $screen->set_help_sidebar(
193
+ "<p><strong>For more information:</strong></p>" .
194
+ "<p><a href='http://wordpress.org/extend/plugins/code-snippets' target='_blank'>WordPress Extend</a></p>" .
195
+ "<p><a href='http://wordpress.org/support/plugin/code-snippets' target='_blank'>Support Forums</a></p>" .
196
+ "<p><a href='http://bungeshea.wordpress.org/plugins/code-snippets' target='_blank'>SheaPress</a></p>"
197
+ );
198
+ }
199
+
200
+ function uninstall_plugin_help() {
201
+ $screen = get_current_screen();
202
+ $screen->add_help_tab( array(
203
+ 'id' => 'overview',
204
+ 'title' => 'Overview',
205
+ 'content' =>
206
+ "<p>If you are absolutly sure that you will never, ever want to use the Code Snippets plugin ever again in your entire life on this WordPress installation, you can use this page to tell Code Snippets to clear all of its data when deactivated. Simply check the box below and click on the submit button. If you realise what a cool plugin Code Snippets actually is before you get around to deactivating the plugin you can come back here and uncheck the box. If the box is selected when Code Snippets is deactivated it will clear up the <code>$this->table_name</code> table and a few other bits of data stored in the database.</p>" .
207
+ "<p>Even if you're sure that you don't want to use Code Snippets on this WordPress installaion, you may want to use phpMyAdmin to back up the <code>$this->table_name</code> table in the database. You can later use phpMyAdmin to import it back.</p>"
208
+ ) );
209
+
210
+ $screen->set_help_sidebar(
211
+ "<p><strong>For more information:</strong></p>" .
212
+ "<p><a href='http://wordpress.org/extend/plugins/code-snippets' target='_blank'>WordPress Extend</a></p>" .
213
+ "<p><a href='http://wordpress.org/support/plugin/code-snippets' target='_blank'>Support Forums</a></p>" .
214
+ "<p><a href='http://bungeshea.wordpress.org/plugins/code-snippets' target='_blank'>SheaPress</a></p>"
215
+ );
216
+ }
217
+
218
+ function manage_snippets() {
219
+ global $wpdb;
220
+ $msg = '';
221
+ if( isset( $_POST['action'] ) && isset( $_POST['snippets'] ) && is_array( $_POST['snippets'] ) ) {
222
+ $count = 0;
223
+ switch( $_POST['action'] ) {
224
+
225
+ case 'activate':
226
+ foreach($_POST['snippets'] as $bd) {
227
+ $wpdb->query('update ' . $this->table_name . ' set active=1 where id=' . intval( $bd ) . ' limit 1' );
228
+ $count++;
229
+ }
230
+ $msg = "Activated $count snippets.";
231
+ break;
232
+
233
+ case 'deactivate':
234
+ foreach($_POST['snippets'] as $bd) {
235
+ $wpdb->query('update ' . $this->table_name . ' set active=0 where id=' . intval( $bd ) . ' limit 1' );
236
+ $count++;
237
+ }
238
+ $msg = "Deactivated $count snippets.";
239
+ break;
240
+
241
+ case 'delete':
242
+ foreach( $_POST['snippets'] as $bd) {
243
+ $wpdb->query("delete from ".$wpdb->prefix."snippets where id=".intval($bd)." limit 1");
244
+ $count++;
245
+ }
246
+ $msg = "Deleted $count snippets.";
247
+ break;
248
+ }
249
+ }
250
+
251
+ if( isset( $_POST['action2'] ) && isset( $_POST['snippets'] ) && is_array( $_POST['snippets'] ) ) {
252
+ $count = 0;
253
+ switch( $_POST['action2'] ) {
254
+
255
+ case 'activate':
256
+ foreach($_POST['snippets'] as $bd) {
257
+ $wpdb->query('update ' . $this->table_name . ' set active=1 where id=' . intval( $bd ) . ' limit 1' );
258
+ $count++;
259
+ }
260
+ $msg = "Activated $count snippets.";
261
+ break;
262
+
263
+ case 'deactivate':
264
+ foreach($_POST['snippets'] as $bd) {
265
+ $wpdb->query('update ' . $this->table_name . ' set active=0 where id=' . intval( $bd ) . ' limit 1' );
266
+ $count++;
267
+ }
268
+ $msg = "Deactivated $count snippets.";
269
+ break;
270
+
271
+ case 'delete':
272
+ foreach( $_POST['snippets'] as $bd) {
273
+ $wpdb->query("delete from ".$wpdb->prefix."snippets where id=".intval($bd)." limit 1");
274
+ $count++;
275
+ }
276
+ $msg = "Deleted $count snippets.";
277
+ break;
278
+ }
279
+ }
280
+
281
+ if( isset( $_GET['action'] ) && isset( $_GET['id'] ) ) {
282
+ if( $_GET['action'] == 'delete') {
283
+ $wpdb->query( 'delete from ' . $this->table_name . ' where id=' . intval( $_GET['id'] ) . ' limit 1' );
284
+ $msg = 'Snippet deleted.';
285
+ }
286
+ elseif( $_GET['action'] == 'activate' ) {
287
+ $wpdb->query('update ' . $this->table_name . ' set active=1 where id=' . intval( $_GET['id'] ) . ' limit 1' );
288
+ $msg = 'Snippet activated.';
289
+ }
290
+ elseif( $_GET['action'] == 'deactivate' ) {
291
+ $wpdb->query('update ' . $this->table_name . ' set active=0 where id=' . intval( $_GET['id'] ) . ' limit 1' );
292
+ $msg = 'Snippet deactivated.';
293
+ }
294
+ }
295
+
296
+ require_once( $this->dirname . '/inc/manage-snippets.php');
297
+ }
298
+
299
+ function edit_snippets() {
300
+ global $wpdb;
301
+ $msg = '';
302
+ if( isset( $_POST['save_snippet'] ) ) {
303
+ $name = mysql_real_escape_string( htmlspecialchars( $_POST['snippet_name' ] ) );
304
+ $description = mysql_real_escape_string( htmlspecialchars( $_POST['snippet_description'] ) );
305
+ $code = mysql_real_escape_string( htmlspecialchars( $_POST['snippet_code'] ) );
306
+
307
+ if( strlen( $name ) && strlen( $code ) ) {
308
+ if( isset($_POST['edit_id'] ) ) {
309
+ $wpdb-> query( "update $this->table_name set name='".$name."',
310
+ description='".$description."',
311
+ code='".$code."'
312
+ where id=" . intval($_POST["edit_id"]." limit 1"));
313
+ $msg = 'Snippet updated.';
314
+ }
315
+ else {
316
+ $wpdb->query( "insert into $this->table_name(name,description,code,active) VALUES ('$name','$description','$code',0)" );
317
+ $msg = 'Snippet added.';
318
+ }
319
+ }
320
+ else {
321
+ $msg = 'Please provide a name for the snippet and the code.';
322
+ }
323
+ }
324
+ require_once( $this->dirname . '/inc/edit-snippets.php');
325
+ }
326
+
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
+
346
+ function uninstall_plugin(){
347
+ $msg = '';
348
+ if( isset( $_POST['uninstall'] ) ) {
349
+ if(isset( $_POST['ch_unin']) ) {
350
+ update_option('cs_complete_uninstall' , 1);
351
+ $msg = 'Option updated. Please deactivate the Code Snippets plugin to clear all data.';
352
+ }
353
+ else {
354
+ update_option('cs_complete_uninstall', 0);
355
+ $msg = 'Option updated. Code Snippets will retain its data when deactivated';
356
+ }
357
+ }
358
+ require_once( $this->dirname . '/inc/uninstall-plugin.php');
359
+ }
360
+
361
+ function settings_link( $links, $file ){
362
+ static $this_plugin;
363
+ if ( ! $this_plugin ) {
364
+ $this_plugin = plugin_basename( __FILE__ );
365
+ }
366
+ if ( $file == $this_plugin ) {
367
+ $settings_link = '<a href="' . $this->manage_snippets_url . '">Settings</a>';
368
+ array_unshift( $links, $settings_link );
369
+ }
370
+ return $links;
371
+ }
372
+
373
+ function run_snippets() {
374
+ global $wpdb;
375
+ // grab the active snippets from the database
376
+ $active_snippets = $wpdb->get_results( 'select * FROM `' . $this->table_name . '` WHERE `active` = 1;' );
377
+ if( count( $active_snippets ) ) {
378
+ foreach( $active_snippets as $snippet ) {
379
+ // execute the php code
380
+ $result = @eval( htmlspecialchars_decode( stripslashes( $snippet->code ) ) );
381
+ }
382
+ }
383
+ }
384
+ }
385
+
386
+ endif; // class exists check
387
+
388
+ global $cs;
389
+ $cs = new code_snippets;
390
+
391
+ ?>
css/style.css ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #icon-snippets.icon32{
2
+ background: url('../img/icon32.png') no-repeat scroll transparent;
3
+ }
4
+
5
+ /* Snippets > Manage Snippets */
6
+
7
+ .inactive a:hover{
8
+ color: #d54e21;
9
+ }
10
+
11
+ a.delete:hover {
12
+ color: #f00;
13
+ border-bottom-color: #f00;
14
+ }
15
+
16
+ a.delete{
17
+ color: #21759b;
18
+ }
19
+
20
+ tr{
21
+ background-color: #fcfcfc;
22
+ }
23
+
24
+ .inactive,
25
+ .inactive th,
26
+ .inactive td{
27
+ background-color: #f4f4f4;
28
+ }
29
+
30
+ .active,
31
+ .active th,
32
+ .active td {
33
+ color: #000;
34
+ }
35
+
36
+ .inactive a {
37
+ color: #557799;
38
+
39
+ }
img/icon-big.png ADDED
Binary file
img/icon-horiz.png ADDED
Binary file
img/icon-med.png ADDED
Binary file
img/icon-small.png ADDED
Binary file
img/icon.odg ADDED
Binary file
img/icon.svg ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
3
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
4
+ <svg height="400pt" id="svg548" inkscape:version="0.38.1" sodipodi:docbase="/var/www/html/svg_gallery/svg/office" sodipodi:docname="scissors.svg" sodipodi:version="0.32" width="400pt" xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink">
5
+ <metadata>
6
+ <rdf:RDF xmlns:cc="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
7
+ <cc:Work rdf:about="">
8
+ <dc:title>Clipart by Nicu Buculei - book_01</dc:title>
9
+ <dc:description/>
10
+ <dc:subject>
11
+ <rdf:Bag>
12
+ <rdf:li>hash</rdf:li>
13
+ <rdf:li/>
14
+ <rdf:li>education</rdf:li>
15
+ </rdf:Bag>
16
+ </dc:subject>
17
+ <dc:publisher>
18
+ <cc:Agent rdf:about="http://www.openclipart.org">
19
+ <dc:title>Nicu Buculei</dc:title>
20
+ </cc:Agent>
21
+ </dc:publisher>
22
+ <dc:creator>
23
+ <cc:Agent>
24
+ <dc:title>Nicu Buculei</dc:title>
25
+ </cc:Agent>
26
+ </dc:creator>
27
+ <dc:rights>
28
+ <cc:Agent>
29
+ <dc:title>Nicu Buculei</dc:title>
30
+ </cc:Agent>
31
+ </dc:rights>
32
+ <dc:date/>
33
+ <dc:format>image/svg+xml</dc:format>
34
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
35
+ <cc:license rdf:resource="http://web.resource.org/cc/PublicDomain"/>
36
+ <dc:language>en</dc:language>
37
+ </cc:Work>
38
+ <cc:License rdf:about="http://web.resource.org/cc/PublicDomain">
39
+ <cc:permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
40
+ <cc:permits rdf:resource="http://web.resource.org/cc/Distribution"/>
41
+ <cc:permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
42
+ </cc:License>
43
+ </rdf:RDF>
44
+ </metadata>
45
+ <defs id="defs550"/>
46
+ <sodipodi:namedview id="base" inkscape:cx="199.99999" inkscape:cy="200.00006" inkscape:window-height="625" inkscape:window-width="673" inkscape:window-x="137" inkscape:window-y="24" inkscape:zoom="1.0000000" showgrid="true"/>
47
+ <g id="g834">
48
+ <path d="M 130.58 19.2281 C 131.428 19.2281 283.206 268.517 283.206 268.517 C 283.206 268.517 237.418 294.803 238.266 294.803 C 239.114 294.803 112.774 100.629 130.58 19.2281 z " id="path693" style="font-size:12.000000;fill:#dadadb;fill-rule:evenodd;stroke:#000000;stroke-width:10.000006;stroke-linejoin:round;stroke-dasharray:none;" transform="matrix(-0.974540,0.224211,0.224211,0.974540,434.7533,-39.90828)"/>
49
+ <path d="M 267.3664 300.2850 C 267.3664 300.2850 221.9645 419.3382 230.3672 437.0187 C 230.0041 447.8045 196.5707 496.4724 174.9575 496.9446 C 156.3212 498.1163 95.02330 483.4552 104.8511 423.1945 C 116.5367 361.1971 166.8067 382.6865 186.6819 380.3566 C 206.5578 378.0260 240.3401 301.1756 216.8954 284.7878 C 243.0601 291.6678 266.7066 302.0627 267.3664 300.2850 z M 178.0108 388.4627 C 110.2231 370.5833 97.04385 476.9229 157.4235 483.1557 C 225.1185 486.0350 224.5492 396.0294 178.0108 388.4627 z " id="path596" style="font-size:12.000000;fill:#3f3f3f;fill-rule:evenodd;stroke:#000000;stroke-width:10.000000;stroke-linejoin:bevel;stroke-dasharray:none;"/>
50
+ <path d="M 130.58 19.2281 C 131.428 19.2281 283.206 268.517 283.206 268.517 C 283.206 268.517 237.418 294.803 238.266 294.803 C 239.114 294.803 112.774 100.629 130.58 19.2281 z " id="path674" style="font-size:12.000000;fill:#dadadb;fill-rule:evenodd;stroke:#000000;stroke-width:9.9999930;stroke-linejoin:bevel;stroke-dasharray:none;" transform="matrix(0.984591,0.174877,-0.174877,0.984591,41.27270,-35.37063)"/>
51
+ <path d="M 81.4005 200.683 C 66.1379 201.531 63.5942 225.273 81.4005 226.121 C 98.359 225.273 98.3592 200.683 81.4005 200.683 z " id="path710" sodipodi:nodetypes="ccc" style="font-size:12.000000;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:6.2500000;stroke-dasharray:none;" transform="translate(161.5948,57.16911)"/>
52
+ <path d="M 69.5296 209.163 C 71.2255 209.163 86.4881 224.425 86.4881 224.425 " id="path711" style="font-size:12.000000;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:6.2500000;stroke-dasharray:none;" transform="translate(161.5948,57.16911)"/>
53
+ <path d="M 76.313 203.227 C 77.1609 203.227 92.4235 218.49 92.4235 218.49 " id="path712" sodipodi:nodetypes="cc" style="font-size:12.000000;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:6.2500000;stroke-dasharray:none;" transform="translate(161.5948,57.16911)"/>
54
+ <path d="M 311.59912,21.282200 C 312.44712,21.282200 250.54912,207.82500 250.54912,207.82500 C 250.54912,207.82500 257.17737,220.62188 259.72037,219.77388 C 262.26437,218.92588 318.38312,30.609400 311.59912,21.282200 z " id="path717" sodipodi:nodetypes="cccc" style="font-size:12.000000;fill:#e6ffff;fill-opacity:0.75000000;fill-rule:evenodd;stroke-width:1.0000000pt;"/>
55
+ <path d="M 236.859 262.031 L 240.39 257.083 L 256.632 272.608 L 252.681 276.708 L 236.859 262.031 z " id="path718" sodipodi:nodetypes="ccccc" style="font-size:12.000000;fill-opacity:0.31851897;fill-rule:evenodd;stroke-width:1.0000000pt;" transform="translate(-3.750000,3.750000)"/>
56
+ <path d="M 319.2507 379.5357 C 386.0528 358.2670 404.5676 463.8086 344.5781 473.0725 C 277.1137 479.3553 273.1522 389.4350 319.2507 379.5357 z M 225.5702 295.9670 C 225.5702 295.9670 276.9068 412.5843 269.4045 430.6653 C 270.3101 441.4191 306.1506 488.3427 327.7603 487.7265 C 346.4319 487.9587 406.9143 470.2310 394.0659 410.5412 C 379.2748 349.2105 330.1500 373.2028 310.1827 371.8762 C 290.2146 370.5489 252.6071 295.4962 275.1973 277.9491 C 249.4120 286.1373 226.3186 297.7092 225.5702 295.9670 z " id="path590" style="font-size:12.000000;fill:#3f3f40;fill-rule:evenodd;stroke:#000000;stroke-width:10.000000;stroke-linejoin:bevel;stroke-dasharray:none;"/>
57
+ </g>
58
+ </svg>
img/icon16.png ADDED
Binary file
img/icon32.png ADDED
Binary file
inc/edit-snippets.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $edit = isset( $_GET['action'] ) && $_GET['action'] == 'edit';
3
+ if( $edit )
4
+ $id = intval( $_GET['id'] );
5
+ ?>
6
+ <div class="wrap">
7
+ <div id="icon-snippets" class="icon32"><br /></div><h2><?php
8
+ if( $edit ) :
9
+ ?>Edit Snippet<a href="<?php echo $this->edit_snippets_url; ?>" class="add-new-h2">Add New</a></h2><?php
10
+ else:
11
+ ?>Add New Snippet</h2>
12
+ <?php endif; ?>
13
+ <?php if ( strlen( $msg ) ) : ?>
14
+ <div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
15
+ <?php else: ?>
16
+ <br />
17
+ <?php endif; ?>
18
+ <form method="post" action="">
19
+ <?php if( $edit ) : ?>
20
+ <?php $record = $wpdb->get_row( "SELECT * FROM `$this->table_name` WHERE `id` = '$id';" ); ?>
21
+ <input type="hidden" name="edit_id" value="<?php echo $id;?>" />
22
+ <?php else: ?>
23
+ <?php
24
+ // define a empty object (or one with default values)
25
+ $record = new stdClass();
26
+ $record->name = '';
27
+ $record->description = '';
28
+ $record->code = '';
29
+ ?>
30
+ <?php endif; ?>
31
+
32
+ <div id="titlediv">
33
+ <div id="titlewrap">
34
+ <label for="title" style="display:none">Name (short title)</label>
35
+ <input id="title" type="text" autocomplete="off" size="30" name="snippet_name" value="<?php echo stripslashes( $record->name ); ?>" placeholder="Name (short title)">
36
+ </div>
37
+ </div>
38
+
39
+ <label for="snippet_code"><h3 style="display:inline">Code</h3>
40
+ <span style="float:right">Enter or paste the snippet code without the <code>&lt;?php</code> and <code>?&gt;</code> tags.</span></label><br />
41
+ <textarea id="snippet_code" name="snippet_code" rows="20" spellcheck="false" style="font-family:monospace;width:100%"><?php echo htmlspecialchars_decode( stripslashes( $record->code ) );?></textarea>
42
+ <br style="margin: 20px;" />
43
+ <div id="desclabel">
44
+ <label for="description" style="text-align:center; margin: 10px auto"><h3 style="display:inline">Description</h3> (Optional)</label><br />
45
+ </div>
46
+ <?php wp_editor( htmlspecialchars_decode( stripslashes( $record->description ) ), 'description', array( 'textarea_name' => 'snippet_description', 'textarea_rows' => 10 ) ); ?>
47
+ <p class="submit">
48
+ <input tabindex="15" type="submit" name="save_snippet" class="button-primary" value="Save" />
49
+ <a href="<?php echo $this->manage_snippets_url; ?>" class="button">Cancel</a>
50
+ </p>
51
+ </form>
52
+ </div>
53
+ <script type="text/javascript">
54
+ //<![CDATA[
55
+ jQuery(document).ready(function() {
56
+
57
+ jQuery('textarea').tabby();
58
+
59
+ });
60
+ //]]>
61
+ </script>
inc/manage-snippets.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php global $wpdb; ?>
2
+ <div class="wrap">
3
+ <div id="icon-snippets" class="icon32"><br /></div><h2>Snippets <a href="<?php echo $this->edit_snippets_url; ?>" class="add-new-h2">Add New</a></h2>
4
+ <?php if ( strlen( $msg ) ) : ?>
5
+ <div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
6
+ <?php endif; ?>
7
+ <?php $snippets = $wpdb->get_results( 'select * from ' . $this->table_name ); ?>
8
+ <form action="" method="post">
9
+ <div class="tablenav top">
10
+ <div class="alignleft actions">
11
+ <select name='action' class="bulk-actions">
12
+ <option value='-1' selected='selected'>Bulk Actions</option>
13
+ <option value='activate'>Activate</option>
14
+ <option value='deactivate'>Deactivate</option>
15
+ <option value='delete'>Delete</option>
16
+ </select>
17
+ <input type="submit" id="doaction" class="button-secondary" value="Apply" />
18
+ </div>
19
+ </div>
20
+ <table class="widefat manage-snippets" style="margin-top: .5em">
21
+ <thead>
22
+ <tr>
23
+ <th scope="col" class="check-column"><input type="checkbox" name="toggle" id="toggle" /></th>
24
+ <th scope="col" id="name">Name</th>
25
+ <th scope="col" id="description">Description</th>
26
+ </tr>
27
+ </thead>
28
+ <?php if( count( $snippets ) ): ?>
29
+ <?php foreach( $snippets as $snippet ) : ?>
30
+ <tr class='<?php
31
+ if($snippet->active == false)
32
+ echo 'inactive';
33
+ else
34
+ echo 'active';
35
+ ?>'>
36
+ <th scope="row" class="check-column"><input class="snippets" type="checkbox" name="snippets[]" value="<?php echo $snippet->id; ?>" /></th>
37
+ <td class="snippet-title"><strong><?php echo stripslashes($snippet->name);?></strong>
38
+ <div class="row-actions-visible">
39
+ <?php if( $snippet->active == 0 ) : ?>
40
+ <span class='activate'><a href="<?php echo $this->manage_snippets_url . '&action=activate&id=' . $snippet->id; ?>" title="Activate this plugin" class="edit">Activate</a> | </span>
41
+ <?php else : ?>
42
+ <span class='deactivate'><a href="<?php echo $this->manage_snippets_url . '&action=deactivate&id=' . $snippet->id; ?>" title="Deactivate this plugin" class="edit">Deactivate</a> | </span>
43
+ <?php endif; ?>
44
+ <span class='edit'><a href="<?php echo $this->edit_snippets_url . '&action=edit&id=' . $snippet->id; ?>" title="Edit this Snippet" class="edit">Edit</a> | </span>
45
+ <span class='delete'><a href="<?php echo $this->manage_snippets_url . '&action=delete&id=' . $snippet->id; ?>" title="Delete this plugin" class="delete" onclick="return confirm('Are you sure? This action is non-reversable');">Delete</a></span>
46
+ </div>
47
+ </td>
48
+ <td><?php echo stripslashes( html_entity_decode( $snippet->description ) ); ?></td>
49
+ </tr>
50
+ <?php endforeach; ?>
51
+ <?php else: ?>
52
+ <tr id='no-groups'>
53
+ <th scope="row" class="check-column">&nbsp;</th>
54
+ <td colspan="4">You do not appear to have any snippets available at this time.</td>
55
+ </tr>
56
+ <?php endif;?>
57
+ </table>
58
+ <div class="tablenav bottom">
59
+ <div class="alignleft actions">
60
+ <select name='action2' class="bulk-actions">
61
+ <option value='-1' selected='selected'>Bulk Actions</option>
62
+ <option value='activate'>Activate</option>
63
+ <option value='deactivate'>Deactivate</option>
64
+ <option value='delete'>Delete</option>
65
+ </select>
66
+ <input type="submit" id="doaction2" class="button-secondary action" value="Apply" />
67
+ </div>
68
+ </div>
69
+ </form>
70
+ </div>
inc/uninstall-plugin.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <div id="icon-snippets" class="icon32"><br /></div><h2>Uninstall Code Snippets</h2>
3
+ <?php if ( strlen($msg) ) : ?>
4
+ <div id="message" class="updated fade"><p><?php echo $msg; ?></p></div>
5
+ <?php endif; ?>
6
+ <p>Checking this box will remove all snippets and the table from the database when the plugin is deactivated.</p>
7
+ <p>Only use if permanently uninstalling the Code Snippets plugin.</p>
8
+ <p>You can come back here before deactivating the plugin and change your choice.</p>
9
+ <form action="" method="post">
10
+ <?php $check_uninstall = ( get_option( 'cs_complete_uninstall',0 ) == 1 ) ? 'checked' : 'id="unin"'; ?>
11
+ <input type="checkbox" name="ch_unin" <?php echo $check_uninstall; ?> style="margin-right: 5px" />
12
+ <input tabindex="15" type="submit" name="uninstall" class="button-primary" value="Submit"/>
13
+ </form>
14
+ <script type="text/javascript">
15
+ //<![CDATA[
16
+ var cb = jQuery('#unin');
17
+ if(cb.length) {
18
+ cb.click(function() {
19
+ if(confirm('Are you sure? \nYou will permanently lose your snippets when the plugin is deactivated.')) {
20
+ cb.unbind('click');
21
+ return true;
22
+ }
23
+ else {
24
+ return false;
25
+ }
26
+ });
27
+ }
28
+ //]]>
29
+ </script>
30
+ </div>
js/jquery.textarea.js ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Tabby jQuery plugin version 0.12
3
+ *
4
+ * Ted Devito - http://teddevito.com/demos/textarea.html
5
+ *
6
+ * Copyright (c) 2009 Ted Devito
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
9
+ * conditions are met:
10
+ *
11
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
13
+ * in the documentation and/or other materials provided with the distribution.
14
+ * 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written
15
+ * permission.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
19
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
22
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ *
24
+ */
25
+
26
+ // create closure
27
+
28
+ (function($) {
29
+
30
+ // plugin definition
31
+
32
+ $.fn.tabby = function(options) {
33
+ //debug(this);
34
+ // build main options before element iteration
35
+ var opts = $.extend({}, $.fn.tabby.defaults, options);
36
+ var pressed = $.fn.tabby.pressed;
37
+
38
+ // iterate and reformat each matched element
39
+ return this.each(function() {
40
+ $this = $(this);
41
+
42
+ // build element specific options
43
+ var options = $.meta ? $.extend({}, opts, $this.data()) : opts;
44
+
45
+ $this.bind('keydown',function (e) {
46
+ var kc = $.fn.tabby.catch_kc(e);
47
+ if (16 == kc) pressed.shft = true;
48
+ /*
49
+ because both CTRL+TAB and ALT+TAB default to an event (changing tab/window) that
50
+ will prevent js from capturing the keyup event, we'll set a timer on releasing them.
51
+ */
52
+ if (17 == kc) {pressed.ctrl = true; setTimeout("$.fn.tabby.pressed.ctrl = false;",1000);}
53
+ if (18 == kc) {pressed.alt = true; setTimeout("$.fn.tabby.pressed.alt = false;",1000);}
54
+
55
+ if (9 == kc && !pressed.ctrl && !pressed.alt) {
56
+ e.preventDefault; // does not work in O9.63 ??
57
+ pressed.last = kc; setTimeout("$.fn.tabby.pressed.last = null;",0);
58
+ process_keypress ($(e.target).get(0), pressed.shft, options);
59
+ return false;
60
+ }
61
+
62
+ }).bind('keyup',function (e) {
63
+ if (16 == $.fn.tabby.catch_kc(e)) pressed.shft = false;
64
+ }).bind('blur',function (e) { // workaround for Opera -- http://www.webdeveloper.com/forum/showthread.php?p=806588
65
+ if (9 == pressed.last) $(e.target).one('focus',function (e) {pressed.last = null;}).get(0).focus();
66
+ });
67
+
68
+ });
69
+ };
70
+
71
+ // define and expose any extra methods
72
+ $.fn.tabby.catch_kc = function(e) { return e.keyCode ? e.keyCode : e.charCode ? e.charCode : e.which; };
73
+ $.fn.tabby.pressed = {shft : false, ctrl : false, alt : false, last: null};
74
+
75
+ // private function for debugging
76
+ function debug($obj) {
77
+ if (window.console && window.console.log)
78
+ window.console.log('textarea count: ' + $obj.size());
79
+ };
80
+
81
+ function process_keypress (o,shft,options) {
82
+ var scrollTo = o.scrollTop;
83
+ //var tabString = String.fromCharCode(9);
84
+
85
+ // gecko; o.setSelectionRange is only available when the text box has focus
86
+ if (o.setSelectionRange) gecko_tab (o, shft, options);
87
+
88
+ // ie; document.selection is always available
89
+ else if (document.selection) ie_tab (o, shft, options);
90
+
91
+ o.scrollTop = scrollTo;
92
+ }
93
+
94
+ // plugin defaults
95
+ $.fn.tabby.defaults = {tabString : String.fromCharCode(9)};
96
+
97
+ function gecko_tab (o, shft, options) {
98
+ var ss = o.selectionStart;
99
+ var es = o.selectionEnd;
100
+
101
+ // when there's no selection and we're just working with the caret, we'll add/remove the tabs at the caret, providing more control
102
+ if(ss == es) {
103
+ // SHIFT+TAB
104
+ if (shft) {
105
+ // check to the left of the caret first
106
+ if ("\t" == o.value.substring(ss-options.tabString.length, ss)) {
107
+ o.value = o.value.substring(0, ss-options.tabString.length) + o.value.substring(ss); // put it back together omitting one character to the left
108
+ o.focus();
109
+ o.setSelectionRange(ss - options.tabString.length, ss - options.tabString.length);
110
+ }
111
+ // then check to the right of the caret
112
+ else if ("\t" == o.value.substring(ss, ss + options.tabString.length)) {
113
+ o.value = o.value.substring(0, ss) + o.value.substring(ss + options.tabString.length); // put it back together omitting one character to the right
114
+ o.focus();
115
+ o.setSelectionRange(ss,ss);
116
+ }
117
+ }
118
+ // TAB
119
+ else {
120
+ o.value = o.value.substring(0, ss) + options.tabString + o.value.substring(ss);
121
+ o.focus();
122
+ o.setSelectionRange(ss + options.tabString.length, ss + options.tabString.length);
123
+ }
124
+ }
125
+ // selections will always add/remove tabs from the start of the line
126
+ else {
127
+ // split the textarea up into lines and figure out which lines are included in the selection
128
+ var lines = o.value.split("\n");
129
+ var indices = new Array();
130
+ var sl = 0; // start of the line
131
+ var el = 0; // end of the line
132
+ var sel = false;
133
+ for (var i in lines) {
134
+ el = sl + lines[i].length;
135
+ indices.push({start: sl, end: el, selected: (sl <= ss && el > ss) || (el >= es && sl < es) || (sl > ss && el < es)});
136
+ sl = el + 1;// for "\n"
137
+ }
138
+
139
+ // walk through the array of lines (indices) and add tabs where appropriate
140
+ var modifier = 0;
141
+ for (var i in indices) {
142
+ if (indices[i].selected) {
143
+ var pos = indices[i].start + modifier; // adjust for tabs already inserted/removed
144
+ // SHIFT+TAB
145
+ if (shft && options.tabString == o.value.substring(pos,pos+options.tabString.length)) { // only SHIFT+TAB if there's a tab at the start of the line
146
+ o.value = o.value.substring(0,pos) + o.value.substring(pos + options.tabString.length); // omit the tabstring to the right
147
+ modifier -= options.tabString.length;
148
+ }
149
+ // TAB
150
+ else if (!shft) {
151
+ o.value = o.value.substring(0,pos) + options.tabString + o.value.substring(pos); // insert the tabstring
152
+ modifier += options.tabString.length;
153
+ }
154
+ }
155
+ }
156
+ o.focus();
157
+ var ns = ss + ((modifier > 0) ? options.tabString.length : (modifier < 0) ? -options.tabString.length : 0);
158
+ var ne = es + modifier;
159
+ o.setSelectionRange(ns,ne);
160
+ }
161
+ }
162
+
163
+ function ie_tab (o, shft, options) {
164
+ var range = document.selection.createRange();
165
+
166
+ if (o == range.parentElement()) {
167
+ // when there's no selection and we're just working with the caret, we'll add/remove the tabs at the caret, providing more control
168
+ if ('' == range.text) {
169
+ // SHIFT+TAB
170
+ if (shft) {
171
+ var bookmark = range.getBookmark();
172
+ //first try to the left by moving opening up our empty range to the left
173
+ range.moveStart('character', -options.tabString.length);
174
+ if (options.tabString == range.text) {
175
+ range.text = '';
176
+ } else {
177
+ // if that didn't work then reset the range and try opening it to the right
178
+ range.moveToBookmark(bookmark);
179
+ range.moveEnd('character', options.tabString.length);
180
+ if (options.tabString == range.text)
181
+ range.text = '';
182
+ }
183
+ // move the pointer to the start of them empty range and select it
184
+ range.collapse(true);
185
+ range.select();
186
+ }
187
+
188
+ else {
189
+ // very simple here. just insert the tab into the range and put the pointer at the end
190
+ range.text = options.tabString;
191
+ range.collapse(false);
192
+ range.select();
193
+ }
194
+ }
195
+ // selections will always add/remove tabs from the start of the line
196
+ else {
197
+
198
+ var selection_text = range.text;
199
+ var selection_len = selection_text.length;
200
+ var selection_arr = selection_text.split("\r\n");
201
+
202
+ var before_range = document.body.createTextRange();
203
+ before_range.moveToElementText(o);
204
+ before_range.setEndPoint("EndToStart", range);
205
+ var before_text = before_range.text;
206
+ var before_arr = before_text.split("\r\n");
207
+ var before_len = before_text.length; // - before_arr.length + 1;
208
+
209
+ var after_range = document.body.createTextRange();
210
+ after_range.moveToElementText(o);
211
+ after_range.setEndPoint("StartToEnd", range);
212
+ var after_text = after_range.text; // we can accurately calculate distance to the end because we're not worried about MSIE trimming a \r\n
213
+
214
+ var end_range = document.body.createTextRange();
215
+ end_range.moveToElementText(o);
216
+ end_range.setEndPoint("StartToEnd", before_range);
217
+ var end_text = end_range.text; // we can accurately calculate distance to the end because we're not worried about MSIE trimming a \r\n
218
+
219
+ var check_html = $(o).html();
220
+ $("#r3").text(before_len + " + " + selection_len + " + " + after_text.length + " = " + check_html.length);
221
+ if((before_len + end_text.length) < check_html.length) {
222
+ before_arr.push("");
223
+ before_len += 2; // for the \r\n that was trimmed
224
+ if (shft && options.tabString == selection_arr[0].substring(0,options.tabString.length))
225
+ selection_arr[0] = selection_arr[0].substring(options.tabString.length);
226
+ else if (!shft) selection_arr[0] = options.tabString + selection_arr[0];
227
+ } else {
228
+ if (shft && options.tabString == before_arr[before_arr.length-1].substring(0,options.tabString.length))
229
+ before_arr[before_arr.length-1] = before_arr[before_arr.length-1].substring(options.tabString.length);
230
+ else if (!shft) before_arr[before_arr.length-1] = options.tabString + before_arr[before_arr.length-1];
231
+ }
232
+
233
+ for (var i = 1; i < selection_arr.length; i++) {
234
+ if (shft && options.tabString == selection_arr[i].substring(0,options.tabString.length))
235
+ selection_arr[i] = selection_arr[i].substring(options.tabString.length);
236
+ else if (!shft) selection_arr[i] = options.tabString + selection_arr[i];
237
+ }
238
+
239
+ if (1 == before_arr.length && 0 == before_len) {
240
+ if (shft && options.tabString == selection_arr[0].substring(0,options.tabString.length))
241
+ selection_arr[0] = selection_arr[0].substring(options.tabString.length);
242
+ else if (!shft) selection_arr[0] = options.tabString + selection_arr[0];
243
+ }
244
+
245
+ if ((before_len + selection_len + after_text.length) < check_html.length) {
246
+ selection_arr.push("");
247
+ selection_len += 2; // for the \r\n that was trimmed
248
+ }
249
+
250
+ before_range.text = before_arr.join("\r\n");
251
+ range.text = selection_arr.join("\r\n");
252
+
253
+ var new_range = document.body.createTextRange();
254
+ new_range.moveToElementText(o);
255
+
256
+ if (0 < before_len) new_range.setEndPoint("StartToEnd", before_range);
257
+ else new_range.setEndPoint("StartToStart", before_range);
258
+ new_range.setEndPoint("EndToEnd", range);
259
+
260
+ new_range.select();
261
+
262
+ }
263
+ }
264
+ }
265
+
266
+ // end of closure
267
+ })(jQuery);
license.txt ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <http://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <http://www.gnu.org/philosophy/why-not-lgpl.html>.
readme.txt ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Code Snippets ===
2
+ Contributors: bungeshea
3
+ Donate link: http://bungeshea.wordpress.com/donate/
4
+ Tags: snippets, code, php
5
+ Requires at least: 3.3
6
+ Tested up to: 3.4
7
+ Stable tag: 1.1
8
+ License: GPLv3 or later
9
+ License URI: http://www.gnu.org/copyleft/gpl.html
10
+
11
+ Allows you to easily add code snippets through a GUI interface.
12
+
13
+ == Description ==
14
+
15
+ **Code Snippets** is a easy, clean and simple way to add code snippets to your site.
16
+
17
+ Use the top level menu to manage your snippets. You can activate, deactivate, edit and delete snippets using a page similar to the Plugins menu. You can add a name for your snippet through the visual editor and the code through a tab-enabled text-area.
18
+
19
+ Snippets are stored in the `wp_snippets` table in the WordPress database (the table name may differ depending on what your table prefix is set to).
20
+
21
+ Code Snippets includes an option to clean up its data when deactivated. Each screen includes a help tab just in case you get stuck.
22
+
23
+ Further information and screenshots are available on the [plugin homepage]( http://bungeshea.wordpress.com/plugins/code-snippets).
24
+
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) :-)
28
+
29
+ == Installation ==
30
+
31
+ 1. Download the `code-snippets.zip` file to your local machine.
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.
33
+ 3. Activate the plugin through the Plugins menu
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)*
36
+
37
+ == Frequently Asked Questions ==
38
+
39
+ = Do I need to include the &lt;?php, &lt;?, ?&gt; tags in my snippet? =
40
+ No, just copy all the content inside those tags.
41
+
42
+ = Is there a way to add a snippet but not run it right away? =
43
+ Yes. Just add it but do not activate it yet.
44
+
45
+ = Can I use the TAB key inside the code text-area to indent my code? =
46
+ Yes! Thanks to Ted Devito's [Tabby jQuery plugin](http://teddevito.com/demos/textarea.html), the TAB key will add an indent instead of switching to the next object.
47
+
48
+ = Will I lose my snippets if I change the theme or upgrade WordPress? =
49
+ No, the snippets are added to the WordPress database so are independent of the theme and unaffected by WordPress upgrades.
50
+
51
+ = Can the plugin be completely uninstalled? =
52
+ Yes, there is an option to delete the database table and if you want to completely remove the plugin.
53
+
54
+ = Can I copy any snippets I've created to another WordPress site? =
55
+ The import/export feature is currently in development. You can however, use the export feature of phpMyAdmin to copy the `wp_snippets` table to another WordPress database.
56
+
57
+ == Screenshots ==
58
+
59
+ 1. The Manage Snippets page
60
+ 2. The Add New Snippet page
61
+ 3. Editing a snippet
62
+ 4. The Uninstall Plugin page
63
+ 5. Each screen includes a help tab just in case you get stuck.
64
+
65
+ == Changelog ==
66
+
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
+
71
+ = 1.0 =
72
+ * Stable version released.
73
+
74
+ == Upgrade Notice ==
75
+
76
+ = 1.1 =
77
+ * Minor bug fixes and improvments on the the 'Edit Snippet' page
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file
screenshot-4.jpg ADDED
Binary file
screenshot-5.jpg ADDED
Binary file