feat: added option for custom content warning button text

This commit is contained in:
wolfgang101 2022-12-07 17:01:50 +01:00
parent a2519704b3
commit d68e0e895a
5 changed files with 21 additions and 5 deletions

View File

@ -33,7 +33,7 @@ Place the following shortcode right into the page. Either as shortcode block or
| text-loading | "Loading Mastodon feed..." | loading text |
| text-boosted | "boosted 🚀" | boosted status indicator text |
| text-viewOnInstance | "view on instance" | view status on instance link text |
| text-showContent | "Show content" | text for content warning buttons |
\* Attributes marked **bold** are required

View File

@ -59,3 +59,7 @@
// default view status on instance link text
// can be overridden in shortcode
define('INCLUDE_MASTODON_FEED_TEXT_VIEW_ON_INSTANCE', 'view on instance',);
// default text for content warning buttons
define('INCLUDE_MASTODON_FEED_TEXT_SHOW_CONTENT', 'Show content');

View File

@ -5,4 +5,5 @@
// define('INCLUDE_MASTODON_FEED_DEFAULT_INSTANCE', 'social.fsoc.lol');
// define('INCLUDE_MASTODON_FEED_TEXT_LOADING', 'LLLL Loading');
// define('INCLUDE_MASTODON_FEED_TEXT_BOOSTED', 'BBBB..oosted');
// define('INCLUDE_MASTODON_FEED_TEXT_VIEW_ON_INSTANCE', 'view elsewhere');
// define('INCLUDE_MASTODON_FEED_TEXT_VIEW_ON_INSTANCE', 'view elsewhere');
// define('INCLUDE_MASTODON_FEED_TEXT_SHOW_CONTENT', 'Show contents');

View File

@ -56,6 +56,10 @@ $constants = [
'key' => 'INCLUDE_MASTODON_FEED_TEXT_VIEW_ON_INSTANCE',
'value' => 'view on instance',
],
[
'key' => 'INCLUDE_MASTODON_FEED_TEXT_SHOW_CONTENT',
'value' => 'Show content',
],
];
foreach($constants as $constant) {
if(!defined($constant['key'])) {
@ -441,7 +445,7 @@ function include_mastodon_feed_init_scripts() {
this.parentElement.nextSibling.style = 'display: block;';
return false;
}
cwLinkElem.innerHTML = 'Show content';
cwLinkElem.innerHTML = options.text.showContent;
cwElem.appendChild(cwLinkElem);
contentWrapperElem.appendChild(cwElem);
@ -512,7 +516,8 @@ function include_mastodon_feed_display_feed($atts) {
'account' => false,
'text-loading' => esc_html(INCLUDE_MASTODON_FEED_TEXT_LOADING),
'text-boosted' => esc_html(INCLUDE_MASTODON_FEED_TEXT_BOOSTED),
'text-viewOnInstance' => esc_html(INCLUDE_MASTODON_FEED_TEXT_VIEW_ON_INSTANCE),
'text-viewoninstance' => esc_html(INCLUDE_MASTODON_FEED_TEXT_VIEW_ON_INSTANCE),
'text-showcontent' => esc_html(INCLUDE_MASTODON_FEED_TEXT_SHOW_CONTENT),
'darkmode' => false,
), $atts
);
@ -535,7 +540,8 @@ function include_mastodon_feed_display_feed($atts) {
{
text: {
boosted: "<?php echo esc_html( $atts['text-boosted'] ); ?>",
viewOnInstance: "<?php echo esc_html( $atts['text-viewOnInstance'] ); ?>",
viewOnInstance: "<?php echo esc_html( $atts['text-viewoninstance'] ); ?>",
showContent: "<?php echo esc_html( $atts['text-showcontent'] ); ?>",
}
}
);

View File

@ -44,6 +44,9 @@ Text indicating boosted statuses (Default: boosted 🚀)
* **text-viewOnInstance**
View status on instance link text (Default: view on instance)
* **text-showContent**
Text for content warning buttons (Default: Show content)
= Additional customizations =
You can create a file `config.php` to overrwrite select settings
@ -80,6 +83,8 @@ Use the following URL to get your ID:
= 1.2.0 =
* fixed broken if post included media attachments other than images
* fixed custom "view on instance" option
* added option for custom content warning button text
* added support for gifv media attachments
= 1.1.0 =