-
Notifications
You must be signed in to change notification settings - Fork 13
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 #29 from getAlby/issue/12
Issue/12
- Loading branch information
Showing
4 changed files
with
101 additions
and
18 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
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
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 |
---|---|---|
|
@@ -119,18 +119,57 @@ public function add_lnurl_to_rss_item_filter() | |
|
||
public function hook_meta_tags() | ||
{ | ||
if ( | ||
(!empty($this->plugin->getGeneralOptions()['lnurl_meta_tag']) && $this->plugin->getGeneralOptions()['lnurl_meta_tag']) || | ||
(!empty($this->plugin->getGeneralOptions()['lnurl_meta_tag_lnurlp']) && $this->plugin->getGeneralOptions()['lnurl_meta_tag_lnurlp']) | ||
) { | ||
if (!empty($this->plugin->getGeneralOptions()['lnurl_meta_tag_lnurlp'])) { | ||
$lnurl = $this->plugin->getGeneralOptions()['lnurl_meta_tag_lnurlp']; | ||
} else { | ||
$lnurl = get_rest_url(null, '/lnp-alby/v1/lnurlp'); | ||
// All options | ||
$options = $this->plugin->getGeneralOptions(); | ||
|
||
// In case options not saved or disabled | ||
if ( empty($options['lnurl_meta_tag']) ) | ||
{ | ||
return; | ||
} | ||
|
||
// LN Address | ||
$lnurl = ( empty($options['lnurl_meta_tag_lnurlp']) ) | ||
? get_rest_url(null, '/lnp-alby/v1/lnurlp') // Default | ||
: $options['lnurl_meta_tag_lnurlp']; // Custom option | ||
|
||
|
||
// In case of WP_Post use authors lightning address | ||
if ( is_singular( array('post') ) ) | ||
{ | ||
global $post; | ||
$address = get_user_meta( $post->post_author, '_lnp_ln_address', true ); | ||
|
||
if ( $address ) | ||
{ | ||
$lnurl = $address; | ||
} | ||
$lnurl_without_protocol = preg_replace('/^https?:\/\//', '', $lnurl); | ||
echo '<meta name="lightning" content="lnurlp:' . esc_attr($lnurl_without_protocol) . '" />'; | ||
} | ||
|
||
/** | ||
* Filter to enable programmatic update | ||
* Usage: | ||
* | ||
* add_filter( 'lnurl_meta_tag_lnurlp', function( $lnurl ) { | ||
* | ||
* if ( is_page('about-us') ) | ||
* { | ||
* $lnurl = '[email protected]'; | ||
* } | ||
* | ||
* return $lnurl; | ||
* }); | ||
*/ | ||
$lnurl = apply_filters( 'lnurl_meta_tag_lnurlp', $lnurl ); | ||
|
||
// Strip protocol | ||
$lnurl_without_protocol = preg_replace('/^https?:\/\//', '', $lnurl); | ||
|
||
// Echo value | ||
printf( | ||
'<meta name="lightning" content="lnurlp:%s" />', | ||
esc_attr($lnurl_without_protocol) | ||
); | ||
} | ||
|
||
public function add_v4v_rss_ns_tag() | ||
|