Making WordPress.org


Ignore:
Timestamp:
08/17/2018 09:32:41 AM (8 years ago)
Author:
vedjain
Message:

WordCamp: Multiple changes to Meetup Application.

  1. Make styling more consistent of Meetup Application with WordCamp Application.
  2. Added more statuses and tags. Specifically, added checkboxes for statuses like Needs Swag, Needs Orientation etc, which will add a tag for easy filtering.
  3. Added tag column in Meetup listing view.
  4. Add different questions for Meetup location and for organizer's mailing address.
  5. Street address, state and zip code fields are optional.
  6. Added log box for tracking tag changes.
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  
    1818
    1919        /**
     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        /**
    2029         * Return user facing label of event type.
    2130         *
     
    7584                'cb'             => '<input type="checkbox" />',
    7685                'title'          => __( 'Title', 'wcpt' ),
    77                 'swag_needed'    => __( 'Swag Needed', 'wcpt' ),
     86                'tags'           => __( 'Tags', 'wcpt' ),
    7887                'organizer'      => __( 'Organizer', 'wcpt' ),
    7988                'date'           => __( 'Date', 'wcpt' ),
     
    116125                case 'helpscout_url':
    117126                    $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                     }
    123127                    break;
    124128            }
     
    186190                'advanced'
    187191            );
     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
    188202        }
    189203
     
    248262
    249263        /**
     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        /**
    250274         * Meta keys group for Meetup Event.
    251275         *
     
    257281
    258282            $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',
    265286            );
    266287
    267288            $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'
    277302            );
    278303
     
    282307                'Primary organizer WordPress.org username'     => 'text',
    283308                'Co-Organizers usernames (seperated by comma)' => 'text',
     309                'Organizer description'                        => 'text',
    284310                'Date closed'                                  => 'date',
    285                 'Skype/Slack'                                  => 'text',
     311                'Slack'                                        => 'text',
    286312                'Region'                                       => 'text',
    287313                'Address'                                      => 'textarea',
     314                'Extra Comments' => 'textarea',
    288315            );
    289316
     
    317344            return $data;
    318345        }
     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        }
    319412    }
    320413
Note: See TracChangeset for help on using the changeset viewer.