Yasr – Yet Another Stars Rating - Version 1.9.4

Version Description

  • NEW: Added "Top 10 Highest rated" gutenberg block
  • NEW: In the settings, is now possible to customize the "you must sign in" text; two html tags are supported: < strong > and < p >
  • FIXED: Update transient to show the new average when a rating get deleted from the panel
  • TWEAKED: Code cleanup
Download this release

Release Info

Developer Dudo
Plugin Icon 128x128 Yasr – Yet Another Stars Rating
Version 1.9.4
Comparing to
See all releases

Code changes from version 1.9.3 to 1.9.4

Files changed (301) hide show
  1. js/src/yasr-guten-blocks.js +502 -348
  2. js/yasr-admin.js +4 -5
  3. js/yasr-guten-blocks.js +181 -5
  4. lib/admin/{yasr-editor-functions.php → editor/yasr-editor-functions.php} +68 -49
  5. lib/admin/{yasr-metabox-multiple-rating.php → editor/yasr-metabox-multiple-rating.php} +0 -0
  6. lib/admin/{yasr-metabox-top-right.php → editor/yasr-metabox-top-right.php} +0 -0
  7. lib/admin/settings/yasr-settings-functions-misc.php +82 -84
  8. lib/admin/settings/yasr-settings-functions.php +329 -246
  9. lib/admin/settings/yasr-stats-functions.php +277 -0
  10. lib/admin/yasr-admin-actions.php +74 -64
  11. lib/yasr-ajax-functions.php +1 -1
  12. lib/yasr-db-functions.php +528 -573
  13. lib/yasr-functions.php +43 -31
  14. lib/yasr-shortcode-functions.php +23 -8
  15. lib/yasr-stats-functions.php +0 -278
  16. lib/yasr-widgets.php +281 -322
  17. readme.txt +12 -5
  18. trunk/LICENSE +0 -280
  19. trunk/changelog.txt +0 -666
  20. trunk/css/yasr-admin.css +0 -644
  21. trunk/css/yasr-table-dark.css +0 -48
  22. trunk/css/yasr-table-light.css +0 -53
  23. trunk/css/yasr.css +0 -218
  24. trunk/freemius/LICENSE.txt +0 -674
  25. trunk/freemius/assets/css/admin/account.css +0 -1
  26. trunk/freemius/assets/css/admin/add-ons.css +0 -2
  27. trunk/freemius/assets/css/admin/affiliation.css +0 -1
  28. trunk/freemius/assets/css/admin/checkout.css +0 -1
  29. trunk/freemius/assets/css/admin/common.css +0 -2
  30. trunk/freemius/assets/css/admin/connect.css +0 -1
  31. trunk/freemius/assets/css/admin/debug.css +0 -1
  32. trunk/freemius/assets/css/admin/dialog-boxes.css +0 -2
  33. trunk/freemius/assets/css/admin/gdpr-optin-notice.css +0 -1
  34. trunk/freemius/assets/css/admin/index.php +0 -3
  35. trunk/freemius/assets/css/customizer.css +0 -1
  36. trunk/freemius/assets/css/index.php +0 -3
  37. trunk/freemius/assets/img/index.php +0 -3
  38. trunk/freemius/assets/img/plugin-icon.png +0 -0
  39. trunk/freemius/assets/img/theme-icon.png +0 -0
  40. trunk/freemius/assets/img/yet-another-stars-rating.png +0 -0
  41. trunk/freemius/assets/index.php +0 -3
  42. trunk/freemius/assets/js/index.php +0 -3
  43. trunk/freemius/assets/js/nojquery.ba-postmessage.js +0 -140
  44. trunk/freemius/assets/js/nojquery.ba-postmessage.min.js +0 -12
  45. trunk/freemius/assets/js/postmessage.js +0 -135
  46. trunk/freemius/assets/scss/_colors.scss +0 -79
  47. trunk/freemius/assets/scss/_functions.scss +0 -0
  48. trunk/freemius/assets/scss/_load.scss +0 -4
  49. trunk/freemius/assets/scss/_mixins.scss +0 -270
  50. trunk/freemius/assets/scss/_start.scss +0 -4
  51. trunk/freemius/assets/scss/_vars.scss +0 -6
  52. trunk/freemius/assets/scss/admin/_ajax-loader.scss +0 -49
  53. trunk/freemius/assets/scss/admin/_auto-install.scss +0 -33
  54. trunk/freemius/assets/scss/admin/_buttons.scss +0 -28
  55. trunk/freemius/assets/scss/admin/_deactivation-feedback.scss +0 -55
  56. trunk/freemius/assets/scss/admin/_gdpr-consent.scss +0 -81
  57. trunk/freemius/assets/scss/admin/_license-activation.scss +0 -47
  58. trunk/freemius/assets/scss/admin/_license-key-resend.scss +0 -68
  59. trunk/freemius/assets/scss/admin/_modal-common.scss +0 -194
  60. trunk/freemius/assets/scss/admin/_multisite-options.scss +0 -40
  61. trunk/freemius/assets/scss/admin/_plugin-upgrade-notice.scss +0 -8
  62. trunk/freemius/assets/scss/admin/_subscription-cancellation.scss +0 -30
  63. trunk/freemius/assets/scss/admin/_themes.scss +0 -21
  64. trunk/freemius/assets/scss/admin/_tooltip.scss +0 -66
  65. trunk/freemius/assets/scss/admin/account.scss +0 -302
  66. trunk/freemius/assets/scss/admin/add-ons.scss +0 -449
  67. trunk/freemius/assets/scss/admin/affiliation.scss +0 -97
  68. trunk/freemius/assets/scss/admin/checkout.scss +0 -5
  69. trunk/freemius/assets/scss/admin/common.scss +0 -220
  70. trunk/freemius/assets/scss/admin/connect.scss +0 -548
  71. trunk/freemius/assets/scss/admin/debug.scss +0 -135
  72. trunk/freemius/assets/scss/admin/dialog-boxes.scss +0 -10
  73. trunk/freemius/assets/scss/admin/gdpr-optin-notice.scss +0 -17
  74. trunk/freemius/assets/scss/admin/index.php +0 -3
  75. trunk/freemius/assets/scss/customizer.scss +0 -125
  76. trunk/freemius/assets/scss/index.php +0 -3
  77. trunk/freemius/config.php +0 -388
  78. trunk/freemius/includes/class-freemius-abstract.php +0 -597
  79. trunk/freemius/includes/class-freemius.php +0 -21794
  80. trunk/freemius/includes/class-fs-admin-notices.php +0 -321
  81. trunk/freemius/includes/class-fs-api.php +0 -625
  82. trunk/freemius/includes/class-fs-logger.php +0 -691
  83. trunk/freemius/includes/class-fs-options.php +0 -431
  84. trunk/freemius/includes/class-fs-plugin-updater.php +0 -1360
  85. trunk/freemius/includes/class-fs-security.php +0 -85
  86. trunk/freemius/includes/class-fs-storage.php +0 -524
  87. trunk/freemius/includes/class-fs-user-lock.php +0 -126
  88. trunk/freemius/includes/customizer/class-fs-customizer-support-section.php +0 -102
  89. trunk/freemius/includes/customizer/class-fs-customizer-upsell-control.php +0 -157
  90. trunk/freemius/includes/customizer/index.php +0 -3
  91. trunk/freemius/includes/debug/class-fs-debug-bar-panel.php +0 -64
  92. trunk/freemius/includes/debug/debug-bar-start.php +0 -52
  93. trunk/freemius/includes/debug/index.php +0 -3
  94. trunk/freemius/includes/entities/class-fs-affiliate-terms.php +0 -128
  95. trunk/freemius/includes/entities/class-fs-affiliate.php +0 -84
  96. trunk/freemius/includes/entities/class-fs-billing.php +0 -95
  97. trunk/freemius/includes/entities/class-fs-entity.php +0 -149
  98. trunk/freemius/includes/entities/class-fs-payment.php +0 -110
  99. trunk/freemius/includes/entities/class-fs-plugin-info.php +0 -34
  100. trunk/freemius/includes/entities/class-fs-plugin-license.php +0 -269
  101. trunk/freemius/includes/entities/class-fs-plugin-plan.php +0 -145
  102. trunk/freemius/includes/entities/class-fs-plugin-tag.php +0 -50
  103. trunk/freemius/includes/entities/class-fs-plugin.php +0 -142
  104. trunk/freemius/includes/entities/class-fs-pricing.php +0 -141
  105. trunk/freemius/includes/entities/class-fs-scope-entity.php +0 -29
  106. trunk/freemius/includes/entities/class-fs-site.php +0 -230
  107. trunk/freemius/includes/entities/class-fs-subscription.php +0 -125
  108. trunk/freemius/includes/entities/class-fs-user.php +0 -62
  109. trunk/freemius/includes/entities/index.php +0 -3
  110. trunk/freemius/includes/fs-core-functions.php +0 -1322
  111. trunk/freemius/includes/fs-essential-functions.php +0 -479
  112. trunk/freemius/includes/fs-plugin-info-dialog.php +0 -1143
  113. trunk/freemius/includes/i18n.php +0 -603
  114. trunk/freemius/includes/index.php +0 -3
  115. trunk/freemius/includes/l10n.php +0 -48
  116. trunk/freemius/includes/managers/class-fs-admin-menu-manager.php +0 -969
  117. trunk/freemius/includes/managers/class-fs-admin-notice-manager.php +0 -472
  118. trunk/freemius/includes/managers/class-fs-cache-manager.php +0 -326
  119. trunk/freemius/includes/managers/class-fs-gdpr-manager.php +0 -202
  120. trunk/freemius/includes/managers/class-fs-key-value-storage.php +0 -392
  121. trunk/freemius/includes/managers/class-fs-license-manager.php +0 -104
  122. trunk/freemius/includes/managers/class-fs-option-manager.php +0 -490
  123. trunk/freemius/includes/managers/class-fs-plan-manager.php +0 -162
  124. trunk/freemius/includes/managers/class-fs-plugin-manager.php +0 -220
  125. trunk/freemius/includes/managers/index.php +0 -3
  126. trunk/freemius/includes/sdk/Exceptions/ArgumentNotExistException.php +0 -9
  127. trunk/freemius/includes/sdk/Exceptions/EmptyArgumentException.php +0 -9
  128. trunk/freemius/includes/sdk/Exceptions/Exception.php +0 -74
  129. trunk/freemius/includes/sdk/Exceptions/InvalidArgumentException.php +0 -8
  130. trunk/freemius/includes/sdk/Exceptions/OAuthException.php +0 -12
  131. trunk/freemius/includes/sdk/Exceptions/index.php +0 -3
  132. trunk/freemius/includes/sdk/FreemiusBase.php +0 -215
  133. trunk/freemius/includes/sdk/FreemiusWordPress.php +0 -704
  134. trunk/freemius/includes/sdk/LICENSE.txt +0 -340
  135. trunk/freemius/includes/sdk/index.php +0 -3
  136. trunk/freemius/includes/supplements/fs-essential-functions-1.1.7.1.php +0 -43
  137. trunk/freemius/includes/supplements/fs-essential-functions-2.2.1.php +0 -45
  138. trunk/freemius/includes/supplements/index.php +0 -3
  139. trunk/freemius/index.php +0 -3
  140. trunk/freemius/languages/freemius-da_DK.mo +0 -0
  141. trunk/freemius/languages/freemius-da_DK.po +0 -2434
  142. trunk/freemius/languages/freemius-en.mo +0 -0
  143. trunk/freemius/languages/freemius-en.po +0 -2320
  144. trunk/freemius/languages/freemius-es_ES.mo +0 -0
  145. trunk/freemius/languages/freemius-es_ES.po +0 -2433
  146. trunk/freemius/languages/freemius-fr_FR.mo +0 -0
  147. trunk/freemius/languages/freemius-fr_FR.po +0 -2433
  148. trunk/freemius/languages/freemius-he_IL.mo +0 -0
  149. trunk/freemius/languages/freemius-he_IL.po +0 -2434
  150. trunk/freemius/languages/freemius-hu_HU.mo +0 -0
  151. trunk/freemius/languages/freemius-hu_HU.po +0 -2433
  152. trunk/freemius/languages/freemius-it_IT.mo +0 -0
  153. trunk/freemius/languages/freemius-it_IT.po +0 -2437
  154. trunk/freemius/languages/freemius-ja_JP.mo +0 -0
  155. trunk/freemius/languages/freemius-ja_JP.po +0 -2436
  156. trunk/freemius/languages/freemius-nl_NL.mo +0 -0
  157. trunk/freemius/languages/freemius-nl_NL.po +0 -2434
  158. trunk/freemius/languages/freemius-ru_RU.mo +0 -0
  159. trunk/freemius/languages/freemius-ru_RU.po +0 -2433
  160. trunk/freemius/languages/freemius.pot +0 -2317
  161. trunk/freemius/languages/index.php +0 -3
  162. trunk/freemius/require.php +0 -49
  163. trunk/freemius/start.php +0 -522
  164. trunk/freemius/templates/account.php +0 -792
  165. trunk/freemius/templates/account/billing.php +0 -431
  166. trunk/freemius/templates/account/index.php +0 -3
  167. trunk/freemius/templates/account/partials/activate-license-button.php +0 -54
  168. trunk/freemius/templates/account/partials/addon.php +0 -350
  169. trunk/freemius/templates/account/partials/deactivate-license-button.php +0 -36
  170. trunk/freemius/templates/account/partials/index.php +0 -3
  171. trunk/freemius/templates/account/partials/site.php +0 -336
  172. trunk/freemius/templates/account/payments.php +0 -59
  173. trunk/freemius/templates/add-ons.php +0 -197
  174. trunk/freemius/templates/add-trial-to-pricing.php +0 -31
  175. trunk/freemius/templates/admin-notice.php +0 -76
  176. trunk/freemius/templates/ajax-loader.php +0 -1
  177. trunk/freemius/templates/auto-installation.php +0 -249
  178. trunk/freemius/templates/checkout.php +0 -329
  179. trunk/freemius/templates/connect.php +0 -932
  180. trunk/freemius/templates/contact.php +0 -128
  181. trunk/freemius/templates/debug.php +0 -726
  182. trunk/freemius/templates/debug/api-calls.php +0 -155
  183. trunk/freemius/templates/debug/index.php +0 -3
  184. trunk/freemius/templates/debug/logger.php +0 -66
  185. trunk/freemius/templates/debug/plugins-themes-sync.php +0 -76
  186. trunk/freemius/templates/debug/scheduled-crons.php +0 -136
  187. trunk/freemius/templates/email.php +0 -49
  188. trunk/freemius/templates/firewall-issues-js.php +0 -59
  189. trunk/freemius/templates/forms/affiliation.php +0 -486
  190. trunk/freemius/templates/forms/deactivation/contact.php +0 -23
  191. trunk/freemius/templates/forms/deactivation/form.php +0 -497
  192. trunk/freemius/templates/forms/deactivation/index.php +0 -3
  193. trunk/freemius/templates/forms/deactivation/retry-skip.php +0 -24
  194. trunk/freemius/templates/forms/index.php +0 -3
  195. trunk/freemius/templates/forms/license-activation.php +0 -700
  196. trunk/freemius/templates/forms/optout.php +0 -267
  197. trunk/freemius/templates/forms/premium-versions-upgrade-handler.php +0 -205
  198. trunk/freemius/templates/forms/premium-versions-upgrade-metadata.php +0 -45
  199. trunk/freemius/templates/forms/resend-key.php +0 -247
  200. trunk/freemius/templates/forms/subscription-cancellation.php +0 -277
  201. trunk/freemius/templates/forms/trial-start.php +0 -181
  202. trunk/freemius/templates/gdpr-optin-js.php +0 -66
  203. trunk/freemius/templates/index.php +0 -3
  204. trunk/freemius/templates/js/index.php +0 -3
  205. trunk/freemius/templates/js/jquery.content-change.php +0 -58
  206. trunk/freemius/templates/js/open-license-activation.php +0 -37
  207. trunk/freemius/templates/js/style-premium-theme.php +0 -45
  208. trunk/freemius/templates/partials/network-activation.php +0 -81
  209. trunk/freemius/templates/plugin-icon.php +0 -20
  210. trunk/freemius/templates/plugin-info/description.php +0 -78
  211. trunk/freemius/templates/plugin-info/features.php +0 -114
  212. trunk/freemius/templates/plugin-info/index.php +0 -3
  213. trunk/freemius/templates/plugin-info/screenshots.php +0 -34
  214. trunk/freemius/templates/powered-by.php +0 -58
  215. trunk/freemius/templates/pricing.php +0 -171
  216. trunk/freemius/templates/secure-https-header.php +0 -39
  217. trunk/freemius/templates/sticky-admin-notice-js.php +0 -39
  218. trunk/freemius/templates/tabs-capture-js.php +0 -63
  219. trunk/freemius/templates/tabs.php +0 -190
  220. trunk/img/Yasr-Stylish.png +0 -0
  221. trunk/img/create-ranking.png +0 -0
  222. trunk/img/dark-multi-set.png +0 -0
  223. trunk/img/dialog-ok-apply.png +0 -0
  224. trunk/img/loader.gif +0 -0
  225. trunk/img/paypal.png +0 -0
  226. trunk/img/star_0.svg +0 -2
  227. trunk/img/star_1.svg +0 -2
  228. trunk/img/star_2.svg +0 -5
  229. trunk/img/star_3.svg +0 -5
  230. trunk/img/star_oxy_0.svg +0 -295
  231. trunk/img/star_oxy_1.svg +0 -589
  232. trunk/img/star_tiny.png +0 -0
  233. trunk/img/stars_rater.png +0 -0
  234. trunk/img/stars_rater_oxy.png +0 -0
  235. trunk/img/stars_rater_yasr.png +0 -0
  236. trunk/img/yasr-multi-set-insert-rate-small.jpg +0 -0
  237. trunk/img/yasr-multi-set-insert-rate.jpg +0 -0
  238. trunk/img/yasr-multi-set.png +0 -0
  239. trunk/img/yasr-pro-stars.png +0 -0
  240. trunk/img/yasr-stars-large.png +0 -0
  241. trunk/img/yasr-stars-medium.png +0 -0
  242. trunk/img/yasr-stars-small.png +0 -0
  243. trunk/img/yasr-user-reviews.png +0 -0
  244. trunk/img/yasr_aggregate.jpg +0 -0
  245. trunk/img/yasr_review.png +0 -0
  246. trunk/js/rater-js-rtl.js +0 -314
  247. trunk/js/rater-js.js +0 -303
  248. trunk/js/src/yasr-guten-blocks.js +0 -475
  249. trunk/js/tippy.all.min.js +0 -1
  250. trunk/js/yasr-admin.js +0 -929
  251. trunk/js/yasr-front.js +0 -350
  252. trunk/js/yasr-guten-blocks.js +0 -568
  253. trunk/js/yasr-shortcode-creator.js +0 -17
  254. trunk/languages/yet-another-stars-rating-cs_CZ.mo +0 -0
  255. trunk/languages/yet-another-stars-rating-cs_CZ.po +0 -1163
  256. trunk/languages/yet-another-stars-rating-de_DE.mo +0 -0
  257. trunk/languages/yet-another-stars-rating-de_DE.po +0 -1615
  258. trunk/languages/yet-another-stars-rating-es_ES.mo +0 -0
  259. trunk/languages/yet-another-stars-rating-es_ES.po +0 -1224
  260. trunk/languages/yet-another-stars-rating-fa_IR.mo +0 -0
  261. trunk/languages/yet-another-stars-rating-fa_IR.po +0 -1222
  262. trunk/languages/yet-another-stars-rating-fr_FR.mo +0 -0
  263. trunk/languages/yet-another-stars-rating-fr_FR.po +0 -1384
  264. trunk/languages/yet-another-stars-rating-hr.mo +0 -0
  265. trunk/languages/yet-another-stars-rating-hr.po +0 -1125
  266. trunk/languages/yet-another-stars-rating-it_IT.mo +0 -0
  267. trunk/languages/yet-another-stars-rating-it_IT.po +0 -1494
  268. trunk/languages/yet-another-stars-rating-nb_NO.mo +0 -0
  269. trunk/languages/yet-another-stars-rating-nb_NO.po +0 -1243
  270. trunk/languages/yet-another-stars-rating-nl_NL.mo +0 -0
  271. trunk/languages/yet-another-stars-rating-nl_NL.po +0 -1430
  272. trunk/languages/yet-another-stars-rating-pl_PL.mo +0 -0
  273. trunk/languages/yet-another-stars-rating-pl_PL.po +0 -1187
  274. trunk/languages/yet-another-stars-rating-pt_BR.mo +0 -0
  275. trunk/languages/yet-another-stars-rating-pt_BR.po +0 -1115
  276. trunk/languages/yet-another-stars-rating-ru_RU.mo +0 -0
  277. trunk/languages/yet-another-stars-rating-ru_RU.po +0 -1296
  278. trunk/languages/yet-another-stars-rating.mo +0 -0
  279. trunk/languages/yet-another-stars-rating.pot +0 -1543
  280. trunk/lib/admin/class-wp-list-table.php +0 -1387
  281. trunk/lib/admin/settings/yasr-settings-functions-misc.php +0 -138
  282. trunk/lib/admin/settings/yasr-settings-functions-multiset.php +0 -828
  283. trunk/lib/admin/settings/yasr-settings-functions-style.php +0 -123
  284. trunk/lib/admin/settings/yasr-settings-functions.php +0 -883
  285. trunk/lib/admin/yasr-admin-actions.php +0 -107
  286. trunk/lib/admin/yasr-editor-functions.php +0 -143
  287. trunk/lib/admin/yasr-metabox-multiple-rating.php +0 -104
  288. trunk/lib/admin/yasr-metabox-top-right.php +0 -142
  289. trunk/lib/yasr-ajax-functions.php +0 -1248
  290. trunk/lib/yasr-db-functions.php +0 -968
  291. trunk/lib/yasr-functions.php +0 -1025
  292. trunk/lib/yasr-shortcode-functions.php +0 -1062
  293. trunk/lib/yasr-stats-functions.php +0 -278
  294. trunk/lib/yasr-widgets.php +0 -552
  295. trunk/readme.txt +0 -186
  296. trunk/yasr-settings-page.php +0 -272
  297. trunk/yasr-stats-page.php +0 -101
  298. trunk/yet-another-stars-rating.php +0 -290
  299. yasr-settings-page.php +1 -1
  300. yasr-stats-page.php +37 -35
  301. yet-another-stars-rating.php +8 -7
