Making WordPress.org

Changeset 5735


Ignore:
Timestamp:
08/03/2017 01:11:02 AM (7 years ago)
Author:
coreymckrill
Message:

WordCamp Post Types: Add Sponsor Agreement metabox

This adds a metabox to the Edit Sponsor screen for uploading a signed,
dated sponsor agreement as a PDF or image file.

In this commit it is only enabled on development environments and
testing sites.

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

Legend:

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

    r5575 r5735  
    214214            wp_enqueue_style( 'wp-datepicker-skins' );
    215215        }
     216
     217        // Enqueues scripts and styles for sponsors admin page
     218        if ( 'wcb_sponsor' == $post_type ) {
     219            wp_enqueue_script(
     220                'wcb-spon', // Avoid "sponsor" since that's a trigger word for ad blockers.
     221                plugins_url( 'js/wcb-spon.js', __FILE__ ),
     222                array( 'jquery', 'backbone', 'media-views' ),
     223                1,
     224                true
     225            );
     226
     227            wp_localize_script(
     228                'wcb-spon',
     229                'wcbSponsors',
     230                array(
     231                    'l10n' => array(
     232                        'modalTitle' => __( 'Sponsor Agreement', 'wordcamporg' ),
     233                    ),
     234                    'modal' => array(
     235                        'allowedTypes' => array( 'image', 'application/pdf' )
     236                    ),
     237                )
     238            );
     239        }
    216240    }
    217241
     
    14171441     */
    14181442    function add_meta_boxes() {
    1419         add_meta_box( 'speaker-info',   __( 'Speaker Info',   'wordcamporg'  ), array( $this, 'metabox_speaker_info'   ), 'wcb_speaker',   'side' );
    1420         add_meta_box( 'organizer-info', __( 'Organizer Info', 'wordcamporg'  ), array( $this, 'metabox_organizer_info' ), 'wcb_organizer', 'side' );
    1421         add_meta_box( 'speakers-list',  __( 'Speakers',       'wordcamporg'  ), array( $this, 'metabox_speakers_list'  ), 'wcb_session',   'side' );
    1422         add_meta_box( 'session-info',   __( 'Session Info',   'wordcamporg'  ), array( $this, 'metabox_session_info'   ), 'wcb_session',   'normal' );
    1423         add_meta_box( 'sponsor-info',   __( 'Sponsor Info',   'wordcamporg'  ), array( $this, 'metabox_sponsor_info'   ), 'wcb_sponsor',   'normal' );
    1424         add_meta_box( 'invoice-sponsor', __( 'Invoice Sponsor', 'wordcamporg' ), array( $this, 'metabox_invoice_sponsor' ), 'wcb_sponsor', 'side'   );
     1443        add_meta_box( 'speaker-info',      __( 'Speaker Info',      'wordcamporg'  ), array( $this, 'metabox_speaker_info'   ), 'wcb_speaker',   'side' );
     1444        add_meta_box( 'organizer-info',    __( 'Organizer Info',    'wordcamporg'  ), array( $this, 'metabox_organizer_info' ), 'wcb_organizer', 'side' );
     1445        add_meta_box( 'speakers-list',     __( 'Speakers',          'wordcamporg'  ), array( $this, 'metabox_speakers_list'  ), 'wcb_session',   'side' );
     1446        add_meta_box( 'session-info',      __( 'Session Info',      'wordcamporg'  ), array( $this, 'metabox_session_info'   ), 'wcb_session',   'normal' );
     1447        add_meta_box( 'sponsor-info',      __( 'Sponsor Info',      'wordcamporg'  ), array( $this, 'metabox_sponsor_info'   ), 'wcb_sponsor',   'normal' );
     1448
     1449        // Enable on 2017.testing only for testing purposes.
     1450        if ( ! defined( 'WORDCAMP_ENVIRONMENT' ) || 'development' === WORDCAMP_ENVIRONMENT || 829 === get_current_blog_id() ) {
     1451            add_meta_box( 'sponsor-agreement', __( 'Sponsor Agreement', 'wordcamporg' ),  array( $this, 'metabox_sponsor_agreement' ), 'wcb_sponsor', 'side'   );
     1452        }
     1453
     1454        add_meta_box( 'invoice-sponsor',   __( 'Invoice Sponsor',   'wordcamporg' ),  array( $this, 'metabox_invoice_sponsor' ), 'wcb_sponsor', 'side'   );
    14251455    }
    14261456
     
    16571687
    16581688    /**
     1689     * Render the Sponsor Agreement metabox view.
     1690     *
     1691     * @param WP_Post $sponsor
     1692     */
     1693    function metabox_sponsor_agreement( $sponsor ) {
     1694        $agreement_id  = get_post_meta( $sponsor->ID, '_wcpt_sponsor_agreement', true );
     1695        $agreement_url = wp_get_attachment_url( $agreement_id );
     1696
     1697        require_once( __DIR__ . '/views/sponsors/metabox-sponsor-agreement.php' );
     1698    }
     1699
     1700    /**
    16591701     * Render the Invoice Sponsor metabox view
    16601702     *
     
    18591901            $values['first_name'] = ucfirst( $values['first_name'] );
    18601902            $values['last_name' ] = ucfirst( $values['last_name' ] );
     1903
     1904            $values['agreement'] = filter_input( INPUT_POST, '_wcpt_sponsor_agreement', FILTER_SANITIZE_NUMBER_INT );
    18611905
    18621906            foreach( $values as $id => $value ) {
Note: See TracChangeset for help on using the changeset viewer.