Skip to content

Commit

Permalink
feat: display linked posts after successful translation link
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquimds committed Nov 6, 2023
1 parent b9a7e05 commit ab28bf1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions web/app/themes/awasqa/src/wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function get_translated_page_by_slug($slug, $lang)

function connect_translations_page()
{
$original_post_links = [];
if ($_POST) {
$processed_ids = [];
foreach ($_POST as $key => $value) {
Expand Down Expand Up @@ -157,6 +158,8 @@ function connect_translations_page()

$processed_keys[] = $key;
$processed_keys[] = $key_b;

$original_post_links[get_the_permalink($original_id)] = get_the_title($original_id);
}
}
$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'post']);
Expand All @@ -170,8 +173,19 @@ function connect_translations_page()
}
?>
<h1>Connect Translations</h1>
<?php if ($original_post_links) : ?>
<p><strong>Successfully linked:</strong></p>
<ul>
<?php foreach ($original_post_links as $link => $title) : ?>
<li><a href="<?= $link ?>"><?= $title ?></a></li>
<?php endforeach ?>
</ul>
<?php endif; ?>
<p>
<strong>Mark matching posts with the same number then click the "Connect" button.</strong>
<strong>
Mark matching posts with the same number then click the
"Connect" button at the bottom of the page.
</strong>
</p>
<form method="POST">
<ul>
Expand All @@ -187,7 +201,7 @@ function connect_translations_page()
</li>
<?php endforeach; ?>
</ul>
<button>Connect</button>
<button class="button button-primary save">Connect</button>
</form>
<script>
const selects = document.querySelectorAll('.connect-translation-select')
Expand Down

0 comments on commit ab28bf1

Please sign in to comment.