diff --git a/readme.md b/readme.md index 13a2670..e1cfb95 100644 --- a/readme.md +++ b/readme.md @@ -16,7 +16,7 @@ TootPress copies your toots from Mastodon to WordPress continuously. The toots c ## Installation -1. Download the plugin from the GitHub Repository (see latest Release) +1. Download the plugin from the GitHub Repository (latest Release) 2. Rename the downloaded folder to "tootpress" 2. Upload the folder to the WordPress Plugin Directory 3. Activate the plugin in WordPress @@ -66,8 +66,8 @@ Following toot objects are not supported. * Audio * Video * Poll -* Emojis * Teaser +* Quotes ## Excluded Toot Types @@ -115,9 +115,9 @@ You can use the following code. ### Filter -#### tootpress_preamble_add +#### tootpress_preamble_filter -This filter outputs html content before the toot loop. +This filter outputs html content before the initial toot loop. You can use the following code. function tootpress_preamble_add( $preamble ) { @@ -130,6 +130,176 @@ You can use the following code. } add_filter( 'tootpress_preamble_filter', 'tootpress_preamble_add', 10, 1 ); +#### tootpress_closing_filter + +This filter outputs html content after the last toot loop. +You can use the following code. + + function tootpress_closing_add( $content ) { + + // Add your filter code here + // Example: $content='

Hello World.

'; + + return $content; + + } + add_filter( 'tootpress_closing_filter', 'tootpress_closing_add', 10, 1 ); + +#### tootpress_menu_forward_label + +This filter overwrites the forward label in the bottom navigation. +You can use the following code. + + function tootpress_menu_forward_label_change( $label ) { + + // Add your filter code here + // Example: $label='Newer Posts'; + + return $label; + + } + add_filter( 'tootpress_menu_forward_label', 'tootpress_menu_forward_label_change', 10, 1 ); + +#### tootpress_menu_backward_label + +This filter overwrites the backward label in the bottom navigation. +You can use the following code. + + function tootpress_menu_backward_label_change( $label ) { + + // Add your filter code here + // Example: $label='Older Posts'; + + return $label; + + } + add_filter( 'tootpress_menu_backward_label', 'tootpress_menu_backward_label_change', 10, 1 ); + +#### tootpress_beforeloop_filter + +This filter outputs content before the toot loop (on all tootpress pages). +You can use the following code. + + function tootpress_beforeloop_add( $content, $current_page_number, $last_page_number ) { + + // Add your filter code here + // Example: $content='

Page '.$current_page_number.' of '.$last_page_number.'

'; + + return $content; + + } + add_filter( 'tootpress_beforeloop_filter', 'tootpress_beforeloop_add', 10, 3 ); + +#### tootpress_afterloop_filter + +This filter outputs content after the toot loop (on all tootpress pages). +You can use the following code. + + function tootpress_afterloop_add( $content, $current_page_number, $last_page_number ) { + + // Add your filter code here + // Example: $content='

Page '.$current_page_number.' of '.$last_page_number.'

