Changeset 1302
- Timestamp:
- 02/24/2015 07:58:53 PM (10 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/multi-event-sponsors
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/multi-event-sponsors/bootstrap.php
r623 r1302 13 13 14 14 require_once( __DIR__ . '/classes/multi-event-sponsors.php' ); 15 require_once( __DIR__ . '/classes/mes-region.php' ); 15 16 require_once( __DIR__ . '/classes/mes-sponsor.php' ); 16 17 require_once( __DIR__ . '/classes/mes-sponsorship-level.php' ); 17 18 18 19 $GLOBALS['multi_event_sponsors'] = new Multi_Event_Sponsors(); 20 $GLOBALS['mes_sponsor'] = new MES_Region(); 19 21 $GLOBALS['mes_sponsor'] = new MES_Sponsor(); 20 22 $GLOBALS['mes_sponsorship_level'] = new MES_Sponsorship_Level(); -
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 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/multi-event-sponsors/classes/mes-sponsorship-level.php
r716 r1302 16 16 public function __construct() { 17 17 add_action( 'init', array( $this, 'create_post_type' ) ); 18 add_action( 'add_meta_boxes_' . self::POST_TYPE_SLUG, array( $this, 'remove_meta_boxes' ) );19 18 add_action( 'admin_init', array( $this, 'add_meta_boxes' ) ); 20 19 add_action( 'save_post', array( $this, 'save_post' ), 10, 2 ); 21 20 add_filter( 'the_content', array( $this, 'add_header_footer_text' ) ); 21 22 // todo readjust whitepsace after this commit 22 23 } 23 24 … … 58 59 'query_var' => true, 59 60 'supports' => array( 'title', 'editor', 'author', 'excerpt', 'revisions' ), 60 'taxonomies' => array( MES_ Sponsor::REGIONS_SLUG ),61 'taxonomies' => array( MES_Region::TAXONOMY_SLUG ), 61 62 ); 62 63 63 64 register_post_type( self::POST_TYPE_SLUG, $post_type_params ); 64 }65 66 /**67 * Remove the taxonomy meta boxes, since we don't assign them directly.68 *69 * @param WP_Post $post70 */71 public function remove_meta_boxes( $post ) {72 remove_meta_box( 'mes-regionsdiv', null, 'side' );73 65 } 74 66 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/multi-event-sponsors/classes/multi-event-sponsors.php
r845 r1302 41 41 public function shortcode_multi_event_sponsors( $parameters ) { 42 42 $sponsors = $this->reindex_array_by_object_id( get_posts( array( 'post_type' => MES_Sponsor::POST_TYPE_SLUG, 'numberposts' => -1 ) ) ); 43 $regions = $this->reindex_array_by_object_id( get_terms( MES_ Sponsor::REGIONS_SLUG, array( 'hide_empty' => false ) ) );43 $regions = $this->reindex_array_by_object_id( get_terms( MES_Region::TAXONOMY_SLUG, array( 'hide_empty' => false ) ) ); 44 44 $sponsorship_levels = $this->reindex_array_by_object_id( get_posts( array( 'post_type' => MES_Sponsorship_Level::POST_TYPE_SLUG, 'numberposts' => -1 ) ) ); 45 45 $grouped_sponsors = $this->group_sponsors_by_region_and_level( $sponsors ); … … 55 55 * This makes for efficient direct access when the ID is known. 56 56 * 57 * @param $array58 * @return mixed57 * @param array $old_array 58 * @return array 59 59 */ 60 60 protected function reindex_array_by_object_id( $old_array ) { … … 124 124 */ 125 125 protected function uksort_regions( $region_a_id, $region_b_id ) { 126 $region_a = get_term( $region_a_id, MES_ Sponsor::REGIONS_SLUG );127 $region_b = get_term( $region_b_id, MES_ Sponsor::REGIONS_SLUG );126 $region_a = get_term( $region_a_id, MES_Region::TAXONOMY_SLUG ); 127 $region_b = get_term( $region_b_id, MES_Region::TAXONOMY_SLUG ); 128 128 129 129 if ( $region_a->name == $region_b->name ) {
Note: See TracChangeset
for help on using the changeset viewer.