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

production deploy #222

Merged
merged 7 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 21 additions & 8 deletions wp-content/plugins/wt-gallery/includes/queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @return WP_Query The query result.
*/

function get_custom_gallery_query($atts = array()) {
function get_custom_gallery_query($atts = array()) {
$defaults = array(
'post_type' => 'languages', // videos, languages, fellows
'posts_per_page' => 6,
Expand All @@ -25,25 +25,38 @@ function get_custom_gallery_query($atts = array()) {
$val_array = explode(',',$atts['meta_value']);
$val_array = array_map('trim', $val_array);

// Default compare operator
$compare_operator = 'LIKE';

// If dealing with fellows or a serialized array, wrap ID in quotes for serialized match
if ($atts['meta_key'] === 'fellow_language') {
// For fellow_language, wrap ID in quotes for serialized match
$compare_operator = 'LIKE';
$val_array = array_map(function($value) {
return '"' . intval($value) . '"'; // Wrap each value in quotes for serialized match
}, $val_array);
} elseif ($atts['meta_key'] === 'nations_of_origin') {
$compare_operator = '=';
}

if (count($val_array) > 1) {
$meta_query = array('relation' => 'OR');
foreach ($val_array as $value) {
$value = trim($value);
if(!empty($value)) {
if (!empty($value)) {
$meta_query[] = array(
'key' => $atts['meta_key'],
'value' => $value,
'compare' => 'LIKE',
'compare' => $compare_operator,
);
}
}
} else {
$meta_query[] = array(
'key' => $atts['meta_key'],
'value' => $atts['meta_value'],
'compare' => 'LIKE',
'value' => $val_array[0],
'compare' => $compare_operator,
);
};
}

$args['meta_query'] = $meta_query;
unset($args['meta_key']);
Expand All @@ -57,10 +70,10 @@ function get_custom_gallery_query($atts = array()) {
}

$query = new WP_Query($args);

return $query;
}


/**
* Retrieves a random video for a given language ISO code.
*
Expand Down
77 changes: 12 additions & 65 deletions wp-content/plugins/wt-gallery/includes/render_gallery_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,30 @@ function render_gallery_items($query, $atts, $gallery_id, $paged, $data_attribut
ob_start();

$classes = 'gallery-container';
// $atts['pagination'] is a string
if (!empty($atts['pagination']) && $atts['pagination'] === 'true' && $query->max_num_pages > 1) {
$classes .= ' paginated';
$classes .= ' paginated';
}

echo '<div class="'.$classes.'" id="' . esc_attr($atts['gallery_id']) . '" data-attributes="' . $data_attributes . '">';

echo '<ul class="gallery-list" style="grid-template-columns: repeat('.$atts['columns'].', 1fr);">';

while ($query->have_posts()) {
$query->the_post();
$thumbnail = get_custom_image($atts['post_type']);
$video_thumbnail_url = '';
$video_thumbnail_object = '';
$language_thumbnail_object = '';
$iso_code_element = '';
$fellow_el = '';
$title = get_custom_title($atts['post_type']);
$language_family = get_field('linguistic_genealogy');
$nations_of_origin = get_field('nations_of_origin');
$fellow_nation = get_field('fellow_location');
$fellow_language_preferred_name = get_field('fellow_language_preferred_name');
$writing_systems = get_field('writing_systems');
$iso_code = get_the_title();
$language_iso_codes = get_field('language_iso_codes');
$post_link = get_permalink();
$featured_languages = get_field('featured_languages');

$video_query = get_videos_by_featured_language($iso_code);

if ($thumbnail) {
if (is_array($thumbnail)) {
$video_thumbnail_url = $thumbnail['url'];
} else {
$video_thumbnail_url = $thumbnail;
}
}

echo '<li class="gallery-item">';

if ($atts['post_type'] === 'videos') {
if ($video_thumbnail_url) {
$video_thumbnail_object = '<div class="thumbnail" style="background-image:url('.esc_url($video_thumbnail_url).');" alt="' . get_the_title() . '"></div>';
$query->the_post();
$post_type = $atts['post_type']; // Use post type dynamically
$title = get_custom_title($atts['post_type']);

// Include the template for the post type
$template_file = plugin_dir_path(__FILE__) . 'templates/gallery-' . $post_type . '.php';
if (file_exists($template_file)) {
include $template_file;
} else {
$video_thumbnail_object = '<div class="no-thumbnail"><p>Thumbnail unavailable</p></div>';
echo '<li>No template found for ' . esc_html($post_type) . '</li>';
}
}
if ($atts['post_type'] === 'fellows') {
if ($video_thumbnail_url) {
$video_thumbnail_object = '<div class="thumbnail" style="background-image:url('.esc_url($video_thumbnail_url).');" alt="' . get_the_title() . '"></div><span>&nbsp;</span>';
} else {
$video_thumbnail_object = '<div class="no-thumbnail"><p>Thumbnail unavailable</p></div><span>&nbsp;</span>';
}
$fellow_el = '<div class="fellow-metadata"><p>'.$fellow_nation.'</p><h3>'.$fellow_language_preferred_name.'</h3><p>Revitalization</p></div>';
}

if ($atts['post_type'] === 'languages') {
$iso_code_element = '<aside>'.esc_html(get_the_title()).'</aside>';
if ($video_query->have_posts()) {
while ($video_query->have_posts()) {
$video_query->the_post();
$thumbnail = get_custom_image('videos');
$video_title = get_custom_title('videos');
$language_thumbnail_object .= '<div class="thumbnail" style="background-image:url('.esc_url($thumbnail).');" alt="' . get_the_title() . '"> <p>' . $video_title . '</p></div>';
}
} else {
$language_thumbnail_object .= '<div class="no-thumbnail"><p>No resources found to display – Yet.</p></div>';
}
}

echo '<a href="' . $post_link . '">' . $video_thumbnail_object . '<div><h3>' . $title . '</h3>' . $iso_code_element . '</div>' . $language_thumbnail_object . $fellow_el . '</a>';

echo '</li>';
}

echo '</ul>';
if ($atts['pagination'] === 'true' && $query->max_num_pages > 1) {
echo generate_gallery_pagination($query, $gallery_id, $paged);
echo generate_gallery_pagination($query, $gallery_id, $paged);
}
echo '</div>';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<li class="gallery-item">
<?php
$thumbnail_url = get_custom_image('fellows');
$fellow_year = get_field('fellow_year');
$location = get_field('fellow_location');
$fellow_language_preferred_name = get_field('fellow_language_preferred_name');
$thumbnail = '';

if ($thumbnail_url) {
$thumbnail = '<div class="thumbnail" style="background-image:url('.esc_url($thumbnail_url).');" alt="' . get_the_title() . '"></div><span class="thumbnail-spacer">&nbsp;</span>';
} else {
$thumbnail = '<div class="no-thumbnail"><p>Thumbnail unavailable</p></div><span class="thumbnail-spacer">&nbsp;</span>';
}

$metadata = '<div class="fellow-metadata"><h3>'.$fellow_language_preferred_name.'</h3>';
$metadata .= '<span><p>'.$location.'</p><p>'.$fellow_year.'</p></span></div>';

echo '<a href="'.esc_url(get_permalink()).'">';
echo $thumbnail;
echo '<div><h3>' . $title . '</h3></div>';
echo $metadata;
echo '</a>';
?>
</li>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<li class="gallery-item">
<?php
$thumbnail_object = '';
$iso_code = get_the_title();
$iso_code_element = '<aside>'.esc_html($iso_code).'</aside>';
$video_query = get_videos_by_featured_language($iso_code);

if ($video_query->have_posts()) {
while ($video_query->have_posts()) {
$video_query->the_post();
$thumbnail = get_custom_image('videos');
$video_title = get_custom_title('videos');
$thumbnail_object .= '<div class="thumbnail" style="background-image:url('.esc_url($thumbnail).');" alt="' . get_the_title() . '"> <p>' . $video_title . '</p></div>';
}
} else {
$thumbnail_object .= '<div class="no-thumbnail"><p>No resources found to display – Yet.</p></div>';
}

echo '<a href="'.esc_url(get_permalink()).'">';
echo '<div><h3>' . $title . '</h3>' . $iso_code_element . '</div>';
echo $thumbnail_object;
echo '</a>';
?>
</li>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<li class="gallery-item">
<?php
$external_resources = get_field('external_resources');
$resource_link = get_field('resource_url');
$resource_title = get_field('resource_title') ? get_field('resource_title') : get_the_title();
$resource_description = get_field('resource_description');
$domain = getDomainFromUrl($resource_link);

echo '<a href="' . esc_url($resource_link) . '">';
echo '<h1>' . esc_html($resource_title) . '</h1>';
if ($resource_description) {
echo '<p class="description">' . esc_html($resource_description) . '</p>';
}
echo '<p class="domain">' . esc_html($domain) . '</p>';
echo '</a>';
?>
</li>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<li class="gallery-item">
<?php
$thumbnail_url = get_custom_image('videos');
$thumbnail_object = '';

if ($thumbnail_url) {
$thumbnail_object= '<div class="thumbnail" style="background-image:url('.esc_url($thumbnail_url).');" alt="' . get_the_title() . '"></div>';
} else {
$thumbnail_object= '<div class="no-thumbnail"><p>Thumbnail unavailable</p></div>';
}

echo '<a href="'.esc_url(get_permalink()).'">';
echo $thumbnail_object;
echo '<div><h3>' . $title . '</h3></div>';
echo '</a>';
?>
</li>
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"id": ""
},
"default_value": "",
"maxlength": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": ""
"append": ""
},
{
"key": "field_61bb8ad93fe60",
Expand Down Expand Up @@ -76,11 +76,14 @@
"post_type": [
"languages"
],
"post_status": "",
"taxonomy": "",
"allow_null": 0,
"return_format": "id",
"multiple": 0,
"return_format": "object",
"ui": 1
"allow_null": 0,
"bidirectional": 0,
"ui": 1,
"bidirectional_target": []
},
{
"key": "field_61bb8b879f81c",
Expand Down Expand Up @@ -121,5 +124,5 @@
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1690319333
}
"modified": 1728509694
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"class": "",
"id": ""
},
"return_format": "id",
"return_format": "array",
"library": "all",
"min_width": "",
"min_height": "",
Expand Down Expand Up @@ -261,7 +261,7 @@
"class": "",
"id": ""
},
"return_format": "array",
"return_format": "id",
"library": "all",
"min_width": "",
"min_height": "",
Expand Down Expand Up @@ -575,5 +575,5 @@
"active": true,
"description": "",
"show_in_rest": 0,
"modified": 1728251478
"modified": 1728232228
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ function languages_custom_column_orderby($query) {
}
}



// ====================
// Update Counts for Custom Fields
// ====================
Expand Down
6 changes: 3 additions & 3 deletions wp-content/themes/blankslate-child/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function manageNav() {
} else {
toggleNavTransparency("remove")
}

}

function changeHeaderClass() {
function changeHeaderClass() {
window.addEventListener("scroll", function () {
manageNav()
});
Expand Down Expand Up @@ -138,7 +138,7 @@ function setActiveLinks() {

if (isLanguagePath) {
// Add active class to the archive nav item
let archiveNavItem = document.querySelector('nav li');
let archiveNavItem = document.querySelector('nav li#menu-item-15090');
if (archiveNavItem) {
archiveNavItem.classList.add('current_page_item');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<?php
$videos = get_field('speakers_recorded');
$videos = is_array($videos) ? $videos : [];
$videos_count = count($videos);
$lexicon_source = get_field('lexicon_source');
$lexicon_target = get_field('lexicon_target');
$lexicon_source = is_array($lexicon_source) ? $lexicon_source : [];
$lexicon_target = is_array($lexicon_target) ? $lexicon_target : [];
$lexicons = array_merge($lexicon_source, $lexicon_target);
$lexicons_count = count($lexicons);

$wikipedia = get_field('wikipedia_url');
$olac = get_field('olac_url');
$glottocode = get_field('glottocode');
Expand Down
Loading
Loading