-
Notifications
You must be signed in to change notification settings - Fork 0
/
prism-data-posts.php
505 lines (461 loc) · 12.5 KB
/
prism-data-posts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
<?php
/**
* Plugin Name: Prism | Posts Data
* Description: Activate to load sample 'Posts' data
* Author: Casey Patrick Driscoll
* Author URI: https://caseypatrickdriscoll.com
*/
class Prism_Posts_Data {
static function init() {
register_activation_hook( __FILE__, array( __CLASS__, 'install' ) );
add_filter( 'prism_branches', array( __CLASS__, 'add_branches' ), 111 );
}
private static function rand_date() {
$int = rand( 1000000000, 1446068703 ); // 2015-10-28 17:45:12 (close to it)
return date( "Y-m-d H:i:s", $int );
}
public static function add_branches( $branches ) {
$post_branches = array(
array(
'title' => 'Posts',
'slug' => array(
'plural' => 'posts',
'single' => 'post'
),
'icon' => 'fa-thumb-tack',
'connections' => array()
),
array(
'title' => 'Swatches',
'slug' => array(
'plural' => 'swatches',
'single' => 'swatch'
),
'icon' => 'fa-sticky-note-o',
'connections' => array()
),
array(
'title' => 'Crayons',
'slug' => array(
'plural' => 'crayons',
'single' => 'crayon'
),
'connections' => array()
),
array(
'title' => 'Cities',
'slug' => array(
'plural' => 'cities',
'single' => 'city'
),
'icon' => 'fa-map',
'connections' => array()
),
);
return array_merge( $branches, $post_branches );
}
static function install() {
P2P_Storage::install();
$posts = array(
array(
'post_title' => 'You think Im an ignorant savage',
'post_content' => ''
),
array(
'post_title' => 'And you\'ve been so many places',
'post_content' => ''
),
array(
'post_title' => 'I guess it must be so',
'post_content' => ''
),
array(
'post_title' => 'But still I cannot see',
'post_content' => ''
),
array(
'post_title' => 'If the savage one is me',
'post_content' => ''
),
array(
'post_title' => 'How can there be so much that you dont know',
'post_content' => ''
),
array(
'post_title' => 'You dont know',
'post_content' => ''
),
array(
'post_title' => 'You think you own whatever land you land on',
'post_content' => ''
),
array(
'post_title' => 'The Earth is just a dead thing you can claim',
'post_content' => ''
),
array(
'post_title' => 'But I know every rock and tree and creature',
'post_content' => ''
),
array(
'post_title' => 'Has a life, has a spirit, has a name',
'post_content' => ''
),
array(
'post_title' => 'You think the only people who are people',
'post_content' => ''
),
array(
'post_title' => 'Are the people who look and think like you',
'post_content' => ''
),
array(
'post_title' => 'But if you walk the footsteps of a stranger',
'post_content' => ''
),
array(
'post_title' => 'You\'ll learn things you never knew, you never knew',
'post_content' => ''
),
array(
'post_title' => 'Have you ever heard the wolf cry to the blue corn moon',
'post_content' => ''
),
array(
'post_title' => 'Or asked the grinning bobcat why he grinned',
'post_content' => ''
),
array(
'post_title' => 'Can you sing with all the voices of the mountains',
'post_content' => ''
),
array(
'post_title' => 'Can you paint with all the colors of the wind',
'post_content' => ''
)
);
foreach ( $posts as $i => $post ) {
$post['post_status'] = 'publish';
$post['post_date'] = self::rand_date();
$posts[$i]['id'] = wp_insert_post( $post );
$url = 'http://lorempixel.com/500/500/';
$tmp = plugin_dir_path( __FILE__ ) . 'images/';
if ( ! file_exists( $tmp ) ) {
mkdir( $tmp , 0660, true );
}
$name = 'image_' . $i . '.jpg';
if ( ! file_exists( $tmp . $name ) )
file_put_contents( $tmp . $name, file_get_contents( $url ) );
$file_array = array( 'tmp_name' => $tmp . $name, 'name' => $name );
$media = media_handle_sideload( $file_array, $posts[$i]['id'] );
set_post_thumbnail( $posts[$i]['id'], $media );
}
// SWATCHES
// https://en.wikipedia.org/wiki/List_of_colors:_A%E2%80%93F
$swatches = array(
array(
'post_title' => 'Absolute Zero',
'post_content' => ''
),
array(
'post_title' => 'Aero',
'post_content' => ''
),
array(
'post_title' => 'Almond',
'post_content' => ''
),
array(
'post_title' => 'Amazon',
'post_content' => ''
),
array(
'post_title' => 'Amber',
'post_content' => ''
),
array(
'post_title' => 'Antique Ruby',
'post_content' => ''
),
array(
'post_title' => 'Barn Red',
'post_content' => ''
),
array(
'post_title' => 'Bazaar',
'post_content' => ''
),
array(
'post_title' => 'B\'dazzled Blue',
'post_content' => ''
),
array(
'post_title' => 'Black Olive',
'post_content' => ''
),
array(
'post_title' => 'Blue',
'post_content' => ''
),
array(
'post_title' => 'Blush',
'post_content' => ''
),
array(
'post_title' => 'Bright Lilac',
'post_content' => ''
),
array(
'post_title' => 'Bubble Gum',
'post_content' => ''
),
array(
'post_title' => 'Byzantium',
'post_content' => ''
),
array(
'post_title' => 'Canary Yellow',
'post_content' => ''
),
array(
'post_title' => 'Candy Apple Red',
'post_content' => ''
),
array(
'post_title' => 'Caribbean Green',
'post_content' => ''
),
array(
'post_title' => 'Carrot Orange',
'post_content' => ''
),
array(
'post_title' => 'Cerise',
'post_content' => ''
),
array(
'post_title' => 'Cherry',
'post_content' => ''
),
array(
'post_title' => 'Chestnut',
'post_content' => ''
),
array(
'post_title' => 'Congo Pink',
'post_content' => ''
),
array(
'post_title' => 'Coquelicot',
'post_content' => ''
),
array(
'post_title' => 'Cordovan',
'post_content' => ''
),
array(
'post_title' => 'Crimson',
'post_content' => ''
),
array(
'post_title' => 'Cyber Yellow',
'post_content' => ''
),
array(
'post_title' => 'Daffodil',
'post_content' => ''
),
array(
'post_title' => 'Dark Lava',
'post_content' => ''
),
array(
'post_title' => 'Deep Champagne',
'post_content' => ''
),
array(
'post_title' => 'Desert',
'post_content' => ''
),
array(
'post_title' => 'Dollar Bill',
'post_content' => ''
),
array(
'post_title' => 'Drab',
'post_content' => ''
),
array(
'post_title' => 'Ecru',
'post_content' => ''
),
array(
'post_title' => 'Eggplant',
'post_content' => ''
),
array(
'post_title' => 'Electric Ultramarine',
'post_content' => ''
),
array(
'post_title' => 'Emerald',
'post_content' => ''
),
array(
'post_title' => 'Eminence',
'post_content' => ''
),
array(
'post_title' => 'Eton Blue',
'post_content' => ''
),
array(
'post_title' => 'Falu Red',
'post_content' => ''
),
array(
'post_title' => 'Fandango',
'post_content' => ''
),
array(
'post_title' => 'Feldgrau',
'post_content' => ''
),
);
foreach ( $swatches as $i => $swatch ) {
$swatch['post_status'] = 'publish';
$swatch['post_type'] = 'swatches';
$swatch['post_date'] = self::rand_date();
$swatches[$i]['id'] = wp_insert_post( $swatch );
}
// Cities (Probably based on Pokemon Cities, which are based on colors)
// http://bulbapedia.bulbagarden.net/wiki/List_of_cities_and_towns
$cities = array(
array(
'post_title' => 'Celadon City',
'post_content' => ''
),
array(
'post_title' => 'Cerulean City',
'post_content' => ''
),
array(
'post_title' => 'Cinnabar Island',
'post_content' => ''
),
array(
'post_title' => 'Fuchsia City',
'post_content' => ''
),
array(
'post_title' => 'Lavendar Town',
'post_content' => ''
),
array(
'post_title' => 'Pallet Town',
'post_content' => ''
),
array(
'post_title' => 'Pewter City',
'post_content' => ''
),
array(
'post_title' => 'Saffron City',
'post_content' => ''
),
array(
'post_title' => 'Vermilion City',
'post_content' => ''
),
array(
'post_title' => 'Viridian City',
'post_content' => ''
),
);
foreach ( $cities as $i => $city ) {
$city['post_status'] = 'publish';
$city['post_type'] = 'cities';
$city['post_date'] = self::rand_date();
$cities[$i]['id'] = wp_insert_post( $city );
}
// CRAYONS
// https://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors
$crayons = array(
array(
'post_title' => 'Maximum Red',
'post_content' => ''
),
array(
'post_title' => 'Light Venetian Red',
'post_content' => ''
),
array(
'post_title' => 'Macaroni and Cheese',
'post_content' => ''
),
array(
'post_title' => 'Mango Tango',
'post_content' => ''
),
array(
'post_title' => 'Goldenrod',
'post_content' => ''
),
array(
'post_title' => 'Maximum Yellow',
'post_content' => ''
),
array(
'post_title' => 'Inchworm',
'post_content' => ''
),
array(
'post_title' => 'Fern',
'post_content' => ''
),
array(
'post_title' => 'Shamrock',
'post_content' => ''
),
array(
'post_title' => 'Tropical Rain Forest',
'post_content' => ''
),
array(
'post_title' => 'Outer Space',
'post_content' => ''
),
array(
'post_title' => 'Pacific Blue',
'post_content' => ''
),
array(
'post_title' => 'Cornflower',
'post_content' => ''
),
array(
'post_title' => 'Denim',
'post_content' => ''
),
array(
'post_title' => 'Indigo',
'post_content' => ''
),
array(
'post_title' => 'Royal Purple',
'post_content' => ''
),
array(
'post_title' => 'Brilliant Rose',
'post_content' => ''
),
);
foreach ( $crayons as $i => $crayon ) {
$crayon['post_status'] = 'publish';
$crayon['post_type'] = 'crayons';
$crayon['post_date'] = self::rand_date();
$crayons[$i]['id'] = wp_insert_post( $crayon );
}
}
}
Prism_Posts_Data::init();