Skip to content

Commit c74f69d

Browse files
authored
Merge pull request #24 from circuscode/develop
Develop
2 parents e41315a + e8f92b5 commit c74f69d

17 files changed

+338
-45
lines changed

readme.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Following toot objects are supported.
5454

5555
* Text
5656
* Images
57+
* Galleries
5758
* URLs
5859
* Hashtags
5960
* Mentions
@@ -62,7 +63,6 @@ Following toot objects are supported.
6263

6364
Following toot objects are not supported.
6465

65-
* Galleries
6666
* Audio
6767
* Video
6868
* Poll
@@ -131,6 +131,10 @@ TootPress does not modify the existing canonical url handling in WordPress. If y
131131

132132
The length of the cron period in combination with the configuration of caching determines how early a toot will be displayed within the blog. If a toot should be displayed as early as possible, the caching must be deactivated for the page containing the toots. Another possibility is removing the affected page from the cache, if new toots have been loaded. For this, a WordPress Action is fired by the plugin, which then must be processed by your caching plugin.
133133

134+
### How are backlinks to Mastodon displayed?
135+
136+
Backlinks to Mastodon can be activated in the plugin settings. In this case, the Mastodon Logo, which is shown for each toot, will be extended with an link to the original toot on the corresponding Mastodon instance. Recommendation is not activating the backlinks as this could cause an negative impact on SEO rating.
137+
134138
### Does TootPress support WordPress Multisite?
135139

136140
No. TootPress does not support the WordPress Multisite Feature. The plugin is working on the master-site, but is not working on all other child sites within the wordpress network.
@@ -139,8 +143,7 @@ No. TootPress does not support the WordPress Multisite Feature. The plugin is wo
139143

140144
* Low maturity level
141145
* Early stage of development
142-
* Future updates may require a complete reload of the toots.
143-
* To avoid data inconsistancy and process errors
146+
* Future updates may require a complete reload of the toots
144147

145148
## Branches
146149

@@ -174,6 +177,18 @@ This project is licensed under the GPL3 License.
174177

175178
## Changelog
176179

180+
### 0.3 "Deadpool"
181+
182+
* April 2024
183+
* Feature: Support of Gallery Toots
184+
* Feature: Amount of Toots will be shown in WordPress Dashboard
185+
* Feature: Option to activate Backlinks to Mastodon
186+
* Changed: Label of User Interface Section in Plugin Options
187+
* Bugfix: Plugin CSS will now really be activated
188+
* Bugfix: Rewrite Rules will be updated after changed settings
189+
* Bugfix: Internal Plugin Version will be set corretly
190+
* Bugfix: CSS Option will be set correctly with Restore of default Settings
191+
177192
### 0.2.1
178193

179194
* April 2023

readme.txt

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Contributors: unmus
33
Tags: mastodon, toots, microblogging, blog, fediverse
44
Requires at least: 6.1
5-
Tested up to: 6.2
6-
Stable tag: 0.2.1
5+
Tested up to: 6.5
6+
Stable tag: 0.3
77
License: GNU General Public License v3 or later
88
License URI: https://www.gnu.org/licenses/gpl-3.0.html
99

@@ -60,6 +60,7 @@ Following toot objects are supported.
6060

6161
* Text
6262
* Images
63+
* Galleries
6364
* URLs
6465
* Hashtags
6566
* Mentions
@@ -68,7 +69,6 @@ Following toot objects are supported.
6869

6970
Following toot objects are not supported.
7071

71-
* Galleries
7272
* Audio
7373
* Video
7474
* Poll
@@ -132,12 +132,28 @@ TootPress does not modify the existing canonical url handling in WordPress. If y
132132

133133
The length of the cron period in combination with the configuration of caching determines how early a toot will be displayed within the blog. If a toot should be displayed as early as possible, the caching must be deactivated for the page containing the toots. Another possibility is removing the affected page from the cache, if new toots have been loaded. For this, a WordPress Action is fired by the plugin, which then must be processed by your caching plugin.
134134

