kk Star Ratings - Version 5.4.0

Version Description

Download this release

Release Info

Developer bhittani
Plugin Icon 128x128 kk Star Ratings
Version 5.4.0
Comparing to
See all releases

Code changes from version 5.3.4 to 5.4.0

CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
 
 
 
 
 
 
 
 
 
 
8
  ## [5.3.4] - 2022-09-06
9
 
10
  ### Fixed
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
 
8
+ ## [5.4.0] - 2022-11-06
9
+
10
+ ### Added
11
+ - Custom blocks support.
12
+
13
+ ### Fixed
14
+ - Text domain path was incorrect in `load_plugin_textdomain`.
15
+ - Use single quotes in payload html attribute (#124).
16
+
17
  ## [5.3.4] - 2022-09-06
18
 
19
  ### Fixed
index.php CHANGED
@@ -10,7 +10,7 @@
10
  * Author URI: http://bhittani.com
11
  * Text Domain: kk-star-ratings
12
  * Domain Path: /languages
13
- * Version: 5.3.4
14
  * License: GPLv2 or later
15
  */
16
 
@@ -28,7 +28,7 @@ define('KK_STAR_RATINGS', __FILE__);
28
  if (function_exists('kksr_freemius')) {
29
  kksr_freemius()->set_basename(true, __FILE__);
30
  } else {
31
- if (! function_exists( 'kksr_freemius' )) {
32
  require_once __DIR__.'/freemius.php';
33
  }
34
 
10
  * Author URI: http://bhittani.com
11
  * Text Domain: kk-star-ratings
12
  * Domain Path: /languages
13
+ * Version: 5.4.0
14
  * License: GPLv2 or later
15
  */
16
 
28
  if (function_exists('kksr_freemius')) {
29
  kksr_freemius()->set_basename(true, __FILE__);
30
  } else {
31
+ if (! function_exists('kksr_freemius')) {
32
  require_once __DIR__.'/freemius.php';
33
  }
34
 
languages/kk-star-ratings.pot CHANGED
@@ -2,14 +2,14 @@
2
  # This file is distributed under the GPLv2 or later.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: kk Star Ratings 5.3.4\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/kk-star-ratings\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2022-10-06T15:02:10+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.6.0\n"
15
  "X-Domain: kk-star-ratings\n"
@@ -35,311 +35,382 @@ msgid "http://bhittani.com"
35
  msgstr ""
36
 
37
  #: src/core/actions/admin/index.php:57
 
38
  msgid "You can only save the options via the admin."
39
  msgstr ""
40
 
41
  #: src/core/actions/admin/index.php:88
 
42
  msgid "There were some errors while saving the options."
43
  msgstr ""
44
 
45
  #: src/core/filters/admin/tabs.php:22
 
46
  msgctxt "Label"
47
  msgid "General"
48
  msgstr ""
49
 
50
  #: src/core/filters/admin/tabs.php:23
 
51
  msgctxt "Label"
52
  msgid "Appearance"
53
  msgstr ""
54
 
55
  #: src/core/filters/admin/tabs.php:24
 
56
  msgctxt "Label"
57
  msgid "Rich Snippets"
58
  msgstr ""
59
 
60
  #: src/core/filters/validate.php:31
 
61
  msgid "The ratings are readonly."
62
  msgstr ""
63
 
64
  #: src/core/filters/validate.php:39
 
65
  msgid "Not allowed at the moment."
66
  msgstr ""
67
 
68
  #: src/core/filters/validate.php:47
 
69
  msgid "You can not cast a vote in archives."
70
  msgstr ""
71
 
72
  #: src/core/filters/validate.php:53
 
73
  msgid "You need to be authenticated to cast a vote."
74
  msgstr ""
75
 
76
  #: src/core/filters/validate.php:61
 
77
  msgid "You have already casted your vote."
78
  msgstr ""
79
 
80
  #: src/core/functions/response.php:45
 
81
  msgid "vote"
82
  msgid_plural "votes"
83
  msgstr[0] ""
84
  msgstr[1] ""
85
 
86
  #: src/core/views/admin/index.php:19
 
87
  msgid "Options saved."
88
  msgstr ""
89
 
90
  #: src/core/views/admin/tabs/appearance.php:15
 
91
  msgctxt "Label"
92
  msgid "Top Left"
93
  msgstr ""
94
 
95
  #: src/core/views/admin/tabs/appearance.php:16
 
96
  msgctxt "Label"
97
  msgid "Top Center"
98
  msgstr ""
99
 
100
  #: src/core/views/admin/tabs/appearance.php:17
 
101
  msgctxt "Label"
102
  msgid "Top Right"
103
  msgstr ""
104
 
105
  #: src/core/views/admin/tabs/appearance.php:18
 
106
  msgctxt "Label"
107
  msgid "Bottom Left"
108
  msgstr ""
109
 
110
  #: src/core/views/admin/tabs/appearance.php:19
 
111
  msgctxt "Label"
112
  msgid "Bottom Center"
113
  msgstr ""
114
 
115
  #: src/core/views/admin/tabs/appearance.php:20
 
116
  msgctxt "Label"
117
  msgid "Bottom Right"
118
  msgstr ""
119
 
120
  #: src/core/views/admin/tabs/appearance.php:30
 
121
  msgctxt "Label"
122
  msgid "Greeting"
123
  msgstr ""
124
 
125
  #: src/core/views/admin/tabs/appearance.php:38
 
126
  msgid "Text that will be displayed when no votes have been casted."
127
  msgstr ""
128
 
129
  #: src/core/views/admin/tabs/appearance.php:40
130
  #: src/core/views/admin/tabs/appearance.php:61
131
  #: src/core/views/admin/tabs/rich-snippets.php:43
 
 
 
132
  msgid "The following variables are available:"
133
  msgstr ""
134
 
135
  #: src/core/views/admin/tabs/appearance.php:42
 
136
  msgid "%s Post Type"
137
  msgstr ""
138
 
139
  #: src/core/views/admin/tabs/appearance.php:51
 
140
  msgctxt "Label"
141
  msgid "Legend"
142
  msgstr ""
143
 
144
  #: src/core/views/admin/tabs/appearance.php:59
 
145
  msgid "Text that will be displayed when votes have been casted."
146
  msgstr ""
147
 
148
  #: src/core/views/admin/tabs/appearance.php:63
 
149
  msgid "%s Average ratings"
150
  msgstr ""
151
 
152
  #: src/core/views/admin/tabs/appearance.php:65
 
153
  msgid "%s Number of votes casted"
154
  msgstr ""
155
 
156
  #: src/core/views/admin/tabs/appearance.php:67
 
157
  msgid "%s Total amount of stars"
158
  msgstr ""
159
 
160
  #: src/core/views/admin/tabs/appearance.php:69
 
161
  msgid "%s Votes"
162
  msgstr ""
163
 
164
  #: src/core/views/admin/tabs/appearance.php:78
 
165
  msgctxt "Label"
166
  msgid "Stars"
167
  msgstr ""
168
 
169
  #: src/core/views/admin/tabs/appearance.php:86
 
170
  msgid "Total number of stars."
171
  msgstr ""
172
 
173
  #: src/core/views/admin/tabs/appearance.php:95
 
174
  msgctxt "Label"
175
  msgid "Gap"
176
  msgstr ""
177
 
178
  #: src/core/views/admin/tabs/appearance.php:103
 
179
  msgid "Gap between the stars."
180
  msgstr ""
181
 
182
  #: src/core/views/admin/tabs/appearance.php:112
 
183
  msgctxt "Label"
184
  msgid "Size"
185
  msgstr ""
186
 
187
  #: src/core/views/admin/tabs/appearance.php:120
 
188
  msgid "Size of a single star."
189
  msgstr ""
190
 
191
  #: src/core/views/admin/tabs/appearance.php:128
 
192
  msgctxt "Label"
193
  msgid "Default Position"
194
  msgstr ""
195
 
196
  #: src/core/views/admin/tabs/appearance.php:140
 
197
  msgid "Choose the default position for the auto-embedded star ratings."
198
  msgstr ""
199
 
200
  #: src/core/views/admin/tabs/general.php:36
 
201
  msgctxt "Label"
202
  msgid "Home"
203
  msgstr ""
204
 
205
  #: src/core/views/admin/tabs/general.php:37
 
206
  msgctxt "Label"
207
  msgid "Archives"
208
  msgstr ""
209
 
210
  #: src/core/views/admin/tabs/general.php:41
 
211
  msgctxt "Label"
212
  msgid "Allow voting in archives"
213
  msgstr ""
214
 
215
  #: src/core/views/admin/tabs/general.php:42
 
216
  msgctxt "Label"
217
  msgid "Allow guests to vote"
218
  msgstr ""
219
 
220
  #: src/core/views/admin/tabs/general.php:43
 
221
  msgctxt "Label"
222
  msgid "Unique votes (based on IP Address)"
223
  msgstr ""
224
 
225
  #: src/core/views/admin/tabs/general.php:53
226
  #: src/core/views/admin/tabs/rich-snippets.php:17
 
 
227
  msgctxt "Label"
228
  msgid "Status"
229
  msgstr ""
230
 
231
  #: src/core/views/admin/tabs/general.php:58
 
232
  msgctxt "Label"
233
  msgid "Active"
234
  msgstr ""
235
 
236
  #: src/core/views/admin/tabs/general.php:61
 
237
  msgid "Globally activate/deactivate the star ratings."
238
  msgstr ""
239
 
240
  #: src/core/views/admin/tabs/general.php:69
 
241
  msgctxt "Label"
242
  msgid "Strategies"
243
  msgstr ""
244
 
245
  #: src/core/views/admin/tabs/general.php:81
 
246
  msgid "Select the voting strategies."
247
  msgstr ""
248
 
249
  #: src/core/views/admin/tabs/general.php:89
 
250
  msgctxt "Label"
251
  msgid "Locations"
252
  msgstr ""
253
 
254
  #: src/core/views/admin/tabs/general.php:101
 
255
  msgid "Star ratings will be auto-embedded for the selected locations. You may still manually allow star ratings for unselected/other locations. E.g. Using %s in your theme/template file(s)."
256
  msgstr ""
257
 
258
  #: src/core/views/admin/tabs/general.php:109
 
259
  msgctxt "Label"
260
  msgid "Exclude Categories"
261
  msgstr ""
262
 
263
  #: src/core/views/admin/tabs/general.php:121
 
264
  msgid "The posts belonging to the selected categories will not auto-embed the star ratings. You may still manually show the star ratings. E.g. Using %s in your theme/template file(s)."
265
  msgstr ""
266
 
267
  #: src/core/views/admin/tabs/rich-snippets.php:22
 
268
  msgctxt "Label"
269
  msgid "Enable"
270
  msgstr ""
271
 
272
  #: src/core/views/admin/tabs/rich-snippets.php:25
 
273
  msgid "Enable/disable rich snippets."
274
  msgstr ""
275
 
276
  #: src/core/views/admin/tabs/rich-snippets.php:33
 
277
  msgctxt "Label"
278
  msgid "Content"
279
  msgstr ""
280
 
281
  #: src/core/views/admin/tabs/rich-snippets.php:41
 
282
  msgid "Provide the ld+json structure."
283
  msgstr ""
284
 
285
  #: src/core/views/admin/tabs/rich-snippets.php:45
 
286
  msgctxt "Label"
287
  msgid "%s Post title"
288
  msgstr ""
289
 
290
  #: src/core/views/admin/tabs/rich-snippets.php:47
 
291
  msgctxt "Label"
292
  msgid "%s Average ratings"
293
  msgstr ""
294
 
295
  #: src/core/views/admin/tabs/rich-snippets.php:49
 
296
  msgctxt "Label"
297
  msgid "%s Number of votes casted"
298
  msgstr ""
299
 
300
  #: src/core/views/admin/tabs/rich-snippets.php:51
 
301
  msgctxt "Label"
302
  msgid "%s Total amount of stars"
303
  msgstr ""
304
 
305
  #: src/core/views/metabox/content.php:15
 
306
  msgctxt "label"
307
  msgid "Reset Ratings"
308
  msgstr ""
309
 
310
  #: src/core/views/metabox/content.php:22
 
311
  msgctxt "label"
312
  msgid "Auto Embed"
313
  msgstr ""
314
 
315
  #: src/core/views/metabox/content.php:28
 
316
  msgctxt "label"
317
  msgid "Global"
318
  msgstr ""
319
 
320
  #: src/core/views/metabox/content.php:32
 
321
  msgctxt "label"
322
  msgid "Enable"
323
  msgstr ""
324
 
325
  #: src/core/views/metabox/content.php:36
 
326
  msgctxt "label"
327
  msgid "Disable"
328
  msgstr ""
329
 
330
  #: src/core/wp/actions/wp_ajax_kk-star-ratings.php:30
331
  #: src/core/wp/actions/wp_ajax_kksr-migrations.php:28
 
 
332
  msgid "This action is forbidden."
333
  msgstr ""
334
 
335
  #: src/core/wp/actions/wp_ajax_kk-star-ratings.php:40
 
336
  msgid "A rating can not be accepted at the moment."
337
  msgstr ""
338
 
339
  #: src/core/wp/actions/wp_ajax_kk-star-ratings.php:44
 
340
  msgid "A rating is required to cast a vote."
341
  msgstr ""
342
 
343
  #: src/core/wp/actions/wp_ajax_kk-star-ratings.php:50
 
344
  msgid "The rating value must be between %1$d and %2$d."
345
  msgstr ""
2
  # This file is distributed under the GPLv2 or later.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: kk Star Ratings 5.4.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/kk-star-ratings\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2022-11-06T12:20:09+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.6.0\n"
15
  "X-Domain: kk-star-ratings\n"
35
  msgstr ""
36
 
37
  #: src/core/actions/admin/index.php:57
38
+ #: svn/src/core/actions/admin/index.php:57
39
  msgid "You can only save the options via the admin."
40
  msgstr ""
41
 
42
  #: src/core/actions/admin/index.php:88
43
+ #: svn/src/core/actions/admin/index.php:88
44
  msgid "There were some errors while saving the options."
45
  msgstr ""
46
 
47
  #: src/core/filters/admin/tabs.php:22
48
+ #: svn/src/core/filters/admin/tabs.php:22
49
  msgctxt "Label"
50
  msgid "General"
51
  msgstr ""
52
 
53
  #: src/core/filters/admin/tabs.php:23
54
+ #: svn/src/core/filters/admin/tabs.php:23
55
  msgctxt "Label"
56
  msgid "Appearance"
57
  msgstr ""
58
 
59
  #: src/core/filters/admin/tabs.php:24
60
+ #: svn/src/core/filters/admin/tabs.php:24
61
  msgctxt "Label"
62
  msgid "Rich Snippets"
63
  msgstr ""
64
 
65
  #: src/core/filters/validate.php:31
66
+ #: svn/src/core/filters/validate.php:31
67
  msgid "The ratings are readonly."
68
  msgstr ""
69
 
70
  #: src/core/filters/validate.php:39
71
+ #: svn/src/core/filters/validate.php:39
72
  msgid "Not allowed at the moment."
73
  msgstr ""
74
 
75
  #: src/core/filters/validate.php:47
76
+ #: svn/src/core/filters/validate.php:47
77
  msgid "You can not cast a vote in archives."
78
  msgstr ""
79
 
80
  #: src/core/filters/validate.php:53
81
+ #: svn/src/core/filters/validate.php:53
82
  msgid "You need to be authenticated to cast a vote."
83
  msgstr ""
84
 
85
  #: src/core/filters/validate.php:61
86
+ #: svn/src/core/filters/validate.php:61
87
  msgid "You have already casted your vote."
88
  msgstr ""
89
 
90
  #: src/core/functions/response.php:45
91
+ #: svn/src/core/functions/response.php:45
92
  msgid "vote"
93
  msgid_plural "votes"
94
  msgstr[0] ""
95
  msgstr[1] ""
96
 
97
  #: src/core/views/admin/index.php:19
98
+ #: svn/src/core/views/admin/index.php:19
99
  msgid "Options saved."
100
  msgstr ""
101
 
102
  #: src/core/views/admin/tabs/appearance.php:15
103
+ #: svn/src/core/views/admin/tabs/appearance.php:15
104
  msgctxt "Label"
105
  msgid "Top Left"
106
  msgstr ""
107
 
108
  #: src/core/views/admin/tabs/appearance.php:16
109
+ #: svn/src/core/views/admin/tabs/appearance.php:16
110
  msgctxt "Label"
111
  msgid "Top Center"
112
  msgstr ""
113
 
114
  #: src/core/views/admin/tabs/appearance.php:17
115
+ #: svn/src/core/views/admin/tabs/appearance.php:17
116
  msgctxt "Label"
117
  msgid "Top Right"
118
  msgstr ""
119
 
120
  #: src/core/views/admin/tabs/appearance.php:18
121
+ #: svn/src/core/views/admin/tabs/appearance.php:18
122
  msgctxt "Label"
123
  msgid "Bottom Left"
124
  msgstr ""
125
 
126
  #: src/core/views/admin/tabs/appearance.php:19
127
+ #: svn/src/core/views/admin/tabs/appearance.php:19
128
  msgctxt "Label"
129
  msgid "Bottom Center"
130
  msgstr ""
131
 
132
  #: src/core/views/admin/tabs/appearance.php:20
133
+ #: svn/src/core/views/admin/tabs/appearance.php:20
134
  msgctxt "Label"
135
  msgid "Bottom Right"
136
  msgstr ""
137
 
138
  #: src/core/views/admin/tabs/appearance.php:30
139
+ #: svn/src/core/views/admin/tabs/appearance.php:30
140
  msgctxt "Label"
141
  msgid "Greeting"
142
  msgstr ""
143
 
144
  #: src/core/views/admin/tabs/appearance.php:38
145
+ #: svn/src/core/views/admin/tabs/appearance.php:38
146
  msgid "Text that will be displayed when no votes have been casted."
147
  msgstr ""
148
 
149
  #: src/core/views/admin/tabs/appearance.php:40
150
  #: src/core/views/admin/tabs/appearance.php:61
151
  #: src/core/views/admin/tabs/rich-snippets.php:43
152
+ #: svn/src/core/views/admin/tabs/appearance.php:40
153
+ #: svn/src/core/views/admin/tabs/appearance.php:61
154
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:43
155
  msgid "The following variables are available:"
156
  msgstr ""
157
 
158
  #: src/core/views/admin/tabs/appearance.php:42
159
+ #: svn/src/core/views/admin/tabs/appearance.php:42
160
  msgid "%s Post Type"
161
  msgstr ""
162
 
163
  #: src/core/views/admin/tabs/appearance.php:51
164
+ #: svn/src/core/views/admin/tabs/appearance.php:51
165
  msgctxt "Label"
166
  msgid "Legend"
167
  msgstr ""
168
 
169
  #: src/core/views/admin/tabs/appearance.php:59
170
+ #: svn/src/core/views/admin/tabs/appearance.php:59
171
  msgid "Text that will be displayed when votes have been casted."
172
  msgstr ""
173
 
174
  #: src/core/views/admin/tabs/appearance.php:63
175
+ #: svn/src/core/views/admin/tabs/appearance.php:63
176
  msgid "%s Average ratings"
177
  msgstr ""
178
 
179
  #: src/core/views/admin/tabs/appearance.php:65
180
+ #: svn/src/core/views/admin/tabs/appearance.php:65
181
  msgid "%s Number of votes casted"
182
  msgstr ""
183
 
184
  #: src/core/views/admin/tabs/appearance.php:67
185
+ #: svn/src/core/views/admin/tabs/appearance.php:67
186
  msgid "%s Total amount of stars"
187
  msgstr ""
188
 
189
  #: src/core/views/admin/tabs/appearance.php:69
190
+ #: svn/src/core/views/admin/tabs/appearance.php:69
191
  msgid "%s Votes"
192
  msgstr ""
193
 
194
  #: src/core/views/admin/tabs/appearance.php:78
195
+ #: svn/src/core/views/admin/tabs/appearance.php:78
196
  msgctxt "Label"
197
  msgid "Stars"
198
  msgstr ""
199
 
200
  #: src/core/views/admin/tabs/appearance.php:86
201
+ #: svn/src/core/views/admin/tabs/appearance.php:86
202
  msgid "Total number of stars."
203
  msgstr ""
204
 
205
  #: src/core/views/admin/tabs/appearance.php:95
206
+ #: svn/src/core/views/admin/tabs/appearance.php:95
207
  msgctxt "Label"
208
  msgid "Gap"
209
  msgstr ""
210
 
211
  #: src/core/views/admin/tabs/appearance.php:103
212
+ #: svn/src/core/views/admin/tabs/appearance.php:103
213
  msgid "Gap between the stars."
214
  msgstr ""
215
 
216
  #: src/core/views/admin/tabs/appearance.php:112
217
+ #: svn/src/core/views/admin/tabs/appearance.php:112
218
  msgctxt "Label"
219
  msgid "Size"
220
  msgstr ""
221
 
222
  #: src/core/views/admin/tabs/appearance.php:120
223
+ #: svn/src/core/views/admin/tabs/appearance.php:120
224
  msgid "Size of a single star."
225
  msgstr ""
226
 
227
  #: src/core/views/admin/tabs/appearance.php:128
228
+ #: svn/src/core/views/admin/tabs/appearance.php:128
229
  msgctxt "Label"
230
  msgid "Default Position"
231
  msgstr ""
232
 
233
  #: src/core/views/admin/tabs/appearance.php:140
234
+ #: svn/src/core/views/admin/tabs/appearance.php:140
235
  msgid "Choose the default position for the auto-embedded star ratings."
236
  msgstr ""
237
 
238
  #: src/core/views/admin/tabs/general.php:36
239
+ #: svn/src/core/views/admin/tabs/general.php:36
240
  msgctxt "Label"
241
  msgid "Home"
242
  msgstr ""
243
 
244
  #: src/core/views/admin/tabs/general.php:37
245
+ #: svn/src/core/views/admin/tabs/general.php:37
246
  msgctxt "Label"
247
  msgid "Archives"
248
  msgstr ""
249
 
250
  #: src/core/views/admin/tabs/general.php:41
251
+ #: svn/src/core/views/admin/tabs/general.php:41
252
  msgctxt "Label"
253
  msgid "Allow voting in archives"
254
  msgstr ""
255
 
256
  #: src/core/views/admin/tabs/general.php:42
257
+ #: svn/src/core/views/admin/tabs/general.php:42
258
  msgctxt "Label"
259
  msgid "Allow guests to vote"
260
  msgstr ""
261
 
262
  #: src/core/views/admin/tabs/general.php:43
263
+ #: svn/src/core/views/admin/tabs/general.php:43
264
  msgctxt "Label"
265
  msgid "Unique votes (based on IP Address)"
266
  msgstr ""
267
 
268
  #: src/core/views/admin/tabs/general.php:53
269
  #: src/core/views/admin/tabs/rich-snippets.php:17
270
+ #: svn/src/core/views/admin/tabs/general.php:53
271
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:17
272
  msgctxt "Label"
273
  msgid "Status"
274
  msgstr ""
275
 
276
  #: src/core/views/admin/tabs/general.php:58
277
+ #: svn/src/core/views/admin/tabs/general.php:58
278
  msgctxt "Label"
279
  msgid "Active"
280
  msgstr ""
281
 
282
  #: src/core/views/admin/tabs/general.php:61
283
+ #: svn/src/core/views/admin/tabs/general.php:61
284
  msgid "Globally activate/deactivate the star ratings."
285
  msgstr ""
286
 
287
  #: src/core/views/admin/tabs/general.php:69
288
+ #: svn/src/core/views/admin/tabs/general.php:69
289
  msgctxt "Label"
290
  msgid "Strategies"
291
  msgstr ""
292
 
293
  #: src/core/views/admin/tabs/general.php:81
294
+ #: svn/src/core/views/admin/tabs/general.php:81
295
  msgid "Select the voting strategies."
296
  msgstr ""
297
 
298
  #: src/core/views/admin/tabs/general.php:89
299
+ #: svn/src/core/views/admin/tabs/general.php:89
300
  msgctxt "Label"
301
  msgid "Locations"
302
  msgstr ""
303
 
304
  #: src/core/views/admin/tabs/general.php:101
305
+ #: svn/src/core/views/admin/tabs/general.php:101
306
  msgid "Star ratings will be auto-embedded for the selected locations. You may still manually allow star ratings for unselected/other locations. E.g. Using %s in your theme/template file(s)."
307
  msgstr ""
308
 
309
  #: src/core/views/admin/tabs/general.php:109
310
+ #: svn/src/core/views/admin/tabs/general.php:109
311
  msgctxt "Label"
312
  msgid "Exclude Categories"
313
  msgstr ""
314
 
315
  #: src/core/views/admin/tabs/general.php:121
316
+ #: svn/src/core/views/admin/tabs/general.php:121
317
  msgid "The posts belonging to the selected categories will not auto-embed the star ratings. You may still manually show the star ratings. E.g. Using %s in your theme/template file(s)."
318
  msgstr ""
319
 
320
  #: src/core/views/admin/tabs/rich-snippets.php:22
321
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:22
322
  msgctxt "Label"
323
  msgid "Enable"
324
  msgstr ""
325
 
326
  #: src/core/views/admin/tabs/rich-snippets.php:25
327
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:25
328
  msgid "Enable/disable rich snippets."
329
  msgstr ""
330
 
331
  #: src/core/views/admin/tabs/rich-snippets.php:33
332
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:33
333
  msgctxt "Label"
334
  msgid "Content"
335
  msgstr ""
336
 
337
  #: src/core/views/admin/tabs/rich-snippets.php:41
338
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:41
339
  msgid "Provide the ld+json structure."
340
  msgstr ""
341
 
342
  #: src/core/views/admin/tabs/rich-snippets.php:45
343
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:45
344
  msgctxt "Label"
345
  msgid "%s Post title"
346
  msgstr ""
347
 
348
  #: src/core/views/admin/tabs/rich-snippets.php:47
349
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:47
350
  msgctxt "Label"
351
  msgid "%s Average ratings"
352
  msgstr ""
353
 
354
  #: src/core/views/admin/tabs/rich-snippets.php:49
355
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:49
356
  msgctxt "Label"
357
  msgid "%s Number of votes casted"
358
  msgstr ""
359
 
360
  #: src/core/views/admin/tabs/rich-snippets.php:51
361
+ #: svn/src/core/views/admin/tabs/rich-snippets.php:51
362
  msgctxt "Label"
363
  msgid "%s Total amount of stars"
364
  msgstr ""
365
 
366
  #: src/core/views/metabox/content.php:15
367
+ #: svn/src/core/views/metabox/content.php:15
368
  msgctxt "label"
369
  msgid "Reset Ratings"
370
  msgstr ""
371
 
372
  #: src/core/views/metabox/content.php:22
373
+ #: svn/src/core/views/metabox/content.php:22
374
  msgctxt "label"
375
  msgid "Auto Embed"
376
  msgstr ""
377
 
378
  #: src/core/views/metabox/content.php:28
379
+ #: svn/src/core/views/metabox/content.php:28
380
  msgctxt "label"
381
  msgid "Global"
382
  msgstr ""
383
 
384
  #: src/core/views/metabox/content.php:32
385
+ #: svn/src/core/views/metabox/content.php:32
386
  msgctxt "label"
387
  msgid "Enable"
388
  msgstr ""
389
 
390
  #: src/core/views/metabox/content.php:36
391
+ #: svn/src/core/views/metabox/content.php:36
392
  msgctxt "label"
393
  msgid "Disable"
394
  msgstr ""
395
 
396
  #: src/core/wp/actions/wp_ajax_kk-star-ratings.php:30
397
  #: src/core/wp/actions/wp_ajax_kksr-migrations.php:28
398
+ #: svn/src/core/wp/actions/wp_ajax_kk-star-ratings.php:30
399
+ #: svn/src/core/wp/actions/wp_ajax_kksr-migrations.php:28
400
  msgid "This action is forbidden."
401
  msgstr ""
402
 
403
  #: src/core/wp/actions/wp_ajax_kk-star-ratings.php:40
404
+ #: svn/src/core/wp/actions/wp_ajax_kk-star-ratings.php:40
405
  msgid "A rating can not be accepted at the moment."
406
  msgstr ""
407
 
408
  #: src/core/wp/actions/wp_ajax_kk-star-ratings.php:44
409
+ #: svn/src/core/wp/actions/wp_ajax_kk-star-ratings.php:44
410
  msgid "A rating is required to cast a vote."
411
  msgstr ""
412
 
413
  #: src/core/wp/actions/wp_ajax_kk-star-ratings.php:50
414
+ #: svn/src/core/wp/actions/wp_ajax_kk-star-ratings.php:50
415
  msgid "The rating value must be between %1$d and %2$d."
416
  msgstr ""
readme.txt CHANGED
@@ -5,8 +5,8 @@ Donate link: https://github.com/kamalkhan/kk-star-ratings
5
  Tags: star ratings, votings, rate posts, ajax ratings, infinite stars, unlimited stars, google rich snippets, structured data, SEO, SERP
6
  Requires at least: 5.0
7
  Requires PHP: 7.2
8
- Tested up to: 6.0
9
- Stable tag: 5.3.4
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
5
  Tags: star ratings, votings, rate posts, ajax ratings, infinite stars, unlimited stars, google rich snippets, structured data, SEO, SERP
6
  Requires at least: 5.0
7
  Requires PHP: 7.2
8
+ Tested up to: 6.1
9
+ Stable tag: 5.4.0
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
src/core/actions/admin/script.php CHANGED
@@ -11,6 +11,7 @@
11
 
12
  namespace Bhittani\StarRating\core\actions\admin;
13
 
 
14
  use function Bhittani\StarRating\core\functions\migrations;
15
  use function Bhittani\StarRating\core\functions\script_migrations;
16
 
@@ -28,4 +29,6 @@ function script(string $hook, bool $isDebugMode = false): void
28
  if ($hook == ('toplevel_page_'.kksr('slug'))) {
29
  // Admin menu hook.
30
  }
 
 
31
  }
11
 
12
  namespace Bhittani\StarRating\core\actions\admin;
13
 
14
+ use function Bhittani\StarRating\core\functions\admin\scripts\blocks;
15
  use function Bhittani\StarRating\core\functions\migrations;
16
  use function Bhittani\StarRating\core\functions\script_migrations;
17
 
29
  if ($hook == ('toplevel_page_'.kksr('slug'))) {
30
  // Admin menu hook.
31
  }
32
+
33
+ blocks($isDebugMode);
34
  }
src/core/filters/blocks.php CHANGED
@@ -16,7 +16,12 @@ if (! defined('KK_STAR_RATINGS')) {
16
  exit();
17
  }
18
 
 
 
 
 
 
19
  function blocks(array $blocks): array
20
  {
21
- return $blocks + kksr('core.blocks', []);
22
  }
16
  exit();
17
  }