js/src/yasr-guten-blocks.js CHANGED
@@ -17,6 +17,10 @@ const {
17
InspectorControls
18
} = wp.editor;
19
20
const yasrOptionalText = __('All these settings are optional', 'yet-another-stars-rating');
21
22
const yasrLabelSelectSize = __('Choose Size', 'yet-another-stars-rating');
@@ -31,7 +35,83 @@ const yasrLeaveThisBlankText = __('Leave this blank if you don\'t know what you\
31
const yasrOverallDescription = __('Remember: only the post author can rate here.', 'yet-another-stars-rating');
32
const yasrVisitorVotesDescription = __('This is the star set where your users will be able to vote', 'yet-another-stars-rating');
33
34
-
35
/**
36
* Register: a Gutenberg Block.
37
*
@@ -46,430 +126,504 @@ const yasrVisitorVotesDescription = __('This is the star set where your users wi
46
* registered; otherwise `undefined`.
47
*/
48
49
- registerBlockType(
50
-
51
- 'yet-another-stars-rating/yasr-overall-rating', {
52
- title: __( 'Yasr: Overall Rating', 'yet-another-stars-rating' ),
53
- description: __('Insert the author rating', ''),
54
- icon: 'star-half',
55
- category: 'yet-another-stars-rating',
56
- keywords: [
57
- __('rating', 'yet-another-stars-rating'),
58
- __('author', 'yet-another-stars-rating'),
59
- __('overall', 'yet-another-stars-rating')
60
- ],
61
- attributes: {
62
- //should be needed just overallRatingMeta:
63
- //but, after the post is saved/updated
64
- //the meta filed returns always undefined
65
- //see this bug https://github.com/WordPress/gutenberg/issues/4989
66
- overallRatingMeta: {
67
- type: 'number',
68
- source: 'meta',
69
- meta: 'yasr_overall_rating'
70
- },
71
- overallRatingAttribute: {
72
- type: 'number',
73
- default: 0
74
- },
75
- size: {
76
- type: 'string',
77
- default: '--'
78
- },
79
- postId: {
80
- type: 'number',
81
- default: ''
82
- },
83
},
84
85
- edit:
86
87
- function( props ) {
88
89
- const { attributes: {overallRatingMeta, overallRatingAttribute, size, postId }, setAttributes, isSelected } = props;
90
91
- let overallRating = 0;
92
93
- if (overallRatingAttribute === 0) {
94
- overallRating = overallRatingMeta;
95
- setAttributes( { overallRatingAttribute: overallRatingMeta } );
96
- }
97
- else {
98
- overallRating = overallRatingAttribute;
99
- }
100
101
- let sizeAttribute = null;
102
- let postIdAttribute = null;
103
- let isNum = false;
104
105
- if (size !== '--') {
106
- sizeAttribute = ' size="' + size + '"';
107
- }
108
109
- isNum = /^\d+#x2F;.test(postId);
110
111
- if (postId && isNum === true) {
112
- postIdAttribute = ' postid="' +postId + '"';
113
}
114
115
- class YasrCreateDivRater extends React.Component {
116
117
- constructor(props) {
118
- super(props);
119
- //const divOverall = React.createRef();
120
- }
121
122
- render () {
123
- return (
124
- <div>
125
- <div id="overall-rater" ref={()=>
126
- raterJs({
127
- starSize: 32,
128
- step: 0.1,
129
- showToolTip: false,
130
- rating: overallRating,
131
- readOnly: false,
132
- element: document.querySelector("#overall-rater"),
133
- rateCallback: function rateCallback(rating, done) {
134
135
- rating = rating.toFixed(1);
136
- rating = parseFloat(rating);
137
138
- setAttributes( { overallRatingAttribute: rating } );
139
140
- //show the load. IF insert before setAttributes, doesn't work
141
- jQuery('#loader-overall-rating').show();
142
143
- this.setRating(rating);
144
145
- const currentPostId = wp.data.select("core/editor").getCurrentPostId();
146
147
- var data = {
148
- action: 'yasr_send_overall_rating',
149
- yasr_nonce_overall_rating: yasrConstantGutenberg.nonceOverall,
150
- yasr_overall_rating: rating,
151
- post_id: currentPostId
152
- };
153
154
- //Send value to the Server
155
- jQuery.post(ajaxurl, data, function(response) {
156
- jQuery('#loader-overall-rating').hide();
157
- response = JSON.parse(response);
158
- if (response === 'OK') {
159
- jQuery('#yasr-rateit-overall-value').text('You\'ve rated it: ' + rating);
160
- }
161
- });
162
163
- done();
164
165
- }
166
- })
167
168
- }
169
- />
170
171
- </div>
172
- );
173
- }
174
175
- }
176
177
- function YasrDivRatingOverall (props) {
178
179
- const yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
180
- const yasrLoading = __("Loading, please wait",'yet-another-stars-rating');
181
- const hideLoaderOverall = {display: 'none'};
182
183
- return (
184
- <div>
185
- {yasrOverallRateThis}
186
- <YasrCreateDivRater />
187
188
- <span id="loader-overall-rating" style={hideLoaderOverall}>
189
- {yasrLoading} <img src={yasrCommonDataAdmin.loaderHtml} />
190
- </span>
191
192
- <div id="yasr-rateit-overall-value" >
193
- </div>
194
195
</div>
196
197
- );
198
199
- }
200
201
- function YasrPrintSelectSize () {
202
- return (
203
- <form>
204
- <select value={size} onChange={ yasrSetStarsSize }>
205
- <option value="--">{yasrSelectSizeChoose}</option>
206
- <option value="small">{yasrSelectSizeSmall}</option>
207
- <option value="medium">{yasrSelectSizeMedium}</option>
208
- <option value="large">{yasrSelectSizeLarge}</option>
209
- </select>
210
- </form>
211
- );
212
- }
213
214
- function yasrSetStarsSize(event) {
215
- const selected = event.target.querySelector( 'option:checked' );
216
- setAttributes( { size: selected.value } );
217
- event.preventDefault();
218
- }
219
220
- function YasrPrintInputId() {
221
- return (
222
- <div>
223
- <input type="text" size="4" onKeyPress={yasrSetPostId} />
224
- </div>
225
- );
226
- }
227
228
- function yasrSetPostId (event) {
229
- if (event.key === 'Enter') {
230
- const postIdValue = event.target.value;
231
232
- //postID is always a string, here I check if this string is made only by digits
233
- var isNum = /^\d+#x2F;.test(postIdValue);
234
235
- if (isNum === true) {
236
- setAttributes({postId: postIdValue})
237
- }
238
- event.preventDefault();
239
- }
240
- }
241
242
- function YasrOverallPanel (props) {
243
244
- return (
245
- <InspectorControls>
246
- <div class="yasr-guten-block-panel yasr-guten-block-panel-center">
247
- <YasrDivRatingOverall />
248
- </div>
249
250
- <PanelBody title='Settings'>
251
- <h3>{yasrOptionalText}</h3>
252
253
- <div className="yasr-guten-block-panel">
254
- <label>{yasrLabelSelectSize}</label>
255
- <div>
256
- <YasrPrintSelectSize />
257
- </div>
258
- </div>
259
260
- <div className="yasr-guten-block-panel">
261
- <label>Post ID</label>
262
- <YasrPrintInputId/>
263
- <div className="yasr-guten-block-explain">
264
- {yasrLeaveThisBlankText}
265
- </div>
266
- </div>
267
268
- <div className="yasr-guten-block-panel">
269
- {yasrOverallDescription}
270
- </div>
271
- </PanelBody>
272
- </InspectorControls>
273
- );
274
275
- }
276
277
return (
278
- <Fragment>
279
- <YasrOverallPanel />
280
- <div className={ props.className }>
281
- [yasr_overall_rating{sizeAttribute}{postIdAttribute}]
282
- {isSelected && <YasrPrintSelectSize />}
283
- </div>
284
- </Fragment>
285
);
286
- },
287
-
288
- /**
289
- * The save function defines the way in which the different attributes should be combined
290
- * into the final markup, which is then serialized by Gutenberg into post_content.
291
- *
292
- * The "save" property must be specified and must be a valid function.
293
- *
294
- * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
295
- */
296
- save:
297
- function( props ) {
298
- const { attributes: {overallRatingAttribute, size, postId }} = props;
299
-
300
- console.log(props);
301
-
302
- let yasrOverallAttributes = null;
303
-
304
- if (size) {
305
- yasrOverallAttributes += ' size="' +size+ '"';
306
- }
307
- if (postId) {
308
- yasrOverallAttributes += ' postid="'+postId+'"';
309
- }
310
311
return (
312
- <p>[yasr_overall_rating {yasrOverallAttributes}]</p>
313
);
314
- },
315
-
316
- });
317
-
318
-
319
- registerBlockType(
320
-
321
- 'yet-another-stars-rating/yasr-visitor-votes', {
322
-
323
- title: __( 'Yasr: Visitor Votes', 'yet-another-stars-rating' ),
324
- description: __('Insert the ability for your visitors to vote', 'yet-another-stars-rating'),
325
- icon: 'star-half',
326
- category: 'yet-another-stars-rating',
327
- keywords: [
328
- __('rating', 'yet-another-stars-rating'),
329
- __('visitor', 'yet-another-stars-rating'),
330
- __('votes', 'yet-another-stars-rating')
331
- ],
332
- attributes: {
333
- //name of the attribute
334
- size: {
335
- type: 'string',
336
- default: '--'
337
- },
338
- postId: {
339
- type: 'int',
340
- default: ''
341
- },
342
- },
343
-
344
- edit:
345
346
- function( props ) {
347
348
- const { attributes: { size, postId }, setAttributes, isSelected } = props;
349
350
- let sizeAttribute = null;
351
- let postIdAttribute = null;
352
- let isNum = false;
353
-
354
- isNum = /^\d+#x2F;.test(postId);
355
-
356
- if (size !== '--') {
357
- sizeAttribute = ' size="' + size + '"';
358
}
359
360
- if (postId && isNum === true) {
361
- postIdAttribute = ' postid="' +postId + '"';
362
- }
363
364
365
- function YasrPrintSelectSize () {
366
- return (
367
- <form>
368
- <select value={size} onChange={ yasrSetStarsSize }>
369
- <option value="--">{yasrSelectSizeChoose}</option>
370
- <option value="small">{yasrSelectSizeSmall}</option>
371
- <option value="medium">{yasrSelectSizeMedium}</option>
372
- <option value="large">{yasrSelectSizeLarge}</option>
373
- </select>
374
- </form>
375
- );
376
- }
377
378
- function yasrSetStarsSize(event) {
379
- const selected = event.target.querySelector( 'option:checked' );
380
- setAttributes( { size: selected.value } );
381
- event.preventDefault();
382
- }
383
384
- function YasrPrintInputId() {
385
- return (
386
- <div>
387
- <input type="text" size="4" onKeyPress={yasrSetPostId} />
388
- </div>
389
- );
390
- }
391
392
- function yasrSetPostId (event) {
393
- if (event.key === 'Enter') {
394
- const postIdValue = event.target.value;
395
396
- //postID is always a string, here I check if this string is made only by digits
397
- var isNum = /^\d+#x2F;.test(postIdValue);
398
399
- if (isNum === true) {
400
- setAttributes({postId: postIdValue})
401
- }
402
- event.preventDefault();
403
- }
404
- }
405
406
- function YasrVVPanel (props) {
407
408
- return (
409
- <InspectorControls>
410
411
- <PanelBody title='Settings'>
412
- <h3>{yasrOptionalText}</h3>
413
414
- <div className="yasr-guten-block-panel">
415
- <label>{yasrLabelSelectSize}</label>
416
- <div>
417
- <YasrPrintSelectSize />
418
- </div>
419
</div>
420
421
- <div className="yasr-guten-block-panel">
422
- <label>Post ID</label>
423
- <YasrPrintInputId/>
424
- <div className="yasr-guten-block-explain">
425
- {yasrLeaveThisBlankText}
426
- </div>
427
</div>
428
429
- <div className="yasr-guten-block-panel">
430
- {yasrVisitorVotesDescription}
431
</div>
432
- </PanelBody>
433
- </InspectorControls>
434
- );
435
436
- }
437
438
- return (
439
- <Fragment>
440
- <YasrVVPanel />
441
- <div className={ props.className }>
442
- [yasr_visitor_votes{sizeAttribute}{postIdAttribute}]
443
- {isSelected && <YasrPrintSelectSize />}
444
- </div>
445
- </Fragment>
446
- );
447
- },
448
-
449
- /**
450
- * The save function defines the way in which the different attributes should be combined
451
- * into the final markup, which is then serialized by Gutenberg into post_content.
452
- *
453
- * The "save" property must be specified and must be a valid function.
454
- *
455
- * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
456
- */
457
- save:
458
- function( props ) {
459
- const { attributes: {size, postId} } = props;
460
-
461
- let yasrVVAttributes = null;
462
-
463
- if (size) {
464
- yasrVVAttributes += ' size="' +size+ '"';
465
- }
466
- if (postId) {
467
- yasrVVAttributes += ' postid="'+postId+'"';
468
- }
469
470
- return (
471
- <p>[yasr_visitor_votes {yasrVVAttributes}]</p>
472
- );
473
- },
474
475
});
17
InspectorControls
18
} = wp.editor;
19
20
+ const {
21
+ apiFetch
22
+ } = wp;
23
+
24
const yasrOptionalText = __('All these settings are optional', 'yet-another-stars-rating');
25
26
const yasrLabelSelectSize = __('Choose Size', 'yet-another-stars-rating');
35
const yasrOverallDescription = __('Remember: only the post author can rate here.', 'yet-another-stars-rating');
36
const yasrVisitorVotesDescription = __('This is the star set where your users will be able to vote', 'yet-another-stars-rating');
37
38
+ /******* function to check ajax response *****/
39
+ /*function checkResponse(res) {
40
+ if (res.status >= 400 && res.status < 600) {
41
+ throw new Error(`Failed with status ${res.status}`);
42
+ }
43
+
44
+ return res;
45
+ }*/
46
+
47
+
48
+ function YasrProText () {
49
+
50
+ const YasrProText1 = __('To be able to customize this ranking, you need', 'yet-another-stars-rating');
51
+ const YasrProText2 = __('You can buy the plugin, including one year of support, updates and upgrades, ' +
52
+ 'on yetanotherstarsrating.com', 'yet-another-stars-rating');
53
+
54
+ return (
55
+ <h3>
56
+ {YasrProText1}
57
+ &nbsp;<a href="https://yetanotherstarsrating.com/#yasr-pro">Yasr Pro.</a><br />
58
+ {YasrProText2}
59
+ </h3>
60
+ )
61
+
62
+ }
63
+
64
+ /*function YasrPrintSelectRows () {
65
+
66
+ let optionValueRows = [];
67
+
68
+ for (let i=2; i<=30; i++) {
69
+ if (i === 9) {
70
+ optionValueRows.push(<option value={i} selected disabled>{i}</option>);
71
+ } else {
72
+ optionValueRows.push(<option value={i} disabled>{i}</option>);
73
+ }
74
+
75
+ }
76
+
77
+ return(
78
+ <form>
79
+ <select>
80
+ {optionValueRows}
81
+ </select>
82
+ <span className="dashicons dashicons-lock"></span>
83
+ </form>
84
+ )
85
+
86
+ }
87
+
88
+
89
+ function YasrPrintSelectSize () {
90
+ return (
91
+ <form>
92
+ <select>
93
+ <option value="--">{yasrSelectSizeChoose}</option>
94
+ <option value="small" disabled>{yasrSelectSizeSmall}</option>
95
+ <option value="medium" disabled>{yasrSelectSizeMedium}</option>
96
+ <option value="large" disabled>{yasrSelectSizeLarge}</option>
97
+ </select>
98
+ <span className="dashicons dashicons-lock"></span>
99
+ </form>
100
+ );
101
+ }
102
+
103
+ function YasrPrintTextPosition () {
104
+ return (
105
+ <form>
106
+ <select>
107
+ <option value="before" selected disabled>Before</option>
108
+ <option value="after" disabled>After</option>
109
+ </select>
110
+ <span className="dashicons dashicons-lock"></span>
111
+ </form>
112
+ );
113
+ }
114
+ */
115
/**
116
* Register: a Gutenberg Block.
117
*
126
* registered; otherwise `undefined`.
127
*/
128
129
+ registerBlockType(
130
+ 'yet-another-stars-rating/yasr-overall-rating', {
131
+ title: __( 'Yasr: Overall Rating', 'yet-another-stars-rating' ),
132
+ description: __('Insert the author rating', ''),
133
+ icon: 'star-half',
134
+ category: 'yet-another-stars-rating',
135
+ keywords: [
136
+ __('rating', 'yet-another-stars-rating'),
137
+ __('author', 'yet-another-stars-rating'),
138
+ __('overall', 'yet-another-stars-rating')
139
+ ],
140
+ attributes: {
141
+ //should be needed just overallRatingMeta:
142
+ //but, after the post is saved/updated
143
+ //the meta field returns always undefined
144
+ //see this bug https://github.com/WordPress/gutenberg/issues/4989
145
+ overallRatingMeta: {
146
+ type: 'number',
147
+ source: 'meta',
148
+ meta: 'yasr_overall_rating'
149
+ },
150
+ overallRatingAttribute: {
151
+ type: 'number',
152
+ default: 0
153
},
154
+ size: {
155
+ type: 'string',
156
+ default: '--'
157
+ },
158
+ postId: {
159
+ type: 'number',
160
+ default: ''
161
+ },
162
+ },
163
164
+ edit:
165
166
+ function(props) {
167
168
+ const { attributes: {overallRatingMeta, overallRatingAttribute, size, postId}, setAttributes, isSelected } = props;
169
170
+ let overallRating = 0;
171
172
+ if (overallRatingAttribute === 0) {
173
+ overallRating = overallRatingMeta;
174
+ setAttributes( { overallRatingAttribute: overallRatingMeta } );
175
+ }
176
+ else {
177
+ overallRating = overallRatingAttribute;
178
+ }
179
180
+ let sizeAttribute = null;
181
+ let postIdAttribute = null;
182
+ let isNum = false;
183
184
+ if (size !== '--') {
185
+ sizeAttribute = ' size="' + size + '"';
186
+ }
187
+
188
+ isNum = /^\d+#x2F;.test(postId);
189
190
+ if (postId && isNum === true) {
191
+ postIdAttribute = ' postid="' +postId + '"';
192
+ }
193
194
+ class YasrCreateDivRater extends React.Component {
195
+
196
+ constructor(props) {
197
+ super(props);
198
+ //const divOverall = React.createRef();
199
}
200
201
+ render () {
202
+ return (
203
+ <div>
204
+ <div id="overall-rater" ref={()=>
205
+ raterJs({
206
+ starSize: 32,
207
+ step: 0.1,
208
+ showToolTip: false,
209
+ rating: overallRating,
210
+ readOnly: false,
211
+ element: document.querySelector("#overall-rater"),
212
+ rateCallback: function rateCallback(rating, done) {
213
+
214
+ rating = rating.toFixed(1);
215
+ rating = parseFloat(rating);
216
+
217
+ setAttributes( { overallRatingAttribute: rating } );
218
+
219
+ //show the load. IF insert before setAttributes, doesn't work
220
+ jQuery('#loader-overall-rating').show();
221
+
222
+ this.setRating(rating);
223
+
224
+ const currentPostId = wp.data.select("core/editor").getCurrentPostId();
225
+
226
+ var data = {
227
+ action: 'yasr_send_overall_rating',
228
+ yasr_nonce_overall_rating: yasrConstantGutenberg.nonceOverall,
229
+ yasr_overall_rating: rating,
230
+ post_id: currentPostId
231
+ };
232
+
233
+ //Send value to the Server
234
+ jQuery.post(ajaxurl, data, function(response) {
235
+ jQuery('#loader-overall-rating').hide();
236
+ response = JSON.parse(response);
237
+ if (response === 'OK') {
238
+ jQuery('#yasr-rateit-overall-value').text('You\'ve rated it: ' + rating);
239
+ }
240
+ });
241
+
242
+ done();
243
244
+ }
245
+ })
246
247
+ }
248
+ />
249
250
+ </div>
251
+ );
252
+ }
253
254
+ }
255
256
+ function YasrDivRatingOverall (props) {
257
258
+ const yasrOverallRateThis = __("Rate this article / item", 'yet-another-stars-rating');
259
+ const yasrLoading = __("Loading, please wait",'yet-another-stars-rating');
260
+ const hideLoaderOverall = {display: 'none'};
261
262
+ return (
263
+ <div>
264
+ {yasrOverallRateThis}
265
+ <YasrCreateDivRater />
266
267
+ <span id="loader-overall-rating" style={hideLoaderOverall}>
268
+ {yasrLoading} <img src={yasrCommonDataAdmin.loaderHtml} />
269
+ </span>
270
271
+ <div id="yasr-rateit-overall-value" >
272
+ </div>
273
274
+ </div>
275
276
+ );
277
278
+ }
279
280
+ function YasrPrintSelectSize () {
281
+ return (
282
+ <form>
283
+ <select value={size} onChange={ yasrSetStarsSize }>
284
+ <option value="--">{yasrSelectSizeChoose}</option>
285
+ <option value="small">{yasrSelectSizeSmall}</option>
286
+ <option value="medium">{yasrSelectSizeMedium}</option>
287
+ <option value="large">{yasrSelectSizeLarge}</option>
288
+ </select>
289
+ </form>
290
+ );
291
+ }
292
293
+ function yasrSetStarsSize(event) {
294
+ const selected = event.target.querySelector( 'option:checked' );
295
+ setAttributes( { size: selected.value } );
296
+ event.preventDefault();
297
+ }
298
299
+ function YasrPrintInputId() {
300
+ return (
301
+ <div>
302
+ <input type="text" size="4" onKeyPress={yasrSetPostId} />
303
+ </div>
304
+ );
305
+ }
306
307
+ function yasrSetPostId (event) {
308
+ if (event.key === 'Enter') {
309
+ const postIdValue = event.target.value;
310
311
+ //postID is always a string, here I check if this string is made only by digits
312
+ var isNum = /^\d+#x2F;.test(postIdValue);
313
314
+ if (isNum === true) {
315
+ setAttributes({postId: postIdValue})
316
+ }
317
+ event.preventDefault();
318
+ }
319
+ }
320
321
+ function YasrOverallPanel (props) {
322
323
+ return (
324
+ <InspectorControls>
325
+ <div class="yasr-guten-block-panel yasr-guten-block-panel-center">
326
+ <YasrDivRatingOverall />
327
</div>
328
329
+ <PanelBody title='Settings'>
330
+ <h3>{yasrOptionalText}</h3>
331
332
+ <div className="yasr-guten-block-panel">
333
+ <label>{yasrLabelSelectSize}</label>
334
+ <div>
335
+ <YasrPrintSelectSize />
336
+ </div>
337
+ </div>
338
339
+ <div className="yasr-guten-block-panel">
340
+ <label>Post ID</label>
341
+ <YasrPrintInputId/>
342
+ <div className="yasr-guten-block-explain">
343
+ {yasrLeaveThisBlankText}
344
+ </div>
345
+ </div>
346
347
+ <div className="yasr-guten-block-panel">
348
+ {yasrOverallDescription}
349
+ </div>
350
+ </PanelBody>
351
+ </InspectorControls>
352
+ );
353
354
+ }
355
+
356
+ return (
357
+ <Fragment>
358
+ <YasrOverallPanel />
359
+ <div className={ props.className }>
360
+ [yasr_overall_rating{sizeAttribute}{postIdAttribute}]
361
+ {isSelected && <YasrPrintSelectSize />}
362
+ </div>
363
+ </Fragment>
364
+ );
365
+ },
366
367
+ /**
368
+ * The save function defines the way in which the different attributes should be combined
369
+ * into the final markup, which is then serialized by Gutenberg into post_content.
370
+ *
371
+ * The "save" property must be specified and must be a valid function.
372
+ *
373
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
374
+ */
375
+ save:
376
+ function( props ) {
377
+ const {attributes: {size, postId}} = props;
378
+
379
+ let yasrOverallAttributes = null;
380
+
381
+ if (size) {
382
+ yasrOverallAttributes += ' size="' +size+ '"';
383
+ }
384
+ if (postId) {
385
+ yasrOverallAttributes += ' postid="'+postId+'"';
386
+ }
387
+
388
+ return (
389
+ <p>[yasr_overall_rating {yasrOverallAttributes}]</p>
390
+ );
391
+ },
392
393
+ });
394
+
395
+ registerBlockType(
396
+ 'yet-another-stars-rating/yasr-visitor-votes', {
397
+
398
+ title: __( 'Yasr: Visitor Votes', 'yet-another-stars-rating' ),
399
+ description: __('Insert the ability for your visitors to vote', 'yet-another-stars-rating'),
400
+ icon: 'star-half',
401
+ category: 'yet-another-stars-rating',
402
+ keywords: [
403
+ __('rating', 'yet-another-stars-rating'),
404
+ __('visitor', 'yet-another-stars-rating'),
405
+ __('votes', 'yet-another-stars-rating')
406
+ ],
407
+ attributes: {
408
+ //name of the attribute
409
+ size: {
410
+ type: 'string',
411
+ default: '--'
412
+ },
413
+ postId: {
414
+ type: 'number',
415
+ default: ''
416
+ },
417
+ },
418
419
+ edit:
420
421
+ function( props ) {
422
423
+ const { attributes: { size, postId }, setAttributes, isSelected } = props;
424
425
+ let sizeAttribute = null;
426
+ let postIdAttribute = null;
427
+ let isNum = false;
428
429
+ isNum = /^\d+#x2F;.test(postId);
430
431
+ if (size !== '--') {
432
+ sizeAttribute = ' size="' + size + '"';
433
+ }
434
435
+ if (postId && isNum === true) {
436
+ postIdAttribute = ' postid="' +postId + '"';
437
+ }
438
439
440
+ function YasrPrintSelectSize () {
441
return (
442
+ <form>
443
+ <select value={size} onChange={ yasrSetStarsSize }>
444
+ <option value="--">{yasrSelectSizeChoose}</option>
445
+ <option value="small">{yasrSelectSizeSmall}</option>
446
+ <option value="medium">{yasrSelectSizeMedium}</option>
447
+ <option value="large">{yasrSelectSizeLarge}</option>
448
+ </select>
449
+ </form>
450
);
451
+ }
452
453
+ function yasrSetStarsSize(event) {
454
+ const selected = event.target.querySelector( 'option:checked' );
455
+ setAttributes( { size: selected.value } );
456
+ event.preventDefault();
457
+ }
458
+
459
+ function YasrPrintInputId() {
460
return (
461
+ <div>
462
+ <input type="text" size="4" onKeyPress={yasrSetPostId} />
463
+ </div>
464
);
465
+ }
466
467
+ function yasrSetPostId (event) {
468
+ if (event.key === 'Enter') {
469
+ const postIdValue = event.target.value;
470
471
+ //postID is always a string, here I check if this string is made only by digits
472
+ var isNum = /^\d+#x2F;.test(postIdValue);
473
474
+ if (isNum === true) {
475
+ setAttributes({postId: postIdValue})
476
+ }
477
+ event.preventDefault();
478
}
479
+ }
480
481
+ function YasrVVPanel (props) {
482
483
+ return (
484
+ <InspectorControls>
485
+ <PanelBody title='Settings'>
486
+ <h3>{yasrOptionalText}</h3>
487
+
488
+ <div className="yasr-guten-block-panel">
489
+ <label>{yasrLabelSelectSize}</label>
490
+ <div>
491
+ <YasrPrintSelectSize />
492
+ </div>
493
+ </div>
494
495
+ <div className="yasr-guten-block-panel">
496
+ <label>Post ID</label>
497
+ <YasrPrintInputId/>
498
+ <div className="yasr-guten-block-explain">
499
+ {yasrLeaveThisBlankText}
500
+ </div>
501
+ </div>
502
503
+ <div className="yasr-guten-block-panel">
504
+ {yasrVisitorVotesDescription}
505
+ </div>
506
+ </PanelBody>
507
+ </InspectorControls>
508
+ );
509
510
+ }
511
+
512
+ return (
513
+ <Fragment>
514
+ <YasrVVPanel />
515
+ <div className={props.className}>
516
+ [yasr_visitor_votes{sizeAttribute}{postIdAttribute}]
517
+ {isSelected && <YasrPrintSelectSize />}
518
+ </div>
519
+ </Fragment>
520
+ );
521
+ },
522
523
+ /**
524
+ * The save function defines the way in which the different attributes should be combined
525
+ * into the final markup, which is then serialized by Gutenberg into post_content.
526
+ *
527
+ * The "save" property must be specified and must be a valid function.
528
+ *
529
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
530
+ */
531
+ save:
532
+ function( props ) {
533
+ const { attributes: {size, postId} } = props;
534
+
535
+ let yasrVVAttributes = null;
536
+
537
+ if (size) {
538
+ yasrVVAttributes += ' size="' +size+ '"';
539
+ }
540
+ if (postId) {
541
+ yasrVVAttributes += ' postid="'+postId+'"';
542
+ }
543
+
544
+ return (
545
+ <p>[yasr_visitor_votes {yasrVVAttributes}]</p>
546
+ );
547
+ },
548
549
+ });
550
551
+ registerBlockType(
552
+ 'yet-another-stars-rating/overall-rating-ranking', {
553
554
+ title: __('Yasr: Top 10 Highest rated', 'yet-another-stars-rating'),
555
+ description: __(
556
+ 'This ranking shows the highest rated posts rated through the overall_rating shortcode.',
557
+ 'yet-another-stars-rating'
558
+ ),
559
+ icon: 'star-half',
560
+ category: 'yet-another-stars-rating',
561
+ keywords: [
562
+ __('ranking', 'yet-another-stars-rating'),
563
+ __('highest', 'yet-another-stars-rating'),
564
+ __('chart', 'yet-another-stars-rating')
565
+ ],
566
567
+ edit:
568
+
569
+ function(props) {
570
571
+ function YasrTopOverallPanel (props) {
572
573
+ return (
574
+ <InspectorControls>
575
+ <PanelBody title='Settings'>
576
+ <YasrProText/>
577
+
578
+ /*<div className="yasr-guten-block-panel">
579
+ <label>{yasrLabelSelectSize}</label>
580
+ <div>
581
+ <YasrPrintSelectRows />
582
</div>
583
+ </div>
584
585
+ <div className="yasr-guten-block-panel">
586
+ <label>{yasrLabelSelectSize}</label>
587
+ <div>
588
+ <YasrPrintSelectSize />
589
</div>
590
+ </div>
591
592
+ <div className="yasr-guten-block-panel">
593
+ <label>{yasrLabelSelectSize}</label>
594
+ <div>
595
+ <YasrPrintTextPosition />
596
</div>
597
+ </div>*/
598
+ </PanelBody>
599
+ </InspectorControls>
600
+ );
601
602
+ }
603
604
+ return (
605
+ <Fragment>
606
+ <YasrTopOverallPanel />
607
+ <div className={props.className}>
608
+ [yasr_top_ten_highest_rated]
609
+ </div>
610
+ </Fragment>
611
+ );
612
+ },
613
614
+ /**
615
+ * The save function defines the way in which the different attributes should be combined
616
+ * into the final markup, which is then serialized by Gutenberg into post_content.
617
+ *
618
+ * The "save" property must be specified and must be a valid function.
619
+ *
620
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
621
+ */
622
+ save:
623
+ function(props) {
624
+ return (
625
+ <p>[yasr_top_ten_highest_rated]</p>
626
+ );
627
+ },
628
629
});
js/yasr-admin.js CHANGED
@@ -240,17 +240,16 @@ function yasrSetRaterAdminMulti (postid, setId, nonceMulti) {
240
if (jQuery(this).is(':checked')) {
241
242
jQuery('.yasr-general-options-text-before').prop('disabled', false);
243
- jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');
244
- jQuery('#yasr-general-options-custom-text-before-visitor').val('Our Reader Score');
245
jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');
246
- jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted for this article');
247
248
}
249
250
else {
251
-
252
jQuery('.yasr-general-options-text-before').prop('disabled', true);
253
-
254
}
255
256
});
240
if (jQuery(this).is(':checked')) {
241
242
jQuery('.yasr-general-options-text-before').prop('disabled', false);
243
+ jQuery('#yasr-general-options-custom-text-before-overall').val('Our Score');
244
+ jQuery('#yasr-general-options-custom-text-before-visitor').val('Our Reader Score');
245
jQuery('#yasr-general-options-custom-text-after-visitor').val('[Total: %total_count% Average: %average%]');
246
+ jQuery('#yasr-general-options-custom-text-must-sign-in').val('You must sign in to vote');
247
+ jQuery('#yasr-general-options-custom-text-already-rated').val('You have already voted for this article');
248
249
}
250
251
else {
252
jQuery('.yasr-general-options-text-before').prop('disabled', true);
253
}
254
255
});
js/yasr-guten-blocks.js CHANGED
@@ -17,6 +17,8 @@ var Fragment = wp.element.Fragment;
17
var _wp$editor = wp.editor,
18
BlockControls = _wp$editor.BlockControls,
19
InspectorControls = _wp$editor.InspectorControls;
20
21
22
var yasrOptionalText = __('All these settings are optional', 'yet-another-stars-rating');
@@ -33,6 +35,86 @@ var yasrLeaveThisBlankText = __('Leave this blank if you don\'t know what you\'r
33
var yasrOverallDescription = __('Remember: only the post author can rate here.', 'yet-another-stars-rating');
34
var yasrVisitorVotesDescription = __('This is the star set where your users will be able to vote', 'yet-another-stars-rating');
35
36
/**
37
* Register: a Gutenberg Block.
38
*
@@ -56,7 +138,7 @@ registerBlockType('yet-another-stars-rating/yasr-overall-rating', {
56
attributes: {
57
//should be needed just overallRatingMeta:
58
//but, after the post is saved/updated
59
- //the meta filed returns always undefined
60
//see this bug https://github.com/WordPress/gutenberg/issues/4989
61
overallRatingMeta: {
62
type: 'number',
@@ -339,13 +421,10 @@ registerBlockType('yet-another-stars-rating/yasr-overall-rating', {
339
*/
340
save: function save(props) {
341
var _props$attributes2 = props.attributes,
342
- overallRatingAttribute = _props$attributes2.overallRatingAttribute,
343
size = _props$attributes2.size,
344
postId = _props$attributes2.postId;
345
346
347
- console.log(props);
348
-
349
var yasrOverallAttributes = null;
350
351
if (size) {
@@ -380,7 +459,7 @@ registerBlockType('yet-another-stars-rating/yasr-visitor-votes', {
380
default: '--'
381
},
382
postId: {
383
- type: 'int',
384
default: ''
385
}
386
},
@@ -565,4 +644,101 @@ registerBlockType('yet-another-stars-rating/yasr-visitor-votes', {
565
);
566
}
567
568
});
17
var _wp$editor = wp.editor,
18
BlockControls = _wp$editor.BlockControls,
19
InspectorControls = _wp$editor.InspectorControls;
20
+ var _wp = wp,
21
+ apiFetch = _wp.apiFetch;
22
23
24
var yasrOptionalText = __('All these settings are optional', 'yet-another-stars-rating');
35
var yasrOverallDescription = __('Remember: only the post author can rate here.', 'yet-another-stars-rating');
36
var yasrVisitorVotesDescription = __('This is the star set where your users will be able to vote', 'yet-another-stars-rating');
37
38
+ /******* function to check ajax response *****/
39
+ /*function checkResponse(res) {
40
+ if (res.status >= 400 && res.status < 600) {
41
+ throw new Error(`Failed with status ${res.status}`);
42
+ }
43
+
44
+ return res;
45
+ }*/
46
+
47
+ function YasrProText() {
48
+
49
+ var YasrProText1 = __('To be able to customize this ranking, you need', 'yet-another-stars-rating');
50
+ var YasrProText2 = __('You can buy the plugin, including one year of support, updates and upgrades, ' + 'on yetanotherstarsrating.com', 'yet-another-stars-rating');
51
+
52
+ return React.createElement(
53
+ 'h3',
54
+ null,
55
+ YasrProText1,
56
+ '\xA0',
57
+ React.createElement(
58
+ 'a',
59
+ { href: 'https://yetanotherstarsrating.com/#yasr-pro' },
60
+ 'Yasr Pro.'
61
+ ),
62
+ React.createElement('br', null),
63
+ YasrProText2
64
+ );
65
+ }
66
+
67
+ /*function YasrPrintSelectRows () {
68
+
69
+ let optionValueRows = [];
70
+
71
+ for (let i=2; i<=30; i++) {
72
+ if (i === 9) {
73
+ optionValueRows.push(<option value={i} selected disabled>{i}</option>);
74
+ } else {
75
+ optionValueRows.push(<option value={i} disabled>{i}</option>);
76
+ }
77
+
78
+ }
79
+
80
+ return(
81
+ <form>
82
+ <select>
83
+ {optionValueRows}
84
+ </select>
85
+ <span className="dashicons dashicons-lock"></span>
86
+ </form>
87
+ )
88
+
89
+ }
90
+
91
+
92
+ function YasrPrintSelectSize () {
93
+ return (
94
+ <form>
95
+ <select>
96
+ <option value="--">{yasrSelectSizeChoose}</option>
97
+ <option value="small" disabled>{yasrSelectSizeSmall}</option>
98
+ <option value="medium" disabled>{yasrSelectSizeMedium}</option>
99
+ <option value="large" disabled>{yasrSelectSizeLarge}</option>
100
+ </select>
101
+ <span className="dashicons dashicons-lock"></span>
102
+ </form>
103
+ );
104
+ }
105
+
106
+ function YasrPrintTextPosition () {
107
+ return (
108
+ <form>
109
+ <select>
110
+ <option value="before" selected disabled>Before</option>
111
+ <option value="after" disabled>After</option>
112
+ </select>
113
+ <span className="dashicons dashicons-lock"></span>
114
+ </form>
115
+ );
116
+ }
117
+ */
118
/**
119
* Register: a Gutenberg Block.
120
*
138
attributes: {
139
//should be needed just overallRatingMeta:
140
//but, after the post is saved/updated
141
+ //the meta field returns always undefined
142
//see this bug https://github.com/WordPress/gutenberg/issues/4989
143
overallRatingMeta: {
144
type: 'number',
421
*/
422
save: function save(props) {
423
var _props$attributes2 = props.attributes,
424
size = _props$attributes2.size,
425
postId = _props$attributes2.postId;
426
427
428
var yasrOverallAttributes = null;
429
430
if (size) {
459
default: '--'
460
},
461
postId: {
462
+ type: 'number',
463
default: ''
464
}
465
},
644
);
645
}
646
647
+ });
648
+
649
+ registerBlockType('yet-another-stars-rating/overall-rating-ranking', {
650
+
651
+ title: __('Yasr: Top 10 Highest rated', 'yet-another-stars-rating'),
652
+ description: __('This ranking shows the highest rated posts rated through the overall_rating shortcode.', 'yet-another-stars-rating'),
653
+ icon: 'star-half',
654
+ category: 'yet-another-stars-rating',
655
+ keywords: [__('ranking', 'yet-another-stars-rating'), __('highest', 'yet-another-stars-rating'), __('chart', 'yet-another-stars-rating')],
656
+
657
+ edit: function edit(props) {
658
+
659
+ function YasrTopOverallPanel(props) {
660
+
661
+ return React.createElement(
662
+ InspectorControls,
663
+ null,
664
+ React.createElement(
665
+ PanelBody,
666
+ { title: 'Settings' },
667
+ React.createElement(YasrProText, null),
668
+ /*,
669
+ React.createElement(
670
+ 'div',
671
+ { className: 'yasr-guten-block-panel' },
672
+ React.createElement(
673
+ 'label',
674
+ null,
675
+ yasrLabelSelectSize
676
+ ),
677
+ React.createElement(
678
+ 'div',
679
+ null,
680
+ React.createElement(YasrPrintSelectRows, null)
681
+ )
682
+ ),
683
+ React.createElement(
684
+ 'div',
685
+ { className: 'yasr-guten-block-panel' },
686
+ React.createElement(
687
+ 'label',
688
+ null,
689
+ yasrLabelSelectSize
690
+ ),
691
+ React.createElement(
692
+ 'div',
693
+ null,
694
+ React.createElement(YasrPrintSelectSize, null)
695
+ )
696
+ ),
697
+ React.createElement(
698
+ 'div',
699
+ { className: 'yasr-guten-block-panel' },
700
+ React.createElement(
701
+ 'label',
702
+ null,
703
+ yasrLabelSelectSize
704
+ ),
705
+ React.createElement(
706
+ 'div',
707
+ null,
708
+ React.createElement(YasrPrintTextPosition, null)
709
+ )
710
+ ),
711
+ */
712
+ )
713
+ );
714
+ }
715
+
716
+ return React.createElement(
717
+ Fragment,
718
+ null,
719
+ React.createElement(YasrTopOverallPanel, null),
720
+ React.createElement(
721
+ 'div',
722
+ { className: props.className },
723
+ '[yasr_top_ten_highest_rated]'
724
+ )
725
+ );
726
+ },
727
+
728
+ /**
729
+ * The save function defines the way in which the different attributes should be combined
730
+ * into the final markup, which is then serialized by Gutenberg into post_content.
731
+ *
732
+ * The "save" property must be specified and must be a valid function.
733
+ *
734
+ * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
735
+ */
736
+ save: function save(props) {
737
+ return React.createElement(
738
+ 'p',
739
+ null,
740
+ '[yasr_top_ten_highest_rated]'
741
+ );
742
+ }
743
+
744
});
lib/admin/{yasr-editor-functions.php → editor/yasr-editor-functions.php} RENAMED
@@ -18,42 +18,54 @@ You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>
19
*/
20
21
- if ( ! defined( 'ABSPATH' ) ) exit('You\'re not allowed to see this page'); // Exit if accessed directly
22
23
//this load guten-block.js, only in admin side
24
add_action('enqueue_block_editor_assets', 'yasr_gutenberg_scripts');
25
26
- function yasr_gutenberg_scripts () {
27
28
- //Script
29
- wp_enqueue_script( 'yasr_blocks', YASR_JS_DIR . '/yasr-guten-blocks.js', array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ) );
30
31
}
32
33
//This filter is used to add a new category in gutenberg
34
- add_filter( 'block_categories', 'yasr_add_gutenberg_category', 10, 2);
35
-
36
- function yasr_add_gutenberg_category ($categories) {
37
- return array_merge(
38
- $categories,
39
- array(
40
- array(
41
- 'slug' => 'yet-another-stars-rating',
42
- 'title' => 'Yasr: Yet Another Stars Rating',
43
- ),
44
- )
45
- );
46
- };
47
48
add_action('yasr_add_admin_scripts_end', 'yasr_add_js_constant_gutenberg');
49
50
- function yasr_add_js_constant_gutenberg ($hook) {
51
52
if ($hook === 'post.php' || $hook === 'post-new.php') {
53
54
- $ajax_nonce_overall = wp_create_nonce( "yasr_nonce_overall_rating_action" );
55
-
56
- wp_localize_script ('yasradmin', 'yasrConstantGutenberg',
57
array(
58
'nonceOverall' => $ajax_nonce_overall
59
)
@@ -63,23 +75,23 @@ function yasr_add_js_constant_gutenberg ($hook) {
63
64
}
65
66
- //This will add to the gutnberg rest yasr_overall_rating meta field
67
- add_action( 'init', 'yasr_gutenberg_show_in_rest_overall_meta' );
68
-
69
- function yasr_gutenberg_show_in_rest_overall_meta() {
70
- register_meta( 'post', 'yasr_overall_rating',
71
- array(
72
- 'show_in_rest' => true,
73
- 'single' => true,
74
- 'type' => 'number',
75
- )
76
- );
77
- }
78
79
80
/****** Create 2 metaboxes in post and pages ******/
81
82
- add_action( 'add_meta_boxes', 'yasr_add_metaboxes' );
83
84
function yasr_add_metaboxes() {
85
@@ -90,17 +102,19 @@ function yasr_add_metaboxes() {
90
$custom_post_types = yasr_get_custom_post_type();
91
92
if ($custom_post_types) {
93
-
94
//First merge array then changes keys to int
95
$post_type_where_display_metabox = array_values(array_merge($post_type_where_display_metabox, $custom_post_types));
96
-
97
}
98
99
//For classic editor, add this metabox
100
foreach ($post_type_where_display_metabox as $post_type) {
101
- add_meta_box( 'yasr_metabox_overall_rating',
102
- 'YASR', 'yasr_metabox_overall_rating_content', $post_type,
103
- 'side', 'high',
104
//Set this to true, so this metabox will be only loaded to classic editor
105
array(
106
'__back_compat_meta_box' => true,
@@ -108,11 +122,18 @@ function yasr_add_metaboxes() {
108
);
109
}
110
111
- $multi_set=yasr_get_multi_set();
112
//If multiset are used then add the second metabox
113
if ($multi_set) {
114
foreach ($post_type_where_display_metabox as $post_type) {
115
- add_meta_box( 'yasr_metabox_multiple_rating', __( 'Yet Another Stars Rating: Multiple set', 'yet-another-stars-rating' ), 'yasr_metabox_multiple_rating_content', $post_type, 'normal', 'high' );
116
}
117
}
118
@@ -120,10 +141,9 @@ function yasr_add_metaboxes() {
120
121
function yasr_metabox_overall_rating_content() {
122
123
- if ( current_user_can( 'publish_posts' ) ) {
124
- include(YASR_ABSOLUTE_PATH . '/lib/admin/yasr-metabox-top-right.php');
125
- }
126
- else {
127
_e("You don't have enought privileges to insert Overall Rating");
128
}
129
@@ -131,10 +151,9 @@ function yasr_metabox_overall_rating_content() {
131
132
function yasr_metabox_multiple_rating_content() {
133
134
- if ( current_user_can( 'publish_posts' ) ) {
135
- include(YASR_ABSOLUTE_PATH . '/lib/admin/yasr-metabox-multiple-rating.php');
136
- }
137
- else {
138
_e("You don't have enough privileges to insert a Multi Set");
139
}
140
18
along with this program. If not, see <http://www.gnu.org/licenses/>
19
*/
20
21
+ if (!defined('ABSPATH')) {
22
+ exit('You\'re not allowed to see this page');
23
+ } // Exit if accessed directly
24
25
//this load guten-block.js, only in admin side
26
add_action('enqueue_block_editor_assets', 'yasr_gutenberg_scripts');
27
28
+ function yasr_gutenberg_scripts() {
29
30
+ //Script
31
+ wp_enqueue_script('yasr_blocks', YASR_JS_DIR . 'yasr-guten-blocks.js', array(
32
+ 'wp-blocks',
33
+ 'wp-i18n',
34
+ 'wp-element',
35
+ 'wp-components',
36
+ 'wp-editor',
37
+ 'wp-api-fetch'
38
+ ));
39
40
}
41
42
//This filter is used to add a new category in gutenberg
43
+ add_filter('block_categories', 'yasr_add_gutenberg_category', 10, 2);
44
+
45
+ function yasr_add_gutenberg_category($categories) {
46
+ return array_merge(
47
+ $categories,
48
+ array(
49
+ array(
50
+ 'slug' => 'yet-another-stars-rating',
51
+ 'title' => 'Yasr: Yet Another Stars Rating',
52
+ ),
53
+ )
54
+ );
55
+ }
56
+
57
+ ;
58
59
add_action('yasr_add_admin_scripts_end', 'yasr_add_js_constant_gutenberg');
60
61
+ function yasr_add_js_constant_gutenberg($hook) {
62
63
if ($hook === 'post.php' || $hook === 'post-new.php') {
64
+ $ajax_nonce_overall = wp_create_nonce("yasr_nonce_overall_rating_action");
65
66
+ wp_localize_script(
67
+ 'yasradmin',
68
+ 'yasrConstantGutenberg',
69
array(
70
'nonceOverall' => $ajax_nonce_overall
71
)
75
76
}
77
78
+ //This will add to the gutenberg rest yasr_overall_rating meta field
79
+ add_action('init', 'yasr_gutenberg_show_in_rest_overall_meta');
80
+
81
+ function yasr_gutenberg_show_in_rest_overall_meta() {
82
+ register_meta('post', 'yasr_overall_rating',
83
+ array(
84
+ 'show_in_rest' => true,
85
+ 'single' => true,
86
+ 'type' => 'number'
87
+ )
88
+ );
89
+ }
90
91
92
/****** Create 2 metaboxes in post and pages ******/
93
94
+ add_action('add_meta_boxes', 'yasr_add_metaboxes');
95
96
function yasr_add_metaboxes() {
97
102
$custom_post_types = yasr_get_custom_post_type();
103
104
if ($custom_post_types) {
105
//First merge array then changes keys to int
106
$post_type_where_display_metabox = array_values(array_merge($post_type_where_display_metabox, $custom_post_types));
107
}
108
109
//For classic editor, add this metabox
110
foreach ($post_type_where_display_metabox as $post_type) {
111
+ add_meta_box(
112
+ 'yasr_metabox_overall_rating',
113
+ 'YASR',
114
+ 'yasr_metabox_overall_rating_content',
115
+ $post_type,
116
+ 'side',
117
+ 'high',
118
//Set this to true, so this metabox will be only loaded to classic editor
119
array(
120
'__back_compat_meta_box' => true,
122
);
123
}
124
125
+ $multi_set = yasr_get_multi_set();
126
//If multiset are used then add the second metabox
127
if ($multi_set) {
128
foreach ($post_type_where_display_metabox as $post_type) {
129
+ add_meta_box(
130
+ 'yasr_metabox_multiple_rating',
131
+ __('Yet Another Stars Rating: Multiple set', 'yet-another-stars-rating'),
132
+ 'yasr_metabox_multiple_rating_content',
133
+ $post_type,
134
+ 'normal',
135
+ 'high'
136
+ );
137
}
138
}
139
141
142
function yasr_metabox_overall_rating_content() {
143
144
+ if (current_user_can('publish_posts')) {
145
+ include(YASR_ABSOLUTE_PATH . '/lib/admin/editor/yasr-metabox-top-right.php');
146
+ } else {
147
_e("You don't have enought privileges to insert Overall Rating");
148
}
149
151
152
function yasr_metabox_multiple_rating_content() {
153
154
+ if (current_user_can('publish_posts')) {
155
+ include(YASR_ABSOLUTE_PATH . '/lib/admin/editor/yasr-metabox-multiple-rating.php');
156
+ } else {
157
_e("You don't have enough privileges to insert a Multi Set");
158
}
159
lib/admin/{yasr-metabox-multiple-rating.php → editor/yasr-metabox-multiple-rating.php} RENAMED
File without changes
lib/admin/{yasr-metabox-top-right.php → editor/yasr-metabox-top-right.php} RENAMED
File without changes
lib/admin/settings/yasr-settings-functions-misc.php CHANGED
@@ -1,42 +1,41 @@
1
<?php
2
3
- function yasr_upgrade_pro_box ($position=FALSE) {
4
5
- if ( yasr_fs()->is_free_plan() ) {
6
7
- if ( $position && $position == "bottom" ) {
8
- $yasr_upgrade_class = "yasr-donatedivbottom";
9
- }
10
11
- else {
12
- $yasr_upgrade_class = "yasr-donatedivdx";
13
- }
14
15
- ?>
16
17
- <div class="<?php echo $yasr_upgrade_class ?>" style="display: none">
18
19
- <h2 style="color: #34A7C1">
20
- <?php _e( 'Upgrade to YASR Pro', 'yet-another-stars-rating' ); ?>
21
- </h2>
22
23
- <div class="yasr-upgrade-to-pro">
24
- <ul>
25
- <li><strong><?php _e( ' User Reviews', 'yet-another-stars-rating' ); ?></strong></li>
26
- <li><strong><?php _e( ' Custom Rankings', 'yet-another-stars-rating' ); ?></strong></li>
27
- <li><strong><?php _e( ' 20 + ready to use themes', 'yet-another-stars-rating' ); ?></strong></li>
28
- <li><strong><?php _e( ' Upload your own theme', 'yet-another-stars-rating' ); ?></strong></li>
29
- <li><strong><?php _e( ' Dedicate support', 'yet-another-stars-rating' ); ?></strong></li>
30
- </ul>
31
- <a href="<?php echo yasr_fs()->get_upgrade_url(); ?>"><button class="button button-primary">Upgrade Now</button></a>
32
33
- </div>
34
35
- </div>
36
-
37
- <?php
38
-
39
- }
40
41
}
42
@@ -46,92 +45,91 @@ function yasr_upgrade_pro_box ($position=FALSE) {
46
* Since version 0.9.0
47
*/
48
49
- function yasr_ask_rating ($position=FALSE) {
50
-
51
- $transient = get_site_transient ('yasr_hide_ask_rating');
52
-
53
- if (!$transient) {
54
55
- if ($position && $position == "bottom") {
56
- $yasr_metabox_class = "yasr-donatedivbottom";
57
- }
58
59
- else {
60
- $yasr_metabox_class = "yasr-donatedivdx";
61
- }
62
63
- $n_stored_ratings = yasr_count_logged_vote ();
64
65
- $div = "<div class=\"$yasr_metabox_class\" id=\"yasr-ask-five-stars\" style=\" display:none; border-left: 3px solid #7AD03A; font-size: 14px;\">";
66
67
- if($n_stored_ratings > 20) {
68
69
- $text = sprintf( __('Hey, seems like you reached %s votes on your site throught YASR! That\'s cool!', 'yet-another-stars-rating'),'<strong>'.$n_stored_ratings.'</strong>');
70
- $text .= "<br />";
71
- $text .= __('Can I ask a favor?', 'yet-another-stars-rating');
72
- $text .= "<br />";
73
- $text .= __('Can you please rate YASR 5 stars on', 'yet-another-stars-rating');
74
- $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">wordpress.org?</a>';
75
- $text .= __(' It will require just 1 min but it\'s a HUGE help for me. Thank you.' , 'yet-another-stars-rating');
76
- $text .= "<br /><br />";
77
- $text .= "<em>> Dario Curvino</em>";
78
79
- $text .= "<ul>
80
81
- <li><a href=\"https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5\">" . __("Ok, I'm glad to help!" , 'yet-another-stars-rating') ."</a></li>
82
- <li><a href=\"#\" id=\"yasr-ask-five-star-later\">" . __("Remind me later!" , 'yet-another-stars-rating') ."</a></li>
83
- <li><a href=\"#\" id=\"yasr-ask-five-close\">" . __("Don't need to ask, I already did it!" , 'yet-another-stars-rating') ."</a></li>
84
85
</ul>";
86
87
88
- $div_and_text = $div . $text . '</div>';
89
90
- echo $div_and_text;
91
92
- }
93
94
- } //End if (!transient)
95
96
97
}
98
99
100
-
101
/** Change default admin footer on yasr settings pages
102
* $text is the default wordpress text
103
- * Since 0.8.9
104
*/
105
106
- add_filter( 'admin_footer_text', 'yasr_custom_admin_footer' );
107
-
108
- function yasr_custom_admin_footer ($text) {
109
-
110
- if (isset($_GET['page'])) {
111
- $yasr_page = $_GET[ 'page' ];
112
-
113
- if ($yasr_page == 'yasr_settings_page') {
114
115
- $custom_text = ' | <i>';
116
- $custom_text .= sprintf( __( 'Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>. Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>', 'yet-another-stars-rating' ),
117
- 'https://yetanotherstarsrating.com',
118
- 'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
119
- 'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5' );
120
- $custom_text .= '</i>';
121
122
- return $text . $custom_text;
123
124
- }
125
126
- else {
127
- return $text;
128
- }
129
130
- }
131
132
- else {
133
- return $text;
134
- }
135
136
}
137
1
<?php
2
3
+ function yasr_upgrade_pro_box($position = false) {
4
5
+ if (yasr_fs()->is_free_plan()) {
6
7
+ if ($position && $position == "bottom") {
8
+ $yasr_upgrade_class = "yasr-donatedivbottom";
9
+ } else {
10
+ $yasr_upgrade_class = "yasr-donatedivdx";
11
+ }
12
13
+ ?>
14
15
+ <div class="<?php echo $yasr_upgrade_class ?>" style="display: none">
16
17
+ <h2 style="color: #34A7C1">
18
+ <?php _e('Upgrade to YASR Pro', 'yet-another-stars-rating'); ?>
19
+ </h2>
20
21
+ <div class="yasr-upgrade-to-pro">
22
+ <ul>
23
+ <li><strong><?php _e(' User Reviews', 'yet-another-stars-rating'); ?></strong></li>
24
+ <li><strong><?php _e(' Custom Rankings', 'yet-another-stars-rating'); ?></strong></li>
25
+ <li><strong><?php _e(' 20 + ready to use themes', 'yet-another-stars-rating'); ?></strong></li>
26
+ <li><strong><?php _e(' Upload your own theme', 'yet-another-stars-rating'); ?></strong></li>
27
+ <li><strong><?php _e(' Dedicate support', 'yet-another-stars-rating'); ?></strong></li>
28
+ </ul>
29
+ <a href="<?php echo yasr_fs()->get_upgrade_url(); ?>">
30
+ <button class="button button-primary">Upgrade Now</button>
31
+ </a>
32
+ </div>
33
34
+ </div>
35
36
+ <?php
37
38
+ }
39
40
}
41
45
* Since version 0.9.0
46
*/
47
48
+ function yasr_ask_rating($position = false) {
49
50
+ $transient = get_site_transient('yasr_hide_ask_rating');
51
52
+ if (!$transient) {
53
54
+ if ($position && $position == "bottom") {
55
+ $yasr_metabox_class = "yasr-donatedivbottom";
56
+ } else {
57
+ $yasr_metabox_class = "yasr-donatedivdx";
58
+ }
59
60
+ $n_stored_ratings = yasr_count_logged_vote();
61
62
+ $div = "<div class=\"$yasr_metabox_class\" id=\"yasr-ask-five-stars\" style=\" display:none; border-left: 3px solid #7AD03A; font-size: 14px;\">";
63
64
+ if ($n_stored_ratings > 20) {
65
+ $text = sprintf(
66
+ __('Hey, seems like you reached %s votes on your site throught YASR! That\'s cool!', 'yet-another-stars-rating'),
67
+ '<strong>' . $n_stored_ratings . '</strong>'
68
+ );
69
+ $text .= "<br />";
70
+ $text .= __('Can I ask a favor?', 'yet-another-stars-rating');
71
+ $text .= "<br />";
72
+ $text .= __('Can you please rate YASR 5 stars on', 'yet-another-stars-rating');
73
+ $text .= ' <a href="https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5">wordpress.org?</a>';
74
+ $text .= __(' It will require just 1 min but it\'s a HUGE help for me. Thank you.', 'yet-another-stars-rating');
75
+ $text .= "<br /><br />";
76
+ $text .= "<em>> Dario Curvino</em>";
77
78
+ $text .= "<ul>
79
80
+ <li><a href=\"https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5\">" . __("Ok, I'm glad to help!", 'yet-another-stars-rating') . "</a></li>
81
+ <li><a href=\"#\" id=\"yasr-ask-five-star-later\">" . __("Remind me later!", 'yet-another-stars-rating') . "</a></li>
82
+ <li><a href=\"#\" id=\"yasr-ask-five-close\">" . __("Don't need to ask, I already did it!", 'yet-another-stars-rating') . "</a></li>
83
84
</ul>";
85
86
87
+ $div_and_text = $div . $text . '</div>';
88
89
+ echo $div_and_text;
90
91
+ }
92
93
+ } //End if (!transient)
94
95
96
}
97
98
99
/** Change default admin footer on yasr settings pages
100
* $text is the default wordpress text
101
+ * Since 0.8.9
102
*/
103
104
+ add_filter('admin_footer_text', 'yasr_custom_admin_footer');
105
106
+ function yasr_custom_admin_footer($text) {
107
108
+ if (isset($_GET['page'])) {
109
+ $yasr_page = $_GET['page'];
110
111
+ if ($yasr_page == 'yasr_settings_page') {
112
+ $custom_text = ' | <i>';
113
+ $custom_text .= sprintf(
114
+ __('Thank you for using <a href="%s" target="_blank">Yet Another Stars Rating</a>.
115
+ Please <a href="%s" target="_blank">rate it</a> 5 stars on <a href="%s" target="_blank">WordPress.org</a>',
116
+ 'yet-another-stars-rating'
117
+ ),
118
+ 'https://yetanotherstarsrating.com',
119
+ 'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5',
120
+ 'https://wordpress.org/support/view/plugin-reviews/yet-another-stars-rating?filter=5'
121
+ );
122
+ $custom_text .= '</i>';
123
124
+ return $text . $custom_text;
125
126
+ } else {
127
+ return $text;
128
+ }
129
130
+ } else {
131
+ return $text;
132
+ }
133
134
}
135
lib/admin/settings/yasr-settings-functions.php CHANGED
@@ -27,11 +27,12 @@ function yasr_settings_tabs( $active_tab )
27
28
<h2 class="nav-tab-wrapper yasr-no-underline">
29
30
- <a href="?page=yasr_settings_page&tab=general_settings" class="nav-tab <?php
31
if ( $active_tab === 'general_settings' ) {
32
echo 'nav-tab-active' ;
33
}
34
- ?>" >
35
<?php
36
_e( "General Settings", 'yet-another-stars-rating' );
37
?>
@@ -41,17 +42,18 @@ function yasr_settings_tabs( $active_tab )
41
if ( $active_tab === 'manage_multi' ) {
42
echo 'nav-tab-active' ;
43
}
44
- ?>" >
45
<?php
46
_e( "Multi Sets", 'yet-another-stars-rating' );
47
?>
48
</a>
49
50
- <a href="?page=yasr_settings_page&tab=style_options" class="nav-tab <?php
51
if ( $active_tab === 'style_options' ) {
52
echo 'nav-tab-active' ;
53
}
54
- ?>" >
55
<?php
56
_e( "Aspect & Styles", 'yet-another-stars-rating' );
57
?>
@@ -97,6 +99,7 @@ function yasr_general_options_init()
97
$option['text_before_visitor_rating'] = '';
98
$option['text_after_visitor_rating'] = '';
99
$option['custom_text_user_voted'] = '';
100
}
101
102
//if it's not blogposting avoid undefined variable
@@ -187,229 +190,242 @@ function yasr_auto_insert_callback( $option )
187
{
188
?>
189
190
- <strong><?php
191
_e( 'Use Auto Insert?', 'yet-another-stars-rating' );
192
?></strong>
193
194
195
- <div class="yasr-onoffswitch-big">
196
- <input type="checkbox" name="yasr_general_options[auto_insert_enabled]" class="yasr-onoffswitch-checkbox" value="1" id="yasr_auto_insert_switch" <?php
197
if ( $option['auto_insert_enabled'] == 1 ) {
198
echo " checked='checked' " ;
199
}
200
?> >
201
- <label class="yasr-onoffswitch-label" for="yasr_auto_insert_switch">
202
- <span class="yasr-onoffswitch-inner"></span>
203
- <span class="yasr-onoffswitch-switch"></span>
204
- </label>
205
- </div>
206
207
- <p>&nbsp;</p>
208
209
- <strong><?php
210
_e( 'What?', 'yet-another-stars-rating' );
211
?></strong>
212
213
- <div class="yasr-indented-answer">
214
215
- <input type="radio" name="yasr_general_options[auto_insert_what]" value="overall_rating" class="yasr-auto-insert-options-class" <?php
216
if ( $option['auto_insert_what'] === 'overall_rating' ) {
217
echo " checked=\"checked\" " ;
218
}
219
?> >
220
- <?php
221
_e( 'Overall Rating / Author Rating', 'yet-another-stars-rating' );
222
?>
223
- <br />
224
225
- <input type="radio" name="yasr_general_options[auto_insert_what]" value="visitor_rating" class="yasr-auto-insert-options-class" <?php
226
if ( $option['auto_insert_what'] === 'visitor_rating' ) {
227
echo " checked=\"checked\" " ;
228
}
229
?> >
230
- <?php
231
_e( 'Visitor Votes', 'yet-another-stars-rating' );
232
?>
233
- <br />
234
235
- <input type="radio" name="yasr_general_options[auto_insert_what]" value="both" class="yasr-auto-insert-options-class" <?php
236
if ( $option['auto_insert_what'] === 'both' ) {
237
echo " checked=\"checked\" " ;
238
}
239
?> >
240
- <?php
241
_e( 'Both', 'yet-another-stars-rating' );
242
?>
243
244
- <p>&nbsp;</p>
245
246
- </div>
247
248
- <strong><?php
249
_e( 'Where?', 'yet-another-stars-rating' );
250
?></strong>
251
252
- <div class="yasr-indented-answer">
253
254
- <input type="radio" name="yasr_general_options[auto_insert_where]" value="top" class="yasr-auto-insert-options-class" <?php
255
if ( $option['auto_insert_where'] === 'top' ) {
256
echo " checked=\"checked\" " ;
257
}
258
?> >
259
- <?php
260
_e( 'Before the post', 'yet-another-stars-rating' );
261
?>
262
- <br />
263
264
- <input type="radio" name="yasr_general_options[auto_insert_where]" value="bottom" class="yasr-auto-insert-options-class" <?php
265
if ( $option['auto_insert_where'] === 'bottom' ) {
266
echo " checked=\"checked\" " ;
267
}
268
?> >
269
- <?php
270
_e( 'After the post', 'yet-another-stars-rating' );
271
?>
272
- <br />
273
274
- <p>&nbsp;</p>
275
276
- </div>
277
278
- <strong><?php
279
_e( 'Size', 'yet-another-stars-rating' );
280
?></strong>
281
282
- <div class="yasr-indented-answer">
283
284
- <div class="yasr-option-size">
285
- <input type="radio" name="yasr_general_options[auto_insert_size]" value="small" class="yasr-auto-insert-options-class" <?php
286
if ( $option['auto_insert_size'] === 'small' ) {
287
echo " checked=\"checked\" " ;
288
}
289
?> >
290
- <img src="<?php
291
echo YASR_IMG_DIR . "yasr-stars-small.png" ;
292
- ?>" class="yasr-img-option-size"><span class="yasr-text-options-size"><?php
293
_e( 'Small', 'yet-another-stars-rating' );
294
?></span>
295
- </div>
296
297
- <div class="yasr-option-size">
298
- <input type="radio" name="yasr_general_options[auto_insert_size]" value="medium" class="yasr-auto-insert-options-class" <?php
299
if ( $option['auto_insert_size'] === 'medium' ) {
300
echo " checked=\"checked\" " ;
301
}
302
?> >
303
- <img src="<?php
304
echo YASR_IMG_DIR . "yasr-stars-medium.png" ;
305
- ?>" class="yasr-img-option-size"><span class="yasr-text-options-size"><?php
306
_e( 'Medium', 'yet-another-stars-rating' );
307
?></span>
308
- </div>
309
310
- <div class="yasr-option-size">
311
- <input type="radio" name="yasr_general_options[auto_insert_size]" value="large" class="yasr-auto-insert-options-class" <?php
312
if ( $option['auto_insert_size'] === 'large' ) {
313
echo " checked=\"checked\" " ;
314
}
315