135+
= How are backlinks to Mastodon displayed? =
136+
137+
Backlinks to Mastodon can be activated in the plugin settings. In this case, the Mastodon Logo, which is shown for each toot, will be extended with an link to the original toot on the corresponding Mastodon instance. Recommendation is not activating the backlinks as this could cause an negative impact on SEO rating.
138+
135139
= Does TootPress support WordPress Multisite? =
136140

137141
No. TootPress does not support the WordPress Multisite Feature. The plugin is working on the master-site, but is not working on all other child sites within the wordpress network.
138142

139143
== Changelog ==
140144

145+
= 0.3 "Deadpool" =
146+
147+
* April 2024
148+
* Feature: Support of Gallery Toots
149+
* Feature: Amount of Toots will be shown in WordPress Dashboard
150+
* Feature: Option to activate Backlinks to Mastodon
151+
* Changed: Label of User Interface Section in Plugin Options
152+
* Bugfix: Plugin CSS will now really be activated
153+
* Bugfix: Rewrite Rules will be updated after changed settings
154+
* Bugfix: Internal Plugin Version will be set corretly
155+
* Bugfix: CSS Option will be set correctly with Restore of default Settings
156+
141157
= 0.2.1 =
142158

143159
* April 2023
@@ -156,5 +172,8 @@ No. TootPress does not support the WordPress Multisite Feature. The plugin is wo
156172

157173
== Upgrade Notice ==
158174

175+
= 0.3 =
176+
This version brings gallery support and contains major bugfixes.
177+
159178
= 0.2.1 =
160179
This version includes bugfixing only.

tootpress.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Plugin Name: TootPress
55
Description: TootPress copies your Toots from Mastodon to WordPress.
6-
Version: 0.2.1
6+
Version: 0.3
77
Author: Marco Hitschler
88
Author URI: https://www.unmus.de/
99
License: GPL3
@@ -35,6 +35,7 @@
3535
require_once('tootpress_loop.php');
3636
require_once('tootpress_blog.php');
3737
require_once('tootpress_menu.php');
38+
require_once('tootpress_widgets.php');
3839
require_once('tootpress_notification.php');
3940
require_once('tootpress_get.php');
4041
require_once('tootpress_set.php');

tootpress_blog.php

Lines changed: 78 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
* @param date Toot Date
2020
* @param string Toot Content
2121
* @param int Media Flag
22+
* @param string Mastodon Instance
23+
* @param string Mastodon Account
24+
* @param int Backlink Flag
2225
* @return string html
2326
*/
2427