'; + + return $content; + + } + add_filter( 'tootpress_afterloop_filter', 'tootpress_afterloop_add', 10, 3 ); + +#### tootpress_mastodon_logo_filter + +This filter overwrites the Mastodon Logo with Custom Logo. +You can use the following code. + + function tootpress_mastodon_logo_change ( $img ) { + + // Standard Value + // Toot Symbol + + // Add your filter code here + // Example: $img='Custom Toot Symbol'; + + return $img; + + } + add_filter( 'tootpress_mastodon_logo_filter', 'tootpress_mastodon_logo_change', 10, 1 ); + +#### tootpress_between_filter + +This filter adds custom HTML between the toots. +You can use the following code. + + function tootpress_create_element_between ( $content ) { + + // Add your filter code here + // $content='
'; + + return $content; + + } + add_filter( 'tootpress_between_filter', 'tootpress_create_element_between', 10, 1 ); + +#### tootpress_toot_content_filter + +This filter can be used to manipulate the toot content. +You can use the following code. + + function tootpress_manipulate_content ( $content ) { + + // Add your filter code here + // $content=str_replace('href=','target="_blank" href=',$content); + + return $content; + + } + add_filter( 'tootpress_toot_content_filter', 'tootpress_manipulate_content', 10, 1 ); + +#### tootpress_date_filter + +This filter overwrites the date output with custom format. +You can use the following code. + + function tootpress_date_custom_format ( $date, $year, $month, $day, $hour, $minute, $second ) { + + // $date = 2023-05-30 22:40:28 + // $year = 2023 + // $month = 05 + // $day = 30 + // $hour = 22 + // $minute = 40 + // $second = 28 + + // Add your filter code here + // $date=$day.'.'.$month.'.'.$year.' '.$hour.':'.$minute.':'.$second; + + return $date; + + } + add_filter( 'tootpress_date_filter', 'tootpress_date_custom_format', 10, 7 ); + +#### tootpress_image_filter + +This filter can be used to manipulate image tags. +You can use the following code. + + function tootpress_image_manipulate ($img_tag,$filename,$description,$width,$height,$image_directory_path,$amount_of_images,$image_number) { + + // Amount of Images + // ---------------- + // 1 = Single Image + // >1 = Gallery + Size of Gallery + + // Image Number + // ------------ + // This number indicates position within the gallery + + // Add your filter code here + // $img_tag=str_replace('alt=','class="tootpress-image" alt=',$img_tag); + + return $img_tag; + + } + add_filter( 'tootpress_image_filter', 'tootpress_image_manipulate', 1, 8 ); + ## WordPress Framework Following components of WordPress are used in TootPress. @@ -169,6 +339,22 @@ Backlinks to Mastodon can be activated in the plugin settings. In this case, the 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. +### Are the toots included in the WordPress Search? + +Unfortunately not. + +### Is there any possiblity to modify the outputs on the user interface? + +Almost every content element, which is created by TootPress in the FrontEnd, can be modified. For example, you can replace the Mastodon Logo with another image. Enabeling this, the plugin is providing a bunch of filters. Please read the documentation of the filter above. + +### Does TootPress recognize, if a published Toot was edited on Mastodon? + +The plugin does not sync the Toots between Mastodon and WordPress. TootPress is copying the toots just once after they are published on Mastodon. So if a published toot is edited on Mastodon later, TootPress does not recognized this change anymore, if the toot was already copied to WordPress. Reflecting the edit in WordPress there is only the possibility to make the same edit again directly in the WordPress database. The toots are stored in the table tootpress_toots. + +### Can toots be loaded from several Mastodon instances? + +No. The plugin does currently not support several Mastodon instances. The architecture is designed to load toots from one single instance. Independent from this, if your toot history is spread over several instances and the timelines does not overlap, you can try to load the timelines one after another. This is not officially supported or tested, but based on user feedback this seems to work surprisingly. + ## Maturity Grade * Low maturity level @@ -207,6 +393,23 @@ This project is licensed under the GPL3 License. ## Changelog +### 0.5 "Echo" + +* July 2025 +* Feature: Closing Filter +* Feature: Move Forward Label Filter +* Feature: Move Backward Label Filter +* Feature: Before Loop Filter +* Feature: After Loop Filter +* Feature: Mastodon Logo Filter +* Feature: Between Filter +* Feature: Toot Content Filter +* Feature: Date Filter +* Feature: Image Filter +* Changed: DOM Structure +* Renamed: CSS Classes +* Security: Better Output Escaping + ### 0.4 "Cassie Lang" * June 2024 diff --git a/readme.txt b/readme.txt index 6b4cb76..6412742 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: unmus Tags: mastodon, toots, microblogging, blog, fediverse Requires at least: 6.1 Tested up to: 6.8 -Stable tag: 0.4 +Stable tag: 0.5 License: GNU General Public License v3 or later License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -72,8 +72,8 @@ Following toot objects are not supported. * Audio * Video * Poll -* Emojis * Teaser +* Quotes = Excluded Toot Types = @@ -116,7 +116,7 @@ You can use the following code. `}` `add_action('tootpress_toots_update', 'tootpress_toots_update_postprocessing');` -**Filter: tootpress_preamble_add** +**Filter: tootpress_preamble_filter** It outputs html content before the toot loop. You can use the following code. @@ -130,6 +130,166 @@ You can use the following code. `}` `add_filter( 'tootpress_preamble_filter', 'tootpress_preamble_add', 10, 1 );` +**Filter: tootpress_closing_filter** +It outputs html content after the last toot loop. +You can use the following code. + +`function tootpress_closing_add( $content ) {` +`` +` // Add your filter code here` +` // Example: $content='

