Changeset 7635
- Timestamp:
- 08/27/2018 03:25:40 AM (6 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-functions.php
r7625 r7635 85 85 $private_notes = get_post_meta( $event_id, '_note' ); 86 86 $status_changes = get_post_meta( $event_id, '_status_change' ); 87 $tag_changes = get_post_meta( $event_id, '_tags_log' ); 87 88 88 foreach ( array( 'note' => $private_notes, 'status_change' => $status_changes ) as $entry_type => $raw_entries ) {89 foreach ( array( 'note' => $private_notes, 'status_change' => $status_changes, 'tag_change' => $tag_changes ) as $entry_type => $raw_entries ) { 89 90 $entries = array_merge( process_raw_entries( $raw_entries, $entry_type ), $entries ); 90 91 } … … 120 121 } 121 122 122 usort( $entries, 'wcpt_sort_log_entries' );123 124 123 return $entries; 125 124 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-admin.php
r7619 r7635 22 22 public function __construct() { 23 23 parent::__construct(); 24 25 add_action( 'wcpt_metabox_save_done', array( $this, 'save_tag_checkboxes' ) );26 24 } 27 25 … … 82 80 public function column_headers( $columns ) { 83 81 $columns = array( 84 'cb' => '<input type="checkbox" />',85 'title' => __( 'Title', 'wcpt' ),86 'ta gs' => __( 'Tags', 'wcpt' ),87 'organizer' => __( 'Organizer', 'wcpt' ),88 'date' => __( 'Date', 'wcpt' ),89 'meetup.com_url' => __( 'Meetup URL', 'wcpt' ),90 'helpscout_url' => __( 'HelpScout Link', 'wcpt' ),82 'cb' => '<input type="checkbox" />', 83 'title' => __( 'Title', 'wcpt' ), 84 'taxonomy-meetup_tags' => __( 'Meetup Tags', 'wcpt' ), 85 'organizer' => __( 'Organizer', 'wcpt' ), 86 'date' => __( 'Date', 'wcpt' ), 87 'meetup.com_url' => __( 'Meetup URL', 'wcpt' ), 88 'helpscout_url' => __( 'HelpScout Link', 'wcpt' ), 91 89 ); 92 90 … … 191 189 ); 192 190 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 202 191 } 203 192 … … 259 248 260 249 self::display_meta_boxes( array(), $meta_keys, array(), $post_id, array() ); 261 }262 263 /**264 * Renders tags logs265 */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 250 } 272 251 … … 297 276 'Joined chapter date' => 'date', 298 277 'Joined chapter by' => 'text', 299 'More Information requested' => 'checkbox',300 'Changes Requested' => 'checkbox',301 'Needs Meeting' => 'checkbox'302 278 ); 303 279 … … 316 292 317 293 $swag_keys = array( 318 'Needs swag' => 'checkbox', 319 'Swag notes' => 'text', 294 'Swag notes' => 'textarea', 320 295 ); 321 296 … … 345 320 } 346 321 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 } 322 412 323 } 413 324 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/meetup-loader.php
r7607 r7635 8 8 use WordPress_Community\Applications\Meetup_Application; 9 9 define( 'WCPT_MEETUP_SLUG', 'wp_meetup' ); 10 define( 'WCPT_MEETUP_TAG_SLUG', 'meetup_tags' ); 10 11 11 12 … … 17 18 class Meetup_Loader extends Event_Loader { 18 19 20 /** 21 * Meetup_Loader constructor. 22 */ 23 public function __construct() { 24 parent::__construct(); 25 add_action( 'init', array( $this, 'register_meetup_taxonomy' ) ); 26 add_action( 'set_object_terms', array( $this, 'log_meetup_tags' ), 10, 6 ); 27 } 28 29 /** 30 * Log when a tag is added or removed in a meetup event 31 * 32 * @param int $event_id Meetup post ID. 33 * @param array $terms An array of tags. 34 * @param array $tt_ids An array of term taxonomy IDs. 35 * @param string $taxonomy Taxonomy slug. 36 * @param bool $append Whether to append new terms to the old terms. 37 * @param array $old_tt_ids Old array of term taxonomy IDs. 38 */ 39 public function log_meetup_tags( $event_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { 40 41 // bail if taxonomy is not meetup tags. 42 if ( WCPT_MEETUP_TAG_SLUG !== $taxonomy ) { 43 return; 44 } 45 46 $tt_added_ids = array_diff( $tt_ids, $old_tt_ids ); 47 $tt_removed_ids = array_diff( $old_tt_ids, $tt_ids ); 48 49 if ( count( $tt_added_ids ) > 0 ) { 50 $added_terms_query = new WP_Term_Query( array( 51 'taxonomy' => WCPT_MEETUP_TAG_SLUG, 52 'object_ids' => $event_id, 53 'term_taxonomy_id' => $tt_added_ids, 54 'fields' => 'names' 55 ) 56 ); 57 58 $added_terms = $added_terms_query->get_terms(); 59 60 add_post_meta( $event_id, '_tags_log', array( 61 'timestamp' => time(), 62 'user_id' => get_current_user_id(), 63 'message' => 'Tags added: ' . join( ', ', $added_terms ), 64 ) ); 65 } 66 67 if ( count( $tt_removed_ids ) > 0 ) { 68 $removed_terms = ( new WP_Term_Query( array( 69 'taxonomy' => WCPT_MEETUP_TAG_SLUG, 70 'term_taxonomy_id' => $tt_removed_ids, 71 'fields' => 'names', 72 'hide_empty' => false, 73 ) 74 ) )->get_terms(); 75 76 add_post_meta( $event_id, '_tags_log', array( 77 'timestamp' => time(), 78 'user_id' => get_current_user_id(), 79 'message' => 'Tags removed: ' . join( ', ', $removed_terms ), 80 ) ); 81 } 82 83 } 84 85 /** 86 * Register custom tags for meetup events. 87 */ 88 public function register_meetup_taxonomy() { 89 register_taxonomy( 90 'meetup_tags', 91 Meetup_Application::POST_TYPE, 92 array( 93 'hierarchical' => false, 94 'labels' => array( 95 'name' => __( 'Meetup Tags' ), 96 'singular_name' => __( 'Meetup Tag' ), 97 ), 98 'show_admin_column' => true, 99 ) 100 ); 101 } 19 102 20 103 /** … … 54 137 $wcpt_supports = array( 55 138 'title', 56 'editor',57 'thumbnail',58 139 'revisions', 59 140 'author',
Note: See TracChangeset
for help on using the changeset viewer.