Get Channel canonical for widget if claimID wasn't set

This commit is contained in:
Paul Kirby 2020-01-27 22:54:40 -06:00
parent f7a3625754
commit f42c3a65cf
2 changed files with 19 additions and 8 deletions

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>
<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!