Hello World.

';` +`` +` return $content;` +`` +`}` +`add_filter( 'tootpress_closing_filter', 'tootpress_closing_add', 10, 1 );` + +**Filter: tootpress_menu_forward_label** +This filter overwrites the forward label in the bottom navigation. +You can use the following code. + +`function tootpress_menu_forward_label_change( $label ) {` +`` +` // Add your filter code here` +` // Example: $label='Newer Posts';` +`` +` return $label;` +`` +`}` +`add_filter( 'tootpress_menu_forward_label', 'tootpress_menu_forward_label_change', 10, 1 );` + +**Filter: tootpress_menu_backward_label** +This filter overwrites the backward label in the bottom navigation. +You can use the following code. + +`function tootpress_menu_backward_label_change( $label ) {` +`` +` // Add your filter code here` +` // Example: $label='Older Posts';` +`` +` return $label;` +`` +`}` +`add_filter( 'tootpress_menu_backward_label', 'tootpress_menu_backward_label_change', 10, 1 );` + +**Filter: tootpress_beforeloop_filter** +This filter outputs content before the toot loop (on all tootpress pages). +You can use the following code. + +`function tootpress_beforeloop_filter_add( $content, $page_number ) {` +`` +` // Add your filter code here` +` // Example: $content='

Page '.$page_number.'

';` +`` +` return $label;` +`` +`}` +`add_filter( 'tootpress_beforeloop_filter', 'tootpress_beforeloop_filter_add', 10, 2 );` + +**Filter: tootpress_afterloop_filter** +This filter outputs content after the toot loop (on all tootpress pages). +You can use the following code. + +`function tootpress_afterloop_add( $content, $current_page_number, $last_page_number ) {` +`` +` // Add your filter code here` +` // Example: $content='

Page '.$current_page_number.' of '.$last_page_number.'

