WordPress.org

Plugin Directory

Changeset 586933


Ignore:
Timestamp:
08/17/12 18:45:00 (20 months ago)
Author:
tommcfarlin
Message:
  • Adding support for comment images on page comments
Location:
comment-images/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • comment-images/trunk/README.txt

    r585416 r586933  
    55Requires at least: 3.4.1 
    66Tested up to: 3.4.1 
    7 Stable tag: 1.2 
     7Stable tag: 1.3 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    5959== Changelog == 
    6060 
     61= 1.3 = 
     62* Adding support for comment images on pages 
     63 
    6164= 1.2 = 
    6265* Changing the way comment images are associated with comments to improve performance for users who aren't logged in 
  • comment-images/trunk/plugin.php

    r585416 r586933  
    44Plugin URI: http://tommcfarlin.com/comment-images 
    55Description: Allow your readers easily to attach an image to their comment. 
    6 Version: 1.2 
     6Version: 1.3 
    77Author: Tom McFarlin 
    88Author URI: http://tommcfarlin.com 
     
    129129     function add_styles() { 
    130130     
    131         if( is_single() ) { 
     131        if( is_single() || is_page() ) { 
    132132             
    133133            wp_register_style( 'comment-images', plugins_url( '/comment-images/css/plugin.css' ) ); 
     
    143143    function add_scripts() { 
    144144     
    145         if( is_single() ) { 
     145        if( is_single() || is_page() ) { 
    146146             
    147147            wp_register_script( 'comment-images', plugins_url( '/comment-images/js/plugin.min.js' ), array( 'jquery' ) ); 
     
    221221         
    222222        // Get the most recent comment 
    223         $comment = $comments[ count( $comments ) - 1 ]; 
    224  
    225         // If the comment image meta value exists, then render the comment image 
    226         if( false != get_comment_meta( $comment->comment_ID, 'comment_image' ) ) { 
    227          
    228             // Get the comment image meta 
    229             $comment_image = get_comment_meta( $comment->comment_ID, 'comment_image', true ); 
    230              
    231             // Render it in a paragraph element appended to the comment 
    232             $comment->comment_content .= '<p class="comment-image">'; 
    233                 $comment->comment_content .= '<img src="' . $comment_image['url'] . '" alt="" />'; 
    234             $comment->comment_content .= '</p><!-- /.comment-image -->';     
    235              
     223        if( count( $comments ) > 0 ) { 
     224         
     225            $comment = $comments[ count( $comments ) - 1 ]; 
     226     
     227            // If the comment image meta value exists, then render the comment image 
     228            if( false != get_comment_meta( $comment->comment_ID, 'comment_image' ) ) { 
     229             
     230                // Get the comment image meta 
     231                $comment_image = get_comment_meta( $comment->comment_ID, 'comment_image', true ); 
     232                 
     233                // Render it in a paragraph element appended to the comment 
     234                $comment->comment_content .= '<p class="comment-image">'; 
     235                    $comment->comment_content .= '<img src="' . $comment_image['url'] . '" alt="" />'; 
     236                $comment->comment_content .= '</p><!-- /.comment-image -->';     
     237                 
     238            } // end if 
     239         
    236240        } // end if 
    237241         
Note: See TracChangeset for help on using the changeset viewer.