Making WordPress.org

Changeset 7119


Ignore:
Timestamp:
04/17/2018 10:20:19 PM (8 years ago)
Author:
iandunn
Message:

WPF Stripe: Move custom_styles closer to render_donate_shortcode.

This makes for a more logical order since they're rendered together at the same time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpressfoundation.org/public_html/content/plugins/wpf-stripe/wpf-stripe.php

    r6866 r7119  
    123123add_shortcode( 'wpfstripe', __NAMESPACE__ . '\render_donate_shortcode' );
    124124
     125/**
     126 * Output CSS for the `[wpfstripe]` shortcode.
     127 */
     128function custom_styles() {
     129    global $post;
     130
     131    if ( ! is_a( $post, 'WP_Post' ) || 'donate' !== $post->post_name ) {
     132        return;
     133    }
     134
     135    ?>
     136
     137    <style>
     138        .stripe-button-el {
     139            text-transform: none;
     140        }
     141
     142        .subscription-plans .stripe-button-el {
     143            margin: 0 12px 12px 0;
     144        }
     145
     146            @media screen and ( min-width: 415px ) {
     147                .subscription-plans {
     148                    display: flex;
     149                    flex-wrap: wrap;
     150                    justify-content: space-around;
     151                }
     152            }
     153
     154        .one-time-donation {
     155            margin-top: .5em;
     156        }
     157
     158        .one-time-donation form {
     159            margin-top: .5em;
     160            text-align: center;
     161        }
     162
     163            .amount {
     164                position: relative;
     165                top: 3px;
     166                width: 5em;
     167                margin-right: .5em;
     168                padding: 1px 5px;
     169                text-align: center;
     170            }
     171    </style>
     172
     173    <?php
     174}
     175add_action( 'wp_head', __NAMESPACE__ . '\custom_styles' );
     176
     177/**
     178 * Process donation transactions through Stripe's API.
     179 *
     180 * Emails for successful transactions are sent by `handle_webhooks()`.
     181 */
    125182function process_payments() {
    126183    if ( ! isset( $_POST['stripeEmail'], $_POST['stripeToken'] ) ) {
     
    166223
    167224/**
    168  * Output CSS for the `[wpfstripe]` shortcode.
    169  */
    170 function custom_styles() {
    171     global $post;
    172 
    173     if ( ! is_a( $post, 'WP_Post' ) || 'donate' !== $post->post_name ) {
    174         return;
    175     }
    176 
    177     ?>
    178 
    179     <style>
    180         .stripe-button-el {
    181             text-transform: none;
    182         }
    183 
    184         .subscription-plans .stripe-button-el {
    185             margin: 0 12px 12px 0;
    186         }
    187 
    188             @media screen and ( min-width: 415px ) {
    189                 .subscription-plans {
    190                     display: flex;
    191                     flex-wrap: wrap;
    192                     justify-content: space-around;
    193                 }
    194             }
    195 
    196         .one-time-donation {
    197             margin-top: .5em;
    198         }
    199 
    200         .one-time-donation form {
    201             margin-top: .5em;
    202             text-align: center;
    203         }
    204 
    205             .amount {
    206                 position: relative;
    207                 top: 3px;
    208                 width: 5em;
    209                 margin-right: .5em;
    210                 padding: 1px 5px;
    211                 text-align: center;
    212             }
    213     </style>
    214 
    215     <?php
    216 }
    217 add_action( 'wp_head', __NAMESPACE__ . '\custom_styles' );
    218 
    219 /**
    220225 * Log an error message.
    221226 *
Note: See TracChangeset for help on using the changeset viewer.