1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<?php
/*
Plugin Name: Acronyms
Plugin URI: http://ketsugi.com/software/wordpress/acronyms-plugin/
Description: A plugin to wrap acronyms in posts and comments with appropriate <acronym> acronyms. Allows users to manage lists of acronyms through admin interface. Based on Joel Bennett's Acronym Replacer plugin (http://www.huddledmasses.org/) and Joel Pan's NP_Acronym plugin for Nucleus CMS.
Version: 1.6.1
Author: Joel Pan
Author URI: http://ketsugi.com/

  Copyright 2008  Joel Pan <[email protected]>

    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 2 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, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

class Acronyms
{

	/* void install ()
	 * Creates tables and populates default acronyms.
	 */
	function install ()
	{
		// Populate defaults
		$acronyms = array(
			'AFAIK' => 'As far as I know',
			'AIM' => 'AOL Instant Messenger',
			'AJAX' => 'Asynchronous JavaScript and XML',
			'AOL' => 'America Online',
			'API' => 'Application Programming Interface',
			'ASAP' => 'As soon as possible',
			'ASCII' => 'American Standard Code for Information Interchange',
			'ASP' => 'Active Server Pages',
			'BTW' => 'By The Way',
			'CD' => 'Compact Disc',
			'CGI' => 'Common Gateway Interface',
			'CMS' => 'Content Management System',
			'CSS' => 'Cascading Style Sheets',
			'CVS' => 'Concurrent Versions System',
			'DBA' => 'Database Administrator',
			'DHTML' => 'Dynamic HyperText Markup Language',
			'DMCA' => 'Digital Millenium Copyright Act',
			'DNS' => 'Domain Name Server',
			'DOM' => 'Document Object Model',
			'DTD' => 'Document Type Definition',
			'DVD' => 'Digital Versatile Disc',
			'EOF' => 'End of file',
			'EOL' => 'End of line',
			'EOM' => 'End of message',
			'EOT' => 'End of text',
			'FAQ' => 'Frequently Asked Questions',
			'FDL' => 'GNU Free Documentation License',
			'FTP' => 'File Transfer Protocol',
			'FUD' => 'Fear, Uncertainty, and Doubt',
			'GB' => 'Gigabyte',
			'GHz' => 'Gigahertz',
			'GIF' => 'Graphics Interchange Format',
			'GPL' => 'GNU General Public License',
			'GUI' => 'Graphical User Interface',
			'HDD' => 'Hard Disk Drive',
			'HTML' => 'HyperText Markup Language',
			'HTTP' => 'HyperText Transfer Protocol',
			'IANAL' => 'I am not a lawyer',
			'ICANN' => 'Internet Corporation for Assigned Names and Numbers',
			'IE' => 'Internet Explorer',
			'IE5' => 'Internet Explorer 5',
			'IE6' => 'Internet Explorer 6',
			'IIRC' => 'If I remember correctly',
			'IIS' => 'Internet Information Services',
			'IM' => 'Instant Message',
			'IMAP' => 'Internet Message Access Protocol',
			'IMHO' => 'In my humble opinion',
			'IMO' => 'In my opinion',
			'IOW' => 'In other words',
			'IP' => 'Internet Protocol',
			'IRC' => 'Internet Relay Chat',
			'IRL' => 'In real life',
			'ISO' => 'International Organization for Standardization',
			'ISP' => 'Internet Service Provider',
			'JDK' => 'Java Development Kit',
			'JPEG' => 'Joint Photographics Experts Group',
			'JPG' => 'Joint Photographics Experts Group',
			'JS' => 'JavaScript',
			'KB' => 'Kilobyte',
			'KISS' => 'Keep it simple, stupid',
			'LGPL' => 'GNU Lesser General Public License',
			'LOL' => 'Laughing out loud',
			'MB' => 'Megabyte',
			'MHz' => 'Megahertz',
			'MIME' => 'Multipurpose Internet Mail Extension',
			'MIT' => 'Massachusetts Institute of Technology',
			'MML' => 'Mathematical Markup Language',
			'MPEG' => 'Motion Picture Experts Group',
			'MS' => 'Microsoft',
			'MSDN' => 'Microsoft Developer Network',
			'MSIE' => 'Microsoft Internet Explorer',
			'MSN' => 'Microsoft Network',
			'OMG' => 'Oh my goodness',
			'OPML' => 'Outline Processor Markup Language',
			'OS' => 'Operating System',
			'OSS' => 'Open Source Software',
			'OTOH' => 'On the other hand',
			'P2P' => 'Peer to Peer',
			'PDA' => 'Personal Digital Assistant',
			'PDF' => 'Portable Document Format',
			'PHP' => 'Pre-Hypertext Processing',
			'PICS' => 'Platform for Internet Content Selection',
			'PIN' => 'Personal Identification Number',
			'PITA' => 'Pain in the Ass',
			'PNG' => 'Portable Network Graphics',
			'POP' => 'Post Office Protocol',
			'POP3' => 'Post Office Protocol 3',
			'Perl' => 'Practical Extraction and Report Language',
			'QoS' => 'Quality of Service',
			'RAID' => 'Redundant Array of Inexpensive Disks',
			'RDF' => 'Resource Description Framework',
			'ROFL' => 'Rolling on the floor laughing',
			'ROFLMAO' => 'Rolling on the floor laughing my ass off',
			'RPC' => 'Remote Procedure Call',
			'RSS' => 'Really Simple Syndication',
			'RTF' => 'Rich Text File',
			'RTFM' => 'Read The Fucking Manual',
			'SCSI' => 'Small Computer System Interface',
			'SDK' => 'Software Development Kit',
			'SGML' => 'Standard General Markup Language',
			'SMIL' => 'Synchronized Multimedia Integration Language',
			'SMTP' => 'Simple Mail Transfer Protocol',
			'SOAP' => 'Simple Object Access Protocol',
			'SQL' => 'Structured Query Language',
			'SSH' => 'Secure Shell',
			'SSI' => 'Server Side Includes',
			'SSL' => 'Secure Sockets Layer',
			'SVG' => 'Scalable Vector Graphics',
			'SVN' => 'Subversion',
			'TIA' => 'Thanks In Advance',
			'TIFF' => 'Tagged Image File Format',
			'TLD' => 'Top Level Domain',
			'TOC' => 'Table of Contents',
			'URI' => 'Uniform Resource Identifier',
			'URL' => 'Uniform Resource Locator',
			'URN' => 'Uniform Resource Name',
			'USB' => 'Universal Serial Bus',
			'VB' => 'Visual Basic',
			'VBA' => 'Visual Basic for Applications',
			'W3C' => 'World Wide Web Consortium',
			'WAN' => 'Wide Area Network',
			'WAP' => 'Wireless Access Protocol',
			'WML' => 'Wireless Markup Language',
			'WP' => 'WordPress',
			'WTF' => 'What the fuck',
			'WWW' => 'World Wide Web',
			'WYSIWYG' => 'What You See Is What You Get',
			'XHTML' => 'eXtensible HyperText Markup Language',
			'XML' => 'eXtensible Markup Language',
			'XSL' => 'eXtensible Stylesheet Language',
			'XSLT' => 'eXtensible Stylesheet Language Transformations',
			'XUL' => 'XML User Interface Language',
			'YMMV' => 'Your mileage may vary'
		);
		add_option( 'acronym_acronyms', $acronyms );

		// Add default options -- Options not currently modifiable by user
		add_option( 'acronym_content', 1 );
		add_option( 'acronym_comments', 1 );
	}

	/* string get_textdomain ()
	 *
	 * returns the text domain to be used for internationalisation
	 */
	function get_textdomain ()
	{
		return "Acronyms";
	}

	/* void uninstall ()
	 */
	function uninstall ()
	{
		// Perhaps I should remove the acronyms when uninstalling to clear out the cruft? But what if the user is just temporarily deactivating the plugin with the intention to activate it again later, and doesn't want to lose all his/her custom acronyms?
	}

	/**
	 * Adds the Management page to WordPress
	 *
	 * @return void
	 **/
	function add_pages ()
	{
		$domain = Acronyms::get_textdomain();

		// Add the Manage page
		add_management_page( __( 'Manage Acronyms', $domain ), __( 'Acronyms', $domain ), "manage_options", __FILE__, array( 'Acronyms', 'manage_acronyms' ) );
	}

	/**
	 * void management_handler ()
	 *
	 * handles actions for adding, editing or deleting acronyms
	 *
	 */
	function management_handler () {
		$domain = Acronyms::get_textdomain();
		load_plugin_textdomain( $domain, "/wp-content/plugins/your-plugin-directory/" );

		$title = __( 'Acronyms', $domain );
		$parent_file = 'tools.php?page=' . Acronyms::get_parent_url();

		if ( 'acronyms.php' == substr( $parent_file, -12 ) ) {
			$acronyms = get_option( 'acronym_acronyms' );

			wp_reset_vars(array('action', 'acronym'));

			if ( isset( $_GET['delete-acronyms'] ) ) // Bulk delete array of acronyms
				$action = 'delete-acronyms';
			else if ( isset( $_GET['search'] ) ) // Search term for redirecting to less crufty HTTP GET URL
			  $action = 'search';
			else $action = $_GET['action'];

			switch ($action) {
				case 'add-acronym':
					check_admin_referer('add_acronym');;
					$acronym = $_GET['acronym'];
					$fulltext = $_GET['fulltext'];
					if ( Acronyms::update ( $acronym, $fulltext ) )	$message = 1;
					else $message = 4;
	  	  			wp_redirect( "$parent_file&message=$message" );
	    			exit;
					break;

				case 'edit-acronym':
					$acronym = $_GET['acronym'];
					$fulltext = $_GET['fulltext'];
					check_admin_referer('edit_acronym');
					if ( Acronyms::update ( $acronym, $fulltext ) )	$message = 3;
					else $message = 5;
	  	  			wp_redirect( "$parent_file&message=$message" );
	    			exit;
					break;

				case 'delete-acronym':
		 			check_admin_referer('delete_acronym');

		  	  		if ( !current_user_can('manage_categories') )
	      				wp_die(__('Cheatin&#8217; uh?'));

			    	$acronym = $_GET['acronym'];
	      			Acronyms::delete ( $acronym );

					$message = 2;
		  	  		wp_redirect( "$parent_file&message=$message" );
		    		exit;
				  	break;

				case 'delete-acronyms':
		 			check_admin_referer('delete-acronyms');

		    		if ( !current_user_can('manage_categories') )
	      				wp_die(__('Cheatin&#8217; uh?'));

			    	$acronyms = $_GET['delete_acronyms'];
		    			foreach( (array) $acronyms as $acronym ) {
			      		Acronyms::delete ( $acronym );
			    	}

			    	if ( 1 < ( count( $acronyms ) ) )
			    		$message = 6;
	    			else $message = 2;
	  	  			wp_redirect( "$parent_file&message=$message" );
	    			exit;
			  	break;

				case 'search':
					$s = '&s=' . urlencode( $_GET['search'] );
					$p = isset( $_GET['p'] ) ? '&p=' . $_GET['p'] : '';
					$n = isset( $_GET['n'] ) && 15 != $_GET['n'] ? '&n=' . $_GET['n'] : '';
					wp_redirect( "$parent_file$s$p$n" );
			}
		}
	}


	/**
	 * Manage Acronyms page
	 *
	 * @return void
	 **/
	function manage_acronyms ()
	{
		$domain = Acronyms::get_textdomain();

		// Set any error/notice messages based on the 'message' GET value
		$message = $_GET['message'];
		$messages[1] = __( 'Acronym added.', $domain );
		$messages[2] = __( 'Acronym deleted.', $domain );
		$messages[3] = __( 'Acronym updated.', $domain );
		$messages[4] = __( 'Acronym not added.', $domain );
		$messages[5] = __( 'Acronym not updated.', $domain );
		$messages[6] = __( 'Acronyms deleted.', $domain );

		if ( isset( $message ) ) { ?>
<div id="message" class="updated fade"><p><?php echo $messages[$message] ?></p></div>
<?php }
		// Retrieve and set pagination information
		$s = isset( $_GET['s'] ) ? urldecode( $_GET['s'] ) : ''; // Number of acronyms per page
		$p = isset( $_GET['p'] ) && is_numeric( $_GET['p'] ) && 0 < $_GET['p'] ? $_GET['p'] : 1; // Which page to display
		$n = 15; // Default number of acronyms to show per page
		if ( 0 == $n ) $t = 1;
		else $t = ceil( Acronyms::count_acronyms( $s ) / $n ); // Total number of pages, rounded up to nearest integer
?>
<div class="wrap">
  <div id="icon-edit" class="icon32"><br/></div>
  <h2>
	<?php
		_e('Acronyms', $domain );
		//if( 'edit' != $_GET['action'] ) echo ' (<a href="#addacronym">' . __('add new', $domain ) . '</a>)'
		?>
	</h2><br class="clear" />
	<form class="search-form" method="get" action="">
		<p class="search-box" id="post-search">
			<input type="hidden" name="page" value="<?php echo Acronyms::get_parent_url() ?>"/>
			<input type="text" id="post-search-input" name="search" value="<?php echo attribute_escape( stripslashes( $_GET['s'] ) ); ?>" />
			<input type="submit" value="<?php _e( 'Search acronyms', $domain  ); ?>" class="button" />
		</p>
	</form>
 	<br class="clear" />
 	<div id="col-container">
 		<div id="col-right">
 			<div class="col-wrap">
 			  <form id="posts-filter" action="" method="get">
			  <input type="hidden" name="page" value="<?php echo Acronyms::get_parent_url() ?>"/>
<?php
		Acronyms::show_pagination_bar( $s, $n, $p, $t, true);
		Acronyms::show_acronym_list( $s, $n, $p );
		Acronyms::show_pagination_bar( $s, $n, $p, $t);
?>
				</form>
			</div>
 		</div>
 		<div id="col-left">
 			<div class="col-wrap">
<?php
		if ( 'edit' == $_GET['action'] && !empty( $_GET['acronym'] ) ) {
			Acronyms::add_acronym_form ( urldecode( $_GET['acronym'] ), urldecode( $_GET['fulltext'] ) );
		} else {
			Acronyms::add_acronym_form ();
		}
?>
 			</div>
		</div>
	</div>
</div>
<?php
	}

	/* string acronym_replace ( string $text, array $acronyms )
	 *
	 * Replaces known acronyms in $text with appropriate <acronym> acronyms.
	 * Note: acronym replacement is case-sensitive.
	 */
	function acronym_replace ( $text )
	{
		$acronyms = get_option( 'acronym_acronyms' );
		$text = " $text ";
		foreach ( $acronyms as $acronym => $fulltext )
			$text = preg_replace( "|(?!<[^<>]*?)(?<![?.&])\b$acronym\b(?!:)(?![^<>]*?>)|msU", "<acronym title=\"$fulltext\">$acronym</acronym>" , $text );
		$text = trim($text);
		return $text;
	}

  /* string show_acronym_list ( string $s, int $n, int $p )
	 *
	 * Displays the list of acronyms, filtered by search term $s and showing page # $p based on $n per page
	 */
	function show_acronym_list ( $s, $n, $p = '1' )
	{
		$domain = Acronyms::get_textdomain();

		// Sort the acronyms appropriately
		$acronyms = get_option( 'acronym_acronyms' );
		uksort( $acronyms, "strnatcasecmp");

?>
	<table class="widefat">
	<thead>
	<tr>
    <th scope="col" class="check-column"><span class="acronym-tooltip" title="<?php _e( 'Select all acronyms' , $domain ) ?>"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></span></th>
    <th scope="col"><?php _e( 'Acronym', $domain ) ?></th>
    <th scope="col"><?php _e( 'Full', $domain ) ?></th>
	</tr>
	</thead>
	<tfoot>
	<tr>
    <th scope="col" class="check-column"><span class="acronym-tooltip" title="<?php _e( 'Select all acronyms' , $domain ) ?>"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></span></th>
    <th scope="col"><?php _e( 'Acronym', $domain ) ?></th>
    <th scope="col"><?php _e( 'Full', $domain ) ?></th>
	</tr>
	</tfoot>
	<tbody id="the-list" class="list:acronym">
<?php
		$index_start = $n * ( $p - 1 );
		$index_end = $n * $p;
		$index = 0;
		foreach ( $acronyms as $acronym => $fulltext )
		{
			if ( ( '' == $s ) || ( ( false !== strpos( strtolower( $acronym ), strtolower( $s ) ) ) || ( false !== strpos( strtolower( $fulltext ), strtolower( $s ) ) ) ) )
			{
				if ( 0 == $n || ( ++$index >= $index_start && $index <= $index_end ) ) {
	?>
			<tr class="iedit<?php if (0 == $i++ % 2) echo ' alternate' ?>">
			  <th scope="row" class="check-column">
			  	<input type="checkbox" name="delete_acronyms[]" value="<?php echo $acronym ?>" id="select-<?php echo $acronym ?>"/>
			  </th>
				<td class="name column-name">
					<label for="select-<?php echo $acronym ?>" style="display:block">
						<strong>
				  		<span class="acronym-tooltip" title="<?php printf( __( "Edit &quot;%s&quot;" , $domain ), $acronym ) ?>">
				  			<?php echo $acronym ?>
				  		</span>
				  	</strong>
				  </label>
				  <div class="row-actions">
				  	<span class="edit">
				  		<a href="tools.php?page=<?php echo Acronyms::get_parent_url() ?>&amp;action=edit&amp;acronym=<?php echo urlencode( $acronym ) ?>&amp;fulltext=<?php echo urlencode( $fulltext ) ?>">
				  			<?php _e( 'Edit' ); ?>
				  		</a>
				  		|
				  	</span>
				  	<span class="delete">
				  		<?php
				  			$link = 'tools.php?page=' . Acronyms::get_parent_url() . '&amp;action=delete-acronym&amp;acronym=' . urlencode( $acronym );
				  			$link = ( function_exists( 'wp_nonce_url' ) ) ? wp_nonce_url( $link, 'delete_acronym' ) : $link;
				  		?>
				  		<a class="submitdelete" href="<?php echo $link ?>" onclick="if ( confirm('<?php _e( "You are about to delete this acronym \'$acronym\'.\\n \'Cancel\' to stop, \'OK\' to delete.", $domain ) ?>') ) { return true;}return false;">
				  			<?php _e ( 'Delete' ); ?>
				  		</a>
				  	</span>
				  </div>
				</td>
				<td><label for="select-<?php echo $acronym ?>" style="display:block"><?php echo $fulltext ?></label></td>
			</tr>
	<?php
				}
			}
		}