';` +`` +` return $content;` +`` +`}` +`add_filter( 'tootpress_afterloop_filter', 'tootpress_afterloop_add', 10, 3 );` + +**Filter: tootpress_mastodon_logo_filter** +This filter overwrites the Mastodon Logo with Custom Logo. +You can use the following code. + +`function tootpress_mastodon_logo_change ( $img ) {` +`` +` // Standard Value` +` // Toot Symbol` +`` +` // Add your filter code here` +` // Example: $img='Custom Toot Symbol';` +`` +` return $img;` +`` +`}` +`add_filter( 'tootpress_mastodon_logo_filter', 'tootpress_mastodon_logo_change', 10, 1 );` + +**Filter: tootpress_between_filter** +This filter adds custom HTML between the toots. +You can use the following code. + +`function tootpress_create_element_between ( $content ) {` +`` +` // Add your filter code here` +` // $content='
';` +`` +` return $content;` +`` +`} +`add_filter( 'tootpress_between_filter', 'tootpress_create_element_between', 10, 1 );` + +**Filter: tootpress_toot_content_filter** +This filter can be used to manipulate the toot content. +You can use the following code. + +`function tootpress_manipulate_content ( $content ) {` +`` +` // Add your filter code here` +` // $content=str_replace('href=','target="_blank" href=',$content); ` +`` +` return $content;` +`` +`} +`add_filter( 'tootpress_toot_content_filter', 'tootpress_manipulate_content', 10, 1 );` + +**Filter: tootpress_date_filter** +This filter overwrites the date output with custom format. +You can use the following code. + +`function tootpress_date_custom_format ( $date, $year, $month, $day, $hour, $minute, $second ) {` +`` +` // $date = 2023-05-30 22:40:28` +` // $year = 2023` +` // $month = 05` +` // $day = 30` +` // $hour = 22` +` // $minute = 40` +` // $second = 28` +`` +` // Add your filter code here` +` // $date=$day.'.'.$month.'.'.$year.' '.$hour.':'.$minute.':'.$second;` +`` +` return $date;` +`` +`} +`add_filter( 'tootpress_date_filter', 'tootpress_date_custom_format', 10, 7 );` + +**Filter: tootpress_image_filter** +This filter can be used to manipulate image tags. +You can use the following code. + +`function tootpress_image_manipulate ($img_tag,$filename,$description,$width,$height,$image_directory_path,$amount_of_images,$image_number) {` +`` +` // Amount of Images` +` // ----------------` +` // 1 = Single Image` +` // >1 = Gallery + Size of Gallery` +`` +` // Image Number` +` // ------------` +` // This number indicates position within the gallery` +`` +` // Add your filter code here` +` // $img_tag=str_replace('alt=','class="tootpress-image" alt=',$img_tag);` +`` +` return $img_tag;` +`` +`} +`add_filter( 'tootpress_image_filter', 'tootpress_image_manipulate', 1, 8 );` + = Related Links = * [Source Code @ GitHub](https://github.com/circuscode/tootpress) @@ -163,8 +323,41 @@ Backlinks to Mastodon can be activated in the plugin settings. In this case, the 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. += Are the toots included in the WordPress Search? = + +Unfortunately not. + += Is there any possiblity to modify the outputs on the user interface? = + +Almost every content element, which is created by TootPress in the FrontEnd, can be modified. For example, you can replace the Mastodon Logo with another image. Enabeling this, the plugin is providing a bunch of filters. Please read the documentation of the filter above. + += Does TootPress recognize, if a published Toot was edited on Mastodon? = + +The plugin does not sync the Toots between Mastodon and WordPress. TootPress is copying the toots just once after they are published on Mastodon. So if a published toot is edited on Mastodon later, TootPress does not recognized this change anymore, if the toot was already copied to WordPress. Reflecting the edit in WordPress there is only the possibility to make the same edit again directly in the WordPress database. The toots are stored in the table tootpress_toots. + += Can toots be loaded from several Mastodon instances? = + +No. The plugin does currently not support several Mastodon instances. The architecture is designed to load toots from one single instance. Independent from this, if your toot history is spread over several instances and the timelines does not overlap, you can try to load the timelines one after another. This is not officially supported or tested, but based on user feedback this seems to work surprisingly. + == Changelog == += 0.5 "Echo" = + +* July 2025 +* Feature: Closing Filter +* Feature: Move Forward Label Filter +* Feature: Move Backward Label Filter +* Feature: Before Loop Filter +* Feature: After Loop Filter +* Feature: Mastodon Logo Filter +* Feature: Between Filter +* Feature: Toot Content Filter +* Feature: Date Filter +* Feature: Image Filter +* Changed: DOM Structure +* Renamed: CSS Classes +* Security: Better Output Escaping + = 0.4 "Cassie Lang" = * June 2024 @@ -200,6 +393,9 @@ No. TootPress does not support the WordPress Multisite Feature. The plugin is wo == Upgrade Notice == += 0.5 = +This version brings a bunch of filters enabling customization. + = 0.4 = This version includes a preamble filter. diff --git a/tootpress.php b/tootpress.php index b06586e..0566793 100644 --- a/tootpress.php +++ b/tootpress.php @@ -3,7 +3,7 @@ /* Plugin Name: TootPress Description: TootPress copies your Toots from Mastodon to WordPress. -Version: 0.4 +Version: 0.5 Author: Marco Hitschler Author URI: https://www.unmus.de/ License: GPL3 diff --git a/tootpress_blog.php b/tootpress_blog.php index 460c8e7..b6bc619 100644 --- a/tootpress_blog.php +++ b/tootpress_blog.php @@ -31,30 +31,25 @@ function tootpress_paint_toot( $mastodon_id, $date, $content, $media , $instance $toot_html=''; // Toot ID as HTML Comment - $toot_html.=''; + $toot_html.=''; // Toot Start $toot_html.='
'; // Toot Elephant - $toot_html.=tootpress_paint_elephant( $instance, $account, $mastodon_id,$backlink); + $toot_html.=tootpress_paint_elephant( $instance, $account, $mastodon_id, $backlink); // Toot Date - if(tootpress_is_language_german()) { - $date=tootpress_convert_mysqldate_to_german_format($date); - } else { - $date=tootpress_convert_mysqldate_to_international_format($date); - } - - $toot_html.='

