-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #290 from wikitongues/main
Prod Deploy
- Loading branch information
Showing
19 changed files
with
583 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
// Lexicons: create language object | ||
if (!function_exists('get_language_gallery_html')) { | ||
function get_language_gallery_html($language_post_id) { | ||
if (!$language_post_id) { | ||
return ''; | ||
} | ||
if (is_array($language_post_id)) { | ||
$language_post_id = $language_post_id['ID']; | ||
// log_data("is array", "dom"); | ||
} else { | ||
$language_post_id = $language_post_id; | ||
// log_data("not array", "dom"); | ||
} | ||
$post_title = get_the_title($language_post_id); | ||
$standard_name = get_field('standard_name', $language_post_id); | ||
return "<div class='language'><span class='identifier'>{$post_title}</span><p>{$standard_name}</p></div>"; | ||
} | ||
} | ||
|
||
// Resources: Get Domain | ||
if (!function_exists('getDomainFromUrl')) { | ||
function getDomainFromUrl($url) { | ||
$host = parse_url($url, PHP_URL_HOST); | ||
if (substr($host, 0, 4) === 'www.') { | ||
$host = substr($host, 4); | ||
} | ||
return $host; | ||
} | ||
} |
133 changes: 69 additions & 64 deletions
133
wp-content/plugins/wt-gallery/includes/render_gallery_items.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,85 @@ | ||
<?php | ||
function render_gallery_items($query, $atts, $gallery_id, $paged, $data_attributes) { | ||
ob_start(); | ||
function render_gallery_items($query, $atts, $gallery_id, $paged, $data_attributes) { | ||
ob_start(); | ||
|
||
$classes = 'gallery-container'; | ||
if (!empty($atts['pagination']) && $atts['pagination'] === 'true' && $query->max_num_pages > 1) { | ||
$classes .= ' paginated'; | ||
} | ||
// Check if this is an AJAX call. | ||
$is_ajax = defined('DOING_AJAX') && DOING_AJAX; | ||
|
||
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);">'; | ||
// Only output the outer container if not an AJAX call. | ||
if (!$is_ajax) { | ||
$classes = 'gallery-container'; | ||
if (!empty($atts['pagination']) && $atts['pagination'] === 'true' && $query->max_num_pages > 1) { | ||
$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(); | ||
$post_type = $atts['post_type']; // Use post type dynamically | ||
$title = get_custom_title($atts['post_type']); | ||
while ($query->have_posts()) { | ||
$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 { | ||
echo '<li>No template found for ' . esc_html($post_type) . '</li>'; | ||
} | ||
} | ||
// 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 { | ||
echo '<li>No template found for ' . esc_html($post_type) . '</li>'; | ||
} | ||
} | ||
|
||
echo '</ul>'; | ||
if ($atts['pagination'] === 'true' && $query->max_num_pages > 1) { | ||
echo generate_gallery_pagination($query, $gallery_id, $paged); | ||
} | ||
echo '</div>'; | ||
echo '</ul>'; | ||
if ($atts['pagination'] === 'true' && $query->max_num_pages > 1) { | ||
echo generate_gallery_pagination($query, $gallery_id, $paged); | ||
} | ||
echo '</div>'; | ||
|
||
wp_reset_postdata(); | ||
wp_reset_postdata(); | ||
|
||
$output = ob_get_clean(); | ||
return $output; | ||
} | ||
$output = ob_get_clean(); | ||
return $output; | ||
} | ||
|
||
function generate_gallery_pagination($query, $gallery_id, $paged) { | ||
$max_pages = $query->max_num_pages; | ||
$pagination_html = '<ul class="gallery-pagination" data-gallery-id="' . esc_attr($gallery_id) . '">'; | ||
function generate_gallery_pagination($query, $gallery_id, $paged) { | ||
$max_pages = $query->max_num_pages; | ||
$pagination_html = '<ul class="gallery-pagination" data-gallery-id="' . esc_attr($gallery_id) . '">'; | ||
|
||
$pages_to_show = 9; | ||
$half_pages_to_show = floor($pages_to_show / 2); | ||
$pages_to_show = 9; | ||
$half_pages_to_show = floor($pages_to_show / 2); | ||
|
||
// Start and end page calculation | ||
$start_page = max(1, $paged - $half_pages_to_show); | ||
$end_page = min($max_pages, $paged + $half_pages_to_show); | ||
// Start and end page calculation | ||
$start_page = max(1, $paged - $half_pages_to_show); | ||
$end_page = min($max_pages, $paged + $half_pages_to_show); | ||
|
||
// Adjust if we are near the beginning or end | ||
if ($paged <= $half_pages_to_show) { | ||
$end_page = min($max_pages, $pages_to_show); | ||
} elseif ($paged + $half_pages_to_show >= $max_pages) { | ||
$start_page = max(1, $max_pages - $pages_to_show + 1); | ||
} | ||
// Adjust if we are near the beginning or end | ||
if ($paged <= $half_pages_to_show) { | ||
$end_page = min($max_pages, $pages_to_show); | ||
} elseif ($paged + $half_pages_to_show >= $max_pages) { | ||
$start_page = max(1, $max_pages - $pages_to_show + 1); | ||
} | ||
|
||
// Generate pagination links | ||
// Add "Previous" button if not on the first page | ||
$prev = ''; | ||
if ($paged > 1) { | ||
$prev = '<a href="#" class="page-numbers" data-page="' . ($paged - 1) . '" data-gallery-id="' . esc_attr($gallery_id) . '">Previous</a>'; | ||
} | ||
$pagination_html .= '<li class="page-helper">'.$prev.'</li>'; | ||
// Generate pagination links | ||
// Add "Previous" button if not on the first page | ||
$prev = ''; | ||
if ($paged > 1) { | ||
$prev = '<a href="#" class="page-numbers" data-page="' . ($paged - 1) . '" data-gallery-id="' . esc_attr($gallery_id) . '">Previous</a>'; | ||
} | ||
$pagination_html .= '<li class="page-helper">'.$prev.'</li>'; | ||
|
||
// Loop through the range of pages to display | ||
for ($i = $start_page; $i <= $end_page; $i++) { | ||
$active_class = ($i == $paged) ? ' active' : ''; // Highlight current page | ||
$pagination_html .= '<li><a href="#" class="page-numbers' . $active_class . '" data-page="' . $i . '" data-gallery-id="' . esc_attr($gallery_id) . '">' . $i . '</a></li>'; | ||
} | ||
// Loop through the range of pages to display | ||
for ($i = $start_page; $i <= $end_page; $i++) { | ||
$active_class = ($i == $paged) ? ' active' : ''; // Highlight current page | ||
$pagination_html .= '<li><a href="#" class="page-numbers' . $active_class . '" data-page="' . $i . '" data-gallery-id="' . esc_attr($gallery_id) . '">' . $i . '</a></li>'; | ||
} | ||
|
||
// Add "Next" button if not on the last page | ||
$next = ''; | ||
if ($paged < $max_pages) { | ||
$next .= '<a href="#" class="page-numbers" data-page="' . ($paged + 1) . '" data-gallery-id="' . esc_attr($gallery_id) . '">Next</a>'; | ||
} | ||
$pagination_html .= '<li class="page-helper">'.$next.'</li>'; | ||
// Add "Next" button if not on the last page | ||
$next = ''; | ||
if ($paged < $max_pages) { | ||
$next .= '<a href="#" class="page-numbers" data-page="' . ($paged + 1) . '" data-gallery-id="' . esc_attr($gallery_id) . '">Next</a>'; | ||
} | ||
$pagination_html .= '<li class="page-helper">'.$next.'</li>'; | ||
|
||
$pagination_html .= '</ul>'; | ||
return $pagination_html; | ||
} | ||
$pagination_html .= '</ul>'; | ||
return $pagination_html; | ||
} |
30 changes: 30 additions & 0 deletions
30
wp-content/plugins/wt-gallery/includes/templates/gallery-lexicons.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<li class="gallery-item"> | ||
<?php | ||
$source_languages = array(get_field('source_languages')); | ||
$target_languages = get_field('target_languages'); | ||
$dropbox_link = get_field('dropbox_link'); | ||
$external_link = get_field('external_link'); | ||
$url = ''; | ||
if ($dropbox_link) { | ||
$url = $dropbox_link; | ||
} elseif ($external_link) { | ||
$url = $external_link; | ||
} | ||
; | ||
echo "<a href={$url}>"; | ||
|
||
echo '<section><p>Lexicon</p>'; | ||
|
||
foreach ($source_languages as $language_post_id) { | ||
echo get_language_gallery_html($language_post_id); | ||
} | ||
echo '</section>'; | ||
|
||
echo '<section><p>to</p><span class="target-languages">'; | ||
foreach ($target_languages as $language_post_id) { | ||
echo get_language_gallery_html($language_post_id); | ||
} | ||
echo '</span></section></a>'; | ||
|
||
?> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
wp-content/themes/blankslate-child/modules/banner--languages-single.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.