?>
  </tbody>
	</table>
<?php
	}

	function show_pagination_bar ( $s, $n, $p, $t, $filter = false)
	{

		$domain = Acronyms::get_textdomain();
?>
		<div class="tablenav">
	    <div class="alignleft actions">
	      <input type="submit" value="<?php _e( 'Delete' ) ?>" name="delete-acronyms" class="button-secondary delete" onclick="if ( confirm('<?php _e( "You are about to delete the selected acronyms.\\n \'Cancel\' to stop, \'OK\' to delete.", $domain ) ?>') ) { return true;}return false;"/>
	      <?php if ( $filter ) { wp_nonce_field('delete-acronyms'); } ?>
			</div>
			<div class="tablenav-pages">
<?php
		// Display pagination links
		$page_links = paginate_links( array(
			'base' => add_query_arg( 'p', '%#%' ),
			'format' => '',
			'total' => $t,
			'current' => $p,
			'add_args' => $n
		) );
		if ( 0 < $n && $page_links ) {
			echo '<div class="tablenav-pages">';
			$range = $n * ( $p - 1 ) + 1 . '-' . $n * $p;
			$total = Acronyms::count_acronyms( $s );
			echo '<span class="displaying-num">';
			_e( "Displaying $range of $total" );
			echo '</span>';

			echo "$page_links</div>";
		}
