Skip to content

Commit

Permalink
"vote-on-comments" option
Browse files Browse the repository at this point in the history
  • Loading branch information
goldenapples committed Jan 13, 2012
1 parent 1778adc commit 36f0963
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
14 changes: 13 additions & 1 deletion admin-functions.php
Expand Up @@ -79,6 +79,17 @@ function reclinks_plugin_settings() {
-->
</td>
</tr>
<tr>
<th scope="row">
<label><?php _e( 'Comments:', 'gad_reclinks' ); ?></label>
</th>
<td>
<p>
<input type="checkbox" name="vote-on-comments" <?php checked( $current_settings['vote-on-comments'] ); ?> />
<label for="vote-on-comments"><?php _e( 'Enable voting / points tally on comments?', 'gad_reclinks' ); ?></label>
</p>
</td>
</tr>
<tr>
<th></th>
<td>
Expand All @@ -105,7 +116,8 @@ function update_reclinks_settings() {
'sort_order' => $_POST['sort_order'],
'tax' => ( isset( $_POST['tax'] ) ) ? $_POST['tax'] : array(),
'allow-unregistered-vote' => (isset($_POST['allow-unregistered-vote']) && true == $_POST['allow-unregistered-vote']),
'allow-unregistered-post' => (isset($_POST['allow-unregistered-post']) &&true == $_POST['allow-unregistered-post']),
'allow-unregistered-post' => (isset($_POST['allow-unregistered-post']) && true == $_POST['allow-unregistered-post']),
'vote-on-comments' => (isset($_POST['vote-on-comments']) && true == $_POST['vote-on-comments']),

// no UI for this yet, but its gotta be in there
'vote-values' => array(
Expand Down
21 changes: 15 additions & 6 deletions display-filters.php
Expand Up @@ -137,15 +137,21 @@ function gad_reclinks_show_votelinks( $content ) {


/**
* By default, filters comment_text to add the vote box above the comment text.
* By default, this function filters comment_text to add the vote box above the
* comment text IF the setting "Enable voting / points tally on comments" is on.
* If you would like to add the vote box in a different location, you can remove
* this filter and include the template tag reclinks_votebox() in your comment
* callback function
*
* callback function.
*
*/
add_filter( 'comment_text', 'reclinks_comment_show_votelinks' );

function reclinks_comment_show_votelinks( $comment_text, $comment = null ) {
$plugin_settings = get_option( 'reclinks_plugin_options' );

if ( false == $plugin_settings['vote-on-comments'] )
return $comment_text;

if ( is_admin() )
return $comment_text;

Expand Down Expand Up @@ -176,14 +182,17 @@ function gad_reclinks_permalink( $permalink ) {

function reclink_domain( $echo = true ) { return reclinks_domain( $echo ); } // the price you pay for typos in documentation

function reclinks_domain( $echo = true ) {
function reclinks_domain( $echo = true, $before = '(', $after = ')' ) {
global $post;
if ( $href = get_post_meta( $post->ID, '_href', true ) )
$host = parse_url( $href, PHP_URL_HOST );

if ( empty( $host ) ) return;

if ( $echo )
echo $host;
echo $before . $host . $after;
else
return $host;
return $before . $host . $after;
}


Expand Down
2 changes: 1 addition & 1 deletion loop-reclinks.php
Expand Up @@ -26,7 +26,7 @@
<li>
<?php reclink_terms(); ?>
<strong><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></strong>
<small>(<?php reclink_domain(); ?>)<small>
<small><?php reclinks_domain(); ?><small>
<br /><?php reclinks_votebox(); ?>
</li>
<?php endwhile; ?>
Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Expand Up @@ -4,7 +4,7 @@ Donate link: http://goldenapplesdesign.com/projects/recommended-links-plugin-for
Tags: social bookmarking, sharing, voting, reddit, digg
Requires at least: 3.2.1
Tested up to: 3.3.1
Stable tag: 0.3.2
Stable tag: 0.3.3

A sort of "Reddit clone" that allows users to post links, up- or down-vote them, and comment on them.

Expand Down Expand Up @@ -68,6 +68,10 @@ There are not many special display features yet. A partial listing:

== Changelog ==

= 0.3.3 =

Several bugfixes; added "vote on comments" option and styling for buttons.

= 0.3.2 =

Fixed a number of "missing index" bugs that caused error messages on first activation of the plugin.
Expand Down Expand Up @@ -104,6 +108,10 @@ I built a version 0.1 back in 2010 for a personal project, which was only half c

== Upgrade Notice ==

= 0.3.3 =

This update fixes several bugs that were pointed out (time zone setting, posts showing up as from "anonymous", update messages not defined), and adds an option to disable voting on comments. It also styles the +1/-1 buttons a bit - skins for the style will be selectable and overridable by version 0.4, but just for now I was tired of seeing the unstyled buttons.

= 0.3 =

This version includes a plugin settings page, as well as multiple new features:
Expand Down
5 changes: 2 additions & 3 deletions recommended-links.php
Expand Up @@ -4,7 +4,7 @@
Plugin URI: http://goldenapplesdesign.com/projects/recommended-links-plugin/
Description: A "reddit clone" that runs in Wordpress.
Author: Nathaniel Taintor
Version: 0.3.2
Version: 0.3.3
Author URI: http://goldenapplesdesign.com
*/

Expand Down Expand Up @@ -77,7 +77,6 @@ function register_cpt_reclink() {

register_post_type( 'reclink', $args );


}

// Activation / deactivation
Expand All @@ -90,7 +89,7 @@ function register_cpt_reclink() {

function gad_check_db_tables() {
$v = get_option( 'reclinks_db_version' );
if ( !$v || $v < 3 )
if ( !$v || $v < 4 )
reclinks_db_option_upgrade( $v );
}

Expand Down

0 comments on commit 36f0963

Please sign in to comment.