Changeset 1302 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/multi-event-sponsors/classes/mes-sponsor.php
- Timestamp:
- 02/24/2015 07:58:53 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/multi-event-sponsors/classes/mes-sponsor.php
r715 r1302 14 14 class MES_Sponsor { 15 15 const POST_TYPE_SLUG = 'mes'; 16 const REGIONS_SLUG = 'mes-regions';17 16 18 17 /** … … 21 20 public function __construct() { 22 21 add_action( 'init', array( $this, 'create_post_type' ) ); 23 add_action( 'init', array( $this, 'create_taxonomies' ) );24 add_action( 'add_meta_boxes_' . self::POST_TYPE_SLUG, array( $this, 'remove_meta_boxes' ) );25 22 add_action( 'admin_init', array( $this, 'add_meta_boxes' ) ); 26 23 add_action( 'save_post', array( $this, 'save_post' ), 10, 2 ); 27 add_action( 'wcpt_metabox_value', array( $this, 'wcpt_region_dropdown_render' ), 10, 3 );28 add_action( 'wcpt_metabox_save', array( $this, 'wcpt_region_dropdown_save' ), 10, 3 );29 24 add_filter( 'the_content', array( $this, 'add_header_footer_text' ) ); 25 26 // todo readjust whitespace after this commit 30 27 } 31 28 … … 65 62 'query_var' => true, 66 63 'supports' => array( 'title', 'editor', 'author', 'excerpt', 'revisions', 'thumbnail' ), 67 'taxonomies' => array( self::REGIONS_SLUG ),64 'taxonomies' => array( MES_Region::TAXONOMY_SLUG ), 68 65 ); 69 66 70 67 register_post_type( self::POST_TYPE_SLUG, $post_type_params ); 71 }72 73 /**74 * Registers the category taxonomy75 */76 public function create_taxonomies() {77 $region_params = array(78 'label' => __( 'Region', 'wordcamporg' ),79 'labels' => array(80 'name' => __( 'Regions', 'wordcamporg' ),81 'singular_name' => __( 'Region', 'wordcamporg' )82 ),83 'hierarchical' => true,84 'rewrite' => array( 'slug' => self::REGIONS_SLUG ),85 );86 87 if ( ! taxonomy_exists( self::REGIONS_SLUG ) ) {88 register_taxonomy( self::REGIONS_SLUG, self::POST_TYPE_SLUG, $region_params );89 }90 68 } 91 69 … … 98 76 __( 'Regional Sponsorships', 'wordcamporg' ), 99 77 array( $this, 'markup_meta_boxes' ), 100 self::POST_TYPE_SLUG,78 MES_Sponsor::POST_TYPE_SLUG, 101 79 'normal', 102 80 'default' … … 107 85 __( 'Contact Information', 'wordcamporg' ), 108 86 array( $this, 'markup_meta_boxes' ), 109 self::POST_TYPE_SLUG,87 MES_Sponsor::POST_TYPE_SLUG, 110 88 'normal', 111 89 'default' … … 114 92 115 93 /** 116 * Remove the taxonomy meta boxes, since we don't assign them directly.117 *118 * @param WP_Post $post119 */120 public function remove_meta_boxes( $post ) {121 remove_meta_box( 'mes-regionsdiv', null, 'side' );122 }123 124 /**125 94 * Builds the markup for all meta boxes 126 95 * … … 133 102 switch ( $box['id'] ) { 134 103 case 'mes_regional_sponsorships': 135 $regions = get_terms( self::REGIONS_SLUG, array( 'hide_empty' => false ) );104 $regions = get_terms( MES_Region::TAXONOMY_SLUG, array( 'hide_empty' => false ) ); 136 105 $sponsorship_levels = get_posts( array( 'post_type' => MES_Sponsorship_Level::POST_TYPE_SLUG, 'numberposts' => -1 ) ); 137 106 $regional_sponsorships = $this->populate_default_regional_sponsorships( get_post_meta( $post->ID, 'mes_regional_sponsorships', true ), $regions ); … … 227 196 } else { 228 197 delete_post_meta( $post_id, 'mes_email_address' ); 229 }230 }231 232 /**233 * Render the dropdown element with regions for the WordCamp Post Type plugin234 *235 * @param string $key236 * @param string $value237 * @param string $field_name238 */239 public function wcpt_region_dropdown_render( $key, $value, $field_name ) {240 if ( 'Multi-Event Sponsor Region' != $key ) {241 return;242 }243 244 global $post;245 246 $regions = get_terms( self::REGIONS_SLUG, array( 'hide_empty' => false ) );247 $selected_region = get_post_meta( $post->ID, $key, true );248 249 require( dirname( __DIR__ ) . '/views/template-region-dropdown.php' );250 }251 252 /**253 * Save the dropdown element with regions for the WordCamp Post Type plugin254 *255 * @param string $key256 * @param string $value257 * @param int $post_id258 */259 public function wcpt_region_dropdown_save( $key, $value, $post_id ) {260 if ( 'Multi-Event Sponsor Region' != $key ) {261 return;262 }263 264 $post_key = wcpt_key_to_str( $key, 'wcpt_' );265 if ( isset( $_POST[ $post_key ] ) ) {266 update_post_meta( $post_id, $key, absint( $_POST[ $post_key ] ) );267 198 } 268 199 }
Note: See TracChangeset
for help on using the changeset viewer.