'.esc_html($date).'

'; + $toot_html.=tootpress_paint_date($date); // Toot Content $content=tootpress_remove_target_blank($content); - $toot_html.='
'.wp_kses($content, tootpress_escaping_allowed_html() ).'
'; + $content=tootpress_toot_content_filter_apply($content); + $toot_html.='
'.wp_kses_post($content).'
'; // Toot Image if($media){ - $toot_html.=wp_kses(tootpress_paint_image($mastodon_id), tootpress_escaping_allowed_html() ); + $toot_html.=tootpress_paint_image($mastodon_id); } // Toot End @@ -78,48 +73,85 @@ function tootpress_paint_image($tootid){ $toot_image=array(); $toot_image=tootpress_get_media_from_database($tootid); $image_html=''; - - // Amount of Images $amount_of_images=sizeof($toot_image); - for($i=0;$i<$amount_of_images;$i++) { + // DOM + $image_html.='
'; + $image_html.='
'; + return $image_html; } +/** + * Create the Image Tag + * + * @since 0.5 + * + * @param string Image File Name + * @param string Image Description + * @param int Image Width + * @param int Image Height + * @param int Amount of Images + * @param int Image Number + * @return html Image Tag + */ + +function tootpress_paint_image_tag($filename, $description, $width, $height, $amount_of_images, $image_number) { + + // Preparation + if($description==FALSE) {$description='Sorry! No image description created.';} + $image_dir=tootpress_get_url_image_directory(); + + // Image Tag + $image_tag='Toot Symbol'; + $elephant_img='Toot Symbol'; + $elephant_img=tootpress_mastodon_logo_filter_apply($elephant_img); + $elephant_html.=$elephant_img; if($backlink) { $elephant_html.=''; } + $elephant_html.='
'; + return $elephant_html; } /** - * Creates the Preamble + * Paint the Date + * + * @since 0.5 + * + * @param string Date + * @return string html + */ + + function tootpress_paint_date($date) { + + // 2023-05-30 22:40:28 + + $mysqldate=$date; + + $date=tootpress_date_filter_apply($date); + + if($mysqldate==$date) { + + if(tootpress_is_language_german()) { + $date=tootpress_convert_mysqldate_to_german_format($date); + } else { + $date=tootpress_convert_mysqldate_to_international_format($date); + } + + } + + $date_html='

'.esc_html($date).'

