Making WordPress.org


Ignore:
Timestamp:
11/29/2018 03:19:31 AM (8 years ago)
Author:
iandunn
Message:

CampTix Badge Generator: Apply coding standards.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/indesign-badges.php

    r7913 r7915  
    22
    33namespace CampTix\Badge_Generator\InDesign;
    4 use \CampTix\Badge_Generator;
    5 use \CampTix\Badge_Generator\HTML;
    6 use \WordCamp\Logger;
     4use Exception;
     5use CampTix_Plugin;
     6use CampTix\Badge_Generator;
     7use CampTix\Badge_Generator\HTML;
     8use WordCamp\Logger;
    79use WordCamp\Utilities;
    810
    9 defined( 'WPINC' ) or die();
     11defined( 'WPINC' ) || die();
    1012
    1113add_action( 'camptix_menu_tools_indesign_badges', __NAMESPACE__ . '\render_indesign_page' );
     
    2830 *
    2931 * @param array $options
     32 *
     33 * @throws Exception
    3034 */
    3135function build_assets( $options ) {
     
    5357                create_zip_file( $zip_filename, $zip_local_folder, $csv_filename, $gravatar_folder );
    5458        } finally {
    55                 // todo Delete contents of $assets_folder, then rmdir( $assets_folder );
     59                // todo Delete contents of $assets_folder, then rmdir( $assets_folder );.
    5660        }
    5761}
     
    6569 * @param string $gravatar_folder
    6670 *
    67  * @throws \Exception
     71 * @throws Exception
    6872 */
    6973function download_gravatars( $attendees, $gravatar_folder ) {
     
    8791                if ( ! $gravatar_file ) {
    8892                        Logger\log( 'gravatar_open_failed', compact( 'attendee', 'gravatar_folder', 'filename' ) );
    89                         throw new \Exception( __( "Couldn't save all Gravatars.", 'wordcamporg' ) );
     93                        throw new Exception( __( "Couldn't save all Gravatars.", 'wordcamporg' ) );
    9094                }
    9195
     
    112116 * @todo Update this to use wcorg_redundant_remote_get() instead, for DRYness
    113117 *
    114  * @throws \Exception when the HTTP request fails
     118 * @throws Exception when the HTTP request fails
    115119 */
    116120function download_single_gravatar( $request_url ) {
     
    124128                $retry_after = min( $retry_after * $attempt_count, 30 );
    125129
    126                 // A 404 is expected when the attendee doesn't have a Gravatar setup, so don't retry them
     130                // A 404 is expected when the attendee doesn't have a Gravatar setup, so don't retry them.
    127131                if ( 404 == $status_code ) {
    128132                        return false;
     
    134138
    135139                if ( is_array( $response ) && isset( $response['body'] ) ) {
    136                         $response['body'] = '[redacted]'; // Avoid cluttering the logs with a ton of binary data
     140                        $response['body'] = '[redacted]'; // Avoid cluttering the logs with a ton of binary data.
    137141                }
    138142
     
    142146                } else {
    143147                        Logger\log( 'request_failed_permenantly', compact( 'request_url', 'response' ) );
    144                         throw new \Exception( __( "Couldn't download all Gravatars.", 'wordcamporg' ) );
     148                        throw new Exception( __( "Couldn't download all Gravatars.", 'wordcamporg' ) );
    145149                }
    146150
     
    170174 * Get the filename for the Zip file
    171175 *
    172  * @param $assets_folder
     176 * @param string $assets_folder
    173177 *
    174178 * @return string
     
    197201 * @param string $gravatar_folder
    198202 *
    199  * @throws \Exception
     203 * @throws Exception
    200204 */
    201205function generate_csv( $csv_filename, $zip_local_folder, $attendees, $gravatar_folder ) {
    202         /** @var \CampTix_Plugin $camptix */
     206        /** @var CampTix_Plugin $camptix */
    203207        global $camptix;
    204208
     
    211215        if ( ! $csv_handle ) {
    212216                Logger\log( 'open_csv_failed' );
    213                 throw new \Exception( __( "Couldn't open CSV file.", 'wordcamporg' ) );
     217                throw new Exception( __( "Couldn't open CSV file.", 'wordcamporg' ) );
    214218        }
    215219
     
    235239 */
    236240function get_admin_flags() {
    237         /** @var \CampTix_Plugin $camptix */
     241        /** @var CampTix_Plugin $camptix */
    238242        global $camptix;
    239243
     
    280284        $row = array();
    281285
    282         if ( 'unknown.attendee@example.org' == $attendee->tix_email ) {
     286        if ( 'unknown.attendee@example.org' === $attendee->tix_email ) {
    283287                return $row;
    284288        }
     
    327331 */
    328332function get_twitter_username( $attendee ) {
    329         /** @global \CampTix_Plugin $camptix */
     333        /** @global CampTix_Plugin $camptix */
    330334        global $camptix;
    331335
     
    353357 * @param string $username
    354358 * @param string $first_name
    355  * @param string $empty_mode 'replace' to replace empty usernames with first names
     359 * @param string $empty_mode 'replace' to replace empty usernames with first names.
    356360 *
    357361 * @return string
    358362 */
    359363function format_twitter_username( $username, $first_name, $empty_mode = '' ) {
    360         if ( empty ( $username ) ) {
     364        if ( empty( $username ) ) {
    361365                if ( 'replace' === $empty_mode ) {
    362366                        $username = $first_name;
    363367                }
    364368        } else {
    365                 // Strip out everything but the username, and prefix a @
     369                // Strip out everything but the username, and prefix a `@` character.
    366370                $username = '@' . preg_replace(
    367371                        '/
     
    408412 * @param string $gravatar_folder
    409413 *
    410  * @throws \Exception
     414 * @throws Exception
    411415 */
    412416function create_zip_file( $zip_filename, $zip_local_folder, $csv_filename, $gravatar_folder ) {
    413417        if ( ! class_exists( 'ZipArchive') ) {
    414418                Logger\log( 'zip_ext_not_installed' );
    415                 throw new \Exception( __( 'The Zip extension for PHP is not installed.', 'wordcamporg' ) );
     419                throw new Exception( __( 'The Zip extension for PHP is not installed.', 'wordcamporg' ) );
    416420        }
    417421
     
    421425        if ( true !== $open_status ) {
    422426                Logger\log( 'zip_open_failed', compact( 'zip_filename', 'open_status' ) );
    423                 throw new \Exception( __( 'The Zip file could not be created.', 'wordcamporg' ) );
     427                throw new Exception( __( 'The Zip file could not be created.', 'wordcamporg' ) );
    424428        }
    425429
     
    453457 * @param string $filename
    454458 *
    455  * @throws \Exception
     459 * @throws Exception
    456460 */
    457461function serve_zip_file( $filename ) {
    458462        if ( ! current_user_can( Badge_Generator\REQUIRED_CAPABILITY ) ) {
    459463                Logger\log( 'access_denied' );
    460                 throw new \Exception( __( "You don't have authorization to perform this action.", 'wordcamporg' ) );
     464                throw new Exception( __( "You don't have authorization to perform this action.", 'wordcamporg' ) );
    461465        }
    462466
Note: See TracChangeset for help on using the changeset viewer.