Changeset 7619 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-admin.php
- Timestamp:
- 08/17/2018 09:32:41 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-admin.php
r7610 r7619 18 18 19 19 /** 20 * Meetup_Admin constructor. 21 */ 22 public function __construct() { 23 parent::__construct(); 24 25 add_action( 'wcpt_metabox_save_done', array( $this, 'save_tag_checkboxes' ) ); 26 } 27 28 /** 20 29 * Return user facing label of event type. 21 30 * … … 75 84 'cb' => '<input type="checkbox" />', 76 85 'title' => __( 'Title', 'wcpt' ), 77 ' swag_needed' => __( 'Swag Needed', 'wcpt' ),86 'tags' => __( 'Tags', 'wcpt' ), 78 87 'organizer' => __( 'Organizer', 'wcpt' ), 79 88 'date' => __( 'Date', 'wcpt' ), … … 116 125 case 'helpscout_url': 117 126 $this->print_clickable_link( get_post_meta( $post_id, 'HelpScout link', true ) ); 118 break;119 case 'swag_needed':120 if ( get_post_meta( $post_id, 'Needs swag', true ) ) {121 echo "<span class='dashicons dashicons-star-filled swag-needed-icon'></span>";122 }123 127 break; 124 128 } … … 186 190 'advanced' 187 191 ); 192 193 add_meta_box( 194 'wcpt_show_tag_logs', 195 'Tag logs', 196 array( $this, 'wcpt_tag_log_metabox' ), 197 $this->get_event_type(), 198 'advanced', 199 'low' 200 ); 201 188 202 } 189 203 … … 248 262 249 263 /** 264 * Renders tags logs 265 */ 266 public function wcpt_tag_log_metabox() { 267 global $post_id; 268 $entries = get_post_meta( $post_id, '_tags_log' ); 269 $entries = process_raw_entries( $entries, 'Tag changed' ); 270 require( WCPT_DIR . '/views/common/metabox-log.php' ); 271 } 272 273 /** 250 274 * Meta keys group for Meetup Event. 251 275 * … … 257 281 258 282 $info_keys = array( 259 'Meetup URL' => 'text', 260 'HelpScout link' => 'text', 261 'City' => 'text', 262 'State' => 'text', 263 'Country' => 'text', 264 'Zip' => 'text', 283 'Meetup URL' => 'text', 284 'HelpScout link' => 'text', 285 'Meetup Location' => 'text', 265 286 ); 266 287 267 288 $application_keys = array( 268 'Date Applied' => 'date', 269 'Date of Last Contact' => 'date', 270 'Who contacted' => 'text', 271 'Vetted Date' => 'date', 272 'Vetted by' => 'text', 273 'Orientation Date' => 'date', 274 'Oriented by' => 'text', 275 'Joined chapter date' => 'date', 276 'Joined chapter by' => 'text', 289 'Date Applied' => 'date', 290 'Already a meetup' => 'text', 291 'Date of Last Contact' => 'date', 292 'Who contacted' => 'text', 293 'Vetted Date' => 'date', 294 'Vetted by' => 'text', 295 'Orientation Date' => 'date', 296 'Oriented by' => 'text', 297 'Joined chapter date' => 'date', 298 'Joined chapter by' => 'text', 299 'More Information requested' => 'checkbox', 300 'Changes Requested' => 'checkbox', 301 'Needs Meeting' => 'checkbox' 277 302 ); 278 303 … … 282 307 'Primary organizer WordPress.org username' => 'text', 283 308 'Co-Organizers usernames (seperated by comma)' => 'text', 309 'Organizer description' => 'text', 284 310 'Date closed' => 'date', 285 'S kype/Slack'=> 'text',311 'Slack' => 'text', 286 312 'Region' => 'text', 287 313 'Address' => 'textarea', 314 'Extra Comments' => 'textarea', 288 315 ); 289 316 … … 317 344 return $data; 318 345 } 346 347 /** 348 * Toggle tags that are rendered as checkboxes 349 * 350 * @param int $post_id 351 */ 352 public function save_tag_checkboxes( $post_id ) { 353 354 $post_tags = wp_get_post_tags( $post_id, array( 'fields' => 'names' ) ); 355 356 $post_tags = $this->add_or_remove_tag( $post_id, $post_tags, 'wcpt_needs_swag', 'Needs Swag', $_POST['wcpt_swag_notes'] ); 357 358 $post_tags = $this->add_or_remove_tag( $post_id, $post_tags, 'wcpt_more_information_requested', 'More Information requested' ); 359 360 $post_tags = $this->add_or_remove_tag( $post_id, $post_tags, 'wcpt_changes_requested', 'Changes Requested' ); 361 362 $post_tags = $this->add_or_remove_tag( $post_id, $post_tags, 'wcpt_needs_meeting', 'Needs Meeting' ); 363 364 if ( $post_tags != wp_get_post_tags( $post_id ) ) { 365 wp_set_post_tags( $post_id, $post_tags ); 366 } 367 } 368 369 /** 370 * Add or remove tag. Also logs and make a note when required 371 * 372 * @param $post_id 373 * @param $tag_array 374 * @param $input_name 375 * @param $label 376 * @param string $note_message 377 * 378 * @return array 379 */ 380 public function add_or_remove_tag( $post_id, $tag_array, $input_name, $label, $note_message = '' ) { 381 382 if ( $note_message !== '' ) { 383 $note_message = ' Note: ' . $note_message; 384 } 385 386 if ( isset( $_POST[ $input_name] ) && $_POST[ $input_name ] && ( ! in_array( $label, $tag_array ) ) ) { 387 388 $tag_array[] = $label; 389 390 add_post_meta( 391 $post_id, '_tags_log', array( 392 'timestamp' => time(), 393 'user_id' => get_current_user_id(), 394 'message' => 'Tag ' . $label . ' added.' . $note_message, 395 ) 396 ); 397 398 } elseif ( ! isset( $_POST[ $input_name] ) && in_array( $label, $tag_array ) ) { 399 $tag_array = array_diff( $tag_array, array( $label ) ); 400 401 add_post_meta( 402 $post_id, '_tags_log', array( 403 'timestamp' => time(), 404 'user_id' => get_current_user_id(), 405 'message' => 'Tag ' . $label . ' removed.' . $note_message, 406 ) 407 ); 408 } 409 410 return $tag_array; 411 } 319 412 } 320 413
Note: See TracChangeset
for help on using the changeset viewer.