fix some last "follower" issues
This commit is contained in:
parent
d4f5ad8ec1
commit
5b712fb7cd
5 changed files with 17 additions and 9 deletions
|
@ -661,6 +661,6 @@ class Base_Object {
|
||||||
public function to_json() {
|
public function to_json() {
|
||||||
$array = $this->to_array();
|
$array = $this->to_array();
|
||||||
|
|
||||||
return \wp_json_encode( $array );
|
return \wp_json_encode( $array, \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_QUOT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class Activity_Dispatcher {
|
||||||
*/
|
*/
|
||||||
public static function init() {
|
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_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
|
// check if a migration is needed before sending new posts
|
||||||
Migration::maybe_migrate();
|
Migration::maybe_migrate();
|
||||||
|
|
||||||
|
if ( ! in_array( $type, array( 'Create', 'Update' ), true ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( is_user_disabled( Users::BLOG_USER_ID ) ) {
|
if ( is_user_disabled( Users::BLOG_USER_ID ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -110,10 +114,14 @@ class Activity_Dispatcher {
|
||||||
*
|
*
|
||||||
* @return void
|
* @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
|
// check if a migration is needed before sending new posts
|
||||||
Migration::maybe_migrate();
|
Migration::maybe_migrate();
|
||||||
|
|
||||||
|
if ( ! in_array( $type, array( 'Create', 'Update' ), true ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( is_user_disabled( Users::BLOG_USER_ID ) ) {
|
if ( is_user_disabled( Users::BLOG_USER_ID ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,7 +298,7 @@ class Followers {
|
||||||
*
|
*
|
||||||
* @return array The Term list of Followers, the format depends on $output
|
* @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(
|
$defaults = array(
|
||||||
'post_type' => self::POST_TYPE,
|
'post_type' => self::POST_TYPE,
|
||||||
'posts_per_page' => $number,
|
'posts_per_page' => $number,
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Followers extends WP_List_Table {
|
||||||
$this->set_pagination_args(
|
$this->set_pagination_args(
|
||||||
array(
|
array(
|
||||||
'total_items' => $counter,
|
'total_items' => $counter,
|
||||||
'total_pages' => round( $counter / $per_page ),
|
'total_pages' => ceil( $counter / $per_page ),
|
||||||
'per_page' => $per_page,
|
'per_page' => $per_page,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,17 +13,17 @@
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h1><?php \esc_html_e( 'Followers', 'activitypub' ); ?></h1>
|
<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. ?>
|
<?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">
|
<form method="get">
|
||||||
<input type="hidden" name="page" value="activitypub" />
|
<input type="hidden" name="page" value="activitypub" />
|
||||||
<input type="hidden" name="tab" value="followers" />
|
<input type="hidden" name="tab" value="followers" />
|
||||||
<?php
|
<?php
|
||||||
$followers_table->prepare_items();
|
$table->prepare_items();
|
||||||
$followers_table->display();
|
$table->display();
|
||||||
?>
|
?>
|
||||||
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
|
<?php wp_nonce_field( 'activitypub-followers-list', '_apnonce' ); ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue