Changeset 7589

Show
Ignore:
Timestamp:
01/25/07 20:37:43 (1 year ago)
Author:
alexkingorg
Message:

changes for 1.3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wp-grins/trunk/README.txt

    r4119 r7589  
    1 === Popularity Contest === 
    2  
     1=== WP Grins === 
    32Tags: clickable, smilies, comments, admin, wpgrins 
    4 Contributors: alexking, alexkingorg 
     3Contributors: alexkingorg 
     4Requires at least: 2.0 
     5Tested up to: 2.1 
     6Stable tag: 1.3 
    57 
    68WP Grins will provide clickable smilies for both the post form in the admin interface and the comments form of your blog. 
    79 
    8 version 1.2, 2004-08-22 
    9  
    10 == Installation ==  
     10== Installation == 
    1111 
    12121. 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)
     132. Put the 'wp-grins.php' file into your wp-content/plugins/ directory
    14143. 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. 
     154. If you are using a version of WP prior to 2.1, upload the included prototype.js to your wp-includes/js/ directory. 
    4016 
    4117 
    42 == Known Incompatibilities == 
     18== Usage == 
     19 
     20Click on the smilies icons to insert their tags into the text field. 
     21 
     22 
     23== Known Issues == 
    4324 
    4425None. 
    4526 
    46 == Frequently Asked Questions ==   
    4727 
    48 None. 
     28== Frequently Asked Questions == 
    4929 
    5030= Anything else? = 
     
    5434--Alex King 
    5535 
    56 http://www.alexking.org/software/wordpress/ 
    57  
     36http://alexking.org/projects/wordpress 
  • wp-grins/trunk/wp-grins.php

    r4119 r7589  
    22 
    33// WP Grins 
    4 // version 1.2, 2004-08-22 
    54// 
    6 // Copyright (c) 2004-2005 Alex King 
    7 // http://www.alexking.org/software/wordpress/ 
     5// Copyright (c) 2004-2007 Alex King 
     6// http://alexking.org/projects/wordpress 
    87// 
    98// This is an add-on for WordPress 
     
    1817/* 
    1918Plugin Name: WP Grins 
    20 Plugin URI: http://www.alexking.org/software/wordpress/ 
     19Plugin URI: http://alexking.org/projects/wordpress 
    2120Description: A Clickable Smilies hack for WordPress. 
    22 Version: 1.2 
     21Version: 1.3 
    2322Author: Alex King 
    24 Author URI: http://www.alexking.org/ 
     23Author URI: http://alexking.org 
    2524*/  
    2625 
    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.'\');"/> '; 
     26function wp_grins() { // left in for legacy reasons 
     27      print(''); 
     28
     29 
     30if (!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; 
    3640            } 
    3741      } 
    38        
    39       print('<div id="wp_grins">'.$grins.'</div>'); 
    4042} 
    4143 
    4244function 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(); 
    4447} 
    4548 
    46 if (isset($_GET['wp_grins_output'])) { // will output stuff for the HTML source 
    47       switch ($_GET['wp_grins_output']) { 
    48             case "javascript": 
     49function 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            } 
    4967?> 
     68function insertAfter(node, referenceNode) { 
     69      referenceNode.parentNode.insertBefore(node, referenceNode.nextSibling); 
     70} 
     71function 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} 
     100Event.observe(window, 'load', loadGrins, false); 
    50101function grin(tag) { 
    51102      var myField; 
    52       if (document.getElementById('content') && document.getElementById('content').type == 'textarea') { 
     103      if ($('content') && $('content').type == 'textarea') { 
    53104            myField = document.getElementById('content'); 
     105            if ($('postdivrich') && typeof tinyMCE != 'undefined' && (!$('edButtons') || $('quicktags').style.display == 'none')) { 
     106                  tinyMCE.execInstanceCommand('mce_editor_0', 'mceInsertContent', false, '&nbsp;' + tag + '&nbsp;'); 
     107                  tinyMCE.selectedInstance.repaint(); 
     108                  return; 
     109            } 
    54110      } 
    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'); 
    57113      } 
    58114      else { 
     
    84140<?php 
    85141            die(); 
    86             break; 
    87142      } 
    88143} 
    89144 
     145add_action('init', 'wp_grins_js'); 
    90146add_action('wp_head', 'wp_grins_head'); 
    91147add_action('admin_head', 'wp_grins_head');