Making WordPress.org

Changeset 8529


Ignore:
Timestamp:
03/26/2019 09:50:41 AM (7 years ago)
Author:
vedjain
Message:

WordCamp: Change sponsor order to reflect their donation status

In acknowledgement message to sponsor on purchase successful page and ticket receipt email while purchasing a ticket, we were showing sponsors who were sponsoring in that region in random order each time.
This patch changes that bahavior to:

  1. Recognise sponsor irrespective of the region that they sponsor in.
  2. Order sponsor names w.r.t. their donation level (Gold, Silver and then Bronze) and sponsor region.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/camptix-tweaks.php

    r7469 r8529  
    670670 */
    671671function get_global_sponsors_string( $sponsor_args = array() ) {
    672     $sponsor_message_html = '';
    673     $sponsors             = get_global_sponsors( $sponsor_args );
    674     $sponsor_count        = count( $sponsors );
    675 
    676     if ( $sponsor_count > 0 ) {
    677         $sponsors = wp_list_pluck( $sponsors, 'name' );
    678 
    679         $sponsors = array_map( function( $string ) {
    680             return "<strong>$string</strong>";
    681         }, $sponsors );
    682 
    683         shuffle( $sponsors );
    684 
    685         switch ( $sponsor_count ) {
    686             case 1 :
    687                 $sponsors_string = array_shift( $sponsors );
    688                 break;
    689             case 2 :
    690                 $sponsors_string = sprintf(
    691                     /* translators: The %s placeholders are the names of sponsors. */
    692                     __( '%s and %s', 'wordcamporg' ),
    693                     array_shift( $sponsors ),
    694                     array_shift( $sponsors )
    695                 );
    696                 break;
    697             default :
    698                 $last_sponsor = array_pop( $sponsors );
    699 
    700                 $sponsors_string = sprintf(
    701                     '%1$s%2$s %3$s',
    702                     /* translators: Used between sponsor names in a list, there is a space after the comma. */
    703                     implode( _x( ', ', 'list item separator', 'wordcamporg' ), $sponsors ),
    704                     /* translators: List item separator, used before the last sponsor name in the list. */
    705                     __( ', and', 'wordcamporg' ),
    706                     $last_sponsor
    707                 );
    708                 break;
    709         }
    710 
    711         $intro = __( 'WordPress Global Community Sponsors help fund WordCamps and meetups around the world.', 'wordcamporg' );
    712 
    713         $thank_you = sprintf(
    714             /* translators: %1$s: list of sponsor names; %2$s: URL; */
    715             _n(
    716                 'Thank you to %1$s for <a href="%2$s">its support</a>!',
    717                 'Thank you to %1$s for <a href="%2$s">their support</a>!',
    718                 $sponsor_count,
    719                 'wordcamporg'
    720             ),
    721             $sponsors_string,
    722             'https://central.wordcamp.org/global-community-sponsors/'
    723         );
    724 
    725         if ( isset( $sponsor_args['region_id'], $sponsor_args['level_id'] ) ) {
    726             $sponsor_level = get_sponsorship_level_name_from_id( $sponsor_args['level_id'] );
    727             $sponsor_region = get_sponsorship_region_description_from_id( $sponsor_args['region_id'] );
    728 
    729             if ( $sponsor_level && $sponsor_region ) {
    730                 $thank_you = sprintf(
    731                     /* translators: %1$s: sponsorship type; %2$s: list of sponsor names; %3$s: URL; %4$s: sponsorship region; */
    732                     _n(
    733                         'Thank you to our %1$s sponsor %2$s for <a href="%3$s">its support</a> in %4$s!',
    734                         'Thank you to our %1$s sponsors %2$s for <a href="%3$s">their support</a> in %4$s!',
    735                         $sponsor_count,
    736                         'wordcamporg'
    737                     ),
    738                     $sponsor_level,
    739                     $sponsors_string,
    740                     'https://central.wordcamp.org/global-community-sponsors/',
    741                     $sponsor_region
    742                 );
    743             }
    744         }
    745 
    746         $sponsor_message_html = sprintf( '%s %s', $intro, $thank_you );
    747     }
     672    $sponsors = array( 'Jetpack', 'WooCommerce', 'Bluehost', 'GoDaddy', 'Liquid Web', 'GreenGeeks', 'DreamHost' );
     673
     674    $sponsors = array_map( function( $string ) {
     675        return "<strong>$string</strong>";
     676    }, $sponsors );
     677
     678    $last_sponsor = array_pop( $sponsors );
     679
     680    $sponsors_string = sprintf(
     681        '%1$s%2$s %3$s',
     682        /* translators: Used between sponsor names in a list, there is a space after the comma. */
     683        implode( _x( ', ', 'list item separator', 'wordcamporg' ), $sponsors ),
     684        /* translators: List item separator, used before the last sponsor name in the list. */
     685        __( ' and', 'wordcamporg' ),
     686        $last_sponsor
     687    );
     688
     689    $intro = __( 'WordPress Global Community Sponsors help fund WordCamps and meetups around the world.', 'wordcamporg' );
     690
     691    $thank_you = sprintf(
     692    /* translators: %1$s: list of sponsor names; %2$s: URL; */
     693        __( 'Thank you to %1$s for <a href="%2$s">their support</a>!', 'wordcamporg' ),
     694        $sponsors_string,
     695        'https://central.wordcamp.org/global-community-sponsors/'
     696    );
     697
     698    $sponsor_message_html = sprintf( '%s %s', $intro, $thank_you );
    748699
    749700    return $sponsor_message_html;
Note: See TracChangeset for help on using the changeset viewer.