<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[7637] sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt: WordCamp: Added meetup.com API sync to meetup posts.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/7637">7637</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/7637","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>vedjain</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-08-29 11:19:29 +0000 (Wed, 29 Aug 2018)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WordCamp: Added meetup.com API sync to meetup posts.

This is part 1 of adding meetup API sync with meetup admin page. This commit syncs some of the group details like members count, location etc. Currently, information sync for list of co-organizers etc is yet to be implemented.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcpteventclasseventadminphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-admin.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcptmeetupclassmeetupadminphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-admin.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcptwordcampwordcampadminphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcpteventclasseventadminphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-admin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-admin.php     2018-08-28 10:59:19 UTC (rev 7636)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-admin.php       2018-08-29 11:19:29 UTC (rev 7637)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,11 +15,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> abstract class Event_Admin {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        public $active_admin_notices;
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Event_Admin constructor.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function __construct() {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->active_admin_notices = array();
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 add_action( 'add_meta_boxes', array( $this, 'metabox' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'add_meta_boxes', array( $this, 'add_status_metabox' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,6 +54,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'admin_print_styles', array( $this, 'common_admin_styles' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                add_action( 'transition_post_status', array( $this, 'log_status_changes' ), 10, 3 );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               add_filter( 'redirect_post_location', array( $this, 'add_admin_notices_to_redirect_url' ), 10, 2 );
+
+               // Admin notices
+               add_action( 'admin_notices', array( $this, 'print_admin_notices' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -414,6 +423,75 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Add our custom admin notice keys to the redirect URL.
+        *
+        * Any member can add a key to $this->active_admin_notices to signify that the corresponding message should
+        * be shown when the redirect finished. When it does, print_admin_notices() will examine the URL and create
+        * a notice with the message that corresponds to the key.
+        *
+        * @param string $location
+        * @param int    $post_id
+        *
+        * @return string
+        */
+       public function add_admin_notices_to_redirect_url( $location, $post_id ) {
+               if ( $this->active_admin_notices ) {
+                       $location = add_query_arg( 'wcpt_messages', implode( ',', $this->active_admin_notices ), $location );
+               }
+
+               // Don't show conflicting messages like 'Post submitted.'
+               if ( in_array( 1, $this->active_admin_notices ) && false !== strpos( $location, 'message=8' ) ) {
+                       $location = remove_query_arg( 'message', $location );
+               }
+
+               return $location;
+       }
+
+       /**
+        * Return admin notices for messages that were passed in the URL.
+        */
+       abstract public function get_admin_notices();
+
+       /**
+        * Create admin notices for messages that were passed in the URL.
+        *
+        * Any member can add a key to $this->active_admin_notices to signify that the corresponding message should
+        * be shown when the redirect finished. add_admin_notices_to_redirect_url() adds those keys to the redirect
+        * url, and this function examines the URL and create a notice with the message that corresponds to the key.
+        *
+        * $notices[key]['type'] should equal 'error' or 'updated'.
+        */
+       public function print_admin_notices() {
+
+               global $post;
+               $screen = get_current_screen();
+
+
+               if ( empty( $post->post_type ) || $this->get_event_type() != $post->post_type || 'post' !== $screen->base ) {
+                       return;
+               }
+
+               $notices = $this->get_admin_notices();
+
+               if ( ! empty( $_REQUEST['wcpt_messages'] ) ) {
+                       $active_notices = explode( ',', $_REQUEST['wcpt_messages'] );
+
+                       foreach ( $active_notices as $notice_key ) {
+                               if ( isset( $notices[ $notice_key ] ) ) {
+                                       ?>
+
+                                       <div class="<?php echo esc_attr( $notices[ $notice_key ]['type'] ); ?>">
+                                               <p><?php echo wp_kses( $notices[ $notice_key ]['notice'], wp_kses_allowed_html( 'post' ) ); ?></p>
+                                       </div>
+
+                                       <?php
+                               }
+                       }
+               }
+
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Validate and add a new private note
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param int $post_id
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcptmeetupclassmeetupadminphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-admin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-admin.php   2018-08-28 10:59:19 UTC (rev 7636)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-admin.php     2018-08-29 11:19:29 UTC (rev 7637)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -21,6 +21,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                public function __construct() {
</span><span class="cx" style="display: block; padding: 0 10px">                        parent::__construct();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       add_action( 'wcpt_metabox_save_done', array( $this, 'maybe_update_meetup_data' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -92,14 +94,29 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 * TODO: Implement
-                *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+          * Return read only meta fields.
+                */
+               public static function get_protected_fields() {
+                       return array(
+
+                               // These fields are update by meetup API and will be overwritten even if manually changed.
+                               'Meetup Location (From meetup.com)',
+                               'Meetup members count',
+                               'Meetup group created on',
+                               'Number of past meetups',
+                               'Last meetup on',
+                               'Last meetup RSVP count',
+                       );
+               }
+
+               /**
+                * Checks if a field is read only.
</ins><span class="cx" style="display: block; padding: 0 10px">                  * @param string $key Name of the field.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="cx" style="display: block; padding: 0 10px">                 * @return bool Whether `$key` is a protected field.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                public static function is_protected_field( $key ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        return false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 return in_array( $key, self::get_protected_fields() );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -188,6 +205,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'advanced'
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        add_meta_box(
+                               'wcpt_meetup_metadata',
+                               __( 'Meetup.com API sync', 'wcpt' ),
+                               array( $this, 'wcpt_meetup_sync' ),
+                               Meetup_Application::POST_TYPE,
+                               'side',
+                               'high'
+                       );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -246,10 +272,136 @@
</span><span class="cx" style="display: block; padding: 0 10px">                public function meetup_metabox( $meta_keys ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        global $post_id;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        self::display_meta_boxes( array(), $meta_keys, array(), $post_id, array() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 self::display_meta_boxes( array(), $meta_keys, array(), $post_id, self::get_protected_fields() );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                public function wcpt_meetup_sync() {
+                       global $post_id;
+                       $meta_key = 'Last meetup.com API sync';
+                       $last_synced_on = get_post_meta( $post_id, $meta_key, true );
+                       $element_name = 'sync_with_meetup_api';
+
+                       if ( empty( $last_synced_on ) ) {
+                               $last_synced_on = 'Never';
+                       } else {
+                               $last_synced_on = date( "Y-m-d",  substr( $last_synced_on, 0, 10 ) );
+                       }
+                       ?>
+                       <div class="wcb submitbox">
+                               <div class="misc-pub-section">
+                                       <label>Last sync: <?php echo $last_synced_on ?></label>
+                               </div>
+                               <div class="misc-pub-section">
+                                       <label>
+                                               <input type="checkbox" name="<?php echo $element_name ?>" >
+                                               Sync Now
+                                       </label>
+                               </div>
+                       </div>
+                       <?php
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">                 /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 * Updates meetup fields using meetup.com API only if Sync now checkbox is checked.
+                *
+                * @param int   $post_id
+                * @param array $original_meta_values
+                */
+               public function maybe_update_meetup_data( $post_id ){
+                       if ( $this->get_event_type() !== get_post_type() ) {
+                               return;
+                       }
+
+                       $should_sync = $_POST[ 'sync_with_meetup_api' ];
+                       if ( ! $should_sync ) {
+                               return;
+                       }
+
+                       $result = self::update_meetup_data( $post_id );
+
+                       if ( is_wp_error( $result ) ) {
+                               $this->active_admin_notices[] = $result->get_error_code();
+                               return;
+                       }
+
+                       update_post_meta( $post_id, 'Last meetup.com API sync', time() );
+
+               }
+
+               /**
+                * Update meetup fields using meetup.com API
+                *
+                * @param $post_id
+                *
+                * @return array|WP_Error
+                */
+               public static function update_meetup_data( $post_id ) {
+
+                       $meetup_url = get_post_meta( $post_id, 'Meetup URL', true );
+
+                       $parsed_url = wp_parse_url( $meetup_url, -1 );
+
+                       if( ! $parsed_url ) {
+                               return new WP_Error( 'invalid-url', __('Provided Meetup URL is not a valid URL.', 'wordcamporg' ) );
+                       }
+                       $url_path_segments = explode( '/', rtrim( $parsed_url['path'], '/' ) );
+                       $slug = array_pop( $url_path_segments );
+                       $mtp_client = new \WordCamp\Utilities\Meetup_Client();
+
+                       $group_details = $mtp_client->get_group_details(
+                               $slug,
+                               array(
+                                       'fields' => 'past_event_count,last_event',
+                               )
+                       );
+
+                       if ( is_wp_error( $group_details ) ) {
+                               return $group_details;
+                       }
+
+                       if ( isset( $group_details['errors'] ) ) {
+                               return new WP_Error( 'invalid-response', __( 'Received invalid response from meetup api.', 'wordcamporg' ) );
+                       }
+
+                       update_post_meta( $post_id, 'Meetup Location (From meetup.com)', $group_details['localized_location'] );
+                       update_post_meta( $post_id, 'Meetup members count', $group_details['members'] );
+                       update_post_meta( $post_id, 'Meetup group created on', $group_details['created'] / 1000 );
+                       update_post_meta( $post_id, 'Number of past meetups', $group_details['past_event_count'] );
+
+                       if ( isset( $group_details['last_event'] ) && is_array( $group_details['last_event'] ) ) {
+                               update_post_meta( $post_id, 'Last meetup on', $group_details['last_event']['time'] / 1000 );
+                               update_post_meta( $post_id, 'Last meetup RSVP count', $group_details['last_event']['yes_rsvp_count'] );
+                       }
+               }
+
+               /**
+                * List of admin notices.
+                *
+                * @return array
+                */
+               public function get_admin_notices() {
+
+                       return array(
+                               'invalid-url'        => array(
+                                       'type'   => 'notice',
+                                       'notice' => __( 'Invalid meetup.com URL. Meetup fields are not updated.', 'wordcamporg' ),
+                               ),
+                               'invalid-response'   => array(
+                                       'type'   => 'notice',
+                                       'notice' => __( 'Received invalid response from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' )
+                               ),
+                               'group_error'        => array(
+                                       'type'   => 'notice',
+                                       'notice' => __( 'Received invalid response from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' )
+                               ),
+                               'http_response_code' => array(
+                                       'type'   => 'notice',
+                                       'notice' => __( 'Received invalid response code from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' )
+                               ),
+                       );
+
+               }
+
+               /**
</ins><span class="cx" style="display: block; padding: 0 10px">                  * Meta keys group for Meetup Event.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="cx" style="display: block; padding: 0 10px">                 * @param string $meta_group
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -259,9 +411,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                public static function meta_keys( $meta_group = '' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $info_keys = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'Meetup URL'      => 'text',
-                               'HelpScout link'  => 'text',
-                               'Meetup Location' => 'text',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'Meetup URL'                        => 'text',
+                               'Meetup Location (From meetup.com)' => 'text',
+                               'Meetup members count'              => 'text',
+                               'Meetup group created on'           => 'date',
+                               'Number of past meetups'            => 'text',
+                               'Last meetup on'                    => 'date',
+                               'Last meetup RSVP count'            => 'text',
+                               'HelpScout link'                    => 'text',
+                               'Meetup Location'                   => 'text',
</ins><span class="cx" style="display: block; padding: 0 10px">                         );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        $application_keys = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -290,6 +448,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                'Extra Comments' => 'textarea',
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        $metadata_keys = array(
+                               'Last meetup.com API sync' => 'date',
+                       );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         $swag_keys = array(
</span><span class="cx" style="display: block; padding: 0 10px">                                'Swag notes' => 'textarea',
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -307,6 +469,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                case 'swag':
</span><span class="cx" style="display: block; padding: 0 10px">                                        $data = $swag_keys;
</span><span class="cx" style="display: block; padding: 0 10px">                                        break;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                case 'metadata':
+                                       $data = $metadata_keys;
+                                       break;
</ins><span class="cx" style="display: block; padding: 0 10px">                                 case 'all':
</span><span class="cx" style="display: block; padding: 0 10px">                                default:
</span><span class="cx" style="display: block; padding: 0 10px">                                        $data = array_merge(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -313,7 +478,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                $info_keys,
</span><span class="cx" style="display: block; padding: 0 10px">                                                $application_keys,
</span><span class="cx" style="display: block; padding: 0 10px">                                                $organizer_keys,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                $swag_keys
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         $swag_keys,
+                                               $metadata_keys
</ins><span class="cx" style="display: block; padding: 0 10px">                                         );
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                        return $data;
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswcptwcptwordcampwordcampadminphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php     2018-08-28 10:59:19 UTC (rev 7636)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php       2018-08-29 11:19:29 UTC (rev 7637)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,7 +16,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @since WordCamp Post Type (0.1)
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        class WordCamp_Admin extends Event_Admin {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                protected $active_admin_notices;
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><span class="cx" style="display: block; padding: 0 10px">                 * Initialize WCPT Admin
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -25,8 +24,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        parent::__construct();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $this->active_admin_notices = array();
-
</del><span class="cx" style="display: block; padding: 0 10px">                         // Add some general styling to the admin area
</span><span class="cx" style="display: block; padding: 0 10px">                        add_action( 'wcpt_admin_head', array( $this, 'admin_head' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -47,11 +44,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                ), 11, 2
</span><span class="cx" style="display: block; padding: 0 10px">                        ); // after enforce_post_status
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Admin notices
-                       add_action( 'admin_notices', array( $this, 'print_admin_notices' ) );
-
-                       add_filter( 'redirect_post_location', array( $this, 'add_admin_notices_to_redirect_url' ), 10, 2 );
-
</del><span class="cx" style="display: block; padding: 0 10px">                         // Cron jobs
</span><span class="cx" style="display: block; padding: 0 10px">                        add_action( 'plugins_loaded', array( $this, 'schedule_cron_jobs' ), 11 );
</span><span class="cx" style="display: block; padding: 0 10px">                        add_action( 'wcpt_close_wordcamps_after_event', array( $this, 'close_wordcamps_after_event' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -862,47 +854,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                 * Add our custom admin notice keys to the redirect URL.
-                *
-                * Any member can add a key to $this->active_admin_notices to signify that the corresponding message should
-                * be shown when the redirect finished. When it does, print_admin_notices() will examine the URL and create
-                * a notice with the message that corresponds to the key.
-                *
-                * @param $location
-                * @param $post_id
-                * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+          * Return admin notices for messages that were passed in the URL.
</ins><span class="cx" style="display: block; padding: 0 10px">                  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                public function add_admin_notices_to_redirect_url( $location, $post_id ) {
-                       if ( $this->active_admin_notices ) {
-                               $location = add_query_arg( 'wcpt_messages', implode( ',', $this->active_admin_notices ), $location );
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         public function get_admin_notices() {
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Don't show conflicting messages like 'Post submitted.'
-                       if ( in_array( 1, $this->active_admin_notices ) && false !== strpos( $location, 'message=8' ) ) {
-                               $location = remove_query_arg( 'message', $location );
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 global $post;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        return $location;
-               }
-
-               /**
-                * Create admin notices for messages that were passed in the URL.
-                *
-                * Any member can add a key to $this->active_admin_notices to signify that the corresponding message should
-                * be shown when the redirect finished. add_admin_notices_to_redirect_url() adds those keys to the redirect
-                * url, and this function examines the URL and create a notice with the message that corresponds to the key.
-                *
-                * $notices[key]['type'] should equal 'error' or 'updated'.
-                */
-               public function print_admin_notices() {
-                       global $post;
</del><span class="cx" style="display: block; padding: 0 10px">                         $screen = get_current_screen();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( empty( $post->post_type ) || WCPT_POST_TYPE_ID != $post->post_type || 'post' !== $screen->base ) {
-                               return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+                       if ( empty( $post->post_type ) || $this->get_event_type() != $post->post_type || 'post' !== $screen->base ) {
+                               return array();
</ins><span class="cx" style="display: block; padding: 0 10px">                         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        $notices = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Show this error permanently, not just after updating.
+                       if ( ! empty( $post->{'Physical Address'} ) && empty( get_post_meta( $post->ID, '_venue_coordinates', true ) ) ) {
+                               $_REQUEST['wcpt_messages'] = empty( $_REQUEST['wcpt_messages'] ) ? '4' : $_REQUEST['wcpt_messages'] . ',4';
+                       }
+
+                       return array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                 1 => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'type'   => 'error',
</span><span class="cx" style="display: block; padding: 0 10px">                                        'notice' => sprintf(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -925,26 +895,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><span class="cx" style="display: block; padding: 0 10px">                        );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Show this error permenantly, not just after updating.
-                       if ( ! empty( $post->{'Physical Address'} ) && empty( get_post_meta( $post->ID, '_venue_coordinates', true ) ) ) {
-                               $_REQUEST['wcpt_messages'] = empty( $_REQUEST['wcpt_messages'] ) ? '4' : $_REQUEST['wcpt_messages'] . ',4';
-                       }
-
-                       if ( ! empty( $_REQUEST['wcpt_messages'] ) ) {
-                               $active_notices = explode( ',', $_REQUEST['wcpt_messages'] );
-
-                               foreach ( $active_notices as $notice_key ) {
-                                       if ( isset( $notices[ $notice_key ] ) ) {
-                                               ?>
-
-                                       <div class="<?php echo esc_attr( $notices[ $notice_key ]['type'] ); ?>">
-                                               <p><?php echo wp_kses( $notices[ $notice_key ]['notice'], wp_kses_allowed_html( 'post' ) ); ?></p>
-                                       </div>
-
-                                               <?php
-                                       }
-                               }
-                       }
</del><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span></span></pre>
</div>
</div>

</body>
</html>