WordPress.org

Plugin Directory

Changeset 481654


Ignore:
Timestamp:
12/28/11 21:47:41 (2 years ago)
Author:
goldenapples
Message:

Committing version 0.2.1, and playing with banner image

Location:
recommended-links
Files:
2 added
5 edited
11 copied

Legend:

Unmodified
Added
Removed
  • recommended-links

    • Property svn:ignore set to
      trunk/.git
  • recommended-links/tags/0.2.1

    • Property svn:ignore set to
      .git
  • recommended-links/tags/0.2.1/display-filters.php

    r481240 r481654  
    99    if ( !is_post_type_archive('reclink') ) 
    1010        return $query; 
     11 
     12    $query->set( 'posts_per_page', 25 ); 
    1113 
    1214    $sortby = 'current'; // default sort 
     
    2527            break; 
    2628        case 'current': 
     29            add_filter( 'posts_fields', 'gad_reclinks_posts_fields' ); 
     30            add_filter( 'posts_join', 'gad_reclinks_votes_join_current' ); 
     31            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
     32            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     33            break; 
    2734        case 'hot': 
     35            add_filter( 'posts_fields', 'gad_reclinks_posts_fields' ); 
     36            add_filter( 'posts_join', 'gad_reclinks_votes_join_hot' ); 
     37            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
     38            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     39            break; 
    2840        case 'newest': 
    2941            break; 
     
    3244    return $query; 
    3345 
     46} 
     47 
     48function gad_reclinks_posts_fields( $fields ) { 
     49    global $wpdb; 
     50    $fields = str_replace( "{$wpdb->posts}.*", "{$wpdb->posts}.*, SUM( {$wpdb->reclinkvotes}.vote ) AS post_vote ", $fields ); 
     51    return $fields; 
     52} 
     53 
     54function gad_reclinks_votes_join_hot() { 
     55    return gad_reclinks_votes_join( '1 DAY' ); 
     56} 
     57 
     58function gad_reclinks_votes_join_current() { 
     59    return gad_reclinks_votes_join( '1 WEEK' ); 
     60} 
     61 
     62function gad_reclinks_votes_join( $interval ) { 
     63    global $wpdb; 
     64    $join_sql = "LEFT JOIN {$wpdb->reclinkvotes} ON ( {$wpdb->reclinkvotes}.post_id = {$wpdb->posts}.ID AND DATE_ADD( {$wpdb->reclinkvotes}.vote_time, INTERVAL $interval ) > NOW() )"; 
     65    return $join_sql; 
     66} 
     67 
     68function gad_reclinks_groupby( $groupby ) { 
     69    global $wpdb; 
     70    $groupby = "{$wpdb->posts}.ID"; 
     71    return $groupby; 
     72} 
     73 
     74function gad_reclinks_orderby( $orderby ) { 
     75    global $wpdb; 
     76    $orderby = "post_vote DESC, {$wpdb->posts}.post_date DESC"; 
     77    return $orderby; 
    3478} 
    3579 
  • recommended-links/tags/0.2.1/readme.txt

    r481350 r481654  
    55Requires at least: 3.2.1 
    66Tested up to: 3.3 
    7 Stable tag: 0.2 
     7Stable tag: 0.2.1 
    88 
    99A sort of "Reddit clone" that allows users to post links, up- or down-vote them, and comment on them. 
     
    2525== Frequently Asked Questions == 
    2626 
     27= What sorting options are there = 
     28 
     29Currently this plugin supports sorting of archive pages by a "sort" parameter passed via query string. The options allowed are: 
     30 
     31* **newest** Sort links by posted time, most recently first 
     32* **hot** Sort links by votes over the past day 
     33* **current** Sort by votes over the past week 
     34* **score** Sort by total vote score over time 
     35 
     36So for example, the URL `yoursite.tld/reclinks/?sort=hot` would display a page of the 25 links with the highest vote score over the past day. 
     37 
     38At this point, implementing these sorting options is fully up to you - a user cookie would make sense here, or a drop down at the top of the archive page would work. I will provide a template tag and a widget to change sorting once I flesh out these options some more. 
     39 
    2740= What markup does the plugin offer? = 
    2841 
     
    3548By default, this plugin filters both `the_content` and `comment_text` to add vote buttons and current score box above the post/comment content. If you want to display these in a different position, you can unhook those filters and use the template tag `reclinks_votebox()` in your template files wherever you want the vote box to display. 
    3649 
    37 There are not many special display features yet.  
     50There are not many special display features yet. A partial listing: 
    3851 
    39 `reclink_domain()` echoes the host of the link submitted - give people a chance to know what they're getting themselves into before they follow a link.  
     52* `reclink_domain()` echoes the host of the link submitted - give people a chance to know what they're getting themselves into before they follow a link.  
     53* `reclink_votebox()` echoes a div with +/- vote buttons, the current score, author, and human time diff'd post date 
    4054 
    4155= Sample markup = 
     
    5872== Changelog == 
    5973 
     74= 0.2.1 = 
     75Implemented four new sorting options to the recommended links archive page: "newest", "hot", "current", and "score". Also fixed minor bug in resolving symlinked plugin directory 
     76 
    6077= 0.2 =  
    6178This is the first initial public release. This uses a custom post type, rather than trying to do everything through custom tables and functions.  
     
    6481I built a version 0.1 back in 2010 for a personal project, which was only half complete (most of the functions necessary to run the plugin were mixed in with theme files, and functionality was very limited.) 
    6582 
     83 
     84== Upgrade Notice == 
     85 
     86= 0.2.1 = 
     87Implemented four new sorting options to the recommended links archive page: "newest", "hot", "current", and "score". 
  • recommended-links/tags/0.2.1/recommended-links.php

    r481240 r481654  
    55Description: A "reddit clone" that runs in Wordpress. 
    66Author: Nathaniel Taintor 
    7 Version: 0.2 
     7Version: 0.2.1 
    88Author URI: http://goldenapplesdesign.com 
    99*/ 
     
    1414global $wpdb; 
    1515 
     16// This is a hack to get around symlink resolving issues, see  
     17// http://wordpress.stackexchange.com/questions/15202/plugins-in-symlinked-directories 
     18// Hopefully a better solution will be found in future versions of WordPress. 
     19if ( isset( $plugin ) ) 
     20    define( 'RECLINKS_DIRECTORY', plugin_dir_url( $plugin ) ); 
     21else define( 'RECLINKS_DIRECTORY', RECLINKS_DIRECTORY ); 
    1622 
    1723// Required files 
     
    8288    if ( is_admin() ) 
    8389        return; 
    84     wp_enqueue_script( 'reclinks-scripts', plugin_dir_url( __FILE__ ) . 'js/reclinks-scripts.js', array( 'jquery' ), false, true ); 
     90    wp_enqueue_script( 'reclinks-scripts', RECLINKS_DIRECTORY . 'js/reclinks-scripts.js', array( 'jquery' ), false, true ); 
    8591    wp_localize_script( 'reclinks-scripts', 'reclinks',  
    8692        array(  
     
    8995        )  
    9096    ); 
    91     wp_enqueue_style( 'reclinks', plugin_dir_url( __FILE__ ) . 'reclinks-styles.css' ); 
     97    wp_enqueue_style( 'reclinks', RECLINKS_DIRECTORY . 'reclinks-styles.css' ); 
    9298} 
    9399 
  • recommended-links/trunk

    • Property svn:ignore set to
      .git
  • recommended-links/trunk/display-filters.php

    r481240 r481654  
    99    if ( !is_post_type_archive('reclink') ) 
    1010        return $query; 
     11 
     12    $query->set( 'posts_per_page', 25 ); 
    1113 
    1214    $sortby = 'current'; // default sort 
     
    2527            break; 
    2628        case 'current': 
     29            add_filter( 'posts_fields', 'gad_reclinks_posts_fields' ); 
     30            add_filter( 'posts_join', 'gad_reclinks_votes_join_current' ); 
     31            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
     32            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     33            break; 
    2734        case 'hot': 
     35            add_filter( 'posts_fields', 'gad_reclinks_posts_fields' ); 
     36            add_filter( 'posts_join', 'gad_reclinks_votes_join_hot' ); 
     37            add_filter( 'posts_groupby', 'gad_reclinks_groupby' ); 
     38            add_filter( 'posts_orderby', 'gad_reclinks_orderby' ); 
     39            break; 
    2840        case 'newest': 
    2941            break; 
     
    3244    return $query; 
    3345 
     46} 
     47 
     48function gad_reclinks_posts_fields( $fields ) { 
     49    global $wpdb; 
     50    $fields = str_replace( "{$wpdb->posts}.*", "{$wpdb->posts}.*, SUM( {$wpdb->reclinkvotes}.vote ) AS post_vote ", $fields ); 
     51    return $fields; 
     52} 
     53 
     54function gad_reclinks_votes_join_hot() { 
     55    return gad_reclinks_votes_join( '1 DAY' ); 
     56} 
     57 
     58function gad_reclinks_votes_join_current() { 
     59    return gad_reclinks_votes_join( '1 WEEK' ); 
     60} 
     61 
     62function gad_reclinks_votes_join( $interval ) { 
     63    global $wpdb; 
     64    $join_sql = "LEFT JOIN {$wpdb->reclinkvotes} ON ( {$wpdb->reclinkvotes}.post_id = {$wpdb->posts}.ID AND DATE_ADD( {$wpdb->reclinkvotes}.vote_time, INTERVAL $interval ) > NOW() )"; 
     65    return $join_sql; 
     66} 
     67 
     68function gad_reclinks_groupby( $groupby ) { 
     69    global $wpdb; 
     70    $groupby = "{$wpdb->posts}.ID"; 
     71    return $groupby; 
     72} 
     73 
     74function gad_reclinks_orderby( $orderby ) { 
     75    global $wpdb; 
     76    $orderby = "post_vote DESC, {$wpdb->posts}.post_date DESC"; 
     77    return $orderby; 
    3478} 
    3579 
  • recommended-links/trunk/readme.txt

    r481350 r481654  
    55Requires at least: 3.2.1 
    66Tested up to: 3.3 
    7 Stable tag: 0.2 
     7Stable tag: 0.2.1 
    88 
    99A sort of "Reddit clone" that allows users to post links, up- or down-vote them, and comment on them. 
     
    2525== Frequently Asked Questions == 
    2626 
     27= What sorting options are there = 
     28 
     29Currently this plugin supports sorting of archive pages by a "sort" parameter passed via query string. The options allowed are: 
     30 
     31* **newest** Sort links by posted time, most recently first 
     32* **hot** Sort links by votes over the past day 
     33* **current** Sort by votes over the past week 
     34* **score** Sort by total vote score over time 
     35 
     36So for example, the URL `yoursite.tld/reclinks/?sort=hot` would display a page of the 25 links with the highest vote score over the past day. 
     37 
     38At this point, implementing these sorting options is fully up to you - a user cookie would make sense here, or a drop down at the top of the archive page would work. I will provide a template tag and a widget to change sorting once I flesh out these options some more. 
     39 
    2740= What markup does the plugin offer? = 
    2841 
     
    3548By default, this plugin filters both `the_content` and `comment_text` to add vote buttons and current score box above the post/comment content. If you want to display these in a different position, you can unhook those filters and use the template tag `reclinks_votebox()` in your template files wherever you want the vote box to display. 
    3649 
    37 There are not many special display features yet.  
     50There are not many special display features yet. A partial listing: 
    3851 
    39 `reclink_domain()` echoes the host of the link submitted - give people a chance to know what they're getting themselves into before they follow a link.  
     52* `reclink_domain()` echoes the host of the link submitted - give people a chance to know what they're getting themselves into before they follow a link.  
     53* `reclink_votebox()` echoes a div with +/- vote buttons, the current score, author, and human time diff'd post date 
    4054 
    4155= Sample markup = 
     
    5872== Changelog == 
    5973 
     74= 0.2.1 = 
     75Implemented four new sorting options to the recommended links archive page: "newest", "hot", "current", and "score". Also fixed minor bug in resolving symlinked plugin directory 
     76 
    6077= 0.2 =  
    6178This is the first initial public release. This uses a custom post type, rather than trying to do everything through custom tables and functions.  
     
    6481I built a version 0.1 back in 2010 for a personal project, which was only half complete (most of the functions necessary to run the plugin were mixed in with theme files, and functionality was very limited.) 
    6582 
     83 
     84== Upgrade Notice == 
     85 
     86= 0.2.1 = 
     87Implemented four new sorting options to the recommended links archive page: "newest", "hot", "current", and "score". 
  • recommended-links/trunk/recommended-links.php

    r481240 r481654  
    55Description: A "reddit clone" that runs in Wordpress. 
    66Author: Nathaniel Taintor 
    7 Version: 0.2 
     7Version: 0.2.1 
    88Author URI: http://goldenapplesdesign.com 
    99*/ 
     
    1414global $wpdb; 
    1515 
     16// This is a hack to get around symlink resolving issues, see  
     17// http://wordpress.stackexchange.com/questions/15202/plugins-in-symlinked-directories 
     18// Hopefully a better solution will be found in future versions of WordPress. 
     19if ( isset( $plugin ) ) 
     20    define( 'RECLINKS_DIRECTORY', plugin_dir_url( $plugin ) ); 
     21else define( 'RECLINKS_DIRECTORY', RECLINKS_DIRECTORY ); 
    1622 
    1723// Required files 
     
    8288    if ( is_admin() ) 
    8389        return; 
    84     wp_enqueue_script( 'reclinks-scripts', plugin_dir_url( __FILE__ ) . 'js/reclinks-scripts.js', array( 'jquery' ), false, true ); 
     90    wp_enqueue_script( 'reclinks-scripts', RECLINKS_DIRECTORY . 'js/reclinks-scripts.js', array( 'jquery' ), false, true ); 
    8591    wp_localize_script( 'reclinks-scripts', 'reclinks',  
    8692        array(  
     
    8995        )  
    9096    ); 
    91     wp_enqueue_style( 'reclinks', plugin_dir_url( __FILE__ ) . 'reclinks-styles.css' ); 
     97    wp_enqueue_style( 'reclinks', RECLINKS_DIRECTORY . 'reclinks-styles.css' ); 
    9298} 
    9399 
Note: See TracChangeset for help on using the changeset viewer.