Widget slug proper dynamic URLS #20

Merged
prkirby merged 2 commits from widget-slug into master 2020-01-28 05:58:14 +01:00
2 changed files with 19 additions and 8 deletions
Showing only changes of commit f42c3a65cf - Show all commits

View file

@ -149,8 +149,12 @@ class LBRY_Daemon
* @param string $claim_id
* @return string Canonical URL, null if not found
*/
public function canonical_url($claim_id)
public function canonical_url($claim_id = null)
{
if (!$claim_id) {
return null;
}
try {
$result = $this->request(
'claim_search',
@ -160,8 +164,6 @@ class LBRY_Daemon
)
);
error_log(print_r($result, true));
$items = $result->result->items;
if (!$items) {
return null;

View file

@ -1,15 +1,24 @@
<?php
$url = get_post_meta(get_the_id(), LBRY_PRETTY_URL, true);
// Backwards compatible if LBRY_PRETTY_URL wasn't set
$url = get_post_meta(get_the_id(), LBRY_CANONICAL_URL, true);
if (!$url) {
$url = get_post_meta(get_the_id(), LBRY_PERM_URL, true);
// Get channel canonical for backwards compatibility
$channel_id = get_post_meta(get_the_id(), LBRY_POST_CHANNEL, true);
$url = LBRY()->daemon->canonical_url($channel_id);
}
if ($url) {
$url = str_replace('lbry://', 'lbry.tv/', $url);
}
?>
<div class="lbry-published-banner">
<h5>Stored Safely on Blockchain</h5>
kauffj commented 2020-01-28 15:26:05 +01:00 (Migrated from github.com)
Review

str_replace(['lbry://', '#'], ['open.lbry.com/', ':'], $url);

`str_replace(['lbry://', '#'], ['open.lbry.com/', ':'], $url);`
<p>
This post is published to <a href="https://lbry.io/get">LBRY</a> blockchain at <a href="<?= $url ?>"><?= $url ?></a>.
This post is published to <a href="https://lbry.io/get">LBRY</a> blockchain
<?php if($url): ?>
at <a href="https://<?= $url ?>"><?= $url ?></a>.
<?php else: ?>
.
<?php endif; ?>
</p>
<p>
<a href="https://lbry.io/get" target="_blank">Try LBRY</a> to experience content freedom, earn crypto, and support The Anti-Media!