YOP Poll - Version 6.0.0

Version Description

  • complete re-write
  • add GDPR compliance
Download this release

Release Info

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

Code changes from version 5.8.3 to 6.0.0

Files changed (700) hide show
  1. admin/admin.php +1231 -0
  2. admin/assets/css/admin.css +15 -0
  3. {fonts → admin/assets/fonts}/flexslider-icon.eot +0 -0
  4. {fonts → admin/assets/fonts}/flexslider-icon.svg +0 -0
  5. {fonts → admin/assets/fonts}/flexslider-icon.ttf +0 -0
  6. {fonts → admin/assets/fonts}/flexslider-icon.woff +0 -0
  7. admin/assets/fonts/glyphicons-halflings-regular.eot +0 -0
  8. admin/assets/fonts/glyphicons-halflings-regular.svg +288 -0
  9. admin/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
  10. admin/assets/fonts/glyphicons-halflings-regular.woff +0 -0
  11. admin/assets/fonts/glyphicons-halflings-regular.woff2 +0 -0
  12. admin/assets/fonts/summernote.eot +0 -0
  13. admin/assets/fonts/summernote.ttf +0 -0
  14. admin/assets/fonts/summernote.woff +0 -0
  15. admin/assets/images/bootstrap-colorpicker/alpha-horizontal.png +0 -0
  16. images/yop-poll-close.png → admin/assets/images/bootstrap-colorpicker/alpha.png +0 -0
  17. admin/assets/images/bootstrap-colorpicker/hue-horizontal.png +0 -0
  18. images/less-details-button.png → admin/assets/images/bootstrap-colorpicker/hue.png +0 -0
  19. admin/assets/images/bootstrap-colorpicker/saturation.png +0 -0
  20. admin/assets/images/jquery/ui-icons_444444_256x240.png +0 -0
  21. admin/assets/images/jquery/ui-icons_555555_256x240.png +0 -0
  22. admin/assets/images/jquery/ui-icons_777620_256x240.png +0 -0
  23. admin/assets/images/jquery/ui-icons_777777_256x240.png +0 -0
  24. admin/assets/images/jquery/ui-icons_cc0000_256x240.png +0 -0
  25. admin/assets/images/jquery/ui-icons_ffffff_256x240.png +0 -0
  26. admin/assets/images/lib/jquery.minicolors.png +0 -0
  27. admin/assets/images/pro-horizontal.svg +12 -0
  28. admin/assets/images/pro-vertical.svg +12 -0
  29. admin/assets/images/slider/image1.jpg +0 -0
  30. admin/assets/images/slider/image2.jpg +0 -0
  31. admin/assets/images/slider/image3.jpg +0 -0
  32. admin/assets/images/slider/image4.jpg +0 -0
  33. admin/assets/images/slider/image6.jpg +0 -0
  34. admin/assets/images/slider/image7.jpg +0 -0
  35. admin/assets/images/templates/basic-pretty.png +0 -0
  36. admin/assets/images/templates/basic.png +0 -0
  37. {images → admin/assets/images}/yop-poll-admin-menu-icon16.png +0 -0
  38. admin/assets/index.php +1 -0
  39. admin/assets/js/admin.min.js +23 -0
  40. admin/inc/ClassYOPPollWidget.php +96 -0
  41. admin/inc/ClassYopPollImporter4x.php +797 -0
  42. admin/inc/ClassYopPollImporter5x.php +2470 -0
  43. admin/inc/Helper.php +56 -0
  44. admin/inc/YopPollUpgrade.php +191 -0
  45. admin/inc/capabilities.php +89 -0
  46. admin/inc/dbschema.php +362 -0
  47. admin/inc/maintenance.php +134 -0
  48. admin/inc/view.php +23 -0
  49. admin/index.php +1 -0
  50. admin/models/bans.php +432 -0
  51. admin/models/elements.php +270 -0
  52. admin/models/logs.php +567 -0
  53. admin/models/polls.php +1964 -0
  54. admin/models/settings.php +22 -0
  55. admin/models/subelements.php +369 -0
  56. admin/models/templates.php +20 -0
  57. admin/models/votes.php +1256 -0
  58. admin/views/addban.php +96 -0
  59. admin/views/addnewpoll.php +326 -0
  60. admin/views/addnewwordpressvote.php +27 -0
  61. admin/views/after-upgrade.php +16 -0
  62. admin/views/before-upgrade.php +86 -0
  63. admin/views/custom-field.php +60 -0
  64. admin/views/editban.php +145 -0
  65. admin/views/editpoll.php +385 -0
  66. admin/views/error.php +9 -0
  67. admin/views/migrate-old-tables.php +52 -0
  68. admin/views/results.php +342 -0
  69. admin/views/support.php +42 -0
  70. admin/views/viewbanns.php +622 -0
  71. admin/views/viewlogs.php +624 -0
  72. admin/views/viewpolls.php +857 -0
  73. admin/views/viewpollvotes.php +225 -0
  74. admin/views/viewsettings.php +263 -0
  75. admin/views/yop-poll-edit-poll-access.php +152 -0
  76. admin/views/yop-poll-edit-poll-elements.php +846 -0
  77. admin/views/yop-poll-edit-poll-poll.php +452 -0
  78. admin/views/yop-poll-edit-poll-results.php +245 -0
  79. admin/views/yop-poll-edit-settings.php +17 -0
  80. admin/views/yop-poll-edit-style.php +658 -0
  81. admin/views/yop-poll-edit-template.php +90 -0
  82. admin/views/yop-poll-elements-definitions.php +571 -0
  83. admin/views/yop-poll-new-poll-access.php +81 -0
  84. admin/views/yop-poll-new-poll-elements.php +339 -0
  85. admin/views/yop-poll-new-poll-poll.php +299 -0
  86. admin/views/yop-poll-new-poll-results.php +128 -0
  87. admin/views/yop-poll-new-settings.php +17 -0
  88. admin/views/yop-poll-new-style.php +469 -0
  89. admin/views/yop-poll-new-template.php +90 -0
  90. app.php +51 -0
  91. captcha/AHGBold.ttf +0 -0
  92. captcha/LICENSE.txt +0 -25
  93. captcha/securimage_play.swf +0 -0
  94. css/Fontsaddict.css +0 -38
  95. css/Fontsaddict.eot +0 -0
  96. css/Fontsaddict.svg +0 -6
  97. css/Fontsaddict.ttf +0 -0
  98. css/Fontsaddict.woff +0 -0
  99. css/colorpicker.css +0 -227
  100. css/custombox.css +0 -872
  101. css/flexslider.css +0 -162
  102. css/fonts/Lato-Bla.ttf +0 -0
  103. css/fonts/Lato-BlaIta.ttf +0 -0
  104. css/fonts/Lato-Bol.ttf +0 -0
  105. css/fonts/Lato-BolIta.ttf +0 -0
  106. css/fonts/Lato-Hai.ttf +0 -0
  107. css/fonts/Lato-HaiIta.ttf +0 -0
  108. css/fonts/Lato-Lig.ttf +0 -0
  109. css/fonts/Lato-LigIta.ttf +0 -0
  110. css/fonts/Lato-Reg.ttf +0 -0
  111. css/fonts/Lato-RegIta.ttf +0 -0
  112. css/fonts/fontomas-webfont.eot +0 -0
  113. css/fonts/fontomas-webfont.svg +0 -31
  114. css/fonts/fontomas-webfont.ttf +0 -0
  115. css/fonts/fontomas-webfont.woff +0 -0
  116. css/jquery-ui.css +0 -561
  117. css/jquery.modalbox-basic.css +0 -156
  118. css/jquery.modalbox-skin-precious-white.css +0 -125
  119. css/polls/add-edit.css +0 -199
  120. css/polls/view-poll.css +0 -535
  121. css/reveal.css +0 -49
  122. css/timepicker.css +0 -7
  123. css/yop-poll-add-edit.css +0 -1
  124. css/yop-poll-admin.css +0 -275
  125. css/yop-poll-donate.css +0 -72
  126. css/yop-poll-optin2.css +0 -162
  127. css/yop-poll-public.css +0 -0
  128. css/yop-poll-slider.css +0 -606
  129. css/yop-poll-wizard.css +0 -312
  130. images/Untitled-7.jpg +0 -0
  131. images/ajax-loader.gif +0 -0
  132. images/blue2.jpg +0 -0
  133. images/blue_pro.jpg +0 -0
  134. images/blue_v3_pro.jpg +0 -0
  135. images/captcha-audio.gif +0 -0
  136. images/captcha_reload.png +0 -0
  137. images/check_radio_sheet.jpg +0 -0
  138. images/check_radio_sheet1.jpg +0 -0
  139. images/dark_pro.jpg +0 -0
  140. images/donate-button-bg.png +0 -0
  141. images/green_pro.jpg +0 -0
  142. images/green_pro_4.jpg +0 -0
  143. images/grey_pro.jpg +0 -0
  144. images/grey_pro_v1.jpg +0 -0
  145. images/grey_prov1.jpg +0 -0
  146. images/grey_prov2.jpg +0 -0
  147. images/image_five.jpg +0 -0
  148. images/image_four.jpg +0 -0
  149. images/image_one.jpg +0 -0
  150. images/image_seven.jpg +0 -0
  151. images/image_six.jpg +0 -0
  152. images/image_three.jpg +0 -0
  153. images/image_two.jpg +0 -0
  154. images/images2/image1.jpg +0 -0
  155. images/images2/image2.jpg +0 -0
  156. images/images2/image3.jpg +0 -0
  157. images/images2/image4.jpg +0 -0
  158. images/images2/image6.jpg +0 -0
  159. images/images2/image7.jpg +0 -0
  160. images/images2/image_five.jpg +0 -0
  161. images/images2/image_four.jpg +0 -0
  162. images/images2/image_one.jpg +0 -0
  163. images/images2/image_seven.jpg +0 -0
  164. images/images2/image_six.jpg +0 -0
  165. images/images2/image_three.jpg +0 -0
  166. images/images2/image_two.jpg +0 -0
  167. images/loading.gif +0 -0
  168. images/loading100x100.gif +0 -0
  169. images/loading100x1001.gif +0 -0
  170. images/loading36x36.gif +0 -0
  171. images/more-details-button.png +0 -0
  172. images/optin-no-title.png +0 -0
  173. images/optin-sidebar-no-title.png +0 -0
  174. images/orange_pro.jpg +0 -0
  175. images/polar-bear.jpg +0 -0
  176. images/red_pro.jpg +0 -0
  177. images/white_pro.jpg +0 -0
  178. images/yop-poll-admin-menu-icon32.png +0 -0
  179. images/yop-poll-admin-question-section-icon32.png +0 -0
  180. images/yop-poll-arrow.png +0 -0
  181. images/yop-poll-bullet.png +0 -0
  182. images/yop-poll-delete-icon.png +0 -0
  183. images/yop-poll-list-style.png +0 -0
  184. images/yop-poll-movable-icon.png +0 -0
  185. inc/WavFile.php +0 -1936
  186. inc/abstract_admin.php +0 -79
  187. inc/admin.php +0 -1436
  188. inc/bans_admin.php +0 -322
  189. inc/capabilities.php +0 -276
  190. inc/config.php +0 -1
  191. inc/db_schema.php +0 -4852
  192. inc/import_admin.php +0 -1020
  193. inc/logs_admin.php +0 -491
  194. inc/maintenance.php +0 -1661
  195. inc/mentenance.php +0 -105
  196. inc/options_admin.php +0 -1167
  197. inc/plugin-functions.php +0 -1065
  198. inc/plugin.php +0 -46
  199. inc/poll_admin.php +0 -2771
  200. inc/pro_admin.php +0 -310
  201. inc/public-admin.php +0 -389
  202. inc/public.php +0 -15
  203. inc/securimage.php +0 -1849
  204. inc/templates_admin.php +0 -1
  205. inc/theme-functions.php +0 -10
  206. inc/upgrade.php +0 -24
  207. inc/widget.php +0 -171
  208. inc/yop_poll_auto_update.php +0 -1
  209. inc/yop_poll_tool_tips.js +0 -21
  210. index.php +1 -0
  211. js/bxslider/bower.json +0 -25
  212. js/bxslider/images/bx_loader.gif +0 -0
  213. js/bxslider/images/controls.png +0 -0
  214. js/bxslider/jquery.bxslider.css +0 -205
  215. js/bxslider/jquery.bxslider.js +0 -1349
  216. js/bxslider/plugins/jquery.easing.1.3.js +0 -205
  217. js/bxslider/plugins/jquery.fitvids.js +0 -80
  218. js/color.picker.js +0 -2372
  219. js/custombox.js +0 -772
  220. js/images/128/bar-alpha.png +0 -0
  221. js/images/128/bar.png +0 -0
  222. js/images/128/map.png +0 -0
  223. js/images/bar-alpha.png +0 -0
  224. js/images/bar-opacity.png +0 -0
  225. js/images/bar-pointer.png +0 -0
  226. js/images/bar.png +0 -0
  227. js/images/map-opacity.png +0 -0
  228. js/images/map-pointer.png +0 -0
  229. js/images/map.png +0 -0
  230. js/images/preview-opacity.png +0 -0
  231. js/images/ui-colorpicker.png +0 -0
  232. js/jquery-textcomplete-master/.gitignore +0 -1
  233. js/jquery-textcomplete-master/.jshintrc +0 -7
  234. js/jquery-textcomplete-master/Gruntfile.js +0 -41
  235. js/jquery-textcomplete-master/README.md +0 -387
  236. js/jquery-textcomplete-master/bower.json +0 -8
  237. js/jquery-textcomplete-master/index.html +0 -225
  238. js/jquery-textcomplete-master/jquery.textcomplete.css +0 -33
  239. js/jquery-textcomplete-master/jquery.textcomplete.js +0 -665
  240. js/jquery-textcomplete-master/jquery.textcomplete.min.js +0 -4
  241. js/jquery-textcomplete-master/jquery.textcomplete.min.map +0 -1
  242. js/jquery-textcomplete-master/package.json +0 -10
  243. js/jquery-ui-timepicker-addon.js +0 -1779
  244. js/jquery.flexslider.js +0 -1157
  245. js/jquery.modalbox-1.5.0-min.js +0 -6
  246. js/jquery.popupWindow.js +0 -62
  247. js/jquery.reveal.js +0 -165
  248. js/jquery.textarea-input-support.js +0 -218
  249. js/legacy.js +0 -874
  250. js/polls/wizard-options.js +0 -571
  251. js/polls/yop-poll-add-edit.js +0 -912
  252. js/polls/yop-poll-results-votes.js +0 -385
  253. js/polls/yop-poll-wizard.js +0 -666
  254. js/super-cookie/superCookie-min.js +0 -8
  255. js/super-cookie/superCookie.js +0 -182
  256. js/super-cookie/swfobject/expressInstall.swf +0 -0
  257. js/super-cookie/swfobject/index.html +0 -28
  258. js/super-cookie/swfobject/index_dynamic.html +0 -17
  259. js/super-cookie/swfobject/src/expressInstall.as +0 -70
  260. js/super-cookie/swfobject/src/expressInstall.fla +0 -0
  261. js/super-cookie/swfobject/src/swfobject.js +0 -777
  262. js/super-cookie/swfobject/swfobject.js +0 -4
  263. js/super-cookie/swfobject/test.swf +0 -0
  264. js/swatches/jquery.ui.colorpicker-crayola.js +0 -124
  265. js/swatches/jquery.ui.colorpicker-pantone.js +0 -941
  266. js/swatches/jquery.ui.colorpicker-ral-classic.js +0 -217
  267. js/textinputs_jquery_src.js +0 -239
  268. js/yop-poll-admin-bans.js +0 -23
  269. js/yop-poll-admin-templates.js +0 -192
  270. js/yop-poll-admin.js +0 -287
  271. js/yop-poll-charts.js +0 -93
  272. js/yop-poll-edit-ban.js +0 -24
  273. js/yop-poll-facebook-vote.js +0 -38
  274. js/yop-poll-facebook.js +0 -20
  275. js/yop-poll-general-options.js +0 -341
  276. js/yop-poll-google.js +0 -12
  277. js/yop-poll-jquery.base64.min.js +0 -20
  278. js/yop-poll-json2.js +0 -7
  279. js/yop-poll-modal-functions.js +0 -38
  280. js/yop-poll-public.js +0 -912
  281. js/yop-poll-sidebar-optin-functions.js +0 -39
  282. js/yop-poll-slider-pro.js +0 -721
  283. js/yop-poll-slider.js +0 -728
  284. js/yop-poll-supercookie.js +0 -17
  285. js/yop_poll_tool_tips.js +0 -0
  286. languages/yop_poll-fr_FR.mo +0 -0
  287. languages/yop_poll-fr_FR.po +0 -2977
  288. languages/yop_poll-fr_FR.pot +0 -2977
  289. lib/Twig/Autoloader.php +0 -48
  290. lib/Twig/AutoloaderYOP.php +0 -48
  291. lib/Twig/Compiler.php +0 -270
  292. lib/Twig/CompilerInterface.php +0 -35
  293. lib/Twig/Environment.php +0 -1262
  294. lib/Twig/Error.php +0 -248
  295. lib/Twig/Error/Loader.php +0 -31
  296. lib/Twig/Error/Runtime.php +0 -20
  297. lib/Twig/Error/Syntax.php +0 -20
  298. lib/Twig/ExistsLoaderInterface.php +0 -28
  299. lib/Twig/ExpressionParser.php +0 -608
  300. lib/Twig/Extension.php +0 -92
  301. lib/Twig/Extension/Core.php +0 -1420
  302. lib/Twig/Extension/Debug.php +0 -71
  303. lib/Twig/Extension/Escaper.php +0 -107
  304. lib/Twig/Extension/Optimizer.php +0 -35
  305. lib/Twig/Extension/Sandbox.php +0 -112
  306. lib/Twig/Extension/Staging.php +0 -113
  307. lib/Twig/Extension/StringLoader.php +0 -64
  308. lib/Twig/Extension/YopPoll.php +0 -66
  309. lib/Twig/ExtensionInterface.php +0 -83
  310. lib/Twig/Filter.php +0 -81
  311. lib/Twig/Filter/Function.php +0 -37
  312. lib/Twig/Filter/Method.php +0 -39
  313. lib/Twig/Filter/Node.php +0 -39
  314. lib/Twig/FilterCallableInterface.php +0 -23
  315. lib/Twig/FilterInterface.php +0 -42
  316. lib/Twig/Function.php +0 -71
  317. lib/Twig/Function/Function.php +0 -38
  318. lib/Twig/Function/Method.php +0 -40
  319. lib/Twig/Function/Node.php +0 -39
  320. lib/Twig/FunctionCallableInterface.php +0 -23
  321. lib/Twig/FunctionInterface.php +0 -39
  322. lib/Twig/Lexer.php +0 -408
  323. lib/Twig/LexerInterface.php +0 -31
  324. lib/Twig/Loader/Array.php +0 -95
  325. lib/Twig/Loader/Chain.php +0 -138
  326. lib/Twig/Loader/Filesystem.php +0 -226
  327. lib/Twig/Loader/String.php +0 -59
  328. lib/Twig/LoaderInterface.php +0 -52
  329. lib/Twig/Markup.php +0 -37
  330. lib/Twig/Node.php +0 -226
  331. lib/Twig/Node/AutoEscape.php +0 -39
  332. lib/Twig/Node/Block.php +0 -44
  333. lib/Twig/Node/BlockReference.php +0 -37
  334. lib/Twig/Node/Body.php +0 -19
  335. lib/Twig/Node/Do.php +0 -38
  336. lib/Twig/Node/Embed.php +0 -38
  337. lib/Twig/Node/Expression.php +0 -20
  338. lib/Twig/Node/Expression/Array.php +0 -86
  339. lib/Twig/Node/Expression/AssignName.php +0 -28
  340. lib/Twig/Node/Expression/Binary.php +0 -40
  341. lib/Twig/Node/Expression/Binary/Add.php +0 -18
  342. lib/Twig/Node/Expression/Binary/And.php +0 -18
  343. lib/Twig/Node/Expression/Binary/BitwiseAnd.php +0 -18
  344. lib/Twig/Node/Expression/Binary/BitwiseOr.php +0 -18
  345. lib/Twig/Node/Expression/Binary/BitwiseXor.php +0 -18
  346. lib/Twig/Node/Expression/Binary/Concat.php +0 -18
  347. lib/Twig/Node/Expression/Binary/Div.php +0 -18
  348. lib/Twig/Node/Expression/Binary/EndsWith.php +0 -30
  349. lib/Twig/Node/Expression/Binary/Equal.php +0 -17
  350. lib/Twig/Node/Expression/Binary/FloorDiv.php +0 -29
  351. lib/Twig/Node/Expression/Binary/Greater.php +0 -17
  352. lib/Twig/Node/Expression/Binary/GreaterEqual.php +0 -17
  353. lib/Twig/Node/Expression/Binary/In.php +0 -33
  354. lib/Twig/Node/Expression/Binary/Less.php +0 -17
  355. lib/Twig/Node/Expression/Binary/LessEqual.php +0 -17
  356. lib/Twig/Node/Expression/Binary/Matches.php +0 -28
  357. lib/Twig/Node/Expression/Binary/Mod.php +0 -18
  358. lib/Twig/Node/Expression/Binary/Mul.php +0 -18
  359. lib/Twig/Node/Expression/Binary/NotEqual.php +0 -17
  360. lib/Twig/Node/Expression/Binary/NotIn.php +0 -33
  361. lib/Twig/Node/Expression/Binary/Or.php +0 -18
  362. lib/Twig/Node/Expression/Binary/Power.php +0 -33
  363. lib/Twig/Node/Expression/Binary/Range.php +0 -33
  364. lib/Twig/Node/Expression/Binary/StartsWith.php +0 -28
  365. lib/Twig/Node/Expression/Binary/Sub.php +0 -18
  366. lib/Twig/Node/Expression/BlockReference.php +0 -51
  367. lib/Twig/Node/Expression/Call.php +0 -178
  368. lib/Twig/Node/Expression/Conditional.php +0 -31
  369. lib/Twig/Node/Expression/Constant.php +0 -23
  370. lib/Twig/Node/Expression/ExtensionReference.php +0 -33
  371. lib/Twig/Node/Expression/Filter.php +0 -36
  372. lib/Twig/Node/Expression/Filter/Default.php +0 -43
  373. lib/Twig/Node/Expression/Function.php +0 -35
  374. lib/Twig/Node/Expression/GetAttr.php +0 -53
  375. lib/Twig/Node/Expression/MethodCall.php +0 -41
  376. lib/Twig/Node/Expression/Name.php +0 -88
  377. lib/Twig/Node/Expression/Parent.php +0 -47
  378. lib/Twig/Node/Expression/TempName.php +0 -26
  379. lib/Twig/Node/Expression/Test.php +0 -32
  380. lib/Twig/Node/Expression/Test/Constant.php +0 -46
  381. lib/Twig/Node/Expression/Test/Defined.php +0 -54
  382. lib/Twig/Node/Expression/Test/Divisibleby.php +0 -33
  383. lib/Twig/Node/Expression/Test/Even.php +0 -32
  384. lib/Twig/Node/Expression/Test/Null.php +0 -31
  385. lib/Twig/Node/Expression/Test/Odd.php +0 -32
  386. lib/Twig/Node/Expression/Test/Sameas.php +0 -29
  387. lib/Twig/Node/Expression/Unary.php +0 -30
  388. lib/Twig/Node/Expression/Unary/Neg.php +0 -18
  389. lib/Twig/Node/Expression/Unary/Not.php +0 -18
  390. lib/Twig/Node/Expression/Unary/Pos.php +0 -18
  391. lib/Twig/Node/Flush.php +0 -36
  392. lib/Twig/Node/For.php +0 -112
  393. lib/Twig/Node/ForLoop.php +0 -55
  394. lib/Twig/Node/If.php +0 -66
  395. lib/Twig/Node/Import.php +0 -50
  396. lib/Twig/Node/Include.php +0 -99
  397. lib/Twig/Node/Macro.php +0 -96
  398. lib/Twig/Node/Module.php +0 -371
  399. lib/Twig/Node/Print.php +0 -39
  400. lib/Twig/Node/Sandbox.php +0 -47
  401. lib/Twig/Node/SandboxedModule.php +0 -60
  402. lib/Twig/Node/SandboxedPrint.php +0 -59
  403. lib/Twig/Node/Set.php +0 -101
  404. lib/Twig/Node/SetTemp.php +0 -35
  405. lib/Twig/Node/Spaceless.php +0 -40
  406. lib/Twig/Node/Text.php +0 -39
  407. lib/Twig/NodeInterface.php +0 -30
  408. lib/Twig/NodeOutputInterface.php +0 -19
  409. lib/Twig/NodeTraverser.php +0 -88
  410. lib/Twig/NodeVisitor/Escaper.php +0 -167
  411. lib/Twig/NodeVisitor/Optimizer.php +0 -246
  412. lib/Twig/NodeVisitor/SafeAnalysis.php +0 -139
  413. lib/Twig/NodeVisitor/Sandbox.php +0 -92
  414. lib/Twig/NodeVisitorInterface.php +0 -47
  415. lib/Twig/Parser.php +0 -390
  416. lib/Twig/ParserInterface.php +0 -30
  417. lib/Twig/Sandbox/SecurityError.php +0 -19
  418. lib/Twig/Sandbox/SecurityPolicy.php +0 -119
  419. lib/Twig/Sandbox/SecurityPolicyInterface.php +0 -24
  420. lib/Twig/SimpleFilter.php +0 -94
  421. lib/Twig/SimpleFunction.php +0 -84
  422. lib/Twig/SimpleTest.php +0 -46
  423. lib/Twig/Template.php +0 -467
  424. lib/Twig/TemplateInterface.php +0 -47
  425. lib/Twig/Test.php +0 -34
  426. lib/Twig/Test/Function.php +0 -35
  427. lib/Twig/Test/IntegrationTestCase.php +0 -154
  428. lib/Twig/Test/Method.php +0 -37
  429. lib/Twig/Test/Node.php +0 -37
  430. lib/Twig/Test/NodeTestCase.php +0 -58
  431. lib/Twig/TestCallableInterface.php +0 -21
  432. lib/Twig/TestInterface.php +0 -26
  433. lib/Twig/Token.php +0 -216
  434. lib/Twig/TokenParser.php +0 -33
  435. lib/Twig/TokenParser/AutoEscape.php +0 -89
  436. lib/Twig/TokenParser/Block.php +0 -83
  437. lib/Twig/TokenParser/Do.php +0 -42
  438. lib/Twig/TokenParser/Embed.php +0 -66
  439. lib/Twig/TokenParser/Extends.php +0 -52
  440. lib/Twig/TokenParser/Filter.php +0 -61
  441. lib/Twig/TokenParser/Flush.php +0 -42
  442. lib/Twig/TokenParser/For.php +0 -136
  443. lib/Twig/TokenParser/From.php +0 -74
  444. lib/Twig/TokenParser/If.php +0 -94
  445. lib/Twig/TokenParser/Import.php +0 -49
  446. lib/Twig/TokenParser/Include.php +0 -80
  447. lib/Twig/TokenParser/Macro.php +0 -68
  448. lib/Twig/TokenParser/Sandbox.php +0 -68
  449. lib/Twig/TokenParser/Set.php +0 -84
  450. lib/Twig/TokenParser/Spaceless.php +0 -59
  451. lib/Twig/TokenParser/Use.php +0 -82
  452. lib/Twig/TokenParserBroker.php +0 -136
  453. lib/Twig/TokenParserBrokerInterface.php +0 -45
  454. lib/Twig/TokenParserInterface.php +0 -43
  455. lib/Twig/TokenStream.php +0 -144
  456. modal/css/jquery.modalbox-basic.css +0 -156
  457. modal/css/jquery.modalbox-skin-precious-white.css +0 -125
  458. modal/img/ajax-loader.gif +0 -0
  459. modal/img/skins/precious_white/bg_shadows_left.png +0 -0
  460. modal/img/skins/precious_white/bg_shadows_right.png +0 -0
  461. modal/img/skins/precious_white/bg_shadows_sprite.png +0 -0
  462. modal/img/skins/precious_white/closebutton_13x13.png +0 -0
  463. modal/js/jquery.modalbox-1.5.0-min.js +0 -6
  464. models/abstract_model.php +0 -2036
  465. models/answer_model.php +0 -542
  466. models/custom_field_model.php +0 -272
  467. models/poll_model.php +0 -1545
  468. models/question_model.php +0 -693
  469. models/yop_poll_model.php +0 -526
  470. public/assets/captcha/audios.json +82 -0
  471. public/assets/captcha/audios/12times2.mp3 +0 -0
  472. public/assets/captcha/audios/12times2.ogg +0 -0
  473. public/assets/captcha/audios/2times10.mp3 +0 -0
  474. public/assets/captcha/audios/2times10.ogg +0 -0
  475. public/assets/captcha/audios/4plus1.mp3 +0 -0
  476. public/assets/captcha/audios/4plus1.ogg +0 -0
  477. public/assets/captcha/audios/4plus3.mp3 +0 -0
  478. public/assets/captcha/audios/4plus3.ogg +0 -0
  479. public/assets/captcha/audios/5plus1.mp3 +0 -0
  480. public/assets/captcha/audios/5plus1.ogg +0 -0
  481. public/assets/captcha/audios/5times2.mp3 +0 -0
  482. public/assets/captcha/audios/5times2.ogg +0 -0
  483. public/assets/captcha/audios/6plus6.mp3 +0 -0
  484. public/assets/captcha/audios/6plus6.ogg +0 -0
  485. public/assets/captcha/audios/99plus1.mp3 +0 -0
  486. public/assets/captcha/audios/99plus1.ogg +0 -0
  487. public/assets/captcha/audios/add3to1.mp3 +0 -0
  488. public/assets/captcha/audios/add3to1.ogg +0 -0
  489. public/assets/captcha/audios/addblueandyellow.mp3 +0 -0
  490. public/assets/captcha/audios/addblueandyellow.ogg +0 -0
  491. public/assets/captcha/audios/after2.mp3 +0 -0
  492. public/assets/captcha/audios/after2.ogg +0 -0
  493. public/assets/captcha/audios/capitaloffrance.mp3 +0 -0
  494. public/assets/captcha/audios/capitaloffrance.ogg +0 -0
  495. public/assets/captcha/audios/divide4by2.mp3 +0 -0
  496. public/assets/captcha/audios/divide4by2.ogg +0 -0
  497. public/assets/captcha/audios/firstletteralphabet.mp3 +0 -0
  498. public/assets/captcha/audios/firstletteralphabet.ogg +0 -0
  499. public/assets/captcha/audios/milkcolor.mp3 +0 -0
  500. public/assets/captcha/audios/milkcolor.ogg +0 -0
  501. public/assets/captcha/audios/skycolor.mp3 +0 -0
  502. public/assets/captcha/audios/skycolor.ogg +0 -0
  503. public/assets/captcha/audios/skynight.mp3 +0 -0
  504. public/assets/captcha/audios/skynight.ogg +0 -0
  505. public/assets/captcha/audios/sunastar.mp3 +0 -0
  506. public/assets/captcha/audios/sunastar.ogg +0 -0
  507. public/assets/captcha/audios/thirdmonth.mp3 +0 -0
  508. public/assets/captcha/audios/thirdmonth.ogg +0 -0
  509. public/assets/captcha/audios/yourobot.mp3 +0 -0
  510. public/assets/captcha/audios/yourobot.ogg +0 -0
  511. public/assets/captcha/images.json +150 -0
  512. public/assets/captcha/images/airplane.png +0 -0
  513. public/assets/captcha/images/airplane@2x.png +0 -0
  514. public/assets/captcha/images/balloons.png +0 -0
  515. public/assets/captcha/images/balloons@2x.png +0 -0
  516. public/assets/captcha/images/camera.png +0 -0
  517. public/assets/captcha/images/camera@2x.png +0 -0
  518. public/assets/captcha/images/car.png +0 -0
  519. public/assets/captcha/images/car@2x.png +0 -0
  520. public/assets/captcha/images/cat.png +0 -0
  521. public/assets/captcha/images/cat@2x.png +0 -0
  522. public/assets/captcha/images/chair.png +0 -0
  523. public/assets/captcha/images/chair@2x.png +0 -0
  524. public/assets/captcha/images/clip.png +0 -0
  525. public/assets/captcha/images/clip@2x.png +0 -0
  526. public/assets/captcha/images/clock.png +0 -0
  527. public/assets/captcha/images/clock@2x.png +0 -0
  528. public/assets/captcha/images/cloud.png +0 -0
  529. public/assets/captcha/images/cloud@2x.png +0 -0
  530. public/assets/captcha/images/computer.png +0 -0
  531. public/assets/captcha/images/computer@2x.png +0 -0
  532. public/assets/captcha/images/envelope.png +0 -0
  533. public/assets/captcha/images/envelope@2x.png +0 -0
  534. public/assets/captcha/images/eye.png +0 -0
  535. public/assets/captcha/images/eye@2x.png +0 -0
  536. public/assets/captcha/images/flag.png +0 -0
  537. public/assets/captcha/images/flag@2x.png +0 -0
  538. public/assets/captcha/images/folder.png +0 -0
  539. public/assets/captcha/images/folder@2x.png +0 -0
  540. public/assets/captcha/images/foot.png +0 -0
  541. public/assets/captcha/images/foot@2x.png +0 -0
  542. public/assets/captcha/images/graph.png +0 -0
  543. public/assets/captcha/images/graph@2x.png +0 -0
  544. public/assets/captcha/images/house.png +0 -0
  545. public/assets/captcha/images/house@2x.png +0 -0
  546. public/assets/captcha/images/key.png +0 -0
  547. public/assets/captcha/images/key@2x.png +0 -0
  548. public/assets/captcha/images/leaf.png +0 -0
  549. public/assets/captcha/images/leaf@2x.png +0 -0
  550. public/assets/captcha/images/light-bulb.png +0 -0
  551. public/assets/captcha/images/light-bulb@2x.png +0 -0
  552. public/assets/captcha/images/lock.png +0 -0
  553. public/assets/captcha/images/lock@2x.png +0 -0
  554. public/assets/captcha/images/magnifying-glass.png +0 -0
  555. public/assets/captcha/images/magnifying-glass@2x.png +0 -0
  556. public/assets/captcha/images/man.png +0 -0
  557. public/assets/captcha/images/man@2x.png +0 -0
  558. public/assets/captcha/images/music-note.png +0 -0
  559. public/assets/captcha/images/music-note@2x.png +0 -0
  560. public/assets/captcha/images/pants.png +0 -0
  561. public/assets/captcha/images/pants@2x.png +0 -0
  562. public/assets/captcha/images/pencil.png +0 -0
  563. public/assets/captcha/images/pencil@2x.png +0 -0
  564. public/assets/captcha/images/printer.png +0 -0
  565. public/assets/captcha/images/printer@2x.png +0 -0
  566. public/assets/captcha/images/robot.png +0 -0
  567. public/assets/captcha/images/robot@2x.png +0 -0
  568. public/assets/captcha/images/scissors.png +0 -0
  569. public/assets/captcha/images/scissors@2x.png +0 -0
  570. public/assets/captcha/images/sunglasses.png +0 -0
  571. public/assets/captcha/images/sunglasses@2x.png +0 -0
  572. public/assets/captcha/images/t-shirt.png +0 -0
  573. public/assets/captcha/images/t-shirt@2x.png +0 -0
  574. public/assets/captcha/images/tag.png +0 -0
  575. public/assets/captcha/images/tag@2x.png +0 -0
  576. public/assets/captcha/images/tree.png +0 -0
  577. public/assets/captcha/images/tree@2x.png +0 -0
  578. public/assets/captcha/images/truck.png +0 -0
  579. public/assets/captcha/images/truck@2x.png +0 -0
  580. public/assets/captcha/images/umbrella.png +0 -0
  581. public/assets/captcha/images/umbrella@2x.png +0 -0
  582. public/assets/captcha/images/woman.png +0 -0
  583. public/assets/captcha/images/woman@2x.png +0 -0
  584. public/assets/captcha/images/world.png +0 -0
  585. public/assets/captcha/images/world@2x.png +0 -0
  586. public/assets/css/yop-poll-public.css +13 -0
  587. public/assets/fonts/glyphicons-halflings-regular.eot +0 -0
  588. public/assets/fonts/glyphicons-halflings-regular.svg +288 -0
  589. public/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
  590. public/assets/fonts/glyphicons-halflings-regular.woff +0 -0
  591. public/assets/fonts/glyphicons-halflings-regular.woff2 +0 -0
  592. public/assets/img/accessibility.png +0 -0
  593. public/assets/img/accessibility@2x.png +0 -0
  594. public/assets/img/refresh.png +0 -0
  595. public/assets/img/refresh@2x.png +0 -0
  596. public/assets/img/skins/flat/aero.png +0 -0
  597. public/assets/img/skins/flat/aero@2x.png +0 -0
  598. public/assets/img/skins/flat/blue.png +0 -0
  599. public/assets/img/skins/flat/blue@2x.png +0 -0
  600. public/assets/img/skins/flat/flat.png +0 -0
  601. public/assets/img/skins/flat/flat@2x.png +0 -0
  602. public/assets/img/skins/flat/green.png +0 -0
  603. public/assets/img/skins/flat/green@2x.png +0 -0
  604. public/assets/img/skins/flat/grey.png +0 -0
  605. public/assets/img/skins/flat/grey@2x.png +0 -0
  606. public/assets/img/skins/flat/orange.png +0 -0
  607. public/assets/img/skins/flat/orange@2x.png +0 -0
  608. public/assets/img/skins/flat/pink.png +0 -0
  609. public/assets/img/skins/flat/pink@2x.png +0 -0
  610. public/assets/img/skins/flat/purple.png +0 -0
  611. public/assets/img/skins/flat/purple@2x.png +0 -0
  612. public/assets/img/skins/flat/red.png +0 -0
  613. public/assets/img/skins/flat/red@2x.png +0 -0
  614. public/assets/img/skins/flat/yellow.png +0 -0
  615. public/assets/img/skins/flat/yellow@2x.png +0 -0
  616. public/assets/img/skins/minimal/aero.png +0 -0
  617. public/assets/img/skins/minimal/aero@2x.png +0 -0
  618. public/assets/img/skins/minimal/blue.png +0 -0
  619. public/assets/img/skins/minimal/blue@2x.png +0 -0
  620. public/assets/img/skins/minimal/green.png +0 -0
  621. public/assets/img/skins/minimal/green@2x.png +0 -0
  622. public/assets/img/skins/minimal/grey.png +0 -0
  623. public/assets/img/skins/minimal/grey@2x.png +0 -0
  624. public/assets/img/skins/minimal/minimal.png +0 -0
  625. public/assets/img/skins/minimal/minimal@2x.png +0 -0
  626. public/assets/img/skins/minimal/orange.png +0 -0
  627. public/assets/img/skins/minimal/orange@2x.png +0 -0
  628. public/assets/img/skins/minimal/pink.png +0 -0
  629. public/assets/img/skins/minimal/pink@2x.png +0 -0
  630. public/assets/img/skins/minimal/purple.png +0 -0
  631. public/assets/img/skins/minimal/purple@2x.png +0 -0
  632. public/assets/img/skins/minimal/red.png +0 -0
  633. public/assets/img/skins/minimal/red@2x.png +0 -0
  634. public/assets/img/skins/minimal/yellow.png +0 -0
  635. public/assets/img/skins/minimal/yellow@2x.png +0 -0
  636. public/assets/img/skins/square/aero.png +0 -0
  637. public/assets/img/skins/square/aero@2x.png +0 -0
  638. public/assets/img/skins/square/blue.png +0 -0
  639. public/assets/img/skins/square/blue@2x.png +0 -0
  640. public/assets/img/skins/square/green.png +0 -0
  641. public/assets/img/skins/square/green@2x.png +0 -0
  642. public/assets/img/skins/square/grey.png +0 -0
  643. public/assets/img/skins/square/grey@2x.png +0 -0
  644. public/assets/img/skins/square/orange.png +0 -0
  645. public/assets/img/skins/square/orange@2x.png +0 -0
  646. public/assets/img/skins/square/pink.png +0 -0
  647. public/assets/img/skins/square/pink@2x.png +0 -0
  648. public/assets/img/skins/square/purple.png +0 -0
  649. public/assets/img/skins/square/purple@2x.png +0 -0
  650. public/assets/img/skins/square/red.png +0 -0
  651. public/assets/img/skins/square/red@2x.png +0 -0
  652. public/assets/img/skins/square/square.png +0 -0
  653. public/assets/img/skins/square/square@2x.png +0 -0
  654. public/assets/img/skins/square/yellow.png +0 -0
  655. public/assets/img/skins/square/yellow@2x.png +0 -0
  656. public/assets/index.php +1 -0
  657. public/assets/js/yop-poll-public.min.js +8 -0
  658. public/inc/Captcha.php +263 -0
  659. public/inc/Session.php +27 -0
  660. public/inc/basic.php +1216 -0
  661. public/index.php +1 -0
  662. public/public.php +149 -0
  663. readme.txt +344 -371
  664. templates/bans_bans.html +0 -544
  665. templates/form_macros.html +0 -27
  666. templates/imports_imports.html +0 -148
  667. templates/logs_logs.html +0 -311
  668. templates/options_general.html +0 -479
  669. templates/options_poll_options.html +0 -368
  670. templates/polls_add_edit-bk.html +0 -1
  671. templates/polls_add_edit.html +0 -484
  672. templates/polls_add_edit_advanced.html +0 -90
  673. templates/polls_add_edit_beginner.html +0 -188
  674. templates/polls_add_edit_options.html +0 -308
  675. templates/polls_add_edit_questions.html +0 -22
  676. templates/polls_add_edit_results_options.html +0 -121
  677. templates/polls_add_edit_template.html +0 -378
  678. templates/polls_answer_media_template.html +0 -1
  679. templates/polls_answer_template.html +0 -1
  680. templates/polls_base.html +0 -91
  681. templates/polls_pop_up_ban.html +0 -77
  682. templates/polls_question_template.html +0 -274
  683. templates/polls_question_template_media.html +0 -260
  684. templates/polls_results.html +0 -136
  685. templates/polls_results_print.html +0 -566
  686. templates/polls_results_votes.html +0 -1114
  687. templates/polls_view.html +0 -316
  688. templates/pro_after_upgrade.html +0 -13
  689. templates/pro_help.html +0 -15
  690. templates/pro_pre_upgrade.html +0 -84
  691. templates/templates_templates.html +0 -1
  692. templates/templates_templates_add_edit.html +0 -228
  693. tinymce/langs/en.js +0 -3
  694. tinymce/yop-poll-admin-menu-icon16.png +0 -0
  695. tinymce/yop-poll-editor-functions.js +0 -60
  696. tinymce/yop-poll-editor.js +0 -36
  697. twig-gettext-extractor/twig-gettext-extractor.php +0 -49
  698. uninstall.php +9 -0
  699. upgrade.php +31 -53
  700. yop_poll.php +62 -195
