diff --git wordcamp.org/public_html/wp-content/plugins/wc-post-types/css/admin.css wordcamp.org/public_html/wp-content/plugins/wc-post-types/css/admin.css
index b5657e8..4909af1 100644
|
|
|
|
| 40 | 40 | display: table-caption; |
| 41 | 41 | font-weight: bold; |
| 42 | 42 | } |
| | 43 | .wcbsponsor-note { |
| | 44 | margin-bottom: 1em; |
| | 45 | } |
| | 46 | .wcbsponsor-note-meta { |
| | 47 | font-weight: 800; |
| | 48 | } |
| | 49 | No newline at end of file |
diff --git wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-notes.php wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-notes.php
new file mode 100644
index 0000000..818fef0
|
-
|
+
|
|
| | 1 | <?php if ( empty ( $existing_notes ) ) : ?> |
| | 2 | |
| | 3 | <?php _e( 'There are no notes yet.', 'wordcamporg' ); ?> |
| | 4 | |
| | 5 | <?php else : ?> |
| | 6 | |
| | 7 | <?php foreach ( $existing_notes as $note ) : ?> |
| | 8 | <div class="wcbsponsor-note"> |
| | 9 | <span class="wcbsponsor-note-meta"> |
| | 10 | <?php echo esc_html( date( 'Y-m-d', $note['timestamp'] ) ); ?> |
| | 11 | <?php echo esc_html( get_the_author_meta( 'nickname', $note['author_id'] ) ); ?>: |
| | 12 | </span> |
| | 13 | |
| | 14 | <?php echo esc_html( $note['message'] ); ?> |
| | 15 | </div> |
| | 16 | <?php endforeach; ?> |
| | 17 | |
| | 18 | <?php endif; ?> |
| | 19 | |
| | 20 | <div> |
| | 21 | <h3> |
| | 22 | <label for="wcbsponsor_new_note"> |
| | 23 | <?php _e( 'Add a Note', 'wordcamporg' ); ?> |
| | 24 | </label> |
| | 25 | |
| | 26 | <?php if ( current_user_can( 'manage_network' ) ) : ?> |
| | 27 | <p class="description">(visible to organizers)</p> |
| | 28 | <?php endif; ?> |
| | 29 | </h3> |
| | 30 | |
| | 31 | <textarea id="wcbsponsor_new_note" name="wcbsponsor_new_note" class="large-text"></textarea> |
| | 32 | |
| | 33 | <?php submit_button( |
| | 34 | esc_html__( 'Add Note', 'wordcamporg' ), |
| | 35 | 'secondary', |
| | 36 | 'wcbsponsor_add_note' |
| | 37 | ); ?> |
| | 38 | </div> |
diff --git wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
index 4fd6e51..91671c9 100644
|
|
|
class WordCamp_Post_Types_Plugin { |
| 1514 | 1514 | add_meta_box( 'sponsor-info', __( 'Sponsor Info', 'wordcamporg' ), array( $this, 'metabox_sponsor_info' ), 'wcb_sponsor', 'normal' ); |
| 1515 | 1515 | add_meta_box( 'sponsor-agreement', __( 'Sponsor Agreement', 'wordcamporg' ), array( $this, 'metabox_sponsor_agreement' ), 'wcb_sponsor', 'side' ); |
| 1516 | 1516 | add_meta_box( 'invoice-sponsor', __( 'Invoice Sponsor', 'wordcamporg' ), array( $this, 'metabox_invoice_sponsor' ), 'wcb_sponsor', 'side' ); |
| | 1517 | add_meta_box( 'sponsor-notes', __( 'Sponsor Notes', 'wordcamporg' ), array( $this, 'metabox_sponsor_notes' ), 'wcb_sponsor', 'side' ); |
| 1517 | 1518 | } |
| 1518 | 1519 | |
| 1519 | 1520 | /** |
| … |
… |
class WordCamp_Post_Types_Plugin { |
| 1806 | 1807 | require_once( __DIR__ . '/views/sponsors/metabox-invoice-sponsor.php' ); |
| 1807 | 1808 | } |
| 1808 | 1809 | |
| | 1810 | function metabox_sponsor_notes( $post ) { |
| | 1811 | $existing_notes = get_post_meta( $post->ID, '_wcbsponsor_notes', true ); |
| | 1812 | require_once( __DIR__ . '/views/sponsors/metabox-notes.php' ); |
| | 1813 | } |
| | 1814 | |
| 1809 | 1815 | /** |
| 1810 | 1816 | * Fired when a post is saved, makes sure additional metadata is also updated. |
| 1811 | 1817 | */ |
| … |
… |
class WordCamp_Post_Types_Plugin { |
| 1982 | 1988 | update_post_meta( $post_id, $meta_key, $value ); |
| 1983 | 1989 | } |
| 1984 | 1990 | } |
| | 1991 | |
| | 1992 | $this->validate_and_save_sponsor_notes( $post, $_POST['wcbsponsor_new_note'] ); |
| 1985 | 1993 | } |
| 1986 | 1994 | } |
| 1987 | 1995 | |
| 1988 | 1996 | /** |
| | 1997 | * Validate and save expense data |
| | 1998 | * |
| | 1999 | * @param WP_Post $post |
| | 2000 | * @param array $expenses |
| | 2001 | */ |
| | 2002 | function validate_and_save_sponsor_notes( $post, $new_note_message ) { |
| | 2003 | |
| | 2004 | $new_note_message = sanitize_text_field( wp_unslash( $new_note_message ) ); |
| | 2005 | |
| | 2006 | if ( empty( $new_note_message ) ) { |
| | 2007 | return; |
| | 2008 | } |
| | 2009 | |
| | 2010 | $notes = get_post_meta( $post->ID, '_wcbsponsor_notes', true ); |
| | 2011 | if ( ! is_array( $notes ) ) { |
| | 2012 | $notes = array(); |
| | 2013 | } |
| | 2014 | |
| | 2015 | $new_note = array( |
| | 2016 | 'timestamp' => time(), |
| | 2017 | 'author_id' => get_current_user_id(), |
| | 2018 | 'message' => $new_note_message |
| | 2019 | ); |
| | 2020 | |
| | 2021 | $notes[] = $new_note; |
| | 2022 | |
| | 2023 | update_post_meta( $post->ID, '_wcbsponsor_notes', $notes ); |
| | 2024 | |
| | 2025 | } |
| | 2026 | |
| | 2027 | /** |
| 1989 | 2028 | * Registers the custom post types, runs during init. |
| 1990 | 2029 | */ |
| 1991 | 2030 | function register_post_types() { |