| 1 |
<?php |
| 2 |
/** |
| 3 |
* Menu file. |
| 4 |
* |
| 5 |
* @package Activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Activitypub\WP_Admin; |
| 9 |
|
| 10 |
use function Activitypub\user_can_activitypub; |
| 11 |
|
| 12 |
/** |
| 13 |
* ActivityPub Menu Class. |
| 14 |
*/ |
| 15 |
class Menu { |
| 16 |
|
| 17 |
/** |
| 18 |
* Add admin menu entry. |
| 19 |
*/ |
| 20 |
public static function admin_menu() { |
| 21 |
$settings_page = \add_options_page( |
| 22 |
'Welcome', |
| 23 |
'ActivityPub', |
| 24 |
'manage_options', |
| 25 |
'activitypub', |
| 26 |
array( Settings::class, 'settings_page' ) |
| 27 |
); |
| 28 |
|
| 29 |
\add_action( 'load-' . $settings_page, array( Settings::class, 'add_settings_help_tab' ) ); |
| 30 |
\add_action( 'load-users.php', array( Settings::class, 'add_users_help_tab' ) ); |
| 31 |
|
| 32 |
// User has to be able to publish posts. |
| 33 |
if ( user_can_activitypub( \get_current_user_id() ) ) { |
| 34 |
$followers_list_page = \add_users_page( |
| 35 |
\__( 'Followers ⁂', 'activitypub' ), |
| 36 |
\__( 'Followers ⁂', 'activitypub' ), |
| 37 |
'activitypub', |
| 38 |
'activitypub-followers-list', |
| 39 |
array( Admin::class, 'followers_list_page' ) |
| 40 |
); |
| 41 |
|
| 42 |
\add_action( 'load-' . $followers_list_page, array( Admin::class, 'add_followers_list_help_tab' ) ); |
| 43 |
|
| 44 |
/** |
| 45 |
* Filter to show the following UI. |
| 46 |
* |
| 47 |
* @param bool $show Show following UI. |
| 48 |
*/ |
| 49 |
if ( \apply_filters( 'activitypub_show_following_ui', false ) ) { |
| 50 |
$following_list_page = \add_users_page( |
| 51 |
\__( 'Following ⁂', 'activitypub' ), |
| 52 |
\__( 'Following ⁂', 'activitypub' ), |
| 53 |
'activitypub', |
| 54 |
'activitypub-following-list', |
| 55 |
array( Admin::class, 'following_list_page' ) |
| 56 |
); |
| 57 |
|
| 58 |
\add_action( 'load-' . $following_list_page, array( Admin::class, 'add_following_list_help_tab' ) ); |
| 59 |
} |
| 60 |
|
| 61 |
\add_users_page( |
| 62 |
\__( 'Extra Fields ⁂', 'activitypub' ), |
| 63 |
\__( 'Extra Fields ⁂', 'activitypub' ), |
| 64 |
'activitypub', |
| 65 |
\esc_url( \admin_url( '/edit.php?post_type=ap_extrafield' ) ) |
| 66 |
); |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
|