WordPress.org

Plugin Directory

Changeset 492236


Ignore:
Timestamp:
01/19/12 17:43:21 (2 years ago)
Author:
goldenapples
Message:

Bumped version number to 0.3.4

Location:
recommended-links/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • recommended-links/trunk/admin-functions.php

    r489412 r492236  
    129129    echo '<div id="message" class="messages updated"><p>Plugin settings updated!</p></div>'; 
    130130} 
     131 
     132/** 
     133 * Settings for edit.php and post.php pages 
     134 * 
     135 **/ 
     136 
     137add_filter( 'manage_edit-reclink_columns', 'reclinks_votes_column_register' ); 
     138 
     139function reclinks_votes_column_register( $columns ) { 
     140    $columns['vote-score'] = __( 'Votes', 'gad_reclinks' ); 
     141    return $columns; 
     142} 
     143 
     144add_action( 'manage_posts_custom_column', 'reclinks_votes_column_display', 10, 2 ); 
     145 
     146function reclinks_votes_column_display( $column_name, $post_id ) { 
     147    if ( 'vote-score' != $column_name ) 
     148        return; 
     149    $total_score = get_post_meta( $post_id, '_vote_score', true ); 
     150    echo '<b>' . __( 'Score:', 'gad_reclinks' ) . ' ' . $total_score . '</b><br>'; 
     151 
     152    global $wpdb; 
     153    $plus = absint( $wpdb->get_var( "SELECT SUM(vote) FROM {$wpdb->reclinkvotes} WHERE post_id={$post_id} AND vote>0" ) ); 
     154    $minus = absint( $wpdb->get_var( "SELECT SUM(vote) FROM {$wpdb->reclinkvotes} WHERE post_id={$post_id} AND vote<0" ) ); 
     155 
     156    echo '<span class="description">' . "( + $plus / - $minus )"; 
     157 
     158} 
     159 
     160add_filter( 'manage_edit-reclink_sortable_columns', 'reclink_column_register_sortable' ); 
     161 
     162function reclink_column_register_sortable( $columns ) { 
     163    $columns['vote-score'] = 'vote-score'; 
     164  
     165    return $columns; 
     166} 
     167 
     168add_filter( 'request', 'votescore_column_orderby' ); 
     169 
     170function votescore_column_orderby( $vars ) { 
     171    if ( isset( $vars['orderby'] ) && 'vote-score' == $vars['orderby'] ) { 
     172        $vars = array_merge( $vars, array( 
     173            'meta_key' => '_vote_score', 
     174            'orderby' => 'meta_value_num' 
     175        ) ); 
     176    } 
     177  
     178    return $vars; 
     179} 
  • recommended-links/trunk/ajax-functions.php

    r489412 r492236  
    8585} 
    8686 
     87// Not currently used; but here in case the YQL solution proves too clow, or unreliable 
    8788add_action( 'wp_ajax_check_reclink_title', 'gad_reclinks_check_link_title' ); 
    8889add_action( 'wp_ajax_nopriv_check_reclink_title', 'gad_reclinks_check_link_title' ); 
  • recommended-links/trunk/display-filters.php

    r489412 r492236  
    2626        return $query; 
    2727     
     28    if ( is_admin() ) 
     29        return $query; 
     30 
    2831    if ( $query === $wp_the_query ) { 
    2932        $posts_per_page = ( isset( $plugin_settings['posts_per_page'] ) ) ? $plugin_settings['posts_per_page'] : 25; 
  • recommended-links/trunk/recommended-links.php

    r489905 r492236  
    147147    if ( $link_exists ) 
    148148        return false; 
    149      
     149 
     150    // See if any taxonomy terms were selected 
     151    $taxes = (isset( $reclinks['reclink_taxes'] ) ) ? 
     152        array_filter( $reclink['reclink_taxes'], 'empty_taxonomy' ) : null; 
     153 
     154    function empty_taxonomy( $t ) { 
     155        if ( is_array( $t ) ) { 
     156            $t = array_filter( $t ); 
     157            return ( !empty( $t ) ); 
     158        }        
     159        else return ( $t ); 
     160    } 
     161 
    150162    $link_ID = wp_insert_post( array( 
    151163        'post_type'     => 'reclink', 
     
    158170 
    159171    update_post_meta( $link_ID, '_href', $reclink['reclink_url'] ); 
    160     update_post_meta( $link_ID, '_vote_score', 1 ); 
     172 
     173    gad_add_reclink_vote( $link_ID, 0, 1, $current_user->ID, $_SERVER['REMOTE_ADDR'] ); 
    161174 
    162175    return $link_ID; 
     
    217230    if ( 0 === $comment) { 
    218231        // vote on post, update post meta value 
    219         update_post_meta( $reclink, '_vote_score', $new_vote_total+1 ); 
     232        update_post_meta( $reclink, '_vote_score', $new_vote_total ); 
    220233    } else { 
    221234        // vote on comment, update comment karma value 
    222235        wp_update_comment( array( 
    223236            'comment_ID' => $comment, 
    224             'comment_karma' => $new_vote_total+1 
     237            'comment_karma' => $new_vote_total 
    225238        ) );     
    226239    } 
     
    228241    do_action( 'reclink_add_vote', $reclink, $comment, $vote ); 
    229242 
    230     return $new_vote_total + 1; 
    231 } 
    232  
     243    return $new_vote_total; 
     244} 
     245 
Note: See TracChangeset for help on using the changeset viewer.