Plugin Directory

Changeset 580449


Ignore:
Timestamp:
08/01/2012 08:55:42 PM (14 years ago)
Author:
doodlebee
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • jquery-expandable-comments/trunk/jQuery-comments.php

    r580441 r580449  
    55Description: Makes comment replies expandable with jQuery, and creates "valid" code.
    66Author: Shelly Cole
    7 Version: 0.2
     7Version: 0.3
    88Author URI: http://brassblogs.com
    99
     
    3838        switch ( $args['style'] ) {
    3939            case 'div':
    40                 echo "<div class='replylink'>Show/Hide Replies</div>\n";
     40                echo "<div class='replylink'>Show Replies</div>\n";
    4141                echo "<div class='children'>\n";
    4242                break;
    4343            case 'ol':             
    44                 echo "<span class='replylink'>Show/Hide Replies</span>\n";
     44                echo "<span class='replylink'>Show Replies</span>\n";
    4545                echo "<ol class='children'>\n";
    4646                break;
    4747            default:
    4848            case 'ul':
    49                 echo "<span class='replylink'>Show/Hide Replies</span>\n";
     49                echo "<span class='replylink'>Show Replies</span>\n";
    5050                echo "<ul class='children'>\n";
    5151                break;
     
    254254----------------------------------------------------------------------------------------*/
    255255
    256 add_action('init', 'bb_start_jquery');
     256if(wp_script_is('jquery', 'registered') !== TRUE) { // we don't want to add jquery if it's already added
     257    add_action('init', 'bb_start_jquery');
     258    function bb_start_jquery() {
     259        wp_deregister_script('jquery'); // just to bypass any possible weirdness
     260        wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
     261        wp_enqueue_script('jquery'); //get that jQuery started up
     262    }
     263}
     264
    257265add_action('wp_head', 'bb_add_jQuery');
    258 
    259 function bb_start_jquery() {
    260     wp_enqueue_script('jquery'); //get that jQuery started up
    261 }
    262 
    263266function bb_add_jQuery() {
    264     if(is_single() || is_paged () || get_query_var ('cpage')) { ?>
     267    if(comments_open()) { ?>
    265268    <!--/start jQuery Expandable Comments -->
    266269  <script type="text/javascript">
     
    270273            $(this).css('cursor','pointer'); }, function (){
    271274                $(this).css('cursor','auto'); } ).click(function() {
     275                    $(this).text( $(this).text() == 'Show Replies' ? 'Hide Replies' : 'Show Replies');
    272276                    var $nextDiv = $(this).next();
    273277                    var $visibleSiblings = $nextDiv.siblings('div:visible');
Note: See TracChangeset for help on using the changeset viewer.