-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
748 lines (627 loc) · 25.4 KB
/
functions.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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
<?php
define('_TEMPLATEURL',WP_CONTENT_URL.'/themes/'.basename(TEMPLATEPATH));
//deactivate WordPress function and activate own function
remove_shortcode('gallery', 'gallery_shortcode');
add_shortcode('gallery', 'my_gallery_shortcode');
add_editor_style();
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 570, 139, true ); //this is the same as project-index
add_image_size('slider', 960, 414, true);
add_image_size('featured', 294, 220, true);
add_image_size('inline-thumbnail', 162, 108, true);
add_image_size('inline-large', 572, 381, false);
add_image_size('project-index', 570, 139, true);
add_image_size('resources-index', 107, 98, true);
// add_action( 'init', 'register_my_taxonomies', 0 );
add_action('init', 'my_init');
add_action( 'manage_posts_custom_column' , 'custom_columns' );
add_filter('manage_edit-person_columns' , 'set_edit_person_columns');
add_filter('post_updated_messages', 'my_post_updated_messages');
add_filter( 'map_meta_cap', 'my_map_meta_cap', 10, 4 );
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
// add your extension to the array
$existing_mimes['unity3d'] = 'application/vnd.unity';
// add as many as you like
// and return the new full result
return $existing_mimes;
}
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() )
$query->set( 'post_type', array( 'post', 'page', 'game', 'resource', 'person') );
return $query;
}
// custom constant (opposite of TEMPLATEPATH)
define('_TEMPLATEURL', WP_CONTENT_URL . '/themes/' . basename(TEMPLATEPATH));
include_once 'WPAlchemy/MetaBox.php';
// include css to style the custom meta boxes, this should be a global
// stylesheet used by all similar meta boxes
$game_credits = new WPAlchemy_MetaBox(array
(
'id' => '_game_credits', // underscore prefix hides fields from the custom fields area
'title' => 'Credits',
'template' => TEMPLATEPATH . '/custom/credits_meta.php',
'types' => array('game'), // added only for custom post type "game"
'priority' => 'low',
));
$person_title = new WPAlchemy_MetaBox(array
(
'id' => '_person_title',
'title' => 'Title',
'template' => TEMPLATEPATH . '/custom/person_title_meta.php',
'types' => array('person'),
'priority' => 'low',
'context' => 'side',
));
$person_department = new WPAlchemy_MetaBox(array
(
'id' => '_person_department',
'title' => 'Department',
'template' => TEMPLATEPATH . '/custom/person_department_meta.php',
'types' => array('person'),
'priority' => 'low',
'context' => 'side',
));
$lab_employee = new WPAlchemy_MetaBox(array
(
'id' => '_lab_employee',
'title' => 'Job Title',
'template' => TEMPLATEPATH . '/custom/job_title_meta.php',
'types' => array('person'),
'priority' => 'low',
'context' => 'side',
));
$short_description = new WPAlchemy_MetaBox(array
(
'id' => '_short_description',
'title' => 'Short Description',
'template' => TEMPLATEPATH . '/custom/short_description_meta.php',
'types' => array('game', 'resource', 'person', 'page'),
'priority' => 'high',
));
$author_bio = new WPAlchemy_MetaBox(array
(
'id' => '_author_bio',
'title' => 'About the author',
'template' => TEMPLATEPATH . '/custom/author_bio_meta.php',
'types' => array('resource'),
'priority' => 'high',
));
$link_out = new WPAlchemy_MetaBox(array
(
'id' => '_link_out',
'title' => 'Link Out',
'template' => TEMPLATEPATH . '/custom/link_out_meta.php',
'types' => array('game', 'resource', 'person'),
'priority' => 'low',
));
$context = new WPAlchemy_MetaBox(array
(
'id' => '_context',
'title' => 'Context',
'template' => TEMPLATEPATH . '/custom/context_meta.php',
'types' => array('game'),
'priority' => 'high',
));
$medium = new WPAlchemy_MetaBox(array
(
'id' => '_medium',
'title' => 'Medium',
'template' => TEMPLATEPATH . '/custom/medium_meta.php',
'types' => array('game'),
'priority' => 'high',
));
$attachments = new WPAlchemy_MetaBox(array
(
'id' => '_attachments',
'title' => 'Attachments',
'template' => TEMPLATEPATH . '/custom/attachments_meta.php',
'types' => array('game', 'resource'),
'priority' => 'low',
));
$eventdate = new WPAlchemy_MetaBox(array
(
'id' => '_eventdate',
'title' => 'Event Date',
'template' => TEMPLATEPATH . '/custom/eventdate_meta.php',
'types' => array('resource'),
'include_category' => array('Events','Lecture', 'Show', 'Workshop'),
'context' => 'side',
));
$requirements = new WPAlchemy_MetaBox(array
(
'id' => '_requirements',
'title' => 'Requirements',
'template' => TEMPLATEPATH . '/custom/requirements_meta.php',
'types' => array('resource'),
'include_category' => array('Events','Lecture', 'Show', 'Workshop'),
));
function my_init()
{
if (is_admin())
{
wp_enqueue_script('custom_js_ui',_TEMPLATEURL .'/custom/js/jquery-ui-1.8.11.custom.min.js',array('custom_js_jquery'));
wp_enqueue_script('custom_js_timepicker',_TEMPLATEURL .'/custom/js/jquery-ui-timepicker-addon.js',array('custom_js_ui', 'custom_js_jquery'));
wp_enqueue_script('custom_js_custom',_TEMPLATEURL .'/custom/js/custom.js',array('custom_js_timepicker','custom_js_jquery'),NULL,TRUE);
wp_enqueue_style('custom_css_daterangepicker',_TEMPLATEURL .'/custom/css/ui-lightness/jquery-ui-1.8.11.custom.css');
wp_enqueue_style('custom_meta_css', _TEMPLATEURL . '/custom/meta.css');
}
$menu_locations = array(
'main-nav' => 'Header',
'footer-nav' => 'Footer',
'people-sub-nav' => 'People Subnav',
);
register_nav_menus($menu_locations);
create_post_types();
}
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'contact',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
register_sidebar(array(
'name' => 'news',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
));
}
function create_post_types(){
create_game_type();
create_resource_type();
create_people_type();
create_status_taxonomy();
}
function create_game_type() {
$capabilities = array(
'publish_posts' => 'publish_games',
'edit_posts' => 'edit_games',
'edit_others_posts' => 'edit_others_games',
'delete_posts' => 'delete_games',
'delete_others_posts' => 'delete_others_games',
'read_private_posts' => 'read_private_games',
'edit_post' => 'edit_game',
'delete_post' => 'delete_game',
'read_post' => 'read_game',
);
$labels = array(
'name' => _x('Games', 'post type general name'),
'singular_name' => _x('Game', 'post type singular name'),
'add_new' => _x('Add Game', 'game'),
'add_new_item' => __('Add New Game'),
'edit_item' => __('Edit Game'),
'new_item' => __('New Game'),
'view_item' => __('View Game'),
'search_items' => __('Search Game'),
'not_found' => __('No Games found'),
'not_found_in_trash' => __('No Games found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'_builtin' => false, // It's a custom post type, not built in!
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array("slug" => "games"), // Permalinks format
'register_meta_box_cb' => 'add_game_metaboxes',
'capability_type' => 'game',
'capabilities' => $capabilities,
'hierarchical' => false,
'supports' => array('title','editor','thumbnail',),
'menu_position' => 5,
'menu_icon' => get_stylesheet_directory_uri() . '/images/star.png',
'taxonomies' => array('post_tag',),
);
register_post_type('game',$args);
}
function create_resource_type() {
$capabilities = array(
'publish_posts' => 'publish_resources',
'edit_posts' => 'edit_resources',
'edit_others_posts' => 'edit_others_resources',
'delete_posts' => 'delete_resources',
'delete_others_posts' => 'delete_others_resources',
'read_private_posts' => 'read_private_resources',
'edit_post' => 'edit_resources',
'delete_post' => 'delete_resources',
'read_post' => 'read_resources',
);
$labels = array(
'name' => _x('Resources', 'post type general name'),
'singular_name' => _x('Resource', 'post type singular name'),
'add_new' => _x('Add Resource', 'resource'),
'add_new_item' => __('Add New Resource'),
'edit_item' => __('Edit Resource'),
'new_item' => __('New Resource'),
'view_item' => __('View Resource'),
'search_items' => __('Search Resource'),
'not_found' => __('No Games Resource'),
'not_found_in_trash' => __('No Resources found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'_builtin' => false, // It's a custom post type, not built in!
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array("slug" => "resources"), // Permalinks format
'register_meta_box_cb' => 'add_resource_metaboxes',
'capability_type' => 'resource',
'capabilities' => $capabilities,
'hierarchical' => true,
'supports' => array('title','editor','thumbnail',),
'menu_position' => 5,
'menu_icon' => get_stylesheet_directory_uri() . '/images/star.png',
'taxonomies' => array('post_tag','category'),
);
register_post_type('resource',$args);
}
function create_people_type(){
$capabilities = array(
'publish_posts' => 'publish_people',
'edit_posts' => 'edit_people',
'edit_others_posts' => 'edit_others_people',
'delete_posts' => 'delete_people',
'delete_others_posts' => 'delete_others_people',
'read_private_posts' => 'read_private_people',
'edit_post' => 'edit_person',
'delete_post' => 'delete_person',
'read_post' => 'read_person',
);
$labels = array(
'name' => _x('People', 'post type general name'),
'singular_name' => _x('Person', 'post type singular name'),
'add_new' => _x('Add Person', 'person'),
'add_new_item' => __('Add New Person'),
'edit_item' => __('Edit Person'),
'new_item' => __('New Person'),
'view_item' => __('View Person'),
'search_items' => __('Search People'),
'not_found' => __('No People found'),
'not_found_in_trash' => __('No People found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'_builtin' => false, // It's a custom post type, not built in!
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array("slug" => "person"), // Permalinks format
'capability_type' => 'person',
'capabilities' => $capabilities,
'hierarchical' => false,
'supports' => array('thumbnail','title'),
'menu_position' => 5,
// 'taxonomies' => array('post_tag','category'),
// 'menu_icon' => get_stylesheet_directory_uri() . '/images/star.png',
);
register_post_type('person',$args);
}
function create_status_taxonomy(){
// Add new taxonomy, NOT hierarchical (like tags)
$labels = array(
'name' => _x( 'Status', 'taxonomy general name' ),
'singular_name' => _x( 'Status', 'taxonomy singular name' ),
'search_items' => __( 'Search Status' ),
'popular_items' => __( 'Popular Status' ),
'all_items' => __( 'All Status' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Status' ),
'update_item' => __( 'Update Status' ),
'add_new_item' => __( 'Add New Status' ),
'new_item_name' => __( 'New Status Name' ),
'separate_items_with_commas' => __( 'These are people subnav filters. Separate each term with commas' ),
'add_or_remove_items' => __( 'Add or remove Status' ),
'choose_from_most_used' => __( 'Choose from the most used Status' )
);
register_taxonomy('status','person',array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'update_count_callback' => '_update_post_term_count',
'rewrite' => array( 'slug' => 'people' ),
));
}
function my_post_updated_messages( $messages ) {
$messages['game'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __('Game updated. <a href="%s">View Game</a>'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
4 => __('Game updated.'),
/* translators: %s: date and time of the revision */
5 => isset($_GET['revision']) ? sprintf( __('Game restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __('Game published. <a href="%s">View Game</a>'), esc_url( get_permalink($post_ID) ) ),
7 => __('Game saved.'),
8 => sprintf( __('Game submitted. <a target="_blank" href="%s">Preview Game</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Game scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Game</a>'),
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('Game draft updated. <a target="_blank" href="%s">Preview Game</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
$messages['resource'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __('Resource updated. <a href="%s">View Resource</a>'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
4 => __('Resource updated.'),
/* translators: %s: date and time of the revision */
5 => isset($_GET['revision']) ? sprintf( __('Resource restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __('Resource published. <a href="%s">View Resource</a>'), esc_url( get_permalink($post_ID) ) ),
7 => __('Resource saved.'),
8 => sprintf( __('Resource submitted. <a target="_blank" href="%s">Preview Resource</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Resource scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Resource</a>'),
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('Resource draft updated. <a target="_blank" href="%s">Preview Resource</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
$messages['person'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __('Person updated. <a href="%s">View Person</a>'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
4 => __('Person updated.'),
/* translators: %s: date and time of the revision */
5 => isset($_GET['revision']) ? sprintf( __('Person restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __('Person published. <a href="%s">View Person</a>'), esc_url( get_permalink($post_ID) ) ),
7 => __('Person saved.'),
8 => sprintf( __('Person submitted. <a target="_blank" href="%s">Preview Person</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Person scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Person</a>'),
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('Person draft updated. <a target="_blank" href="%s">Preview Person</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
return $messages;
}
function add_help_text($contextual_help, $screen_id, $screen) {
//$contextual_help .= var_dump($screen); // use this to help determine $screen->id
if ('student_project' == $screen->id ) {
$contextual_help =
'<p>' . __('Things to remember when adding or editing a Game:') . '</p>' .
'<ul>' .
'<li>' . __('Specify the correct class number such as 152B, or 157A.') . '</li>' .
'<li>' . __('Specify the correct team mebers of the Game.') . '</li>' .
'</ul>' .
'<p>' . __('If you want to schedule the Student Project to be published in the future:') . '</p>' .
'<ul>' .
'<li>' . __('Under the Publish module, click on the Edit link next to Publish.') . '</li>' .
'<li>' . __('Change the date to the date to actual publish this article, then click on Ok.') . '</li>' .
'</ul>' .
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Posts_Edit_SubPanel" target="_blank">Edit Posts Documentation</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' ;
} elseif ( 'edit-book' == $screen->id ) {
$contextual_help =
'<p>' . __('This is the help screen displaying the table of Game blah blah blah.') . '</p>' ;
}
if ('book' == $screen->id ) {
$contextual_help =
'<p>' . __('Things to remember when adding or editing a book:') . '</p>' .
'<ul>' .
'<li>' . __('Specify the correct genre such as Mystery, or Historic.') . '</li>' .
'<li>' . __('Specify the correct writer of the book. Remember that the Author module refers to you, the author of this book review.') . '</li>' .
'</ul>' .
'<p>' . __('If you want to schedule the book review to be published in the future:') . '</p>' .
'<ul>' .
'<li>' . __('Under the Publish module, click on the Edit link next to Publish.') . '</li>' .
'<li>' . __('Change the date to the date to actual publish this article, then click on Ok.') . '</li>' .
'</ul>' .
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Posts_Edit_SubPanel" target="_blank">Edit Posts Documentation</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' ;
} elseif ( 'edit-book' == $screen->id ) {
$contextual_help =
'<p>' . __('This is the help screen displaying the table of books blah blah blah.') . '</p>' ;
}
return $contextual_help;
}
function my_map_meta_cap( $caps, $cap, $user_id, $args ) {
/* If editing, deleting, or reading a game, get the post and post type object. */
if ( 'edit_game' == $cap || 'delete_game' == $cap || 'read_game' == $cap ) {
$post = get_post( $args[0] );
$post_type = get_post_type_object( $post->post_type );
/* Set an empty array for the caps. */
$caps = array();
}
/* If editing, deleting, or reading a resource, get the post and post type object. */
if ( 'edit_resouce' == $cap || 'delete_resource' == $cap || 'read_resouce' == $cap ) {
$post = get_post( $args[0] );
$post_type = get_post_type_object( $post->post_type );
/* Set an empty array for the caps. */
$caps = array();
}
if ( 'edit_person' == $cap || 'delete_person' == $cap || 'read_person' == $cap ) {
$post = get_post( $args[0] );
$post_type = get_post_type_object( $post->post_type );
/* Set an empty array for the caps. */
$caps = array();
}
/* If editing a game, assign the required capability. */
if ( 'edit_game' == $cap ) {
if ( $user_id == $post->post_author )
$caps[] = $post_type->cap->edit_posts;
else
$caps[] = $post_type->cap->edit_others_posts;
}
/* If editing a resource, assign the required capability. */
if ( 'edit_resource' == $cap ) {
if ( $user_id == $post->post_author )
$caps[] = $post_type->cap->edit_posts;
else
$caps[] = $post_type->cap->edit_others_posts;
}
if ( 'edit_person' == $cap ) {
if ( $user_id == $post->post_author )
$caps[] = $post_type->cap->edit_posts;
else
$caps[] = $post_type->cap->edit_others_posts;
}
/* If deleting a game, assign the required capability. */
elseif ( 'delete_game' == $cap ) {
if ( $user_id == $post->post_author )
$caps[] = $post_type->cap->delete_posts;
else
$caps[] = $post_type->cap->delete_others_posts;
}
/* If deleting a resource, assign the required capability. */
elseif ( 'delete_resouce' == $cap ) {
if ( $user_id == $post->post_author )
$caps[] = $post_type->cap->delete_posts;
else
$caps[] = $post_type->cap->delete_others_posts;
}
elseif ( 'delete_person' == $cap ) {
if ( $user_id == $post->post_author )
$caps[] = $post_type->cap->delete_posts;
else
$caps[] = $post_type->cap->delete_others_posts;
}
/* If reading a private game, assign the required capability. */
elseif ( 'read_game' == $cap ) {
if ( 'private' != $post->post_status )
$caps[] = 'read';
elseif ( $user_id == $post->post_author )
$caps[] = 'read';
else
$caps[] = $post_type->cap->read_private_posts;
}
/* If reading a private resource, assign the required capability. */
elseif ( 'read_resouce' == $cap ) {
if ( 'private' != $post->post_status )
$caps[] = 'read';
elseif ( $user_id == $post->post_author )
$caps[] = 'read';
else
$caps[] = $post_type->cap->read_private_posts;
}
elseif ( 'read_person' == $cap ) {
if ( 'private' != $post->post_status )
$caps[] = 'read';
elseif ( $user_id == $post->post_author )
$caps[] = 'read';
else
$caps[] = $post_type->cap->read_private_posts;
}
/* Return the capabilities required by the user. */
return $caps;
}
function set_edit_person_columns($columns) {
return array(
'cb' => '<input type="checkbox" />',
'title' => __('Title'),
'date' => __('Date'),
'status' =>__( 'Status'),
);
}
function custom_columns( $column ) {
global $post;
switch ( $column )
{
case 'status':
$terms = get_the_term_list( $post->ID , 'status' , '' , ',' , '' );
if ( is_string( $terms ) ) {
echo $terms;
}
else
{
echo 'status not set';
}
break;
// case 'publisher':
// echo get_post_meta( $post->ID , 'publisher' , true );
// break;
}
}
//the own renamed function
function my_gallery_shortcode($attr) {
global $post, $wp_locale;
static $instance = 0;
$instance++;
// Allow plugins/themes to override the default gallery template.
$output = apply_filters('post_gallery', '', $attr);
if ( $output != '' )
return $output;
// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
if ( isset( $attr['orderby'] ) ) {
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
if ( !$attr['orderby'] )
unset( $attr['orderby'] );
}
extract(shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'thumbnail',
'include' => '',
'exclude' => ''
), $attr));
$id = intval($id);
if ( 'RAND' == $order )
$orderby = 'none';
if ( !empty($include) ) {
$include = preg_replace( '/[^0-9,]+/', '', $include );
$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( !empty($exclude) ) {
$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
} else {
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
}
if ( empty($attachments) )
return '';
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $att_id => $attachment )
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
return $output;
}
$itemtag = tag_escape($itemtag);
$captiontag = tag_escape($captiontag);
$columns = intval($columns);
$float = is_rtl() ? 'right' : 'left';
$selector = "gallery-{$instance}";
$output = apply_filters('gallery_style', "
<div id='$selector' class='gallery galleryid-{$id}'>");
$i = 0;
foreach ( $attachments as $id => $attachment ) {
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
$output .= "<{$itemtag} class='gallery-item col-{$columns}'>";
$output .= "
<{$icontag} class='gallery-icon'>
$link
</{$icontag}>";
if ( $captiontag && trim($attachment->post_excerpt) ) {
$output .= "
<{$captiontag} class='gallery-caption'>
" . wptexturize($attachment->post_excerpt) . "
</{$captiontag}>";
}
$output .= "</{$itemtag}>";
if ( $columns > 0 && ++$i % $columns == 0 )
$output .= '<br />';
}
$output .= "</div>\n";
return $output;
}
?>