Create Pledge: Make form functional (#31)

This broadly enables & styles the pledge forms across the frontend and wp-admin.

- Switches field `readonly` control to a variable called `$readonly`
- Create `PledgeMeta\get_pledge_meta()` which will fetch data from `$_POST`, a pledge post, or defaults.
- Add Number of Employees field
- Update form content to match mockup:
  - fields now have help text
  - success message uses content from mockup
  - logo field is moved to the "org info" section
- Style form in theme, add some similar styles to the admin

Fixes #7, fixes #28
This commit is contained in:
Kelly Dwan 2019-10-08 18:29:35 -04:00 committed by GitHub
parent 0111c36db4
commit 0f675ae6c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 313 additions and 127 deletions

View file

@ -7,15 +7,19 @@ use function WordPressDotOrg\FiveForTheFuture\get_views_path;
/** @var bool $updated */
?>
<form id="5ftf-form-pledge-manage" action="" method="post">
<form class="pledge-form" id="5ftf-form-pledge-manage" action="" method="post">
<?php
require get_views_path() . 'inputs-pledge-org-info.php';
require get_views_path() . 'inputs-pledge-org-logo.php';
require get_views_path() . 'inputs-pledge-org-email.php';
require get_views_path() . 'inputs-pledge-contributors.php';
require get_views_path() . 'inputs-pledge-org-email.php';
?>
<div>
<input type="submit" id="5ftf-pledge-submit" name="action" class="button button-primary" value="<?php esc_attr_e( 'Update Pledge', 'wporg' ); ?>" />
<input
type="submit"
id="5ftf-pledge-submit"
name="action"
value="<?php esc_attr_e( 'Update Pledge', 'wporg' ); ?>"
/>
</div>
</form>

View file

@ -13,33 +13,41 @@ use function WordPressDotOrg\FiveForTheFuture\get_views_path;
<?php if ( ! empty( $messages ) ) : ?>
<div class="notice notice-error notice-alt">
<?php foreach ( $messages as $message ) : ?>
<div class="notice notice-error">
<?php echo wpautop( $message ); ?>
</div>
<p><?php echo wp_kses_post( $message ); ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ( true === $complete ) : ?>
<div class="notice notice-info">
<?php echo wpautop( __( 'Thank you for your submission. You will receive an email confirmation.', 'wporg' ) ); ?>
<div class="notice notice-success notice-alt">
<p><?php esc_html_e( 'Thanks for pledging Five for the Future! Your new pledge profile has been created, and weve emailed you a link you can use to edit your pledge in the future. Your contributors have also been emailed a link to confirm their contributions with your organization.', 'wporg' ); ?></p>
<p><?php esc_html_e( 'Once your pledge has been approved by a moderator, it will appear in the pledges list.', 'wporg' ); ?></p>
<p><?php esc_html_e( 'Want to hire additional employees to contribute to WordPress? Post a job listing on jobs.wordpress.net.', 'wporg' ); ?></p>
</div>
<?php else : ?>
<form id="5ftf-form-pledge-new" action="" method="post">
<form class="pledge-form" id="5ftf-form-pledge-new" action="" method="post">
<?php
require get_views_path() . 'inputs-pledge-org-info.php';
require get_views_path() . 'inputs-pledge-org-logo.php';
require get_views_path() . 'inputs-pledge-org-email.php';
require get_views_path() . 'inputs-pledge-contributors.php';
require get_views_path() . 'inputs-pledge-org-email.php';
require get_views_path() . 'inputs-pledge-new-misc.php';
?>
<div>
<input type="submit" id="5ftf-pledge-submit" name="action" class="button button-primary" value="<?php esc_attr_e( 'Submit Pledge', 'wporg' ); ?>" />
<input
type="submit"
id="5ftf-pledge-submit"
name="action"
value="<?php esc_attr_e( 'Submit Pledge', 'wporg' ); ?>"
/>
</div>
</form>

View file

@ -1,9 +1,9 @@
<?php
namespace WordPressDotOrg\FiveForTheFuture\View;
/** @var bool $editable */
/** @var array $data */
/** @var array $contributors */
/** @var array $data */
/** @var bool $readonly */
?>
<?php if ( empty( $contributors ) ) : ?>
@ -14,14 +14,14 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
</label>
<input
type="text"
class="large-text"
id="5ftf-pledge-contributors"
name="pledge-contributors"
value=""
required
aria-describedby="5ftf-pledge-contributors-help"
/>
<p>
<!-- Instructions for inputting wporg usernames -->
<p id="5ftf-pledge-contributors-help">
<?php esc_html_e( 'Separate each username with a comma.', 'wordpressorg' ); ?>
</p>
</div>

View file

@ -1,11 +1,11 @@
<?php
namespace WordPressDotOrg\FiveForTheFuture\View;
/** @var bool $editable */
/** @var array $data */
/** @var bool $readonly */
?>
<div class="form-field">
<div class="form-field form-field__agree">
<p>
<!-- Statement of agreement to pledge, link to further info maybe? -->
</p>

View file

@ -1,23 +1,26 @@
<?php
namespace WordPressDotOrg\FiveForTheFuture\View;
/** @var bool $editable */
/** @var array $data */
/** @var bool $readonly */
?>
<div class="form-field">
<label for="5ftf-pledge-email" class="screen-reader-text">
<?php esc_html_e( 'Email', 'wordpressorg' ); ?>
<label for="5ftf-pledge-email">
<?php esc_html_e( 'Administrator Email', 'wordpressorg' ); ?>
</label>
<input
type="email"
class="large-text"
id="5ftf-pledge-email"
name="org-pledge-email"
value="<?php echo esc_attr( $data['pledge-email'] ); ?>"
value="<?php echo esc_attr( $data['org-pledge-email'] ); ?>"
required
<?php echo ( $editable ) ? '' : 'readonly'; ?>
aria-describedby="5ftf-pledge-email-help"
<?php echo $readonly ? 'readonly' : ''; ?>
/>
<p id="5ftf-pledge-email-help">
<?php esc_html_e( 'This email will be used to verify your organizations contribution profile, and later manage any changes.', 'wordpressorg' ); ?>
</p>
<?php if ( is_admin() ) : ?>
<?php if ( $data['pledge-email-confirmed'] ) : ?>

View file

@ -1,8 +1,8 @@
<?php
namespace WordPressDotOrg\FiveForTheFuture\View;
/** @var bool $editable */
/** @var array $data */
/** @var bool $readonly */
?>
<div class="form-field">
@ -11,12 +11,24 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
</label>
<input
type="text"
class="large-text"
id="5ftf-org-name"
name="org-name"
value="<?php echo esc_attr( $data['org-name'] ); ?>"
required
<?php echo ( $editable ) ? '' : 'readonly'; ?>
<?php echo $readonly ? 'readonly' : ''; ?>
/>
</div>
<div class="form-field form-field__logo">
<label for="5ftf-org-logo">
<?php esc_html_e( 'Logo', 'wordpressorg' ); ?>
</label>
<br />
<?php /* @todo Display existing logo here */ ?>
<input
type="file"
id="5ftf-org-logo"
name="org-logo"
/>
</div>
@ -26,26 +38,39 @@ namespace WordPressDotOrg\FiveForTheFuture\View;
</label>
<input
type="url"
class="large-text"
id="5ftf-org-url"
name="org-url"
value="<?php echo esc_attr( $data['org-url'] ); ?>"
required
<?php echo ( $editable ) ? '' : 'readonly'; ?>
<?php echo $readonly ? 'readonly' : ''; ?>
/>
</div>
<div class="form-field">
<label for="5ftf-org-description">
<?php _e( 'Organization Blurb', 'wordpressorg' ); ?>
<?php esc_html_e( 'Organization Blurb', 'wordpressorg' ); ?>
</label>
<textarea
class="large-text"
id="5ftf-org-description"
name="org-description"
rows="5"
required
<?php echo ( $editable ) ? '' : 'readonly'; ?>
>
<?php echo esc_html( $data['org-description'] ); ?>
</textarea>
<?php echo $readonly ? 'readonly' : ''; ?>
><?php /* phpcs:ignore -- php tags should be on the same line as textarea to prevent extra whitespace */
echo esc_html( $data['org-description'] );
/* phpcs:ignore */ ?></textarea>
</div>
<div class="form-field">
<label for="5ftf-org-number-employees">
<?php esc_html_e( 'Number of Employees Being Contributed', 'wordpressorg' ); ?>
</label>
<input
type="number"
id="5ftf-org-number-employees"
name="org-number-employees"
value="<?php echo esc_attr( $data['org-number-employees'] ); ?>"
required
<?php echo $readonly ? 'readonly' : ''; ?>
/>
</div>

View file

@ -1,17 +0,0 @@
<?php
namespace WordPressDotOrg\FiveForTheFuture\View;
/** @var bool $editable */
/** @var array $data */
?>
<div class="form-field">
<label for="5ftf-org-logo">
<?php esc_html_e( 'Logo', 'wordpressorg' ); ?>
</label>
<input
type="file"
id="5ftf-org-logo"
name="org-logo"
/>
</div>