Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to only have positive votes #16

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions admin/includes/class.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,16 @@ function get_settings_fields() {
'type' => 'text',
'default' => '',
'sanitize_callback' => 'idea_factory_sanitize_int'
),
array(
'name' => 'if_positive_only',
'label' => __( 'Positive Votes Only', 'idea-factory' ),
'desc' => __( 'Check this box to only allow positive votes.', 'idea-factory' ),
'type' => 'checkbox',
'default' => '',
'sanitize_callback' => 'idea_factory_sanitize_checkbox'
)

),
'if_settings_advanced' => array(
array(
Expand Down Expand Up @@ -378,9 +387,3 @@ function idea_factory_sanitize_int( $input ) {
endif;

$settings = new if_settings_api_wrap();






13 changes: 9 additions & 4 deletions public/includes/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function idea_factory_get_votes( $postid = 0 ) {

/**
*
* Grab an optoin from our settings
* Grab an option from our settings
*
* @param $option string name of the option
* @param $section string name of the section
Expand Down Expand Up @@ -448,9 +448,14 @@ function idea_factory_vote_controls( $postid = '' ) {
$postid = get_the_ID();

?>
<a class="idea-factory vote-up" data-post-id="<?php echo (int) $postid;?>" href="#"></a>
<a class="idea-factory vote-down" data-post-id="<?php echo (int) $postid;?>" href="#"></a>
<?php
<a class="idea-factory vote-up" data-user-id="<?php echo get_current_user_ID();?>" data-post-id="<?php echo (int) $postid;?>" href="#"></a>

<?php
$positive = idea_factory_get_option('if_positive_only','if_settings_main');
if ( 'on' !== $positive ) {
?> <a class="idea-factory vote-down" data-user-id="<?php echo get_current_user_ID();?>" data-post-id="<?php echo (int) $postid;?> " href="#"></a>
<?php
}
}

endif;
Expand Down