Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Markus Hermann
wp-polls
Commits
564556a3
Commit
564556a3
authored
Mar 08, 2019
by
Thomas Brace
Browse files
Change get poll timestamp to get time
parent
a6dff291
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
564556a3
...
...
@@ -225,10 +225,10 @@ I spent most of my free time creating, updating, maintaining and supporting thes
<?php
endif
;
?>
```
### To Display Poll Time
stamp
by ID
### To Display Poll Time by ID
and date format
```
php
<?php
if
(
function_exists
(
'get_polltime
stamp
'
)
)
:
?>
<?php
get_polltime
stamp
(
$poll_id
);
?>
<?php
if
(
function_exists
(
'get_polltime'
)
)
:
?>
<?php
get_polltime
(
$poll_id
,
$date_format
);
?>
<?php
endif
;
?>
```
wp-polls.php
View file @
564556a3
...
...
@@ -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 Time
stamp
Based on Poll ID
if
(
!
function_exists
(
'get_polltime
stamp
'
))
{
function
get_polltime
stamp
(
$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
;
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment