PluginProbe
ActivityPub / 5.7.0
ActivityPub v5.7.0
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
activitypub / includes / wp-admin / class-welcome-fields.php

class-welcome-fields.php in ActivityPub 5.7.0, at includes/wp-admin/class-welcome-fields.php

344 lines 16.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ActivityPub Welcome Fields Class.
4 *
5 * @package Activitypub
6 */
7
8 namespace Activitypub\WP_Admin;
9
10 use Activitypub\Model\Blog;
11 use Activitypub\Collection\Actors;
12
13 use function Activitypub\get_reply_intent_js;
14 use function Activitypub\user_can_activitypub;
15
16 /**
17 * Class Welcome_Fields.
18 */
19 class Welcome_Fields {
20 /**
21 * Initialize the welcome fields.
22 */
23 public static function init() {
24 \add_action( 'load-settings_page_activitypub', array( self::class, 'register_welcome_fields' ) );
25 \add_action( 'load-settings_page_activitypub', array( self::class, 'add_admin_notices' ) );
26 }
27
28 /**
29 * Register welcome fields.
30 */
31 public static function register_welcome_fields() {
32 // Add settings sections.
33 \add_settings_section(
34 'activitypub_intro',
35 \__( 'Welcome', 'activitypub' ),
36 array( self::class, 'render_welcome_intro_section' ),
37 'activitypub_welcome'
38 );
39
40 \add_settings_section(
41 'activitypub_bookmarklet',
42 \__( 'Bookmarklet', 'activitypub' ),
43 array( self::class, 'render_bookmarklet_section' ),
44 'activitypub_welcome'
45 );
46
47 if ( user_can_activitypub( Actors::BLOG_USER_ID ) ) {
48 \add_settings_section(
49 'activitypub_blog_profile',
50 \__( 'Blog profile', 'activitypub' ),
51 array( self::class, 'render_blog_profile_section' ),
52 'activitypub_welcome'
53 );
54 }
55
56 if ( user_can_activitypub( \get_current_user_id() ) ) {
57 \add_settings_section(
58 'activitypub_author_profile',
59 \__( 'Author profile', 'activitypub' ),
60 array( self::class, 'render_author_profile_section' ),
61 'activitypub_welcome'
62 );
63 }
64
65 if ( ACTIVITYPUB_SHOW_PLUGIN_RECOMMENDATIONS ) {
66 \add_settings_section(
67 'activitypub_recommended_plugins',
68 \__( 'Recommended Plugins', 'activitypub' ),
69 array( self::class, 'render_recommended_plugins_section' ),
70 'activitypub_welcome'
71 );
72 }
73 }
74
75 /**
76 * Add Health Check errors as admin notices.
77 */
78 public static function add_admin_notices() {
79 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
80 if ( isset( $_GET['tab'] ) && 'welcome' !== $_GET['tab'] ) {
81 return;
82 }
83
84 if ( ! \get_user_meta( \get_current_user_id(), 'activitypub_show_welcome_tab', true ) ) {
85 return;
86 }
87
88 if ( Health_Check::count_results( 'critical' ) ) {
89 \add_action( 'admin_notices', array( self::class, 'admin_notices' ) );
90 }
91 }
92
93 /**
94 * Render welcome intro section.
95 */
96 public static function render_welcome_intro_section() {
97 ?>
98 <a class="welcome-tab-close" href="<?php echo \esc_url( \admin_url( 'options-general.php?page=activitypub&welcome=0' ) ); ?>" aria-label="<?php \esc_attr_e( 'Dismiss the welcome page', 'activitypub' ); ?>"><?php \esc_html_e( 'Dismiss Welcome Page', 'activitypub' ); ?></a>
99 <p><?php echo wp_kses( \__( 'Enter the fediverse with <strong>ActivityPub</strong>, broadcasting your blog to a wider audience. Attract followers, deliver updates, and receive comments from a diverse user base on <strong>Mastodon</strong>, <strong>Friendica</strong>, <strong>Pleroma</strong>, <strong>Pixelfed</strong>, and all <strong>ActivityPub</strong>-compliant platforms.', 'activitypub' ), array( 'strong' => array() ) ); ?></p>
100 <?php
101 }
102
103 /**
104 * Render bookmarklet section.
105 */
106 public static function render_bookmarklet_section() {
107 ?>
108 <p>
109 <?php
110 $bookmarklet_js = get_reply_intent_js();
111
112 /* translators: %s is the domain of this site */
113 $reply_from_template = __( 'Reply from %s', 'activitypub' );
114
115 printf(
116 '<a href="%s" class="button">%s</a>',
117 esc_attr( $bookmarklet_js ), // Need to escape quotes for the bookmarklet.
118 sprintf( esc_html( $reply_from_template ), esc_html( \wp_parse_url( \home_url(), PHP_URL_HOST ) ) )
119 );
120 ?>
121 </p>
122 <p>
123 <?php
124 /* translators: %s is where the button HTML will be rendered. */
125 \esc_html_e(
126 'Save this bookmarklet to reply to posts on other sites from your own blog! When visiting a post on another site, click the bookmarklet to start a reply.',
127 'activitypub'
128 );
129
130 printf( ' <a href="%s">%s</a>', esc_url( \admin_url( 'tools.php#activitypub' ) ), esc_html__( 'For additional information, please visit the Tools page.', 'activitypub' ) );
131 ?>
132 </p>
133 <?php
134 }
135
136 /**
137 * Render blog profile section.
138 */
139 public static function render_blog_profile_section() {
140 $blog_user = new Blog();
141
142 ?>
143 <p>
144 <?php \esc_html_e( 'People can follow your blog by using:', 'activitypub' ); ?>
145 </p>
146 <table class="form-table" role="presentation">
147 <tbody>
148 <tr>
149 <th scope="row"><?php \esc_html_e( 'Username', 'activitypub' ); ?></th>
150 <td>
151 <input type="text" class="large-text code" id="activitypub-blog-identifier" value="<?php echo \esc_attr( $blog_user->get_webfinger() ); ?>" readonly />
152 </td>
153 </tr>
154 <tr>
155 <th scope="row"><?php \esc_html_e( 'Profile URL', 'activitypub' ); ?></th>
156 <td>
157 <input type="text" class="large-text code" id="activitypub-blog-url" value="<?php echo \esc_attr( $blog_user->get_url() ); ?>" readonly />
158 </td>
159 </tr>
160 </tbody>
161 </table>
162 <p>
163 <?php \esc_html_e( 'This blog profile will federate all posts written on your blog, regardless of the author who posted it.', 'activitypub' ); ?>
164 <a href="<?php echo \esc_url( \admin_url( '/options-general.php?page=activitypub&tab=blog-profile' ) ); ?>">
165 <?php \esc_html_e( 'Customize the blog profile.', 'activitypub' ); ?>
166 </a>
167 </p>
168 <?php
169 }
170
171 /**
172 * Render author profile section.
173 */
174 public static function render_author_profile_section() {
175 $user = Actors::get_by_id( \get_current_user_id() );
176 ?>
177 <p>
178 <?php \esc_html_e( 'People can follow you by using your author name:', 'activitypub' ); ?>
179 </p>
180 <table class="form-table" role="presentation">
181 <tbody>
182 <tr>
183 <th scope="row"><?php \esc_html_e( 'Username', 'activitypub' ); ?></th>
184 <td>
185 <input type="text" class="large-text code" id="activitypub-user-identifier" value="<?php echo \esc_attr( $user->get_webfinger() ); ?>" readonly />
186 </td>
187 </tr>
188 <tr>
189 <th scope="row"><?php \esc_html_e( 'Profile URL', 'activitypub' ); ?></th>
190 <td>
191 <input type="text" class="large-text code" id="activitypub-user-url" value="<?php echo \esc_attr( $user->get_url() ); ?>" readonly />
192 </td>
193 </tr>
194 </tbody>
195 </table>
196 <p>
197 <?php \esc_html_e( 'Authors who can not access this settings page will find their username on the "Edit Profile" page.', 'activitypub' ); ?>
198 <a href="<?php echo \esc_url( \admin_url( '/profile.php#activitypub' ) ); ?>">
199 <?php \esc_html_e( 'Customize username on "Edit Profile" page.', 'activitypub' ); ?>
200 </a>
201 </p>
202 <?php
203 }
204
205 /**
206 * Render troubleshooting section.
207 */
208 public static function admin_notices() {
209 $results = Health_Check::count_results();
210 ?>
211 <div class="activitypub-notice notice notice-warning">
212 <p>
213 <span class="dashicons dashicons-warning"></span>
214 <?php
215 echo wp_kses(
216 \sprintf(
217 /* translators: the placeholders are the number of critical and recommended issues on the site. */
218 \__(
219 '<strong>Important:</strong> There are <span class="count">%1$d</span> critical and <span class="count">%2$d</span> recommended issues affecting your site&#8217;s compatibility with the fediverse. Please check the <a href="%3$s">Site Health</a> page to resolve these issues.',
220 'activitypub'
221 ),
222 $results['critical'],
223 $results['recommended'],
224 \esc_url( \admin_url( 'site-health.php' ) )
225 ),
226 array(
227 'strong' => array(),
228 'span' => array(
229 'class' => array(),
230 ),
231 'a' => array(
232 'href' => array(),
233 ),
234 )
235 );
236 ?>
237 </p>
238 </div>
239 <?php
240 }
241
242 /**
243 * Render recommended plugins section.
244 */
245 public static function render_recommended_plugins_section() {
246 ?>
247 <p><?php \esc_html_e( 'ActivityPub works as is and there is no need for you to install additional plugins, nevertheless there are some plugins that extends the functionality of ActivityPub.', 'activitypub' ); ?></p>
248
249 <div class="activitypub-settings-accordion">
250 <?php if ( ! \defined( 'FRIENDS_VERSION' ) ) : ?>
251 <h4 class="activitypub-settings-accordion-heading">
252 <button aria-expanded="true" class="activitypub-settings-accordion-trigger" aria-controls="activitypub-settings-accordion-block-friends-plugin" type="button">
253 <span class="title"><?php \esc_html_e( 'Following Others', 'activitypub' ); ?></span>
254 <span class="icon"></span>
255 </button>
256 </h4>
257 <div id="activitypub-settings-accordion-block-friends-plugin" class="activitypub-settings-accordion-panel plugin-card-friends">
258 <p><?php \esc_html_e( 'To follow people on Mastodon or similar platforms using your own WordPress, you can use the Friends Plugin for WordPress which uses this plugin to receive posts and display them on your own WordPress, thus making your own WordPress a Fediverse instance of its own.', 'activitypub' ); ?></p>
259 <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=friends&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the Friends Plugin', 'activitypub' ); ?></a></p>
260 </div>
261 <?php endif; ?>
262 <?php if ( ! \defined( 'EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_VERSION' ) ) : ?>
263 <h4 class="activitypub-settings-accordion-heading">
264 <button aria-expanded="false" class="activitypub-settings-accordion-trigger" aria-controls="activitypub-settings-accordion-block-event-bridge-for-activitypub-plugin" type="button">
265 <span class="title"><?php \esc_html_e( 'Federate Events', 'activitypub' ); ?></span>
266 <span class="icon"></span>
267 </button>
268 </h4>
269 <div id="activitypub-settings-accordion-block-event-bridge-for-activitypub-plugin" class="activitypub-settings-accordion-panel plugin-card-block-event-bridge-for-activitypub" hidden="hidden">
270 <p><?php \esc_html_e( 'Make your events more discoverable, expand your reach effortlessly while being independent of other (commercial) platforms, and be a part of the growing decentralized web (the Fediverse). With the Event Bridge for ActivityPub Plugin for WordPress, your events can be automatically followed, aggregated and displayed across decentralized platforms like Mastodon or Gancio, without any extra work.', 'activitypub' ); ?></p>
271 <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=event-bridge-for-activitypub&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the Event Bridge for ActivityPub Plugin', 'activitypub' ); ?></a></p>
272 </div>
273 <?php endif; ?>
274 <?php if ( ! \defined( 'ENABLE_MASTODON_APPS_VERSION' ) ) : ?>
275 <h4 class="activitypub-settings-accordion-heading">
276 <button aria-expanded="false" class="activitypub-settings-accordion-trigger" aria-controls="activitypub-settings-accordion-block-enable-mastodon-apps-plugin" type="button">
277 <span class="title"><?php \esc_html_e( 'Use Mastodon Apps', 'activitypub' ); ?></span>
278 <span class="icon"></span>
279 </button>
280 </h4>
281 <div id="activitypub-settings-accordion-block-enable-mastodon-apps-plugin" class="activitypub-settings-accordion-panel plugin-card-block-enable-mastodon-apps" hidden="hidden">
282 <p>
283 <?php
284 echo \wp_kses(
285 \sprintf(
286 // translators: %s is a URL.
287 \__( 'Enable the use of a wide variety of <a href="%s" target="_blank">Mastodon apps</a> to interact with your WordPress site, for example write posts that can then be federated via the ActivityPub plugin.', 'activitypub' ),
288 'https://joinmastodon.org/apps'
289 ),
290 array(
291 'a' => array(
292 'href' => true,
293 'target' => true,
294 ),
295 )
296 );
297 ?>
298 </p>
299 <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=enable-mastodon-apps&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the Enable Mastodon Apps Plugin', 'activitypub' ); ?></a></p>
300 </div>
301 <?php endif; ?>
302 <?php if ( ! \class_exists( 'Hum' ) ) : ?>
303 <h4 class="activitypub-settings-accordion-heading">
304 <button aria-expanded="false" class="activitypub-settings-accordion-trigger" aria-controls="activitypub-settings-accordion-block-activitypub-hum-plugin" type="button">
305 <span class="title"><?php \esc_html_e( 'Add a URL Shortener', 'activitypub' ); ?></span>
306 <span class="icon"></span>
307 </button>
308 </h4>
309 <div id="activitypub-settings-accordion-block-activitypub-hum-plugin" class="activitypub-settings-accordion-panel plugin-card-hum" hidden="hidden">
310 <p><?php \esc_html_e( 'Hum is a personal URL shortener for WordPress, designed to provide short URLs to your personal content, both hosted on WordPress and elsewhere.', 'activitypub' ); ?></p>
311 <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=hum&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the Hum Plugin', 'activitypub' ); ?></a></p>
312 </div>
313 <?php endif; ?>
314 <?php if ( ! \class_exists( 'Webfinger' ) ) : ?>
315 <h4 class="activitypub-settings-accordion-heading">
316 <button aria-expanded="false" class="activitypub-settings-accordion-trigger" aria-controls="activitypub-settings-accordion-block-activitypub-webfinger-plugin" type="button">
317 <span class="title"><?php \esc_html_e( 'Advanced WebFinger Support', 'activitypub' ); ?></span>
318 <span class="icon"></span>
319 </button>
320 </h4>
321 <div id="activitypub-settings-accordion-block-activitypub-webfinger-plugin" class="activitypub-settings-accordion-panel plugin-card-webfinger" hidden="hidden">
322 <p><?php \esc_html_e( 'WebFinger is a protocol that allows for discovery of information about people and things identified by a URI. Information about a person might be discovered via an "acct:" URI, for example, which is a URI that looks like an email address.', 'activitypub' ); ?></p>
323 <p><?php \esc_html_e( 'The ActivityPub plugin comes with basic WebFinger support, if you need more configuration options and compatibility with other Fediverse/IndieWeb plugins, please install the WebFinger plugin.', 'activitypub' ); ?></p>
324 <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=webfinger&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the WebFinger Plugin', 'activitypub' ); ?></a></p>
325 </div>
326 <?php endif; ?>
327 <?php if ( ! \function_exists( 'nodeinfo_init' ) ) : ?>
328 <h4 class="activitypub-settings-accordion-heading">
329 <button aria-expanded="false" class="activitypub-settings-accordion-trigger" aria-controls="activitypub-settings-accordion-block-activitypub-nodeinfo-plugin" type="button">
330 <span class="title"><?php \esc_html_e( 'Provide Enhanced Information About Your Blog', 'activitypub' ); ?></span>
331 <span class="icon"></span>
332 </button>
333 </h4>
334 <div id="activitypub-settings-accordion-block-activitypub-nodeinfo-plugin" class="activitypub-settings-accordion-panel plugin-card-nodeinfo" hidden="hidden">
335 <p><?php \esc_html_e( 'NodeInfo is an effort to create a standardized way of exposing metadata about a server running one of the distributed social networks. The two key goals are being able to get better insights into the user base of distributed social networking and the ability to build tools that allow users to choose the best fitting software and server for their needs.', 'activitypub' ); ?></p>
336 <p><?php \esc_html_e( 'The ActivityPub plugin comes with a simple NodeInfo endpoint. If you need more configuration options and compatibility with other Fediverse plugins, please install the NodeInfo plugin.', 'activitypub' ); ?></p>
337 <p><a href="<?php echo \esc_url( \admin_url( 'plugin-install.php?tab=plugin-information&plugin=nodeinfo&TB_iframe=true' ) ); ?>" class="thickbox open-plugin-details-modal button install-now" target="_blank"><?php \esc_html_e( 'Install the NodeInfo Plugin', 'activitypub' ); ?></a></p>
338 </div>
339 <?php endif; ?>
340 </div>
341 <?php
342 }
343 }
344