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
63b72312
Commit
63b72312
authored
Mar 08, 2019
by
Thomas Brace
Browse files
Add extra helper functions
parent
f9769f8f
Changes
2
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
63b72312
...
...
@@ -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 Timestamp by ID
```
php
<?php
if
(
function_exists
(
'get_polltimestamp'
)
)
:
?>
<?php
get_polltimestamp
(
$poll_id
);
?>
<?php
endif
;
?>
```
wp-polls.php
View file @
63b72312
...
...
@@ -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
(
"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,20 @@ if(!function_exists('get_pollvoters')) {
}
}
### Function: Get Poll Timestamp Based on Poll ID
if
(
!
function_exists
(
'get_polltimestamp'
))
{
function
get_pollvotes_by_id
(
$poll_id
,
$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
);
if
(
$display
)
{
echo
$timestamp
;
}
else
{
return
$timestamp
;
}
}
}
### Function: Check Voted To Get Voted Answer
function
check_voted_multiple
(
$poll_id
,
$polls_ips
)
{
...
...
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