This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'activitypub_safe_remote_post_response', function( $response, $url, $body, $user_id ) { | |
$activity = json_decode( $body ); | |
if ( empty( $activity->type ) || 'Create' !== $activity->type ) { | |
error_log( 'Not a Create activity.' ); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds video to Share on Mastodon's attachment array by hooking into Share on | |
* Mastodon's `share_on_mastodon_media` filter. | |
* | |
* Just drop this file into `wp-content/mu-plugins`. | |
* | |
* @param array $media Array of up to 4 image IDs. | |
* @param WP_Post $post Post object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Exclude "likes" and "reposts" from comment count. We'd use a comment query but there's a weird bug that messes up counts when using meta query. | |
add_filter( 'get_comments_number', function( $count, $post_id ) { | |
if ( is_admin() ) { | |
return $count; | |
} | |
if ( ! is_singular() ) { | |
return $count; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function randomize_block_core_gallery( $parsed_block ) { | |
if ( 'core/gallery' === $parsed_block['blockName'] && isset( $parsed_block['attrs']['className'] ) && 'random' === $parsed_block['attrs']['className'] ) { | |
shuffle( $parsed_block['innerBlocks'] ); | |
} | |
return $parsed_block; | |
} | |
add_filter( 'render_block_data', 'randomize_block_core_gallery' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Our "API client," responsible for turning recent toots into WordPress posts. | |
* | |
* @package Import_From_Mastodon | |
*/ | |
namespace Import_From_Mastodon; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'pre_get_posts', function( $query ) { | |
if ( is_admin() ) { | |
return $query; | |
} | |
if ( is_feed() ) { | |
return $query; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Webmention Widget | |
* Description: Add recent webmentions’ status to WordPress’ dashboard. | |
* Version: 0.1 | |
* Author: Jan Boddez | |
* Author URI: https://jan.boddez.net/ | |
* License: GNU General Public License v2 or later | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'webmention_post_send', function( $response, $source, $target, $post_id ) { | |
if ( is_wp_error( $response ) ) { | |
// Something went wrong. | |
error_log( 'Error trying to send webmention to ' . esc_url_raw( $target ) . ': ' . $response->get_error_message() ); | |
} else { | |
error_log( 'Sent webmention to ' . esc_url_raw( $target ) . '; response code: ' . wp_remote_retrieve_response_code( $response ) ); | |
} |