You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: snippets/snippets.code-snippets
+79-3Lines changed: 79 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
{
2
-
// Theme Redone WordPress snippets
2
+
// Theme Redone snippets
3
3
4
4
"trb:text": {
5
5
"scope": "json",
@@ -244,7 +244,83 @@
244
244
"\t}",
245
245
"}"
246
246
],
247
-
"description": "This snippet of code will generate a Video Selector. The field name will be video_field_name, its label will be “Video” and by default, it won’t have a selected video."
247
+
"description": "This snippet of code will generate a CTA control. The field name will be “link_field_name”, its label will be “Link” and it will be empty by default."
248
+
},
249
+
250
+
"trb:objectselector": {
251
+
"scope": "json",
252
+
"prefix": "trbs:objectselector",
253
+
"body": [
254
+
"\"${1:object_field_name}\": {",
255
+
"\t\"type\": \"object\",",
256
+
"\t\"field_meta\": {",
257
+
"\t\t\"object_type\": \"${2|post,term|}\",",
258
+
"\t\t\"objects\": [\"${3:posts}\"],",
259
+
"\t\t\"type\": \"object_selector\",",
260
+
"\t\t\"label\": \"${4:Post}\"",
261
+
"\t},",
262
+
"\t\"default\": {",
263
+
"\t\t\"id\": ${5:null},",
264
+
"\t\t\"title\": \"${6}\"",
265
+
"\t}",
266
+
"}"
267
+
],
268
+
"description": "This snippet of code will generate an object_selector control. The field name will be “object_field_name”, its label will be “Post” and it will not have anything selected by default. This particular example will make it possible for us to search for, and select one post of the “post” post type."
248
269
},
249
270
250
-
}
271
+
"trb:repeater": {
272
+
"scope": "json",
273
+
"prefix": "trbs:repeater",
274
+
"body": [
275
+
"\"${1:repeater_field_name}\": {",
276
+
"\t\"type\": \"array\",",
277
+
"\t\"field_meta\": {",
278
+
"\t\t\"type\": \"repeater\",",
279
+
"\t\t\"label\": \"${2:Fields}\",",
280
+
"\t\t\"subfields\": {",
281
+
"\t\t\t\"title\": {",
282
+
"\t\t\t\t\"type\": \"object\",",
283
+
"\t\t\t\t\"field_meta\": {",
284
+
"\t\t\t\t\t\"type\": \"text\",",
285
+
"\t\t\t\t\t\"label\": \"Title\"",
286
+
"\t\t\t\t},",
287
+
"\t\t\t\t\"default\": {",
288
+
"\t\t\t\t\t\"text\": \"\"",
289
+
"\t\t\t\t}",
290
+
"\t\t\t},",
291
+
"\t\t\t\"cta\": {",
292
+
"\t\t\t\t\"type\": \"object\",",
293
+
"\t\t\t\t\"field_meta\": {",
294
+
"\t\t\t\t\t\"type\": \"cta\",",
295
+
"\t\t\t\t\t\"label\": \"CTA\"",
296
+
"\t\t\t\t},",
297
+
"\t\t\t\t\"default\": {",
298
+
"\t\t\t\t\t\"title\": \"\",",
299
+
"\t\t\t\t\t\"url\": \"\",",
300
+
"\t\t\t\t\t\"target\": false",
301
+
"\t\t\t\t}",
302
+
"\t\t\t},",
303
+
"\t\t\t\"image\": {",
304
+
"\t\t\t\t\"type\": \"object\",",
305
+
"\t\t\t\t\"field_meta\": {",
306
+
"\t\t\t\t\t\"type\": \"image\",",
307
+
"\t\t\t\t\t\"label\": \"Image\"",
308
+
"\t\t\t\t},",
309
+
"\t\t\t\t\"default\": {",
310
+
"\t\t\t\t\t\"src\": \"\",",
311
+
"\t\t\t\t\t\"id\": null",
312
+
"\t\t\t\t}",
313
+
"\t\t\t}",
314
+
"\t\t}",
315
+
"\t},",
316
+
"\t\"default\": []",
317
+
"}"
318
+
],
319
+
"description": "
320
+
This snippet of code will generate a repeater control. The field name will be “repeater_field_name”, its label will be “Fields” and it will be empty by default. The repeater will have three subfields: title, cta and image. The title will be a text field, the cta will be a CTA control and the image will be an Image Selector. --- It is also possible to use repeater fields inside repeater fields. This way, we can create nested repeaters. This is useful for creating complex data structures. But, only one level deep."
0 commit comments