mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-05 10:25:45 +03:00
Enable "add contributors" functionality
This commit is contained in:
parent
b0672a6f6e
commit
5a72ff8b53
4 changed files with 63 additions and 6 deletions
|
@ -37,6 +37,25 @@ function handler() {
|
|||
'contributors' => Contributor\get_pledge_contributors_data( $pledge_id ),
|
||||
] ) );
|
||||
break;
|
||||
|
||||
case 'add-contributor':
|
||||
$new_contributors = PledgeForm\parse_contributors( $_POST['contributors'] );
|
||||
if ( is_wp_error( $new_contributors ) ) {
|
||||
wp_die( wp_json_encode( [
|
||||
'success' => false,
|
||||
'message' => $new_contributors->get_error_message(),
|
||||
] ) );
|
||||
}
|
||||
Contributor\add_pledge_contributors( $pledge_id, $new_contributors );
|
||||
|
||||
// Fetch all contributors, now that the new ones have been added.
|
||||
$contributors = Contributor\get_pledge_contributors_data( $pledge_id );
|
||||
|
||||
wp_die( wp_json_encode( [
|
||||
'success' => true,
|
||||
'contributors' => $contributors,
|
||||
] ) );
|
||||
break;
|
||||
}
|
||||
|
||||
// No matching action, we can just exit.
|
||||
|
|
|
@ -483,6 +483,7 @@ function enqueue_assets() {
|
|||
wp_register_script( '5ftf-admin', plugins_url( 'assets/js/admin.js', __DIR__ ), [ 'jquery' ], $ver );
|
||||
|
||||
$script_data = [
|
||||
'pledgeId' => get_the_ID(),
|
||||
'manageNonce' => wp_create_nonce( 'manage-pledge' ),
|
||||
];
|
||||
wp_add_inline_script(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue