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

New speakers block #925

Merged
merged 61 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b14c692
Adds company logo to Speakers sidebar
cjyabraham Jul 16, 2024
47f0ff6
Duplicates Speakers block to create new block
cjyabraham Jul 16, 2024
47afc16
Clone speakers block other files
cjyabraham Jul 16, 2024
907f6c3
Adapting Speakers block 2
cjyabraham Jul 16, 2024
556d3d0
strip out unneeded options
cjyabraham Jul 16, 2024
52d421e
Bulid the new block
cjyabraham Jul 17, 2024
a0340df
Added new speaker fields
cjyabraham Jul 18, 2024
64851b9
Add help text
cjyabraham Jul 18, 2024
c3b02c7
Moved CNCF people design in to new speaker block
cjyabraham Jul 19, 2024
21fa7cb
Get the modal working
cjyabraham Jul 19, 2024
0dd497d
got the company logo showing
cjyabraham Jul 19, 2024
e633646
got the close image to show
cjyabraham Jul 19, 2024
aefd8f6
respect block width setting
cjyabraham Jul 21, 2024
30eed48
open social links in new tabs to be consistent with lfevents conventions
cjyabraham Jul 21, 2024
c5b4f2a
Fix social hover colors
cjyabraham Jul 21, 2024
443d14d
tweak designs
cjyabraham Jul 22, 2024
0c65dee
update comments
cjyabraham Jul 22, 2024
af2379f
amp up the name
cjyabraham Jul 22, 2024
79cea08
remove social links on tile
cjyabraham Jul 26, 2024
dc4b262
got the tiles looking good
cjyabraham Jul 26, 2024
37a7112
fixed image in modal
cjyabraham Jul 26, 2024
9eb5289
get things centered
cjyabraham Jul 26, 2024
9ad8eac
fix modal on mobile
cjyabraham Jul 26, 2024
453326a
style tweaks
cjyabraham Jul 26, 2024
a72f08c
fix image margin
cjyabraham Jul 26, 2024
276f7db
Fix image alt text
cjyabraham Jul 26, 2024
27bf88a
Add sched data bits
cjyabraham Aug 12, 2024
21691af
Got the sync with sched working and schedule showing in Speaker's modal
cjyabraham Aug 12, 2024
31780b4
Styled the schedule
cjyabraham Aug 12, 2024
5d37554
added venue
cjyabraham Aug 12, 2024
5516dea
improve the check
cjyabraham Aug 12, 2024
a9705fb
run the sync
cjyabraham Aug 12, 2024
e61a818
fixed errors with import
cjyabraham Aug 12, 2024
a93ba2a
turn of manual sync
cjyabraham Aug 12, 2024
9ed8926
fix code sniff
cjyabraham Aug 13, 2024
e94d045
Style tweaks
cjyabraham Aug 13, 2024
8012bd7
minor tweaks
cjyabraham Aug 13, 2024
b54a528
Only show active sessions; link directly to session
cjyabraham Aug 14, 2024
917ae22
styling tweaks
cjyabraham Aug 14, 2024
576eb36
link to bookmark on page
cjyabraham Aug 14, 2024
cccc1a4
Swaps in dnd-kit for react-beautiful-dnd to fix sort issue (fixes #929)
cjyabraham Aug 15, 2024
a59b3bb
Fixed issue with hidden select drop-down on speakers block (fixes #933)
cjyabraham Aug 19, 2024
f9f5319
Merge branch 'main' into new-speakers
cjyabraham Aug 20, 2024
2817809
Add a way to trigger Sched sync from Settings
thetwopct Aug 20, 2024
eac8715
Move timestamp update outside of loops
cjyabraham Aug 21, 2024
dd6ff82
fixed hardcoded event id
cjyabraham Aug 21, 2024
e8cabab
fixed update_post_meta command which automatically strips slashes
cjyabraham Aug 21, 2024
c9c1444
#934 Removing hardcoded LMFP URL
thetwopct Aug 21, 2024
001cb49
Rename, refactor, optimise
thetwopct Aug 21, 2024
c8d2c02
#935 fix npm run dev to keep watching files
thetwopct Aug 21, 2024
b9a3e49
Add generic speaker image
thetwopct Aug 21, 2024
1b9f089
Update PHPCS to include SB2
thetwopct Aug 21, 2024
0f21a3b
Improve accessibility of menu, #673
thetwopct Aug 22, 2024
ecfc327
Improve display of outlines site-wide, #673
thetwopct Aug 22, 2024
8e806bf
Additional accessibility improvements, #637
thetwopct Aug 22, 2024
cab1978
Update Speakers Block design
thetwopct Aug 22, 2024
547b12c
Improving Admin screen for Speakers
thetwopct Aug 22, 2024
054cf92
Style Tweaks
thetwopct Aug 23, 2024
86be553
Darken the background a touch
cjyabraham Aug 23, 2024
c07e463
Updates to speakers block 2
thetwopct Aug 29, 2024
3123956
Block makes use of event Sched ID
thetwopct Aug 30, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ Thumbs.db
# Allowing custom plugins
!web/wp-content/plugins/speakers-block
web/wp-content/plugins/speakers-block/node_modules
!web/wp-content/plugins/speakers-block-2
web/wp-content/plugins/speakers-block-2/node_modules
!web/wp-content/plugins/sponsors-dynamic-block
web/wp-content/plugins/sponsors-dynamic-block/node_modules
!web/wp-content/plugins/text-on-image-block
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<file>./web/wp-content/plugins/live-stream-gate-block/</file>
<file>./web/wp-content/plugins/pricing-block/</file>
<file>./web/wp-content/plugins/speakers-block/</file>
<file>./web/wp-content/plugins/speakers-block-2/</file>
<file>./web/wp-content/plugins/sponsors-dynamic-block/</file>
<file>./web/wp-content/plugins/tab-container-block/</file>
<file>./web/wp-content/plugins/text-on-image-block/</file>
Expand Down
1 change: 0 additions & 1 deletion web/wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
define( 'WP_DEBUG_LOG', __DIR__ . '/wp-content/debug.log' ); // Moves log file to writable location.
define( 'SCRIPT_DEBUG', true );
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', true ); // stops admin email sent.
define( 'LOAD_MEDIA_FROM_PRODUCTION_URL', 'https://events.linuxfoundation.org/' ); // Sets url for loading media files on dev instance.

// fixes small problem with LH-HSTS.
if ( ! isset( $_SERVER['HTTP_HOST'] ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,29 @@ public function staff_custom_column( $columns ) {
*/
public function speaker_custom_column_data( $column, $post_id ) {
switch ( $column ) {
case 'title_company':
echo esc_html( get_post_meta( $post_id, 'lfes_speaker_title', true ) ? get_post_meta( $post_id, 'lfes_speaker_title', true ) : '-' );
case 'featured_image':
echo has_post_thumbnail( $post_id ) ?
'<span class="dashicons dashicons-yes-alt" style="color:green"></span>' :
'<span class="dashicons dashicons-no-alt" style="color:red"></span>';
break;
case 'job_title':
echo esc_html( get_post_meta( $post_id, 'lfes_speaker_job_title', true ) ? get_post_meta( $post_id, 'lfes_speaker_job_title', true ) : '-' );
break;
case 'company':
echo esc_html( get_post_meta( $post_id, 'lfes_speaker_company', true ) ? get_post_meta( $post_id, 'lfes_speaker_company', true ) : '-' );
break;
case 'company_logo':
echo get_post_meta( $post_id, 'lfes_speaker_company_logo', true ) ? '<span class="dashicons dashicons-yes-alt" style="color:green"></span>' : '<span class="dashicons dashicons-no-alt" style="color:red"></span>';
break;
case 'linkedin_url':
echo get_post_meta( $post_id, 'lfes_speaker_linkedin', true ) ? '<span class="dashicons dashicons-yes-alt" style="color:green"></span>' : '<span class="dashicons dashicons-no-alt" style="color:red"></span>';
break;
case 'twitter_url':
echo get_post_meta( $post_id, 'lfes_speaker_twitter', true ) ? '<span class="dashicons dashicons-yes-alt" style="color:green"></span>' : '<span class="dashicons dashicons-no-alt" style="color:red"></span>';
break;
case 'github_url':
echo get_post_meta( $post_id, 'lfes_speaker_github', true ) ? '<span class="dashicons dashicons-yes-alt" style="color:green"></span>' : '<span class="dashicons dashicons-no-alt" style="color:red"></span>';
break;
case 'website_url':
echo get_post_meta( $post_id, 'lfes_speaker_website', true ) ? '<span class="dashicons dashicons-yes-alt" style="color:green"></span>' : '<span class="dashicons dashicons-no-alt" style="color:red"></span>';
break;
Expand All @@ -405,9 +419,13 @@ public function speaker_custom_column( $columns ) {
unset( $columns['date'] );
unset( $columns['author'] );
// add new columns.
$columns['title_company'] = 'Title, Company';
$columns['featured_image'] = 'Speaker Image';
$columns['job_title'] = 'Title';
$columns['company'] = 'Company';
$columns['company_logo'] = 'Company Logo';
$columns['linkedin_url'] = 'Linkedin URL';
$columns['twitter_url'] = 'Twitter/X URL';
$columns['twitter_url'] = 'X URL';
$columns['github_url'] = 'GitHub URL';
$columns['website_url'] = 'Website URL';
// add back in old columns.
$columns['author'] = $author;
Expand Down Expand Up @@ -600,4 +618,11 @@ private function get_kids( $post_id ) {

return $kid_ids;
}

/**
* Sync Sched info for Speakers.
*/
public function sync_sched() {
include_once 'partials/sync-sched.php';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,28 @@
'use_toggle' => false,
'input_label' => __( 'Hide "All Upcoming Events" link' ),
),
array(
'type' => 'text',
'id' => 'sched_event_id',
'data_type' => 'meta',
'data_key' => 'sched_event_id',
'label' => 'Sched Event ID',
'register_meta' => true,
'ui_border_top' => true,
'default_value' => '',
'placeholder' => 'kccncna2024',
),
array(
'type' => 'text',
'id' => 'sched_event_api_key',
'data_type' => 'meta',
'data_key' => 'sched_event_api_key',
'label' => 'Sched Event API Key',
'register_meta' => true,
'ui_border_top' => false,
'default_value' => '',
'placeholder' => '84d755edbd943d009fbd27d557f27a37',
thetwopct marked this conversation as resolved.
Show resolved Hide resolved
),
),
),
),
Expand Down Expand Up @@ -824,14 +846,34 @@
'settings' => array(
array(
'type' => 'text',
'id' => 'title',
'id' => 'job_title',
'data_type' => 'meta',
'data_key' => 'title',
'label' => __( 'Title, Company' ),
'data_key' => 'job_title',
'label' => __( 'Job Title' ),
'register_meta' => true,
'ui_border_top' => false,
'default_value' => '',
'placeholder' => __( 'Title, Company' ),
'placeholder' => __( 'Senior Software Engineer' ),
),
array(
'type' => 'text',
'id' => 'company',
'data_type' => 'meta',
'data_key' => 'company',
'label' => __( 'Company' ),
'register_meta' => true,
'ui_border_top' => false,
'default_value' => '',
'placeholder' => __( 'Microsoft' ),
),
array(
'type' => 'image',
'id' => 'company_logo',
'data_type' => 'meta',
'data_key' => 'company_logo',
'label' => __( 'Company logo' ),
'register_meta' => true,
'ui_border_top' => false,
),
array(
'type' => 'text',
Expand All @@ -840,7 +882,7 @@
'data_key' => 'linkedin',
'label' => __( 'LinkedIn URL' ),
'register_meta' => true,
'ui_border_top' => false,
'ui_border_top' => true,
'default_value' => '',
'placeholder' => __( 'https://www.linkedin.com/in/username/' ),
),
Expand Down Expand Up @@ -877,6 +919,28 @@
'default_value' => '',
'placeholder' => __( 'https://cncf.io' ),
),
array(
'type' => 'text',
'id' => 'sched_username',
'data_type' => 'meta',
'data_key' => 'sched_username',
'label' => __( 'Sched username' ),
'register_meta' => true,
'ui_border_top' => true,
'default_value' => '',
),
array(
'type' => 'text',
'id' => 'title',
'data_type' => 'meta',
'data_key' => 'title',
'label' => __( '!!!OLD!!! Title, Company' ),
'register_meta' => true,
'ui_border_top' => true,
'default_value' => '',
'placeholder' => __( 'For old speakers block' ),
'help' => __( 'This field is deprecated and is only used for the old Speakers block.' ),
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/**
* Sync Sched information for Speakers
*
* @link https://events.linuxfoundation.org/
* @since 1.1.0
*
* @package Lf_Mu
* @subpackage Lf_Mu/admin/partials
*/

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
$args = array(
'post_type' => 'page',
'post_parent' => 0,
'meta_query' => array(
array(
'key' => 'lfes_event_has_passed',
'compare' => '!=',
'value' => '1',
),
array(
'key' => 'lfes_sched_event_id',
'compare' => '!=',
'value' => '',
),
array(
'key' => 'lfes_sched_event_api_key',
'compare' => '!=',
'value' => '',
),
),
);

$the_query = new WP_Query( $args );

while ( $the_query->have_posts() ) {
$the_query->the_post();
$sched_event_id = get_post_meta( get_the_ID(), 'lfes_sched_event_id', true );
$sched_event_api_key = get_post_meta( get_the_ID(), 'lfes_sched_event_api_key', true );

$url = 'https://' . $sched_event_id . '.sched.com/api/session/export?api_key=' . $sched_event_api_key . '&format=json&strip_html=Y&custom_data=Y';
$data = wp_remote_get( $url );
if ( is_wp_error( $data ) || ( wp_remote_retrieve_response_code( $data ) != 200 ) ) {
return false;
}

$sessions = json_decode( wp_remote_retrieve_body( $data ) );
$speakers = array();

foreach ( $sessions as $session ) {
// Go through all sessions and create a new array with keys of speakers.
// Each object in the array will have another array of all the sessions by that speaker.
if ( property_exists( $session, 'speakers' ) ) {
foreach ( $session->speakers as $sp ) {
if ( ! array_key_exists( $sp->username, $speakers ) ) {
$speakers[ $sp->username ] = array();
}
$speakers[ $sp->username ][] = $session;
}
}
}

foreach ( $speakers as $username => $speaker ) {
// Step throught the speaker array and jsonify each element.
// Write that string to the speaker's postmeta using the event_id as the meta key.
$args = array(
'post_type' => 'lfe_speaker',
'meta_query' => array(
array(
'key' => 'lfes_speaker_sched_username',
'value' => $username,
),
),
);
$speaker_query = new WP_Query( $args );

while ( $speaker_query->have_posts() ) {
$speaker_query->the_post();
$speaker_id = get_the_ID();
update_post_meta( $speaker_id, $sched_event_id, wp_slash( json_encode( $speaker ) ) );
}
wp_reset_postdata(); // Restore original Post Data.
}
}
update_option( 'lfevents_sync_sched_last_run', current_time( 'timestamp' ) );
wp_reset_postdata(); // Restore original Post Data.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private function define_admin_hooks() {
$this->loader->add_action( 'save_post', $plugin_admin, 'set_event_year', 10, 3 );

// Example of how to run a sync locally on demand.
// $this->loader->add_action( 'init', $plugin_admin, 'sync_kcds' ); //phpcs:ignore.
// $this->loader->add_action( 'init', $plugin_admin, 'sync_sched' ); //phpcs:ignore.

// schedule KCD sync on lfeventsci.
if ( isset( $_ENV['PANTHEON_SITE_NAME'] ) && 'lfeventsci' === $_ENV['PANTHEON_SITE_NAME'] ) {
Expand All @@ -186,6 +186,12 @@ private function define_admin_hooks() {
wp_schedule_event( time(), 'daily', 'lfevents_sync_kcds' );
}
}

// Sync Sched data for Speakers.
$this->loader->add_action( 'lfevents_sync_sched', $plugin_admin, 'sync_sched' );
if ( ! wp_next_scheduled( 'lfevents_sync_sched' ) ) {
wp_schedule_event( time(), 'twicedaily', 'lfevents_sync_sched' );
}
}

/**
Expand Down
14 changes: 14 additions & 0 deletions web/wp-content/plugins/speakers-block-2/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
27 changes: 27 additions & 0 deletions web/wp-content/plugins/speakers-block-2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Coverage directory used by tools like istanbul
coverage

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Output of 'npm pack'
*.tgz

# dotenv environment variables file
.env
Loading