Commit 564556a3 authored by Thomas Brace's avatar Thomas Brace
Browse files

Change get poll timestamp to get time

parent a6dff291
......@@ -225,10 +225,10 @@ I spent most of my free time creating, updating, maintaining and supporting thes
<?php endif; ?>
```
### To Display Poll Timestamp by ID
### To Display Poll Time by ID and date format
```php
<?php if ( function_exists( 'get_polltimestamp' ) ): ?>
<?php get_polltimestamp($poll_id); ?>
<?php if ( function_exists( 'get_polltime' ) ): ?>
<?php get_polltime($poll_id, $date_format); ?>
<?php endif; ?>
```
......@@ -856,7 +856,7 @@ 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("SELECT pollq_totalvotes FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $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 {
......@@ -879,16 +879,17 @@ if(!function_exists('get_pollvoters')) {
}
}
### Function: Get Poll Timestamp Based on Poll ID
if(!function_exists('get_polltimestamp')) {
function get_polltimestamp($poll_id, $display = true) {
### 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("SELECT pollq_timestamp FROM $wpdb->pollsq WHERE pollq_id = %d LIMIT 1", $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 $timestamp;
echo $formatted_date;
} else {
return $timestamp;
return $formatted_date;
}
}
}
......
Supports Markdown
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