'; + return $date_html; + +} + +/** + * Create the Preamble * * @since 0.4 * * @param int TootPress Current Page - * @return string html + * @return html Preamble */ function tootpress_paint_preamble($tootpress_current_page) { @@ -169,7 +237,7 @@ function tootpress_paint_preamble($tootpress_current_page) { if($tootpress_current_page==1) { - $preamble.=tootpress_preamble_filter_apply($preamble); + $preamble=tootpress_preamble_filter_apply($preamble); if($preamble) { $preamble='
'.$preamble.'
'; @@ -181,4 +249,103 @@ function tootpress_paint_preamble($tootpress_current_page) { } +/** + * Create the Closing + * + * @since 0.5 + * + * @param int TootPress Current Page + * @return html Content + */ + + function tootpress_paint_closing($tootpress_current_page) { + + $content=''; + $lastpage=tootpress_amount_of_pages(); + + if($tootpress_current_page==$lastpage) { + + $content.=tootpress_closing_filter_apply($content); + + if($content) { + $content='
'.$content.'
'; + } + + } + + return $content; + +} + +/** + * Create the Before Loop Content. + * + * @since 0.5 + * + * @param string empty + * @param int TootPress Current Page + * @return html Content + */ + +function tootpress_paint_beforeloop($tootpress_current_page) { + + $content=''; + $content=tootpress_beforeloop_filter_apply($content, $tootpress_current_page); + + if($content) { + $content='
'.$content.'
'; + } + + return $content; + +} + +/** + * Create the After Loop Content. + * + * @since 0.5 + * + * @param string empty + * @param int TootPress Current Page + * @return html Content + */ + +function tootpress_paint_afterloop($tootpress_current_page) { + + $content=''; + $content=tootpress_afterloop_filter_apply($content, $tootpress_current_page); + + if($content) { + $content='
'.$content.'
'; + } + + return $content; + +} + +/** + * Create the Between Element. + * + * @since 0.5 + * + * @param int Open Loops + * @return html Between Element + */ + +function tootpress_paint_between($open_loops) { + + $content=''; + + if ($open_loops>1) { + $content=tootpress_between_filter_apply($content); + } + + if($content) { + $content='
'.$content.'
'; + } + + return $content; + +} + ?> \ No newline at end of file diff --git a/tootpress_healthy.php b/tootpress_healthy.php index d2a7bf7..1eec527 100644 --- a/tootpress_healthy.php +++ b/tootpress_healthy.php @@ -127,7 +127,7 @@ function tootpress_healthy_check() { // Required to build the backlinks $mastodon_account_name=tootpress_get_mastodon_account_name(); if ($mastodon_account_name) { - $output.='Mastodon Account Name has been retrieved: @'.$mastodon_account_name; + $output.='Mastodon Account Name has been retrieved: @'.esc_html($mastodon_account_name); } else { $output.=' Warning:  Mastodon Account Name could not be retrieved.'; } diff --git a/tootpress_hooks.php b/tootpress_hooks.php index 547d6fd..a49f3ff 100644 --- a/tootpress_hooks.php +++ b/tootpress_hooks.php @@ -17,7 +17,7 @@ /** * Fires when new toots are loaded * - * This hook can be used by other plugins to process after load functions. + * This action will be fired after toot update to execute custom post-processing. * For example: Cache Refresh * * @since 0.1 @@ -28,57 +28,230 @@ function tootpress_fire_toots_update() { } /** - * Action Example: tootpress_toots_update + * Filter + */ + +/** + * Preample + * + * This filter outputs html content before the initial toot loop. * * @since 0.4 * - * function tootpress_toots_update_postprocessing() { - * - * // Add your code to be executed here - * - * } - * add_action('tootpress_toots_update', 'tootpress_toots_update_postprocessing'); + * @param string Preamble + * @return html Filtered Preamble + */ + +function tootpress_preamble_filter_apply($preamble) { + $preamble=apply_filters( 'tootpress_preamble_filter', $preamble ); + $preamble=wp_kses_post($preamble); + return $preamble; +} + +/** + * Closing Filter + * + * This filter outputs content after the last toot loop. + * + * @since 0.5 * + * @param string Closing + * @return html Filtered Closing */ +function tootpress_closing_filter_apply($content) { + $content=apply_filters( 'tootpress_closing_filter', $content ); + $content=wp_kses_post($content); + return $content; +} + /** - * Filter + * Move Forward Filter + * + * This filter overwrites the forward label in the menu + * + * @since 0.5 + * + * @param string Original Label + * @return string New Label + */ + +function tootpress_menu_forward_filter_apply($label) { + $label=apply_filters( 'tootpress_menu_forward_label', $label ); + $label=esc_html($label); + return $label; +} + +/** + * Move Backward Filter + * + * This filter overwrites the backward label in the menu + * + * @since 0.5 + * + * @param string Original Label + * @return string New Label */ +function tootpress_menu_backward_filter_apply($label) { + $label=apply_filters( 'tootpress_menu_backward_label', $label ); + $label=esc_html($label); + return $label; +} + /** - * Preample + * Before Loop Filter * - * This filter outputs html content before the toot loop. + * This filter outputs content before the toot loop. + * It will be applied on all tootpress pages. * - * @since 0.4 + * @since 0.5 * - * @param string Unfiltered Preample - * @return html Filtered Preample + * @param string Content + * @param int TootPress Current Page Number + * @return html Content */ -function tootpress_preamble_filter_apply($preamble) { - $preamble.=apply_filters( 'tootpress_preamble_filter', $preamble ); - return $preamble; +function tootpress_beforeloop_filter_apply($content, $current_page_number) { + + $last_page_number=tootpress_amount_of_pages(); + + $content=apply_filters( 'tootpress_beforeloop_filter', $content, $current_page_number, $last_page_number ); + + $content=wp_kses_post($content); + + return $content; } /** - * Filter Example: tootpress_preamble_filter + * After Loop Filter * - * @since 0.4 + * This filter outputs content after the toot loop. + * It will be applied on all tootpress pages. + * + * @since 0.5 + * + * @param string Content + * @param int TootPress Current Page Number + * @return html Content + */ + +function tootpress_afterloop_filter_apply($content, $current_page_number) { + + $last_page_number=tootpress_amount_of_pages(); + + $content=apply_filters( 'tootpress_afterloop_filter', $content, $current_page_number, $last_page_number ); + + $content=wp_kses_post($content); + + return $content; +} + +/** + * Mastodon Logo Filter + * + * This filter overwrites the Mastodon Logo with Custom Logo + * + * @since 0.5 + * + * @param html Mastodon Logo + * @return html Custom Logo + */ + +function tootpress_mastodon_logo_filter_apply($img) { + $img=apply_filters( 'tootpress_mastodon_logo_filter', $img ); + $img=wp_kses_post($img); + return $img; +} + +/** + * Between Filter + * + * This filter adds custom HTML between the toots + * + * @since 0.5 + * + * @param string Content + * @return html Between Content + */ + +function tootpress_between_filter_apply($content) { + $content=apply_filters( 'tootpress_between_filter', $content ); + $content=wp_kses_post($content); + return $content; +} + +/** + * Toot Content Filter + * + * This filter can be used to manipulate the toot content + * + * @since 0.5 * - * @param string Unfiltered Preample - * @return html Filtered Preample - * - * function tootpress_preamble_add( $preamble ) { + * @param html Content + * @return html Filtered Content + */ + +function tootpress_toot_content_filter_apply($content) { + $content=apply_filters( 'tootpress_toot_content_filter', $content ); + $content=wp_kses_post($content); + return $content; +} + +/** + * Date Filter * - * // Add your filter code here - * // Example: $preamble='

