mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-05 10:25:45 +03:00
Log: Record event for contributor post status change
This commit is contained in:
parent
dddab4bed0
commit
fb1fe69b43
1 changed files with 36 additions and 12 deletions
|
@ -224,7 +224,10 @@ function capture_added_post_meta( $meta_id, $object_id, $meta_key, $meta_value )
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function capture_transition_post_status( $new_status, $old_status, WP_Post $post ) {
|
function capture_transition_post_status( $new_status, $old_status, WP_Post $post ) {
|
||||||
if ( Pledge\CPT_ID !== get_post_type( $post ) ) {
|
$cpts = array( Pledge\CPT_ID, Contributor\CPT_ID );
|
||||||
|
$post_type = get_post_type( $post );
|
||||||
|
|
||||||
|
if ( ! in_array( $post_type, $cpts, true ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,6 +235,8 @@ function capture_transition_post_status( $new_status, $old_status, WP_Post $post
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch ( $post_type ) {
|
||||||
|
case Pledge\CPT_ID:
|
||||||
add_log_entry(
|
add_log_entry(
|
||||||
$post->ID,
|
$post->ID,
|
||||||
'pledge_status_changed',
|
'pledge_status_changed',
|
||||||
|
@ -243,6 +248,25 @@ function capture_transition_post_status( $new_status, $old_status, WP_Post $post
|
||||||
array(),
|
array(),
|
||||||
get_current_user_id()
|
get_current_user_id()
|
||||||
);
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Contributor\CPT_ID:
|
||||||
|
$pledge = get_post( $post->post_parent );
|
||||||
|
|
||||||
|
add_log_entry(
|
||||||
|
$pledge->ID,
|
||||||
|
'contributor_status_changed',
|
||||||
|
sprintf(
|
||||||
|
'Contributor <code>%1$s</code> status changed from <code>%2$s</code> to <code>%3$s</code>.',
|
||||||
|
esc_html( $post->post_title ),
|
||||||
|
esc_html( $old_status ),
|
||||||
|
esc_html( $new_status )
|
||||||
|
),
|
||||||
|
array(),
|
||||||
|
get_current_user_id()
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue