Changeset 2876912
- Timestamp:
- 03/09/2023 05:57:30 AM (17 months ago)
- Location:
- shortnotes
- Files:
-
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
shortnotes/tags/1.5.0/LICENSE
r2703548 r2876912 1 1 Shortnotes - A WordPress plugin. 2 2 3 Copyright 2021-202 2by Jeremy Felt3 Copyright 2021-202 by Jeremy Felt 4 4 5 5 This program is free software; you can redistribute it and/or modify -
shortnotes/tags/1.5.0/includes/post-type-note.php
r2824968 r2876912 162 162 * function from the `allowed_block_types` filter won't cause any trouble. 163 163 * 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. 166 166 * @return array A modified list of allowed block types. 167 167 */ 168 function filter_allowed_block_types( $allowed_block_types, $post ) {168 function filter_allowed_block_types( $allowed_block_types, $post ) { 169 169 if ( get_slug() === $post->post_type ) { 170 170 return array( … … 205 205 * @return string Generated subtitle. 206 206 */ 207 function generate_sub_title( $html ){207 function generate_sub_title( { 208 208 $sub_title = wp_strip_all_tags( $html ); 209 209 … … 225 225 * @return string The formatted title. 226 226 */ 227 function get_formatted_title( $post_data ){227 function get_formatted_title( { 228 228 $blocks = parse_blocks( $post_data['post_content'] ); 229 229 … … 241 241 242 242 // A paragraph has been found, we're moving on and using it for the title. 243 244 245 246 247 243 248 break; 244 249 } elseif ( 'core/image' === $block['blockName'] ) { … … 279 284 * @return array $post_data A modified list of post data. 280 285 */ 281 function filter_wp_insert_post_data( $post_data ){286 function filter_wp_insert_post_data( { 282 287 if ( get_slug() !== $post_data['post_type'] ) { 283 288 return $post_data; … … 304 309 * @return string Markup to use for a u-in-reply-to. 305 310 */ 306 function get_reply_to_markup( $post ){311 function get_reply_to_markup( { 307 312 if ( get_slug() !== $post->post_type ) { 308 313 return ''; … … 366 371 * @return string The content, possibly prepended with additional markup. 367 372 */ 368 function prepend_reply_to_markup( $content ){373 function prepend_reply_to_markup( { 369 374 if ( is_admin() ) { 370 375 return $content; … … 378 383 return $content; 379 384 } 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 11 11 12 12 add_filter( 'share_on_mastodon_status', __NAMESPACE__ . '\filter_status_text', 10, 2 ); 13 13 14 14 15 /** … … 39 40 40 41 /** 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 41 60 * Retrieve the reply to ID for a Mastodon status URL. 42 61 * … … 45 64 */ 46 65 function 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 ); 48 69 49 if ( ! isset( $url_parts['path'] )) {70 if ( ! ) { 50 71 return 0; 51 72 } 52 73 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 ); 54 78 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 ) ) { 56 97 return 0; 57 98 } 58 99 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, '/' ) ); 66 101 67 102 if ( 2 !== count( $path_parts ) || ! is_numeric( $path_parts[1] ) ) { … … 79 114 * @return string The modified status text. 80 115 */ 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 ); 116 function filter_status_text( string $status, \WP_Post $post ): string { 117 $status = Note\transform_content( $post->post_content ); 104 118 105 119 return $status; 106 120 } 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 18 18 * @param int $post_id The post ID of the note. 19 19 */ 20 function schedule( $post_id ) {20 function schedule( $post_id ) { 21 21 if ( defined( 'WP_IMPORTING' ) || false === class_exists( 'Webmention_Sender' ) ) { 22 22 return; … … 33 33 * @param int $post_id The post ID of the note. 34 34 */ 35 function send( $post_id ) {35 function send( $post_id ) { 36 36 $post = get_post( $post_id ); 37 37 … … 49 49 * @return array A modified list of URLs. 50 50 */ 51 function filter_webmention_links( $urls, $post_id ){51 function filter_webmention_links( { 52 52 $post = get_post( $post_id ); 53 53 -
shortnotes/tags/1.5.0/languages/shortnotes.pot
r2824968 r2876912 1 # Copyright (C) 202 2jeremyfelt1 # Copyright (C) 202 jeremyfelt 2 2 # This file is distributed under the same license as the Shortnotes plugin. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Shortnotes 1. 3.1\n"5 "Project-Id-Version: Shortnotes 1.\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/shortnotes\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 202 2-11-23T22:57:51+00:00\n"12 "POT-Creation-Date: 202+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.6.0\n" … … 20 20 21 21 #. Plugin URI of the plugin 22 msgid "https:// github.com/jeremyfelt/shortnotes"22 msgid "https://" 23 23 msgstr "" 24 24 … … 144 144 msgstr "" 145 145 146 #: includes/post-type-note.php:2 45146 #: includes/post-type-note.php:2 147 147 msgid "Image posted on" 148 148 msgstr "" 149 149 150 #: includes/post-type-note.php:2 47150 #: includes/post-type-note.php:2 151 151 msgid "Images posted on" 152 152 msgstr "" 153 153 154 #: includes/post-type-note.php:32 0154 #: includes/post-type-note.php:32 155 155 msgid "this post" 156 156 msgstr "" 157 157 158 #: includes/post-type-note.php:33 4158 #: includes/post-type-note.php:33 159 159 msgid "In reply to:" 160 160 msgstr "" -
shortnotes/tags/1.5.0/plugin.php
r2824968 r2876912 2 2 /** 3 3 * Plugin Name: Shortnotes 4 * Plugin URI: https:// github.com/jeremyfelt/shortnotes4 * Plugin URI: https:// 5 5 * Description: Add a notes post type to WordPress. For your short notes. 6 6 * Author: jeremyfelt … … 8 8 * Text Domain: shortnotes 9 9 * Domain Path: /languages 10 * Version: 1. 4.010 * Version: 1..0 11 11 * 12 12 * @package shortnotes -
shortnotes/tags/1.5.0/readme.txt
r2824968 r2876912 4 4 Requires at least: 5.6 5 5 Tested up to: 6.1 6 Stable tag: 1. 4.06 Stable tag: 1..0 7 7 License: GPLv2 or Later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 63 63 64 64 ## Changelog 65 66 67 68 69 70 71 72 73 74 75 76 77 65 78 66 79 ### 1.4.0 -
shortnotes/trunk/LICENSE
r2703548 r2876912 1 1 Shortnotes - A WordPress plugin. 2 2 3 Copyright 2021-202 2by Jeremy Felt3 Copyright 2021-202 by Jeremy Felt 4 4 5 5 This program is free software; you can redistribute it and/or modify -
shortnotes/trunk/includes/post-type-note.php
r2824968 r2876912 162 162 * function from the `allowed_block_types` filter won't cause any trouble. 163 163 * 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. 166 166 * @return array A modified list of allowed block types. 167 167 */ 168 function filter_allowed_block_types( $allowed_block_types, $post ) {168 function filter_allowed_block_types( $allowed_block_types, $post ) { 169 169 if ( get_slug() === $post->post_type ) { 170 170 return array( … … 205 205 * @return string Generated subtitle. 206 206 */ 207 function generate_sub_title( $html ){207 function generate_sub_title( { 208 208 $sub_title = wp_strip_all_tags( $html ); 209 209 … … 225 225 * @return string The formatted title. 226 226 */ 227 function get_formatted_title( $post_data ){227 function get_formatted_title( { 228 228 $blocks = parse_blocks( $post_data['post_content'] ); 229 229 … … 241 241 242 242 // A paragraph has been found, we're moving on and using it for the title. 243 244 245 246 247 243 248 break; 244 249 } elseif ( 'core/image' === $block['blockName'] ) { … … 279 284 * @return array $post_data A modified list of post data. 280 285 */ 281 function filter_wp_insert_post_data( $post_data ){286 function filter_wp_insert_post_data( { 282 287 if ( get_slug() !== $post_data['post_type'] ) { 283 288 return $post_data; … … 304 309 * @return string Markup to use for a u-in-reply-to. 305 310 */ 306 function get_reply_to_markup( $post ){311 function get_reply_to_markup( { 307 312 if ( get_slug() !== $post->post_type ) { 308 313 return ''; … … 366 371 * @return string The content, possibly prepended with additional markup. 367 372 */ 368 function prepend_reply_to_markup( $content ){373 function prepend_reply_to_markup( { 369 374 if ( is_admin() ) { 370 375 return $content; … … 378 383 return $content; 379 384 } 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 11 11 12 12 add_filter( 'share_on_mastodon_status', __NAMESPACE__ . '\filter_status_text', 10, 2 ); 13 13 14 14 15 /** … … 39 40 40 41 /** 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 41 60 * Retrieve the reply to ID for a Mastodon status URL. 42 61 * … … 45 64 */ 46 65 function 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 ); 48 69 49 if ( ! isset( $url_parts['path'] )) {70 if ( ! ) { 50 71 return 0; 51 72 } 52 73 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 ); 54 78 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 ) ) { 56 97 return 0; 57 98 } 58 99 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, '/' ) ); 66 101 67 102 if ( 2 !== count( $path_parts ) || ! is_numeric( $path_parts[1] ) ) { … … 79 114 * @return string The modified status text. 80 115 */ 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 ); 116 function filter_status_text( string $status, \WP_Post $post ): string { 117 $status = Note\transform_content( $post->post_content ); 104 118 105 119 return $status; 106 120 } 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 18 18 * @param int $post_id The post ID of the note. 19 19 */ 20 function schedule( $post_id ) {20 function schedule( $post_id ) { 21 21 if ( defined( 'WP_IMPORTING' ) || false === class_exists( 'Webmention_Sender' ) ) { 22 22 return; … … 33 33 * @param int $post_id The post ID of the note. 34 34 */ 35 function send( $post_id ) {35 function send( $post_id ) { 36 36 $post = get_post( $post_id ); 37 37 … … 49 49 * @return array A modified list of URLs. 50 50 */ 51 function filter_webmention_links( $urls, $post_id ){51 function filter_webmention_links( { 52 52 $post = get_post( $post_id ); 53 53 -
shortnotes/trunk/languages/shortnotes.pot
r2824968 r2876912 1 # Copyright (C) 202 2jeremyfelt1 # Copyright (C) 202 jeremyfelt 2 2 # This file is distributed under the same license as the Shortnotes plugin. 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Shortnotes 1. 3.1\n"5 "Project-Id-Version: Shortnotes 1.\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/shortnotes\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 10 10 "Content-Type: text/plain; charset=UTF-8\n" 11 11 "Content-Transfer-Encoding: 8bit\n" 12 "POT-Creation-Date: 202 2-11-23T22:57:51+00:00\n"12 "POT-Creation-Date: 202+00:00\n" 13 13 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 14 14 "X-Generator: WP-CLI 2.6.0\n" … … 20 20 21 21 #. Plugin URI of the plugin 22 msgid "https:// github.com/jeremyfelt/shortnotes"22 msgid "https://" 23 23 msgstr "" 24 24 … … 144 144 msgstr "" 145 145 146 #: includes/post-type-note.php:2 45146 #: includes/post-type-note.php:2 147 147 msgid "Image posted on" 148 148 msgstr "" 149 149 150 #: includes/post-type-note.php:2 47150 #: includes/post-type-note.php:2 151 151 msgid "Images posted on" 152 152 msgstr "" 153 153 154 #: includes/post-type-note.php:32 0154 #: includes/post-type-note.php:32 155 155 msgid "this post" 156 156 msgstr "" 157 157 158 #: includes/post-type-note.php:33 4158 #: includes/post-type-note.php:33 159 159 msgid "In reply to:" 160 160 msgstr "" -
shortnotes/trunk/plugin.php
r2824968 r2876912 2 2 /** 3 3 * Plugin Name: Shortnotes 4 * Plugin URI: https:// github.com/jeremyfelt/shortnotes4 * Plugin URI: https:// 5 5 * Description: Add a notes post type to WordPress. For your short notes. 6 6 * Author: jeremyfelt … … 8 8 * Text Domain: shortnotes 9 9 * Domain Path: /languages 10 * Version: 1. 4.010 * Version: 1..0 11 11 * 12 12 * @package shortnotes -
shortnotes/trunk/readme.txt
r2824968 r2876912 4 4 Requires at least: 5.6 5 5 Tested up to: 6.1 6 Stable tag: 1. 4.06 Stable tag: 1..0 7 7 License: GPLv2 or Later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 63 63 64 64 ## Changelog 65 66 67 68 69 70 71 72 73 74 75 76 77 65 78 66 79 ### 1.4.0
Note: See TracChangeset
for help on using the changeset viewer.