Changeset 1717 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-new-site.php
- Timestamp:
- 07/09/2015 10:54:33 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-new-site.php
r1683 r1717 72 72 73 73 if ( 'URL' == $key && 'wc-url' == $field_type && isset( $_POST[ $field_name ] ) ) { 74 // todo use https instead of http 74 75 $url = strtolower( substr( $_POST[ $field_name ], 0, 4 ) ) == 'http' ? $_POST[ $field_name ] : 'http://' . $_POST[ $field_name ]; 75 76 $url = set_url_scheme( esc_url_raw( $url ), 'https' ); … … 91 92 protected function create_new_site( $wordcamp_id, $url ) { 92 93 if ( ! current_user_can( 'manage_sites' ) ) { 94 return; 95 } 96 97 // The sponsor region is required so we can import the relevant sponsors and levels 98 if ( ! get_post_meta( $wordcamp_id, 'Multi-Event Sponsor Region', true ) ) { 93 99 return; 94 100 } … … 208 214 * Create stubs for commonly-used posts 209 215 * 210 * @todo Create sponsorship levels based on new mes-sponsor-level taxonomy instead of hardcoding211 *212 216 * @param WP_Post $wordcamp 213 217 * @param array $meta … … 215 219 */ 216 220 protected function create_post_stubs( $wordcamp, $meta, $lead_organizer ) { 221 $assigned_sponsor_data = $this->get_assigned_sponsor_data( $wordcamp->ID ); 222 $this->create_sponsorship_levels( $assigned_sponsor_data['assigned_sponsors'] ); 223 217 224 // Get stub content 218 225 $stubs = array_merge( 219 226 $this->get_stub_posts( $wordcamp, $meta ), 220 227 $this->get_stub_pages( $wordcamp, $meta ), 221 $this->get_stub_me_sponsors( $ wordcamp, $meta ),222 $this->get_stub_me_sponsor_thank_yous( $ wordcamp, $meta )228 $this->get_stub_me_sponsors( $assigned_sponsor_data ), 229 $this->get_stub_me_sponsor_thank_yous( $assigned_sponsor_data ) 223 230 ); 224 225 // Create sponsorship levels -- @todo pull these from Central instead of hardcoding226 $sponsor_level_ids['champion'] = wp_create_term( 'WordCamp Champion', 'wcb_sponsor_level' );227 $sponsor_level_ids['accomplice'] = wp_create_term( 'WordCamp Accomplice', 'wcb_sponsor_level' );228 $sponsor_level_ids['pillar'] = wp_create_term( 'WordCamp Pillar', 'wcb_sponsor_level' );229 231 230 232 // Create actual posts from stubs … … 266 268 267 269 // Assign sponsorship level 268 if ( isset( $page['term'] ) ) {269 wp_set_ post_terms( $page_id, $sponsor_level_ids[ $page['term']], 'wcb_sponsor_level', true );270 if ( 'wcb_sponsor' == $page['type'] && isset( $page['term'] ) ) { 271 wp_set_object_terms( $page_id, $page['term'], 'wcb_sponsor_level', true ); 270 272 } 271 273 } … … 551 553 552 554 /** 555 * Create the sponsorship levels for the assigned Multi-Event Sponsors 556 * 557 * @param array $assigned_sponsors 558 */ 559 protected function create_sponsorship_levels( $assigned_sponsors ) { 560 foreach( $assigned_sponsors as $sponsorship_level_id ) { 561 foreach ( $sponsorship_level_id as $sponsor ) { 562 wp_create_term( 563 $sponsor->sponsorship_level->post_title, 564 'wcb_sponsor_level' 565 ); 566 } 567 } 568 } 569 570 /** 553 571 * Get the content for sponsor stubs 554 572 * 555 573 * These are just the multi-event sponsors. Each camp will also have local sponsors, but they'll add those manually. 556 574 * 557 * @todo - load these from the new Multi_Event_Sponsors post type instead of hardcoding. 558 * 559 * @param WP_Post $wordcamp 560 * @param array $meta 575 * @param array $assigned_sponsor_data 561 576 * 562 577 * @return array 563 578 */ 564 protected function get_stub_me_sponsors( $wordcamp, $meta ) { 565 $me_sponsors = array( 566 array( 567 'title' => 'Code Poet', 568 'content' => "<p>If you use WordPress to build things for other people, Code Poet wants to make your life easier. No matter whether you freelance on a solo basis, lead a small web shop, make plugins in a dark closet, or crack the whip at a large design firm, Code Poet’s aim is to become your go-to source of information and resources to help you expand your WordPress skills and know-how. To make you better at what you do. To make it easier to make your living and look great doing it.</p> <p>You’re part of a tribe of WordPress designers and developers over 10,000 strong, spanning the entire globe. <a href='http://codepoet.com'>codepoet.com</a> aims to bring the working knowledge and real world strategies of those people into one place, for you to tap into.</p>", 569 'status' => 'publish', 570 'type' => 'wcb_sponsor', 571 'featured_image' => 'http://central.wordcamp.org/files/2013/09/Code-Poet-2.png', 572 'term' => 'champion' 573 ), 574 575 array( 576 'title' => 'WPML', 577 'content' => "<p>WPML turns WordPress websites multilingual. It works with caching, SEO and E-Commerce plugins, and allows the building of complete multilingual sites. WPML powers simple blogs as well as corporate and enterprise sites.</p> <p>WPML allows users to translate everything in the site, including content, menus, widgets and even theme and plugin texts. WPML powers over 400,000 commercial websites from all over the world.</p> <p>More information about going multilingual can be found at <a href='http://wpml.org'>WPML.org</a></p>", 578 'status' => 'publish', 579 'type' => 'wcb_sponsor', 580 'featured_image' => 'http://central.wordcamp.org/files/2013/09/wpml-web.png', 581 'term' => 'accomplice' 582 ), 583 584 array( 585 'title' => 'Bluehost', 586 'content' => "<p><a href='http://bluehost.com'>Bluehost</a> has been a WordPress partner since 2005 and powers over one million WordPress sites. Their goal is to provide outstanding hosting services and customer support for the best possible price. Bluehost is also constantly innovating and upgrading their services and infrastructure at no additional cost to their customers. Join the millions of other website owners that have already chosen Bluehost and see how they can help you with your site.</p>", 587 'status' => 'publish', 588 'type' => 'wcb_sponsor', 589 'featured_image' => 'http://central.wordcamp.org/files/2013/09/bluehost-logo13.png', 590 'term' => 'pillar' 591 ), 592 593 array( 594 'title' => 'DreamHost', 595 'content' => "<p>DreamHost is a global Web hosting and cloud services provider with over 350,000 customers and 1.2 million blogs, websites and apps hosted. The company offers a wide spectrum of Web hosting and cloud services including Shared Hosting, Virtual Private Servers (VPS), Dedicated Server Hosting, Domain Name Registration, the cloud storage service, DreamObjects, and the cloud computing service DreamCompute. More information can be found at <a href='http://dreamhost.com'>http://dreamhost.com</a>.</p>", 596 'status' => 'publish', 597 'type' => 'wcb_sponsor', 598 'featured_image' => 'http://central.wordcamp.org/files/2013/09/dreamhost_logo-cmyk-no_tag-2012.jpg', 599 'term' => 'accomplice' 600 ), 601 602 array( 603 'title' => 'Media Temple', 604 'content' => "<p>From its inception in 1998, (mt) Media Temple has been on a mission to help people and businesses succeed online.</p> <p>Over 125,000 customers in 100 countries now rely on Media Temple’s tools for domain registration, web hosting, business applications, virtual servers, and other cloud services to power more than 1.5 million websites. With 200 dedicated, U.S.-based employees, Media Temple takes pride in our 24/7 customer support. Our customers range from everyday people to top bloggers, creative professionals, and small businesses, as well as large enterprises like Starbucks, Adidas, Samsung, and Toyota.</p> <p>More information can be found anytime on the web at <a href='http://mediatemple.com'>http://mediatemple.com</a> or on Twitter <a href='https://twitter.com/mediatemple'>@MediaTemple</a>.</p>", 605 'status' => 'publish', 606 'type' => 'wcb_sponsor', 607 'featured_image' => 'http://central.wordcamp.org/files/2013/12/mt-250x140-dk.png', 608 'term' => 'pillar' 609 ), 610 ); 579 protected function get_stub_me_sponsors( $assigned_sponsor_data ) { 580 $me_sponsors = array(); 581 582 foreach ( $assigned_sponsor_data['assigned_sponsors'] as $sponsorship_level_id => $assigned_sponsors ) { 583 foreach ( $assigned_sponsors as $assigned_sponsor ) { 584 $me_sponsors[] = array( 585 'title' => $assigned_sponsor->post_title, 586 'content' => $assigned_sponsor->post_content, 587 'status' => 'publish', 588 'type' => 'wcb_sponsor', 589 'term' => $assigned_sponsor->sponsorship_level->post_name, 590 'featured_image' => isset( $assigned_sponsor_data['featured_images'][ $assigned_sponsor->ID ] ) ? $assigned_sponsor_data['featured_images'][ $assigned_sponsor->ID ] : '', 591 ); 592 } 593 } 611 594 612 595 return $me_sponsors; … … 627 610 switch_to_blog( BLOG_ID_CURRENT_SITE ); // central.wordcamp.org 628 611 612 $data['featured_images'] = array(); 629 613 $data['assigned_sponsors'] = $multi_event_sponsors->get_wordcamp_me_sponsors( $wordcamp_id, 'sponsor_level' ); 630 614 $data['sponsorship_levels'] = get_posts( array( … … 632 616 'numberposts' => -1 633 617 ) ); 618 // todo remove sponsorship levels item and refactor thank you stubs to use new posts in data['assigned_sponsors'][sponsor][sponsorship_level] 619 620 foreach( $data['assigned_sponsors'] as $sponsorship_level_id => $sponsors ) { 621 foreach( $sponsors as $sponsor ) { 622 if ( ! $attachment_id = get_post_thumbnail_id( $sponsor->ID ) ) { 623 continue; 624 } 625 626 if ( ! $attachment = wp_get_attachment_image_src( $attachment_id, 'full' ) ) { 627 continue; 628 } 629 630 $data['featured_images'][ $sponsor->ID ] = $attachment[0]; 631 } 632 } 634 633 635 634 restore_current_blog(); … … 644 643 * post excerpts contain the blurb for each sponsor. 645 644 * 646 * @param WP_Post $wordcamp 647 * @param array $meta 645 * @param array $assigned_sponsor_data 648 646 * 649 647 * @return array 650 648 */ 651 protected function get_stub_me_sponsor_thank_yous( $ wordcamp, $meta ) {649 protected function get_stub_me_sponsor_thank_yous( $assigned_sponsor_data ) { 652 650 /** @var $multi_event_sponsors Multi_Event_Sponsors */ 653 651 global $multi_event_sponsors; 654 652 $pages = array(); 655 656 $assigned_sponsor_data = $this->get_assigned_sponsor_data( $wordcamp->ID );657 653 658 654 foreach ( $assigned_sponsor_data['sponsorship_levels'] as $sponsorship_level ) {
Note: See TracChangeset
for help on using the changeset viewer.