type !== 'activity_update' ) { return; } try { $auth_token = ''; $room = ''; $from = ''; $r = ''; // Get Plugin Options $anbph_options = get_option( 'anbph_hipchat' ); $message_length = ! empty( $anbph_options['message_length'] ) ? $anbph_options['message_length'] : 10; if ( ! empty( $anbph_options['auth_token'] ) ) { $auth_token = $anbph_options['auth_token']; } // Return if plugin is not configured propery if ( empty( $auth_token ) ) { return; } if ( ! empty( $anbph_options['room_name'] ) ) { $room = $anbph_options['room_name']; } if ( ! empty( $anbph_options['from_name'] ) ) { $from = $anbph_options['from_name']; } $user = ''; $activity_url = bp_activity_get_permalink( $post->id ); $user_data = get_userdata( $post->user_id ); $activity_content = $post->content; if ( ! empty( $activity_content ) ) { $activity_content = wp_trim_words( $activity_content, $message_length ); } else { $activity_content = __( 'No Title', ANBPH_TEXTDOMAIN ); } if ( ! empty( $user_data ) ) { $user = $user_data->display_name; } $message = $user .' just posted '. $activity_content .''; if ( ! empty( $room ) && ! empty( $from ) && ! empty( $message ) ) { $bp_hc = new Anpbp_HipChat( $auth_token ); $r = $bp_hc->message_room( $room, $from, $message ); } if ( empty( $r ) ) { // Something went wrong, not sure what to do here? } } catch ( Anpbp_HipChat_Exception $e ) { // Something went wrong, not sure what to do here? } return $post; } /** * Validate Settings * * Filter the submitted data as per your request and return the array * * @param array $input */ function save_settings( $input ) { $input['auth_token'] = ! empty( $input['auth_token'] ) ? esc_attr( $input['auth_token'] ) : ''; $input['from_name'] = ! empty( $input['from_name'] ) ? esc_attr( $input['from_name'] ) : ''; $input['room_name'] = ! empty( $input['room_name'] ) ? esc_attr( $input['room_name'] ) : ''; $input['message_length'] = ! empty( $input['message_length'] ) ? esc_attr( $input['message_length'] ) : ''; return $input; } } // Let's roll $anbph = new Activity_Notifications_BuddyPress_HipChat(); endif;