Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add First Time being a organizer/speaker/sponsor question to CPT #939

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public_html/wp-content/plugins/wc-post-types/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

li.wcpt-form-header {
display: table-caption;
width: max-content;
font-weight: 700;
}

Expand Down
4 changes: 4 additions & 0 deletions public_html/wp-content/plugins/wc-post-types/css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@
margin-right: 0;
}

.wc-panel-speaker-info .components-base-control,
.wc-panel-organizer-info .components-base-control,
.wc-panel-volunteer-info .components-base-control {
margin-bottom: 2em;
}

.wc-panel-speaker-info .components-base-control:last-child,
.wc-panel-organizer-info .components-base-control:last-child,
.wc-panel-volunteer-info .components-base-control:last-child {
margin-bottom: 0;
}
3 changes: 3 additions & 0 deletions public_html/wp-content/plugins/wc-post-types/inc/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function speaker_personal_data_exporter( $email_address, $page ) {
'post_content' => __( 'Speaker Bio', 'wordcamporg' ),
'_wcb_speaker_email' => __( 'Gravatar Email', 'wordcamporg' ),
'_wcpt_user_id' => __( 'WordPress.org Username', 'wordcamporg' ),
'_wcb_speaker_first_time' => __( 'First Time Speaker', 'wordcamporg' ),
);

return _personal_data_exporter( 'wcb_speaker', $props_to_export, $email_address, $page );
Expand All @@ -79,6 +80,7 @@ function sponsor_personal_data_exporter( $email_address, $page ) {
'_wcpt_sponsor_last_name' => __( 'Last Name', 'wordcamporg' ),
'_wcpt_sponsor_email_address' => __( 'Email Address', 'wordcamporg' ),
'_wcpt_sponsor_phone_number' => __( 'Phone Number', 'wordcamporg' ),
'_wcpt_sponsor_first_time' => __( 'First Time Sponsor', 'wordcamporg' ),
);

return _personal_data_exporter( 'wcb_sponsor', $props_to_export, $email_address, $page );
Expand All @@ -96,6 +98,7 @@ function organizer_personal_data_exporter( $email_address, $page ) {
$props_to_export = array(
'post_title' => __( 'Organizer Name', 'wordcamporg' ),
'_wcpt_user_id' => __( 'WordPress.org Username', 'wordcamporg' ),
'_wcb_organizer_first_time' => __( 'First Time Organizer', 'wordcamporg' ),
);

return _personal_data_exporter( 'wcb_organizer', $props_to_export, $email_address, $page );
Expand Down
42 changes: 42 additions & 0 deletions public_html/wp-content/plugins/wc-post-types/inc/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ function register_sponsor_post_meta() {
'auth_callback' => __NAMESPACE__ . '\meta_auth_callback',
)
);
register_post_meta(
'wcb_sponsor',
'_wcpt_sponsor_first_time',
iandunn marked this conversation as resolved.
Show resolved Hide resolved
array(
'type' => 'string',
'show_in_rest' => array(
'schema' => array(
'context' => array( 'edit' ),
),
),
'single' => true,
'auth_callback' => __NAMESPACE__ . '\meta_auth_callback',
iandunn marked this conversation as resolved.
Show resolved Hide resolved
)
);
}

