Unverified Commit 24b97f77 authored by Lester Chan's avatar Lester Chan Committed by GitHub
Browse files

Merge pull request #127 from kmd-thomasBrace/master

Add extra display functions for individual polls
parents 2afa438d ebf75c9b
......@@ -209,6 +209,14 @@ I spent most of my free time creating, updating, maintaining and supporting thes
<?php endif; ?>
```
### To Display Poll Votes by ID
```php
<?php if ( function_exists( 'get_pollvotes_by_id' ) ): ?>
<?php get_pollvotes_by_id($poll_id); ?>
<?php endif; ?>
```
### To Display Total Poll Voters
```php
......@@ -216,3 +224,11 @@ I spent most of my free time creating, updating, maintaining and supporting thes
<?php get_pollvoters(); ?>
<?php endif; ?>
```
### To Display Poll Time by ID and date format
```php
<?php if ( function_exists( 'get_polltime' ) ): ?>
<?php get_polltime($poll_id, $date_format); ?>
<?php endif; ?>
```
......@@ -851,6 +851,20 @@ if(!function_exists('get_pollvotes')) {
}
}
### Function: Get Poll Votes Based on Poll ID
if(!function_exists('get_pollvotes_by_id')) {
function get_pollvotes_by_id($poll_id, $display = true) {
global $wpdb;
$poll_id = (int) $poll_id;
$totalvotes = (int) $wpdb->get_var( $wpdb->prepare("SELECT pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $poll_id));
if($display) {
echo $totalvotes;
} else {
return $totalvotes;
}
}
}
### Function: Get Poll Total Voters
if(!function_exists('get_pollvoters')) {
......@@ -865,6 +879,21 @@ if(!function_exists('get_pollvoters')) {
}
}
### Function: Get Poll Time Based on Poll ID and Date Format
if(!function_exists('get_polltime')) {
function get_polltime($poll_id, $date_format = 'd/m/Y', $display = true) {
global $wpdb;
$poll_id = (int) $poll_id;
$timestamp = (int) $wpdb->get_var( $wpdb->prepare("SELECT pollq_timestamp FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $poll_id));
$formatted_date = date( $date_format, $timestamp );
if($display) {
echo $formatted_date;
} else {
return $formatted_date;
}
}
}
### Function: Check Voted To Get Voted Answer
function check_voted_multiple($poll_id, $polls_ips) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment