Plugin Directory

Changeset 2876912

Timestamp:
03/09/2023 05:57:30 AM (17 months ago)
Author:
jeremyfelt
Message:

Update to version 1.5.0 from GitHub

Location:
shortnotes
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • shortnotes/tags/1.5.0/LICENSE

    r2703548 r2876912  
    11Shortnotes - A WordPress plugin.
    22
    3 Copyright 2021-2022 by Jeremy Felt
     3Copyright 2021-202 by Jeremy Felt
    44
    55This program is free software; you can redistribute it and/or modify
  • shortnotes/tags/1.5.0/includes/post-type-note.php

    r2824968 r2876912  
    162162 *       function from the `allowed_block_types` filter won't cause any trouble.
    163163 *
    164  * @param array    $allowed_block_types A list of allowed block types.
    165  * @param \WP_Post $post                The current note.
     164 * @param .
     165 * @param \WP_Post $post                The current note.
    166166 * @return array A modified list of allowed block types.
    167167 */
    168 function filter_allowed_block_types( $allowed_block_types, $post ) {
     168function filter_allowed_block_types( $allowed_block_types, $post ) {
    169169    if ( get_slug() === $post->post_type ) {
    170170        return array(
     
    205205 * @return string Generated subtitle.
    206206 */
    207 function generate_sub_title( $html ) {
     207function generate_sub_title( {
    208208    $sub_title = wp_strip_all_tags( $html );
    209209
     
    225225 * @return string The formatted title.
    226226 */
    227 function get_formatted_title( $post_data ) {
     227function get_formatted_title( {
    228228    $blocks = parse_blocks( $post_data['post_content'] );
    229229
     
    241241
    242242            // A paragraph has been found, we're moving on and using it for the title.
     243
     244
     245
     246
     247
    243248            break;
    244249        } elseif ( 'core/image' === $block['blockName'] ) {
     
    279284 * @return array $post_data A modified list of post data.
    280285 */
    281 function filter_wp_insert_post_data( $post_data ) {
     286function filter_wp_insert_post_data( {
    282287    if ( get_slug() !== $post_data['post_type'] ) {
    283288        return $post_data;
     
    304309 * @return string Markup to use for a u-in-reply-to.
    305310 */
    306 function get_reply_to_markup( $post ) {
     311function get_reply_to_markup( {
    307312    if ( get_slug() !== $post->post_type ) {
    308313        return '';
     
    366371 * @return string The content, possibly prepended with additional markup.
    367372 */
    368 function prepend_reply_to_markup( $content ) {
     373function prepend_reply_to_markup( {
    369374    if ( is_admin() ) {
    370375        return $content;
     
    378383    return $content;
    379384}
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
  • shortnotes/tags/1.5.0/includes/share-on-mastodon.php

    r2824968 r2876912  
    1111
    1212add_filter( 'share_on_mastodon_status', __NAMESPACE__ . '\filter_status_text', 10, 2 );
     13
    1314
    1415/**
     
    3940
    4041/**
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
    4160 * Retrieve the reply to ID for a Mastodon status URL.
    4261 *
     
    4564 */
    4665function get_reply_to_id( string $url ) : int {
    47     $url_parts = wp_parse_url( $url );
     66    $site_host = wp_parse_url( home_url(), PHP_URL_HOST );
     67    $url_host  = wp_parse_url( $url, PHP_URL_HOST );
     68    $url_path  = wp_parse_url( $url, PHP_URL_PATH );
    4869
    49     if ( ! isset( $url_parts['path'] ) ) {
     70    if ( ! ) {
    5071        return 0;
    5172    }
    5273
    53     $result = wp_remote_head( $url );
     74    if ( $site_host === $url_host ) {
     75        $path_parts = explode( '/', trim( $url_path, '/' ) );
     76        $post_name  = array_pop( $path_parts ); // Huge assumptions are okay with me!
     77        $post_id    = Note\get_note_by_post_name( $post_name );
    5478
    55     if ( is_wp_error( $result ) ) {
     79        // No note was found.
     80        if ( ! $post_id ) {
     81            return 0;
     82        }
     83
     84        // Override the URL with the note's previously stored Mastodon URL.
     85        $url = get_post_meta( $post_id, '_share_on_mastodon_url', true );
     86
     87        if ( ! $url ) {
     88            return 0;
     89        }
     90
     91        $url_path = wp_parse_url( $url, PHP_URL_PATH );
     92
     93        if ( ! $url_path ) {
     94            return 0;
     95        }
     96    } elseif ( false === is_mastodon_server( $url ) ) {
    5697        return 0;
    5798    }
    5899
    59     $server = strtolower( wp_remote_retrieve_header( $result, 'server' ) );
    60 
    61     if ( 'mastodon' !== $server ) {
    62         return 0;
    63     }
    64 
    65     $path_parts = explode( '/', trim( $url_parts['path'], '/' ) );
     100    $path_parts = explode( '/', trim( $url_path, '/' ) );
    66101
    67102    if ( 2 !== count( $path_parts ) || ! is_numeric( $path_parts[1] ) ) {
     
    79114 * @return string The modified status text.
    80115 */
    81 function filter_status_text( $status, $post ) {
    82     $status = apply_filters( 'the_content', $post->post_content ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
    83     $status = trim( $status );
    84     $status = convert_anchors( $status );
    85 
    86     $status = str_replace( '<p>', '', $status );
    87     $status = substr_replace( $status, ' ', strrpos( $status, '</p>' ), 4 );
    88     $status = str_replace( '</p>', "\n\n", $status );
    89 
    90     // Do what the plugin does to the title, but to the rendered content.
    91     $status = wp_strip_all_tags(
    92         html_entity_decode( $status, ENT_QUOTES | ENT_HTML5, get_bloginfo( 'charset' ) ) // Avoid double-encoded HTML entities.
    93     );
    94 
    95     // Remove more than two contiguous line breaks. Thanks, wpautop!
    96     $status = preg_replace( "/\n\n+/", "\n\n", $status );
    97 
    98     add_filter(
    99         'share_on_mastodon_toot_args',
    100         function( $args ) use ( $post ) {
    101             return filter_args( $args, $post );
    102         }
    103     );
     116function filter_status_text( string $status, \WP_Post $post ): string {
     117    $status = Note\transform_content( $post->post_content );
    104118
    105119    return $status;
    106120}
    107 
    108 /**
    109  * Parse and move anchors to the end of post content.
    110  *
    111  * @param string $html The post content.
    112  * @return string Modified post content.
    113  */
    114 function convert_anchors( string $html ) : string {
    115     preg_match_all( '/<a\s+(?:[^>]*?\s+)?href=(["\'])(.*?)\1/', $html, $matches );
    116 
    117     $links = array_filter(
    118         $matches[2],
    119         function( $link ) {
    120             return wp_parse_url( $link, PHP_URL_HOST );
    121         }
    122     );
    123 
    124     return $html . implode( ' ', $links );
    125 }
  • shortnotes/tags/1.5.0/includes/webmention.php

    r2824968 r2876912  
    1818 * @param int $post_id The post ID of the note.
    1919 */
    20 function schedule( $post_id ) {
     20function schedule( $post_id ) {
    2121    if ( defined( 'WP_IMPORTING' ) || false === class_exists( 'Webmention_Sender' ) ) {
    2222        return;
     
    3333 * @param int $post_id The post ID of the note.
    3434 */
    35 function send( $post_id ) {
     35function send( $post_id ) {
    3636    $post = get_post( $post_id );
    3737
     
    4949 * @return array A modified list of URLs.
    5050 */
    51 function filter_webmention_links( $urls, $post_id ) {
     51function filter_webmention_links( {
    5252    $post = get_post( $post_id );
    5353
  • shortnotes/tags/1.5.0/languages/shortnotes.pot

    r2824968 r2876912  
    1 # Copyright (C) 2022 jeremyfelt
     1# Copyright (C) 202 jeremyfelt
    22# This file is distributed under the same license as the Shortnotes plugin.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Shortnotes 1.3.1\n"
     5"Project-Id-Version: Shortnotes 1.\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/shortnotes\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2022-11-23T22:57:51+00:00\n"
     12"POT-Creation-Date: 202+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.6.0\n"
     
    2020
    2121#. Plugin URI of the plugin
    22 msgid "https://github.com/jeremyfelt/shortnotes"
     22msgid "https://"
    2323msgstr ""
    2424
     
    144144msgstr ""
    145145
    146 #: includes/post-type-note.php:245
     146#: includes/post-type-note.php:2
    147147msgid "Image posted on"
    148148msgstr ""
    149149
    150 #: includes/post-type-note.php:247
     150#: includes/post-type-note.php:2
    151151msgid "Images posted on"
    152152msgstr ""
    153153
    154 #: includes/post-type-note.php:320
     154#: includes/post-type-note.php:32
    155155msgid "this post"
    156156msgstr ""
    157157
    158 #: includes/post-type-note.php:334
     158#: includes/post-type-note.php:33
    159159msgid "In reply to:"
    160160msgstr ""
  • shortnotes/tags/1.5.0/plugin.php

    r2824968 r2876912  
    22/**
    33 * Plugin Name:     Shortnotes
    4  * Plugin URI:      https://github.com/jeremyfelt/shortnotes
     4 * Plugin URI:      https://
    55 * Description:     Add a notes post type to WordPress. For your short notes.
    66 * Author:          jeremyfelt
     
    88 * Text Domain:     shortnotes
    99 * Domain Path:     /languages
    10  * Version:         1.4.0
     10 * Version:         1..0
    1111 *
    1212 * @package shortnotes
  • shortnotes/tags/1.5.0/readme.txt

    r2824968 r2876912  
    44Requires at least: 5.6
    55Tested up to: 6.1
    6 Stable tag: 1.4.0
     6Stable tag: 1..0
    77License: GPLv2 or Later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6363
    6464## Changelog
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
    6578
    6679### 1.4.0
  • shortnotes/trunk/LICENSE

    r2703548 r2876912  
    11Shortnotes - A WordPress plugin.
    22
    3 Copyright 2021-2022 by Jeremy Felt
     3Copyright 2021-202 by Jeremy Felt
    44
    55This program is free software; you can redistribute it and/or modify
  • shortnotes/trunk/includes/post-type-note.php

    r2824968 r2876912  
    162162 *       function from the `allowed_block_types` filter won't cause any trouble.
    163163 *
    164  * @param array    $allowed_block_types A list of allowed block types.
    165  * @param \WP_Post $post                The current note.
     164 * @param .
     165 * @param \WP_Post $post                The current note.
    166166 * @return array A modified list of allowed block types.
    167167 */
    168 function filter_allowed_block_types( $allowed_block_types, $post ) {
     168function filter_allowed_block_types( $allowed_block_types, $post ) {
    169169    if ( get_slug() === $post->post_type ) {
    170170        return array(
     
    205205 * @return string Generated subtitle.
    206206 */
    207 function generate_sub_title( $html ) {
     207function generate_sub_title( {
    208208    $sub_title = wp_strip_all_tags( $html );
    209209
     
    225225 * @return string The formatted title.
    226226 */
    227 function get_formatted_title( $post_data ) {
     227function get_formatted_title( {
    228228    $blocks = parse_blocks( $post_data['post_content'] );
    229229
     
    241241
    242242            // A paragraph has been found, we're moving on and using it for the title.
     243
     244
     245
     246
     247
    243248            break;
    244249        } elseif ( 'core/image' === $block['blockName'] ) {
     
    279284 * @return array $post_data A modified list of post data.
    280285 */
    281 function filter_wp_insert_post_data( $post_data ) {
     286function filter_wp_insert_post_data( {
    282287    if ( get_slug() !== $post_data['post_type'] ) {
    283288        return $post_data;
     
    304309 * @return string Markup to use for a u-in-reply-to.
    305310 */
    306 function get_reply_to_markup( $post ) {
     311function get_reply_to_markup( {
    307312    if ( get_slug() !== $post->post_type ) {
    308313        return '';
     
    366371 * @return string The content, possibly prepended with additional markup.
    367372 */
    368 function prepend_reply_to_markup( $content ) {
     373function prepend_reply_to_markup( {
    369374    if ( is_admin() ) {
    370375        return $content;
     
    378383    return $content;
    379384}
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
  • shortnotes/trunk/includes/share-on-mastodon.php

    r2824968 r2876912  
    1111
    1212add_filter( 'share_on_mastodon_status', __NAMESPACE__ . '\filter_status_text', 10, 2 );
     13
    1314
    1415/**
     
    3940
    4041/**
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
    4160 * Retrieve the reply to ID for a Mastodon status URL.
    4261 *
     
    4564 */
    4665function get_reply_to_id( string $url ) : int {
    47     $url_parts = wp_parse_url( $url );
     66    $site_host = wp_parse_url( home_url(), PHP_URL_HOST );
     67    $url_host  = wp_parse_url( $url, PHP_URL_HOST );
     68    $url_path  = wp_parse_url( $url, PHP_URL_PATH );
    4869
    49     if ( ! isset( $url_parts['path'] ) ) {
     70    if ( ! ) {
    5071        return 0;
    5172    }
    5273
    53     $result = wp_remote_head( $url );
     74    if ( $site_host === $url_host ) {
     75        $path_parts = explode( '/', trim( $url_path, '/' ) );
     76        $post_name  = array_pop( $path_parts ); // Huge assumptions are okay with me!
     77        $post_id    = Note\get_note_by_post_name( $post_name );
    5478
    55     if ( is_wp_error( $result ) ) {
     79        // No note was found.
     80        if ( ! $post_id ) {
     81            return 0;
     82        }
     83
     84        // Override the URL with the note's previously stored Mastodon URL.
     85        $url = get_post_meta( $post_id, '_share_on_mastodon_url', true );
     86
     87        if ( ! $url ) {
     88            return 0;
     89        }
     90
     91        $url_path = wp_parse_url( $url, PHP_URL_PATH );
     92
     93        if ( ! $url_path ) {
     94            return 0;
     95        }
     96    } elseif ( false === is_mastodon_server( $url ) ) {
    5697        return 0;
    5798    }
    5899
    59     $server = strtolower( wp_remote_retrieve_header( $result, 'server' ) );
    60 
    61     if ( 'mastodon' !== $server ) {
    62         return 0;
    63     }
    64 
    65     $path_parts = explode( '/', trim( $url_parts['path'], '/' ) );
     100    $path_parts = explode( '/', trim( $url_path, '/' ) );
    66101
    67102    if ( 2 !== count( $path_parts ) || ! is_numeric( $path_parts[1] ) ) {
     
    79114 * @return string The modified status text.
    80115 */
    81 function filter_status_text( $status, $post ) {
    82     $status = apply_filters( 'the_content', $post->post_content ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
    83     $status = trim( $status );
    84     $status = convert_anchors( $status );
    85 
    86     $status = str_replace( '<p>', '', $status );
    87     $status = substr_replace( $status, ' ', strrpos( $status, '</p>' ), 4 );
    88     $status = str_replace( '</p>', "\n\n", $status );
    89 
    90     // Do what the plugin does to the title, but to the rendered content.
    91     $status = wp_strip_all_tags(
    92         html_entity_decode( $status, ENT_QUOTES | ENT_HTML5, get_bloginfo( 'charset' ) ) // Avoid double-encoded HTML entities.
    93     );
    94 
    95     // Remove more than two contiguous line breaks. Thanks, wpautop!
    96     $status = preg_replace( "/\n\n+/", "\n\n", $status );
    97 
    98     add_filter(
    99         'share_on_mastodon_toot_args',
    100         function( $args ) use ( $post ) {
    101             return filter_args( $args, $post );
    102         }
    103     );
     116function filter_status_text( string $status, \WP_Post $post ): string {
     117    $status = Note\transform_content( $post->post_content );
    104118
    105119    return $status;
    106120}
    107 
    108 /**
    109  * Parse and move anchors to the end of post content.
    110  *
    111  * @param string $html The post content.
    112  * @return string Modified post content.
    113  */
    114 function convert_anchors( string $html ) : string {
    115     preg_match_all( '/<a\s+(?:[^>]*?\s+)?href=(["\'])(.*?)\1/', $html, $matches );
    116 
    117     $links = array_filter(
    118         $matches[2],
    119         function( $link ) {
    120             return wp_parse_url( $link, PHP_URL_HOST );
    121         }
    122     );
    123 
    124     return $html . implode( ' ', $links );
    125 }
  • shortnotes/trunk/includes/webmention.php

    r2824968 r2876912  
    1818 * @param int $post_id The post ID of the note.
    1919 */
    20 function schedule( $post_id ) {
     20function schedule( $post_id ) {
    2121    if ( defined( 'WP_IMPORTING' ) || false === class_exists( 'Webmention_Sender' ) ) {
    2222        return;
     
    3333 * @param int $post_id The post ID of the note.
    3434 */
    35 function send( $post_id ) {
     35function send( $post_id ) {
    3636    $post = get_post( $post_id );
    3737
     
    4949 * @return array A modified list of URLs.
    5050 */
    51 function filter_webmention_links( $urls, $post_id ) {
     51function filter_webmention_links( {
    5252    $post = get_post( $post_id );
    5353
  • shortnotes/trunk/languages/shortnotes.pot

    r2824968 r2876912  
    1 # Copyright (C) 2022 jeremyfelt
     1# Copyright (C) 202 jeremyfelt
    22# This file is distributed under the same license as the Shortnotes plugin.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Shortnotes 1.3.1\n"
     5"Project-Id-Version: Shortnotes 1.\n"
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/shortnotes\n"
    77"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2022-11-23T22:57:51+00:00\n"
     12"POT-Creation-Date: 202+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.6.0\n"
     
    2020
    2121#. Plugin URI of the plugin
    22 msgid "https://github.com/jeremyfelt/shortnotes"
     22msgid "https://"
    2323msgstr ""
    2424
     
    144144msgstr ""
    145145
    146 #: includes/post-type-note.php:245
     146#: includes/post-type-note.php:2
    147147msgid "Image posted on"
    148148msgstr ""
    149149
    150 #: includes/post-type-note.php:247
     150#: includes/post-type-note.php:2
    151151msgid "Images posted on"
    152152msgstr ""
    153153
    154 #: includes/post-type-note.php:320
     154#: includes/post-type-note.php:32
    155155msgid "this post"
    156156msgstr ""
    157157
    158 #: includes/post-type-note.php:334
     158#: includes/post-type-note.php:33
    159159msgid "In reply to:"
    160160msgstr ""
  • shortnotes/trunk/plugin.php

    r2824968 r2876912  
    22/**
    33 * Plugin Name:     Shortnotes
    4  * Plugin URI:      https://github.com/jeremyfelt/shortnotes
     4 * Plugin URI:      https://
    55 * Description:     Add a notes post type to WordPress. For your short notes.
    66 * Author:          jeremyfelt
     
    88 * Text Domain:     shortnotes
    99 * Domain Path:     /languages
    10  * Version:         1.4.0
     10 * Version:         1..0
    1111 *
    1212 * @package shortnotes
  • shortnotes/trunk/readme.txt

    r2824968 r2876912  
    44Requires at least: 5.6
    55Tested up to: 6.1
    6 Stable tag: 1.4.0
     6Stable tag: 1..0
    77License: GPLv2 or Later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6363
    6464## Changelog
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
    6578
    6679### 1.4.0
Note: See TracChangeset for help on using the changeset viewer.