/**
Expand Down Expand Up @@ -106,6 +120,20 @@ function register_speaker_post_meta() {
'auth_callback' => __NAMESPACE__ . '\meta_auth_callback',
)
);
register_post_meta(
'wcb_speaker',
'_wcb_speaker_first_time',
array(
'type' => 'string',
'show_in_rest' => array(
'schema' => array(
'context' => array( 'edit' ),
),
),
'single' => true,
'auth_callback' => __NAMESPACE__ . '\meta_auth_callback',
)
);
}

/**
Expand Down Expand Up @@ -240,6 +268,20 @@ function register_organizer_post_meta() {
'auth_callback' => __NAMESPACE__ . '\meta_auth_callback',
)
);
register_post_meta(
'wcb_organizer',
'_wcb_organizer_first_time',
array(
'type' => 'string',
'show_in_rest' => array(
'schema' => array(
'context' => array( 'edit' ),
),
),
'single' => true,
'auth_callback' => __NAMESPACE__ . '\meta_auth_callback',
)
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { RadioControl } from '@wordpress/components';

/**
* Internal dependencies
Expand All @@ -12,6 +13,7 @@ import UsernameControl from '../components/username-control';

export default function OrganizerInfoPanel() {
const [ username, setUsername ] = usePostMeta( '_wcpt_user_name', '' );
const [ firstTime, setFirstTime ] = usePostMeta( '_wcb_organizer_first_time', false );

return (
<PluginDocumentSettingPanel
Expand All @@ -24,6 +26,16 @@ export default function OrganizerInfoPanel() {
value={ username }
onChange={ setUsername }
/>
<RadioControl
label={ __( 'Is this their first time being an organizer at a WordPress event?', 'wordcamporg' ) }
selected={ firstTime }
onChange={ ( value ) => setFirstTime( value ) }
options={ [
{ label: 'Yes', value: 'yes' },
{ label: 'No', value: 'no' },
{ label: 'Unsure', value: 'unsure' },
] }
/>
</PluginDocumentSettingPanel>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { TextControl } from '@wordpress/components';
import { RadioControl, TextControl } from '@wordpress/components';

/**
* Internal dependencies
Expand All @@ -14,6 +14,7 @@ import UsernameControl from '../components/username-control';
export default function SpeakerInfoPanel() {
const [ email, setEmail ] = usePostMeta( '_wcb_speaker_email', '' );
const [ username, setUsername ] = usePostMeta( '_wcpt_user_name', '' );
const [ firstTime, setFirstTime ] = usePostMeta( '_wcb_speaker_first_time', false );

return (
<PluginDocumentSettingPanel
Expand All @@ -32,6 +33,16 @@ export default function SpeakerInfoPanel() {
value={ username }
onChange={ setUsername }
/>
<RadioControl
label={ __( 'Is this their first time being a speaker at a WordPress event?', 'wordcamporg' ) }
selected={ firstTime }
onChange={ ( value ) => setFirstTime( value ) }
options={ [
{ label: 'Yes', value: 'yes' },
{ label: 'No', value: 'no' },
{ label: 'Unsure', value: 'unsure' },
] }
/>
</PluginDocumentSettingPanel>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/** @var string $state */
/** @var string $zip_code */
/** @var string $country */
/** @var string $first_time */
/** @var array $available_countries */
?>
<ul class="wcpt-form">
Expand Down Expand Up @@ -278,6 +279,49 @@ class="regular-text"
</li>
</ul>

<ul class="wcpt-form">
<li class="wcpt-form-header">
<?php esc_html_e( 'Is this their first time being a sponsor at a WordPress event?', 'wordcamporg' ); ?>
</li>

<li>
<label for="_wcpt_sponsor_first_time_yes">
<?php esc_html_e( 'Yes', 'wordcamporg' ); ?>
</label>
<input
type="radio"
id="_wcpt_sponsor_first_time_yes"
name="_wcpt_sponsor_first_time"
value="yes"
<?php checked( $first_time, 'yes' ); ?>
/>
</li>
<li>
<label for="_wcpt_sponsor_first_time_no">
<?php esc_html_e( 'No', 'wordcamporg' ); ?>
</label>
<input
type="radio"
id="_wcpt_sponsor_first_time_no"
name="_wcpt_sponsor_first_time"
value="no"
<?php checked( $first_time, 'no' ); ?>
/>
</li>
<li>
<label for="_wcpt_sponsor_first_time_unsure">
<?php esc_html_e( 'I don\'t know', 'wordcamporg' ); ?>
</label>
<input
type="radio"
id="_wcpt_sponsor_first_time_unsure"
name="_wcpt_sponsor_first_time"
value="unsure"
<?php checked( $first_time, 'unsure' ); ?>
/>
</li>
</ul>

<span class="wcpt-form-required">
<?php _e( '* required', 'wordcamporg' ); ?>
</span>
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<!-- wp:jetpack/contact-form {"subject":"WordCamp Speaker Request","hasFormSettingsSet":"yes"} -->
<!-- wp:jetpack/field-name {"label":"Name","required":true} /-->

<!-- wp:jetpack/field-email {"label":"Email Address","required":true} /-->
<!-- wp:jetpack/field-email {"label":"Email","required":true,"requiredText":"(required)","id":"speaker-email"} /-->

<!-- wp:jetpack/field-text {"label":"WordPress.org Username","required":true} /-->
<!-- wp:jetpack/field-text {"label":"WordPress.org Username","requiredText":"(required)","id":"speaker-username"} /-->
renintw marked this conversation as resolved.
Show resolved Hide resolved

<!-- wp:jetpack/field-textarea {"label":"Your Bio","required":true} /-->

Expand All @@ -21,5 +21,7 @@