25-
function tootpress_paint_toot( $mastodon_id, $date, $content, $media )
28+
function tootpress_paint_toot( $mastodon_id, $date, $content, $media , $instance, $account, $backlink)
2629
{
2730

2831
$toot_html='';
@@ -33,8 +36,8 @@ function tootpress_paint_toot( $mastodon_id, $date, $content, $media )
3336
// Toot Start
3437
$toot_html.='<div class="tootpress-toot"/>';
3538

36-
// Toot Symbol
37-
$toot_html.='<img class="tootpress-toot-symbol" src="'.esc_url(plugins_url()).'/tootpress/tootpress_toot.png" alt="Toot Symbol" width="35" height="37"/>';
39+
// Toot Elephant
40+
$toot_html.=tootpress_paint_elephant( $instance, $account, $mastodon_id,$backlink);
3841

3942
// Toot Date
4043
if(tootpress_is_language_german()) {
@@ -71,30 +74,84 @@ function tootpress_paint_toot( $mastodon_id, $date, $content, $media )
7174

7275
function tootpress_paint_image($tootid){
7376

74-
// Get Image from Database
77+
// Get Images from Database
7578
$toot_image=array();
7679
$toot_image=tootpress_get_media_from_database($tootid);
7780
$image_html='';
7881

79-
// Image Content
80-
$image_html.='<div class="toot-image">';
81-
$image_html.='<img ';
82-
$image_html.='src="';
83-
$image_html.=tootpress_get_url_image_directory();
84-
$image_html.=$toot_image[0]['attachment_file'];
85-
$image_html.='" ';
86-
$image_html.='alt="';
87-
$image_html.=$toot_image[0]['attachment_description'];
88-
//$image_html.='" ';
89-
//$image_html.='width="';
90-
//$image_html.=$toot_image[0]['attachment_width'];
91-
//$image_html.='" ';
92-
//$image_html.='height="';
93-
//$image_html.=$toot_image[0]['attachment_height'];
94-
$image_html.='" />';
95-
$image_html.='</div>';
82+
// Amount of Images
83+
$amount_of_images=sizeof($toot_image);
84+
85+
for($i=0;$i<$amount_of_images;$i++) {
86+
87+
// Image Content
88+
$image_html.='<div class="toot-image ';
89+
90+
// Classes
91+
if($amount_of_images>1) {
92+
// Galleries
93+
$image_html.='toot-image-gallery ';
94+
$image_html.='toot-image-gallery-'.$amount_of_images.' ';
95+
$image_html.='toot-image-'.($i+1);
96+
} else {
97+
// Single Images
98+
$image_html.='toot-image-single ';
99+
}
100+
101+
$image_html.='">';
102+
$image_html.='<img ';
103+
$image_html.='src="';
104+
$image_html.=tootpress_get_url_image_directory();
105+
$image_html.=$toot_image[$i]['attachment_file'];
106+
$image_html.='" ';
107+
$image_html.='alt="';
108+
$image_html.=$toot_image[$i]['attachment_description'];
109+
//$image_html.='" ';
110+
//$image_html.='width="';
111+
//$image_html.=$toot_image[0]['attachment_width'];
112+
//$image_html.='" ';
113+
//$image_html.='height="';
114+
//$image_html.=$toot_image[0]['attachment_height'];
115+
$image_html.='" />';
116+
$image_html.='</div>';
117+
118+
}
96119

97120
return $image_html;
98121
}
99122

123+
/**
124+
* Creates the Elephant
125+
*
126+
* @since 0.3
127+
*
128+
* @param string Mastodon Instance
129+
* @param string Mastodon Account
130+
* @param int Mastodon Toot ID
131+
* @param int Backlink Option
132+
* @return string html
133+
*/
134+
135+
function tootpress_paint_elephant( $instance, $account, $mastodon_id, $backlink) {
136+
137+
$elephant_html='';
138+
$url='https://'.$instance.'/@'.$account.'/'.$mastodon_id;
139+
140+
if($backlink) {
141+
$elephant_html.='<a href="';
142+
$elephant_html.=esc_url($url);
143+
$elephant_html.='" class="toot-backlink"/>';
144+
}
145+
146+
// The Elephant
147+
$elephant_html.='<img class="tootpress-toot-symbol" src="'.esc_url(plugins_url()).'/tootpress/tootpress_toot.png" alt="Toot Symbol" width="35" height="37"/>';
148+
149+
if($backlink) {
150+
$elephant_html.='</a>';
151+
}
152+
153+
return $elephant_html;
154+
155+
}
156+
100157
?>

tootpress_database.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,13 @@ function tootpress_clear_data() {
110110

111111
function tootpress_restore_factory_settings() {
112112

113-
update_option('tootpress_plugin_version', "1");
113+
update_option('tootpress_plugin_version', "4");
114114
update_option('tootpress_database_version', "1");
115115
update_option('tootpress_active', "1");
116116
update_option('tootpress_mastodon_instance',"");
117117
update_option('tootpress_mastodon_oauth_access_token',"");
118118
update_option('tootpress_mastodon_account_id',"");
119+
update_option('tootpress_mastodon_account_name',"");
119120
update_option('tootpress_mastodon_amount_of_requests',"0");
120121
update_option('tootpress_latest_toot',"");
121122
update_option('tootpress_oldest_toot',"");
@@ -127,9 +128,12 @@ function tootpress_restore_factory_settings() {
127128
update_option('tootpress_page_id', "");
128129
update_option('tootpress_amount_toots_page',"50");
129130
update_option('tootpress_navigation',"standard");
130-
update_option('tootpress_css',"1");
131+
// CSS Option requires an inverse value (please do not ask why)
132+
update_option('tootpress_css',"0");
133+
update_option('tootpress_backlink','0');
134+
update_option('tootpress_rewrite_update','0');
131135
update_option('tootpress_developer',"0");
132-
136+
133137
global $wpdb;
134138
$table_name=$wpdb->prefix . 'tootpress_toots';
135139
$wpdb->get_var( "DELETE FROM $table_name" );

tootpress_get.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ function tootpress_get_mastodon_account_id() {
4949
return $mastodon_account_id;
5050
}
5151

52+
/**
53+
* Get Mastodon Account Name
54+
*
55+
* @since 0.3
56+
*
57+
* @return string Mastodon Account Name
58+
*/
59+
60+
function tootpress_get_mastodon_account_name() {
61+
$mastodon_account_name=get_option('tootpress_mastodon_account_name');
62+
return $mastodon_account_name;
63+
}
64+
5265
/**
5366
* Get latest Toot
5467
*
@@ -145,6 +158,22 @@ function tootpress_get_css_option() {
145158

146159
}
147160

161+
/**
162+
* Get Backlink Option
163+
*
164+
* @since 0.3
165+
*
166+
* @return int Backlink Option
167+
*/
168+
169+
function tootpress_get_backlink_option() {
170+
171+
$backlink=get_option('tootpress_backlink');
172+
173+
return $backlink;
174+
175+
}
176+
148177
/**
149178
* Get Page Slug of TootPress Page
150179
*

tootpress_healthy.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ function tootpress_healthy_check() {
121121
} else {
122122
$output.='<span class="mathilda-healtycheck-error">&nbsp;Error:&nbsp;</span> PHP option allow_url_fopen is set to FALSE (0) on the webhosting environment. Please change to TRUE (1).';
123123
}
124+
$output.='<br/>';
125+
126+
// Check: Mastodon Account Name received
127+
// Required to build the backlinks
128+
$mastodon_account_name=tootpress_get_mastodon_account_name();
129+
if ($mastodon_account_name) {
130+
$output.='Mastodon Account Name has been retrieved: @'.$mastodon_account_name;
131+
} else {
132+
$output.='<span class="tootpress-healtycheck-warning">&nbsp;Warning:&nbsp;</span> Mastodon Account Name could not be retrieved.';
133+
}
124134
$output.='</p>';
125135

126136
/*

tootpress_install.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ function tootpress_activate () {
2424

2525
// Initialize Settings
2626

27-
add_option('tootpress_plugin_version', "1");
27+
add_option('tootpress_plugin_version', "4");
2828
add_option('tootpress_database_version', "1");
2929
add_option('tootpress_active', "1");
3030
add_option('tootpress_mastodon_instance',"");
3131
add_option('tootpress_mastodon_oauth_access_token',"");
3232
add_option('tootpress_mastodon_account_id',"");
33+
add_option('tootpress_mastodon_account_name',"");
3334
add_option('tootpress_mastodon_amount_of_requests',"0");
3435
add_option('tootpress_latest_toot',"");
3536
add_option('tootpress_oldest_toot',"");
@@ -42,6 +43,8 @@ function tootpress_activate () {
4243
add_option('tootpress_amount_toots_page',"50");
4344
add_option('tootpress_navigation',"standard");
4445
add_option('tootpress_css','1');
46+
add_option('tootpress_backlink','0');
47+
add_option('tootpress_rewrite_update','0');
4548
add_option('tootpress_developer',"0");
4649
}
4750

@@ -75,6 +78,7 @@ function tootpress_delete () {
7578
delete_option('tootpress_mastodon_instance');
7679
delete_option('tootpress_mastodon_oauth_access_token');
7780
delete_option('tootpress_mastodon_account_id');
81+
delete_option('tootpress_mastodon_account_name');
7882
delete_option('tootpress_mastodon_amount_of_requests');
7983
delete_option('tootpress_latest_toot');
8084
delete_option('tootpress_oldest_toot');
@@ -87,6 +91,8 @@ function tootpress_delete () {
8791
delete_option('tootpress_amount_toots_page');
8892
delete_option('tootpress_navigation');
8993
delete_option('tootpress_css');
94+
delete_option('tootpress_backlink');
95+
delete_option('tootpress_rewrite_update');
9096
delete_option('tootpress_developer');
9197
}
9298

0 commit comments

Comments
 (0)