Making WordPress.org

Changeset 6611


Ignore:
Timestamp:
02/12/2018 10:23:27 PM (4 years ago)
Author:
iandunn
Message:

WordCamp Payments: Replace code with get_wordcamp_dropdown().

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/sponsor-payment-stripe.php

    r6602 r6611  
    66namespace WordCamp\Budgets\Sponsor_Payment_Stripe;
    77use WordCamp\Utilities\Stripe_Client;
     8use WordCamp_Loader;
    89use WordCamp_Budgets;
    910use Exception;
     
    3435        'keys'       => $keys,
    3536        'step'       => STEP_SELECT_INVOICE,
    36         'wordcamps'  => _get_wordcamps(),
     37        'wordcamp_query_options' => get_wordcamp_query_options(),
    3738        'currencies' => WordCamp_Budgets::get_currencies(),
    3839        'errors'     => array(),
     
    6465
    6566/**
    66  * Return a list of valid WordCamp posts.
    67  *
    68  * @return array An array or WP_Post objects for all public WordCamps.
    69  */
    70 function _get_wordcamps() {
    71     static $wordcamps;
    72 
    73     if ( ! isset( $wordcamps ) ) {
    74         $wordcamps = get_posts( array(
    75             'post_type'      => 'wordcamp',
    76             'post_status'    => \WordCamp_Loader::get_public_post_statuses(),
    77             'posts_per_page' => - 1,
    78             'orderby'        => 'title',
    79             'order'          => 'asc',
    80 
    81             'meta_query' => array(
    82                 array(
    83                     'key'     => 'Start Date (YYYY-mm-dd)',
    84                     'value'   => strtotime( '-3 months' ),
    85                     'compare' => '>'
    86                 )
     67 * Returns query options to be used with `get_wordcamps()`.
     68 *
     69 * This provides a consistent and canonical source for the query options, so that all callers are in sync.
     70 *
     71 * @return array
     72 */
     73function get_wordcamp_query_options() {
     74    return array(
     75        'post_status' => WordCamp_Loader::get_public_post_statuses(),
     76        'orderby'     => 'title',
     77        'order'       => 'asc',
     78
     79        'meta_query' => array(
     80            array(
     81                'key'     => 'Start Date (YYYY-mm-dd)',
     82                'value'   => strtotime( '-3 months' ),
     83                'compare' => '>'
    8784            )
    88         ) );
    89     }
    90 
    91     return $wordcamps;
     85        )
     86    );
    9287}
    9388
     
    136131            // Make sure the selected WordCamp is valid.
    137132            $wordcamp_id = absint( $_POST['wordcamp_id'] );
    138             $valid_ids   = wp_list_pluck( _get_wordcamps(), 'ID' );
     133            $valid_ids   = wp_list_pluck( get_wordcamps( get_wordcamp_query_options() ), 'ID' );
    139134
    140135            if ( ! in_array( $wordcamp_id, $valid_ids ) ) {
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/sponsor-payment/main.php

    r6603 r6611  
    2929                <label><?php esc_html_e( 'Event', 'wordcamporg' ); ?></label>
    3030                <div class="control">
    31                     <select name="wordcamp_id">
    32                         <option value="" disabled selected><?php esc_html_e( 'Select a WordCamp', 'wordcamporg' ); ?></option>
    33                         <?php foreach ( $data['wordcamps'] as $wordcamp ) : ?>
    34                         <option value="<?php echo esc_attr( $wordcamp->ID ); ?>"><?php echo esc_html( $wordcamp->post_title ); ?></option>
    35                         <?php endforeach; ?>
    36                     </select>
     31                    <?php echo get_wordcamp_dropdown( 'wordcamp_id', $data['wordcamp_query_options'] ); ?>
    3732                </div>
    3833
Note: See TracChangeset for help on using the changeset viewer.