WordPress.org

Plugin Directory

Changeset 481905


Ignore:
Timestamp:
12/29/11 15:40:11 (2 years ago)
Author:
goldenapples
Message:

Bugfix: remove all filters after custom query

Location:
recommended-links
Files:
3 edited
13 copied

Legend:

Unmodified
Added
Removed
  • recommended-links/tags/0.2.3/display-filters.php

    r481764 r481905  
    3333            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
    3434            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     35            add_action( 'the_posts', 'gad_remove_custom_filters' ); 
    3536            break; 
    3637        case 'hot': 
     
    3940            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
    4041            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     42            add_action( 'the_posts', 'gad_remove_custom_filters' ); 
    4143            break; 
    4244        case 'newest': 
     
    4749 
    4850} 
     51 
     52function gad_remove_custom_filters( $posts ) { 
     53    remove_filter( 'posts_fields', 'gad_reclinks_posts_fields' ); 
     54    remove_filter( 'posts_join', 'gad_reclinks_votes_join_hot' ); 
     55    remove_filter( 'posts_join', 'gad_reclinks_votes_join_current' ); 
     56    remove_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
     57    remove_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     58    return $posts; 
     59} 
     60 
    4961 
    5062function gad_reclinks_posts_fields( $fields ) { 
     
    123135        $comments_number = get_comments_number(); 
    124136        if ( $comments_number > 0 ) 
    125             $comments_text = _n( 'One comment', "%s comments", get_comments_number(), 'gad_reclinks' ); 
     137            $comments_text = _n( 'One comment', sprintf( '%s comments', get_comments_number() ) ,get_comments_number(), 'gad_reclinks' ); 
    126138        else  
    127139            $comments_text = __( 'No comments yet', 'gad_reclinks' ); 
    128140         
    129         $comments_link_text = '<a href="' . get_comments_link() . '" title="' . the_title_attribute( 'echo=0' ) . '">' . $comments_text . '</a>'; 
     141        $comments_link_text = '- <a href="' . get_comments_link() . '" title="' . the_title_attribute( 'echo=0' ) . '">' . $comments_text . '</a>'; 
    130142        $author_link = ( get_the_author() )  
    131143            ?  '<a href="' . get_author_posts_url( $post->post_author ) . '">' . get_the_author() . '</a>'  
     
    175187 
    176188    $votebox = <<<VOTEBOX 
    177 <div class="votebox">$vote_options | <span class="votescore">$current_score</span> points by $author_link $submit_time - $comments_link_text</form></div> 
     189<div class="votebox">$vote_options | <span class="votescore">$current_score</span> points by $author_link $submit_time $comments_link_text</form></div> 
    178190VOTEBOX; 
    179191 
  • recommended-links/tags/0.2.3/readme.txt

    r481764 r481905  
    55Requires at least: 3.2.1 
    66Tested up to: 3.3 
    7 Stable tag: 0.2.2 
     7Stable tag: 0.2.3 
    88 
    99A sort of "Reddit clone" that allows users to post links, up- or down-vote them, and comment on them. 
  • recommended-links/tags/0.2.3/recommended-links.php

    r481764 r481905  
    55Description: A "reddit clone" that runs in Wordpress. 
    66Author: Nathaniel Taintor 
    7 Version: 0.2.2 
     7Version: 0.2.3 
    88Author URI: http://goldenapplesdesign.com 
    99*/ 
     
    1212$reclinks_theme_options = get_option('reclinks_plugin_options'); 
    1313 
     14// Register reclinks_votes table so it can be used with $wpdb class 
    1415global $wpdb; 
     16$wpdb->reclinkvotes = $wpdb->prefix . 'reclinks_votes'; 
    1517 
    1618// This is a hack to get around symlink resolving issues, see  
     
    2628require_once( plugin_dir_path( __FILE__ ) . '/ajax-functions.php' ); 
    2729require_once( plugin_dir_path( __FILE__ ) . '/display-filters.php' ); 
    28  
    29 // Register reclinks_votes table so it can be used with $wpdb class 
    30 global $wpdb; 
    31 $wpdb->reclinkvotes = $wpdb->prefix . 'reclinks_votes'; 
    3230 
    3331// Register custom post type required for this work 
  • recommended-links/trunk/display-filters.php

    r481764 r481905  
    3333            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
    3434            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     35            add_action( 'the_posts', 'gad_remove_custom_filters' ); 
    3536            break; 
    3637        case 'hot': 
     
    3940            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
    4041            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     42            add_action( 'the_posts', 'gad_remove_custom_filters' ); 
    4143            break; 
    4244        case 'newest': 
     
    4749 
    4850} 
     51 
     52function gad_remove_custom_filters( $posts ) { 
     53    remove_filter( 'posts_fields', 'gad_reclinks_posts_fields' ); 
     54    remove_filter( 'posts_join', 'gad_reclinks_votes_join_hot' ); 
     55    remove_filter( 'posts_join', 'gad_reclinks_votes_join_current' ); 
     56    remove_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
     57    remove_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     58    return $posts; 
     59} 
     60 
    4961 
    5062function gad_reclinks_posts_fields( $fields ) { 
     
    123135        $comments_number = get_comments_number(); 
    124136        if ( $comments_number > 0 ) 
    125             $comments_text = _n( 'One comment', "%s comments", get_comments_number(), 'gad_reclinks' ); 
     137            $comments_text = _n( 'One comment', sprintf( '%s comments', get_comments_number() ) ,get_comments_number(), 'gad_reclinks' ); 
    126138        else  
    127139            $comments_text = __( 'No comments yet', 'gad_reclinks' ); 
    128140         
    129         $comments_link_text = '<a href="' . get_comments_link() . '" title="' . the_title_attribute( 'echo=0' ) . '">' . $comments_text . '</a>'; 
     141        $comments_link_text = '- <a href="' . get_comments_link() . '" title="' . the_title_attribute( 'echo=0' ) . '">' . $comments_text . '</a>'; 
    130142        $author_link = ( get_the_author() )  
    131143            ?  '<a href="' . get_author_posts_url( $post->post_author ) . '">' . get_the_author() . '</a>'  
     
    175187 
    176188    $votebox = <<<VOTEBOX 
    177 <div class="votebox">$vote_options | <span class="votescore">$current_score</span> points by $author_link $submit_time - $comments_link_text</form></div> 
     189<div class="votebox">$vote_options | <span class="votescore">$current_score</span> points by $author_link $submit_time $comments_link_text</form></div> 
    178190VOTEBOX; 
    179191 
  • recommended-links/trunk/readme.txt

    r481764 r481905  
    55Requires at least: 3.2.1 
    66Tested up to: 3.3 
    7 Stable tag: 0.2.2 
     7Stable tag: 0.2.3 
    88 
    99A sort of "Reddit clone" that allows users to post links, up- or down-vote them, and comment on them. 
  • recommended-links/trunk/recommended-links.php

    r481764 r481905  
    55Description: A "reddit clone" that runs in Wordpress. 
    66Author: Nathaniel Taintor 
    7 Version: 0.2.2 
     7Version: 0.2.3 
    88Author URI: http://goldenapplesdesign.com 
    99*/ 
     
    1212$reclinks_theme_options = get_option('reclinks_plugin_options'); 
    1313 
     14// Register reclinks_votes table so it can be used with $wpdb class 
    1415global $wpdb; 
     16$wpdb->reclinkvotes = $wpdb->prefix . 'reclinks_votes'; 
    1517 
    1618// This is a hack to get around symlink resolving issues, see  
     
    2628require_once( plugin_dir_path( __FILE__ ) . '/ajax-functions.php' ); 
    2729require_once( plugin_dir_path( __FILE__ ) . '/display-filters.php' ); 
    28  
    29 // Register reclinks_votes table so it can be used with $wpdb class 
    30 global $wpdb; 
    31 $wpdb->reclinkvotes = $wpdb->prefix . 'reclinks_votes'; 
    3230 
    3331// Register custom post type required for this work 
Note: See TracChangeset for help on using the changeset viewer.