Skip to content

Commit

Permalink
Moved followers list to user-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
pfefferle committed Aug 21, 2019
1 parent b6b0743 commit 2e91ce1
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 101 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Tags:** OStatus, fediverse, activitypub, activitystream
**Requires at least:** 4.7
**Tested up to:** 5.2.2
**Stable tag:** 0.7.3
**Stable tag:** 0.8.0
**Requires PHP:** 5.6
**License:** MIT
**License URI:** http://opensource.org/licenses/MIT
Expand Down Expand Up @@ -84,6 +84,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides.

Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).

### 0.8.0 ###

* Moved followers list to user-menu

### 0.7.4 ###

* added admin_email to metadata, to be able to "Manage your instance" on https://fediverse.network/manage/
Expand Down
3 changes: 2 additions & 1 deletion activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: ActivityPub
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
* Version: 0.7.4
* Version: 0.8.0
* Author: Matthias Pfefferle
* Author URI: https://notiz.blog/
* License: MIT
Expand All @@ -21,6 +21,7 @@
function init() {
defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' );

require_once dirname( __FILE__ ) . '/includes/table/followers-list.php';
require_once dirname( __FILE__ ) . '/includes/class-signature.php';
require_once dirname( __FILE__ ) . '/includes/class-activity.php';
require_once dirname( __FILE__ ) . '/includes/db/class-followers.php';
Expand Down
21 changes: 18 additions & 3 deletions includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,25 @@ public static function admin_menu() {
array( '\Activitypub\Admin', 'settings_page' )
);

add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_help_tab' ) );
add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) );

$followers_list_page = add_users_page( __( 'Followers', 'activitypub' ), __( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) );

add_action( 'load-' . $followers_list_page, array( '\Activitypub\Admin', 'add_followers_list_help_tab' ) );
}

/**
* Load settings page
*/
public static function settings_page() {
load_template( dirname( __FILE__ ) . '/../templates/settings-page.php' );
load_template( dirname( __FILE__ ) . '/../templates/settings.php' );
}

/**
* Load user settings page
*/
public static function followers_list_page() {
load_template( dirname( __FILE__ ) . '/../templates/followers-list.php' );
}

/**
Expand Down Expand Up @@ -89,7 +100,7 @@ public static function register_settings() {
);
}

public static function add_help_tab() {
public static function add_settings_help_tab() {
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
Expand All @@ -109,6 +120,10 @@ public static function add_help_tab() {
);
}

public static function add_followers_list_help_tab() {
// todo
}

public static function add_fediverse_profile( $user ) {
?>
<h2><?php esc_html_e( 'Fediverse', 'activitypub' ); ?></h2>
Expand Down
6 changes: 6 additions & 0 deletions includes/db/class-followers.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public static function get_followers( $author_id ) {
return $followers;
}

public static function count_followers( $author_id ) {
$followers = self::get_followers( $author_id );

return count( $followers );
}

public static function add_follower( $actor, $author_id ) {
$followers = get_user_option( 'activitypub_followers', $author_id );

Expand Down
36 changes: 36 additions & 0 deletions includes/table/followers-list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace Activitypub\Table;

if ( ! class_exists( '\WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}

class Followers_List extends \WP_List_Table {
public function get_columns() {
return array(
'identifier' => __( 'Identifier', 'activitypub' ),
);
}

public function get_sortable_columns() {
return array();
}

public function prepare_items() {
$columns = $this->get_columns();
$hidden = array();

$this->process_action();
$this->_column_headers = array( $columns, $hidden, $this->get_sortable_columns() );

$this->items = array();

foreach ( \Activitypub\Db\Followers::get_followers( get_current_user_id() ) as $follower ) {
$this->items[]['identifier'] = esc_attr( $follower );
}
}

public function column_default( $item, $column_name ) {
return $item[ $column_name ];
}
}
Loading

0 comments on commit 2e91ce1

Please sign in to comment.