fix some last "follower" issues

This commit is contained in:
Matthias Pfefferle 2023-07-07 13:43:12 +02:00
parent d4f5ad8ec1
commit 5b712fb7cd
5 changed files with 17 additions and 9 deletions

View file

@ -661,6 +661,6 @@ class Base_Object {
public function to_json() {
$array = $this->to_array();
return \wp_json_encode( $array );
return \wp_json_encode( $array, \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT );
}
}

View file

@ -23,7 +23,7 @@ class Activity_Dispatcher {
*/
public static function init() {
\add_action( 'activitypub_send_activity', array( self::class, 'send_user_activity' ), 10, 2 );
\add_action( 'activitypub_send_activity', array( self::class, 'send_blog_activity' ), 10, 2 );
\add_action( 'activitypub_send_activity', array( self::class, 'send_announce_activity' ), 10, 2 );
}
/**
@ -74,6 +74,10 @@ class Activity_Dispatcher {
// check if a migration is needed before sending new posts
Migration::maybe_migrate();
if ( ! in_array( $type, array( 'Create', 'Update' ), true ) ) {
return;
}
if ( is_user_disabled( Users::BLOG_USER_ID ) ) {
return;
}
@ -110,10 +114,14 @@ class Activity_Dispatcher {
*
* @return void
*/
public static function send_blog_announce_activity( WP_Post $wp_post, $type ) {
public static function send_announce_activity( WP_Post $wp_post, $type ) {
// check if a migration is needed before sending new posts
Migration::maybe_migrate();
if ( ! in_array( $type, array( 'Create', 'Update' ), true ) ) {
return;
}
if ( is_user_disabled( Users::BLOG_USER_ID ) ) {
return;
}

View file

@ -298,7 +298,7 @@ class Followers {
*
* @return array The Term list of Followers, the format depends on $output
*/
public static function get_followers( $user_id, $number = null, $page = null, $args = array() ) {
public static function get_followers( $user_id, $number = -1, $page = null, $args = array() ) {
$defaults = array(
'post_type' => self::POST_TYPE,
'posts_per_page' => $number,

View file

@ -62,7 +62,7 @@ class Followers extends WP_List_Table {
$this->set_pagination_args(
array(
'total_items' => $counter,
'total_pages' => round( $counter / $per_page ),
'total_pages' => ceil( $counter / $per_page ),
'per_page' => $per_page,
)
);

View file

@ -13,17 +13,17 @@
<div class="wrap">
<h1><?php \esc_html_e( 'Followers', 'activitypub' ); ?></h1>
<?php $followers_table = new \Activitypub\Table\Followers(); ?>
<?php $table = new \Activitypub\Table\Followers(); ?>
<?php // translators: The follower count. ?>
<p><?php \printf( \esc_html__( 'You currently have %s followers.', 'activitypub' ), \esc_attr( $followers_table->get_user_count() ) ); ?></p>
<p><?php \printf( \esc_html__( 'You currently have %s followers.', 'activitypub' ), \esc_attr( $table->get_user_count() ) ); ?></p>
<form method="get">
<input type="hidden" name="page" value="activitypub" />
<input type="hidden" name="tab" value="followers" />
<?php
$followers_table->prepare_items();
$followers_table->display();
$table->prepare_items();
$table->display();
?>
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
</form>