Changeset 3357470
- Timestamp:
- 09/07/2025 05:44:13 PM (7 months ago)
- Location:
- share-on-mastodon
- Files:
-
- 12 edited
- 1 copied
-
tags/0.19.4 (copied) (copied from share-on-mastodon/trunk)
-
tags/0.19.4/includes/class-block-editor.php (modified) (1 diff)
-
tags/0.19.4/includes/class-plugin-options.php (modified) (3 diffs)
-
tags/0.19.4/includes/class-post-handler.php (modified) (2 diffs)
-
tags/0.19.4/includes/class-share-on-mastodon.php (modified) (1 diff)
-
tags/0.19.4/readme.txt (modified) (2 diffs)
-
tags/0.19.4/share-on-mastodon.php (modified) (1 diff)
-
trunk/includes/class-block-editor.php (modified) (1 diff)
-
trunk/includes/class-plugin-options.php (modified) (3 diffs)
-
trunk/includes/class-post-handler.php (modified) (2 diffs)
-
trunk/includes/class-share-on-mastodon.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/share-on-mastodon.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
share-on-mastodon/tags/0.19.4/includes/class-block-editor.php
r3317007 r3357470 180 180 }, 181 181 'sanitize_callback' => function ( $status ) { 182 // Prevent the `%ca` in `%category%` from being mistaken for a percentage-encoded character. 183 $status = str_replace( '%category%', '%yrogetac%', $status ); 182 184 $status = sanitize_textarea_field( $status ); 185 $status = str_replace( '%yrogetac%', '%category%', $status ); // Undo what we did before. 183 186 $status = preg_replace( '~\R~u', "\r\n", $status ); 184 187 return $status; -
share-on-mastodon/tags/0.19.4/includes/class-plugin-options.php
r3317007 r3357470 164 164 $delay = min( $delay, HOUR_IN_SECONDS ); // Limit to one hour. 165 165 166 $status_template = ''; 167 if ( isset( $settings['status_template'] ) && is_string( $settings['status_template'] ) ) { 168 // Prevent the `%ca` in `%category%` from being mistaken for a percentage-encoded character. 169 $status_template = str_replace( '%category%', '%yrogetac%', $settings['status_template'] ); 170 $status_template = sanitize_textarea_field( $status_template ); 171 $status_template = str_replace( '%yrogetac%', '%category%', $status_template ); // Undo what we did before. 172 $status_template = preg_replace( '~\R~u', "\r\n", $status_template ); 173 } 174 166 175 $options = array( 167 176 'optin' => isset( $settings['optin'] ) ? true : false, … … 171 180 'syn_links_compat' => isset( $settings['syn_links_compat'] ) ? true : false, 172 181 'custom_status_field' => isset( $settings['custom_status_field'] ) ? true : false, 173 'status_template' => isset( $settings['status_template'] ) && is_string( $settings['status_template'] ) 174 ? preg_replace( '~\R~u', "\r\n", sanitize_textarea_field( $settings['status_template'] ) ) 175 : '', 182 'status_template' => $status_template, 176 183 'meta_box' => isset( $settings['meta_box'] ) ? true : false, 177 184 'content_warning' => isset( $settings['content_warning'] ) ? true : false, … … 415 422 <td><textarea name="share_on_mastodon_settings[status_template]" id="share_on_mastodon_status_template" rows="5" style="min-width: 33%;"><?php echo ! empty( $this->options['status_template'] ) ? esc_html( $this->options['status_template'] ) : ''; ?></textarea> 416 423 <?php /* translators: %s: supported template tags */ ?> 417 <p class="description"><?php printf( esc_html__( 'Customize the default status template. Supported “template tags”: %s.', 'share-on-mastodon' ), '<code>%title%</code>, <code>%excerpt%</code>, <code>%tags%</code>, <code>% permalink%</code>' ); ?></p></td>424 <p class="description"><?php printf( esc_html__( 'Customize the default status template. Supported “template tags”: %s.', 'share-on-mastodon' ), '<code>%title%</code>, <code>%excerpt%</code>, <code>%tags%</code>, <code>%category%</code>, <code>%permalink%</code>' ); ?></p></td> 418 425 </tr> 419 426 <tr valign="top"> -
share-on-mastodon/tags/0.19.4/includes/class-post-handler.php
r3317007 r3357470 556 556 $status = str_replace( '%title%', get_the_title( $post_id ), $status ); 557 557 $status = str_replace( '%tags%', $this->get_tags( $post_id ), $status ); 558 $status = str_replace( '%category%', $this->get_category( $post_id ), $status ); 558 559 559 560 // Estimate a max length of sorts. … … 645 646 646 647 /** 648 * Returns the first of a post's categories as a hashtag. 649 * 650 * @param int $post_id Post ID. 651 * @return string (Possibly "CamelCased") hashtag, or empty string. 652 */ 653 protected function get_category( $post_id ) { 654 $cats = get_the_category( $post_id ); 655 656 if ( empty( $cats[0]->cat_name ) ) { 657 return ''; 658 } 659 660 // Grab the first category. 661 $cat_name = $cats[0]->cat_name; 662 663 if ( preg_match( '/(\s|-)+/', $cat_name ) ) { 664 // Try to "CamelCase" multi-word categories. 665 $cat_name = preg_replace( '~(\s|-)+~', ' ', $cat_name ); 666 $cat_name = explode( ' ', $cat_name ); 667 $cat_name = implode( '', array_map( 'ucfirst', $cat_name ) ); 668 } 669 670 return '#' . trim( $cat_name ); 671 } 672 673 /** 647 674 * Checks for a Mastodon instance and auth token. 648 675 * -
share-on-mastodon/tags/0.19.4/includes/class-share-on-mastodon.php
r3328844 r3357470 10 10 */ 11 11 class Share_On_Mastodon { 12 const PLUGIN_VERSION = '0.19. 3';12 const PLUGIN_VERSION = '0.19.4'; 13 13 const DB_VERSION = '1'; 14 14 -
share-on-mastodon/tags/0.19.4/readme.txt
r3328844 r3357470 3 3 Tags: mastodon, social, fediverse, syndication, posse 4 4 Tested up to: 6.8 5 Stable tag: 0.19. 35 Stable tag: 0.19.4 6 6 License: GNU General Public License v3.0 7 7 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 29 29 30 30 == Changelog == 31 = 0.19.4 = 32 Added the `%category%` "template tag" to share a post's _first_ category _as a hashtag_. 33 31 34 = 0.19.3 = 32 35 Improved detection of "in-post images." -
share-on-mastodon/tags/0.19.4/share-on-mastodon.php
r3328844 r3357470 9 9 * License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 10 * Text Domain: share-on-mastodon 11 * Version: 0.19. 311 * Version: 0.19.4 12 12 * Requires at least: 5.9 13 13 * Requires PHP: 7.2 -
share-on-mastodon/trunk/includes/class-block-editor.php
r3317007 r3357470 180 180 }, 181 181 'sanitize_callback' => function ( $status ) { 182 // Prevent the `%ca` in `%category%` from being mistaken for a percentage-encoded character. 183 $status = str_replace( '%category%', '%yrogetac%', $status ); 182 184 $status = sanitize_textarea_field( $status ); 185 $status = str_replace( '%yrogetac%', '%category%', $status ); // Undo what we did before. 183 186 $status = preg_replace( '~\R~u', "\r\n", $status ); 184 187 return $status; -
share-on-mastodon/trunk/includes/class-plugin-options.php
r3317007 r3357470 164 164 $delay = min( $delay, HOUR_IN_SECONDS ); // Limit to one hour. 165 165 166 $status_template = ''; 167 if ( isset( $settings['status_template'] ) && is_string( $settings['status_template'] ) ) { 168 // Prevent the `%ca` in `%category%` from being mistaken for a percentage-encoded character. 169 $status_template = str_replace( '%category%', '%yrogetac%', $settings['status_template'] ); 170 $status_template = sanitize_textarea_field( $status_template ); 171 $status_template = str_replace( '%yrogetac%', '%category%', $status_template ); // Undo what we did before. 172 $status_template = preg_replace( '~\R~u', "\r\n", $status_template ); 173 } 174 166 175 $options = array( 167 176 'optin' => isset( $settings['optin'] ) ? true : false, … … 171 180 'syn_links_compat' => isset( $settings['syn_links_compat'] ) ? true : false, 172 181 'custom_status_field' => isset( $settings['custom_status_field'] ) ? true : false, 173 'status_template' => isset( $settings['status_template'] ) && is_string( $settings['status_template'] ) 174 ? preg_replace( '~\R~u', "\r\n", sanitize_textarea_field( $settings['status_template'] ) ) 175 : '', 182 'status_template' => $status_template, 176 183 'meta_box' => isset( $settings['meta_box'] ) ? true : false, 177 184 'content_warning' => isset( $settings['content_warning'] ) ? true : false, … … 415 422 <td><textarea name="share_on_mastodon_settings[status_template]" id="share_on_mastodon_status_template" rows="5" style="min-width: 33%;"><?php echo ! empty( $this->options['status_template'] ) ? esc_html( $this->options['status_template'] ) : ''; ?></textarea> 416 423 <?php /* translators: %s: supported template tags */ ?> 417 <p class="description"><?php printf( esc_html__( 'Customize the default status template. Supported “template tags”: %s.', 'share-on-mastodon' ), '<code>%title%</code>, <code>%excerpt%</code>, <code>%tags%</code>, <code>% permalink%</code>' ); ?></p></td>424 <p class="description"><?php printf( esc_html__( 'Customize the default status template. Supported “template tags”: %s.', 'share-on-mastodon' ), '<code>%title%</code>, <code>%excerpt%</code>, <code>%tags%</code>, <code>%category%</code>, <code>%permalink%</code>' ); ?></p></td> 418 425 </tr> 419 426 <tr valign="top"> -
share-on-mastodon/trunk/includes/class-post-handler.php
r3317007 r3357470 556 556 $status = str_replace( '%title%', get_the_title( $post_id ), $status ); 557 557 $status = str_replace( '%tags%', $this->get_tags( $post_id ), $status ); 558 $status = str_replace( '%category%', $this->get_category( $post_id ), $status ); 558 559 559 560 // Estimate a max length of sorts. … … 645 646 646 647 /** 648 * Returns the first of a post's categories as a hashtag. 649 * 650 * @param int $post_id Post ID. 651 * @return string (Possibly "CamelCased") hashtag, or empty string. 652 */ 653 protected function get_category( $post_id ) { 654 $cats = get_the_category( $post_id ); 655 656 if ( empty( $cats[0]->cat_name ) ) { 657 return ''; 658 } 659 660 // Grab the first category. 661 $cat_name = $cats[0]->cat_name; 662 663 if ( preg_match( '/(\s|-)+/', $cat_name ) ) { 664 // Try to "CamelCase" multi-word categories. 665 $cat_name = preg_replace( '~(\s|-)+~', ' ', $cat_name ); 666 $cat_name = explode( ' ', $cat_name ); 667 $cat_name = implode( '', array_map( 'ucfirst', $cat_name ) ); 668 } 669 670 return '#' . trim( $cat_name ); 671 } 672 673 /** 647 674 * Checks for a Mastodon instance and auth token. 648 675 * -
share-on-mastodon/trunk/includes/class-share-on-mastodon.php
r3328844 r3357470 10 10 */ 11 11 class Share_On_Mastodon { 12 const PLUGIN_VERSION = '0.19. 3';12 const PLUGIN_VERSION = '0.19.4'; 13 13 const DB_VERSION = '1'; 14 14 -
share-on-mastodon/trunk/readme.txt
r3328844 r3357470 3 3 Tags: mastodon, social, fediverse, syndication, posse 4 4 Tested up to: 6.8 5 Stable tag: 0.19. 35 Stable tag: 0.19.4 6 6 License: GNU General Public License v3.0 7 7 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 29 29 30 30 == Changelog == 31 = 0.19.4 = 32 Added the `%category%` "template tag" to share a post's _first_ category _as a hashtag_. 33 31 34 = 0.19.3 = 32 35 Improved detection of "in-post images." -
share-on-mastodon/trunk/share-on-mastodon.php
r3328844 r3357470 9 9 * License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 10 * Text Domain: share-on-mastodon 11 * Version: 0.19. 311 * Version: 0.19.4 12 12 * Requires at least: 5.9 13 13 * Requires PHP: 7.2
Note: See TracChangeset
for help on using the changeset viewer.