PluginProbe
Time Clock – A WordPress Employee & Volunteer Time Clock Plugin / 1.2
Time Clock – A WordPress Employee & Volunteer Time Clock Plugin v1.2
trunk 1.0 1.0.1 1.1 1.1.1 1.1.2 1.2 1.2.1 1.2.2 1.2.3 1.3 1.3.1 1.3.2
time-clock / includes / admin / post_types.php

post_types.php in Time Clock – A WordPress Employee & Volunteer Time Clock Plugin 1.2, at includes/admin/post_types.php

98 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit; // Exit if accessed directly
4
5
6 // register post types
7 function etimeclockwp_register_post_type() {
8
9 if (current_user_can('update_plugins')) {
10
11 // activity
12 $activity_labels = array(
13 'name' => __( 'Activity', 'etimeclockwp' ),
14 'singular_name' => __( 'Activity', 'etimeclockwp' ),
15 'add_new_item' => __( 'Add New Activity', 'etimeclockwp' ),
16 'search_items' => __( 'Search Activity', 'etimeclockwp' ),
17 'edit_item' => __( 'Activity', 'etimeclockwp' ),
18 'new_item' => __( 'New Activity', 'etimeclockwp' ),
19 'not_found' => __( 'No Activity found', 'etimeclockwp' ),
20 'all_items' => __( 'Activity', 'etimeclockwp' )
21 );
22
23 $activity_args = array(
24 'labels' => $activity_labels,
25 'public' => false,
26 'show_ui' => true,
27 'exclude_from_search' => true,
28 'show_in_menu' => 'etimeclockwp_menu',
29 'has_archive' => true,
30 'map_meta_cap' => true,
31 'capabilities' => array('create_posts' => false ),
32 );
33 register_post_type('etimeclockwp_clock', $activity_args);
34
35
36 // users
37 $users_labels = array(
38 'name' => __( 'Users', 'etimeclockwp' ),
39 'singular_name' => __( 'User', 'etimeclockwp' ),
40 'add_new_item' => __( 'Add New User', 'etimeclockwp' ),
41 'search_items' => __( 'Search Users', 'etimeclockwp' ),
42 'edit_item' => __( 'Edit User', 'etimeclockwp' ),
43 'new_item' => __( 'New User', 'etimeclockwp' ),
44 'not_found' => __( 'No Users Found', 'etimeclockwp' ),
45 'all_items' => __( 'Users', 'etimeclockwp' )
46 );
47
48 $users_args = array(
49 'labels' => $users_labels,
50 'public' => true,
51 'publicly_queryable' => true,
52 'show_ui' => true,
53 'show_in_menu' => 'etimeclockwp_menu',
54 'query_var' => true,
55 'map_meta_cap' => true,
56 'has_archive' => false,
57 'hierarchical' => false,
58 'rewrite' => array('slug' => 'users','with_front' => false ),
59 );
60
61 register_post_type('etimeclockwp_users', $users_args);
62
63 }
64
65 }
66 add_action('init','etimeclockwp_register_post_type', 1 );
67
68
69 // hide post metaboxes in custom post types
70 function etimeclockwp_hide_post_type_boxes() {
71
72 // activity
73 remove_post_type_support( 'etimeclockwp_users', 'title' );
74 remove_post_type_support( 'etimeclockwp_users', 'editor' );
75 remove_post_type_support( 'etimeclockwp_clock', 'title' );
76 remove_post_type_support( 'etimeclockwp_clock', 'editor' );
77
78 }
79 add_action('init','etimeclockwp_hide_post_type_boxes');
80
81
82 // remove metaboxs in custom post types
83 function etimeclockwp_remove_metaboxs() {
84 remove_meta_box('submitdiv','etimeclockwp_users', 'side');
85 remove_meta_box('slugdiv','etimeclockwp_users', 'normal');
86 remove_meta_box('submitdiv','etimeclockwp_clock', 'side');
87 remove_meta_box('slugdiv','etimeclockwp_clock', 'normal');
88 }
89 add_action('admin_menu','etimeclockwp_remove_metaboxs');
90
91
92 // turn off autosave for post types
93 function my_admin_enqueue_scripts() {
94 if ('etimeclockwp_clock' == get_post_type()) {
95 wp_dequeue_script( 'autosave' );
96 }
97 }
98 add_action( 'admin_enqueue_scripts', 'my_admin_enqueue_scripts' );