Style pledge form in wp-admin

This commit is contained in:
Kelly Dwan 2019-10-08 16:42:10 -04:00
parent 161331deff
commit b32fa5a0af
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
2 changed files with 57 additions and 1 deletions

View file

@ -1 +1,37 @@
/* rounded corners on contributor avatar */
.pledge-form .form-field {
margin-bottom: 16px;
}
.pledge-form .form-field label {
margin-bottom: 8px;
display: inline-block;
}
.pledge-form .form-field input[type=text],
.pledge-form .form-field input[type=url],
.pledge-form .form-field input[type=number],
.pledge-form .form-field input[type=email],
.pledge-form .form-field textarea {
display: block;
width: 100%;
padding: 8px;
}
.pledge-form .form-field input[type=number] {
max-width: 10em;
height: auto;
}
.pledge-form .form-field > p {
margin-top: 8px;
font-size: 0.9em;
}
.pledge-form .form-field__logo input {
padding: 8px 0;
line-height: 1;
}
.pledge-form .form-field__agree label {
margin-bottom: 0;
}

View file

@ -17,6 +17,7 @@ add_action( 'init', __NAMESPACE__ . '\register_ple
add_action( 'admin_init', __NAMESPACE__ . '\add_meta_boxes' );
add_action( 'save_post', __NAMESPACE__ . '\save_pledge', 10, 2 );
add_action( 'updated_' . Pledge\CPT_ID . '_meta', __NAMESPACE__ . '\update_generated_meta', 10, 4 );
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\enqueue_assets' );
/**
* Define pledge meta fields and their properties.
@ -142,6 +143,8 @@ function render_meta_boxes( $pledge, $box ) {
$data[ $key ] = get_post_meta( $pledge->ID, META_PREFIX . $key, $config['single'] );
}
echo '<div class="pledge-form">';
switch ( $box['id'] ) {
case 'pledge-email':
require FiveForTheFuture\get_views_path() . 'inputs-pledge-org-email.php';
@ -154,6 +157,8 @@ function render_meta_boxes( $pledge, $box ) {
require FiveForTheFuture\get_views_path() . 'inputs-pledge-contributors.php';
break;
}
echo '</div>';
}
/**
@ -343,3 +348,18 @@ function get_normalized_domain_from_url( $url ) {
return $domain;
}
/**
* Enqueue CSS file for admin page.
*
* @return void
*/
function enqueue_assets() {
$ver = filemtime( FiveForTheFuture\PATH . '/assets/css/admin.css' );
wp_register_style( '5ftf-admin', plugins_url( 'assets/css/admin.css', __DIR__ ), [], $ver );
$current_page = get_current_screen();
if ( Pledge\CPT_ID === $current_page->id ) {
wp_enqueue_style( '5ftf-admin' );
}
}