Making WordPress.org

Changeset 7684


Ignore:
Timestamp:
09/20/2018 08:36:21 AM (6 years ago)
Author:
vedjain
Message:

Participation Notifier: Add hook for adding meetup badges.

This sends a request to profiles.wordpress.org and request adding meetup badge to list of wporg profiles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-participation-notifier/wordcamp-participation-notifier.php

    r4279 r7684  
    2020        add_action( 'camptix_rl_registration_confirmed',       array( $this, 'additional_attendee_confirmed_registration' ), 10, 2 );
    2121        add_action( 'added_post_meta',                         array( $this, 'attendee_checked_in' ), 10, 4 );
     22        add_action( 'update_meetup_organizers',                array( $this, 'update_meetup_organizers' ), 10, 2 );
    2223    }
    2324
     
    4849            $this->speaker_post_published_or_unpublished( $new_status, $old_status, $post );
    4950        }
     51    }
     52
     53    /**
     54     * Add badges to meetup organizers.
     55     *
     56     * @param array   $organizers
     57     * @param WP_Post $post
     58     *
     59     * @return mixed
     60     */
     61    public function update_meetup_organizers( $organizers, $post ) {
     62        if ( empty( $organizers ) ) {
     63            return;
     64        }
     65
     66        return $this->remote_post( self::PROFILES_HANDLER_URL, $this->get_meetup_org_payload( $organizers, $post ) );
     67    }
     68
     69    /**
     70     * Helper function to create post data for AJAX request
     71     *
     72     * @param array   $organizers
     73     * @param WP_Post $post
     74     *
     75     * @return array
     76     */
     77    protected function get_meetup_org_payload( $organizers, $post ) {
     78        $association = array(
     79            'action'      => 'wporg_handle_association',
     80            'source'      => 'meetups',
     81            'command'     => 'add',
     82            'users'       => $organizers,
     83            'meetup_id'   => $post->ID,
     84            'association' => 'meetup-organizer'
     85        );
     86
     87        return apply_filters( 'wp_meetup_organizer_association_payload', $association, $post );
    5088    }
    5189
Note: See TracChangeset for help on using the changeset viewer.