Skip to content
Snippets Groups Projects
Commit 0c3756a3 authored by agata's avatar agata
Browse files

[auto] plugin: autopost-to-mastodon 3.4

parent 4fd40ea3
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
* Plugin Name: Mastodon Autopost
* Plugin URI: https://github.com/simonfrey/mastodon_wordpress_autopost
* Description: A Wordpress Plugin that automatically posts your new articles to Mastodon
* Version: 3.3.2
* Version: 3.4
* Author: L1am0
* Author URI: http://www.simon-frey.eu
* License: GPL2
......@@ -116,16 +116,6 @@ class autopostToMastodon
wp_enqueue_script('settings_page', $plugin_url . 'js/settings_page.js', array('jquery'), $infos['Version'], true);
}
if (in_array($pagenow, ['post-new.php', 'post.php'])) {
$plugin_url = plugin_dir_url(__FILE__);
wp_enqueue_script('toot_editor', $plugin_url . 'js/toot_editor.js', array('jquery'), $infos['Version'], true);
$title_nonce = wp_create_nonce('mastodonNonce');
wp_localize_script('toot_editor', 'ajax_obj', array(
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => $title_nonce,
));
}
}
/**
......@@ -140,7 +130,7 @@ class autopostToMastodon
add_options_page(
'Mastodon Autopost',
'Mastodon Autopost',
'install_plugins',
'manage_options',
'autopost-to-mastodon',
array($this, 'show_configuration_page')
);
......@@ -496,28 +486,30 @@ class autopostToMastodon
}
//Replace excerpt
$post_content_long = $post->post_content;
if ($wp_version[0] == "5"){
//Replace with the excerpt of the post
$post_optional_excerpt = $post->post_excerpt;
if (strlen($post_optional_excerpt) > 0) {
$post_content_long = $post_optional_excerpt;
} else {
$post_content_long = $post->post_content;
}
if ($wp_version[0] == "5") {
$post_content_long = excerpt_remove_blocks($post_content_long);
}
$post_content_long = wp_strip_all_tags($post_content_long);
$post_content_long = strip_shortcodes($post_content_long);
$post_content_long = strip_tags($post_content_long);
$post_content_long = html_entity_decode($post_content_long, ENT_COMPAT, 'UTF-8');
$post_content_long = wp_strip_all_tags($post_content_long);
//$post_content_long = str_replace("...", "",$post_content_long);
$excerpt_len = $toot_size - strlen($message_template) + 9 - 5;
//Replace with the excerpt of the post
$post_optional_excerpt = get_the_excerpt($id);
if (strlen($post_optional_excerpt)>0){
$post_content_long = $post_optional_excerpt;
}
$post_excerpt = substr($post_content_long, 0, $excerpt_len);
mb_internal_encoding("UTF-8");
$post_excerpt = mb_substr($post_content_long, 0, $excerpt_len);
$message_template = str_replace("[excerpt]", $post_excerpt, $message_template);
return substr($message_template, 0, $toot_size);
return mb_substr($message_template, 0, $toot_size);
}
private function sendTestToot()
......
......@@ -2,8 +2,8 @@
Contributors: l1am0, Hellexis
Tags: mastodon, Mastodon, Mastdon Autopost, federated web, GNU social, statusnet, social web, social media, auto post
Requires at least: 4.6
Tested up to: 5.0
Stable tag: 3.3.2
Tested up to: 5.2.1
Stable tag: 3.4
License: GPLv2
Donate link: https://patreon.com/simonfrey
License URI: http://www.gnu.org/licenses/gpl-2.0.html
......@@ -46,6 +46,16 @@ The plugin never transmits any data to me, or anyone else than the mastodon node
== Changelog ==
= 3.4 =
* Fix for the manual added excerpt to also get encoded and remove html tags
= 3.3.4 =
* Remove toot editor javascript as we do not have a toot editor anymore
= 3.3.3 =
* Change permission for settings pages
* Update for HTML tags striping
= 3.3.2 =
* Remove HTML tags from excerpt (with php strip_tags())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment