mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-05 10:25:45 +03:00
Log: Record when contributors are added to a pledge
This also updates the function that creates new contributor posts. It replaces `create_new_contributor` with `add_pledge_contributors`. This way we can capture a batch of contributor additions all in one event by collecting all the `wp_insert_post` results in an array and including it as an action parameter.
This commit is contained in:
parent
a41ecd7665
commit
461278f525
3 changed files with 55 additions and 15 deletions
|
@ -17,6 +17,7 @@ add_action( 'save_post_' . Pledge\CPT_ID, __NAMESPACE__ . '\capture_save_post',
|
|||
add_action( 'updated_postmeta', __NAMESPACE__ . '\capture_updated_postmeta', 99, 4 );
|
||||
add_action( 'added_post_meta', __NAMESPACE__ . '\capture_added_post_meta', 99, 4 );
|
||||
add_action( 'transition_post_status', __NAMESPACE__ . '\capture_transition_post_status', 99, 3 );
|
||||
add_action( FiveForTheFuture\PREFIX . '_add_pledge_contributors', __NAMESPACE__ . '\capture_add_pledge_contributors', 99, 3 );
|
||||
|
||||
/**
|
||||
* Adds a meta box for the log on the custom post type.
|
||||
|
@ -234,3 +235,26 @@ function capture_transition_post_status( $new_status, $old_status, WP_Post $post
|
|||
get_current_user_id()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Record a log for the event of contributors being added to a pledge.
|
||||
*
|
||||
* @param int $pledge_id The post ID of the pledge.
|
||||
* @param array $contributors Array of contributor wporg usernames.
|
||||
* @param array $results Associative array, key is wporg username, value is post ID on success,
|
||||
* or an error code on failure.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function capture_add_pledge_contributors( $pledge_id, $contributors, $results ) {
|
||||
add_log_entry(
|
||||
$pledge_id,
|
||||
'contributors_added',
|
||||
sprintf(
|
||||
'Contributors added: <code>%s</code>',
|
||||
implode( '</code>, <code>', $contributors )
|
||||
),
|
||||
$results,
|
||||
get_current_user_id()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue