Making WordPress.org

Changeset 8085


Ignore:
Timestamp:
01/16/2019 03:36:24 PM (5 years ago)
Author:
vedjain
Message:

WCPT: Applies code standard changes to wcpt plugin.

Most of the changes are small, but these are some important ones:

  1. Added nonce check in multiple places. This will ensure that request is always coming from the intended page.
  1. Escaped output HTML in many places. These are not necessarily XSS vulnerabilities, and in most places they were hardcoded. But its a good practice to always escape regardless of source.

Summary:

  • wcpt-event/class-event-admin.php
    • Added nonce check in metabox_save.
    • Escaped output in dislpay_meta_boxes
  • wcpt-event/class-event-application.php
    • Change definition of submit_application to pass $POST arguments
  • wcpt-loader.php
    • Indent whole file by 1 indent.
  • wcpt-meetup/class-meetup-admin.php
    • Added nonce check in maybe_update_meetup_data
  • wcpt-wordcamp/wordcamp-admin.php
    • Escaping in user_profile_wordcamp, column_data
    • Escaping using kses in post_row_actions
    • Use post_data_raw instead of $_POST in enforce_post_status
Location:
sites/trunk/wordcamp.org
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/phpcs.xml.dist

    r8072 r8085  
    155155        <exclude name="Squiz.Commenting.ClassComment.WrongStyle" />
    156156        <exclude name="Squiz.Commenting.ClassComment.SpacingAfter" />
     157
     158        <!-- WordPress have translators comment which requires no space after `//` -->
     159        <exclude name="Squiz.Commenting.InlineComment.NoSpaceBefore" />
    157160    </rule>
    158161
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/views/applications/meetup/shortcode-application.php

    r7885 r8085  
    22
    33namespace WordPress_Community\Applications\Meetup;
    4 defined( 'WPINC' ) or die();
     4defined( 'WPINC' ) || die();
    55
    66/**
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/views/applications/wordcamp/shortcode-application.php

    r7607 r8085  
    22
    33namespace WordPress_Community\Applications\WordCamp;
    4 defined( 'WPINC' ) or die();
     4defined( 'WPINC' ) || die();
    55
    66
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-admin.php

    r8083 r8085  
    4242
    4343        add_filter(
    44             'manage_' . $this->get_event_type() . '_posts_columns', array(
     44            'manage_' . $this->get_event_type() . '_posts_columns',
     45            array(
    4546                $this,
    4647                'column_headers',
     
    6061        add_filter( 'redirect_post_location', array( $this, 'add_admin_notices_to_redirect_url' ), 10, 2 );
    6162
    62         // Admin notices
     63        // Admin notices.
    6364        add_action( 'admin_notices', array( $this, 'print_admin_notices' ) );
    6465
     
    269270
    270271        $log_id = add_post_meta(
    271             $post->ID, '_status_change', array(
     272            $post->ID,
     273            '_status_change',
     274            array(
    272275                'timestamp' => time(),
    273276                'user_id'   => get_current_user_id(),
     
    275278            )
    276279        );
    277         // Encoding $post_type and status_change meta ID in key so that we can fetch it if needed while simultaneously be able to have a where clause on value
    278         // Because of the way MySQL works, it will still be able to use index on meta_key when searching, as long as we are querying just the prefix
     280        // Encoding $post_type and status_change meta ID in key so that we can fetch it if needed while simultaneously be able to have a where clause on value.
     281        // Because of the way MySQL works, it will still be able to use index on meta_key when searching, as long as we are querying just the prefix.
    279282        if ( $log_id ) {
    280283            add_post_meta( $post->ID, "_status_change_log_$post->post_type $log_id", time() );
     
    285288     * Hooked to `transition_post_status`, will send notifications to community slack channels based whenever an application status changes to something that we are interested in. Most likely would be when an application is declined or accepted.
    286289     *
    287      * @param string  $new_status New status
    288      * @param string  $old_status Old Status
     290     * @param string  $new_status New status.
     291     * @param string  $old_status Old Status.
    289292     * @param WP_Post $event
    290293     */
     
    294297     * Schedule notificaiton for declined application. Currently supports WordCamp and Meetup
    295298     *
    296      * @param WP_Post $event Event object
    297      * @param string  $label Could be WordCamp or Meetup
     299     * @param WP_Post $event Event object.
     300     * @param string  $label Could be WordCamp or Meetup.
    298301     * @param string  $location
    299      *
    300      * @return bool|string
    301302     */
    302303    public static function schedule_decline_notification( $event, $label, $location ) {
     
    313314    public static function send_decline_notification( $event_id, $label, $location ) {
    314315        $message = sprintf(
    315             "A %s application for %s has been declined, and the applicant has been informed via email.",
     316            'A %s application for %s has been declined, and the applicant has been informed via email.',
    316317            $label,
    317318            $location
     
    345346        }
    346347
    347         wp_localize_script( 'wcpt-admin', 'wcpt_admin', array(
    348             'gutenberg_enabled' => $gutenberg_enabled,
    349         ) );
     348        wp_localize_script(
     349            'wcpt-admin',
     350            'wcpt_admin',
     351            array( 'gutenberg_enabled' => $gutenberg_enabled )
     352        );
    350353
    351354        wp_enqueue_script( 'wcpt-admin' );
     
    402405     * Save metadata from form
    403406     *
    404      * @param int     $post_id Post ID.
    405      * @param WP_Post $post    Post Object.
     407     * @hook save_post
    406408     */
    407409    public function metabox_save( $post_id, $post ) {
     
    411413        }
    412414
     415        // Make sure the requset came from the edit post screen.
     416        if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update-post_' . $post_id ) ) {
     417            die( 'Unable to verify nonce' );
     418        }
     419
    413420        // Don't add/remove meta on trash, untrash, restore, etc.
    414421        if ( empty( $_POST['action'] ) || 'editpost' !== $_POST['action'] ) {
     
    417424
    418425        if ( $this->get_event_type() !== get_post_type() ) {
    419             return;
    420         }
    421 
    422         // Make sure the requset came from the edit post screen.
    423         if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update-post_' . $post_id ) ) {
    424426            return;
    425427        }
     
    432434            $values[ $key ] = isset( $_POST[ $post_value ] ) ? esc_attr( $_POST[ $post_value ] ) : '';
    433435
    434             // Don't update protected fields
     436            // Don't update protected fields.
    435437            if ( $this->is_protected_field( $key ) ) {
    436438                continue;
     
    477479        }
    478480
     481        // TODO: This should also pass $_POST params since nonce is verified here.
    479482        do_action( 'wcpt_metabox_save_done', $post_id, $orig_meta_values );
    480483
     
    500503        }
    501504
    502         // Don't show conflicting messages like 'Post submitted.'
     505        // Don't show conflicting messages like 'Post submitted'.
    503506        if ( in_array( 1, $this->active_admin_notices ) && false !== strpos( $location, 'message=8' ) ) {
    504507            $location = remove_query_arg( 'message', $location );
     
    527530        $screen = get_current_screen();
    528531
    529 
    530532        if ( empty( $post->post_type ) || $this->get_event_type() != $post->post_type || 'post' !== $screen->base ) {
    531533            return;
     
    570572        }
    571573
    572         // Note that this is private, see wcpt_get_log_entries()
     574        // Note that this is private, see `wcpt_get_log_entries()`.
    573575        add_post_meta(
    574             $post_id, '_note', array(
     576            $post_id,
     577            '_note',
     578            array(
    575579                'timestamp' => time(),
    576580                'user_id'   => get_current_user_id(),
     
    606610
    607611                    <p>
    608                         <strong><?php echo $key; ?></strong>:
    609                         <input type="checkbox" name="<?php echo $object_name; ?>"
    610                                id="<?php echo $object_name; ?>" <?php checked( get_post_meta( $post_id, $key, true ) ); ?><?php echo $readonly; ?> />
     612                        <strong><?php echo esc_html( $key ); ?></strong>:
     613                        <input type="checkbox" name="<?php echo esc_attr( $object_name ); ?>"
     614                               id="<?php echo esc_attr( $object_name ); ?>" <?php checked( get_post_meta( $post_id, $key, true ) ); ?><?php echo esc_attr( $readonly ); ?> />
    611615                    </p>
    612616
     
    614618
    615619                    <p>
    616                         <strong><?php echo $key; ?></strong>
     620                        <strong><?php echo esc_html( $key ); ?></strong>
    617621                        <?php if ( in_array( $key, $required_fields, true ) ) : ?>
    618                             <span class="description"><?php _e( '(required)', 'wordcamporg' ); ?></span>
     622                            <span class="description"><?php esc_html_e( '(required)', 'wordcamporg' ); ?></span>
    619623                        <?php endif; ?>
    620624                    </p>
     
    622626                    <p>
    623627                        <label class="screen-reader-text"
    624                                for="<?php echo $object_name; ?>"><?php echo $key; ?></label>
     628                               for="<?php echo esc_attr( $object_name ); ?>"><?php echo esc_html( $key ); ?></label>
    625629
    626630                        <?php
     
    629633                                ?>
    630634
    631                                 <input type="text" size="36" name="<?php echo $object_name; ?>"
    632                                        id="<?php echo $object_name; ?>"
    633                                        value="<?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?>"<?php echo $readonly; ?> />
     635                                <input type="text" size="36" name="<?php echo esc_attr( $object_name ); ?>"
     636                                       id="<?php echo esc_attr( $object_name ); ?>"
     637                                       value="<?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?>"<?php echo esc_attr( $readonly ); ?> />
    634638
    635639                                <?php
     
    638642                                ?>
    639643
    640                                 <input type="number" size="16" name="<?php echo $object_name; ?>"
    641                                        id="<?php echo $object_name; ?>"
     644                                <input type="number" size="16" name="<?php echo esc_attr( $object_name ); ?>"
     645                                       id="<?php echo esc_attr( $object_name ); ?>"
    642646                                       value="<?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?>"
    643                                        step="any" min="0"<?php echo $readonly; ?> />
     647                                       step="any" min="0"<?php echo esc_attr( $readonly ); ?> />
    644648
    645649                                <?php
    646650                                break;
    647651                            case 'date':
    648                                 // Quick filter on dates
    649                                 if ( $date = get_post_meta( $post_id, $key, true ) ) {
     652                                // Quick filter on dates.
     653                                $date = get_post_meta( $post_id, $key, true );
     654                                if ( $date ) {
    650655                                    $date = date( 'Y-m-d', $date );
    651656                                }
     
    653658                                ?>
    654659
    655                                 <input type="text" size="36" class="date-field" name="<?php echo $object_name; ?>"
    656                                        id="<?php echo $object_name; ?>"
    657                                        value="<?php echo $date; ?>"<?php echo $readonly; ?> />
     660                                <input type="text" size="36" class="date-field" name="<?php echo esc_attr( $object_name ); ?>"
     661                                       id="<?php echo esc_attr( $object_name ); ?>"
     662                                       value="<?php echo esc_attr( $date ); ?>"<?php echo esc_attr( $readonly ); ?> />
    658663
    659664                                <?php
     
    662667                                ?>
    663668
    664                                 <textarea rows="4" cols="23" name="<?php echo $object_name; ?>"
    665                                           id="<?php echo $object_name; ?>"<?php echo $readonly; ?>><?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?></textarea>
     669                                <textarea rows="4" cols="23" name="<?php echo esc_attr( $object_name ); ?>"
     670                                          id="<?php echo esc_attr( $object_name ); ?>"<?php echo esc_attr( $readonly ); ?>><?php echo esc_attr( get_post_meta( $post_id, $key, true ) ); ?></textarea>
    666671
    667672                                <?php
     
    675680                                    $value = get_post_meta( $post_id, $key, true );
    676681                                    ?>
    677                                 <select name="<?php echo $object_name; ?>"
    678                                         id="<?php echo $object_name; ?>"<?php echo $readonly; ?>>
     682                                <select name="<?php echo esc_attr( $object_name ); ?>"
     683                                        id="<?php echo esc_attr( $object_name ); ?>"<?php echo esc_attr( $readonly ); ?>>
    679684                                    <option value="<?php echo esc_attr( $value ); ?>" selected>
    680685                                        <?php echo ( $value ) ? esc_html( $currencies[ $value ] . ' (' . $value . ')' ) : ''; ?>
     
    696701
    697702                            case 'deputy_list':
    698                                 wp_dropdown_users( array(
    699                                     'role__in'         => array(
    700                                         'administrator',
    701                                         'editor',
    702                                     ),
    703                                     'name'             => esc_attr( $object_name ),
    704                                     'id'               => esc_attr( $object_name ),
    705                                     'selected'         => get_post_meta( $post_id, $key, true ),
    706                                     'show_option_none' => 'None',
    707                                 ) );
     703                                wp_dropdown_users(
     704                                    array(
     705                                        'role__in'         => array(
     706                                            'administrator',
     707                                            'editor',
     708                                        ),
     709                                        'name'             => esc_attr( $object_name ),
     710                                        'id'               => esc_attr( $object_name ),
     711                                        'selected'         => get_post_meta( $post_id, $key, true ),
     712                                        'show_option_none' => 'None',
     713                                    )
     714                                );
    708715                                break;
    709716                            default:
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php

    r8083 r8085  
    5353
    5454    /**
    55      * Render the output the of the [meetup-organizer-application] shortcode.
     55     * Render the output the of the application forms shortcode.
    5656     *
    5757     * @todo Use force_login_to_view_form() and populate_form_based_on_user().
     
    6262        ob_start();
    6363
     64        // phpcs:ignore WordPress.Security.NonceVerification.Missing -- We do not verify nonce for frontend forms because WP Super Cache may cache an expired nonce token.
    6465        if ( isset( $_POST['submit-application'] ) ) {
    65             $this->submit_application();
     66            $this->submit_application( $_POST );
    6667        } else {
    6768            $countries = wcorg_get_countries();
     
    8384    /**
    8485     * Submit application details. Calls `create_post` to actually create the event.
    85      */
    86     public function submit_application() {
    87         $application_data = $this->validate_data( $_POST );
     86     *
     87     * @param array $post_data Form params.
     88     */
     89    public function submit_application( $post_data ) {
     90        $application_data = $this->validate_data( $post_data );
    8891
    8992        if ( $this->is_rate_limited() ) {
     
    9699            $this->create_post( $application_data );
    97100            $this->notify_applicant_application_received(
    98                     $this->get_organizer_email(),
    99                     $this->get_event_location()
     101                $this->get_organizer_email(),
     102                $this->get_event_location()
    100103            );
    101104
     
    223226        $message = sprintf(
    224227            __(
    225                 "Thank you for applying to organize a %s in %s! We'll send you a follow-up e-mail once we've had a chance to review your application.",
     228                "Thank you for applying to organize a %1\$s in %2\$s! We'll send you a follow-up e-mail once we've had a chance to review your application.",
    226229                'wpct'
    227230            ),
    228             $this->get_event_label(), sanitize_text_field( $event_city )
     231            $this->get_event_label(),
     232            sanitize_text_field( $event_city )
    229233        );
    230234
     
    238242
    239243        // Not translating because this will be sent to community events slack channel.
    240         $message = sprintf( "A %s application for %s has been received.", $this->get_event_label(), $this->get_event_location() );
     244        $message = sprintf( 'A %s application for %s has been received.', $this->get_event_label(), $this->get_event_location() );
    241245
    242246        $public_report_url = $this->get_application_report_url();
    243247        if ( isset( $public_report_url ) ) {
    244248            // `<%s|here> is syntax for slack message to hyperlink text `here` with url provided in `%s`
    245             $message = sprintf( "%s Public status can be followed on <%s|%s application report page>.", $message, $public_report_url, $this->get_event_label() );
     249            $message = sprintf( '%s Public status can be followed on <%s|%s application report page>.', $message, $public_report_url, $this->get_event_label() );
    246250        }
    247251
    248252        $default_status = $this->get_default_status();
    249         $queue_size = wp_count_posts( $post_type=$this->get_event_type() )->$default_status;
     253        $queue_size = wp_count_posts( $this->get_event_type() )->$default_status;
    250254        if ( isset( $queue_size ) ) {
    251255            $singular = "is $queue_size application";
    252256            $plural   = "are $queue_size applications";
    253257            $message = sprintf(
    254                     "%s\n _There %s in vetting queue._",
    255                     $message,
    256                     1 === $queue_size ? $singular : $plural );
    257         }
    258 
    259         $attachment = create_event_attachment( $message,  sprintf( "New %s application ", $this->get_event_label() ) );
     258                "%s\n _There %s in vetting queue._",
     259                $message,
     260                1 === $queue_size ? $singular : $plural
     261            );
     262        }
     263
     264        $attachment = create_event_attachment( $message,  sprintf( 'New %s application ', $this->get_event_label() ) );
    260265        return wcpt_slack_notify( COMMUNITY_TEAM_SLACK, $attachment );
    261266    }
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/notification.php

    r8084 r8085  
    55
    66if ( defined( 'WPORG_SANDBOXED' ) && WPORG_SANDBOXED ) {
    7     // If this is sandbox and then send notification of owner of sandbox (as long as sandbox username and slack username matches)
     7    // If this is sandbox and then send notification of owner of sandbox (as long as sandbox username and slack username matches).
    88    if ( defined( 'SANDBOX_SLACK_USERNAME' ) ) {
    99        $slack_username = SANDBOX_SLACK_USERNAME;
    1010    } else {
    11         $slack_username = "@" . str_replace( array( '.dev.ord', '.dev' ), '', WPORG_SANDBOXED );
     11        $slack_username = '@' . str_replace( array( '.dev.ord', '.dev' ), '', WPORG_SANDBOXED );
    1212    }
    1313    define( 'COMMUNITY_TEAM_SLACK', $slack_username );
     
    2222 *
    2323 * @param string $channel Name of the channel we want to send the notification to.
    24  * @param array  $attachment Attachment object
     24 * @param array  $attachment Attachment object.
    2525 *
    2626 * @return bool|string
    2727 */
    28 function wcpt_slack_notify ( $channel, $attachment ) {
     28function wcpt_slack_notify( $channel, $attachment ) {
    2929    if ( ! class_exists( 'Dotorg\Slack\Send' ) ) {
    3030        return false;
     
    4444 * See the structure of attachment here: https://api.slack.com/docs/message-attachments
    4545 *
    46  * @param string $message Main text to send in the notification
    47  * @param string $event_label Label for the event. Would probably be one of `WordCamp` or `Meetup`.
     46 * @param string $message Main text to send in the notification.
     47 * @param string $title   Title of the notification.
    4848 *
    4949 * @return array
    5050 */
    51 function create_event_attachment ( $message, $title ) {
     51function create_event_attachment( $message, $title ) {
    5252    // Not translating because this will be send to Slack.
    5353    return array(
    54         "title" => $title,
    55         "text" => $message,
     54        'title' => $title,
     55        'text' => $message,
    5656    );
    5757}
    5858
     59/**
     60 * Returns an attachment object to customize notification for slack.
     61 * See https://api.slack.com/docs/message-attachments
     62 *
     63 * @param string $message  Text that should be in the attachment.
     64 * @param int    $event_id Post ID of the event. Will be used to gather props.
     65 * @param string $title    TItle of the message.
     66 *
     67 * @return array
     68 */
    5969function create_event_status_attachment( $message, $event_id, $title ) {
    6070    $props = get_props_for_event( $event_id );
    6171
    62     $props_string = implode( ", ", $props );
     72    $props_string = implode( ', ', $props );
     73
    6374    return array(
    64         "title" => $title,
    65         "text" => $message,
    66         "fields" => array(
     75        'title' => $title,
     76        'text'  => $message,
     77        'fields' => array(
    6778            array(
    6879                "title" => "Application processed by",
     
    8293 * @return array Array of usernames of people who have participated in vetting this application
    8394 */
    84 function get_props_for_event ( $event_id ) {
     95function get_props_for_event( $event_id ) {
    8596    $user_ids = array();
    8697
     
    97108    $user_nicenames = get_user_nicenames_from_ids( $user_ids );
    98109
    99     // remove bot user `wordcamp`
     110    // remove bot user `wordcamp`.
    100111    $user_nicenames = array_diff( $user_nicenames, array( 'wordcamp' ) );
    101112    return $user_nicenames;
     
    105116 * Return user names for list of user ids provided in the function
    106117 *
    107  * @param array $user_ids List of user_ids
     118 * @param array $user_ids List of user_ids.
    108119 *
    109120 * @return array List of user nicenames
     
    114125    }
    115126
    116     $user_query = new WP_User_Query( array( 'include' => $user_ids, 'fields'  => array( 'user_nicename' ), ) );
     127    $user_query = new WP_User_Query(
     128        array(
     129            'include' => $user_ids,
     130            'fields'  => array( 'user_nicename' ),
     131        )
     132    );
    117133
    118134    $users = $user_query->get_results();
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-loader.php

    r8083 r8085  
    11<?php
     2
    23/*
    34Plugin Name: WordCamp Post Type
     
    1819define( 'WCPT_URL', plugins_url( '/', __FILE__ ) );
    1920
    20 if ( !class_exists( 'WCPT_Loader' ) ) :
    21 /**
    22  * WCPT_Loader
    23  *
    24  * @package
    25  * @subpackage Loader
    26  * @since WordCamp Post Type (0.1)
    27  *
    28  */
    29 class WCPT_Loader {
     21if ( ! class_exists( 'WCPT_Loader' ) ) :
     22    /**
     23     * WCPT_Loader
     24     *
     25     * @package
     26     * @subpackage Loader
     27     * @since WordCamp Post Type (0.1)
     28     */
     29    class WCPT_Loader {
    3030
    31     /**
    32     * The main WordCamp Post Type loader
    33     */
    34     function __construct() {
    35         add_action( 'plugins_loaded', array( $this, 'core_admin' ) );
    36         add_action( 'init', array( $this, 'core_text_domain' ) );
     31        /**
     32        * The main WordCamp Post Type loader
     33        */
     34        public function __construct() {
     35            add_action( 'plugins_loaded', array( $this, 'core_admin' ) );
     36            add_action( 'init', array( $this, 'core_text_domain' ) );
    3737
    38         $this->includes();
    39     }
     38            $this->includes();
     39        }
    4040
    41     /**
    42     * WordCamp Core File Includes
    43     */
    44     function includes() {
    45         // Load the files
    46         require_once ( WCPT_DIR . 'wcpt-functions.php' );
    47         require_once ( WCPT_DIR . 'wcpt-wordcamp/wordcamp-loader.php' );
    48         require_once ( WCPT_DIR . 'wcpt-meetup/meetup-loader.php' );
    49         require_once ( WCPT_DIR . 'wcpt-event/tracker.php' );
    50         require_once ( WCPT_DIR . 'wcpt-wordcamp/wordcamp.php' );
    51         require_once ( WCPT_DIR . 'wcpt-meetup/meetup.php' );
    52         require_once ( WCPT_DIR . 'wcpt-meetup/class-meetup-admin.php' );
    53         require_once ( WCPT_DIR . 'wcpt-event/class-event-admin.php' ); // required for declined application cron to work.
     41        /**
     42        * WordCamp Core File Includes
     43        */
     44        public function includes() {
     45            // Load the files.
     46            require_once( WCPT_DIR . 'wcpt-functions.php' );
     47            require_once( WCPT_DIR . 'wcpt-wordcamp/wordcamp-loader.php' );
     48            require_once( WCPT_DIR . 'wcpt-meetup/meetup-loader.php' );
     49            require_once( WCPT_DIR . 'wcpt-event/tracker.php' );
     50            require_once( WCPT_DIR . 'wcpt-wordcamp/wordcamp.php' );
     51            require_once( WCPT_DIR . 'wcpt-meetup/meetup.php' );
     52            require_once( WCPT_DIR . 'wcpt-meetup/class-meetup-admin.php' );
     53            require_once( WCPT_DIR . 'wcpt-event/class-event-admin.php' ); // required for declined application cron to work.
    5454
    55         // Require admin files.
    56         if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
    57             require_once ( WCPT_DIR . 'wcpt-admin.php' );
    58             require_once ( WCPT_DIR . 'wcpt-wordcamp/wordcamp-admin.php' );
    59             require_once ( WCPT_DIR . 'wcpt-wordcamp/privacy.php' );
    60             require_once ( WCPT_DIR . 'mentors/dashboard.php' );
     55            // Require admin files.
     56            if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
     57                require_once( WCPT_DIR . 'wcpt-admin.php' );
     58                require_once( WCPT_DIR . 'wcpt-wordcamp/wordcamp-admin.php' );
     59                require_once( WCPT_DIR . 'wcpt-wordcamp/privacy.php' );
     60                require_once( WCPT_DIR . 'mentors/dashboard.php' );
     61            }
     62        }
     63
     64        /**
     65         * Initialize core admin objects
     66         */
     67        public function core_admin() {
     68            // Quick admin check.
     69            if ( ! is_admin() && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
     70                return;
     71            }
     72
     73            // Create admin.
     74            $GLOBALS['wcpt_admin']     = new WCPT_Admin();
     75            $GLOBALS['wordcamp_admin'] = new WordCamp_Admin();
     76            $GLOBALS['meetup_admin']   = new Meetup_Admin();
     77        }
     78
     79        /**
     80         * Load the translation file for current language
     81         */
     82        public function core_text_domain() {
     83            $locale = apply_filters( 'wcpt_textdomain', get_locale() );
     84            $mofile = WCPT_DIR . "wcpt-languages/wcpt-$locale.mo";
     85
     86            load_textdomain( 'wcpt', $mofile );
    6187        }
    6288    }
    6389
    64     function core_admin() {
    65         // Quick admin check
    66         if ( ! is_admin() && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) {
    67             return;
    68         }
     90endif; // class_exists check.
    6991
    70         // Create admin
    71         $GLOBALS['wcpt_admin'] = new WCPT_Admin;
    72         $GLOBALS['wordcamp_admin'] = new WordCamp_Admin;
    73         $GLOBALS['meetup_admin'] = new Meetup_Admin();
    74     }
    75 
    76     /**
    77      * core_text_domain ()
    78      *
    79      * Load the translation file for current language
    80      */
    81     function core_text_domain() {
    82         $locale = apply_filters( 'wcpt_textdomain', get_locale() );
    83         $mofile = WCPT_DIR . "wcpt-languages/wcpt-$locale.mo";
    84 
    85         load_textdomain( 'wcpt', $mofile );
    86     }
    87 }
    88 
    89 endif; // class_exists check
    90 
    91 // Load everything up
    92 $wcpt_loader     = new WCPT_Loader;
    93 $wordcamp_loader = new WordCamp_Loader;
    94 $meetup_loader = new Meetup_Loader();
     92// Load everything up.
     93$wcpt_loader     = new WCPT_Loader();
     94$wordcamp_loader = new WordCamp_Loader();
     95$meetup_loader   = new Meetup_Loader();
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-admin.php

    r8084 r8085  
    120120        /**
    121121         * Checks if a field is read only.
     122         *
    122123         * @param string $key Name of the field.
    123124         *
     
    168169         * TODO: Remove quickedit action.
    169170         *
    170          * @param $actions
    171          * @param $post
     171         * @param array   $actions
     172         * @param WP_Post $post
    172173         *
    173174         * @return mixed
     
    296297                $last_synced_on = 'Never';
    297298            } else {
    298                 $last_synced_on = date( "Y-m-d",  substr( $last_synced_on, 0, 10 ) );
     299                $last_synced_on = date( 'Y-m-d',  substr( $last_synced_on, 0, 10 ) );
    299300            }
    300301            ?>
    301302            <div class="wcb submitbox">
    302303                <div class="misc-pub-section">
    303                     <label>Last sync: <?php echo $last_synced_on ?></label>
     304                    <label>Last sync: <?php echo esc_html( $last_synced_on ); ?></label>
    304305                </div>
    305306                <div class="misc-pub-section">
    306307                    <label>
    307                         <input type="checkbox" name="<?php echo $element_name ?>" >
     308                        <input type="checkbox" name="<?php echo esc_html( $element_name ); ?>" >
    308309                        Sync Now
    309310                    </label>
     
    316317         * Updates meetup fields using meetup.com API only if Sync now checkbox is checked.
    317318         *
    318          * @param int   $post_id
    319          * @param array $original_meta_values
    320          */
    321         public function maybe_update_meetup_data( $post_id ){
     319         * @param int $post_id
     320         */
     321        public function maybe_update_meetup_data( $post_id ) {
    322322            if ( $this->get_event_type() !== get_post_type() ) {
    323323                return;
    324324            }
    325325
    326             $should_sync = $_POST[ 'sync_with_meetup_api' ] ?? false;
     326            //phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified in `metabox_save` in class-event-admin.php.
     327            $should_sync = $_POST['sync_with_meetup_api'] ?? false;
    327328            if ( ! $should_sync ) {
    328329                return;
     
    340341         * Update meetup fields using meetup.com API
    341342         *
    342          * @param $post_id
     343         * @param int $post_id
    343344         *
    344345         * @return array|WP_Error
     
    350351            $parsed_url = wp_parse_url( $meetup_url, -1 );
    351352
    352             if( ! $parsed_url ) {
     353            if ( ! $parsed_url ) {
    353354                return new WP_Error( 'invalid-url', __('Provided Meetup URL is not a valid URL.', 'wordcamporg' ) );
    354355            }
     
    391392                foreach ( $group_leads as $event_host ) {
    392393                    if ( WCPT_WORDPRESS_MEETUP_ID === $event_host['id'] ) {
    393                         // Skip WordPress admin user
     394                        // Skip WordPress admin user.
    394395                        continue;
    395396                    }
    396397                    $event_hosts[] = array(
    397                             'name' => $event_host['name'],
    398                             'id'   => $event_host['id'],
     398                        'name' => $event_host['name'],
     399                        'id'   => $event_host['id'],
    399400                    );
    400401                }
     
    406407            update_post_meta( $post_id, 'Meetup group created on', $group_details['created'] / 1000 );
    407408
    408 
    409409            if ( isset( $group_details['last_event'] ) && is_array( $group_details['last_event'] ) ) {
    410410                update_post_meta( $post_id, 'Number of past meetups', $group_details['past_event_count'] );
     
    423423         * @param array $original_data
    424424         */
    425         public function meetup_organizers_changed( $post_id, $original_data ){
     425        public function meetup_organizers_changed( $post_id, $original_data ) {
    426426            global $post;
    427427
     
    509509         * Send notification when a new Meetup groups is added to the chapter.
    510510         *
    511          * @param WP_Post $meetup Meetup post object
     511         * @param WP_Post $meetup Meetup post object.
    512512         *
    513513         * @return bool|string
     
    519519            $organizer_slack = get_post_meta( $meetup->ID, 'Slack', true );
    520520            $meetup_link     = get_post_meta( $meetup->ID, 'Meetup URL', true );
    521             $title           = "New meetup group added";
     521            $title           = 'New meetup group added';
    522522
    523523            $message = sprintf(
     
    557557         * Helper method which triggers action `update_meetup_organizers`
    558558         *
    559          * @param $organizers
    560          * @param $post
     559         * @param array   $organizers
     560         * @param WP_Post $post
    561561         */
    562562        protected function update_meetup_organizers( $organizers, $post ) {
     
    580580                'invalid-response'   => array(
    581581                    'type'   => 'notice',
    582                     'notice' => __( 'Received invalid response from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' )
     582                    'notice' => __( 'Received invalid response from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' ),
    583583                ),
    584584                'group_error'        => array(
    585585                    'type'   => 'notice',
    586                     'notice' => __( 'Received invalid response from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' )
     586                    'notice' => __( 'Received invalid response from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' ),
    587587                ),
    588588                'http_response_code' => array(
    589589                    'type'   => 'notice',
    590                     'notice' => __( 'Received invalid response code from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' )
     590                    'notice' => __( 'Received invalid response code from Meetup API. Please make sure Meetup URL is correct, or try again after some time.', 'wordcamporg' ),
    591591                ),
    592592            );
     
    597597         * Render list of co-organizer of meetup linking to their profile on meetup.com
    598598         *
    599          * @param string $key Name of meetup field. Should be 'Meetup Co-organizer names'
     599         * @param string $key Name of meetup field. Should be 'Meetup Co-organizer names'.
    600600         */
    601601        public function render_co_organizers_list( $key ) {
     
    605605            }
    606606            $organizers = get_post_meta( $post_id, $key, true );
    607             if ( isset ( $organizers ) && is_array( $organizers ) ) {
     607            if ( isset( $organizers ) && is_array( $organizers ) ) {
    608608                $group_slug = get_post_meta( $post_id, 'Meetup URL', true );
    609                 if ( empty ( $group_slug ) ) {
     609                if ( empty( $group_slug ) ) {
    610610                    echo 'Invalid Meetup Group URL';
    611611                    return;
     
    625625                echo '</ul>';
    626626            } else {
    627                 echo __( 'No meetup organizers set.', 'wordcamp.org' );
     627                esc_html_e( 'No meetup organizers set.', 'wordcamp.org' );
    628628            }
    629629        }
     
    742742         */
    743743        public static function meetup_api_sync() {
    744             $query = new WP_Query( array(
    745                 'post_type'   => self::get_event_type(),
    746                 'post_status' => 'wcpt-mtp-active',
    747                 'fields'      => 'ids',
    748                 'posts_per_page' => -1,
    749             ) );
     744            $query = new WP_Query(
     745                array(
     746                    'post_type'      => self::get_event_type(),
     747                    'post_status'    => 'wcpt-mtp-active',
     748                    'fields'         => 'ids',
     749                    'posts_per_page' => - 1,
     750                )
     751            );
    750752
    751753            $new_meetup_org_data = array();
     
    769771                }
    770772
    771                 if ( empty ( $new_ids ) ) {
     773                if ( empty( $new_ids ) ) {
    772774                    continue;
    773775                }
     
    802804            $count = 0;
    803805            foreach ( $new_meetup_org_data as $post_id => $new_meetup_org ) {
    804                 $count += 1;
     806                $count ++;
    805807                $title = get_the_title( $post_id );
    806808                $meetup_tracker_url = get_site_url() . "/wp-admin/post.php?post=$post_id&action=edit";
     
    813815                    $meetup_members[] = "<a href='$meetup_group_url/members/$organizer_id' target='_blank' rel='noreferrer' >$organizer_name</a>";
    814816                }
    815                 $template = $template . join( ', ', $meetup_members ) . "<br>";
    816 
    817                 // Add a tag for meetup
     817                $template = $template . join( ', ', $meetup_members ) . '<br>';
     818
     819                // Add a tag for meetup.
    818820                wp_set_object_terms( $post_id, 'Needs to update Organizer list', 'meetup_tags', true );
    819821            }
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-application.php

    r8083 r8085  
    8181     * Enqueue scripts and stylesheets.
    8282     */
    83     function enqueue_assets() {
     83    public function enqueue_assets() {
    8484        global $post;
    8585
     
    162162     */
    163163    public function get_default_application_values() {
    164         // WordCamp uses an ID with questions. Not sure how are they used. Ask @corey
     164        // WordCamp uses an ID with questions. Not sure how are they used. Ask @corey.
    165165        $values = array(
    166166            'q_name'                => '',
     
    232232        add_post_meta( $post_id, 'Meetup Location', $data['q_mtp_loc'] );
    233233        add_post_meta(
    234             $post_id, '_status_change', array(
     234            $post_id,
     235            '_status_change',
     236            array(
    235237                'timestamp' => time(),
    236238                'user_id'   => $wordcamp_user_id,
     
    279281     */
    280282    public static function get_application_report_url() {
    281         return "https://central.wordcamp.org/reports/meetup-applications/";
     283        return 'https://central.wordcamp.org/reports/meetup-applications/';
    282284    }
    283285
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/meetup.php

    r8083 r8085  
    66use WordPress_Community\Applications\Meetup_Application;
    77
    8 defined( 'WPINC' ) or die();
     8defined( 'WPINC' ) || die();
    99
    1010/*
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/class-wordcamp-application.php

    r8083 r8085  
    1414    const SHORTCODE_SLUG = 'wordcamp-organizer-application';
    1515
    16     static function get_event_label() {
     16    /**
     17     * Return publicly displayed name of the event
     18     *
     19     * @return string
     20     */
     21    public static function get_event_label() {
    1722        return __( 'WordCamp', 'wordcamporg' );
    1823    }
     
    2328     * @return string
    2429     */
    25     static function get_event_type() {
     30    public static function get_event_type() {
    2631        return WCPT_POST_TYPE_ID;
    2732    }
     
    3035     * Enqueue scripts and stylesheets
    3136     */
    32     function enqueue_assets() {
     37    public function enqueue_assets() {
    3338        global $post;
    3439
     
    5358     * @return null|void
    5459     */
    55     function render_application_form( $countries ) {
     60    public function render_application_form( $countries ) {
    5661        render_wordcamp_application_form( $countries );
    5762    }
     
    6469     * @return array|\WP_Error
    6570     */
    66     function validate_data( $unsafe_data ) {
     71    public function validate_data( $unsafe_data ) {
    6772        $safe_data   = array();
    6873        $unsafe_data = shortcode_atts( $this->get_default_application_values(), $unsafe_data );
     
    98103     * @return array
    99104     */
    100     function get_default_application_values() {
     105    public function get_default_application_values() {
    101106        $values = array(
    102             // Part 1
     107            // Part 1.
    103108            'q_1079074_first_name'                       => '',
    104109            'q_1079074_last_name'                        => '',
     
    118123            'q_1068223_hope_to_accomplish_other'         => '',
    119124
    120             // Part 2
     125            // Part 2.
    121126            'q_1045950_active_meetup'                    => '',
    122127            'q_1045953_role_in_meetup'                   => '',
     
    128133            'q_1079082_other_tech_events_success'        => '',
    129134
    130             // Part 3
     135            // Part 3.
    131136            'q_1079103_wordcamp_location'                => '',
    132137            'q_1046006_wordcamp_date'                    => '',
     
    149154            'q_1079098_anything_else'                    => '',
    150155
    151             // Bonus
     156            // Bonus.
    152157            'q_1079112_best_describes_you'               => '',
    153158            'q_1079112_best_describes_you_other'         => '',
     
    172177     */
    173178    public static function get_application_report_url() {
    174         return "https://central.wordcamp.org/reports/application-status/";
     179        return 'https://central.wordcamp.org/reports/application-status/';
    175180    }
    176181
     
    182187     * @return bool|\WP_Error
    183188     */
    184     function create_post( $data ) {
    185         // Create the post
     189    public function create_post( $data ) {
     190        // Create the post.
    186191        $user      = wcorg_get_user_by_canonical_names( $data['q_4236565_wporg_username'] );
    187192        $statues   = \WordCamp_Loader::get_post_statuses();
     
    192197            'post_title'  => 'WordCamp ' . $data['q_1079103_wordcamp_location'],
    193198            'post_status' => WCPT_DEFAULT_STATUS,
    194             'post_author' => is_a( $user, 'WP_User' ) ? $user->ID : 7694169, // Set `wordcamp` as author if supplied username is not valid
     199            'post_author' => is_a( $user, 'WP_User' ) ? $user->ID : 7694169, // Set `wordcamp` as author if supplied username is not valid.
    195200        );
    196201
     
    201206        }
    202207
    203         // Populate the meta fields
     208        // Populate the meta fields.
    204209        add_post_meta( $post_id, '_application_data', $data );
    205210        add_post_meta( $post_id, '_application_submitter_ip_address', $_SERVER['REMOTE_ADDR'] );
    206211
    207 
    208212        add_post_meta(
    209             $post_id, 'Organizer Name', sprintf(
     213            $post_id,
     214            'Organizer Name',
     215            sprintf(
    210216                '%s %s',
    211217                $data['q_1079074_first_name'],
     
    220226
    221227        add_post_meta(
    222             $post_id, 'Mailing Address', sprintf(
     228            $post_id,
     229            'Mailing Address',
     230            sprintf(
    223231                "%s\n%s%s%s %s\n%s",
    224232                $data['q_1079060_add1'],
     
    232240
    233241        add_post_meta(
    234             $post_id, '_status_change', array(
     242            $post_id,
     243            '_status_change',
     244            array(
    235245                'timestamp' => time(),
    236246                'user_id'   => is_a( $user, 'WP_User' ) ? $user->ID : 0,
     
    248258     * @return null|string
    249259     */
    250     function get_organizer_email() {
     260    public function get_organizer_email() {
    251261        if ( isset( $this->post ) && isset( $this->post->ID ) ) {
    252262            return get_post_meta( $this->post->ID, 'Email Address', true );
     
    259269     * @return null|string
    260270     */
    261     function get_event_location() {
     271    public function get_event_location() {
    262272        if ( isset( $this->post ) && isset( $this->post->ID ) ) {
    263273            return get_post_meta( $this->post->ID, 'Location', true );
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php

    r8084 r8085  
    2323         * Initialize WCPT Admin
    2424         */
    25         function __construct() {
     25        public function __construct() {
    2626
    2727            parent::__construct();
    2828
    29             // Add some general styling to the admin area
     29            // Add some general styling to the admin area.
    3030            add_action( 'wcpt_admin_head', array( $this, 'admin_head' ) );
    3131
    32             // Scripts and CSS
     32            // Scripts and CSS.
    3333            add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
    3434
    35             // Post status transitions
     35            // Post status transitions.
    3636            add_action( 'transition_post_status', array( $this, 'trigger_schedule_actions' ), 10, 3 );
    3737            add_action( 'wcpt_approved_for_pre_planning', array( $this, 'add_organizer_to_central' ), 10 );
     
    4141
    4242            add_filter(
    43                 'wp_insert_post_data', array(
     43                'wp_insert_post_data',
     44                array(
    4445                    $this,
    4546                    'require_complete_meta_to_publish_wordcamp',
    46                 ), 11, 2
    47             ); // after enforce_post_status
    48 
    49             // Cron jobs
     47                ),
     48                11,
     49                2
     50            ); // after enforce_post_status.
     51
     52            // Cron jobs.
    5053            add_action( 'plugins_loaded', array( $this, 'schedule_cron_jobs' ), 11 );
    5154            add_action( 'wcpt_close_wordcamps_after_event', array( $this, 'close_wordcamps_after_event' ) );
     
    5558
    5659        /**
    57          * metabox ()
    58          *
    5960         * Add the metabox
    6061         *
    6162         * @uses add_meta_box
    6263         */
    63         function metabox() {
     64        public function metabox() {
    6465            add_meta_box(
    6566                'wcpt_information',
     
    104105         * @return string
    105106         */
    106         static function get_event_label() {
     107        public static function get_event_label() {
    107108            return WordCamp_Application::get_event_label();
    108109        }
     
    113114         * @return string
    114115         */
    115         static function get_event_type() {
     116        public static function get_event_type() {
    116117            return WordCamp_Application::get_event_type();
    117118        }
     
    120121         * Check if a field is readonly.
    121122         *
    122          * @param $key
     123         * @param string $key
    123124         *
    124125         * @return bool
    125126         */
    126         function _is_protected_field( $key ) {
     127        public function _is_protected_field( $key ) {
    127128            return self::is_protected_field( $key );
    128129        }
    129130
     131        /**
     132         * Update mentor username.
     133         *
     134         * @param int $post_id
     135         */
    130136        public function update_mentor( $post_id ) {
    131137            if ( $this->get_event_type() !== get_post_type() ) {
     
    133139            }
    134140
    135             // If the Mentor username changed, update the site
     141            // If the Mentor username changed, update the site.
     142            //phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified in `metabox_save` in class-event-admin.php.
    136143            $mentor_username = $_POST[ wcpt_key_to_str( 'Mentor WordPress.org User Name', 'wcpt_' ) ];
    137             if ( $mentor_username !== get_post_meta( $post_id, 'Mentor WordPress.org User Name', true ) ) {
     144            if ( get_post_meta( $post_id, 'Mentor WordPress.org User Name', true ) !== $mentor_username ) {
    138145                $this->add_mentor( get_post( $post_id ), $mentor_username );
    139146            }
     
    146153         * These are used for the maps on Central, stats, etc.
    147154         *
    148          * @param int   $post_id              Post id
    149          * @param array $original_meta_values Original meta values before save
     155         * @param int   $post_id              Post id.
     156         * @param array $original_meta_values Original meta values before save.
    150157         */
    151158        public function update_venue_address( $post_id, $original_meta_values ) {
     
    154161            }
    155162
    156             // If the venue address was changed, update its coordinates
     163            // If the venue address was changed, update its coordinates.
     164            //phpcs:ignore WordPress.Security.NonceVerification.Missing -- Nonce verified in `metabox_save` in class-event-admin.php.
    157165            $new_address = $_POST[ wcpt_key_to_str( 'Physical Address', 'wcpt_' ) ];
    158166            if ( $new_address === $original_meta_values['Physical Address'][0] ) {
     
    160168            }
    161169
    162             $request_url = add_query_arg( array(
    163                 'address' => rawurlencode( $new_address ),
    164             ), 'https://maps.googleapis.com/maps/api/geocode/json' );
     170            $request_url = add_query_arg(
     171                array(
     172                    'address' => rawurlencode( $new_address ),
     173                ),
     174                'https://maps.googleapis.com/maps/api/geocode/json'
     175            );
    165176
    166177            $key = apply_filters( 'wordcamp_google_maps_api_key', '', 'server' );
    167178
    168179            if ( $key ) {
    169                 $request_url = add_query_arg( array(
    170                     'key' => $key,
    171                 ), $request_url );
     180                $request_url = add_query_arg(
     181                    array( 'key' => $key ),
     182                    $request_url
     183                );
    172184            }
    173185
     
    175187            $body     = json_decode( wp_remote_retrieve_body( $response ) );
    176188
    177             // Don't delete the existing (and probably good) values if the request failed
     189            // Don't delete the existing (and probably good) values if the request failed.
    178190            if ( is_wp_error( $response ) || empty( $body->results[0]->address_components ) ) {
    179191                Logger\log( 'geocoding_failure', compact( 'request_url', 'response' ) );
     
    198210         * @see https://developers.google.com/maps/documentation/geocoding/intro#Types API response schema
    199211         *
    200          * @param $response
     212         * @param array $response
    201213         *
    202214         * @return array
     
    225237
    226238                            case 'country':
    227                                 $country_code = $component->short_name; // This is not guaranteed to be ISO 3166-1 alpha-2, but should match in most cases
     239                                $country_code = $component->short_name; // This is not guaranteed to be ISO 3166-1 alpha-2, but should match in most cases.
    228240                                $country_name = $component->long_name;
    229241                                break;
     
    272284         * @return array
    273285         */
    274         static function meta_keys( $meta_group = '' ) {
     286        public static function meta_keys( $meta_group = '' ) {
    275287            /*
    276288             * Warning: These keys are used for both the input field label and the postmeta key, so if you want to
     
    289301                        'Organizer Name'                   => 'text',
    290302                        'WordPress.org Username'           => 'text',
    291                         'Email Address'                    => 'text', // Note: This is the lead organizer's e-mail address, which is different than the "E-mail Address" field
     303                        'Email Address'                    => 'text', // Note: This is the lead organizer's e-mail address, which is different than the "E-mail Address" field.
    292304                        'Telephone'                        => 'text',
    293305                        'Mailing Address'                  => 'textarea',
     
    342354
    343355                case 'contributor':
    344                     // These fields names need to be unique, hence the 'Contributor' prefix on each one
     356                    // These fields names need to be unique, hence the 'Contributor' prefix on each one.
    345357                    $retval = array(
    346358                        'Contributor Day'                => 'checkbox',
     
    361373                        'URL'                             => 'wc-url',
    362374                        'E-mail Address'                  => 'text',
    363                         // Note: This is the address for the entire organizing team, which is different than the "Email Address" field
     375                        // Note: This is the address for the entire organizing team, which is different than the "Email Address" field.
    364376                        'Twitter'                         => 'text',
    365377                        'WordCamp Hashtag'                => 'text',
     
    457469         * @return array
    458470         */
    459         static function get_venue_address_meta_keys() {
     471        public static function get_venue_address_meta_keys() {
    460472            return array(
    461473                '_venue_coordinates',
     
    472484         * Adds jQuery UI
    473485         */
    474         function admin_scripts() {
    475 
    476             // Edit WordCamp screen
     486        public function admin_scripts() {
     487
     488            // Edit WordCamp screen.
    477489            if ( WCPT_POST_TYPE_ID === get_post_type() ) {
    478490
    479                 // Default data
     491                // Default data.
    480492                $data = array(
    481493                    'Mentors' => array(
     
    487499                );
    488500
    489                 // Only include mentor data if the Mentor username field is editable
     501                // Only include mentor data if the Mentor username field is editable.
    490502                if ( current_user_can( 'wordcamp_manage_mentors' ) ) {
    491503                    $data['Mentors']['data'] = Mentors_Dashboard\get_all_mentor_data();
     
    501513
    502514        /**
    503          * admin_head ()
    504          *
    505515         * Add some general styling to the admin area
    506516         */
    507         function admin_head() {
    508             if ( ! empty( $_GET['post_type'] ) && $_GET['post_type'] == WCPT_POST_TYPE_ID ) : ?>
     517        public function admin_head() {
     518            if ( ! empty( $_GET['post_type'] ) && WCPT_POST_TYPE_ID == $_GET['post_type'] ) : ?>
    509519
    510520            .column-title { width: 40%; }
     
    516526
    517527        /**
    518          * user_profile_update ()
    519          *
    520528         * Responsible for showing additional profile options and settings
    521529         *
    522530         * @todo Everything
    523531         */
    524         function user_profile_update( $user_id ) {
     532        public function user_profile_update( $user_id ) {
    525533            if ( ! wcpt_has_access() ) {
    526534                return false;
     
    529537
    530538        /**
    531          * user_profile_wordcamp ()
    532          *
    533539         * Responsible for saving additional profile options and settings
    534540         *
    535541         * @todo Everything
    536542         */
    537         function user_profile_wordcamp( $profileuser ) {
     543        public function user_profile_wordcamp( $profileuser ) {
    538544            if ( ! wcpt_has_access() ) {
    539545                return false;
     
    541547            ?>
    542548
    543         <h3><?php _e( 'WordCamps', 'wcpt' ); ?></h3>
     549        <h3><?php esc_html_e( 'WordCamps', 'wcpt' ); ?></h3>
    544550
    545551        <table class="form-table">
    546552            <tr valign="top">
    547                 <th scope="row"><?php _e( 'WordCamps', 'wcpt' ); ?></th>
     553                <th scope="row"><?php esc_html_e( 'WordCamps', 'wcpt' ); ?></th>
    548554
    549555                <td>
     
    556562
    557563        /**
    558          * column_headers ()
    559          *
    560564         * Manage the column headers
    561565         *
    562566         * @param array $columns
     567         *
    563568         * @return array $columns
    564569         */
    565         function column_headers( $columns ) {
     570        public function column_headers( $columns ) {
    566571            $columns = array(
    567572                'cb'             => '<input type="checkbox" />',
     
    577582
    578583        /**
    579          * column_data ( $column, $post_id )
    580          *
    581584         * Print extra columns
    582585         *
     
    584587         * @param int    $post_id
    585588         */
    586         function column_data( $column, $post_id ) {
    587             if ( $_GET['post_type'] !== WCPT_POST_TYPE_ID ) {
     589        public function column_data( $column, $post_id ) {
     590            if ( WCPT_POST_TYPE_ID !== $_GET['post_type'] ) {
    588591                return $column;
    589592            }
     
    591594            switch ( $column ) {
    592595                case 'wcpt_location':
    593                     echo wcpt_get_wordcamp_location() ? wcpt_get_wordcamp_location() : __( 'No Location', 'wcpt' );
     596                    echo esc_html( wcpt_get_wordcamp_location() ? wcpt_get_wordcamp_location() : __( 'No Location', 'wcpt' ) );
    594597                    break;
    595598
    596599                case 'wcpt_date':
    597                     // Has a start date
    598                     if ( $start = wcpt_get_wordcamp_start_date() ) {
    599 
    600                         // Has an end date
    601                         if ( $end = wcpt_get_wordcamp_end_date() ) {
     600                    // Has a start date.
     601                    $start = wcpt_get_wordcamp_start_date();
     602                    if ( $start ) {
     603
     604                        // Has an end date.
     605                        $end = wcpt_get_wordcamp_end_date();
     606                        if ( $end ) {
    602607                            $string_date = sprintf( __( 'Start: %1$s<br />End: %2$s', 'wcpt' ), $start, $end );
    603608
    604                             // No end date
     609                            // No end date.
    605610                        } else {
    606611                            $string_date = sprintf( __( 'Start: %1$s', 'wcpt' ), $start );
    607612                        }
    608613
    609                         // No date
     614                        // No date.
    610615                    } else {
    611616                        $string_date = __( 'No Date', 'wcpt' );
    612617                    }
    613618
    614                     echo $string_date;
     619                    echo wp_kses( $string_date, array( 'br' => array() ) );
    615620                    break;
    616621
    617622                case 'wcpt_organizer':
    618                     echo wcpt_get_wordcamp_organizer_name() ? wcpt_get_wordcamp_organizer_name() : __( 'No Organizer', 'wcpt' );
     623                    echo esc_html( wcpt_get_wordcamp_organizer_name() ? wcpt_get_wordcamp_organizer_name() : __( 'No Organizer', 'wcpt' ) );
    619624                    break;
    620625
    621626                case 'wcpt_venue':
    622                     echo wcpt_get_wordcamp_venue_name() ? wcpt_get_wordcamp_venue_name() : __( 'No Venue', 'wcpt' );
     627                    echo esc_html( wcpt_get_wordcamp_venue_name() ? wcpt_get_wordcamp_venue_name() : __( 'No Venue', 'wcpt' ) );
    623628                    break;
    624629            }
     
    626631
    627632        /**
    628          * post_row_actions ( $actions, $post )
    629          *
    630633         * Remove the quick-edit action link and display the description under
    631634         *
     
    634637         * @return array $actions
    635638         */
    636         function post_row_actions( $actions, $post ) {
     639        public function post_row_actions( $actions, $post ) {
    637640            if ( WCPT_POST_TYPE_ID == $post->post_type ) {
    638641                unset( $actions['inline hide-if-no-js'] );
     
    640643                $wc = array();
    641644
    642                 if ( $wc_location = wcpt_get_wordcamp_location() ) {
     645                $wc_location = wcpt_get_wordcamp_location();
     646                if ( $wc_location ) {
    643647                    $wc['location'] = $wc_location;
    644648                }
    645649
    646                 if ( $wc_url = make_clickable( wcpt_get_wordcamp_url() ) ) {
     650                $wc_url = make_clickable( wcpt_get_wordcamp_url() );
     651                if ( $wc_url ) {
    647652                    $wc['url'] = $wc_url;
    648653                }
    649654
    650                 echo implode( ' - ', (array) $wc );
     655                echo wp_kses( implode( ' - ', (array) $wc ), wp_kses_allowed_html() );
    651656            }
    652657
     
    672677            if ( 'wcpt-pre-planning' == $new_status ) {
    673678                do_action( 'wcpt_approved_for_pre_planning', $post );
    674             } elseif ( $old_status == 'wcpt-needs-schedule' && $new_status == 'wcpt-scheduled' ) {
     679            } elseif ( 'wcpt-needs-schedule' == $old_status && 'wcpt-scheduled' == $new_status ) {
    675680                do_action( 'wcpt_added_to_final_schedule', $post );
    676681            }
     
    689694         */
    690695        public function add_organizer_to_central( $post ) {
     696
     697            // phpcs:ignore WordPress.Security.NonceVerification.Missing -- WordCamp status can be moved to pre-planning status only from the admin edit screen where nonce is already verified.
    691698            $lead_organizer = get_user_by( 'login', $_POST['wcpt_wordpress_org_username'] );
    692699
     
    767774         */
    768775        public function enforce_post_status( $post_data, $post_data_raw ) {
    769             if ( $post_data['post_type'] != WCPT_POST_TYPE_ID || empty( $_POST['post_ID'] ) ) {
     776            if ( WCPT_POST_TYPE_ID != $post_data['post_type'] || empty( $post_data_raw['ID'] ) ) {
    770777                return $post_data;
    771778            }
    772779
    773             $post = get_post( $_POST['post_ID'] );
     780            $post = get_post( $post_data_raw['post_ID'] );
    774781            if ( ! $post ) {
    775782                return $post_data;
     
    814821            $required_scheduled_fields  = $this->get_required_fields( 'scheduled' );
    815822
    816             // Check pending posts
    817             if ( 'wcpt-needs-site' == $post_data['post_status'] && absint( $_POST['post_ID'] ) > $min_site_id ) {
     823            // Check pending posts.
     824            if ( 'wcpt-needs-site' == $post_data['post_status'] && absint( $post_data_raw['ID'] ) > $min_site_id ) {
    818825                foreach ( $required_needs_site_fields as $field ) {
     826
     827                    // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce check would have done in `metabox_save`.
    819828                    $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ];
    820829
     
    827836            }
    828837
    829             // Check published posts
    830             if ( 'wcpt-scheduled' == $post_data['post_status'] && isset( $_POST['post_ID'] ) && absint( $_POST['post_ID'] ) > $min_site_id ) {
     838            // Check published posts.
     839            if ( 'wcpt-scheduled' == $post_data['post_status'] && isset( $post_data_raw['ID'] ) && absint( $post_data_raw['ID'] ) > $min_site_id ) {
    831840                foreach ( $required_scheduled_fields as $field ) {
     841                    // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce check would have done in `metabox_save`.
    832842                    $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ];
    833843
     
    846856         * Get a list of fields required to move to a certain post status
    847857         *
    848          * @param string $status 'needs-site' | 'scheduled' | 'any'
     858         * @param string $status 'needs-site' | 'scheduled' | 'any'.
    849859         *
    850860         * @return array
     
    854864
    855865            $scheduled = array(
    856                 // WordCamp
     866                // WordCamp.
    857867                'Start Date (YYYY-mm-dd)',
    858868                'Location',
     
    862872                'Multi-Event Sponsor Region',
    863873
    864                 // Organizing Team
     874                // Organizing Team.
    865875                'Organizer Name',
    866876                'WordPress.org Username',
     
    873883                'Budget Wrangler E-mail Address',
    874884
    875                 // Venue
    876                 'Physical Address', // used to build stats
     885                // Venue.
     886                'Physical Address', // used to build stats.
    877887            );
    878888
     
    895905        }
    896906
     907        /**
     908         * TODO: Add description.
     909         *
     910         * @return array
     911         */
    897912        public static function get_protected_fields() {
    898913            $protected_fields = array();
     
    900915            if ( ! current_user_can( 'wordcamp_manage_mentors' ) ) {
    901916                $protected_fields = array_merge(
    902                     $protected_fields, array(
     917                    $protected_fields,
     918                    array(
    903919                        'Mentor WordPress.org User Name',
    904920                        'Mentor Name',
     
    910926            if ( ! current_user_can( 'wordcamp_wrangle_wordcamps' ) ) {
    911927                $protected_fields = array_merge(
    912                     $protected_fields, array(
     928                    $protected_fields,
     929                    array(
    913930                        'Multi-Event Sponsor Region',
    914931                    )
     
    941958
    942959            $screen = get_current_screen();
    943 
    944960
    945961            if ( empty( $post->post_type ) || $this->get_event_type() != $post->post_type || 'post' !== $screen->base ) {
     
    10561072        }
    10571073    }
    1058 endif; // class_exists check
     1074endif; // class_exists check.
    10591075
    10601076/**
     
    10661082}
    10671083
     1084/**
     1085 * Displays organizer metabox
     1086 */
    10681087function wcpt_organizer_metabox() {
    10691088    $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'organizer' );
     
    10711090}
    10721091
     1092/**
     1093 * Displays venue metabox
     1094 */
    10731095function wcpt_venue_metabox() {
    10741096    $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'venue' );
     
    10761098}
    10771099
     1100/**
     1101 * Displays contributor metabox
     1102 */
    10781103function wcpt_contributor_metabox() {
    10791104    $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'contributor' );
     
    10821107
    10831108/**
    1084  * wcpt_metabox ()
    1085  *
    10861109 * The metabox that holds all of the additional information
    10871110 *
     
    10951118    $required_fields = WordCamp_Admin::get_required_fields( 'any' );
    10961119
    1097     // @todo When you refactor meta_keys() to support changing labels -- see note in meta_keys() -- also make it support these notes
     1120    // @todo When you refactor meta_keys() to support changing labels -- see note in meta_keys() -- also make it support these notes.
    10981121    $messages = array(
    10991122        'Telephone'                       => 'Required for shipping.',
    11001123        'Mailing Address'                 => 'Shipping address.',
    1101         'Physical Address'                => 'Please include the city, state/province and country.', // So it can be geocoded correctly for the map
     1124        'Physical Address'                => 'Please include the city, state/province and country.', // So it can be geocoded correctly for the map.
    11021125        'Global Sponsorship Grant Amount' => 'No commas, thousands separators or currency symbols. Ex. 1234.56',
    11031126        'Global Sponsorship Grant'        => 'Deprecated.',
Note: See TracChangeset for help on using the changeset viewer.