From b32fa5a0af835bef34037f1e669ef42977e5ff05 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Tue, 8 Oct 2019 16:42:10 -0400 Subject: [PATCH] Style pledge form in wp-admin --- plugins/wporg-5ftf/assets/css/admin.css | 38 ++++++++++++++++++++- plugins/wporg-5ftf/includes/pledge-meta.php | 20 +++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/plugins/wporg-5ftf/assets/css/admin.css b/plugins/wporg-5ftf/assets/css/admin.css index 64f72ac..1298cca 100755 --- a/plugins/wporg-5ftf/assets/css/admin.css +++ b/plugins/wporg-5ftf/assets/css/admin.css @@ -1 +1,37 @@ -/* rounded corners on contributor avatar */ \ No newline at end of file +.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; +} diff --git a/plugins/wporg-5ftf/includes/pledge-meta.php b/plugins/wporg-5ftf/includes/pledge-meta.php index b2a38ae..b5eac33 100755 --- a/plugins/wporg-5ftf/includes/pledge-meta.php +++ b/plugins/wporg-5ftf/includes/pledge-meta.php @@ -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 '
'; + 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 '
'; } /** @@ -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' ); + } +}