Hello World.

'; + * This filter overwrites the date output with custom format * - * return $preamble; - * - * } - * add_filter( 'tootpress_preamble_filter', 'tootpress_preamble_add', 10, 1 ); + * @since 0.5 * + * @param string Date + * @return string Custom Format */ +function tootpress_date_filter_apply($date) { + + // 2023-05-30 22:40:28 + + $year=substr($date,0,4); + $month=substr($date,5,2); + $day=substr($date,8,2); + $hour=substr($date,11,2); + $minute=substr($date,14,2); + $second=substr($date,17,2); + + $date=apply_filters( 'tootpress_date_filter', $date, $year, $month, $day, $hour, $minute, $second ); + + $date=esc_html($date); + + return $date; +} + +/** + * Image Filter + * + * This filter can be used to manipulate image tags + * + * @since 0.5 + * + * @param html Image Tag + * @param string Image File Name + * @param string Image Description + * @param int Image Width + * @param int Image Height + * @param url TootPress Image Directory + * @param int Amount of Images + * @param int Image Number + * @return html Filtered Image Tag + */ + +function tootpress_image_filter_apply($img_tag,$filename,$description,$width,$height,$image_directory_path,$amount_of_images,$image_number) { + + $img_tag=apply_filters( 'tootpress_image_filter',$img_tag,$filename,$description,$width,$height,$image_directory_path,$amount_of_images,$image_number); + + $img_tag=wp_kses_post($img_tag); + + return $img_tag; +} + ?> \ No newline at end of file diff --git a/tootpress_install.php b/tootpress_install.php index 08861dc..71d06d8 100644 --- a/tootpress_install.php +++ b/tootpress_install.php @@ -24,7 +24,7 @@ function tootpress_activate () { // Initialize Settings - add_option('tootpress_plugin_version', "4"); + add_option('tootpress_plugin_version', "5"); add_option('tootpress_database_version', "1"); add_option('tootpress_active', "1"); add_option('tootpress_mastodon_instance',""); diff --git a/tootpress_loop.php b/tootpress_loop.php index 6a8b8d5..ca005d7 100644 --- a/tootpress_loop.php +++ b/tootpress_loop.php @@ -35,9 +35,18 @@ function tootpress_content($content) { // TootPress Preamble $tootpress_content.=tootpress_paint_preamble($tootpress_current_page); + // TootPress Before Loop + $tootpress_content.=tootpress_paint_beforeloop($tootpress_current_page); + // TootPress Loop $tootpress_content.=tootpress_loop($tootpress_current_page); + // TootPress After Loop + $tootpress_content.=tootpress_paint_afterloop($tootpress_current_page); + + // TootPress Closing + $tootpress_content.=tootpress_paint_closing($tootpress_current_page); + // TootPress Bottom Navigation $tootpress_content.=tootpress_create_menu($tootpress_current_page); @@ -71,6 +80,7 @@ function tootpress_loop($range) { $toot_cache=array(); $toot_cache=tootpress_get_toots_from_database($amount_toots_page, $range); $amount_toots_cache=count($toot_cache); + $open_loops=$amount_toots_cache; // Get Configuration $mastodon_instance=tootpress_get_mastodon_instance(); @@ -85,6 +95,12 @@ function tootpress_loop($range) { // Paint $tootloop.=tootpress_paint_toot( $toot['toot_mastodon_id'], $toot['toot_date'], $toot['toot_content'], $toot['toot_media'], $mastodon_instance, $mastodon_account, $tootpress_backlink); + // Between Filter + $tootloop.=tootpress_paint_between($open_loops); + + // -1 + $open_loops=($open_loops-1); + } } diff --git a/tootpress_menu.php b/tootpress_menu.php index fd1f477..106039f 100644 --- a/tootpress_menu.php +++ b/tootpress_menu.php @@ -65,7 +65,7 @@ function tootpress_generate_nav_standard($current_page) { if($current_page>1) { $menu_html.=' \ No newline at end of file diff --git a/tootpress_plugin.php b/tootpress_plugin.php index 98ada49..6621f8b 100644 --- a/tootpress_plugin.php +++ b/tootpress_plugin.php @@ -47,7 +47,7 @@ function tootpress_admin_css($hook) { add_action( 'admin_enqueue_scripts', 'tootpress_admin_css' ); /** - * Adds Mathilda Flag + * Adds TootPress Flag * * @since 0.1 * diff --git a/tootpress_toots.css b/tootpress_toots.css index 1aae05e..6ac8eb1 100644 --- a/tootpress_toots.css +++ b/tootpress_toots.css @@ -7,7 +7,7 @@ TootPress CSS @ Blog clear:both; } -.tootpress-toot-symbol { +.toot-symbol { float:left !important; margin-top:5px; } @@ -16,11 +16,8 @@ TootPress CSS @ Blog margin-left:60px; } -.toot-date { - font-size:85%; -} - .toot-date p { + font-size:80%; margin-bottom:0px; } @@ -32,7 +29,7 @@ TootPress CSS @ Blog max-width: 100%; } -.toot-image-gallery { +.toot-gallery-image { margin-bottom:5px; } diff --git a/tootpress_update.php b/tootpress_update.php index 3680650..1a14086 100644 --- a/tootpress_update.php +++ b/tootpress_update.php @@ -42,6 +42,16 @@ function tootpress_update() { } add_option('tootpress_rewrite_update','0'); } + + /* Update Process Version 0.4 */ + if($tootpress_previous_version==4) { + update_option('tootpress_plugin_version', "5"); + } + + /* Update Process Version 0.5 */ + if($tootpress_previous_version==5) { + update_option('tootpress_plugin_version', "6"); + } } add_action( 'plugins_loaded', 'tootpress_update' ); diff --git a/tootpress_url.php b/tootpress_url.php index df52eb9..d45715d 100644 --- a/tootpress_url.php +++ b/tootpress_url.php @@ -44,6 +44,9 @@ function tootpress_get_query_var() { // If Query Var is not set if ($qvar=="") {$qvar="1";} + // Security + $qvar=(int)$qvar; + return $qvar; }