<!-- wp:jetpack/field-text {"label":"Intended Audience","required":true} /-->

<!-- wp:jetpack/field-radio {"label":"Is this your first time being a speaker at a WordPress event?","requiredText":"(required)","options":["Yes","No","Unsure"],"id":"first-time-speaker"} /-->

<!-- wp:jetpack/field-textarea {"label":"Past Speaking Experience (not necessary to apply)"} /-->
<!-- /wp:jetpack/contact-form -->
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<!-- wp:paragraph {"backgroundColor":"accent","textColor":"background","className":"has-accent-background-color has-background"} -->
<p class="has-accent-background-color has-background has-background-color has-text-color"><em>Organizers Note:</em>
Submissions to this form will automatically create <code>draft</code>
<a href="<?php echo esc_url( admin_url( 'edit.php?post_type=wcb_sponsor' ) ); ?>">Sponsor posts</a>.
You can use those to manage your sponsors, by publishing the ones that you accept, and deleting the ones that you don't.
Changing the <code>name</code>, <code>email</code>, <code>username</code>, or <code>first time sponsoring</code> questions can break the automation, though.
</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Blurb with information for potential sponsors.</p>
<!-- /wp:paragraph -->
Expand All @@ -9,13 +18,15 @@

<!-- wp:jetpack/field-url {"label":"Company Website","required":true} /-->

<!-- wp:jetpack/field-email {"label":"Email","required":true} /-->
<!-- wp:jetpack/field-email {"label":"Email","required":true,"requiredText":"(required)","id":"sponsor-email"} /-->

<!-- wp:jetpack/field-telephone {"label":"Phone Number"} /-->

<!-- wp:jetpack/field-select {"label":"Sponsorship Level","options":["Bronze","Silver","Gold"]} /-->

<!-- wp:jetpack/field-textarea {"label":"Why Would you Like to Sponsor WordCamp?","required":true} /-->

<!-- wp:jetpack/field-radio {"label":"Is this your first time being a sponsor at a WordPress event?","requiredText":"(required)","options":["Yes","No","Unsure"],"id":"first-time-sponsor"} /-->
iandunn marked this conversation as resolved.
Show resolved Hide resolved

<!-- wp:jetpack/field-textarea {"label":"Questions / Comments"} /-->
<!-- /wp:jetpack/contact-form -->
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@ protected function get_stub_posts( $wordcamp, $meta ) {
'content' => $this->get_stub_content( 'post', 'call-for-sponsors' ),
'status' => 'draft',
'type' => 'post',
'meta' => array(
'wcfd-key' => 'call-for-sponsors',
),
),

array(
Expand Down Expand Up @@ -851,6 +854,9 @@ public static function get_stub_me_sponsors_meta( $assigned_sponsor ) {
$sponsor_meta[ "_wcpt_sponsor_$key" ] = get_post_meta( $assigned_sponsor->ID, "mes_$key", true );
}

// Always set the first-time sponsor value to 'no' for Multi Event (ME) Sponsors.
$sponsor_meta['_wcpt_sponsor_first_time'] = 'no';

restore_current_blog();

return $sponsor_meta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function print_front_end_styles() {
?>

<style>
<?php require_once( __DIR__ . '/front-end.css' ); ?>
<?php require_once __DIR__ . '/front-end.css'; ?>
iandunn marked this conversation as resolved.
Show resolved Hide resolved
</style>

<?php
Expand All @@ -55,7 +55,7 @@ public function enqueue_inert_script() {
if ( ! $this->form_requires_login( $this->get_current_form_id() ) ) {
return;
}
$deps_path = __DIR__ . '/build/inert.asset.php';
$deps_path = __DIR__ . '/build/inert.asset.php';
$script_info = require $deps_path;

wp_enqueue_script(
Expand Down Expand Up @@ -472,8 +472,11 @@ protected function create_draft_speaker( $speaker ) {
);

if ( $speaker_id ) {
$first_time = strtolower( $speaker['Is this your first time being a speaker at a WordPress event?'] ) ?? '';
$first_time = in_array( $first_time, array( 'yes', 'no', 'unsure' ), true ) ? $first_time : '';
update_post_meta( $speaker_id, '_wcb_speaker_email', $speaker['Email Address'] ?? '' );
update_post_meta( $speaker_id, '_wcpt_user_id', $this->get_user_id_from_username( $speaker['WordPress.org Username'] ?? '' ) );
update_post_meta( $speaker_id, '_wcb_speaker_first_time', $first_time );
}

return $speaker_id;
Expand Down