Changeset 7915
- Timestamp:
- 11/29/2018 03:19:31 AM (6 years ago)
- 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 11 11 12 12 namespace CampTix\Badge_Generator; 13 defined( 'WPINC' ) ordie();13 defined( 'WPINC' ) || die(); 14 14 15 15 const REQUIRED_CAPABILITY = 'manage_options'; -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/common.php
r7914 r7915 2 2 3 3 namespace CampTix\Badge_Generator; 4 use \CampTix\Badge_Generator\HTML; 5 6 defined( 'WPINC' ) or die(); 4 use CampTix_Plugin; 5 use CampTix\Badge_Generator\HTML; 6 7 defined( 'WPINC' ) || die(); 7 8 8 9 if ( is_admin() ) { … … 66 67 * Get the attendees 67 68 * 68 * @param string|array $ticket_ids Reducefetched 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' 69 70 * will result in all attendees being fetched, regardless of their 70 71 * ticket. An array of ticket IDs will result in only the attendees for 71 72 * those tickets being fetched. 72 * @param string $registered_after Reducefetched attendees by their registration date. Any value parseable73 * @param string $registered_after Filter fetched attendees by their registration date. Any value parseable 73 74 * by strtotime(). 74 75 * @param string $admin_flag Filter fetched attendees to only those who have the given admin flag … … 133 134 */ 134 135 function add_dynamic_post_meta( $value, $post_id, $meta_key ) { 135 /** @global \CampTix_Plugin $camptix */136 /** @global CampTix_Plugin $camptix */ 136 137 global $camptix; 137 138 … … 142 143 } 143 144 144 if ( 'tix_attendee' != $attendee->post_type ) {145 if ( 'tix_attendee' !== $attendee->post_type ) { 145 146 return $value; 146 147 } … … 156 157 ) 157 158 ); 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. 159 160 break; 160 161 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/html-badges.php
r6768 r7915 6 6 7 7 namespace CampTix\Badge_Generator\HTML; 8 use \CampTix\Badge_Generator; 9 10 defined( 'WPINC' ) or die(); 8 use CampTix\Badge_Generator; 9 use CampTix_Plugin; 10 use WP_Customize_Manager; 11 12 defined( 'WPINC' ) || die(); 11 13 12 14 add_action( 'customize_register', __NAMESPACE__ . '\register_customizer_components' ); … … 14 16 add_action( 'admin_print_styles', __NAMESPACE__ . '\print_customizer_styles' ); 15 17 add_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() 18 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_previewer_scripts', 999 ); // after remove_all_previewer_styles(). 17 19 add_filter( 'template_include', __NAMESPACE__ . '\use_badges_template' ); 18 20 … … 20 22 * Register our Customizer settings, panels, sections, and controls 21 23 * 22 * @param \WP_Customize_Manager $wp_customize24 * @param WP_Customize_Manager $wp_customize 23 25 */ 24 26 function register_customizer_components( $wp_customize ) { … … 123 125 } 124 126 125 // Enqueue our scripts 127 // Enqueue our scripts. 126 128 wp_enqueue_script( 127 129 'camptix-html-badges-customizer', … … 168 170 */ 169 171 function is_badges_preview() { 170 /** @global \WP_Customize_Manager $wp_customize */172 /** @global WP_Customize_Manager $wp_customize */ 171 173 global $wp_customize; 172 174 … … 199 201 */ 200 202 function render_badges_template() { 201 /** @global \CampTix_Plugin $camptix */203 /** @global CampTix_Plugin $camptix */ 202 204 global $camptix; 203 205 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/indesign-badges.php
r7913 r7915 2 2 3 3 namespace CampTix\Badge_Generator\InDesign; 4 use \CampTix\Badge_Generator; 5 use \CampTix\Badge_Generator\HTML; 6 use \WordCamp\Logger; 4 use Exception; 5 use CampTix_Plugin; 6 use CampTix\Badge_Generator; 7 use CampTix\Badge_Generator\HTML; 8 use WordCamp\Logger; 7 9 use WordCamp\Utilities; 8 10 9 defined( 'WPINC' ) ordie();11 defined( 'WPINC' ) || die(); 10 12 11 13 add_action( 'camptix_menu_tools_indesign_badges', __NAMESPACE__ . '\render_indesign_page' ); … … 28 30 * 29 31 * @param array $options 32 * 33 * @throws Exception 30 34 */ 31 35 function build_assets( $options ) { … … 53 57 create_zip_file( $zip_filename, $zip_local_folder, $csv_filename, $gravatar_folder ); 54 58 } finally { 55 // todo Delete contents of $assets_folder, then rmdir( $assets_folder ); 59 // todo Delete contents of $assets_folder, then rmdir( $assets_folder );. 56 60 } 57 61 } … … 65 69 * @param string $gravatar_folder 66 70 * 67 * @throws \Exception71 * @throws Exception 68 72 */ 69 73 function download_gravatars( $attendees, $gravatar_folder ) { … … 87 91 if ( ! $gravatar_file ) { 88 92 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' ) ); 90 94 } 91 95 … … 112 116 * @todo Update this to use wcorg_redundant_remote_get() instead, for DRYness 113 117 * 114 * @throws \Exception when the HTTP request fails118 * @throws Exception when the HTTP request fails 115 119 */ 116 120 function download_single_gravatar( $request_url ) { … … 124 128 $retry_after = min( $retry_after * $attempt_count, 30 ); 125 129 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. 127 131 if ( 404 == $status_code ) { 128 132 return false; … … 134 138 135 139 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. 137 141 } 138 142 … … 142 146 } else { 143 147 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' ) ); 145 149 } 146 150 … … 170 174 * Get the filename for the Zip file 171 175 * 172 * @param $assets_folder176 * @param string $assets_folder 173 177 * 174 178 * @return string … … 197 201 * @param string $gravatar_folder 198 202 * 199 * @throws \Exception203 * @throws Exception 200 204 */ 201 205 function generate_csv( $csv_filename, $zip_local_folder, $attendees, $gravatar_folder ) { 202 /** @var \CampTix_Plugin $camptix */206 /** @var CampTix_Plugin $camptix */ 203 207 global $camptix; 204 208 … … 211 215 if ( ! $csv_handle ) { 212 216 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' ) ); 214 218 } 215 219 … … 235 239 */ 236 240 function get_admin_flags() { 237 /** @var \CampTix_Plugin $camptix */241 /** @var CampTix_Plugin $camptix */ 238 242 global $camptix; 239 243 … … 280 284 $row = array(); 281 285 282 if ( 'unknown.attendee@example.org' == $attendee->tix_email ) {286 if ( 'unknown.attendee@example.org' === $attendee->tix_email ) { 283 287 return $row; 284 288 } … … 327 331 */ 328 332 function get_twitter_username( $attendee ) { 329 /** @global \CampTix_Plugin $camptix */333 /** @global CampTix_Plugin $camptix */ 330 334 global $camptix; 331 335 … … 353 357 * @param string $username 354 358 * @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. 356 360 * 357 361 * @return string 358 362 */ 359 363 function format_twitter_username( $username, $first_name, $empty_mode = '' ) { 360 if ( empty 364 if ( empty( $username ) ) { 361 365 if ( 'replace' === $empty_mode ) { 362 366 $username = $first_name; 363 367 } 364 368 } else { 365 // Strip out everything but the username, and prefix a @369 // Strip out everything but the username, and prefix a `@` character. 366 370 $username = '@' . preg_replace( 367 371 '/ … … 408 412 * @param string $gravatar_folder 409 413 * 410 * @throws \Exception414 * @throws Exception 411 415 */ 412 416 function create_zip_file( $zip_filename, $zip_local_folder, $csv_filename, $gravatar_folder ) { 413 417 if ( ! class_exists( 'ZipArchive') ) { 414 418 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' ) ); 416 420 } 417 421 … … 421 425 if ( true !== $open_status ) { 422 426 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' ) ); 424 428 } 425 429 … … 453 457 * @param string $filename 454 458 * 455 * @throws \Exception459 * @throws Exception 456 460 */ 457 461 function serve_zip_file( $filename ) { 458 462 if ( ! current_user_can( Badge_Generator\REQUIRED_CAPABILITY ) ) { 459 463 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' ) ); 461 465 } 462 466 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/common/page-generate-badges.php
r5819 r7915 2 2 3 3 namespace CampTix\Badge_Generator; 4 defined( 'WPINC' ) or die(); 4 defined( 'WPINC' ) || die(); 5 6 /** 7 * @var string $html_customizer_url 8 * @var string $indesign_page_url 9 * @var string $notify_tool_url 10 */ 5 11 6 12 ?> 7 13 8 14 <p> 9 <?php _e(15 <?php esc_html_e( 10 16 '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:', 11 17 'wordcamporg' … … 15 21 <div id="cbg-method-overviews"> 16 22 <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> 18 26 19 27 <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> 23 31 </ul> 24 32 25 33 <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' ); ?> 27 35 </a> 28 36 </div> 29 37 30 38 <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> 32 42 33 43 <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> 36 46 <li> 37 47 <?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' ) ), 39 49 'https://www.adobe.com/products/indesign.html' 40 50 ); ?> … … 43 53 44 54 <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' ); ?> 46 56 </a> 47 57 </div> … … 50 60 <p> 51 61 <?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( __( 54 64 '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.', 55 65 'wordcamporg' 56 ) ,66 ) ), 57 67 'https://gravatar.com', 58 68 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 2 2 3 3 namespace CampTix\Badge_Generator\HTML; 4 defined( 'WPINC' ) ordie();4 defined( 'WPINC' ) || die(); 5 5 6 _e( 'Create personalized attendee badges with HTML and CSS. ', 'wordcamporg' );6 esc_html_e( 'Create personalized attendee badges with HTML and CSS. ', 'wordcamporg' ); 7 7 8 8 ?> 9 9 10 10 <div id="cbg-firefox-recommended" class="notice notice-warning notice-large hidden"> 11 <?php _e(11 <?php esc_html_e( 12 12 'We strongly recommend using Firefox, because other browsers have inconsistent support for CSS page breaks.', 13 13 'wordcamporg' -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/html-badges/template-badges.php
r6768 r7915 4 4 use WP_Post; 5 5 6 defined( 'WPINC' ) ordie();6 defined( 'WPINC' ) || die(); 7 7 8 8 /** … … 16 16 * function, so that we get a nice, clean, local scope. 17 17 */ 18 if ( isset( $template ) && __FILE__ == $template ) {18 if ( isset( $template ) && __FILE__ === $template ) { 19 19 render_badges_template(); 20 20 return; … … 25 25 26 26 <head> 27 <title><?php _e( 'CampTix HTML Badges', 'wordcamporg' ); ?></title>27 <title><?php esc_html_e( 'CampTix HTML Badges', 'wordcamporg' ); ?></title> 28 28 <meta charset="<?php bloginfo( 'charset' ); ?>"> 29 29 <?php wp_head(); ?> … … 35 35 if ( empty( $attendees ) ) : 36 36 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' ); 38 38 39 39 else : -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/html-badges/template-part-badge-contents.php
r6768 r7915 4 4 use WP_Post; 5 5 6 defined( 'WPINC' ) ordie();6 defined( 'WPINC' ) || die(); 7 7 8 8 /** -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/views/indesign-badges/page-indesign-badges.php
r6768 r7915 2 2 3 3 namespace CampTix\Badge_Generator\InDesign; 4 defined( 'WPINC' ) ordie();4 defined( 'WPINC' ) || die(); 5 5 6 6 /** … … 11 11 12 12 <h2> 13 <?php _e( 'InDesign Badges', 'wordcamporg' ); ?>13 <?php esc_html_e( 'InDesign Badges', 'wordcamporg' ); ?> 14 14 </h2> 15 15 16 16 <p> 17 <?php _e(17 <?php esc_html_e( 18 18 "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.", 19 19 'wordcamporg' … … 23 23 <p> 24 24 <?php printf( 25 __(25 wp_kses_post( __( 26 26 '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.', 27 27 'wordcamporg' 28 ) ,28 ) ), 29 29 'https://make.wordpress.org/community/handbook/wordcamp-organizer-handbook/first-steps/helpful-documents-and-templates/create-wordcamp-badges-with-gravatars/', 30 30 esc_url( $html_customizer_url ) … … 34 34 <p> 35 35 <?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' ) ), 37 37 'https://meta.trac.wordpress.org/ticket/262' 38 38 ); ?>
Note: See TracChangeset
for help on using the changeset viewer.