fix: date-locale and date-options params, misc maintenance cleanup

This commit is contained in:
wolfgang101 2024-11-23 22:40:25 +01:00
parent dee77bb7c2
commit bca1e1bbd6
4 changed files with 28 additions and 22 deletions

View File

@ -7,7 +7,7 @@
https://directory.fsf.org/wiki/License:Expat
Copyright 2022 wolfgang.lol
Copyright 2024 wolfgang.lol
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@ -25,11 +25,11 @@ Place the following shortcode right into the page. Either as shortcode block or
### Supported shortcode attributes
| Attribute | Default value | Example | Description |
| Attribute | Default value | Example | Description |
| ------------------- | ----------------------------- | ------------------------- | ----------------------------------------------------------------- |
| **instance** | | instance="example.org" | (required attribute) Domain name of the instance without https:// |
| **account** | | id="012345678910" | (required attribute) Your account ID ([a long number](#how-do-i-find-my-account-id)) |
| tag | | tag="travel" | use **tag** instead of **account** if you want to embed a tag feed instead of a personal feed |
| **instance** | | instance="example.org" | (required attribute) Domain name of the instance without https:// |
| limit | 20 | limit="10" | Maximum number of statuses |
| excludeBoosts | false | excludeBoosts="true" | Exclude boosted statuses |
| excludeReplies | false | excludeReplies="true" | Exclude replies to other accounts |
@ -106,6 +106,8 @@ If you are familiar with Github you can clone the repository right into your Wor
## FAQ
### How do I find my account ID?
Please feel free to use [this handy lookup tool](https://wolfgang.lol/code/include-mastodon-feed-wordpress-plugin/)
As an instance admin you can easily read your user ID in the admin backend. As regular user you can try an API v2 search to find your ID
Use the following URL to get your ID:

View File

@ -3,9 +3,11 @@
Plugin Name: Include Mastodon Feed
Plugin URI: https://wolfgang.lol/code/include-mastodon-feed-wordpress-plugin
Description: Plugin providing [include-mastodon-feed] shortcode
Version: 1.9.7
Version: 1.9.8
Author: wolfgang.lol
Author URI: https://wolfgang.lol
License: MIT
License URI: https://directory.fsf.org/wiki/License:Expat
*/
namespace IncludeMastodonFeedPlugin;
@ -157,7 +159,6 @@ function error($msg) {
function init_styles() {
ob_start();
?>
<style>
:root {
@ -311,12 +312,10 @@ function init_styles() {
}
</style>
<?php
echo ob_get_clean();
}
add_action('wp_head', __NAMESPACE__ . '\init_styles', 7);
function init_scripts() {
ob_start();
?>
<script>
@ -643,7 +642,6 @@ function init_scripts() {
}
</script>
<?php
echo ob_get_clean();
}
add_action('wp_footer', __NAMESPACE__ . '\init_scripts');
@ -724,10 +722,10 @@ function display_feed($atts) {
<script>
window.addEventListener("load", () => {
mastodonFeedLoad(
"<?php echo sanitize_url( $apiUrl, ['https'] ); ?>",
"<?php echo esc_url(sanitize_url( $apiUrl, ['https'] )); ?>",
"<?php echo filter_var( $elemId, FILTER_UNSAFE_RAW ); ?>",
{
linkTarget: "<?php echo esc_js(filter_var( $atts['linktarget'], FILTER_UNSAFE_RAW )); ?>",
linkTarget: "<?php echo esc_attr(filter_var( $atts['linktarget'], FILTER_UNSAFE_RAW )); ?>",
showPreviewCards: <?php echo (filter_var( $atts['showpreviewcards'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ? "true" : "false"); ?>,
excludeConversationStarters: <?php echo (filter_var( $atts['excludeconversationstarters'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ? "true" : "false"); ?>,
content: {
@ -740,18 +738,18 @@ function display_feed($atts) {
link: "<?php echo ( "image" === $atts['imagelink'] ? "image" : "status" ); ?>",
},
text: {
boosted: "<?php echo esc_js( $atts['text-boosted'] ); ?>",
boosted: "<?php echo esc_html( $atts['text-boosted'] ); ?>",
noStatuses: "<?php echo esc_html( $atts['text-nostatuses'] ); ?>",
viewOnInstance: "<?php echo esc_js( $atts['text-viewoninstance'] ); ?>",
showContent: "<?php echo esc_js( $atts['text-showcontent'] ); ?>",
permalinkPre: "<?php echo esc_js( $atts['text-permalinkpre'] ); ?>",
permalinkPost: "<?php echo esc_js( $atts['text-permalinkpost'] ); ?>",
edited: "<?php echo esc_js( $atts['text-edited'] ); ?>",
showContent: "<?php echo esc_html( $atts['text-showcontent'] ); ?>",
permalinkPre: "<?php echo esc_html( $atts['text-permalinkpre'] ); ?>",
permalinkPost: "<?php echo esc_html( $atts['text-permalinkpost'] ); ?>",
edited: "<?php echo esc_html( $atts['text-edited'] ); ?>",
},
localization: {
date: {
locale: "<?php echo esc_js(filter_var( $atts['date-locale'], FILTER_UNSAFE_RAW )); ?>",
options: <?php echo esc_js(filter_var( $atts['date-options'], FILTER_UNSAFE_RAW )); ?>,
locale: "<?php echo filter_var( $atts['date-locale'], FILTER_UNSAFE_RAW ); ?>",
options: <?php echo filter_var( $atts['date-options'], FILTER_UNSAFE_RAW ); ?>,
}
}
}

View File

@ -5,8 +5,8 @@ Tags: mastodon, status, feed
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.9.7
License: Expat License
Stable tag: 1.9.8
License: MIT
License URI: https://directory.fsf.org/wiki/License:Expat
Plugin that provides a shortcode to easily integrate mastodon feeds into wordpress pages.
@ -26,15 +26,15 @@ The plugin is written in PHP and generates native JavaScript to fetch and render
`[include-mastodon-feed instance="YOUR-INSTANCE" account="YOUR-ACCOUNT-ID"]`
= Shortcode attributes =
* **instance** (required)
Domain name of the instance without https:// (e.g. example.org)
* **account** (required)
The account ID (a long number - see FAQ on how to get it)
* **tag**
Use **tag** instead of **account** if you want to embed a tag feed instead of a personal feed
* **instance** (required)
Domain name of the instance without https:// (e.g. example.org)
* **limit**
Maximum number of statuses (Default: 20)
@ -154,6 +154,12 @@ Use the following URL to get your ID:
== Changelog ==
= 1.9.8 =
* fix broken date-locale and date-options parameters
* improved string excaping for text parameters and added url escaping
* removed unnecessary output buffering
* fix license SPDX Identifier
= 1.9.7 =
* fix option to either display smaller image media attachment previews (default) or large image versions (thank you @beach@illo.social)