WordPress.org

Making WordPress.org

Changeset 2261


Ignore:
Timestamp:
01/08/2016 11:30:10 PM (5 years ago)
Author:
iandunn
Message:

WordCamp Post Types: Add billing information fields to Sponsor post type.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/css/admin.css

    r1026 r2261  
    1818    content: "\f487";
    1919}
     20
     21.wcpt-form {
     22    display: table;
     23}
     24
     25    .wcpt-form li {
     26        display: table-row;
     27    }
     28
     29        .wcpt-form li label {
     30            display: table-cell;
     31        }
     32
     33        .wcpt-form li input,
     34        .wcpt-form li select {
     35            display: table-cell;
     36            margin-left: 1em;
     37        }
     38
     39        li.wcpt-form-header {
     40            display: table-caption;
     41            font-weight: bold;
     42        }
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r2199 r2261  
    255255            case 'edit-wcb_sponsor':
    256256            case 'edit-wcb_session':
     257            case 'wcb_sponsor':
    257258            case 'dashboard':
    258259                wp_enqueue_style( 'wcpt-admin', plugins_url( '/css/admin.css', __FILE__ ), array(), 1 );
     
    13091310        add_meta_box( 'speakers-list',  __( 'Speakers',       'wordcamporg'  ), array( $this, 'metabox_speakers_list'  ), 'wcb_session',   'side' );
    13101311        add_meta_box( 'session-info',   __( 'Session Info',   'wordcamporg'  ), array( $this, 'metabox_session_info'   ), 'wcb_session',   'normal' );
    1311         add_meta_box( 'sponsor-info',   __( 'Sponsor Info',   'wordcampbase' ), array( $this, 'metabox_sponsor_info'   ), 'wcb_sponsor',   'side' );
     1312        add_meta_box( 'sponsor-info',   __( 'Sponsor Info',   'wordcamporg'  ), array( $this, 'metabox_sponsor_info'   ), 'wcb_sponsor',   'normal' );
    13121313    }
    13131314
     
    15021503    /**
    15031504     * Render the Sponsor Info metabox view
     1505     *
     1506     * @param WP_Post $sponsor
    15041507     */
    15051508    function metabox_sponsor_info( $sponsor ) {
    1506         $website = get_post_meta( $sponsor->ID, '_wcpt_sponsor_website', true );
     1509        $company_name      = get_post_meta( $sponsor->ID, '_wcpt_sponsor_company_name',      true );
     1510        $website           = get_post_meta( $sponsor->ID, '_wcpt_sponsor_website',           true );
     1511        $first_name        = get_post_meta( $sponsor->ID, '_wcpt_sponsor_first_name',        true );
     1512        $last_name         = get_post_meta( $sponsor->ID, '_wcpt_sponsor_last_name',         true );
     1513        $email_address     = get_post_meta( $sponsor->ID, '_wcpt_sponsor_email_address',     true );
     1514        $phone_number      = get_post_meta( $sponsor->ID, '_wcpt_sponsor_phone_number',      true );
     1515        $tax_resale_number = get_post_meta( $sponsor->ID, '_wcpt_sponsor_tax_resale_number', true );
     1516
     1517        $street_address1 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address1',   true );
     1518        $street_address2 = get_post_meta( $sponsor->ID, '_wcpt_sponsor_street_address2',   true );
     1519        $city            = get_post_meta( $sponsor->ID, '_wcpt_sponsor_city',              true );
     1520        $state           = get_post_meta( $sponsor->ID, '_wcpt_sponsor_state',             true );
     1521        $zip_code        = get_post_meta( $sponsor->ID, '_wcpt_sponsor_zip_code',          true );
     1522        $country         = get_post_meta( $sponsor->ID, '_wcpt_sponsor_country',           true );
     1523
     1524        $available_countries = array( 'Abkhazia', 'Afghanistan', 'Aland', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Ascension', 'Ashmore and Cartier Islands', 'Australia', 'Australian Antarctic Territory', 'Austria', 'Azerbaijan', 'Bahamas, The', 'Bahrain', 'Baker Island', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Bouvet Island', 'Brazil', 'British Antarctic Territory', 'British Indian Ocean Territory', 'British Sovereign Base Areas', 'British Virgin Islands', 'Brunei', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', "China, People's Republic of", 'China, Republic of (Taiwan)', 'Christmas Island', 'Clipperton Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo, (Congo – Brazzaville)', 'Congo, (Congo – Kinshasa)', 'Cook Islands', 'Coral Sea Islands', 'Costa Rica', "Cote d'Ivoire (Ivory Coast)", 'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Falkland Islands (Islas Malvinas)', 'Faroe Islands', 'Fiji', 'Finland', 'France', 'French Guiana', 'French Polynesia', 'French Southern and Antarctic Lands', 'Gabon', 'Gambia, The', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guernsey', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Heard Island and McDonald Islands', 'Honduras', 'Hong Kong', 'Howland Island', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Isle of Man', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jarvis Island', 'Jersey', 'Johnston Atoll', 'Jordan', 'Kazakhstan', 'Kenya', 'Kingman Reef', 'Kiribati', 'Korea, North', 'Korea, South', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macau', 'Macedonia', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Martinique', 'Mauritania', 'Mauritius', 'Mayotte', 'Mexico', 'Micronesia', 'Midway Islands', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro', 'Montserrat', 'Morocco', 'Mozambique', 'Myanmar (Burma)', 'Nagorno-Karabakh', 'Namibia', 'Nauru', 'Navassa Island', 'Nepal', 'Netherlands', 'Netherlands Antilles', 'New Caledonia', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Niue', 'Norfolk Island', 'Northern Cyprus', 'Northern Mariana Islands', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Palmyra Atoll', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Peter I Island', 'Philippines', 'Pitcairn Islands', 'Poland', 'Portugal', 'Pridnestrovie (Transnistria)', 'Puerto Rico', 'Qatar', 'Queen Maud Land', 'Reunion', 'Romania', 'Ross Dependency', 'Russia', 'Rwanda', 'Saint Barthelemy', 'Saint Helena', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Martin', 'Saint Pierre and Miquelon', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'Somaliland', 'South Africa', 'South Georgia & South Sandwich Islands', 'South Ossetia', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Svalbard', 'Swaziland', 'Sweden', 'Switzerland', 'Syria', 'Tajikistan', 'Tanzania', 'Thailand', 'Timor-Leste (East Timor)', 'Togo', 'Tokelau', 'Tonga', 'Trinidad and Tobago', 'Tristan da Cunha', 'Tunisia', 'Turkey', 'Turkmenistan', 'Turks and Caicos Islands', 'Tuvalu', 'U.S. Virgin Islands', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City', 'Venezuela', 'Vietnam', 'Wake Island', 'Wallis and Futuna', 'Yemen', 'Zambia', 'Zimbabwe' );
     1525
     1526        /*
     1527         * In most cases, the company name will be the same as the post title, but sometimes companies sponsor
     1528         * under specific brands (e.g., Automattic as Jetpack), so we want to pre-populate the field to avoid
     1529         * making the user do unnecessary work.
     1530         */
     1531        if ( empty( $company_name ) ) {
     1532            $company_name = $sponsor->post_title;
     1533        }
     1534
     1535        if ( empty( $country ) ) {
     1536            $country = 'United States';
     1537        }
     1538
    15071539        wp_nonce_field( 'edit-sponsor-info', 'wcpt-meta-sponsor-info' );
    15081540
    1509         ?>
    1510 
    1511         <p>
    1512             <label for="_wcpt_sponsor_website"><?php _e( 'Website:', 'wordcampbase' ); ?></label>
    1513             <input type="text" class="widefat" id="_wcpt_sponsor_website" name="_wcpt_sponsor_website" value="<?php echo esc_attr( esc_url( $website ) ); ?>" />
    1514         </p>
    1515 
    1516         <?php
     1541        require_once( __DIR__ . '/views/sponsors/metabox-sponsor-info.php' );
    15171542    }
    15181543
     
    16781703
    16791704        if ( isset( $_POST['wcpt-meta-sponsor-info'] ) && wp_verify_nonce( $_POST['wcpt-meta-sponsor-info'], 'edit-sponsor-info' ) ) {
    1680             $website = esc_url_raw( $_POST['_wcpt_sponsor_website'] );
    1681 
     1705            $text_values = array(
     1706                'company_name', 'first_name', 'last_name', 'email_address', 'phone_number', 'tax_resale_number',
     1707                'street_address1', 'street_address2', 'city', 'state', 'zip_code', 'country'
     1708            );
     1709
     1710            foreach ( $text_values as $id ) {
     1711                $values[ $id ] = sanitize_text_field( $_POST["_wcpt_sponsor_$id"] );
     1712            }
     1713
     1714            $values['website'] = esc_url_raw( $_POST['_wcpt_sponsor_website'] );
    16821715            // TODO: maybe only allows links to home page, depending on outcome of http://make.wordpress.org/community/2013/12/31/irs-rules-for-corporate-sponsorship-of-wordcamp/
    16831716
    1684             if ( $website ) {
    1685                 update_post_meta( $post_id, '_wcpt_sponsor_website', $website );
    1686             } else {
    1687                 delete_post_meta( $post_id, '_wcpt_sponsor_website' );
     1717            foreach( $values as $id => $value ) {
     1718                if ( empty( $value ) ) {
     1719                    delete_post_meta( $post_id, "_wcpt_sponsor_$id" );
     1720                } else {
     1721                    update_post_meta( $post_id, "_wcpt_sponsor_$id", $value );
     1722                }
    16881723            }
    16891724        }
Note: See TracChangeset for help on using the changeset viewer.