YOP Poll - Version 6.0.6

Version Description

  • fixed issue with blocking voters
  • fixed issue with logs
  • fixed issue with bans
  • fixed issue with settings
  • fixed issue with wordpress voting
Download this release

Release Info

Developer yourownprogrammer
Plugin Icon 128x128 YOP Poll
Version 6.0.6
Comparing to
See all releases

Code changes from version 6.0.5 to 6.0.6

admin/admin.php CHANGED
@@ -69,6 +69,10 @@ class YOP_Poll_Admin {
69
$maintenance = new YOP_POLL_Maintenance();
70
$maintenance->update_to_version_6_0_5();
71
}
72
}
73
}
74
public function load_translations() {
@@ -850,7 +854,7 @@ class YOP_Poll_Admin {
850
);
851
} else {
852
$error = __( 'Invalid poll', 'yop-poll' );
853
- $template = YOP_POLL_PATH . 'admin/views/error.php';
854
echo YOP_Poll_View::render(
855
$template,
856
array(
@@ -898,11 +902,11 @@ class YOP_Poll_Admin {
898
}
899
}
900
public function manage_support() {
901
- $template = YOP_POLL_PATH . 'admin/views/support.php';
902
echo YOP_Poll_View::render( $template );
903
}
904
public function migrate_old_tables() {
905
- $template = YOP_POLL_PATH . 'admin/views/migrate-old-tables.php';
906
echo YOP_Poll_View::render( $template );
907
}
908
public function manage_logs () {
@@ -912,7 +916,7 @@ class YOP_Poll_Admin {
912
$params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'asc';
913
$params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
914
$logs = YOP_Poll_Logs::get_logs( $params );
915
- $template = YOP_POLL_PATH . 'admin/views/viewlogs.php';
916
echo YOP_Poll_View::render( $template, array(
917
'logs' => $logs['logs'],
918
'params' => $params,
@@ -979,7 +983,7 @@ class YOP_Poll_Admin {
979
$params['order_by'] = isset( $_GET['order_by'] ) ? $_GET['order_by'] : '';
980
$params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'asc';
981
$params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
982
- $template = YOP_POLL_PATH . 'admin/views/viewbanns.php';
983
$bans = YOP_Poll_Bans::get_bans( $params );
984
echo YOP_Poll_View::render( $template, array(
985
'bans' => $bans['bans'],
@@ -995,7 +999,7 @@ class YOP_Poll_Admin {
995
public function show_add_ban() {
996
if ( current_user_can( 'yop_poll_add' ) ) {
997
$polls = YOP_Poll_Polls::get_names();
998
- $template = YOP_POLL_PATH . 'admin/views/addban.php';
999
echo YOP_Poll_View::render( $template, array(
1000
'polls' => $polls
1001
) );
@@ -1024,7 +1028,7 @@ class YOP_Poll_Admin {
1024
$ban = YOP_Poll_Bans::get_ban( $ban_id );
1025
if ( false !== $ban ) {
1026
$polls = YOP_Poll_Polls::get_names();
1027
- $template = YOP_POLL_PATH . 'admin/views/editban.php';
1028
echo YOP_Poll_View::render( $template, array(
1029
'ban' => $ban['ban'],
1030
'polls' => $polls
@@ -1141,7 +1145,7 @@ class YOP_Poll_Admin {
1141
}
1142
public function record_wordpress_vote() {
1143
if ( isset( $_GET['poll_id'] ) && ( 0 < intval( $_GET['poll_id'] ) ) ) {
1144
- $template = YOP_POLL_PATH . 'admin/views/addnewwordpressvote.php';
1145
echo YOP_Poll_View::render( $template, array(
1146
'poll_id' => $_GET['poll_id']
1147
) );
@@ -1314,7 +1318,7 @@ class YOP_Poll_Admin {
1314
public function manage_settings() {
1315
$unserialized_settings = array();
1316
if ( current_user_can( 'yop_poll_add' ) ) {
1317
- $template = YOP_POLL_PATH . 'admin/views/viewsettings.php';
1318
$yop_poll_settings = get_option( 'yop_poll_settings' );
1319
if ( $yop_poll_settings ) {
1320
$unserialized_settings = unserialize( $yop_poll_settings );
69
$maintenance = new YOP_POLL_Maintenance();
70
$maintenance->update_to_version_6_0_5();
71
}
72
+ if ( true === version_compare( $installed_version, '6.0.6', '<' ) ) {
73
+ $maintenance = new YOP_POLL_Maintenance();
74
+ $maintenance->update_to_version_6_0_6();
75
+ }
76
}
77
}
78
public function load_translations() {
854
);
855
} else {
856
$error = __( 'Invalid poll', 'yop-poll' );
857
+ $template = YOP_POLL_PATH . 'admin/views/general/error.php';
858
echo YOP_Poll_View::render(
859
$template,
860
array(
902
}
903
}
904
public function manage_support() {
905
+ $template = YOP_POLL_PATH . 'admin/views/support/view.php';
906
echo YOP_Poll_View::render( $template );
907
}
908
public function migrate_old_tables() {
909
+ $template = YOP_POLL_PATH . 'admin/views/general/migrate-old-tables.php';
910
echo YOP_Poll_View::render( $template );
911
}
912
public function manage_logs () {
916
$params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'asc';
917
$params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
918
$logs = YOP_Poll_Logs::get_logs( $params );
919
+ $template = YOP_POLL_PATH . 'admin/views/logs/view.php';
920
echo YOP_Poll_View::render( $template, array(
921
'logs' => $logs['logs'],
922
'params' => $params,
983
$params['order_by'] = isset( $_GET['order_by'] ) ? $_GET['order_by'] : '';
984
$params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'asc';
985
$params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
986
+ $template = YOP_POLL_PATH . 'admin/views/bans/view.php';
987
$bans = YOP_Poll_Bans::get_bans( $params );
988
echo YOP_Poll_View::render( $template, array(
989
'bans' => $bans['bans'],
999
public function show_add_ban() {
1000
if ( current_user_can( 'yop_poll_add' ) ) {
1001
$polls = YOP_Poll_Polls::get_names();
1002
+ $template = YOP_POLL_PATH . 'admin/views/bans/add.php';
1003
echo YOP_Poll_View::render( $template, array(
1004
'polls' => $polls
1005
) );
1028
$ban = YOP_Poll_Bans::get_ban( $ban_id );
1029
if ( false !== $ban ) {
1030
$polls = YOP_Poll_Polls::get_names();
1031
+ $template = YOP_POLL_PATH . 'admin/views/bans/edit.php';
1032
echo YOP_Poll_View::render( $template, array(
1033
'ban' => $ban['ban'],
1034
'polls' => $polls
1145
}
1146
public function record_wordpress_vote() {
1147
if ( isset( $_GET['poll_id'] ) && ( 0 < intval( $_GET['poll_id'] ) ) ) {
1148
+ $template = YOP_POLL_PATH . 'admin/views/general/addnewwordpressvote.php';
1149
echo YOP_Poll_View::render( $template, array(
1150
'poll_id' => $_GET['poll_id']
1151
) );
1318
public function manage_settings() {
1319
$unserialized_settings = array();
1320
if ( current_user_can( 'yop_poll_add' ) ) {
1321
+ $template = YOP_POLL_PATH . 'admin/views/settings/view.php';
1322
$yop_poll_settings = get_option( 'yop_poll_settings' );
1323
if ( $yop_poll_settings ) {
1324
$unserialized_settings = unserialize( $yop_poll_settings );
admin/inc/maintenance.php CHANGED
@@ -42,7 +42,10 @@ class YOP_POLL_Maintenance {
42
$db_schema_object->update_table_templates();
43
$db_schema_object->update_table_polls_add_skin_field();
44
update_option( 'yop_poll_version', '6.0.5' );
45
- }
46
public function create_archive_page() {
47
$poll_archive_page = get_page_by_path( 'yop-poll-archive', ARRAY_A );
48
if ( ! $poll_archive_page ) {
42
$db_schema_object->update_table_templates();
43
$db_schema_object->update_table_polls_add_skin_field();
44
update_option( 'yop_poll_version', '6.0.5' );
45
+ }
46
+ public function update_to_version_6_0_6() {
47
+ update_option( 'yop_poll_version', '6.0.6' );
48
+ }
49
public function create_archive_page() {
50
$poll_archive_page = get_page_by_path( 'yop-poll-archive', ARRAY_A );
51
if ( ! $poll_archive_page ) {
admin/models/polls.php CHANGED
@@ -2120,4 +2120,99 @@ class YOP_Poll_Polls {
2120
}
2121
return $accept_votes_from_user;
2122
}
2123
}
2120
}
2121
return $accept_votes_from_user;
2122
}
2123
+ public static function accept_votes_from_anonymous( $poll, $voter_data ) {
2124
+ $accept_votes_from_anonymous = true;
2125
+ $should_continue = true;
2126
+ $previous_vote = null;
2127
+ if ( true === in_array( 'by-cookie', $poll->meta_data['options']['access']['blockVoters'] ) ) {
2128
+ if ( '' !== $voter_data['c-data'] ) {
2129
+ $previous_vote = YOP_Poll_Votes::get_vote( $poll->id, 'voter_id', $voter_data['c-data'] );
2130
+ }
2131
+ }
2132
+ if ( null !== $previous_vote ) {
2133
+ switch ( $poll->meta_data['options']['access']['blockForPeriod'] ) {
2134
+ case 'minutes': {
2135
+ $block_for_period = 'PT' . $poll->meta_data['options']['access']['blockForValue'] . 'M';
2136
+ break;
2137
+ }
2138
+ case 'hours': {
2139
+ $block_for_period = 'PT' . $poll->meta_data['options']['access']['blockForValue'] . 'H';
2140
+ break;
2141
+ }
2142
+ case 'days': {
2143
+ $block_for_period = 'P' . $poll->meta_data['options']['access']['blockForValue'] . 'D';
2144
+ break;
2145
+ }
2146
+ }
2147
+ $current_vote_date = new DateTime();
2148
+ $previous_vote_date = new DateTime( $previous_vote->added_date );
2149
+ $previous_vote_date->add( new DateInterval( $block_for_period ) );
2150
+ if ( $current_vote_date < $previous_vote_date ) {
2151
+ $accept_votes_from_anonymous = false;
2152
+ $should_continue = false;
2153
+ }
2154
+ }
2155
+ if ( true === $should_continue ) {
2156
+ $previous_vote = null;
2157
+ if ( true === in_array( 'by-ip', $poll->meta_data['options']['access']['blockVoters'] ) ) {
2158
+ if ( '' !== $voter_data['ipaddress'] ) {
2159
+ $previous_vote = YOP_Poll_Votes::get_vote( $poll->id, 'ipaddress', $voter_data['ipaddress'] );
2160
+ }
2161
+ }
2162
+ if ( null !== $previous_vote ) {
2163
+ switch ( $poll->meta_data['options']['access']['blockForPeriod'] ) {
2164
+ case 'minutes': {
2165
+ $block_for_period = 'PT' . $poll->meta_data['options']['access']['blockForValue'] . 'M';
2166
+ break;
2167
+ }
2168
+ case 'hours': {
2169
+ $block_for_period = 'PT' . $poll->meta_data['options']['access']['blockForValue'] . 'H';
2170
+ break;
2171
+ }
2172
+ case 'days': {
2173
+ $block_for_period = 'P' . $poll->meta_data['options']['access']['blockForValue'] . 'D';
2174
+ break;
2175
+ }
2176
+ }
2177
+ $current_vote_date = new DateTime();
2178
+ $previous_vote_date = new DateTime( $previous_vote->added_date );
2179
+ $previous_vote_date->add( new DateInterval( $block_for_period ) );
2180
+ if ( $current_vote_date < $previous_vote_date ) {
2181
+ $accept_votes_from_anonymous = false;
2182
+ $should_continue = false;
2183
+ }
2184
+ }
2185
+ }
2186
+ if ( true === $should_continue ) {
2187
+ $previous_vote = null;
2188
+ if ( true === in_array( 'by-user-id', $poll->meta_data['options']['access']['blockVoters'] ) ) {
2189
+ if ( '' !== $voter_data['user-id'] ) {
2190
+ $previous_vote = YOP_Poll_Votes::get_vote( $poll->id, 'user_id', $voter_data['user-id'] );
2191
+ }
2192
+ }
2193
+ if ( null !== $previous_vote ) {
2194
+ switch ( $poll->meta_data['options']['access']['blockForPeriod'] ) {
2195
+ case 'minutes': {
2196
+ $block_for_period = 'PT' . $poll->meta_data['options']['access']['blockForValue'] . 'M';
2197
+ break;
2198
+ }
2199
+ case 'hours': {
2200
+ $block_for_period = 'PT' . $poll->meta_data['options']['access']['blockForValue'] . 'H';
2201
+ break;
2202
+ }
2203
+ case 'days': {
2204
+ $block_for_period = 'P' . $poll->meta_data['options']['access']['blockForValue'] . 'D';
2205
+ break;
2206
+ }
2207
+ }
2208
+ $current_vote_date = new DateTime();
2209
+ $previous_vote_date = new DateTime( $previous_vote->added_date );
2210
+ $previous_vote_date->add( new DateInterval( $block_for_period ) );
2211
+ if ( $current_vote_date < $previous_vote_date ) {
2212
+ $accept_votes_from_anonymous = false;
2213
+ }
2214
+ }
2215
+ }
2216
+ return $accept_votes_from_anonymous;
2217
+ }
2218
}
readme.txt CHANGED
@@ -118,6 +118,13 @@ You can have only one question per poll.
118
119
== Changelog ==
120
121
= 6.0.5 =
122
* added skins
123
* redesigned templates
118
119
== Changelog ==
120
121
+ = 6.0.6 =
122
+ * fixed issue with blocking voters
123
+ * fixed issue with logs
124
+ * fixed issue with bans
125
+ * fixed issue with settings
126
+ * fixed issue with wordpress voting
127
+
128
= 6.0.5 =
129
* added skins
130
* redesigned templates
yop_poll.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: YOP Poll
4
Plugin URI: https://yop-poll.com
5
Description: Use a full option polling functionality to get the answers you need. YOP Poll is the perfect, easy to use poll plugin for your WordPress website.
6
- Version: 6.0.5
7
Author: yourownprogrammer
8
Author URI: https://yop-poll.com
9
License: GPL2
@@ -11,7 +11,7 @@ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
Domain Path: /languages
12
Text Domain: yop-poll
13
*/
14
- define ( 'YOP_POLL_VERSION', '6.0.5' );
15
define ( 'YOP_POLL_URL', plugin_dir_url( __FILE__ ) );
16
define ( 'YOP_POLL_PATH', plugin_dir_path( __FILE__ ) );
17
define( 'YOP_POLL_TEST_MODE', false );
3
Plugin Name: YOP Poll
4
Plugin URI: https://yop-poll.com
5
Description: Use a full option polling functionality to get the answers you need. YOP Poll is the perfect, easy to use poll plugin for your WordPress website.
6
+ Version: 6.0.6
7
Author: yourownprogrammer
8
Author URI: https://yop-poll.com
9
License: GPL2
11
Domain Path: /languages
12
Text Domain: yop-poll
13
*/
14
+ define ( 'YOP_POLL_VERSION', '6.0.6' );
15
define ( 'YOP_POLL_URL', plugin_dir_url( __FILE__ ) );
16
define ( 'YOP_POLL_PATH', plugin_dir_path( __FILE__ ) );
17
define( 'YOP_POLL_TEST_MODE', false );