admin/admin.php ADDED
@@ -0,0 +1,1231 @@
1
+ <?php
2
+ class YOP_Poll_Admin {
3
+ private $templates;
4
+ private static $date_format, $time_format, $old_version = null;
5
+ public function __construct() {
6
+ self::$date_format = get_option( 'date_format' );
7
+ self::$time_format = get_option( 'time_format' );
8
+ self::$old_version = get_option( 'yop_poll_old_version' );
9
+ if ( true === is_admin() ) {
10
+ add_filter( 'admin_title', array( &$this, 'change_page_title' ) );
11
+ add_action( 'admin_menu', array( &$this, 'build_admin_menu' ) );
12
+ add_action( 'plugins_loaded', array( &$this, 'verify_update' ) );
13
+ add_action( 'admin_enqueue_scripts', array( &$this, 'load_dependencies' ) );
14
+ add_action( 'wp_ajax_create_yop_poll', array( &$this, 'create_poll' ) );
15
+ add_action( 'wp_ajax_update_yop_poll', array( &$this, 'update_poll' ) );
16
+ add_action( 'wp_ajax_delete_single_yop_poll', array( &$this, 'delete_single_poll' ) );
17
+ add_action( 'wp_ajax_delete_bulk_yop_poll', array( &$this, 'delete_bulk_poll' ) );
18
+ add_action( 'wp_ajax_clone_single_yop_poll', array( &$this, 'clone_single_poll' ) );
19
+ add_action( 'wp_ajax_clone_bulk_yop_poll', array( &$this, 'clone_bulk_poll' ) );
20
+ add_action( 'wp_ajax_create_yop_poll_ban', array( &$this, 'create_ban' ) );
21
+ add_action( 'wp_ajax_delete_yop_poll_ban', array( &$this, 'delete_single_ban' ) );
22
+ add_action( 'wp_ajax_update_yop_poll_ban', array( &$this, 'update_ban' ) );
23
+ add_action( 'wp_ajax_delete_bulk_yop_poll_ban', array( &$this, 'delete_bulk_ban' ) );
24
+ add_action( 'wp_ajax_delete_yop_poll_log', array( &$this, 'delete_single_log' ) );
25
+ add_action( 'wp_ajax_get_yop_poll_log_details', array( &$this, 'get_log_details' ) );
26
+ add_action( 'wp_ajax_delete_bulk_yop_poll_log', array( &$this, 'delete_bulk_log' ) );
27
+ add_action( 'wp_ajax_yop_poll_is_user_logged_in', array( &$this, 'is_user_logged_in' ) );
28
+ add_action( 'wp_ajax_nopriv_yop_poll_is_user_logged_in', array( &$this, 'is_user_logged_in' ) );
29
+ add_action( 'wp_ajax_yop_poll_record_vote', array( &$this, 'record_vote' ) );
30
+ add_action( 'wp_ajax_nopriv_yop_poll_record_vote', array( &$this, 'record_vote' ) );
31
+ add_action( 'wp_ajax_yop_poll_record_wordpress_vote', array( &$this, 'record_wordpress_vote' ) );
32
+ add_action( 'wp_ajax_get_yop_poll_votes_customs', array( &$this, 'get_yop_poll_votes_customs' ) );
33
+ add_action( 'wp_ajax_yop-poll-get-vote-details', array( &$this, 'get_vote_details' ) );
34
+ add_action( 'wp_ajax_nopriv_yop_poll_record_wordpress_vote', array( &$this, 'record_wordpress_vote' ) );
35
+ add_action( 'wp_ajax_yop_poll_save_settings', array( &$this, 'save_settings' ) );
36
+ if ( self::$old_version ) {
37
+ if ( false !== strpos( self::$old_version, '4.' ) ) {
38
+ add_action( 'wp_ajax_yop_ajax_migrate', array( 'ClassYopPollImporter4x', 'yop_ajax_import' ) );
39
+ } elseif ( false !== strpos( self::$old_version, '5.' ) ) {
40
+ add_action( 'wp_ajax_yop_ajax_migrate', array( 'ClassYopPollImporter5x', 'yop_ajax_import' ) );
41
+ }
42
+ }
43
+ }
44
+ Yop_Poll_DbSchema::initialize_tables_names();
45
+ }
46
+ public function verify_update() {
47
+ $installed_version = get_option( 'yop_poll_version' );
48
+ if ( $installed_version ) {
49
+ if ( true === version_compare( $installed_version, '6.0.0', '<' ) ) {
50
+ $maintenance = new YOP_POLL_Maintenance();
51
+ $maintenance->activate();
52
+ }
53
+ }
54
+ }
55
+ public function is_user_logged_in() {
56
+ if ( true === is_user_logged_in() ) {
57
+ wp_send_json_success();
58
+ } else {
59
+ wp_send_json_error();
60
+ }
61
+ die();
62
+ }
63
+ public function build_admin_menu() {
64
+ if( function_exists( 'add_menu_page' ) ) {
65
+ $page = add_menu_page(
66
+ __( 'Yop Poll', 'yop-poll' ),
67
+ __( 'Yop Poll', 'yop-poll' ),
68
+ 'yop_poll_results_own',
69
+ 'yop-polls',
70
+ array(
71
+ $this,
72
+ 'manage_polls'
73
+ ),
74
+ YOP_POLL_URL . "admin/assets/images/yop-poll-admin-menu-icon16.png",
75
+ '26.6'
76
+ );
77
+ if ( function_exists( 'add_submenu_page' ) ) {
78
+ $subpage = add_submenu_page(
79
+ 'yop-polls',
80
+ __( 'All Polls', 'yop-poll' ),
81
+ __( 'All Polls', 'yop-poll' ),
82
+ 'yop_poll_results_own',
83
+ 'yop-polls',
84
+ array(
85
+ $this,
86
+ 'manage_polls'
87
+ )
88
+ );
89
+ if ( $subpage ) {
90
+ $votesObj = YOP_Poll_Votes::get_instance();
91
+ add_action( 'load-' . $subpage, array( $votesObj, 'send_votes_to_download' ) );
92
+ }
93
+ $subpage = add_submenu_page(
94
+ 'yop-polls',
95
+ __( 'Add New', 'yop-poll' ),
96
+ __( 'Add New', 'yop-poll' ),
97
+ 'yop_poll_add',
98
+ 'yop-poll-add-poll',
99
+ array(
100
+ $this,
101
+ 'add_new_poll'
102
+ )
103
+ );
104
+ $subpage = add_submenu_page(
105
+ 'yop-polls',
106
+ __( 'Bans', 'yop-poll' ),
107
+ __( 'Bans', 'yop-poll' ),
108
+ 'yop_poll_results_own',
109
+ 'yop-poll-bans',
110
+ array(
111
+ $this,
112
+ 'manage_bans'
113
+ )
114
+ );
115
+ $subpage_logs = add_submenu_page(
116
+ 'yop-polls',
117
+ __( 'Logs', 'yop-poll' ),
118
+ __( 'Logs', 'yop-poll' ),
119
+ 'yop_poll_results_own',
120
+ 'yop-poll-logs',
121
+ array(
122
+ $this,
123
+ 'manage_logs'
124
+ )
125
+ );
126
+ if ( $subpage_logs ) {
127
+ $logsObj = YOP_Poll_Logs::get_instance();
128
+ add_action( 'load-' . $subpage_logs, array( $logsObj, 'send_logs_to_download' ) );
129
+ }
130
+ $subpage = add_submenu_page(
131
+ 'yop-polls',
132
+ __( 'Settings', 'yop-poll' ),
133
+ __( 'Settings', 'yop-poll' ),
134
+ 'yop_poll_results_own',
135
+ 'yop-poll-settings',
136
+ array(
137
+ $this,
138
+ 'manage_settings'
139
+ )
140
+ );
141
+ if ( self::$old_version ) {
142
+ $subpage = add_submenu_page(
143
+ 'yop-polls',
144
+ __( 'Migrate old records', 'yop-poll' ),
145
+ __( 'Migrate old records', 'yop-poll' ),
146
+ 'yop_poll_results_own',
147
+ 'yop-poll-migrate',
148
+ array(
149
+ $this,
150
+ 'migrate_old_tables'
151
+ )
152
+ );
153
+ }
154
+ $proObj = YopPollUpgrade::get_instance();
155
+ $subpage_upgrade = add_submenu_page(
156
+ 'yop-polls',
157
+ __( "Upgrade to Pro", 'yop-poll' ),
158
+ __( "Upgrade to Pro", 'yop-poll' ),
159
+ 'yop_poll_results_own',
160
+ 'yop-poll-upgrade-pro', array(
161
+ &$proObj,
162
+ "manage_upgrade_pages"
163
+ ) );
164
+ }
165
+ }
166
+ }
167
+ public function load_dependencies() {
168
+ $this->load_styles();
169
+ $this->load_scripts();
170
+ }
171
+ public function load_scripts() {
172
+ //include jquery by default
173
+ wp_enqueue_script( 'jquery' );
174
+ wp_enqueue_script( 'tiny_mce' );
175
+ wp_enqueue_script( 'jquery-ui-core', array( 'jquery' ) );
176
+ wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) );
177
+ wp_enqueue_script( 'jquery-ui-sortable', array( 'jquery-ui-core' ) );
178
+ wp_enqueue_script( 'jquery-ui-draggable', array( 'jquery-ui-core' ) );
179
+ wp_enqueue_script( 'jquery-ui-droppable', array( 'jquery-ui-core' ) );
180
+ wp_enqueue_script( 'yop', YOP_POLL_URL . 'admin/assets/js/admin.min.js', array( 'jquery',
181
+ 'jquery-ui-sortable',
182
+ 'jquery-ui-dialog',
183
+ 'jquery-ui-datepicker' )
184
+ );
185
+ //wp_localize_script( 'yop', 'yop_app_url', YOP_POLL_URL );
186
+ wp_localize_script( 'yop', 'objectL10n', array(
187
+ 'yopPollParams' => array(
188
+ 'appUrl' => YOP_POLL_URL,
189
+ 'dateFormat' => self::$date_format,
190
+ 'timeFormat' => self::$time_format,
191
+ 'timeNow' => time(),
192
+ 'votingEnded' => esc_html__( 'This poll is no longer accepting votes', 'yop-poll' ),
193
+ 'votingNotStarted' => esc_html__( 'This poll is not accepting votes yet', 'yop-poll' ),
194
+ 'newCustomFieldText' => esc_html__( 'New Custom Field', 'yop-poll' ),
195
+ 'deleteTitle' => esc_html__( 'Warning', 'yop-poll' ),
196
+ 'deletePollMessage' => esc_html__( 'Are you sure you want to delete this poll?', 'yop-poll' ),
197
+ 'deleteBulkPollsSingleMessage' => esc_html__( 'Are you sure you want to delete this poll?', 'yop-poll' ),
198
+ 'deleteBulkPollsMultiMessage' => esc_html__( 'Are you sure you want to delete these polls?', 'yop-poll' ),
199
+ 'clonePollMessage' => esc_html__( 'Are you sure you want to clone this poll?', 'yop-poll' ),
200
+ 'cloneBulkPollsSingleMessage' => esc_html__( 'Are you sure you want to clone this poll?', 'yop-poll' ),
201
+ 'cloneBulkPollsMultiMessage' => esc_html__( 'Are you sure you want to clone these polls?', 'yop-poll' ),
202
+ 'noBulkActionSelected' => esc_html__( 'No bulk action selected', 'yop-poll' ),
203
+ 'noPollsSelectedForBulk' => esc_html__( 'No polls selected', 'yop-poll' ),
204
+ 'noBansSelectedForBulk' => esc_html__( 'No bans selected', 'yop-poll' ),
205
+ 'noLogsSelectedForBulk' => esc_html__( 'No logs selected', 'yop-poll' ),
206
+ 'deleteBulkBansSingleMessage' => esc_html__( 'Are you sure you want to delete this ban?', 'yop-poll' ),
207
+ 'deleteBulkBansMultiMessage' => esc_html__( 'Are you sure you want to delete these bans?', 'yop-poll' ),
208
+ 'deleteBulkLogsSingleMessage' => esc_html__( 'Are you sure you want to delete this log?', 'yop-poll' ),
209
+ 'deleteBulkLogsMultiMessage' => esc_html__( 'Are you sure you want to delete these logs?', 'yop-poll' ),
210
+ /* PRO */
211
+ 'deleteCustomFieldMessage' => esc_html__( 'Are you sure you want to delete this field?', 'yop-poll' ),
212
+ 'deleteQuestionMessage' => esc_html__( 'Are you sure you want to delete this question?', 'yop-poll' ),
213
+ 'deleteSpaceSeparatorMessage' => esc_html__( 'Are you sure you want to delete this space separator?', 'yop-poll' ),
214
+ 'deleteTextBlockMessage' => esc_html__( 'Are you sure you want to delete this text block?', 'yop-poll' ),
215
+ /* END PRO */
216
+ 'deleteAnswerMessage' => esc_html__( 'Are you sure you want to delete this answer?', 'yop-poll' ),
217
+ 'deleteAnswerNotAllowedMessage' => esc_html__( 'Answer can\'t be deleted. At least one answer is required!', 'yop-poll' ),
218
+ 'deleteCustomFieldMessage' => esc_html__( 'Are you sure you want to delete this custom field?', 'yop-poll' ),
219
+ 'deleteCancelLabel' => esc_html__( 'Cancel', 'yop-poll' ),
220
+ 'deleteOkLabel' => esc_html__( 'Ok', 'yop-poll' ),
221
+ 'noTemplateSelectedLabel' => esc_html__( 'Before generating the preview a template is required', 'yop-poll' ),
222
+ 'noNumberOfColumnsDefined' => esc_html__( 'Number of columns is missing', 'yop-poll' ),
223
+ 'numberOfColumnsTooBig' => esc_html__( 'Too many columns. Max 12 allowed', 'yop-poll' ),
224
+ 'selectHelperText' => esc_html__( 'Click to select', 'yop-poll' ),
225
+ 'publishDateImmediately' => esc_html__( 'Publish immediately', 'yop-poll' ),
226
+ 'publishDateSchedule' => esc_html__( 'Schedule for', 'yop-poll' ),
227
+ 'copyToClipboardSuccess' => esc_html__( 'Code Copied To Clipboard', 'yop-poll' ),
228
+ 'copyToClipboardError' => array(
229
+ 'press' => esc_html__( 'Press', 'yop-poll' ),
230
+ 'copy' => esc_html__( ' to copy', 'yop-poll' ),
231
+ 'noSupport' => esc_html__( 'No Support', 'yop-poll' )
232
+ ),
233
+ 'captchaParams' => array(
234
+ 'imgPath' => YOP_POLL_URL . 'public/assets/img/',
235
+ 'url' => YOP_POLL_URL . 'app.php',
236
+ 'accessibilityAlt' => esc_html__( 'Sound icon', 'yop-poll' ),
237
+ 'accessibilityTitle' => esc_html__( 'Accessibility option: listen to a question and answer it!', 'yop-poll' ),
238
+ 'accessibilityDescription' => __( 'Type below the <strong>answer</strong> to what you hear. Numbers or words:', 'yop-poll' ),
239
+ 'explanation' => __( "Click or touch the <strong>ANSWER</strong>", 'yop-poll' ),
240
+ 'refreshAlt' => esc_html__( 'Refresh/reload icon', 'yop-poll' ),
241
+ 'refreshTitle' => esc_html__( 'Refresh/reload: get new images and accessibility option!', 'yop-poll' )
242
+ ),
243
+ 'previewParams' => array(
244
+ 'pollPreviewTitle' => esc_html__( 'Poll Preview', 'yop-poll' ),
245
+ 'choosePreviewText' => esc_html__( 'Show preview for', 'yop-poll' ),
246
+ 'votingText' => esc_html__( 'Voting', 'yop-poll' ),
247
+ 'resultsText' => esc_html__( 'Results', 'yop-poll' ),
248
+ 'numberOfVotesSingular' => esc_html__( 'vote', 'yop-poll' ),
249
+ 'numberOfVotesPlural' => esc_html__( 'votes', 'yop-poll' ),
250
+ 'numberOfAnswerSingular' => esc_html__( 'answer', 'yop-poll' ),
251
+ 'numberOfAnswersPlural' => esc_html__( 'answers', 'yop-poll' ),
252
+ 'annonymousVoteText' => esc_html__( 'Anonymous Vote', 'yop-poll' ),
253
+ 'wordpressVoteText' => esc_html__( 'Sign in with Wordpress', 'yop-poll' ),
254
+ 'facebookVoteText' => esc_html__( 'Sign in with Facebook', 'yop-poll' ),
255
+ 'googleVoteText' => esc_html__( 'Sign in with Google', 'yop-poll' )
256
+ ),
257
+ 'saveParams' => array(
258
+ 'noTemplateSelected' => esc_html__( 'Template is missing', 'yop-poll' ),
259
+ 'generalErrorMessage' => esc_html__( ' is missing', 'yop-poll' ),
260
+ 'noPollName' => esc_html__( 'Poll name is missing', 'yop-poll' ),
261
+ 'noQuestion' => esc_html__( 'Question Text is missing', 'yop-poll' ),
262
+ 'noAnswerText' => esc_html__( 'Answer Text is missing', 'yop-poll' ),
263
+ 'noAnswerLink' => esc_html__( 'Answer Link is missing', 'yop-poll' ),
264
+ 'noAnswerEmbed' => esc_html__( 'Answer Embed is missing', 'yop-poll' ),
265
+ 'noOtherLabel' => esc_html__( 'Label for Other is missing', 'yop-poll' ),
266
+ 'noMinAnswers' => esc_html__( 'Minimum answers is missing', 'yop-poll' ),
267
+ 'noMaxAnswers' => esc_html__( 'Maximum answers is missing', 'yop-poll' ),
268
+ 'noCustomFieldName' => esc_html__( 'Custom Field Name is missing', 'yop-poll' ),
269
+ 'noStartDate' => esc_html__( 'Poll Start Date is missing', 'yop-poll' ),
270
+ 'noEndDate' => esc_html__( 'Poll End Date is missing', 'yop-poll' ),
271
+ 'noCustomDate' => esc_html__( 'Custom Date for displaying results is missing', 'yop-poll' ),
272
+ 'noShowResultsMoment' => esc_html__( 'Show Results Time is missing', 'yop-poll' ),
273
+ 'noShowResultsTo' => esc_html__( 'Show Results To is missing', 'yop-poll' ),
274
+ 'noVoteAsWordpress' => esc_html__( 'Vote As Wordpress User is missing', 'yop-poll' )
275
+ ),
276
+ 'saveBanParams' => array(
277
+ 'noBanFor' => esc_html__( 'Ban For is missing', 'yop-poll' ),
278
+ 'noBanValue' => esc_html__( 'Ban Value is missing', 'yop-poll' )
279
+ ),
280
+ 'deleteBanMessage' => esc_html__( 'Are you sure you want to delete this ban?', 'yop-poll' ),
281
+ 'deleteLogMessage' => esc_html__( 'Are you sure you want to delete this log?', 'yop-poll' ),
282
+ 'viewLogDetailsQuestionText' => esc_html__( 'Question', 'yop-poll' ),
283
+ 'viewLogDetailsAnswerText' => esc_html__( 'Answer', 'yop-poll' ),
284
+ 'showLogDetailsLinkText' => esc_html__( 'Answer', 'yop-poll' ),
285
+ 'showLogDetailsLinkText' => esc_html__( 'View Details', 'yop-poll' ),
286
+ 'hideLogDetailsLinkText' => esc_html__( 'Hide Details', 'yop-poll' ),
287
+ 'numberOfVotesText' => esc_html__( 'Number of Votes', 'yop-poll' ),
288
+ 'resultsParams'=> array(
289
+ 'singleVote' => esc_html__( 'vote', 'yop-poll' ),
290
+ 'multipleVotes' => esc_html__( 'votes', 'yop-poll' )
291
+ ),
292
+ 'importOld' => array(
293
+ 'gdprEnabledContinue' => esc_html__( 'Got It. Continue with the migration', 'yop-poll' ),
294
+ 'gdprEnabledStop' => esc_html__( 'Hold On. I want to change settings', 'yop-poll' ),
295
+ 'gdprEnabledGeneral' => esc_html__( 'Please review your settings before continue', 'yop-poll' ),
296
+ 'gdprEnabledChoice' => esc_html__( 'Your selection', 'yop-poll' ),
297
+ 'gdprEnabledMigrateAsIs' => esc_html__( 'This setting will migrate all data from previous version without any anonymization', 'yop-poll' ),
298
+ 'gdprEnabledAnonymizeIp' => esc_html__( 'This setting will migrate all data from previous version but ips will be anonymized', 'yop-poll' ),
299
+ 'gdprEnabledNoStore' => esc_html__( 'This setting will migrate everything except ip addresses. ', 'yop-poll' ),
300
+ 'response' => esc_html__( 'Response:', 'yop-poll' ),
301
+ 'allDone' => esc_html__( 'All done.', 'yop-poll' ),
302
+ 'importStarted' => esc_html__( 'Migration started', 'yop-poll' ),
303
+ )
304
+ )
305
+ ) );
306
+ }
307
+ public function load_styles() {
308
+ wp_enqueue_style( 'yop-admin', YOP_POLL_URL . 'admin/assets/css/admin.css' );
309
+ wp_enqueue_style( 'yop-public', YOP_POLL_URL . 'public/assets/css/yop-poll-public.css' );
310
+ }
311
+ public function change_page_title( $title ) {
312
+ $_page = isset( $_GET['page'] ) ? $_GET['page'] : '';
313
+ $_action = isset( $_GET['action'] ) ? $_GET['action'] : '';
314
+ switch ( $_page ) {
315
+ case 'yop-polls':{
316
+ switch ( $_action ) {
317
+ case 'edit': {
318
+ $title = __( 'Edit Poll', 'yop-poll' );
319
+ break;
320
+ }
321
+ case 'view-results': {
322
+ $title = __( 'View Poll Results', 'yop-poll' );
323
+ break;
324
+ }
325
+ default: {
326
+ $title = __( 'All Polls', 'yop-poll' );
327
+ break;
328
+ }
329
+ }
330
+ break;
331
+ }
332
+ case 'yop-poll-logs': {
333
+ switch ( $_action ) {
334
+ default: {
335
+ $title = __( 'View Logs', 'yop-poll' );
336
+ break;
337
+ }
338
+ }
339
+ break;
340
+ }
341
+ case 'yop-poll-bans': {
342
+ switch ( $_action ) {
343
+ case 'add': {
344
+ $title = __( 'Add Ban', 'yop-poll' );
345
+ break;
346
+ }
347
+ case 'edit': {
348
+ $title = __( 'Edit Ban', 'yop-poll' );
349
+ break;
350
+ }
351
+ default: {
352
+ $title = __( 'All Bans', 'yop-poll' );
353
+ break;
354
+ }
355
+ }
356
+ break;
357
+ }
358
+ }
359
+ return $title;
360
+ }
361
+ public function manage_polls() {
362
+ $_action = isset( $_GET['action'] ) ? $_GET['action'] : '';
363
+ switch ( $_action) {
364
+ case 'edit': {
365
+ $this->show_edit_poll( $_GET['poll_id'] );
366
+ break;
367
+ }
368
+ case 'delete': {
369
+ $this->delete_poll( $_GET['poll_id'] );
370
+ break;
371
+ }
372
+ case 'view-results': {
373
+ $this->display_results( $_GET['poll_id'] );
374
+ break;
375
+ }
376
+ case 'results': {
377
+ $this->build_results( $_GET['poll_id'] );
378
+ break;
379
+ }
380
+ case 'view-votes': {
381
+ $this->display_votes( $_GET['poll_id'] );
382
+ break;
383
+ }
384
+ default: {
385
+ $this->show_polls();
386
+ break;
387
+ }
388
+ }
389
+ }
390
+ public function show_polls() {
391
+ if ( current_user_can( 'yop_poll_results_own' ) ) {
392
+ $params['q'] = isset( $_GET['q']) ? $_GET['q'] : '';
393
+ $params['order_by'] = isset( $_GET['order_by'] ) ? $_GET['order_by'] : '';
394
+ $params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'desc';
395
+ $params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
396
+ $polls = YOP_Poll_Polls::get_polls( $params );
397
+ $template = YOP_POLL_PATH . 'admin/views/viewpolls.php';
398
+ echo YOP_Poll_View::render(
399
+ $template,
400
+ array(
401
+ 'polls' => $polls['polls'],
402
+ 'statistics' => $polls['statistics'],
403
+ 'params' => $params,
404
+ 'total_polls' => $polls['total_polls'],
405
+ 'total_pages' => $polls['total_pages'],
406
+ 'pagination' => $polls['pagination'],
407
+ 'date_format' => self::$date_format,
408
+ 'time_format' => self::$time_format
409
+ )
410
+ );
411
+ }
412
+ return true;
413
+ }
414
+ public function add_new_poll() {
415
+ if ( current_user_can( 'yop_poll_add' ) ) {
416
+ $template = YOP_POLL_PATH . 'admin/views/addnewpoll.php';
417
+ $templates = YOP_Poll_Templates::get_templates();
418
+ $email_settings = YOP_Poll_Settings::get_email_settings();
419
+ echo YOP_Poll_View::render( $template, array(
420
+ 'templates' => $templates,
421
+ 'email_settings' => $email_settings,
422
+ 'date_format' => self::$date_format
423
+ ) );
424
+ }
425
+ }
426
+ public function show_edit_poll( $poll_id ) {
427
+ if ( 0 < intval( $poll_id ) ) {
428
+ $current_user = wp_get_current_user();
429
+ $poll_owner = YOP_Poll_Polls::get_owner( $poll_id );
430
+ if (
431
+ ( ( $poll_owner === $current_user->ID ) && ( current_user_can( 'yop_poll_edit_own' ) ) ) ||
432
+ ( ( $poll_owner !== $current_user->ID ) && ( current_user_can( 'yop_poll_edit_others' ) ) )
433
+ ) {
434
+ $poll = YOP_Poll_Polls::get_poll( $poll_id );
435
+ if ( false !== $poll ) {
436
+ $template = YOP_POLL_PATH . 'admin/views/editpoll.php';
437
+ $templates = YOP_Poll_Templates::get_templates();
438
+ echo YOP_Poll_View::render( $template, array(
439
+ 'poll' => $poll,
440
+ 'templates' => $templates,
441
+ 'date_format' => self::$date_format ) );
442
+ } else {
443
+ echo __( 'You don\'t have sufficient permissions to access this page', 'yop-poll');
444
+ }
445
+ }
446
+ }
447
+ }
448
+ public function create_poll() {
449
+ if ( current_user_can( 'yop_poll_add' ) && check_ajax_referer( 'yop-poll-add-poll', '_token', false ) ) {
450
+ $result = YOP_Poll_Polls::add( json_decode( wp_unslash( $_POST['poll'] ) ) );
451
+ if ( true === $result['success'] ) {
452
+ wp_send_json_success( __( 'Poll successfully added', 'yop-poll' ) );
453
+ } else {
454
+ wp_send_json_error( $result['error'] );
455
+ }
456
+ } else {
457
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
458
+ }
459
+ }
460
+ public function update_poll() {
461
+ $current_user = wp_get_current_user();
462
+ $poll = json_decode( wp_unslash( $_POST['poll'] ) );
463
+ $poll_owner = YOP_Poll_Polls::get_owner( $poll->id );
464
+ if ( check_ajax_referer( 'yop-poll-edit-poll', '_token', false ) ) {
465
+ if (
466
+ ( ( $poll_owner === $current_user->ID ) && ( current_user_can( 'yop_poll_edit_own' ) ) ) ||
467
+ ( ( $poll_owner !== $current_user->ID ) && ( current_user_can( 'yop_poll_edit_others' ) ) )
468
+ ) {
469
+ $result = YOP_Poll_Polls::update( $poll );
470
+ if ( true === $result['success'] ) {
471
+ wp_send_json_success( __( 'Poll successfully updated', 'yop-poll' ) );
472
+ } else {
473
+ wp_send_json_error( $result['error'] );
474
+ }
475
+ } else {
476
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
477
+ }
478
+ } else {
479
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
480
+ }
481
+ }
482
+ public function delete_single_poll() {
483
+ if ( check_ajax_referer( 'yop-poll-view-polls', '_token', false ) || check_ajax_referer( 'yop-poll-edit-poll', '_token', false ) ) {
484
+ if ( isset( $_POST['poll_id'] ) && ( 0 < intval( $_POST['poll_id'] ) ) ) {
485
+ $current_user = wp_get_current_user();
486
+ $poll_owner = YOP_Poll_Polls::get_owner( $_POST['poll_id'] );
487
+ if (
488
+ ( ( $poll_owner === $current_user->ID ) && ( current_user_can( 'yop_poll_delete_own' ) ) ) ||
489
+ ( ( $poll_owner !== $current_user->ID ) && ( current_user_can( 'yop_poll_delete_others' ) ) )
490
+ ) {
491
+ $result = YOP_Poll_Polls::delete( $_POST['poll_id'] );
492
+ if ( true === $result['success'] ) {
493
+ YOP_Poll_Bans::delete_all_for_poll( $_POST['poll_id'] );
494
+ wp_send_json_success( __( 'Poll successfully deleted', 'yop-poll' ) );
495
+ } else {
496
+ wp_send_json_error( $result['error'] );
497
+ }
498
+ } else {
499
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
500
+ }
501
+ } else {
502
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
503
+ }
504
+ } else {
505
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
506
+ }
507
+ }
508
+ public function delete_bulk_poll() {
509
+ if ( check_ajax_referer( 'yop-poll-bulk-polls', '_token', false ) ) {
510
+ $current_user = wp_get_current_user();
511
+ $polls = json_decode( wp_unslash( $_POST['polls'] ) );
512
+ $success = 0;
513
+ foreach ( $polls as $poll ) {
514
+ $poll_owner = YOP_Poll_Polls::get_owner( $poll );
515
+ if (
516
+ ( ( $poll_owner === $current_user->ID ) && ( current_user_can( 'yop_poll_delete_own' ) ) ) ||
517
+ ( ( $poll_owner !== $current_user->ID ) && ( current_user_can( 'yop_poll_delete_others' ) ) )
518
+ ) {
519
+ $result = YOP_Poll_Polls::delete( $poll );
520
+ if ( true === $result['success'] ) {
521
+ $success++;
522
+ } else {
523
+ $success--;
524
+ }
525
+ } else {
526
+ $success--;
527
+ }
528
+ }
529
+ if ( $success === intval( count( $polls ) ) ) {
530
+ wp_send_json_success( _n(
531
+ 'Poll successfully deleted',
532
+ 'Polls successfully deleted',
533
+ count( $polls ),
534
+ 'yop-poll' )
535
+ );
536
+ } else {
537
+ wp_send_json_error( _(
538
+ 'Error deleting poll',
539
+ 'Error deleting polls',
540
+ count( $polls ),
541
+ 'yop-poll' )
542
+ );
543
+ }
544
+ } else {
545
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
546
+ }
547
+ }
548
+ public function clone_single_poll() {
549
+ if ( check_ajax_referer( 'yop-poll-view-polls', '_token', false ) ) {
550
+ if ( isset( $_POST['poll_id'] ) && ( 0 < intval( $_POST['poll_id'] ) ) ) {
551
+ if ( current_user_can( 'yop_poll_add' ) ) {
552
+ $result = YOP_Poll_Polls::clone_poll( $_POST['poll_id'] );
553
+ if ( true === $result['success'] ) {
554
+ wp_send_json_success( __( 'Poll successfully cloned', 'yop-poll' ) );
555
+ } else {
556
+ wp_send_json_error( $result['error'] );
557
+ }
558
+ } else {
559
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
560
+ }
561
+ } else {
562
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
563
+ }
564
+ } else {
565
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
566
+ }
567
+ }
568
+ public function clone_bulk_poll() {
569
+ if ( check_ajax_referer( 'yop-poll-bulk-polls', '_token', false ) ) {
570
+ $polls = json_decode( wp_unslash( $_POST['polls'] ) );
571
+ $success = 0;
572
+ foreach ( $polls as $poll ) {
573
+ if ( current_user_can( 'yop_poll_add' ) ) {
574
+ $result = YOP_Poll_Polls::clone_poll( $poll );
575
+ if ( true === $result['success'] ) {
576
+ $success++;
577
+ } else {
578
+ $success--;
579
+ }
580
+ } else {
581
+ $success--;
582
+ }
583
+ }
584
+ if ( $success === intval( count( $polls ) ) ) {
585
+ wp_send_json_success( _n(
586
+ 'Poll successfully cloned',
587
+ 'Polls successfully cloned',
588
+ count( $polls ),
589
+ 'yop-poll' )
590
+ );
591
+ } else {
592
+ wp_send_json_error( _(
593
+ 'Error cloning poll',
594
+ 'Error cloning polls',
595
+ count( $polls ),
596
+ 'yop-poll' )
597
+ );
598
+ }
599
+ } else {
600
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
601
+ }
602
+ }
603
+ public function display_results( $poll_id ) {
604
+ if ( current_user_can( 'yop_poll_results_own' ) ) {
605
+ $template = YOP_POLL_PATH . 'admin/views/viewresults.php';
606
+ $poll = YOP_Poll_Polls::get_poll( $poll_id );
607
+ echo YOP_Poll_View::render(
608
+ $template,
609
+ array(
610
+ 'poll' => $poll
611
+ )
612
+ );
613
+ }
614
+ }
615
+ public function build_results( $poll_id ) {
616
+ if ( current_user_can( 'yop_poll_results_own' ) ) {
617
+ $params['q'] = isset( $_GET['q']) ? $_GET['q'] : '';
618
+ $params['order_by'] = isset( $_GET['order_by'] ) ? $_GET['order_by'] : '';
619
+ $params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'asc';
620
+ $params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
621
+ $template = YOP_POLL_PATH . 'admin/views/results.php';
622
+ $poll = YOP_Poll_Polls::get_poll( $poll_id );
623
+ if ( $poll ) {
624
+ $voters = YOP_Poll_Votes::get_poll_voters_sorted( $poll_id );
625
+ $limit = 10;
626
+ $page = 1;
627
+ $offset = 0;
628
+ $cf_string = '';
629
+ $cf_hidden = '';
630
+ $cf_total_pages = 0;
631
+ $customs_count = 0;
632
+ $total_votes_per_question = [];
633
+ $total_voters_per_question = [];
634
+ $votes_count = $GLOBALS['wpdb']->get_var( $GLOBALS['wpdb']->prepare( "SELECT COUNT(*) FROM `{$GLOBALS['wpdb']->yop_poll_votes}` WHERE `poll_id` = %d AND `status` = 'active'", array( $poll_id ) ) );
635
+ $total_pages = ceil( $votes_count/$limit );
636
+ $query = "SELECT * FROM `{$GLOBALS['wpdb']->yop_poll_votes}` WHERE `poll_id` = %d AND `status` = 'active' limit $offset, $limit";
637
+ $votes = $GLOBALS['wpdb']->get_results( $GLOBALS['wpdb']->prepare( $query, array( $poll_id ) ) );
638
+
639
+ $all_votes_query = "SELECT * FROM `{$GLOBALS['wpdb']->yop_poll_votes}` WHERE `poll_id` = %d AND `status` = 'active'";
640
+ $all_votes = $GLOBALS['wpdb']->get_results( $GLOBALS['wpdb']->prepare( $all_votes_query, array( $poll_id ) ) );
641
+
642
+ $other_answers = [];
643
+ foreach ( $all_votes as $av ) {
644
+ $vote_data = unserialize( $av->vote_data );
645
+ $user_type = $av->user_type;
646
+ foreach ( $vote_data['elements'] as $ave ) {
647
+ $question_aswers = [];
648
+ if ( 'question' === $ave['type'] ) {
649
+ foreach ( $ave['data'] as $answers ) {
650
+ if ( 0 == $answers['id'] ) {
651
+ $question_aswers[] = $answers['data'];
652
+ }
653
+ }
654
+ if( isset( $total_votes_per_question[$ave['id']] ) ) {
655
+ $total_votes_per_question[$ave['id']]++;
656
+ } else {
657
+ $total_votes_per_question[$ave['id']] = 1;
658
+ }
659
+ if( isset( $total_voters_per_question[$ave['id']][$user_type] ) ) {
660
+ $total_voters_per_question[$ave['id']][$user_type]++;
661
+ } else {
662
+ $total_voters_per_question[$ave['id']][$user_type] = 1;
663
+ }
664
+ $other_answers[] = [ 'question_id' => $ave['id'], 'other_answers' => $question_aswers ];
665
+ }
666
+ }
667
+ }
668
+ $other_answers = Helper::group_other_answers( $other_answers );
669
+ if( count( $votes ) > 0 ) {
670
+ $cf_hidden .= '<input type="hidden" name="cf_total_pages" id="cf-total-pages" value="' . $total_pages . '">';
671
+ $cf_hidden .= '<input type="hidden" name="cf_page" id="cf-page" value="' . $page . '">';
672
+ foreach ( $votes as $vote ) {
673
+ $vote_data = unserialize( $vote->vote_data );
674
+ $custom_fields = [];
675
+ foreach ( $vote_data['elements'] as $vde ) {
676
+ if ( 'custom-field' === $vde['type'] ) {
677
+ $custom_fields[] = [ 'id' => $vde['id'], 'data' => isset( $vde['data'][0] ) ? $vde['data'][0] : '' ];
678
+ $customs_count++;
679
+ }
680
+ }
681
+ if ( count( $custom_fields ) > 0 ) {
682
+ $cf_total_pages = ceil( count( $custom_fields )/$limit );
683
+ $cf_string .= '<tr>';
684
+ foreach ( $custom_fields as $cf ) {
685
+ $cf_string .= '<td>' . $cf['data'] . '</td>';
686
+ }
687
+ $cf_string .= '</tr>';
688
+ } else {
689
+ $cf_total_pages = 0;
690
+ }
691
+ }
692
+ }
693
+ echo YOP_Poll_View::render(
694
+ $template,
695
+ array(
696
+ 'params' => $params,
697
+ 'poll' => $poll,
698
+ 'total_votes' => $votes_count,
699
+ 'total_pages' => $total_pages,
700
+ 'voters' => $voters,
701
+ 'cf_string' => $cf_string,
702
+ 'cf_hidden' => $cf_hidden,
703
+ 'cf_total_pages' => $cf_total_pages,
704
+ 'other_answers' => $other_answers,
705
+ 'total_votes_per_question' => $total_votes_per_question,
706
+ 'total_voters_per_question' => $total_voters_per_question
707
+ )
708
+ );
709
+ } else {
710
+ $error = __( 'Invalid poll', 'yop-poll' );
711
+ $template = YOP_POLL_PATH . 'admin/views/error.php';
712
+ echo YOP_Poll_View::render(
713
+ $template,
714
+ array(
715
+ 'error' => $error
716
+ )
717
+ );
718
+ }
719
+ }
720
+ }
721
+ public function display_votes( $poll_id ) {
722
+ if ( current_user_can( 'yop_poll_results_own' ) ) {
723
+ $params['order_by'] = isset( $_GET['order_by'] ) ? $_GET['order_by'] : '';
724
+ $params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'asc';
725
+ $params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
726
+ $params['page'] = isset( $_GET['page'] ) ? $_GET['page'] : 'yop-poll';
727
+ $params['poll_id'] = isset( $_GET['poll_id'] ) ? $_GET['poll_id'] : '';
728
+ $params['action'] = isset( $_GET['action'] ) ? $_GET['action'] : '';
729
+ $template = YOP_POLL_PATH . 'admin/views/viewpollvotes.php';
730
+ $poll = YOP_Poll_Polls::get_poll( $poll_id );
731
+ if ($poll) {
732
+ $votes = YOP_Poll_Votes::get_votes_to_display( $params );
733
+ echo YOP_Poll_View::render(
734
+ $template,
735
+ array(
736
+ 'params' => $params,
737
+ 'poll' => $poll,
738
+ 'total_votes' => $votes['total_votes'],
739
+ 'votes_pages' => $votes['total_pages'],
740
+ 'total_pages' => $votes['total_pages'],
741
+ 'votes' => $votes['votes'],
742
+ 'pagination' => $votes['pagination']
743
+ )
744
+ );
745
+ } else {
746
+ $error = __( 'Invalid poll', 'yop-poll' );
747
+ $template = YOP_POLL_PATH . 'admin/views/error.php';
748
+ echo YOP_Poll_View::render(
749
+ $template,
750
+ array(
751
+ 'error' => $error
752
+ )
753
+ );
754
+ }
755
+ }
756
+ }
757
+ public function get_yop_poll_votes_customs() {
758
+ if ( check_ajax_referer( 'yop-poll-get-vote-customs', '_token', false ) ) {
759
+ $limit = 10;
760
+ if(isset($_POST['page']) && $_POST['page'] != "") {
761
+ $page = $_POST['page'];
762
+ $offset = $limit * ($page-1);
763
+ } else {
764
+ $page = 1;
765
+ $offset = 0;
766
+ }
767
+ $votes = YOP_Poll_Votes::get_vote_by_poll( $_POST['poll_id'], $limit, $offset );
768
+ $cf_string = '';
769
+ if( count( $votes ) > 0 ) {
770
+ foreach ( $votes as $vote ) {
771
+ $vote_data = unserialize( $vote->vote_data );
772
+ $custom_fields = [];
773
+ foreach ( $vote_data['elements'] as $vde ) {
774
+ if ( 'custom-field' === $vde['type'] ) {
775
+ $custom_fields[] = [ 'id' => $vde['id'], 'data' => isset( $vde['data'][0] ) ? $vde['data'][0] : '' ];
776
+ }
777
+ }
778
+ if ( count( $custom_fields ) > 0 ) {
779
+ $cf_string .= '<tr>';
780
+ foreach ($custom_fields as $cf ) {
781
+ $cf_string .= '<td>' . $cf['data'] . '</td>';
782
+ }
783
+ $cf_string .= '</tr>';
784
+ }
785
+ }
786
+ wp_send_json_success( $cf_string );
787
+ } else {
788
+ wp_send_json_success( $cf_string );
789
+ }
790
+ } else {
791
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
792
+ }
793
+ }
794
+ public function manage_support() {
795
+ $template = YOP_POLL_PATH . 'admin/views/support.php';
796
+ echo YOP_Poll_View::render( $template );
797
+ }
798
+ public function migrate_old_tables() {
799
+ $template = YOP_POLL_PATH . 'admin/views/migrate-old-tables.php';
800
+ echo YOP_Poll_View::render( $template );
801
+ }
802
+ public function manage_logs () {
803
+ if ( current_user_can( 'yop_poll_add' ) ) {
804
+ $params['q'] = isset( $_GET['q']) ? $_GET['q'] : '';
805
+ $params['order_by'] = isset( $_GET['order_by'] ) ? $_GET['order_by'] : '';
806
+ $params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'asc';
807
+ $params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
808
+ $logs = YOP_Poll_Logs::get_logs( $params );
809
+ $template = YOP_POLL_PATH . 'admin/views/viewlogs.php';
810
+ echo YOP_Poll_View::render( $template, array(
811
+ 'logs' => $logs['logs'],
812
+ 'params' => $params,
813
+ 'total_logs' => $logs['total_logs'],
814
+ 'total_pages' => $logs['total_pages'],
815
+ 'pagination' => $logs['pagination'],
816
+ 'date_format' => self::$date_format,
817
+ 'time_format' => self::$time_format
818
+ ) );
819
+ }
820
+ }
821
+ public function get_log_details() {
822
+ if ( check_ajax_referer( 'yop-poll-view-logs', '_token', false ) ) {
823
+ if ( isset( $_POST['log_id'] ) && ( 0 < intval( $_POST['log_id'] ) ) ) {
824
+ $log_owner = YOP_Poll_Logs::get_owner( $_POST['log_id'] );
825
+ $current_user = wp_get_current_user();
826
+ if ( $log_owner == $current_user->ID ) {
827
+ $results = YOP_Poll_Logs::get_log_details( $_POST['log_id'] );
828
+ $details_string = '';
829
+ foreach ( $results as $res ) {
830
+ if ( 'custom-field' === $res['question']) {
831
+ $details_string .= "<div>" . __( 'Custom Field', 'yop-poll' ) . ': ' . $res['caption'];
832
+ $details_string .= '<div style="padding-left: 10px;">' . __( 'Answer', 'yop-poll' ) . ': ' .
833
+ $res['answers'][0]['answer_value'] . '</div>';
834
+ } else {
835
+ $details_string .= "<div>" . __('Question', 'yop-poll' ). ': ' . $res['question'];
836
+ foreach ( $res['answers'] as $ra ) {
837
+ $details_string .= '<div style="padding-left: 10px;">' . __( 'Answer', 'yop-poll' ) . ': ' . $ra['answer_value'] . '</div>';
838
+ }
839
+ }
840
+ $details_string .= '</div>';
841
+ }
842
+ wp_send_json_success( [ 'details' => $details_string ] );
843
+ } else {
844
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
845
+ }
846
+ } else {
847
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
848
+ }
849
+ } else {
850
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
851
+ }
852
+ }
853
+ public function manage_bans() {
854
+ $_action = isset( $_GET['action'] ) ? $_GET['action'] : '';
855
+ switch ( $_action) {
856
+ case 'add': {
857
+ $this->show_add_ban();
858
+ break;
859
+ }
860
+ case 'edit': {
861
+ $this->show_edit_ban( $_GET['ban_id'] );
862
+ break;
863
+ }
864
+ default: {
865
+ $this->show_bans();
866
+ break;
867
+ }
868
+ }
869
+ }
870
+ public function show_bans() {
871
+ if ( current_user_can( 'yop_poll_add' ) ) {
872
+ $params['q'] = isset( $_GET['q']) ? $_GET['q'] : '';
873
+ $params['order_by'] = isset( $_GET['order_by'] ) ? $_GET['order_by'] : '';
874
+ $params['sort_order'] = isset( $_GET['sort_order'] ) ? $_GET['sort_order'] : 'asc';
875
+ $params['page_no'] = isset( $_GET['page_no'] ) ? $_GET['page_no'] : '1';
876
+ $template = YOP_POLL_PATH . 'admin/views/viewbanns.php';
877
+ $bans = YOP_Poll_Bans::get_bans( $params );
878
+ echo YOP_Poll_View::render( $template, array(
879
+ 'bans' => $bans['bans'],
880
+ 'params' => $params,
881
+ 'total_bans' => $bans['total_bans'],
882
+ 'total_pages' => $bans['total_pages'],
883
+ 'pagination' => $bans['pagination'],
884
+ 'date_format' => self::$date_format,
885
+ 'time_format' => self::$time_format
886
+ ) );
887
+ }
888
+ }
889
+ public function show_add_ban() {
890
+ if ( current_user_can( 'yop_poll_add' ) ) {
891
+ $polls = YOP_Poll_Polls::get_names();
892
+ $template = YOP_POLL_PATH . 'admin/views/addban.php';
893
+ echo YOP_Poll_View::render( $template, array(
894
+ 'polls' => $polls
895
+ ) );
896
+ }
897
+ }
898
+ public function create_ban() {
899
+ if ( current_user_can( 'yop_poll_add' ) && check_ajax_referer( 'yop-poll-add-ban', '_token', false ) ) {
900
+ $result = YOP_Poll_Bans::add( json_decode( wp_unslash( $_POST['ban'] ) ) );
901
+ if ( true === $result['success'] ) {
902
+ wp_send_json_success( __( 'Ban successfully added', 'yop-poll' ) );
903
+ } else {
904
+ wp_send_json_error( $result['error'] );
905
+ }
906
+ } else {
907
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
908
+ }
909
+ }
910
+ public function show_edit_ban( $ban_id ) {
911
+ if ( 0 < intval( $ban_id ) ) {
912
+ $current_user = wp_get_current_user();
913
+ $ban_owner = YOP_Poll_Bans::get_owner( $ban_id );
914
+ if (
915
+ ( ( $ban_owner === $current_user->ID ) && ( current_user_can( 'yop_poll_edit_own' ) ) ) ||
916
+ ( ( $ban_owner !== $current_user->ID ) && ( current_user_can( 'yop_poll_edit_others' ) ) )
917
+ ) {
918
+ $ban = YOP_Poll_Bans::get_ban( $ban_id );
919
+ if ( false !== $ban ) {
920
+ $polls = YOP_Poll_Polls::get_names();
921
+ $template = YOP_POLL_PATH . 'admin/views/editban.php';
922
+ echo YOP_Poll_View::render( $template, array(
923
+ 'ban' => $ban['ban'],
924
+ 'polls' => $polls
925
+ ));
926
+ } else {
927
+ echo __( 'You don\'t have sufficient permissions to access this page', 'yop-poll' );
928
+ }
929
+ }
930
+ }
931
+ }
932
+ public function delete_single_ban() {
933
+ if ( check_ajax_referer( 'yop-poll-view-bans', '_token', false ) ) {
934
+ if ( isset( $_POST['ban_id'] ) && ( 0 < intval( $_POST['ban_id'] ) ) ) {
935
+ $current_user = wp_get_current_user();
936
+ $ban_owner = YOP_Poll_Bans::get_owner( $_POST['ban_id'] );
937
+ if (
938
+ ( ( $ban_owner === $current_user->ID ) && ( current_user_can( 'yop_poll_delete_own' ) ) ) ||
939
+ ( ( $ban_owner !== $current_user->ID ) && ( current_user_can( 'yop_poll_delete_others' ) ) )
940
+ ) {
941
+ $result = YOP_Poll_Bans::delete( $_POST['ban_id'] );
942
+ if ( true === $result['success'] ) {
943
+ wp_send_json_success( __( 'Ban successfully deleted', 'yop-poll' ) );
944
+ } else {
945
+ wp_send_json_error( $result['error'] );
946
+ }
947
+ } else {
948
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
949
+ }
950
+ } else {
951
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
952
+ }
953
+ } else {
954
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
955
+ }
956
+ }
957
+ public function update_ban() {
958
+ $ban = json_decode( wp_unslash( $_POST['ban'] ) );
959
+ $ban_owner = YOP_Poll_Bans::get_owner( $ban->ban->id );
960
+ $current_user = wp_get_current_user();
961
+ if ( check_ajax_referer( 'yop-poll-edit-ban', '_token', false ) ) {
962
+ if (
963
+ ( ( $ban_owner === $current_user->ID ) && ( current_user_can( 'yop_poll_edit_own' ) ) ) ||
964
+ ( ( $ban_owner !== $current_user->ID ) && ( current_user_can( 'yop_poll_edit_others' ) ) )
965
+ ) {
966
+ $result = YOP_Poll_Bans::update( $ban );
967
+ if ( true === $result['success'] ) {
968
+ wp_send_json_success( __( 'Ban successfully updated', 'yop-poll' ) );
969
+ } else {
970
+ wp_send_json_error( $result['error'] );
971
+ }
972
+ } else {
973
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
974
+ }
975
+ } else {
976
+ wp_send_json_error( __( 'You are not allowed to perform this action', 'yop-poll' ) );
977
+ }
978
+ }
979
+ public function delete_bulk_ban() {
980
+ if ( check_ajax_referer( 'yop-poll-bulk-bans', '_token', false ) ) {
981
+ $bans = json_decode( wp_unslash( $_POST['bans'] ) );
982
+ $success = 0;
983
+ $current_user = wp_get_current_user();
984
+ foreach ( $bans as $ban ) {
985
+ $ban_owner = YOP_Poll_Bans::get_owner( $ban );
986
+ if (
987
+ ( ( $ban_owner === $current_user->ID ) && ( current_user_can( 'yop_poll_delete_own' ) ) ) ||
988
+ ( ( $ban_owner !== $current_user->ID ) && ( current_user_can( 'yop_poll_delete_others' ) ) )
989
+ ) {
990
+ $result = YOP_Poll_Bans::delete( $ban );
991
+ if ( true === $result['success'] ) {
992
+ $success++;
993
+ } else {
994
+ $success--;
995
+ }
996
+ } else {
997
+ $success--;
998
+ }
999
+ }
1000
+ if ( $success === intval( count( $bans ) ) ) {
1001
+ wp_send_json_success( _n(
1002
+ 'Ban successfully deleted',
1003
+ 'Bans successfully deleted',
1004
+ count( $bans ),
1005
+ 'yop-poll' )
1006
+ );
1007
+ } else {
1008
+ wp_send_json_error( _(
1009
+ 'Error deleting ban',