18
 
19
+ /**
20
+ * @param array<string,array<string,mixed>> $blocks
21
+ *
22
+ * @return array<string,array<string,mixed>>
23
+ */
24
  function blocks(array $blocks): array
25
  {
26
+ return $blocks;
27
  }
src/core/functions/admin/index.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of bhittani/kk-star-ratings.
5
+ *
6
+ * (c) Kamal Khan <shout@bhittani.com>
7
+ *
8
+ * For the full copyright and license information, please view
9
+ * the LICENSE file that was distributed with this source code.
10
+ */
11
+
12
+ if (! defined('KK_STAR_RATINGS')) {
13
+ http_response_code(404);
14
+ exit();
15
+ }
src/core/functions/admin/scripts/blocks.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of bhittani/kk-star-ratings.
5
+ *
6
+ * (c) Kamal Khan <shout@bhittani.com>
7
+ *
8
+ * For the full copyright and license information, please view
9
+ * the LICENSE file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Bhittani\StarRating\core\functions\admin\scripts;
13
+
14
+ if (! defined('KK_STAR_RATINGS')) {
15
+ http_response_code(404);
16
+ exit();
17
+ }
18
+
19
+ function blocks(bool $isDebugMode = false): void
20
+ {
21
+ wp_enqueue_script(kksr('slug').'-blocks');
22
+ }
src/core/functions/admin/scripts/index.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of bhittani/kk-star-ratings.
5
+ *
6
+ * (c) Kamal Khan <shout@bhittani.com>
7
+ *
8
+ * For the full copyright and license information, please view
9
+ * the LICENSE file that was distributed with this source code.
10
+ */
11
+
12
+ if (! defined('KK_STAR_RATINGS')) {
13
+ http_response_code(404);
14
+ exit();
15
+ }
src/core/public/js/blocks.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * kk Star Ratings
3
+ * @see https://github.com/kamalkhan/kk-star-ratings
4
+ */
5
+
6
+ "use strict";
7
+
8
+ (function (window, blocks) {
9
+ function createRegisterFn(payloads) {
10
+ return function (name, callback) {
11
+ if (name.indexOf("/") < 0) {
12
+ name = "kk-star-ratings/" + name;
13
+ }
14
+
15
+ if (!payloads[name]) {
16
+ throw new Error("The '" + name + "' block is not registered.");
17
+ }
18
+
19
+ var optionsOrEditFn = callback({
20
+ name,
21
+ data: payloads[name]["data"] || {},
22
+ });
23
+
24
+ var options = Object.assign(
25
+ {},
26
+ payloads[name]["meta"] || {},
27
+ optionsOrEditFn instanceof Function
28
+ ? {
29
+ edit: optionsOrEditFn,
30
+ }
31
+ : optionsOrEditFn
32
+ );
33
+
34
+ return blocks.registerBlockType(name, options);
35
+ };
36
+ }
37
+
38
+ window.kkStarRatingsBlocks = {
39
+ register: createRegisterFn(kk_star_ratings_blocks),
40
+ };
41
+ })(window, window.wp.blocks);
src/core/public/js/blocks.min.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ /**
2
+ * kk Star Ratings
3
+ * @see https://github.com/kamalkhan/kk-star-ratings
4
+ */
5
+ "use strict";!function(t,e){var r;t.kkStarRatingsBlocks={register:(r=kk_star_ratings_blocks,function(t,i){if(0>t.indexOf("/")&&(t="kk-star-ratings/"+t),!r[t])throw Error("The '"+t+"' block is not registered.");var s=i({name:t,data:r[t].data||{}}),a=Object.assign({},r[t].meta||{},s instanceof Function?{edit:s}:s);return e.registerBlockType(t,a)})}}(window,window.wp.blocks);
src/core/views/markup/index.php CHANGED
@@ -26,7 +26,7 @@
26
  ?>
