├── parts
└── before-binder.php
├── README.md
├── style.css
├── articles
└── person.php
├── functions.php
├── taxonomy-cereo_person_type.php
└── includes
└── cereo-people.php
/parts/before-binder.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # cereo.wsu.edu
2 |
3 | The WordPress child theme for CEREO
4 |
5 | * Requires the [University Center plugin](https://github.com/washingtonstateuniversity/WSUWP-Plugin-University-Center)
6 |
--------------------------------------------------------------------------------
/style.css:
--------------------------------------------------------------------------------
1 | /*
2 | Theme Name: WSU CEREO
3 | Theme URI: http://web.wsu.edu/spine
4 | Author: WSU University Communications
5 | Author URI: http://web.wsu.edu
6 | Description: A child theme of the WSU Web Communications Spine template
7 | Template: spine
8 | Version: 0.1.1
9 | License: GPLv2 (or later)
10 | Tags: light
11 | */
--------------------------------------------------------------------------------
/articles/person.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | - Department:
6 |
7 |
8 | - CEREO Theme:
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/functions.php:
--------------------------------------------------------------------------------
1 | is_main_query() && is_tax( 'cereo_person_type' ) ) {
20 | $query->set( 'orderby', 'meta_value' );
21 | $query->set( 'order', 'ASC' );
22 | $query->set( 'meta_key', 'cereo_person_last_name' );
23 | $query->set( 'posts_per_page', 500 );
24 | }
25 | }
--------------------------------------------------------------------------------
/taxonomy-cereo_person_type.php:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | person_content_type = $wsuwp_university_center->people_content_type;
39 | }
40 |
41 | /**
42 | * Register a taxonomy to track types of people.
43 | */
44 | public function register_people_type_taxonomy() {
45 | $args = array(
46 | 'labels' => array(
47 | 'name' => 'People Types',
48 | 'singular_name' => 'People Type',
49 | 'search_items' => 'Search People Types',
50 | 'all_items' => 'All People Types',
51 | 'edit_item' => 'Edit People Type',
52 | 'update_item' => 'Update People Type',
53 | 'add_new_item' => 'Add New People Type',
54 | 'new_item_name' => 'New People Type Name',
55 | 'menu_name' => 'People Type',
56 | ),
57 | 'hierarchical' => false,
58 | 'show_ui' => true,
59 | 'show_admin_column' => true,
60 | 'query_var' => true,
61 | 'rewrite' => array( 'slug' => 'members' ),
62 | );
63 |
64 | register_taxonomy( $this->person_type_taxonomy, $this->person_content_type, $args );
65 | }
66 |
67 | public function remove_people_editor_support() {
68 | remove_post_type_support( $this->person_content_type, 'editor' );
69 | register_taxonomy_for_object_type( 'post_tag', $this->person_content_type );
70 | }
71 |
72 | public function add_meta_boxes( $post_type ) {
73 | if ( $this->person_content_type !== $post_type ) {
74 | return;
75 | }
76 |
77 | add_meta_box( 'wsu_cereo_people_fields', 'Data', array( $this, 'display_people_fields_meta_box' ), null, 'normal', 'default' );
78 | }
79 |
80 | /**
81 | * Display a meta box to capture data about a person.
82 | * @todo - keywords
83 | */
84 | public function display_people_fields_meta_box( $post ) {
85 | $cereo_person_last_name = get_post_meta( $post->ID, 'cereo_person_last_name', true );
86 | $cereo_person_position = get_post_meta( $post->ID, 'cereo_person_position', true );
87 | $cereo_person_department = get_post_meta( $post->ID, 'cereo_person_department', true );
88 | $cereo_person_college = get_post_meta( $post->ID, 'cereo_person_college', true );
89 | $cereo_person_campus = get_post_meta( $post->ID, 'cereo_person_campus', true );
90 | $cereo_person_address = get_post_meta( $post->ID, 'cereo_person_address', true );
91 | $cereo_person_phone = get_post_meta( $post->ID, 'cereo_person_phone', true );
92 | $cereo_person_email = get_post_meta( $post->ID, 'cereo_person_email', true );
93 | $cereo_person_web = get_post_meta( $post->ID, 'cereo_person_web', true );
94 | $cereo_person_theme = get_post_meta( $post->ID, 'cereo_person_theme', true );
95 | $cereo_person_specialty = get_post_meta( $post->ID, 'cereo_person_specialty', true );
96 | $cereo_person_courses = get_post_meta( $post->ID, 'cereo_person_courses', true );
97 | $cereo_person_research = get_post_meta( $post->ID, 'cereo_person_research', true );
98 | $cereo_person_outreach = get_post_meta( $post->ID, 'cereo_person_outreach', true );
99 |
100 | wp_nonce_field( 'save-cereo-person', '_cereo_person_nonce' );
101 | ?>
102 |
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 | person_content_type !== $post->post_type ) {
169 | return;
170 | }
171 |
172 | if ( 'auto-draft' === $post->post_status ) {
173 | return;
174 | }
175 |
176 | if ( ! isset( $_POST['_cereo_person_nonce'] ) || false === wp_verify_nonce( $_POST['_cereo_person_nonce'], 'save-cereo-person' ) ) {
177 | return;
178 | }
179 |
180 | $fields = array(
181 | 'cereo_person_last_name' => 0,
182 | 'cereo_person_position' => 'Position',
183 | 'cereo_person_department' => 'Department',
184 | 'cereo_person_college' => 'College',
185 | 'cereo_person_campus' => 'Campus',
186 | 'cereo_person_address' => 'Address',
187 | 'cereo_person_phone' => 'Phone',
188 | 'cereo_person_email' => 'Email',
189 | 'cereo_person_web' => 'Web',
190 | 'cereo_person_theme' => 'CEREO Theme',
191 | 'cereo_person_specialty' => 'Specialty',
192 | 'cereo_person_courses' => 'Env Courses',
193 | 'cereo_person_research' => 'Env Research',
194 | 'cereo_person_outreach' => 'Env Outreach',
195 | );
196 |
197 | $content_html = '| Name: | ' . esc_html( $post->post_title ) . ' |
';
198 |
199 | foreach( $fields as $field => $name ) {
200 | if ( isset( $_POST[ $field ] ) ) {
201 | update_post_meta( $post_id, $field, sanitize_text_field( $_POST[ $field ] ) );
202 | if ( 0 !== $name ) {
203 | $content_html .= '| ' . $name . ' | ' . sanitize_text_field( $_POST[ $field ] ) . ' |
';
204 | }
205 | }
206 | }
207 |
208 | $keywords = wp_get_object_terms( $post_id, 'post_tag' );
209 |
210 | if ( ! is_wp_error( $keywords ) ) {
211 | $keywords = wp_list_pluck( $keywords, 'name' );
212 | $keywords = implode( ', ', $keywords );
213 | $content_html .= '| Keywords | ' . $keywords . ' |
';
214 | }
215 |
216 | $content_html .= '
';
217 |
218 | // Remove this action before saving the compile post content so that we aren't double processing the data.
219 | remove_action( 'save_post', array( $this, 'save_post' ) );
220 | $post->post_content = $content_html;
221 | wp_update_post( $post );
222 | }
223 |
224 | /**
225 | * If saving the WSU Faculty Membership form, store a person record.
226 | *
227 | * @param $post_data
228 | * @param $form
229 | * @param $lead
230 | *
231 | * @return mixed
232 | */
233 | public function capture_form_save( $post_data, $form ) {
234 | if ( 'WSU Faculty Membership' === $form['title'] ) {
235 | $post_data['post_type'] = $this->person_content_type;
236 | }
237 |
238 | return $post_data;
239 | }
240 | }
241 | new WSU_Cereo_People();
--------------------------------------------------------------------------------