Making WordPress.org

Changeset 7915


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

CampTix Badge Generator: Apply coding standards.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator
Files:
9 edited

Legend:

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

    r4316 r7915  
    1111
    1212namespace CampTix\Badge_Generator;
    13 defined( 'WPINC' ) or die();
     13defined( 'WPINC' ) || die();
    1414
    1515const REQUIRED_CAPABILITY = 'manage_options';
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/common.php

    r7914 r7915  
    22
    33namespace CampTix\Badge_Generator;
    4 use \CampTix\Badge_Generator\HTML;
    5 
    6 defined( 'WPINC' ) or die();
     4use CampTix_Plugin;
     5use CampTix\Badge_Generator\HTML;
     6
     7defined( 'WPINC' ) || die();
    78
    89if ( is_admin() ) {
     
    6667 * Get the attendees
    6768 *
    68  * @param string|array $ticket_ids       Reduce fetched attendees by the ticket they purchased. The string 'all'
     69 * @param string|array $ticket_ids       Filter fetched attendees by the ticket they purchased. The string 'all'
    6970 *                                       will result in all attendees being fetched, regardless of their
    7071 *                                       ticket. An array of ticket IDs will result in only the attendees for
    7172 *                                       those tickets being fetched.
    72  * @param string       $registered_after Reduce fetched attendees by their registration date. Any value parseable
     73 * @param string       $registered_after Filter fetched attendees by their registration date. Any value parseable
    7374 *                                       by strtotime().
    7475 * @param string       $admin_flag       Filter fetched attendees to only those who have the given admin flag
     
    133134 */
    134135function add_dynamic_post_meta( $value, $post_id, $meta_key ) {
    135         /** @global \CampTix_Plugin $camptix */
     136        /** @global CampTix_Plugin $camptix */
    136137        global $camptix;
    137138
     
    142143        }
    143144
    144         if ( 'tix_attendee' != $attendee->post_type ) {
     145        if ( 'tix_attendee' !== $attendee->post_type ) {
    145146                return $value;
    146147        }
     
    156157                                )
    157158                        );
    158                         $value = str_replace( 'secure.gravatar.com', 'en.gravatar.com', $value );   // work around Varnish bug on secure.gravatar.com that causes `503` response codes
     159                        $value = str_replace( 'secure.gravatar.com', 'en.gravatar.com', $value );   // work around Varnish bug on secure.gravatar.com that causes `503` response codes.
    159160                        break;
    160161
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/html-badges.php

    r6768 r7915  
    66
    77namespace CampTix\Badge_Generator\HTML;
    8 use \CampTix\Badge_Generator;
    9 
    10 defined( 'WPINC' ) or die();
     8use CampTix\Badge_Generator;
     9use CampTix_Plugin;
     10use WP_Customize_Manager;
     11
     12defined( 'WPINC' ) || die();
    1113
    1214add_action( 'customize_register',    __NAMESPACE__ . '\register_customizer_components'   );
     
    1416add_action( 'admin_print_styles',    __NAMESPACE__ . '\print_customizer_styles'          );
    1517add_action( 'wp_enqueue_scripts',    __NAMESPACE__ . '\remove_all_previewer_styles', 998 );
    16 add_action( 'wp_enqueue_scripts',    __NAMESPACE__ . '\enqueue_previewer_scripts',   999 );  // after remove_all_previewer_styles()
     18add_action( 'wp_enqueue_scripts',    __NAMESPACE__ . '\enqueue_previewer_scripts',   999 );  // after remove_all_previewer_styles().
    1719add_filter( 'template_include',      __NAMESPACE__ . '\use_badges_template'              );
    1820
     
    2022 * Register our Customizer settings, panels, sections, and controls
    2123 *
    22  * @param \WP_Customize_Manager $wp_customize
     24 * @param WP_Customize_Manager $wp_customize
    2325 */
    2426function register_customizer_components( $wp_customize ) {
     
    123125        }
    124126
    125         // Enqueue our scripts
     127        // Enqueue our scripts.
    126128        wp_enqueue_script(
    127129                'camptix-html-badges-customizer',
     
    168170 */
    169171function is_badges_preview() {
    170         /** @global \WP_Customize_Manager $wp_customize */
     172        /** @global WP_Customize_Manager $wp_customize */
    171173        global $wp_customize;
    172174
     
    199201 */
    200202function render_badges_template() {
    201         /** @global \CampTix_Plugin $camptix */
     203        /** @global CampTix_Plugin $camptix */
    202204        global $camptix;
    203205
  • 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
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/common/page-generate-badges.php

    r5819 r7915  
    22
    33namespace CampTix\Badge_Generator;
    4 defined( 'WPINC' ) or die();
     4defined( 'WPINC' ) || die();
     5
     6/**
     7 * @var string $html_customizer_url
     8 * @var string $indesign_page_url
     9 * @var string $notify_tool_url
     10 */
    511
    612?>
    713
    814<p>
    9         <?php _e(
     15        <?php esc_html_e(
    1016                'This tool will help you create personalized badges for attendees to wear during the event. There are two methods for this, depending on your preferences:',
    1117                'wordcamporg'
     
    1521<div id="cbg-method-overviews">
    1622        <div id="html-badge-overview">
    17                 <h2><?php _e( 'HTML and CSS', 'wordcamporg' ); ?></h2>
     23                <h2>
     24                        <?php esc_html_e( 'HTML and CSS', 'wordcamporg' ); ?>
     25                </h2>
    1826
    1927                <ul class="ul-disc">
    20                         <li><?php _e( 'The Easiest method.',                                                                              'wordcamporg' ); ?></li>
    21                         <li><?php _e( 'Can be as simple as using the default design and printing at home.',                               'wordcamporg' ); ?></li>
    22                         <li><?php _e( 'Design is customizable by a designer or developer, but options are limited compared to InDesign.', 'wordcamporg' ); ?></li>
     28                        <li><?php esc_html_e( 'The Easiest method.',                                                                              'wordcamporg' ); ?></li>
     29                        <li><?php esc_html_e( 'Can be as simple as using the default design and printing at home.',                               'wordcamporg' ); ?></li>
     30                        <li><?php esc_html_e( 'Design is customizable by a designer or developer, but options are limited compared to InDesign.', 'wordcamporg' ); ?></li>
    2331                </ul>
    2432
    2533                <a class="button button-primary" href="<?php echo esc_url( $html_customizer_url ); ?>">
    26                         <?php _e( 'Create Badges with HTML and CSS', 'wordcamporg' ); ?>
     34                        <?php esc_html_e( 'Create Badges with HTML and CSS', 'wordcamporg' ); ?>
    2735                </a>
    2836        </div>
    2937
    3038        <div id="indesign-badges-overview" class="cbg-method-overview">
    31                 <h2><?php _e( 'InDesign', 'wordcamporg' ); ?></h2>
     39                <h2>
     40                        <?php esc_html_e( 'InDesign', 'wordcamporg' ); ?>
     41                </h2>
    3242
    3343                <ul class="ul-disc">
    34                         <li><?php _e( 'The best results, but requires more work.', 'wordcamporg' ); ?></li>
    35                         <li><?php _e( 'Most flexible design options.',             'wordcamporg' ); ?></li>
     44                        <li><?php esc_html_e( 'The best results, but requires more work.', 'wordcamporg' ); ?></li>
     45                        <li><?php esc_html_e( 'Most flexible design options.',             'wordcamporg' ); ?></li>
    3646                        <li>
    3747                                <?php printf(
    38                                         __( 'Requires a designer and a copy of InDesign. <a href="%s">Free trial copies are available</a>.', 'wordcamporg' ),
     48                                        wp_kses_post( __( 'Requires a designer and a copy of InDesign. <a href="%s">Free trial copies are available</a>.', 'wordcamporg' ) ),
    3949                                        'https://www.adobe.com/products/indesign.html'
    4050                                ); ?>
     
    4353
    4454                <a class="button button-primary" href="<?php echo esc_url( $indesign_page_url ); ?>">
    45                         <?php _e( 'Create Badges with InDesign', 'wordcamporg' ); ?>
     55                        <?php esc_html_e( 'Create Badges with InDesign', 'wordcamporg' ); ?>
    4656                </a>
    4757        </div>
     
    5060<p>
    5161        <?php printf(
    52                 // translators: 1: Gravatar.com URL, 2: Notify tool URL
    53                 __(
     62                // translators: 1: Gravatar.com URL, 2: Notify tool URL.
     63                wp_kses_post( __(
    5464                        'Regardless of which method you choose, you\'ll get the best results if you encourage attendees to create <a href="%1$s">Gravatar</a> accounts before you create the badges. You can use <a href="%2$s">the Notify tool</a> to e-mail everyone. Make sure to tell them to create their Gravatar account using the same e-mail address that provided when purchasing a ticket.',
    5565                        'wordcamporg'
    56                 ),
     66                ) ),
    5767                'https://gravatar.com',
    5868                esc_url( $notify_tool_url )
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/html-badges/section-description.php

    r3015 r7915  
    22
    33namespace CampTix\Badge_Generator\HTML;
    4 defined( 'WPINC' ) or die();
     4defined( 'WPINC' ) || die();
    55
    6 _e( 'Create personalized attendee badges with HTML and CSS. ', 'wordcamporg' );
     6esc_html_e( 'Create personalized attendee badges with HTML and CSS. ', 'wordcamporg' );
    77
    88?>
    99
    1010<div id="cbg-firefox-recommended" class="notice notice-warning notice-large hidden">
    11         <?php _e(
     11        <?php esc_html_e(
    1212                'We strongly recommend using Firefox, because other browsers have inconsistent support for CSS page breaks.',
    1313                'wordcamporg'
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/html-badges/template-badges.php

    r6768 r7915  
    44use WP_Post;
    55
    6 defined( 'WPINC' ) or die();
     6defined( 'WPINC' ) || die();
    77
    88/**
     
    1616 * function, so that we get a nice, clean, local scope.
    1717 */
    18 if ( isset( $template ) && __FILE__ == $template ) {
     18if ( isset( $template ) && __FILE__ === $template ) {
    1919        render_badges_template();
    2020        return;
     
    2525
    2626<head>
    27         <title><?php _e( 'CampTix HTML Badges', 'wordcamporg' ); ?></title>
     27        <title><?php esc_html_e( 'CampTix HTML Badges', 'wordcamporg' ); ?></title>
    2828        <meta charset="<?php bloginfo( 'charset' ); ?>">
    2929        <?php wp_head(); ?>
     
    3535        if ( empty( $attendees ) ) :
    3636
    37                 _e( 'No attendees were found. Please try again once tickets have been purchased.', 'wordcamporg' );
     37                esc_html_e( 'No attendees were found. Please try again once tickets have been purchased.', 'wordcamporg' );
    3838
    3939        else :
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/html-badges/template-part-badge-contents.php

    r6768 r7915  
    44use WP_Post;
    55
    6 defined( 'WPINC' ) or die();
     6defined( 'WPINC' ) || die();
    77
    88/**
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/indesign-badges/page-indesign-badges.php

    r6768 r7915  
    22
    33namespace CampTix\Badge_Generator\InDesign;
    4 defined( 'WPINC' ) or die();
     4defined( 'WPINC' ) || die();
    55
    66/**
     
    1111
    1212<h2>
    13         <?php _e( 'InDesign Badges', 'wordcamporg' ); ?>
     13        <?php esc_html_e( 'InDesign Badges', 'wordcamporg' ); ?>
    1414</h2>
    1515
    1616<p>
    17         <?php _e(
     17        <?php esc_html_e(
    1818                "The process for building InDesign badges hasn't been automated yet, so it requires a developer to run a script. That script will create a CSV file and will download Gravatar images for all attendees. Once that's done, a designer can take those files into InDesign and use the Data Merge feature to create personalized badges for each attendee.",
    1919                'wordcamporg'
     
    2323<p>
    2424        <?php printf(
    25                 __(
     25                wp_kses_post( __(
    2626                        'Full instructions are <a href="%1$s">available in the WordCamp Organizer Handbook</a>. If you\'d prefer an easier way, <a href="%2$s">the HTML/CSS method</a> is much more automated at this time.',
    2727                        'wordcamporg'
    28                 ),
     28                ) ),
    2929                'https://make.wordpress.org/community/handbook/wordcamp-organizer-handbook/first-steps/helpful-documents-and-templates/create-wordcamp-badges-with-gravatars/',
    3030                esc_url( $html_customizer_url )
     
    3434<p>
    3535        <?php printf(
    36                 __( 'If you\'d like to help automate the InDesign process, you can contribute to <a href="%s">Meta ticket #262</a>.', 'wordcamporg' ),
     36                wp_kses_post( __( 'If you\'d like to help automate the InDesign process, you can contribute to <a href="%s">Meta ticket #262</a>.', 'wordcamporg' ) ),
    3737                'https://meta.trac.wordpress.org/ticket/262'
    3838        ); ?>
Note: See TracChangeset for help on using the changeset viewer.