?>
		</div>
  </div>
  <br class="clear" />
<?php
	}

	/* void add_acronym_form ( string $acronym, string $fulltext )
	 *
	 * Display the form for adding or editing acronyms
	 */
  function add_acronym_form ( $acronym = '', $fulltext = '' )
	{
		$domain = Acronyms::get_textdomain();

		if ( ! empty($acronym) ) {
			$heading = __( 'Edit Acronym', $domain );
			$submit_text = __( 'Edit Acronym', $domain );
			$form = '<form name="editacronym" id="editacronym" method="get" action="" class="validate">';
			$action = 'edit-acronym';
			$nonce_action = 'edit_acronym';
		} else {
			$heading = __( 'Add Acronym', $domain );
			$submit_text = __( 'Add Acronym', $domain );
			$form = '<form name="addacronym" id="addacronym" method="get" action="" class="add:the-list: validate">';
			$action = 'add-acronym';
			$nonce_action = 'add_acronym';
		}
?>
<div class="form-wrap">
	<h3><?php echo $heading ?></h3>
	<div id="ajax-response"></div>
	<?php echo $form ?>
		<input type="hidden" name="page" value="<?php echo Acronyms::get_parent_url() ?>"/>
		<input type="hidden" name="action" value="<?php echo $action ?>" />
<?php wp_original_referer_field(true, 'previous'); wp_nonce_field($nonce_action); ?>
		<div class="form-field form-required">
			<label for="acronym"><?php _e( 'Acronym', $domain ) ?></label>
			<input name="acronym" id="acronym" type="text" value="<?php echo attribute_escape( $acronym ); ?>" size="20" <?php if ( 'edit-acronym' == $action ) echo 'disabled="disabled"'; ?>/>
			<p><?php _e( 'This is the acronym or abbreviation as it appears in your blog posts.', $domain ) ?></p>
		</div>
		<div class="form-field form-required">
			<label for="fulltext"><?php _e( 'Full', $domain ) ?></label>
			<input name="fulltext" id="fulltext" type="text" value="<?php echo attribute_escape( $fulltext ); ?>" size="80" />
			<p><?php _e( 'The full text is the expanded version of the abbreviation as it will appear in a tooltip displayed when a user hovers his/her mouse cursor over the abbreviation.</p>', $domain ) ?>
		</div>
		<p class="submit">
			<?php if ( 'edit-acronym' == $action ) echo '<a accesskey="c" title="' . __( 'Cancel' ) . '" class="cancel button-secondary alignright" href="tools.php?page=' . Acronyms::get_parent_url() . '">' . __( 'Cancel' ) . '</a>' ?>
			<input type="submit" class="button<?php if ( 'edit-acronym' == $action ) echo '-primary'; else echo '-secondary'; ?> alignleft" name="submit" value="<?php echo $submit_text ?>" />
		</p>
	</form>
</div>
<?php
}

	/* boolean update ( string $acronym, string $fulltext )
	 *
	 * Add a new acronym to the list, or edit an existing one
	 */
	function update ( $acronym, $fulltext )
	{
		if ( empty( $acronym ) || empty( $fulltext ) ) return false;
		else {
			$acronyms = get_option( 'acronym_acronyms' );
			$acronyms[$acronym] = $fulltext;
			update_option( 'acronym_acronyms', $acronyms );
			return true;
		}
	}

	/* boolean delete ( string $acronym )
	 *
	 * Delete an existing acronym
	 */
	function delete ( $acronym )
	{
		$acronyms = get_option( 'acronym_acronyms' );
		if ( array_key_exists( $acronym, $acronyms ) )
		{
			unset( $acronyms[$acronym] );
			update_option( 'acronym_acronyms', $acronyms );
			return true;
		}
		else return false;
	}

	/* int count_acronyms ( string $s )
	 *
	 * Get the number of acronyms based on the search term if provided
	 */
	function count_acronyms ( $s = '' )
	{
		$acronyms = get_option( 'acronym_acronyms' );
		if ( empty( $s ) ) return count( $acronyms );
		else {
			$index = 0;
			foreach ( $acronyms as $acronym => $fulltext )
			{
				if ( false !== strpos( strtolower( $acronym ), strtolower( $s ) ) || ( false !== strpos( strtolower( $fulltext ), strtolower( $s ) ) ) )
				{
					$index++;
				}
			}
			return $index;
		}
	}

	/* string get_parent_url ()
	 *
	 */
  function get_parent_url()
  {
		return $_GET['page'];
	}

} /* END CLASS acronyms */

add_action( 'admin_init', array( 'Acronyms', 'management_handler' ) );
register_activation_hook( __FILE__, array( 'Acronyms', 'install' ) );
//register_deactivation_hook( __FILE__, array( 'Acronyms', 'uninstall' ) );
if (1 == get_option( 'acronym_content' ) )
	add_filter( 'the_content', array( 'Acronyms', 'acronym_replace' ) );
if (1 == get_option( 'acronym_comments' ) )
	add_filter( 'comment_text', array( 'Acronyms', 'acronym_replace' ) );
add_action( 'admin_menu', array( 'Acronyms', 'add_pages' ) );
?>