| 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 |
\_x( 'Welcome', 'page title', 'activitypub' ), |
| 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 |
\add_action( 'load-' . $settings_page, array( Admin::class, 'add_settings_list_tables' ) ); |
| 32 |
\add_action( 'load-' . $settings_page, array( Screen_Options::class, 'add_settings_list_options' ) ); |
| 33 |
|
| 34 |
if ( \get_option( 'activitypub_reader_ui', '0' ) && \version_compare( \get_bloginfo( 'version' ), '6.9-alpha', '>=' ) ) { |
| 35 |
$app_hook = \add_dashboard_page( |
| 36 |
\__( 'Social Web', 'activitypub' ), |
| 37 |
\__( 'Social Web', 'activitypub' ), |
| 38 |
ACTIVITYPUB_BLOG_MODE === \get_option( 'activitypub_actor_mode' ) ? 'manage_options' : 'activitypub', |
| 39 |
'activitypub-social-web', |
| 40 |
array( App::class, 'render_page' ) |
| 41 |
); |
| 42 |
|
| 43 |
\add_action( 'load-' . $app_hook, array( App::class, 'remove_admin_notices' ) ); |
| 44 |
\add_action( 'admin_print_scripts-' . $app_hook, array( App::class, 'enqueue_scripts' ) ); |
| 45 |
} |
| 46 |
|
| 47 |
// User has to be able to publish posts. |
| 48 |
if ( user_can_activitypub( \get_current_user_id() ) ) { |
| 49 |
$followers_list_page = \add_users_page( |
| 50 |
\__( 'Followers ⁂', 'activitypub' ), |
| 51 |
\__( 'Followers ⁂', 'activitypub' ), |
| 52 |
'activitypub', |
| 53 |
'activitypub-followers-list', |
| 54 |
array( Admin::class, 'followers_list_page' ) |
| 55 |
); |
| 56 |
|
| 57 |
\add_action( 'load-' . $followers_list_page, array( Admin::class, 'add_followers_list_table' ) ); |
| 58 |
\add_action( 'load-' . $followers_list_page, array( Screen_Options::class, 'add_followers_list_options' ) ); |
| 59 |
|
| 60 |
if ( '1' === \get_option( 'activitypub_following_ui', '0' ) ) { |
| 61 |
$following_list_page = \add_users_page( |
| 62 |
\__( 'Following ⁂', 'activitypub' ), |
| 63 |
\__( 'Following ⁂', 'activitypub' ), |
| 64 |
'activitypub', |
| 65 |
'activitypub-following-list', |
| 66 |
array( Admin::class, 'following_list_page' ) |
| 67 |
); |
| 68 |
|
| 69 |
\add_action( 'load-' . $following_list_page, array( Admin::class, 'add_following_list_table' ) ); |
| 70 |
\add_action( 'load-' . $following_list_page, array( Settings::class, 'add_following_help_tab' ) ); |
| 71 |
\add_action( 'load-' . $following_list_page, array( Screen_Options::class, 'add_following_list_options' ) ); |
| 72 |
} |
| 73 |
|
| 74 |
// Only show blocked actors page if user has blocked actors. |
| 75 |
$blocked_actors_list_page = \add_users_page( |
| 76 |
\__( 'Blocked Actors ⁂', 'activitypub' ), |
| 77 |
\__( 'Blocked Actors ⁂', 'activitypub' ), |
| 78 |
'activitypub', |
| 79 |
'activitypub-blocked-actors-list', |
| 80 |
array( Admin::class, 'blocked_actors_list_page' ) |
| 81 |
); |
| 82 |
|
| 83 |
\add_action( 'load-' . $blocked_actors_list_page, array( Admin::class, 'add_blocked_actors_list_table' ) ); |
| 84 |
\add_action( 'load-' . $blocked_actors_list_page, array( Screen_Options::class, 'add_blocked_actors_list_options' ) ); |
| 85 |
|
| 86 |
\add_users_page( |
| 87 |
\__( 'Extra Fields ⁂', 'activitypub' ), |
| 88 |
\__( 'Extra Fields ⁂', 'activitypub' ), |
| 89 |
'activitypub', |
| 90 |
\esc_url( \admin_url( '/edit.php?post_type=ap_extrafield' ) ) |
| 91 |
); |
| 92 |
} |
| 93 |
} |
| 94 |
} |
| 95 |
|