Changeset 7589
- Timestamp:
- 01/25/07 20:37:43 (1 year ago)
- Files:
-
- wp-grins/trunk/README.txt (modified) (2 diffs)
- wp-grins/trunk/prototype.js (added)
- wp-grins/trunk/wp-grins.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wp-grins/trunk/README.txt
r4119 r7589 1 === Popularity Contest === 2 1 === WP Grins === 3 2 Tags: clickable, smilies, comments, admin, wpgrins 4 Contributors: alexking, alexkingorg 3 Contributors: alexkingorg 4 Requires at least: 2.0 5 Tested up to: 2.1 6 Stable tag: 1.3 5 7 6 8 WP Grins will provide clickable smilies for both the post form in the admin interface and the comments form of your blog. 7 9 8 version 1.2, 2004-08-22 9 10 == Installation == 10 == Installation == 11 11 12 12 1. Download the plugin archive and expand it (you've likely already done this). 13 2. Upload the wp-grins.php file to your wp-content/plugins directory (not in a sub-folder).13 2. Put the 'wp-grins.php' file into your wp-content/plugins/ directory. 14 14 3. Go to the Plugins page in your WordPress Administration area and click 'Activate' for WP Grins. 15 4. Add the clickable smilies to your admin interface. Find the places that have this code: 16 17 <?php the_quicktags(); ?> 18 19 and add the wp_grins(); tag, like so: 20 21 <?php the_quicktags(); wp_grins(); ?> 22 23 In version 1.5.2, there are 4 locations where this should be done in the wp-admin directory: 24 25 edit-form-advancer.php, line 93 26 edit-form-comment.php, line 41 27 edit-form.php, line 36 28 edit-page-form.php, line 70 29 30 5. Add the clickable smilies to your comments form. Find the code like this in your theme/comments.php file: 31 32 <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p> 33 34 and add the wp_grins(); tag, like so: 35 36 <?php wp_grins(); ?> 37 <p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p> 38 39 6. If you use the pop-up comment form, you'll need to do the same in the wp-comments-popup.php page. 15 4. If you are using a version of WP prior to 2.1, upload the included prototype.js to your wp-includes/js/ directory. 40 16 41 17 42 == Known Incompatibilities == 18 == Usage == 19 20 Click on the smilies icons to insert their tags into the text field. 21 22 23 == Known Issues == 43 24 44 25 None. 45 26 46 == Frequently Asked Questions ==47 27 48 None. 28 == Frequently Asked Questions == 49 29 50 30 = Anything else? = … … 54 34 --Alex King 55 35 56 http://www.alexking.org/software/wordpress/ 57 36 http://alexking.org/projects/wordpress wp-grins/trunk/wp-grins.php
r4119 r7589 2 2 3 3 // WP Grins 4 // version 1.2, 2004-08-225 4 // 6 // Copyright (c) 2004-200 5Alex King7 // http:// www.alexking.org/software/wordpress/5 // Copyright (c) 2004-2007 Alex King 6 // http://alexking.org/projects/wordpress 8 7 // 9 8 // This is an add-on for WordPress … … 18 17 /* 19 18 Plugin Name: WP Grins 20 Plugin URI: http:// www.alexking.org/software/wordpress/19 Plugin URI: http://alexking.org/projects/wordpress 21 20 Description: A Clickable Smilies hack for WordPress. 22 Version: 1. 221 Version: 1.3 23 22 Author: Alex King 24 Author URI: http:// www.alexking.org/23 Author URI: http://alexking.org 25 24 */ 26 25 27 function wp_grins() { 28 global $wpsmiliestrans; 29 $grins = ''; 30 $smiled = array(); 31 foreach ($wpsmiliestrans as $tag => $grin) { 32 if (!in_array($grin, $smiled)) { 33 $smiled[] = $grin; 34 $tag = str_replace(' ', '', $tag); 35 $grins .= '<img src="'.get_bloginfo('wpurl').'/wp-images/smilies/'.$grin.'" alt="'.$tag.'" onclick="grin(\''.$tag.'\');"/> '; 26 function wp_grins() { // left in for legacy reasons 27 print(''); 28 } 29 30 if (!function_exists('ak_prototype')) { 31 function ak_prototype() { 32 if (!function_exists('wp_enqueue_script')) { 33 global $ak_prototype; 34 if (!isset($ak_prototype) || !$ak_prototype) { 35 print(' 36 <script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-includes/js/prototype.js"></script> 37 '); 38 } 39 $ak_prototype = true; 36 40 } 37 41 } 38 39 print('<div id="wp_grins">'.$grins.'</div>');40 42 } 41 43 42 44 function wp_grins_head() { 43 print('<script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-content/plugins/wp-grins.php?wp_grins_output=javascript"></script>'."\n"); 45 print('<script type="text/javascript" src="'.get_bloginfo('wpurl').'/index.php?ak_action=wp_grins_js"></script>'."\n"); 46 ak_prototype(); 44 47 } 45 48 46 if (isset($_GET['wp_grins_output'])) { // will output stuff for the HTML source 47 switch ($_GET['wp_grins_output']) { 48 case "javascript": 49 function wp_grins_js() { 50 if (function_exists('wp_enqueue_script')) { 51 wp_enqueue_script('prototype'); 52 } 53 if (isset($_GET['ak_action']) && $_GET['ak_action'] == 'wp_grins_js') { 54 global $wpsmiliestrans; 55 56 header("Content-type: text/javascript"); 57 58 $grins = ''; 59 $smiled = array(); 60 foreach ($wpsmiliestrans as $tag => $grin) { 61 if (!in_array($grin, $smiled)) { 62 $smiled[] = $grin; 63 $tag = str_replace(' ', '', $tag); 64 $grins .= '<img src="'.get_bloginfo('wpurl').'/wp-includes/images/smilies/'.$grin.'" alt="'.$tag.'" onclick="grin(\''.$tag.'\');"/> '; 65 } 66 } 49 67 ?> 68 function insertAfter(node, referenceNode) { 69 referenceNode.parentNode.insertBefore(node, referenceNode.nextSibling); 70 } 71 function loadGrins() { 72 var grinsDiv = document.createElement('div'); 73 grinsDiv.id = 'wp_grins'; 74 grinsDiv.innerHTML = '<?php print(str_replace("'", "\'", $grins)); ?>'; 75 if ($('postdiv')) { 76 var type = 'child'; 77 var node = $('postdiv'); 78 } 79 else if (document.getElementById('postdivrich')) { 80 var type = 'child'; 81 var node = $('postdivrich'); 82 } 83 else if (document.getElementById('comment')) { 84 var type = 'before'; 85 var node = $('comment'); 86 } 87 else { 88 return; 89 } 90 switch (type) { 91 case 'child': 92 grinsDiv.style.paddingTop = '5px'; 93 node.appendChild(grinsDiv); 94 break; 95 case 'before': 96 node.parentNode.insertBefore(grinsDiv, node); 97 break; 98 } 99 } 100 Event.observe(window, 'load', loadGrins, false); 50 101 function grin(tag) { 51 102 var myField; 52 if ( document.getElementById('content') && document.getElementById('content').type == 'textarea') {103 if ($('content') && $('content').type == 'textarea') { 53 104 myField = document.getElementById('content'); 105 if ($('postdivrich') && typeof tinyMCE != 'undefined' && (!$('edButtons') || $('quicktags').style.display == 'none')) { 106 tinyMCE.execInstanceCommand('mce_editor_0', 'mceInsertContent', false, ' ' + tag + ' '); 107 tinyMCE.selectedInstance.repaint(); 108 return; 109 } 54 110 } 55 else if ( document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {56 myField = document.getElementById('comment');111 else if ($('comment') && $('comment').type == 'textarea') { 112 myField = $('comment'); 57 113 } 58 114 else { … … 84 140 <?php 85 141 die(); 86 break;87 142 } 88 143 } 89 144 145 add_action('init', 'wp_grins_js'); 90 146 add_action('wp_head', 'wp_grins_head'); 91 147 add_action('admin_head', 'wp_grins_head');
