diff --git a/wp-content/plugins/autopost-to-mastodon/form.tpl.php b/wp-content/plugins/autopost-to-mastodon/form.tpl.php index e86d566ac58e795024dcf57b306cdab599ebef19..ef5ade019d4b131f2039ab4233a8f8eb46236acb 100644 --- a/wp-content/plugins/autopost-to-mastodon/form.tpl.php +++ b/wp-content/plugins/autopost-to-mastodon/form.tpl.php @@ -14,7 +14,7 @@ define("ADVANCED_VIEW",false); <svg aria-hidden="true" class="octicon octicon-mark-github" height="32" version="1.1" viewBox="0 0 16 16" width="32"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg> </a> - <a href="https://paypal.me/51edpo" target="_blank"><img src="<?php echo plugins_url( 'img/paypal.png', __FILE__ );?>" style="height:30px;"></a> <a href="https://patreon.com/simonfrey" target="_blank"><img src="<?php echo plugins_url( 'img/patron.png', __FILE__ );?>" style="height:30px;"></a> <a href="https://liberapay.com/Mastodon-Auto-Share-Team/donate" target="_blank"><img src="<?php echo plugins_url( 'img/donate.svg', __FILE__ );?>"></a> + <a href="https://paypal.me/51edpo" target="_blank"><img src="<?php echo plugins_url( 'img/paypal.png', __FILE__ );?>" style="height:30px;"></a> <br> <br> <?php if(ACCOUNT_CONNECTED): ?> @@ -117,6 +117,15 @@ define("ADVANCED_VIEW",false); </td> </tr> + <tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>"> + <th scope="row"> + <label for="cats_as_tags"><?php esc_html_e( 'Use categories as tags', 'autopost-to-mastodon' ); ?></label> + </th> + <td> + <input type="checkbox" id="cats_as_tags" name="cats_as_tags" value="on" <?php echo ( $cats_as_tags == 'on')?'checked':''; ?>> + </td> + </tr> + <tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>"> <th scope="row"> <label for="autopost_standard"><?php esc_html_e( 'Autopost new posts', 'autopost-to-mastodon' ); ?></label> @@ -124,7 +133,30 @@ define("ADVANCED_VIEW",false); <td> <input type="checkbox" id="autopost_standard" name="autopost_standard" value="on" <?php echo ( $autopost == 'on')?'checked':''; ?>> </td> - </tr> + </tr> + <tr style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>"> + <th scope="row"> + <label for="post_types"><?php esc_html_e( 'Choose active post types', 'autopost-to-mastodon' ); ?></label> + </th> + <td> + <fieldset id="post_types"> +<?php + // get all post types + $args = array( + 'public' => true, + // '_builtin' => false, + ); + $output = 'objects'; + $operator = 'and'; + $wp_post_types = get_post_types( $args, $output, $operator ); + foreach ( $wp_post_types as $post_type ) { + $checked = ($post_types[$post_type->name] == 'on')?'checked':''; + echo "<label for=\"" . $post_type->name . "\"><input type=\"checkbox\" id=\"" . $post_type->name . "\" name=\"" . $post_type->name . "\"" . $checked . " />" . $post_type->label . "</label></br>"; + } +?> + </fieldset> + </td> + </tr> </tbody> </table> diff --git a/wp-content/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.mo b/wp-content/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.mo index a9a5928389fa2e043c2202f4d519b7e81d40bafd..2cd906195a344ec14d07a6a7f54ca454834a5e79 100644 Binary files a/wp-content/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.mo and b/wp-content/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.mo differ diff --git a/wp-content/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.po b/wp-content/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.po index cae4d815a521ee1bc0714dac6841a5b606d8fb3f..05da243245bbe39972c0e12d1508da73fed04b51 100644 --- a/wp-content/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.po +++ b/wp-content/plugins/autopost-to-mastodon/languages/autopost-to-mastodon-de_DE.po @@ -107,4 +107,8 @@ msgid "characters" msgstr "Zeichen" msgid "View Toot" -msgstr "Zum Toot" \ No newline at end of file +msgstr "Zum Toot" + +msgid "Choose active post types" +msgstr "Aktiviere für folgende Post-Types" + diff --git a/wp-content/plugins/autopost-to-mastodon/mastodon_autopost.php b/wp-content/plugins/autopost-to-mastodon/mastodon_autopost.php index ab19ae961e4cc7955db65ab435bd5e28dfa90410..2e52bdc59637436b7fcf95ce1f01a922d0cdd8bc 100644 --- a/wp-content/plugins/autopost-to-mastodon/mastodon_autopost.php +++ b/wp-content/plugins/autopost-to-mastodon/mastodon_autopost.php @@ -3,9 +3,9 @@ * 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.4 + * Version: 3.6 * Author: L1am0 - * Author URI: http://www.simon-frey.eu + * Author URI: https://www.simon-frey.eu * License: GPL2 * Text Domain: autopost-to-mastodon * Domain Path: /languages @@ -208,6 +208,30 @@ class autopostToMastodon update_option('autopostToMastodon-postOnStandard', 'off'); } + + if (isset($_POST['cats_as_tags'])) { + update_option('autopostToMastodon-catsAsTags', 'on'); + } else { + update_option('autopostToMastodon-catsAsTags', 'off'); + } + + // get all post types + $args = array( + 'public' => true, + ); + $output = 'names'; + $operator = 'and'; + $post_types = get_post_types( $args, $output, $operator ); + // check post for content type configs + foreach ( $post_types as $post_type ) { + if (isset($_POST[$post_type]) ? $_POST[$post_type] : "off" == "on") { + update_option("autopostToMastodon-post_types-$post_type", 'on'); + } + else { + update_option("autopostToMastodon-post_types-$post_type", 'off'); + } + } + update_option('autopostToMastodon-content-warning', sanitize_textarea_field($content_warning)); $account = $client->verify_credentials($token); @@ -248,6 +272,21 @@ class autopostToMastodon $toot_size = get_option('autopostToMastodon-toot-size', 500); $content_warning = get_option('autopostToMastodon-content-warning', ''); $autopost = get_option('autopostToMastodon-postOnStandard', 'on'); + $cats_as_tags = get_option('autopostToMastodon-catsAsTags', 'on'); + $post_types = []; + + // get all post types + $args = array( + 'public' => true, + ); + $output = 'names'; + $operator = 'and'; + $wp_post_types = get_post_types( $args, $output, $operator ); + + // add form context data for post type options + foreach ( $wp_post_types as $post_type ) { + $post_types[$post_type] = get_option("autopostToMastodon-post_types-$post_type", 'on'); + } include 'form.tpl.php'; } @@ -413,14 +452,33 @@ class autopostToMastodon */ public function add_metabox() { - add_meta_box( - 'autopostToMastodon_metabox', - 'Mastodon Autopost', - array($this, 'metabox'), - ['post', 'page'], - 'side', - 'high' + $active_post_types = []; + // get all post types + $args = array( + 'public' => true, ); + $output = 'names'; + $operator = 'and'; + $post_types = get_post_types( $args, $output, $operator ); + + // add form context data for post type options + foreach ( $post_types as $post_type ) { + if (get_option("autopostToMastodon-post_types-$post_type", 'on') == 'on') { + array_push($active_post_types, $post_type); + } + } + + // empty array activates everywhere -> check + if (!empty($active_post_types)) { + add_meta_box( + 'autopostToMastodon_metabox', + 'Mastodon Autopost', + array($this, 'metabox'), + $active_post_types, + 'side', + 'high' + ); + } } /** @@ -472,18 +530,27 @@ class autopostToMastodon $message_template = str_replace("[permalink]", $post_permalink, $message_template); //Replace tags - $post_tags = get_the_tags($id); + $post_tags_content = ''; + $cats_as_tags = get_option('autopostToMastodon-catsAsTags', 'off'); + if ($cats_as_tags == 'on') { + $post_cats = get_the_category($id); + if (sizeof($post_cats) > 0 && $post_cats) { + foreach ($post_cats as $cat) { + $post_tags_content = $post_tags_content . '#' . preg_replace('/\s+/', '', html_entity_decode($cat->name, ENT_COMPAT, 'UTF-8')) . ' '; + } + } + } + $post_tags = get_the_tags($id); if (sizeof($post_tags) > 0) { - $post_tags_content = ''; if ($post_tags) { foreach ($post_tags as $tag) { $post_tags_content = $post_tags_content . '#' . preg_replace('/\s+/', '', html_entity_decode($tag->name, ENT_COMPAT, 'UTF-8')) . ' '; } $post_tags_content = trim($post_tags_content); } - $message_template = str_replace("[tags]", $post_tags_content, $message_template); } + $message_template = str_replace("[tags]", $post_tags_content, $message_template); //Replace excerpt //Replace with the excerpt of the post diff --git a/wp-content/plugins/autopost-to-mastodon/readme.txt b/wp-content/plugins/autopost-to-mastodon/readme.txt index 87c13046c5e80ac0c80d208e0d24f71d45d56a30..c81eeb195b55df5481a03157f13d76992ab564cd 100644 --- a/wp-content/plugins/autopost-to-mastodon/readme.txt +++ b/wp-content/plugins/autopost-to-mastodon/readme.txt @@ -2,10 +2,10 @@ 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.2.1 -Stable tag: 3.4 +Tested up to: 5.3.2 +Stable tag: 3.6 License: GPLv2 -Donate link: https://patreon.com/simonfrey +Donate link: https://paypal.me/51edpo License URI: http://www.gnu.org/licenses/gpl-2.0.html A Wordpress Plugin that automatically posts your new articles to Mastodon. The best: It is set and forget! @@ -26,7 +26,7 @@ For any questions, do not hesitate to contact me: Do you want to help translating this plugin in your language? [Visit the translation page](https://translate.wordpress.org/projects/wp-plugins/autopost-to-mastodon) -Please consider donating via [Patreon](https://patreon.com/simonfrey), [PayPal](https://paypal.me/51edpo) or [Liberapay](https://liberapay.com/Mastodon-Auto-Share-Team/donate) <3 +Please consider donating via [PayPal](https://paypal.me/51edpo) <3 == Frequently Asked Questions == @@ -46,6 +46,12 @@ The plugin never transmits any data to me, or anyone else than the mastodon node == Changelog == += 3.6 = +* Allow the plugin to work on custom post types (Thanks to [unicode-it](https://github.com/unicode-it)) + += 3.5 = +* Use categorys as hashtags on posts (Thanks to [rseabra](https://github.com/rseabra)) + = 3.4 = * Fix for the manual added excerpt to also get encoded and remove html tags diff --git a/wp-content/plugins/autopost-to-mastodon/uninstall.php b/wp-content/plugins/autopost-to-mastodon/uninstall.php index 3dcd0c2af7d5627514a2466674b30402e5a99ad2..2816e500b5249c3f39ad70d6624205a5c54295d0 100644 --- a/wp-content/plugins/autopost-to-mastodon/uninstall.php +++ b/wp-content/plugins/autopost-to-mastodon/uninstall.php @@ -10,4 +10,15 @@ delete_option( 'autopostToMastodon-instance' ); delete_option( 'autopostToMastodon-message' ); delete_option( 'autopostToMastodon-mode' ); delete_option( 'autopostToMastodon-toot-size' ); -delete_option( 'autopostToMastodon-notice' ); \ No newline at end of file +delete_option( 'autopostToMastodon-notice' ); +// get all post types +$args = array( + 'public' => true, +); +$output = 'names'; +$operator = 'and'; +$post_types = get_post_types( $args, $output, $operator ); +// delete configs for all post_types +foreach ( $post_types as $post_type ) { + delete_option("autopostToMastodon-post_types-$post_type" ); +}