WordPress.org

Making WordPress.org

Changeset 8384


Ignore:
Timestamp:
03/01/2019 07:26:16 PM (4 months ago)
Author:
coreymckrill
Message:

WordCamp: Updates to generated content for compatibility with block editor

  • Update the post and page stubs that are added when a new WordCamp site is created
  • Update the Forms-to-Drafts plugin so speaker and session posts created from the Call For Speakers form use blocks
Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins
Files:
19 added
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-new-site.php

    r8375 r8384  
    492492     */
    493493    protected function get_stub_pages( $wordcamp, $meta ) {
    494         // todo remove the to field from all contact forms and notes, just let it default to the admin email
    495 
    496494        $pages = array(
    497495            array(
    498496                'title'   => __( 'Schedule', 'wordcamporg' ),
    499                 'content' =>
    500                     '<p>'  . __( '<em>Organizers note:</em> You can enter content for this page in the Sessions menu item in the sidebar.', 'wordcamporg' ) . '</p> ' .
    501                     '<h1>' . __( 'Saturday, January 1st', 'wordcamporg' ) . '</h1> ' .
    502                     '<p>[schedule date="YYYY-MM-DD" tracks="example-track,another-example-track,yet-another-example-track"]</p>',
     497                'content' => $this->get_stub_content( 'page', 'schedule' ),
    503498                'status'  => 'publish',
    504499                'type'    => 'page',
     
    507502            array(
    508503                'title'   => __( 'Speakers', 'wordcamporg' ),
    509                 'content' =>
    510                     '<p>' . __( '<em>Organizers note:</em> You can enter content for this page in the Speakers menu item in the sidebar.', 'wordcamporg' ) . '</p> ' .
    511                     '<p>[speakers]</p>',
     504                'content' => $this->get_stub_content( 'page', 'speakers' ),
    512505                'status'  => 'publish',
    513506                'type'    => 'page',
     
    516509            array(
    517510                'title'   => __( 'Sessions', 'wordcamporg' ),
    518                 'content' =>
    519                     '<p>' . __( '<em>Organizers note:</em> You can enter content for this page in the Sessions menu item in the sidebar.', 'wordcamporg' ) . '</p> ' .
    520                     '<p>[sessions orderby="session_time" order="asc"]</p>',
     511                'content' => $this->get_stub_content( 'page', 'sessions' ),
    521512                'status'  => 'publish',
    522513                'type'    => 'page',
     
    525516            array(
    526517                'title'   => __( 'Sponsors', 'wordcamporg' ),
    527                 'content' =>
    528                     '<p>' . sprintf(
    529                         /* translators: %s: Global Community Sponsorship page URL */
    530                         __( "<em>Organizers note:</em> Multi-event sponsors have been automatically created in the Sponsors menu, but you'll need to remove the ones that don't apply to your specific event. To find out which ones apply, please visit the <a href=\"%s\">Global Community Sponsorship</a> handbook page. After that, you should add the sponsors that are specific to your event. For non-English sites, make sure the URL below matches the Call for Sponsors page.", 'wordcamporg' ),
    531                         'https://make.wordpress.org/community/handbook/wordcamp-organizer/planning-details/fundraising/global-community-sponsorship-for-event-organizers/'
    532                     ) . '</p> ' .
    533                     '<h3>' . __( 'Our Sponsors', 'wordcamporg' ) . '</h3> ' .
    534                     '<p>'  . __( 'Blurb thanking sponsors', 'wordcamporg' ) . '</p> ' .
    535                     '<p>[sponsors]</p> ' .
    536                     '<h3>' . __( 'Interested in sponsoring WordCamp this year?', 'wordcamporg' ) . '</h3> ' .
    537                     '<p>'  . __( 'Check out our <a href="/call-for-sponsors">Call for Sponsors</a> post for details on how you can help make this year\'s WordCamp the best it can be!</p>', 'wordcamporg' ),
     518                'content' => $this->get_stub_content( 'page', 'sponsors' ),
    538519                'status'  => 'publish',
    539520                'type'    => 'page',
     
    549530            array(
    550531                'title'   => __( 'Organizers', 'wordcamporg' ),
    551                 'content' =>
    552                     '<p>' . __( '<em>Organizers note:</em> You can enter content for this page in the Organizers menu item in the sidebar.', 'wordcamporg' ) . '</p> ' .
    553                     '<p>[organizers]</p>',
     532                'content' => $this->get_stub_content( 'page', 'organizers' ),
    554533                'status'  => 'publish',
    555534                'type'    => 'page',
     
    558537            array(
    559538                'title'   => __( 'Tickets', 'wordcamporg' ),
    560                 'content' =>
    561                     '<p>' . __( "<em>Organizers note:</em> If you'd like to change the slug for this page, please make sure you do that before opening ticket sales. Changing the page slug after tickets have started selling will break the link that users receive in their receipt e-mail.", 'wordcamporg' ) . '</p> ' .
    562                     '<p>[camptix]</p>',
     539                'content' => $this->get_stub_content( 'page', 'tickets' ),
    563540                'status'  => 'draft',
    564541                'type'    => 'page',
     
    567544            array(
    568545                'title'   => __( 'Attendees', 'wordcamporg' ),
    569                 'content' => '[camptix_attendees columns="3"]',
     546                'content' => $this->get_stub_content( 'page', 'attendees' ),
    570547                'status'  => 'draft',
    571548                'type'    => 'page',
     
    574551            array(
    575552                'title'   => __( 'Videos', 'wordcamporg' ),
    576                 'content' =>
    577                     '<p>' . __( '<em>Organizers note:</em> After your WordCamp is over and the sessions are published to WordPress.tv, you can embed them here. Just enter the event slug into the shortcode below, and hit the <em>Publish</em> button.', 'wordcamporg' ) . '</p> ' .
    578                      '<p>[wptv event="enter-event-slug-here"]</p>',
     553                'content' => $this->get_stub_content( 'page', 'videos' ),
    579554                'status'  => 'draft',
    580555                'type'    => 'page',
     
    583558            array(
    584559                'title'   => __( 'Slideshow', 'wordcamporg' ),
    585                 'content' =>
    586                     '<p>' . __( "<em>Organizers note:</em> Upload photos to this page and they'll automagically appear in a slideshow!", 'wordcamporg' ) . '</p> ' .
    587                     '<p>[slideshow]</p>',
     560                // todo Update this one when Jetpack's Slideshow block becomes available.
     561                'content' => $this->get_stub_content( 'page', 'slideshow' ),
    588562                'status'  => 'draft',
    589563                'type'    => 'page',
     
    592566            array(
    593567                'title'   => __( 'Contact', 'wordcamporg' ),
    594                 'content' => sprintf(
    595                     '<p>' .
    596                         '[contact-form to="%s" subject="%s"]' .
    597                             '[contact-field label="%s" type="name"     required="1" /]' .
    598                             '[contact-field label="%s" type="email"    required="1" /]' .
    599                             '[contact-field label="%s" type="textarea" required="1" /]' .
    600                         '[/contact-form]' .
    601                     '</p>',
    602                     get_option( 'admin_email' ),
    603                     __( 'WordCamp Contact Request', 'wordcamporg' ),
    604                     __( 'Name', 'wordcamporg' ),
    605                     __( 'Email', 'wordcamporg' ),
    606                     __( 'Message', 'wordcamporg' )
    607                 ),
     568                'content' => $this->get_stub_content( 'page', 'contact' ),
    608569                'status'  => 'publish',
    609570                'type'    => 'page',
     
    612573            array(
    613574                'title'   => __( 'Social Media Stream', 'wordcamporg' ),
    614                 'content' =>
    615                     '<p>' . __( '<em>Organizers note:</em> The [[tagregator]] shortcode will pull in a stream of social media posts and display them. In order to use it, you\'ll need to follow the setup instructions at http://wordpress.org/plugins/tagregator/installation, and then update "#wcxyz" below with your hashtag.', 'wordcamporg' ) . '</p> ' .
    616                     '<p>[tagregator hashtag="#wcxzy"]</p>',
     575                'content' => $this->get_stub_content( 'page', 'social-media-stream' ),
    617576                'status'  => 'publish',
    618577                'type'    => 'page',
     
    621580            array(
    622581                'title'   => __( 'Code of Conduct', 'wordcamporg' ),
    623                 'content' =>
    624                     '<p>' .
    625                         sprintf(
    626                             // translators: %s: URL for code of conduct policy
    627                             __( '<em>Organizers note:</em> Below is a boilerplate code of conduct that you can customize; another great example is the Ada Initiative <a href="%s">anti-harassment policy.</a>', 'wordcamporg' ),
    628                             'http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy'
    629                         ) .
    630                     '</p> ' .
    631 
    632                     '<p>' .
    633                         sprintf(
    634                             // translators: %s: URL for article about harassment reports
    635                             __( 'We also recommend the organizing team read this article on <a href="%s">how to take a harassment report</a>', 'wordcamporg' ),
    636                             'http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Responding_to_reports'
    637                         ) .
    638                     '</p> ' .
    639 
    640                     '<p>' . __( 'Please update the portions <span style="color: red; text-decoration: underline;">with red text</span>. You can use the "Remove Formatting" button on the toolbar (the eraser icon on the second line) to remove the color and underline.', 'wordcamporg' ) .
    641                     $this->get_code_of_conduct(),
     582                'content' => $this->get_stub_content( 'page', 'code-of-conduct' ),
    642583                'status'  => 'publish',
    643584                'type'    => 'page',
     
    661602                // translators: %s: site title
    662603                'title'   => sprintf( __( 'Welcome to %s', 'wordcamporg' ), get_option( 'blogname' ) ),
    663                 'content' =>
    664                     '<p>' . __( '<em>Organizers note:</em> Please update the portions <span style="color: red; text-decoration: underline;">with red text</span>.', 'wordcamporg' ) . '</p> ' .
    665                     '<p>' . __( 'We\'re happy to announce that <span style="color: red; text-decoration: underline;">WordCamp YourCityName</span> is officially on the calendar!', 'wordcamporg' ) . '</p> ' .
    666                     '<p>' . __( '<span style="color: red; text-decoration: underline;">WordCamp YourCityName</span> will be <span style="color: red; text-decoration: underline;">DATE(S)</span> at <span style="color: red; text-decoration: underline;">LOCATION</span>.', 'wordcamporg' ) . '</p> ' .
    667                     '<p>' . __( '<span style="color: red; text-decoration: underline;">Subscribe using the form in the sidebar</span> to stay up to date on the most recent news. We’ll be keeping you posted on all the details over the coming months, including speaker submissions, ticket sales and more!', 'wordcamporg' ) . '</p> ',
     604                'content' => $this->get_stub_content( 'post', 'welcome' ),
    668605                'status'  => 'publish',
    669606                'type'    => 'post',
     
    672609            array(
    673610                'title'   => __( 'Call for Sponsors', 'wordcamporg' ),
    674                 'content' =>
    675                     '<p>' . __( 'Blurb with information for potential sponsors.', 'wordcamporg' ) . '</p> ' .
    676                     '<p>' .
    677                         sprintf( '
    678                             [contact-form to="%s" subject="%s"]
    679                             [contact-field label="%s" type="text"     required="1" /]
    680                             [contact-field label="%s" type="name"     required="1" /]
    681                             [contact-field label="%s" type="email"    required="1" /]
    682                             [contact-field label="%s" type="text"                  /]
    683                             [contact-field label="%s" type="text"                  /]
    684                             [contact-field label="%s" type="textarea" required="1" /]
    685                             [contact-field label="%s" type="textarea"              /]
    686                             [/contact-form]',
    687                             get_option( 'admin_email' ),
    688                             __( 'WordCamp Sponsor Request', 'wordcamporg' ),
    689                             __( 'Contact Name', 'wordcamporg' ),
    690                             __( 'Company Name', 'wordcamporg' ),
    691                             __( 'Email', 'wordcamporg' ),
    692                             __( 'Phone Number', 'wordcamporg' ),
    693                             __( 'Sponsorship Level', 'wordcamporg' ),
    694                             __( 'Why Would you Like to Sponsor WordCamp?', 'wordcamporg' ),
    695                             __( 'Questions / Comments', 'wordcamporg' )
    696                         ) .
    697                     '</p>',
     611                'content' => $this->get_stub_content( 'post', 'call-for-sponsors' ),
    698612                'status'  => 'draft',
    699613                'type'    => 'post',
     
    702616            array(
    703617                'title'   => __( 'Call for Speakers', 'wordcamporg' ),
    704                 'content' =>
    705                     '<p>' . __( '<em>Organizers note:</em> Submissions to this form will automatically create draft posts for the Speaker and Session post types. Feel free to customize the form, but deleting or renaming the following fields will break the automation: Name, Email, WordPress.org Username, Your Bio, Session Title, Session Description.', 'wordcamporg' ) . '</p>' .
    706                     '<p>' . __( "If you'd like to propose multiple topics, please submit the form multiple times, once for each topic. [Other speaker instructions/info goes here.]", 'wordcamporg' ) . '</p>' .
    707                     '<p>' .
    708                         sprintf( '
    709                             [contact-form to="%s" subject="%s"]
    710                                 [contact-field label="%s" type="name"     required="1" /]
    711                                 [contact-field label="%s" type="email"    required="1" /]
    712                                 [contact-field label="%s" type="text"     required="1" /]
    713                                 [contact-field label="%s" type="textarea" required="1" /]
    714                                 [contact-field label="%s" type="text"     required="1" /]
    715                                 [contact-field label="%s" type="textarea" required="1" /]
    716                                 [contact-field label="%s" type="text"     required="1" /]
    717                                 [contact-field label="%s" type="textarea"              /]
    718                             [/contact-form]',
    719                             get_option( 'admin_email' ),
    720                             __( 'WordCamp Speaker Request', 'wordcamporg' ),
    721                             __( 'Name', 'wordcamporg' ),
    722                             __( 'Email Address', 'wordcamporg' ),
    723                             __( 'WordPress.org Username', 'wordcamporg' ),
    724                             __( 'Your Bio', 'wordcamporg' ),
    725                             __( 'Topic Title', 'wordcamporg' ),
    726                             __( 'Topic Description', 'wordcamporg' ),
    727                             __( 'Intended Audience', 'wordcamporg' ),
    728                             __( 'Past Speaking Experience (not necessary to apply)', 'wordcamporg' )
    729                         ) .
    730                     '</p>',
     618                'content' => $this->get_stub_content( 'post', 'call-for-speakers' ),
    731619                'status'  => 'draft',
    732620                'type'    => 'post',
     
    738626            array(
    739627                'title'   => __( 'Call for Volunteers', 'wordcamporg' ),
    740                 'content' =>
    741                     '<p>' . __( 'Blurb with information for potential volunteers.', 'wordcamporg' ) . '</p> ' .
    742                     '<p>' .
    743                         sprintf( '
    744                             [contact-form to="%s" subject="%s"]
    745                                 [contact-field label="%s" type="text"     required="1" /]
    746                                 [contact-field label="%s" type="email"    required="1" /]
    747                                 [contact-field label="%s" type="textarea" required="1" /]
    748                                 [contact-field label="%s" type="text"     required="1" /]
    749                                 [contact-field label="%s" type="textarea"              /]
    750                             [/contact-form]',
    751                             get_option( 'admin_email' ),
    752                             __( 'WordCamp Volunteer Application', 'wordcamporg' ),
    753                             __( 'Name', 'wordcamporg' ),
    754                             __( 'Email', 'wordcamporg' ),
    755                             __( 'Skills / Interests / Experience (not necessary to volunteer)', 'wordcamporg' ),
    756                             __( 'Number of Hours Available', 'wordcamporg' ),
    757                             __( 'Questions / Comments', 'wordcamporg' )
    758                         ) .
    759                     '</p>',
     628                'content' => $this->get_stub_content( 'post', 'call-for-volunteers' ),
    760629                'status'  => 'draft',
    761630                'type'    => 'post',
     
    764633
    765634        return $posts;
     635    }
     636
     637    /**
     638     * Load the content for a stub from an include file.
     639     *
     640     * @param string $post_type
     641     * @param string $stub_name
     642     *
     643     * @return string
     644     */
     645    protected function get_stub_content( $post_type, $stub_name ) {
     646        $content   = '';
     647        $stub_file = WCPT_DIR . "stubs/$post_type/$stub_name.php";
     648
     649        if ( is_readable( $stub_file ) ) {
     650            ob_start();
     651            require $stub_file;
     652            $content = ob_get_clean();
     653        }
     654
     655        return $content;
    766656    }
    767657
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-forms-to-drafts/wordcamp-forms-to-drafts.php

    r6765 r8384  
    270270     *   insert custom fields programmatically.
    271271     * - Sideload the logo from submitted URL and set it as the featured image.
     272     * - Add a Company Description field to the Call For Sponsors form stub, or populate content from something else?
     273     * - Also ensure content is formatted for the block editor.
    272274     *
    273275     * @param int   $submission_id
     
    379381     */
    380382    protected function create_draft_speaker( $speaker ) {
     383        $content = $speaker['Your Bio'] ?? '';
     384
     385        if ( $content ) {
     386            $content = wpautop( $content );
     387            $content = str_replace( '<p>', "<!-- wp:paragraph -->\n<p>", $content );
     388            $content = str_replace( '</p>', "</p>\n<!-- /wp:paragraph -->", $content );
     389        }
     390
    381391        $speaker_id = wp_insert_post(
    382392            array(
    383393                'post_type'    => 'wcb_speaker',
    384394                'post_title'   => $speaker['Name'],
    385                 'post_content' => $speaker['Your Bio'],
     395                'post_content' => $content,
    386396                'post_status'  => 'draft',
    387397                'post_author'  => $this->get_user_id_from_username( 'wordcamp' ),
     
    407417     */
    408418    protected function create_draft_session( $session, $speaker ) {
     419        $content = $session['Topic Description'] ?? '';
     420
     421        if ( $content ) {
     422            $content = wpautop( $content );
     423            $content = str_replace( '<p>', "<!-- wp:paragraph -->\n<p>", $content );
     424            $content = str_replace( '</p>', "</p>\n<!-- /wp:paragraph -->", $content );
     425        }
     426
    409427        $session_id = wp_insert_post(
    410428            array(
    411429                'post_type'    => 'wcb_session',
    412430                'post_title'   => $session['Topic Title'],
    413                 'post_content' => $session['Topic Description'],
     431                'post_content' => $content,
    414432                'post_status'  => 'draft',
    415433                'post_author'  => $this->get_user_id_from_username( $session['WordPress.org Username'] ),
Note: See TracChangeset for help on using the changeset viewer.