Changeset 8085
- Timestamp:
- 01/16/2019 03:36:24 PM (6 years ago)
- Location:
- sites/trunk/wordcamp.org
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/phpcs.xml.dist
r8072 r8085 155 155 <exclude name="Squiz.Commenting.ClassComment.WrongStyle" /> 156 156 <exclude name="Squiz.Commenting.ClassComment.SpacingAfter" /> 157 158 <!-- WordPress have translators comment which requires no space after `//` --> 159 <exclude name="Squiz.Commenting.InlineComment.NoSpaceBefore" /> 157 160 </rule> 158 161 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/views/applications/meetup/shortcode-application.php
r7885 r8085 2 2 3 3 namespace WordPress_Community\Applications\Meetup; 4 defined( 'WPINC' ) ordie();4 defined( 'WPINC' ) || die(); 5 5 6 6 /** -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/views/applications/wordcamp/shortcode-application.php
r7607 r8085 2 2 3 3 namespace WordPress_Community\Applications\WordCamp; 4 defined( 'WPINC' ) ordie();4 defined( 'WPINC' ) || die(); 5 5 6 6 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-admin.php
r8083 r8085 42 42 43 43 add_filter( 44 'manage_' . $this->get_event_type() . '_posts_columns', array( 44 'manage_' . $this->get_event_type() . '_posts_columns', 45 array( 45 46 $this, 46 47 'column_headers', … … 60 61 add_filter( 'redirect_post_location', array( $this, 'add_admin_notices_to_redirect_url' ), 10, 2 ); 61 62 62 // Admin notices 63 // Admin notices. 63 64 add_action( 'admin_notices', array( $this, 'print_admin_notices' ) ); 64 65 … … 269 270 270 271 $log_id = add_post_meta( 271 $post->ID, '_status_change', array( 272 $post->ID, 273 '_status_change', 274 array( 272 275 'timestamp' => time(), 273 276 'user_id' => get_current_user_id(), … … 275 278 ) 276 279 ); 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. 279 282 if ( $log_id ) { 280 283 add_post_meta( $post->ID, "_status_change_log_$post->post_type $log_id", time() ); … … 285 288 * 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. 286 289 * 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. 289 292 * @param WP_Post $event 290 293 */ … … 294 297 * Schedule notificaiton for declined application. Currently supports WordCamp and Meetup 295 298 * 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. 298 301 * @param string $location 299 *300 * @return bool|string301 302 */ 302 303 public static function schedule_decline_notification( $event, $label, $location ) { … … 313 314 public static function send_decline_notification( $event_id, $label, $location ) { 314 315 $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.', 316 317 $label, 317 318 $location … … 345 346 } 346 347 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 ); 350 353 351 354 wp_enqueue_script( 'wcpt-admin' ); … … 402 405 * Save metadata from form 403 406 * 404 * @param int $post_id Post ID. 405 * @param WP_Post $post Post Object. 407 * @hook save_post 406 408 */ 407 409 public function metabox_save( $post_id, $post ) { … … 411 413 } 412 414 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 413 420 // Don't add/remove meta on trash, untrash, restore, etc. 414 421 if ( empty( $_POST['action'] ) || 'editpost' !== $_POST['action'] ) { … … 417 424 418 425 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 ) ) {424 426 return; 425 427 } … … 432 434 $values[ $key ] = isset( $_POST[ $post_value ] ) ? esc_attr( $_POST[ $post_value ] ) : ''; 433 435 434 // Don't update protected fields 436 // Don't update protected fields. 435 437 if ( $this->is_protected_field( $key ) ) { 436 438 continue; … … 477 479 } 478 480 481 // TODO: This should also pass $_POST params since nonce is verified here. 479 482 do_action( 'wcpt_metabox_save_done', $post_id, $orig_meta_values ); 480 483 … … 500 503 } 501 504 502 // Don't show conflicting messages like 'Post submitted .'505 // Don't show conflicting messages like 'Post submitted'. 503 506 if ( in_array( 1, $this->active_admin_notices ) && false !== strpos( $location, 'message=8' ) ) { 504 507 $location = remove_query_arg( 'message', $location ); … … 527 530 $screen = get_current_screen(); 528 531 529 530 532 if ( empty( $post->post_type ) || $this->get_event_type() != $post->post_type || 'post' !== $screen->base ) { 531 533 return; … … 570 572 } 571 573 572 // Note that this is private, see wcpt_get_log_entries()574 // Note that this is private, see `wcpt_get_log_entries()`. 573 575 add_post_meta( 574 $post_id, '_note', array( 576 $post_id, 577 '_note', 578 array( 575 579 'timestamp' => time(), 576 580 'user_id' => get_current_user_id(), … … 606 610 607 611 <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 ); ?> /> 611 615 </p> 612 616 … … 614 618 615 619 <p> 616 <strong><?php echo $key; ?></strong>620 <strong><?php echo esc_html( $key ); ?></strong> 617 621 <?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> 619 623 <?php endif; ?> 620 624 </p> … … 622 626 <p> 623 627 <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> 625 629 626 630 <?php … … 629 633 ?> 630 634 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 ); ?> /> 634 638 635 639 <?php … … 638 642 ?> 639 643 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 ); ?>" 642 646 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 ); ?> /> 644 648 645 649 <?php 646 650 break; 647 651 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 ) { 650 655 $date = date( 'Y-m-d', $date ); 651 656 } … … 653 658 ?> 654 659 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 ); ?> /> 658 663 659 664 <?php … … 662 667 ?> 663 668 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> 666 671 667 672 <?php … … 675 680 $value = get_post_meta( $post_id, $key, true ); 676 681 ?> 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 ); ?>> 679 684 <option value="<?php echo esc_attr( $value ); ?>" selected> 680 685 <?php echo ( $value ) ? esc_html( $currencies[ $value ] . ' (' . $value . ')' ) : ''; ?> … … 696 701 697 702 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 ); 708 715 break; 709 716 default: -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/class-event-application.php
r8083 r8085 53 53 54 54 /** 55 * Render the output the of the [meetup-organizer-application]shortcode.55 * Render the output the of the application forms shortcode. 56 56 * 57 57 * @todo Use force_login_to_view_form() and populate_form_based_on_user(). … … 62 62 ob_start(); 63 63 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. 64 65 if ( isset( $_POST['submit-application'] ) ) { 65 $this->submit_application( );66 $this->submit_application( $_POST ); 66 67 } else { 67 68 $countries = wcorg_get_countries(); … … 83 84 /** 84 85 * 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 ); 88 91 89 92 if ( $this->is_rate_limited() ) { … … 96 99 $this->create_post( $application_data ); 97 100 $this->notify_applicant_application_received( 98 99 101 $this->get_organizer_email(), 102 $this->get_event_location() 100 103 ); 101 104 … … 223 226 $message = sprintf( 224 227 __( 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.", 226 229 'wpct' 227 230 ), 228 $this->get_event_label(), sanitize_text_field( $event_city ) 231 $this->get_event_label(), 232 sanitize_text_field( $event_city ) 229 233 ); 230 234 … … 238 242 239 243 // 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() ); 241 245 242 246 $public_report_url = $this->get_application_report_url(); 243 247 if ( isset( $public_report_url ) ) { 244 248 // `<%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() ); 246 250 } 247 251 248 252 $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; 250 254 if ( isset( $queue_size ) ) { 251 255 $singular = "is $queue_size application"; 252 256 $plural = "are $queue_size applications"; 253 257 $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() ) ); 260 265 return wcpt_slack_notify( COMMUNITY_TEAM_SLACK, $attachment ); 261 266 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-event/notification.php
r8084 r8085 5 5 6 6 if ( 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). 8 8 if ( defined( 'SANDBOX_SLACK_USERNAME' ) ) { 9 9 $slack_username = SANDBOX_SLACK_USERNAME; 10 10 } else { 11 $slack_username = "@". str_replace( array( '.dev.ord', '.dev' ), '', WPORG_SANDBOXED );11 $slack_username = '@' . str_replace( array( '.dev.ord', '.dev' ), '', WPORG_SANDBOXED ); 12 12 } 13 13 define( 'COMMUNITY_TEAM_SLACK', $slack_username ); … … 22 22 * 23 23 * @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. 25 25 * 26 26 * @return bool|string 27 27 */ 28 function wcpt_slack_notify 28 function wcpt_slack_notify( $channel, $attachment ) { 29 29 if ( ! class_exists( 'Dotorg\Slack\Send' ) ) { 30 30 return false; … … 44 44 * See the structure of attachment here: https://api.slack.com/docs/message-attachments 45 45 * 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. 48 48 * 49 49 * @return array 50 50 */ 51 function create_event_attachment 51 function create_event_attachment( $message, $title ) { 52 52 // Not translating because this will be send to Slack. 53 53 return array( 54 "title"=> $title,55 "text"=> $message,54 'title' => $title, 55 'text' => $message, 56 56 ); 57 57 } 58 58 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 */ 59 69 function create_event_status_attachment( $message, $event_id, $title ) { 60 70 $props = get_props_for_event( $event_id ); 61 71 62 $props_string = implode( ", ", $props ); 72 $props_string = implode( ', ', $props ); 73 63 74 return array( 64 "title"=> $title,65 "text"=> $message,66 "fields"=> array(75 'title' => $title, 76 'text' => $message, 77 'fields' => array( 67 78 array( 68 79 "title" => "Application processed by", … … 82 93 * @return array Array of usernames of people who have participated in vetting this application 83 94 */ 84 function get_props_for_event 95 function get_props_for_event( $event_id ) { 85 96 $user_ids = array(); 86 97 … … 97 108 $user_nicenames = get_user_nicenames_from_ids( $user_ids ); 98 109 99 // remove bot user `wordcamp` 110 // remove bot user `wordcamp`. 100 111 $user_nicenames = array_diff( $user_nicenames, array( 'wordcamp' ) ); 101 112 return $user_nicenames; … … 105 116 * Return user names for list of user ids provided in the function 106 117 * 107 * @param array $user_ids List of user_ids 118 * @param array $user_ids List of user_ids. 108 119 * 109 120 * @return array List of user nicenames … … 114 125 } 115 126 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 ); 117 133 118 134 $users = $user_query->get_results(); -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-loader.php
r8083 r8085 1 1 <?php 2 2 3 /* 3 4 Plugin Name: WordCamp Post Type … … 18 19 define( 'WCPT_URL', plugins_url( '/', __FILE__ ) ); 19 20 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 { 21 if ( ! 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 { 30 30 31 /**32 * The main WordCamp Post Type loader33 */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' ) ); 37 37 38 $this->includes();39 }38 $this->includes(); 39 } 40 40 41 /**42 * WordCamp Core File Includes43 */44 function includes() {45 // Load the files46 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. 54 54 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 ); 61 87 } 62 88 } 63 89 64 function core_admin() { 65 // Quick admin check 66 if ( ! is_admin() && ( ! defined( 'DOING_CRON' ) || ! DOING_CRON ) ) { 67 return; 68 } 90 endif; // class_exists check. 69 91 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 120 120 /** 121 121 * Checks if a field is read only. 122 * 122 123 * @param string $key Name of the field. 123 124 * … … 168 169 * TODO: Remove quickedit action. 169 170 * 170 * @param $actions171 * @param $post171 * @param array $actions 172 * @param WP_Post $post 172 173 * 173 174 * @return mixed … … 296 297 $last_synced_on = 'Never'; 297 298 } 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 ) ); 299 300 } 300 301 ?> 301 302 <div class="wcb submitbox"> 302 303 <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> 304 305 </div> 305 306 <div class="misc-pub-section"> 306 307 <label> 307 <input type="checkbox" name="<?php echo $element_name?>" >308 <input type="checkbox" name="<?php echo esc_html( $element_name ); ?>" > 308 309 Sync Now 309 310 </label> … … 316 317 * Updates meetup fields using meetup.com API only if Sync now checkbox is checked. 317 318 * 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 ) { 322 322 if ( $this->get_event_type() !== get_post_type() ) { 323 323 return; 324 324 } 325 325 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; 327 328 if ( ! $should_sync ) { 328 329 return; … … 340 341 * Update meetup fields using meetup.com API 341 342 * 342 * @param $post_id343 * @param int $post_id 343 344 * 344 345 * @return array|WP_Error … … 350 351 $parsed_url = wp_parse_url( $meetup_url, -1 ); 351 352 352 if ( ! $parsed_url ) {353 if ( ! $parsed_url ) { 353 354 return new WP_Error( 'invalid-url', __('Provided Meetup URL is not a valid URL.', 'wordcamporg' ) ); 354 355 } … … 391 392 foreach ( $group_leads as $event_host ) { 392 393 if ( WCPT_WORDPRESS_MEETUP_ID === $event_host['id'] ) { 393 // Skip WordPress admin user 394 // Skip WordPress admin user. 394 395 continue; 395 396 } 396 397 $event_hosts[] = array( 397 398 398 'name' => $event_host['name'], 399 'id' => $event_host['id'], 399 400 ); 400 401 } … … 406 407 update_post_meta( $post_id, 'Meetup group created on', $group_details['created'] / 1000 ); 407 408 408 409 409 if ( isset( $group_details['last_event'] ) && is_array( $group_details['last_event'] ) ) { 410 410 update_post_meta( $post_id, 'Number of past meetups', $group_details['past_event_count'] ); … … 423 423 * @param array $original_data 424 424 */ 425 public function meetup_organizers_changed( $post_id, $original_data ) {425 public function meetup_organizers_changed( $post_id, $original_data ) { 426 426 global $post; 427 427 … … 509 509 * Send notification when a new Meetup groups is added to the chapter. 510 510 * 511 * @param WP_Post $meetup Meetup post object 511 * @param WP_Post $meetup Meetup post object. 512 512 * 513 513 * @return bool|string … … 519 519 $organizer_slack = get_post_meta( $meetup->ID, 'Slack', true ); 520 520 $meetup_link = get_post_meta( $meetup->ID, 'Meetup URL', true ); 521 $title = "New meetup group added";521 $title = 'New meetup group added'; 522 522 523 523 $message = sprintf( … … 557 557 * Helper method which triggers action `update_meetup_organizers` 558 558 * 559 * @param $organizers560 * @param $post559 * @param array $organizers 560 * @param WP_Post $post 561 561 */ 562 562 protected function update_meetup_organizers( $organizers, $post ) { … … 580 580 'invalid-response' => array( 581 581 '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' ), 583 583 ), 584 584 'group_error' => array( 585 585 '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' ), 587 587 ), 588 588 'http_response_code' => array( 589 589 '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' ), 591 591 ), 592 592 ); … … 597 597 * Render list of co-organizer of meetup linking to their profile on meetup.com 598 598 * 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'. 600 600 */ 601 601 public function render_co_organizers_list( $key ) { … … 605 605 } 606 606 $organizers = get_post_meta( $post_id, $key, true ); 607 if ( isset 607 if ( isset( $organizers ) && is_array( $organizers ) ) { 608 608 $group_slug = get_post_meta( $post_id, 'Meetup URL', true ); 609 if ( empty 609 if ( empty( $group_slug ) ) { 610 610 echo 'Invalid Meetup Group URL'; 611 611 return; … … 625 625 echo '</ul>'; 626 626 } else { 627 e cho __( 'No meetup organizers set.', 'wordcamp.org' );627 esc_html_e( 'No meetup organizers set.', 'wordcamp.org' ); 628 628 } 629 629 } … … 742 742 */ 743 743 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 ); 750 752 751 753 $new_meetup_org_data = array(); … … 769 771 } 770 772 771 if ( empty 773 if ( empty( $new_ids ) ) { 772 774 continue; 773 775 } … … 802 804 $count = 0; 803 805 foreach ( $new_meetup_org_data as $post_id => $new_meetup_org ) { 804 $count + = 1;806 $count ++; 805 807 $title = get_the_title( $post_id ); 806 808 $meetup_tracker_url = get_site_url() . "/wp-admin/post.php?post=$post_id&action=edit"; … … 813 815 $meetup_members[] = "<a href='$meetup_group_url/members/$organizer_id' target='_blank' rel='noreferrer' >$organizer_name</a>"; 814 816 } 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. 818 820 wp_set_object_terms( $post_id, 'Needs to update Organizer list', 'meetup_tags', true ); 819 821 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/class-meetup-application.php
r8083 r8085 81 81 * Enqueue scripts and stylesheets. 82 82 */ 83 function enqueue_assets() {83 public function enqueue_assets() { 84 84 global $post; 85 85 … … 162 162 */ 163 163 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. 165 165 $values = array( 166 166 'q_name' => '', … … 232 232 add_post_meta( $post_id, 'Meetup Location', $data['q_mtp_loc'] ); 233 233 add_post_meta( 234 $post_id, '_status_change', array( 234 $post_id, 235 '_status_change', 236 array( 235 237 'timestamp' => time(), 236 238 'user_id' => $wordcamp_user_id, … … 279 281 */ 280 282 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/'; 282 284 } 283 285 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-meetup/meetup.php
r8083 r8085 6 6 use WordPress_Community\Applications\Meetup_Application; 7 7 8 defined( 'WPINC' ) ordie();8 defined( 'WPINC' ) || die(); 9 9 10 10 /* -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/class-wordcamp-application.php
r8083 r8085 14 14 const SHORTCODE_SLUG = 'wordcamp-organizer-application'; 15 15 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() { 17 22 return __( 'WordCamp', 'wordcamporg' ); 18 23 } … … 23 28 * @return string 24 29 */ 25 static function get_event_type() {30 public static function get_event_type() { 26 31 return WCPT_POST_TYPE_ID; 27 32 } … … 30 35 * Enqueue scripts and stylesheets 31 36 */ 32 function enqueue_assets() {37 public function enqueue_assets() { 33 38 global $post; 34 39 … … 53 58 * @return null|void 54 59 */ 55 function render_application_form( $countries ) {60 public function render_application_form( $countries ) { 56 61 render_wordcamp_application_form( $countries ); 57 62 } … … 64 69 * @return array|\WP_Error 65 70 */ 66 function validate_data( $unsafe_data ) {71 public function validate_data( $unsafe_data ) { 67 72 $safe_data = array(); 68 73 $unsafe_data = shortcode_atts( $this->get_default_application_values(), $unsafe_data ); … … 98 103 * @return array 99 104 */ 100 function get_default_application_values() {105 public function get_default_application_values() { 101 106 $values = array( 102 // Part 1 107 // Part 1. 103 108 'q_1079074_first_name' => '', 104 109 'q_1079074_last_name' => '', … … 118 123 'q_1068223_hope_to_accomplish_other' => '', 119 124 120 // Part 2 125 // Part 2. 121 126 'q_1045950_active_meetup' => '', 122 127 'q_1045953_role_in_meetup' => '', … … 128 133 'q_1079082_other_tech_events_success' => '', 129 134 130 // Part 3 135 // Part 3. 131 136 'q_1079103_wordcamp_location' => '', 132 137 'q_1046006_wordcamp_date' => '', … … 149 154 'q_1079098_anything_else' => '', 150 155 151 // Bonus 156 // Bonus. 152 157 'q_1079112_best_describes_you' => '', 153 158 'q_1079112_best_describes_you_other' => '', … … 172 177 */ 173 178 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/'; 175 180 } 176 181 … … 182 187 * @return bool|\WP_Error 183 188 */ 184 function create_post( $data ) {185 // Create the post 189 public function create_post( $data ) { 190 // Create the post. 186 191 $user = wcorg_get_user_by_canonical_names( $data['q_4236565_wporg_username'] ); 187 192 $statues = \WordCamp_Loader::get_post_statuses(); … … 192 197 'post_title' => 'WordCamp ' . $data['q_1079103_wordcamp_location'], 193 198 '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. 195 200 ); 196 201 … … 201 206 } 202 207 203 // Populate the meta fields 208 // Populate the meta fields. 204 209 add_post_meta( $post_id, '_application_data', $data ); 205 210 add_post_meta( $post_id, '_application_submitter_ip_address', $_SERVER['REMOTE_ADDR'] ); 206 211 207 208 212 add_post_meta( 209 $post_id, 'Organizer Name', sprintf( 213 $post_id, 214 'Organizer Name', 215 sprintf( 210 216 '%s %s', 211 217 $data['q_1079074_first_name'], … … 220 226 221 227 add_post_meta( 222 $post_id, 'Mailing Address', sprintf( 228 $post_id, 229 'Mailing Address', 230 sprintf( 223 231 "%s\n%s%s%s %s\n%s", 224 232 $data['q_1079060_add1'], … … 232 240 233 241 add_post_meta( 234 $post_id, '_status_change', array( 242 $post_id, 243 '_status_change', 244 array( 235 245 'timestamp' => time(), 236 246 'user_id' => is_a( $user, 'WP_User' ) ? $user->ID : 0, … … 248 258 * @return null|string 249 259 */ 250 function get_organizer_email() {260 public function get_organizer_email() { 251 261 if ( isset( $this->post ) && isset( $this->post->ID ) ) { 252 262 return get_post_meta( $this->post->ID, 'Email Address', true ); … … 259 269 * @return null|string 260 270 */ 261 function get_event_location() {271 public function get_event_location() { 262 272 if ( isset( $this->post ) && isset( $this->post->ID ) ) { 263 273 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 23 23 * Initialize WCPT Admin 24 24 */ 25 function __construct() {25 public function __construct() { 26 26 27 27 parent::__construct(); 28 28 29 // Add some general styling to the admin area 29 // Add some general styling to the admin area. 30 30 add_action( 'wcpt_admin_head', array( $this, 'admin_head' ) ); 31 31 32 // Scripts and CSS 32 // Scripts and CSS. 33 33 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); 34 34 35 // Post status transitions 35 // Post status transitions. 36 36 add_action( 'transition_post_status', array( $this, 'trigger_schedule_actions' ), 10, 3 ); 37 37 add_action( 'wcpt_approved_for_pre_planning', array( $this, 'add_organizer_to_central' ), 10 ); … … 41 41 42 42 add_filter( 43 'wp_insert_post_data', array( 43 'wp_insert_post_data', 44 array( 44 45 $this, 45 46 '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. 50 53 add_action( 'plugins_loaded', array( $this, 'schedule_cron_jobs' ), 11 ); 51 54 add_action( 'wcpt_close_wordcamps_after_event', array( $this, 'close_wordcamps_after_event' ) ); … … 55 58 56 59 /** 57 * metabox ()58 *59 60 * Add the metabox 60 61 * 61 62 * @uses add_meta_box 62 63 */ 63 function metabox() {64 public function metabox() { 64 65 add_meta_box( 65 66 'wcpt_information', … … 104 105 * @return string 105 106 */ 106 static function get_event_label() {107 public static function get_event_label() { 107 108 return WordCamp_Application::get_event_label(); 108 109 } … … 113 114 * @return string 114 115 */ 115 static function get_event_type() {116 public static function get_event_type() { 116 117 return WordCamp_Application::get_event_type(); 117 118 } … … 120 121 * Check if a field is readonly. 121 122 * 122 * @param $key123 * @param string $key 123 124 * 124 125 * @return bool 125 126 */ 126 function _is_protected_field( $key ) {127 public function _is_protected_field( $key ) { 127 128 return self::is_protected_field( $key ); 128 129 } 129 130 131 /** 132 * Update mentor username. 133 * 134 * @param int $post_id 135 */ 130 136 public function update_mentor( $post_id ) { 131 137 if ( $this->get_event_type() !== get_post_type() ) { … … 133 139 } 134 140 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. 136 143 $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 ) { 138 145 $this->add_mentor( get_post( $post_id ), $mentor_username ); 139 146 } … … 146 153 * These are used for the maps on Central, stats, etc. 147 154 * 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. 150 157 */ 151 158 public function update_venue_address( $post_id, $original_meta_values ) { … … 154 161 } 155 162 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. 157 165 $new_address = $_POST[ wcpt_key_to_str( 'Physical Address', 'wcpt_' ) ]; 158 166 if ( $new_address === $original_meta_values['Physical Address'][0] ) { … … 160 168 } 161 169 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 ); 165 176 166 177 $key = apply_filters( 'wordcamp_google_maps_api_key', '', 'server' ); 167 178 168 179 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 ); 172 184 } 173 185 … … 175 187 $body = json_decode( wp_remote_retrieve_body( $response ) ); 176 188 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. 178 190 if ( is_wp_error( $response ) || empty( $body->results[0]->address_components ) ) { 179 191 Logger\log( 'geocoding_failure', compact( 'request_url', 'response' ) ); … … 198 210 * @see https://developers.google.com/maps/documentation/geocoding/intro#Types API response schema 199 211 * 200 * @param $response212 * @param array $response 201 213 * 202 214 * @return array … … 225 237 226 238 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. 228 240 $country_name = $component->long_name; 229 241 break; … … 272 284 * @return array 273 285 */ 274 static function meta_keys( $meta_group = '' ) {286 public static function meta_keys( $meta_group = '' ) { 275 287 /* 276 288 * Warning: These keys are used for both the input field label and the postmeta key, so if you want to … … 289 301 'Organizer Name' => 'text', 290 302 '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. 292 304 'Telephone' => 'text', 293 305 'Mailing Address' => 'textarea', … … 342 354 343 355 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. 345 357 $retval = array( 346 358 'Contributor Day' => 'checkbox', … … 361 373 'URL' => 'wc-url', 362 374 '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. 364 376 'Twitter' => 'text', 365 377 'WordCamp Hashtag' => 'text', … … 457 469 * @return array 458 470 */ 459 static function get_venue_address_meta_keys() {471 public static function get_venue_address_meta_keys() { 460 472 return array( 461 473 '_venue_coordinates', … … 472 484 * Adds jQuery UI 473 485 */ 474 function admin_scripts() {475 476 // Edit WordCamp screen 486 public function admin_scripts() { 487 488 // Edit WordCamp screen. 477 489 if ( WCPT_POST_TYPE_ID === get_post_type() ) { 478 490 479 // Default data 491 // Default data. 480 492 $data = array( 481 493 'Mentors' => array( … … 487 499 ); 488 500 489 // Only include mentor data if the Mentor username field is editable 501 // Only include mentor data if the Mentor username field is editable. 490 502 if ( current_user_can( 'wordcamp_manage_mentors' ) ) { 491 503 $data['Mentors']['data'] = Mentors_Dashboard\get_all_mentor_data(); … … 501 513 502 514 /** 503 * admin_head ()504 *505 515 * Add some general styling to the admin area 506 516 */ 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'] ) : ?> 509 519 510 520 .column-title { width: 40%; } … … 516 526 517 527 /** 518 * user_profile_update ()519 *520 528 * Responsible for showing additional profile options and settings 521 529 * 522 530 * @todo Everything 523 531 */ 524 function user_profile_update( $user_id ) {532 public function user_profile_update( $user_id ) { 525 533 if ( ! wcpt_has_access() ) { 526 534 return false; … … 529 537 530 538 /** 531 * user_profile_wordcamp ()532 *533 539 * Responsible for saving additional profile options and settings 534 540 * 535 541 * @todo Everything 536 542 */ 537 function user_profile_wordcamp( $profileuser ) {543 public function user_profile_wordcamp( $profileuser ) { 538 544 if ( ! wcpt_has_access() ) { 539 545 return false; … … 541 547 ?> 542 548 543 <h3><?php _e( 'WordCamps', 'wcpt' ); ?></h3>549 <h3><?php esc_html_e( 'WordCamps', 'wcpt' ); ?></h3> 544 550 545 551 <table class="form-table"> 546 552 <tr valign="top"> 547 <th scope="row"><?php _e( 'WordCamps', 'wcpt' ); ?></th>553 <th scope="row"><?php esc_html_e( 'WordCamps', 'wcpt' ); ?></th> 548 554 549 555 <td> … … 556 562 557 563 /** 558 * column_headers ()559 *560 564 * Manage the column headers 561 565 * 562 566 * @param array $columns 567 * 563 568 * @return array $columns 564 569 */ 565 function column_headers( $columns ) {570 public function column_headers( $columns ) { 566 571 $columns = array( 567 572 'cb' => '<input type="checkbox" />', … … 577 582 578 583 /** 579 * column_data ( $column, $post_id )580 *581 584 * Print extra columns 582 585 * … … 584 587 * @param int $post_id 585 588 */ 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'] ) { 588 591 return $column; 589 592 } … … 591 594 switch ( $column ) { 592 595 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' ) ); 594 597 break; 595 598 596 599 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 ) { 602 607 $string_date = sprintf( __( 'Start: %1$s<br />End: %2$s', 'wcpt' ), $start, $end ); 603 608 604 // No end date 609 // No end date. 605 610 } else { 606 611 $string_date = sprintf( __( 'Start: %1$s', 'wcpt' ), $start ); 607 612 } 608 613 609 // No date 614 // No date. 610 615 } else { 611 616 $string_date = __( 'No Date', 'wcpt' ); 612 617 } 613 618 614 echo $string_date;619 echo wp_kses( $string_date, array( 'br' => array() ) ); 615 620 break; 616 621 617 622 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' ) ); 619 624 break; 620 625 621 626 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' ) ); 623 628 break; 624 629 } … … 626 631 627 632 /** 628 * post_row_actions ( $actions, $post )629 *630 633 * Remove the quick-edit action link and display the description under 631 634 * … … 634 637 * @return array $actions 635 638 */ 636 function post_row_actions( $actions, $post ) {639 public function post_row_actions( $actions, $post ) { 637 640 if ( WCPT_POST_TYPE_ID == $post->post_type ) { 638 641 unset( $actions['inline hide-if-no-js'] ); … … 640 643 $wc = array(); 641 644 642 if ( $wc_location = wcpt_get_wordcamp_location() ) { 645 $wc_location = wcpt_get_wordcamp_location(); 646 if ( $wc_location ) { 643 647 $wc['location'] = $wc_location; 644 648 } 645 649 646 if ( $wc_url = make_clickable( wcpt_get_wordcamp_url() ) ) { 650 $wc_url = make_clickable( wcpt_get_wordcamp_url() ); 651 if ( $wc_url ) { 647 652 $wc['url'] = $wc_url; 648 653 } 649 654 650 echo implode( ' - ', (array) $wc);655 echo wp_kses( implode( ' - ', (array) $wc ), wp_kses_allowed_html() ); 651 656 } 652 657 … … 672 677 if ( 'wcpt-pre-planning' == $new_status ) { 673 678 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 ) { 675 680 do_action( 'wcpt_added_to_final_schedule', $post ); 676 681 } … … 689 694 */ 690 695 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. 691 698 $lead_organizer = get_user_by( 'login', $_POST['wcpt_wordpress_org_username'] ); 692 699 … … 767 774 */ 768 775 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'] ) ) { 770 777 return $post_data; 771 778 } 772 779 773 $post = get_post( $ _POST['post_ID'] );780 $post = get_post( $post_data_raw['post_ID'] ); 774 781 if ( ! $post ) { 775 782 return $post_data; … … 814 821 $required_scheduled_fields = $this->get_required_fields( 'scheduled' ); 815 822 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 ) { 818 825 foreach ( $required_needs_site_fields as $field ) { 826 827 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce check would have done in `metabox_save`. 819 828 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ]; 820 829 … … 827 836 } 828 837 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 ) { 831 840 foreach ( $required_scheduled_fields as $field ) { 841 // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce check would have done in `metabox_save`. 832 842 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ]; 833 843 … … 846 856 * Get a list of fields required to move to a certain post status 847 857 * 848 * @param string $status 'needs-site' | 'scheduled' | 'any' 858 * @param string $status 'needs-site' | 'scheduled' | 'any'. 849 859 * 850 860 * @return array … … 854 864 855 865 $scheduled = array( 856 // WordCamp 866 // WordCamp. 857 867 'Start Date (YYYY-mm-dd)', 858 868 'Location', … … 862 872 'Multi-Event Sponsor Region', 863 873 864 // Organizing Team 874 // Organizing Team. 865 875 'Organizer Name', 866 876 'WordPress.org Username', … … 873 883 'Budget Wrangler E-mail Address', 874 884 875 // Venue 876 'Physical Address', // used to build stats 885 // Venue. 886 'Physical Address', // used to build stats. 877 887 ); 878 888 … … 895 905 } 896 906 907 /** 908 * TODO: Add description. 909 * 910 * @return array 911 */ 897 912 public static function get_protected_fields() { 898 913 $protected_fields = array(); … … 900 915 if ( ! current_user_can( 'wordcamp_manage_mentors' ) ) { 901 916 $protected_fields = array_merge( 902 $protected_fields, array( 917 $protected_fields, 918 array( 903 919 'Mentor WordPress.org User Name', 904 920 'Mentor Name', … … 910 926 if ( ! current_user_can( 'wordcamp_wrangle_wordcamps' ) ) { 911 927 $protected_fields = array_merge( 912 $protected_fields, array( 928 $protected_fields, 929 array( 913 930 'Multi-Event Sponsor Region', 914 931 ) … … 941 958 942 959 $screen = get_current_screen(); 943 944 960 945 961 if ( empty( $post->post_type ) || $this->get_event_type() != $post->post_type || 'post' !== $screen->base ) { … … 1056 1072 } 1057 1073 } 1058 endif; // class_exists check 1074 endif; // class_exists check. 1059 1075 1060 1076 /** … … 1066 1082 } 1067 1083 1084 /** 1085 * Displays organizer metabox 1086 */ 1068 1087 function wcpt_organizer_metabox() { 1069 1088 $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'organizer' ); … … 1071 1090 } 1072 1091 1092 /** 1093 * Displays venue metabox 1094 */ 1073 1095 function wcpt_venue_metabox() { 1074 1096 $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'venue' ); … … 1076 1098 } 1077 1099 1100 /** 1101 * Displays contributor metabox 1102 */ 1078 1103 function wcpt_contributor_metabox() { 1079 1104 $meta_keys = $GLOBALS['wordcamp_admin']->meta_keys( 'contributor' ); … … 1082 1107 1083 1108 /** 1084 * wcpt_metabox ()1085 *1086 1109 * The metabox that holds all of the additional information 1087 1110 * … … 1095 1118 $required_fields = WordCamp_Admin::get_required_fields( 'any' ); 1096 1119 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. 1098 1121 $messages = array( 1099 1122 'Telephone' => 'Required for shipping.', 1100 1123 '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. 1102 1125 'Global Sponsorship Grant Amount' => 'No commas, thousands separators or currency symbols. Ex. 1234.56', 1103 1126 'Global Sponsorship Grant' => 'Deprecated.',
Note: See TracChangeset
for help on using the changeset viewer.