27
 
28
  <div class="<?php echo implode(' ', array_filter(array_map('esc_attr', $class))); ?>"
29
- data-payload="<?php echo esc_attr(json_encode(array_map('esc_attr', $__payload))); ?>">
30
  <?php echo $__view('markup/stars.php'); ?>
31
  <?php echo $__view('markup/legend.php'); ?>
32
  </div>
26
  ?>
27
 
28
  <div class="<?php echo implode(' ', array_filter(array_map('esc_attr', $class))); ?>"
29
+ data-payload='<?php echo esc_attr(json_encode(array_map('esc_attr', $__payload))); ?>'>
30
  <?php echo $__view('markup/stars.php'); ?>
31
  <?php echo $__view('markup/legend.php'); ?>
32
  </div>
src/core/wp/actions/init.php CHANGED
@@ -11,8 +11,7 @@
11
 
12
  namespace Bhittani\StarRating\core\wp\actions;
13
 
14
- use function Bhittani\StarRating\core\functions\filter;
15
- use function Bhittani\StarRating\functions\block;
16
 
17
  if (! defined('KK_STAR_RATINGS')) {
18
  http_response_code(404);
@@ -21,9 +20,7 @@ if (! defined('KK_STAR_RATINGS')) {
21
 
22
  function init(): void
23
  {
24
- load_plugin_textdomain(kksr('domain'), false, kksr('signature').'/languages');
25
 
26
- foreach (filter('blocks', []) as $namespace => $payload) {
27
- block($namespace, $payload);
28
- }
29
  }
11
 
12
  namespace Bhittani\StarRating\core\wp\actions;
13
 
14
+ use function Bhittani\StarRating\core\wp\functions\register_blocks;
 
15
 
16
  if (! defined('KK_STAR_RATINGS')) {
17
  http_response_code(404);
20
 
21
  function init(): void
22
  {
23
+ load_plugin_textdomain(kksr('domain'), false, dirname(kksr('signature')).'/languages');
24
 
25
+ register_blocks();
 
 
26
  }
src/core/wp/functions/register_blocks.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of bhittani/kk-star-ratings.
5
+ *
6
+ * (c) Kamal Khan <shout@bhittani.com>
7
+ *
8
+ * For the full copyright and license information, please view
9
+ * the LICENSE file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Bhittani\StarRating\core\wp\functions;
13
+
14
+ use function Bhittani\StarRating\core\functions\filter;
15
+ use function Bhittani\StarRating\functions\block;
16
+
17
+ if (! defined('KK_STAR_RATINGS')) {
18
+ http_response_code(404);
19
+ exit();
20
+ }
21
+
22
+ function register_blocks(): void
23
+ {
24
+ $blocks = array_filter(filter('blocks', []));
25
+
26
+ if ($blocks) {
27
+ $isDebugMode = defined('WP_DEBUG') && WP_DEBUG;
28
+
29
+ $jsBlockApiScriptSlug = kksr('slug').'-blocks';
30
+
31
+ wp_register_script(
32
+ $jsBlockApiScriptSlug,
33
+ kksr('core.url').'public/js/blocks'
34
+ .($isDebugMode ? '' : '.min').'.js',
35
+ ['wp-blocks'],
36
+ kksr('version')
37
+ );
38
+
39
+ $payloads = [];
40
+
41
+ foreach ($blocks as $block) {
42
+ $payload = block($block);
43
+
44
+ if ($payload) {
45
+ $payloads[$payload['name']] = $payload;
46
+ }
47
+ }
48
+
49
+ wp_localize_script(
50
+ $jsBlockApiScriptSlug,
51
+ preg_replace('/[^\w]+/', '_', $jsBlockApiScriptSlug),
52
+ $payloads
53
+ );
54
+ }
55
+ }
src/functions/autoload_array.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of bhittani/kk-star-ratings.
5
+ *
6
+ * (c) Kamal Khan <shout@bhittani.com>
7
+ *
8
+ * For the full copyright and license information, please view
9
+ * the LICENSE file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Bhittani\StarRating\functions;
13
+
14
+ if (! defined('KK_STAR_RATINGS')) {
15
+ http_response_code(404);
16
+ exit();
17
+ }
18
+
19
+ function autoload_array(string $filepath): array
20
+ {
21
+ if (! is_file($filepath)) {
22
+ return [];
23
+ }
24
+
25
+ $maybeArray = require $filepath;
26
+
27
+ if (! is_array($maybeArray)) {
28
+ return [];
29
+ }
30
+
31
+ return $maybeArray;
32
+ }
src/functions/autoload_block.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of bhittani/kk-star-ratings.
5
+ *
6
+ * (c) Kamal Khan <shout@bhittani.com>
7
+ *
8
+ * For the full copyright and license information, please view
9
+ * the LICENSE file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Bhittani\StarRating\functions;
13
+
14
+ use Closure;
15
+
16
+ if (! defined('KK_STAR_RATINGS')) {
17
+ http_response_code(404);
18
+ exit();
19
+ }
20
+
21
+ /** @return array<string,mixed> */
22
+ function autoload_block(string $fileOrDir): array
23
+ {
24
+ if (! file_exists($fileOrDir)) {
25
+ // Neither a block file nor a directory.
26
+ return [];
27
+ }
28
+
29
+ $path = rtrim($fileOrDir, '\/').'/';
30
+ $blockFile = "{$path}block.php";
31
+
32
+ if (is_file($fileOrDir)) {
33
+ $path = dirname($fileOrDir).'/';
34
+ $blockFile = $fileOrDir;
35
+ }
36
+
37
+ if (! is_file($blockFile)) {
38
+ // Could not locate the block file.
39
+ return [];
40
+ }
41
+
42
+ $block = require $blockFile;
43
+ $payload = $block;
44
+
45
+ if ($block instanceof Closure) {
46
+ $isDebugMode = defined('WP_DEBUG') && WP_DEBUG;
47
+ $payload = $block($isDebugMode);
48
+ }
49
+
50
+ if (! $payload) {
51
+ // Could not locate the block.php file.
52
+ return [];
53
+ }
54
+
55
+ if (array_diff(['name', 'editor_script'], array_keys($payload))) {
56
+ // The required keys are not available.
57
+ return [];
58
+ }
59
+
60
+ if (strpos($payload['name'], '/') === false) {
61
+ $payload['name'] = prefix($payload['name'], kksr('slug').'/');
62
+ }
63
+
64
+ $payload['attributes'] = ($payload['attributes'] ?? [])
65
+ + autoload_array("{$path}attributes.php");
66
+
67
+ $payload['data'] = ($payload['data'] ?? [])
68
+ + autoload_array("{$path}data.php");
69
+
70
+ $payload['meta'] = ($payload['meta'] ?? [])
71
+ + autoload_array("{$path}meta.php");
72
+
73
+ if (! isset($payload['render'])) {
74
+ $renderFile = "{$path}render.php";
75
+
76
+ if (is_file($renderFile)) {
77
+ $payload['render'] = require $renderFile;
78
+ }
79
+ }
80
+
81
+ return $payload;
82
+ }
src/functions/autoload_blocks.php CHANGED
@@ -18,60 +18,19 @@ if (! defined('KK_STAR_RATINGS')) {
18
 
19
  use DirectoryIterator;
20
 
21
- function autoload_blocks(string $namespace, string $path, string $slug = null): array
 
22
  {
23
- $path = rtrim($path, '\/');
24
- $namespace = rtrim($namespace, '\\');
25
-
26
  if (! is_dir($path)) {
27
  return [];
28
  }
29
 
30
- if (is_null($slug)) {
31
- $slug = kksr('slug');
32
- }
33
-
34
- $isDebugMode = defined('WP_DEBUG') && WP_DEBUG;
35
-
36
  $autoloads = [];
37
 
38
  foreach (new DirectoryIterator($path) as $fileInfo) {
39
- if (! ($fileInfo->isDot()
40
- || $fileInfo->isFile()
41
- )) {
42
- $name = $fileInfo->getFilename();
43
- $path = $fileInfo->getRealPath();
44
- $ns = $namespace.'\\'.$name;
45
- $signature = $slug.'/'.$name;
46
-
47
- $functions = autoload($ns, $path);
48
-
49
- $attributes = [];
50
-
51
- if ($attributes = ($functions['attributes'] ?? [])) {
52
- unset($functions['attributes']);
53
- $attributes = $attributes();
54
- }
55
-
56
- $dependencies = [];
57
-
58
- if ($dependencies = ($functions['dependencies'] ?? [])) {
59
- unset($functions['dependencies']);
60
- $dependencies = $dependencies();
61
- }
62
-
63
- $dist = $path.'/dist/block'.($isDebugMode ? '.es5' : '.min');
64
-
65
- $assetFile = $dist.'.asset.php';
66
- $options = is_file($assetFile) ? ((array) require $assetFile) : [];
67
-
68
- $autoloads[$signature] = $functions + [
69
- // 'namespace' => $signature,
70
- 'script' => url($dist.'.js'),
71
- 'version' => $options['version'] ?? kksr('version'),
72
- 'attributes' => $attributes,
73
- 'dependencies' => array_merge($options['dependencies'] ?? [], $dependencies),
74
- ];
75
  }
76
  }
77
 
18
 
19
  use DirectoryIterator;
20
 
21
+ /** @return array<string,array<string,mixed>> */
22
+ function autoload_blocks(string $path): array
23
  {
 
 
 
24
  if (! is_dir($path)) {
25
  return [];
26
  }
27
 
 
 
 
 
 
 
28
  $autoloads = [];
29
 
30
  foreach (new DirectoryIterator($path) as $fileInfo) {
31
+ if (! ($fileInfo->isDot() || $fileInfo->isFile())) {
32
+ $block = autoload_block($fileInfo->getPathname());
33
+ $autoloads[$block['name']] = $block;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
  }
36
 
src/functions/block.php CHANGED
@@ -16,23 +16,119 @@ if (! defined('KK_STAR_RATINGS')) {
16
  exit();
17
  }
18
 
19
- function block(string $namespace, array $payload, string $slug = null): string
 
 
 
 
 
 
20
  {
21
- $slug = $slug ?: ($payload['slug'] ?? trim(preg_replace('/[^\w]+/', '_', $namespace), '_'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- wp_register_script(
24
- $slug,
25
- $payload['script'],
26
- $payload['dependencies'] ?? [],
27
- $payload['version'] ?? kksr('version')
28
- );
29
 
30
- register_block_type($namespace, array_filter([
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  'api_version' => 2,
32
- 'attributes' => $payload['attributes'] ?? [],
33
- 'editor_script' => $slug,
34
- 'render_callback' => $payload['block'] ?? null,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ]));
36
 
37
- return $slug;
 
 
 
 
 
38
  }
16
  exit();
17
  }
18
 
19
+ /**
20
+ * @param string|array<string,mixed> $blockOrDeprecatedNamespace
21
+ * @param array<string,mixed> $deprecatedPayload
22
+ *
23
+ * @return string|array<string,mixed>
24
+ */
25
+ function block($blockOrDeprecatedNamespace, array $deprecatedPayload = [], string $deprecatedSlug = null)
26
  {
27
+ static $genAssetArgs;
28
+
29
+ // Support addons depending on version <= 5.3.4
30
+ if (! is_array($blockOrDeprecatedNamespace)) {
31
+ return block_5_3_4(
32
+ $blockOrDeprecatedNamespace,
33
+ $deprecatedPayload,
34
+ $deprecatedSlug
35
+ );
36
+ }
37
+
38
+ $block = $blockOrDeprecatedNamespace;
39
+
40
+ $genAssetArgs = $genAssetArgs ?: static function (string $slug, $srcOrOptions) {
41
+ if (! $srcOrOptions) {
42
+ return [];
43
+ }
44
+
45
+ $options = $srcOrOptions;
46
+ if (! is_array($srcOrOptions)) {
47
+ $options = ['src' => $srcOrOptions];
48
+ }
49
+
50
+ if (! isset($options['src'])) {
51
+ // The 'src' key is required.
52
+ return [];
53
+ }
54
+
55
+ return $options + compact('slug') + ['deps' => []] + [
56
+ 'version' => kksr('version'), //(string) filemtime($options['src']),
57
+ ];
58
+ };
59
 
60
+ if (! isset($block['name'])) {
61
+ // The 'name' is required.
62
+ return [];
63
+ }
 
 
64
 
65
+ if (! isset($block['editor_script'])) {
66
+ // The 'editor_script' is required.
67
+ return [];
68
+ }
69
+
70
+ // Generate name.
71
+ if (strpos($block['name'], '/') === false) {
72
+ $block['name'] = prefix($block['name'], kksr('slug').'/');
73
+ }
74
+
75
+ // Fill missing values.
76
+ $block += [
77
+ 'data' => [],
78
+ ];
79
+
80
+ // Construct meta.
81
+ $block['meta'] = array_filter([
82
+ 'title' => $block['title'] ?? null,
83
+ 'api_version' => $block['api_version'] ?? null,
84
+ ]) + ($block['meta'] ?? []) + [
85
  'api_version' => 2,
86
+ ];
87
+
88
+ // Generate title.
89
+ if (! isset($block['meta']['title'])) {
90
+ $title = explode('/', $block['name'], 2)[1];
91
+ $block['meta']['title'] = ucwords(trim(preg_replace('/[^\w]+/', ' ', $title)));
92
+ }
93
+
94
+ // Change meta key case ('foo_bar' => 'fooBar').
95
+ $block['meta'] = array_combine(array_map(function ($key) {
96
+ return str_replace('_', '', lcfirst(ucwords($key, '_')));
97
+ }, array_keys($block['meta'])), array_values($block['meta']));
98
+
99
+ // Generate slug.
100
+ $slug = trim(preg_replace('/[^\w]+/', '_', $block['name']), '_');
101
+
102
+ // Register scripts and styles.
103
+ $block['editor_script'] = $genAssetArgs("{$slug}_editor", $block['editor_script']);
104
+ $editorScriptReqDeps = [kksr('slug').'-blocks', 'wp-element'];
105
+ $block['editor_script']['deps'] = array_unique(array_merge($editorScriptReqDeps, $block['editor_script']['deps']));
106
+ foreach ([
107
+ ['wp_register_script', $block['editor_script']],
108
+ ['wp_register_style', $block['editor_style'] = $genAssetArgs("{$slug}_editor", $block['editor_style'] ?? null)],
109
+ ['wp_register_script', $block['script'] = $genAssetArgs($slug, $block['script'] ?? null)],
110
+ ['wp_register_style', $block['style'] = $genAssetArgs($slug, $block['style'] ?? null)],
111
+ ] as [$fn, $args]) {
112
+ if ($args) {
113
+ $fn($args['slug'], $args['src'], $args['deps'], $args['version']);
114
+ }
115
+ }
116
+
117
+ // Finally, register the block.
118
+ register_block_type($block['name'], array_filter([
119
+ 'api_version' => $block['meta']['apiVersion'],
120
+ 'attributes' => $block['attributes'] ?? [],
121
+ 'render_callback' => $block['render'] ?? null,
122
+ 'editor_script' => $block['editor_script']['slug'],
123
+ 'editor_style' => $block['editor_style'] ? $block['editor_style']['slug'] : null,
124
+ 'script' => $block['script'] ? $block['script']['slug'] : null,
125
+ 'style' => $block['style'] ? $block['style']['slug'] : null,
126
  ]));
127
 
128
+ // Return the payload necessary for the js block api.
129
+ return [
130
+ 'name' => $block['name'],
131
+ 'meta' => $block['meta'],
132
+ 'data' => $block['data'],
133
+ ];
134
  }
src/functions/block_5.3.4.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of bhittani/kk-star-ratings.
5
+ *
6
+ * (c) Kamal Khan <shout@bhittani.com>
7
+ *
8
+ * For the full copyright and license information, please view
9
+ * the LICENSE file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Bhittani\StarRating\functions;
13
+
14
+ if (! defined('KK_STAR_RATINGS')) {
15
+ http_response_code(404);
16
+ exit();
17
+ }
18
+
19
+ /**
20
+ * @param array<string,mixed> $payload
21
+ */
22
+ function block_5_3_4(string $namespace, array $payload = [], string $slug = null): string
23
+ {
24
+ $slug = $slug ?: ($payload['slug'] ?? trim(preg_replace('/[^\w]+/', '_', $namespace), '_'));
25
+
26
+ wp_register_script(
27
+ $slug,
28
+ $payload['script'],
29
+ $payload['dependencies'] ?? [],
30
+ $payload['version'] ?? kksr('version')
31
+ );
32
+
33
+ register_block_type($namespace, array_filter([
34
+ 'api_version' => 2,
35
+ 'attributes' => $payload['attributes'] ?? [],
36
+ 'editor_script' => $slug,
37
+ 'render_callback' => $payload['block'] ?? null,
38
+ ]));
39
+
40
+ return $slug;
41
+ }