Plugin Directory

Changeset 3357470


Ignore:
Timestamp:
09/07/2025 05:44:13 PM (7 months ago)
Author:
janboddez
Message:

Update to version 0.19.4 from GitHub

Location:
share-on-mastodon
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • share-on-mastodon/tags/0.19.4/includes/class-block-editor.php

    r3317007 r3357470  
    180180                            },
    181181                            '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 );
    182184                                $status = sanitize_textarea_field( $status );
     185                                $status = str_replace( '%yrogetac%', '%category%', $status ); // Undo what we did before.
    183186                                $status = preg_replace( '~\R~u', "\r\n", $status );
    184187                                return $status;
  • share-on-mastodon/tags/0.19.4/includes/class-plugin-options.php

    r3317007 r3357470  
    164164        $delay = min( $delay, HOUR_IN_SECONDS ); // Limit to one hour.
    165165
     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
    166175        $options = array(
    167176            'optin'               => isset( $settings['optin'] ) ? true : false,
     
    171180            'syn_links_compat'    => isset( $settings['syn_links_compat'] ) ? true : false,
    172181            '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,
    176183            'meta_box'            => isset( $settings['meta_box'] ) ? true : false,
    177184            'content_warning'     => isset( $settings['content_warning'] ) ? true : false,
     
    415422                            <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>
    416423                            <?php /* translators: %s: supported template tags */ ?>
    417                             <p class="description"><?php printf( esc_html__( 'Customize the default status template. Supported &ldquo;template tags&rdquo;: %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 &ldquo;template tags&rdquo;: %s.', 'share-on-mastodon' ), '<code>%title%</code>, <code>%excerpt%</code>, <code>%tags%</code>, <code>%category%</code>, <code>%permalink%</code>' ); ?></p></td>
    418425                        </tr>
    419426                        <tr valign="top">
  • share-on-mastodon/tags/0.19.4/includes/class-post-handler.php

    r3317007 r3357470  
    556556        $status = str_replace( '%title%', get_the_title( $post_id ), $status );
    557557        $status = str_replace( '%tags%', $this->get_tags( $post_id ), $status );
     558        $status = str_replace( '%category%', $this->get_category( $post_id ), $status );
    558559
    559560        // Estimate a max length of sorts.
     
    645646
    646647    /**
     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    /**
    647674     * Checks for a Mastodon instance and auth token.
    648675     *
  • share-on-mastodon/tags/0.19.4/includes/class-share-on-mastodon.php

    r3328844 r3357470  
    1010 */
    1111class Share_On_Mastodon {
    12     const PLUGIN_VERSION = '0.19.3';
     12    const PLUGIN_VERSION = '0.19.4';
    1313    const DB_VERSION     = '1';
    1414
  • share-on-mastodon/tags/0.19.4/readme.txt

    r3328844 r3357470  
    33Tags: mastodon, social, fediverse, syndication, posse
    44Tested up to: 6.8
    5 Stable tag: 0.19.3
     5Stable tag: 0.19.4
    66License: GNU General Public License v3.0
    77License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2929
    3030== Changelog ==
     31= 0.19.4 =
     32Added the `%category%` "template tag" to share a post's _first_ category _as a hashtag_.
     33
    3134= 0.19.3 =
    3235Improved detection of "in-post images."
  • share-on-mastodon/tags/0.19.4/share-on-mastodon.php

    r3328844 r3357470  
    99 * License URI:       http://www.gnu.org/licenses/gpl-3.0.html
    1010 * Text Domain:       share-on-mastodon
    11  * Version:           0.19.3
     11 * Version:           0.19.4
    1212 * Requires at least: 5.9
    1313 * Requires PHP:      7.2
  • share-on-mastodon/trunk/includes/class-block-editor.php

    r3317007 r3357470  
    180180                            },
    181181                            '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 );
    182184                                $status = sanitize_textarea_field( $status );
     185                                $status = str_replace( '%yrogetac%', '%category%', $status ); // Undo what we did before.
    183186                                $status = preg_replace( '~\R~u', "\r\n", $status );
    184187                                return $status;
  • share-on-mastodon/trunk/includes/class-plugin-options.php

    r3317007 r3357470  
    164164        $delay = min( $delay, HOUR_IN_SECONDS ); // Limit to one hour.
    165165
     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
    166175        $options = array(
    167176            'optin'               => isset( $settings['optin'] ) ? true : false,
     
    171180            'syn_links_compat'    => isset( $settings['syn_links_compat'] ) ? true : false,
    172181            '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,
    176183            'meta_box'            => isset( $settings['meta_box'] ) ? true : false,
    177184            'content_warning'     => isset( $settings['content_warning'] ) ? true : false,
     
    415422                            <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>
    416423                            <?php /* translators: %s: supported template tags */ ?>
    417                             <p class="description"><?php printf( esc_html__( 'Customize the default status template. Supported &ldquo;template tags&rdquo;: %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 &ldquo;template tags&rdquo;: %s.', 'share-on-mastodon' ), '<code>%title%</code>, <code>%excerpt%</code>, <code>%tags%</code>, <code>%category%</code>, <code>%permalink%</code>' ); ?></p></td>
    418425                        </tr>
    419426                        <tr valign="top">
  • share-on-mastodon/trunk/includes/class-post-handler.php

    r3317007 r3357470  
    556556        $status = str_replace( '%title%', get_the_title( $post_id ), $status );
    557557        $status = str_replace( '%tags%', $this->get_tags( $post_id ), $status );
     558        $status = str_replace( '%category%', $this->get_category( $post_id ), $status );
    558559
    559560        // Estimate a max length of sorts.
     
    645646
    646647    /**
     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    /**
    647674     * Checks for a Mastodon instance and auth token.
    648675     *
  • share-on-mastodon/trunk/includes/class-share-on-mastodon.php

    r3328844 r3357470  
    1010 */
    1111class Share_On_Mastodon {
    12     const PLUGIN_VERSION = '0.19.3';
     12    const PLUGIN_VERSION = '0.19.4';
    1313    const DB_VERSION     = '1';
    1414
  • share-on-mastodon/trunk/readme.txt

    r3328844 r3357470  
    33Tags: mastodon, social, fediverse, syndication, posse
    44Tested up to: 6.8
    5 Stable tag: 0.19.3
     5Stable tag: 0.19.4
    66License: GNU General Public License v3.0
    77License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    2929
    3030== Changelog ==
     31= 0.19.4 =
     32Added the `%category%` "template tag" to share a post's _first_ category _as a hashtag_.
     33
    3134= 0.19.3 =
    3235Improved detection of "in-post images."
  • share-on-mastodon/trunk/share-on-mastodon.php

    r3328844 r3357470  
    99 * License URI:       http://www.gnu.org/licenses/gpl-3.0.html
    1010 * Text Domain:       share-on-mastodon
    11  * Version:           0.19.3
     11 * Version:           0.19.4
    1212 * Requires at least: 5.9
    1313 * Requires PHP:      7.2
Note: See TracChangeset for help on using the changeset viewer.