explicit use of global functions

This commit is contained in:
Matthias Pfefferle 2019-09-27 11:36:52 +02:00
parent ad691bc488
commit 54eb7a960f
4 changed files with 65 additions and 65 deletions

View file

@ -1,7 +1,7 @@
<div class="wrap"> <div class="wrap">
<h1><?php esc_html_e( 'Followers (Fediverse)', 'activitypub' ); ?></h1> <h1><?php \esc_html_e( 'Followers (Fediverse)', 'activitypub' ); ?></h1>
<p><?php printf( __( 'You currently have %s followers.', 'activitypub' ), esc_attr( \Activitypub\Db\Followers::count_followers( get_current_user_id() ) ) ); ?></p> <p><?php \printf( \__( 'You currently have %s followers.', 'activitypub' ), \esc_attr( \Activitypub\Db\Followers::count_followers( \get_current_user_id() ) ) ); ?></p>
<?php $token_table = new \Activitypub\Table\Followers_List(); ?> <?php $token_table = new \Activitypub\Table\Followers_List(); ?>

View file

@ -1,43 +1,43 @@
<?php <?php
$author_id = get_the_author_meta( 'ID' ); $author_id = \get_the_author_meta( 'ID' );
$json = new stdClass(); $json = new \stdClass();
$json->{'@context'} = \Activitypub\get_context(); $json->{'@context'} = \Activitypub\get_context();
$json->id = get_author_posts_url( $author_id ); $json->id = \get_author_posts_url( $author_id );
$json->type = 'Person'; $json->type = 'Person';
$json->name = get_the_author_meta( 'display_name', $author_id ); $json->name = \get_the_author_meta( 'display_name', $author_id );
$json->summary = html_entity_decode( $json->summary = \html_entity_decode(
get_the_author_meta( 'description', $author_id ), \get_the_author_meta( 'description', $author_id ),
ENT_QUOTES, ENT_QUOTES,
'UTF-8' 'UTF-8'
); );
$json->preferredUsername = get_the_author_meta( 'login', $author_id ); // phpcs:ignore $json->preferredUsername = \get_the_author_meta( 'login', $author_id ); // phpcs:ignore
$json->url = get_author_posts_url( $author_id ); $json->url = \get_author_posts_url( $author_id );
$json->icon = array( $json->icon = array(
'type' => 'Image', 'type' => 'Image',
'url' => get_avatar_url( $author_id, array( 'size' => 120 ) ), 'url' => \get_avatar_url( $author_id, array( 'size' => 120 ) ),
); );
if ( has_header_image() ) { if ( \has_header_image() ) {
$json->image = array( $json->image = array(
'type' => 'Image', 'type' => 'Image',
'url' => get_header_image(), 'url' => \get_header_image(),
); );
} }
$json->inbox = get_rest_url( null, "/activitypub/1.0/users/$author_id/inbox" ); $json->inbox = \get_rest_url( null, "/activitypub/1.0/users/$author_id/inbox" );
$json->outbox = get_rest_url( null, "/activitypub/1.0/users/$author_id/outbox" ); $json->outbox = \get_rest_url( null, "/activitypub/1.0/users/$author_id/outbox" );
$json->followers = get_rest_url( null, "/activitypub/1.0/users/$author_id/followers" ); $json->followers = \get_rest_url( null, "/activitypub/1.0/users/$author_id/followers" );
$json->following = get_rest_url( null, "/activitypub/1.0/users/$author_id/following" ); $json->following = \get_rest_url( null, "/activitypub/1.0/users/$author_id/following" );
$json->manuallyApprovesFollowers = apply_filters( 'activitypub_json_manually_approves_followers', __return_false() ); // phpcs:ignore $json->manuallyApprovesFollowers = \apply_filters( 'activitypub_json_manually_approves_followers', __return_false() ); // phpcs:ignore
// phpcs:ignore // phpcs:ignore
$json->publicKey = array( $json->publicKey = array(
'id' => get_author_posts_url( $author_id ) . '#main-key', 'id' => \get_author_posts_url( $author_id ) . '#main-key',
'owner' => get_author_posts_url( $author_id ), 'owner' => \get_author_posts_url( $author_id ),
'publicKeyPem' => trim( \Activitypub\Signature::get_public_key( $author_id ) ), 'publicKeyPem' => \trim( \Activitypub\Signature::get_public_key( $author_id ) ),
); );
$json->tag = array(); $json->tag = array();
@ -46,8 +46,8 @@ $json->attachment = array();
$json->attachment[] = array( $json->attachment[] = array(
'type' => 'PropertyValue', 'type' => 'PropertyValue',
'name' => __( 'Blog', 'activitypub' ), 'name' => __( 'Blog', 'activitypub' ),
'value' => html_entity_decode( 'value' => \html_entity_decode(
'<a rel="me" title="' . esc_attr( home_url( '/' ) ) . '" target="_blank" href="' . home_url( '/' ) . '">' . wp_parse_url( home_url( '/' ), PHP_URL_HOST ) . '</a>', '<a rel="me" title="' . \esc_attr( \home_url( '/' ) ) . '" target="_blank" href="' . \home_url( '/' ) . '">' . \wp_parse_url( \home_url( '/' ), PHP_URL_HOST ) . '</a>',
ENT_QUOTES, ENT_QUOTES,
'UTF-8' 'UTF-8'
), ),
@ -56,19 +56,19 @@ $json->attachment[] = array(
$json->attachment[] = array( $json->attachment[] = array(
'type' => 'PropertyValue', 'type' => 'PropertyValue',
'name' => __( 'Profile', 'activitypub' ), 'name' => __( 'Profile', 'activitypub' ),
'value' => html_entity_decode( 'value' => \html_entity_decode(
'<a rel="me" title="' . esc_attr( get_author_posts_url( $author_id ) ) . '" target="_blank" href="' . get_author_posts_url( $author_id ) . '">' . wp_parse_url( get_author_posts_url( $author_id ), PHP_URL_HOST ) . '</a>', '<a rel="me" title="' . \esc_attr( \get_author_posts_url( $author_id ) ) . '" target="_blank" href="' . \get_author_posts_url( $author_id ) . '">' . \wp_parse_url( \get_author_posts_url( $author_id ), PHP_URL_HOST ) . '</a>',
ENT_QUOTES, ENT_QUOTES,
'UTF-8' 'UTF-8'
), ),
); );
if ( get_the_author_meta( 'user_url', $author_id ) ) { if ( \get_the_author_meta( 'user_url', $author_id ) ) {
$json->attachment[] = array( $json->attachment[] = array(
'type' => 'PropertyValue', 'type' => 'PropertyValue',
'name' => __( 'Website', 'activitypub' ), 'name' => __( 'Website', 'activitypub' ),
'value' => html_entity_decode( 'value' => \html_entity_decode(
'<a rel="me" title="' . esc_attr( get_the_author_meta( 'user_url', $author_id ) ) . '" target="_blank" href="' . get_the_author_meta( 'user_url', $author_id ) . '">' . wp_parse_url( get_the_author_meta( 'user_url', $author_id ), PHP_URL_HOST ) . '</a>', '<a rel="me" title="' . \esc_attr( \get_the_author_meta( 'user_url', $author_id ) ) . '" target="_blank" href="' . \get_the_author_meta( 'user_url', $author_id ) . '">' . \wp_parse_url( \get_the_author_meta( 'user_url', $author_id ), PHP_URL_HOST ) . '</a>',
ENT_QUOTES, ENT_QUOTES,
'UTF-8' 'UTF-8'
), ),
@ -76,20 +76,20 @@ if ( get_the_author_meta( 'user_url', $author_id ) ) {
} }
//$json->endpoints = array( //$json->endpoints = array(
// 'sharedInbox' => get_rest_url( null, '/activitypub/1.0/inbox' ), // 'sharedInbox' => \get_rest_url( null, '/activitypub/1.0/inbox' ),
//); //);
// filter output // filter output
$json = apply_filters( 'activitypub_json_author_array', $json ); $json = \apply_filters( 'activitypub_json_author_array', $json );
/* /*
* Action triggerd prior to the ActivityPub profile being created and sent to the client * Action triggerd prior to the ActivityPub profile being created and sent to the client
*/ */
do_action( 'activitypub_json_author_pre' ); \do_action( 'activitypub_json_author_pre' );
$options = 0; $options = 0;
// JSON_PRETTY_PRINT added in PHP 5.4 // JSON_PRETTY_PRINT added in PHP 5.4
if ( get_query_var( 'pretty' ) ) { if ( \get_query_var( 'pretty' ) ) {
$options |= JSON_PRETTY_PRINT; // phpcs:ignore $options |= JSON_PRETTY_PRINT; // phpcs:ignore
} }
@ -100,12 +100,12 @@ $options |= JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT;
* *
* @param int $options The current options flags * @param int $options The current options flags
*/ */
$options = apply_filters( 'activitypub_json_author_options', $options ); $options = \apply_filters( 'activitypub_json_author_options', $options );
header( 'Content-Type: application/activity+json' ); \header( 'Content-Type: application/activity+json' );
echo wp_json_encode( $json, $options ); echo \wp_json_encode( $json, $options );
/* /*
* Action triggerd after the ActivityPub profile has been created and sent to the client * Action triggerd after the ActivityPub profile has been created and sent to the client
*/ */
do_action( 'activitypub_json_author_post' ); \do_action( 'activitypub_json_author_post' );

View file

@ -1,20 +1,20 @@
<?php <?php
$post = get_post(); $post = \get_post();
$activitypub_post = new \Activitypub\Post( $post ); $activitypub_post = new \Activitypub\Post( $post );
$json = array_merge( array( '@context' => \Activitypub\get_context() ), $activitypub_post->to_array() ); $json = \array_merge( array( '@context' => \Activitypub\get_context() ), $activitypub_post->to_array() );
// filter output // filter output
$json = apply_filters( 'activitypub_json_post_array', $json ); $json = \apply_filters( 'activitypub_json_post_array', $json );
/* /*
* Action triggerd prior to the ActivityPub profile being created and sent to the client * Action triggerd prior to the ActivityPub profile being created and sent to the client
*/ */
do_action( 'activitypub_json_post_pre' ); \do_action( 'activitypub_json_post_pre' );
$options = 0; $options = 0;
// JSON_PRETTY_PRINT added in PHP 5.4 // JSON_PRETTY_PRINT added in PHP 5.4
if ( get_query_var( 'pretty' ) ) { if ( \get_query_var( 'pretty' ) ) {
$options |= JSON_PRETTY_PRINT; // phpcs:ignore $options |= JSON_PRETTY_PRINT; // phpcs:ignore
} }
@ -25,12 +25,12 @@ $options |= JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT;
* *
* @param int $options The current options flags * @param int $options The current options flags
*/ */
$options = apply_filters( 'activitypub_json_post_options', $options ); $options = \apply_filters( 'activitypub_json_post_options', $options );
header( 'Content-Type: application/activity+json' ); \header( 'Content-Type: application/activity+json' );
echo wp_json_encode( $json, $options ); echo \wp_json_encode( $json, $options );
/* /*
* Action triggerd after the ActivityPub profile has been created and sent to the client * Action triggerd after the ActivityPub profile has been created and sent to the client
*/ */
do_action( 'activitypub_json_post_post' ); \do_action( 'activitypub_json_post_post' );

View file

@ -1,14 +1,14 @@
<div class="wrap"> <div class="wrap">
<h1><?php esc_html_e( 'ActivityPub Settings', 'activitypub' ); ?></h1> <h1><?php \esc_html_e( 'ActivityPub Settings', 'activitypub' ); ?></h1>
<p><?php esc_html_e( 'ActivityPub turns your blog into a federated social network. This means you can share and talk to everyone using the ActivityPub protocol, including users of Friendica, Pleroma and Mastodon.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'ActivityPub turns your blog into a federated social network. This means you can share and talk to everyone using the ActivityPub protocol, including users of Friendica, Pleroma and Mastodon.', 'activitypub' ); ?></p>
<form method="post" action="options.php"> <form method="post" action="options.php">
<?php settings_fields( 'activitypub' ); ?> <?php \settings_fields( 'activitypub' ); ?>
<h2><?php esc_html_e( 'Activities', 'activitypub' ); ?></h2> <h2><?php \esc_html_e( 'Activities', 'activitypub' ); ?></h2>
<p><?php esc_html_e( 'All activity related settings.', 'activitypub' ); ?></p> <p><?php \esc_html_e( 'All activity related settings.', 'activitypub' ); ?></p>
<table class="form-table"> <table class="form-table">
<tbody> <tbody>
@ -18,59 +18,59 @@
</th> </th>
<td> <td>
<p> <p>
<label><input type="radio" name="activitypub_post_content_type" id="activitypub_post_content_type_excerpt" value="excerpt" <?php echo checked( 'excerpt', get_option( 'activitypub_post_content_type', 'content' ) ); ?> /> <?php esc_html_e( 'Excerpt', 'activitypub' ); ?></label> - <span class="description"><?php esc_html_e( 'A content summary, shortened to 400 characters and without markup.', 'activitypub' ); ?></span> <label><input type="radio" name="activitypub_post_content_type" id="activitypub_post_content_type_excerpt" value="excerpt" <?php echo \checked( 'excerpt', \get_option( 'activitypub_post_content_type', 'content' ) ); ?> /> <?php \esc_html_e( 'Excerpt', 'activitypub' ); ?></label> - <span class="description"><?php \esc_html_e( 'A content summary, shortened to 400 characters and without markup.', 'activitypub' ); ?></span>
</p> </p>
<p> <p>
<label><input type="radio" name="activitypub_post_content_type" id="activitypub_post_content_type_content" value="content" <?php echo checked( 'content', get_option( 'activitypub_post_content_type', 'content' ) ); ?> /> <?php esc_html_e( 'Content (default)', 'activitypub' ); ?></label> - <span class="description"><?php esc_html_e( 'The full content.', 'activitypub' ); ?></span> <label><input type="radio" name="activitypub_post_content_type" id="activitypub_post_content_type_content" value="content" <?php echo \checked( 'content', \get_option( 'activitypub_post_content_type', 'content' ) ); ?> /> <?php \esc_html_e( 'Content (default)', 'activitypub' ); ?></label> - <span class="description"><?php \esc_html_e( 'The full content.', 'activitypub' ); ?></span>
</p> </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row"> <th scope="row">
<?php esc_html_e( 'Backlink', 'activitypub' ); ?> <?php \esc_html_e( 'Backlink', 'activitypub' ); ?>
</th> </th>
<td> <td>
<p><label><input type="checkbox" name="activitypub_use_shortlink" id="activitypub_use_shortlink" value="1" <?php echo checked( '1', get_option( 'activitypub_use_shortlink', '0' ) ); ?> /> <?php esc_html_e( 'Use the Shortlink instead of the permalink', 'activitypub' ); ?></label></p> <p><label><input type="checkbox" name="activitypub_use_shortlink" id="activitypub_use_shortlink" value="1" <?php echo \checked( '1', \get_option( 'activitypub_use_shortlink', '0' ) ); ?> /> <?php \esc_html_e( 'Use the Shortlink instead of the permalink', 'activitypub' ); ?></label></p>
<p class="description"><?php printf( esc_html( 'I can recommend %sHum%s, to prettify the Shortlinks', 'activitypub' ), '<a href="https://wordpress.org/plugins/hum/" target="_blank">', '</a>' ); ?></p> <p class="description"><?php \printf( esc_html( 'I can recommend %sHum%s, to prettify the Shortlinks', 'activitypub' ), '<a href="https://wordpress.org/plugins/hum/" target="_blank">', '</a>' ); ?></p>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row"> <th scope="row">
<?php esc_html_e( 'Activity-Object-Type', 'activitypub' ); ?> <?php \esc_html_e( 'Activity-Object-Type', 'activitypub' ); ?>
</th> </th>
<td> <td>
<p> <p>
<label><input type="radio" name="activitypub_object_type" id="activitypub_object_type_note" value="note" <?php echo checked( 'note', get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php esc_html_e( 'Note (default)', 'activitypub' ); ?></label> - <span class="description"><?php esc_html_e( 'Should work with most platforms.', 'activitypub' ); ?></span> <label><input type="radio" name="activitypub_object_type" id="activitypub_object_type_note" value="note" <?php echo \checked( 'note', \get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php \esc_html_e( 'Note (default)', 'activitypub' ); ?></label> - <span class="description"><?php \esc_html_e( 'Should work with most platforms.', 'activitypub' ); ?></span>
</p> </p>
<p> <p>
<label><input type="radio" name="activitypub_object_type" id="activitypub_object_type_article" value="article" <?php echo checked( 'article', get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php esc_html_e( 'Article', 'activitypub' ); ?></label> - <span class="description"><?php esc_html_e( 'The presentation of the "Article" might change on different platforms. Mastodon for example shows the "Article" type as a simple link.', 'activitypub' ); ?></span> <label><input type="radio" name="activitypub_object_type" id="activitypub_object_type_article" value="article" <?php echo \checked( 'article', \get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php \esc_html_e( 'Article', 'activitypub' ); ?></label> - <span class="description"><?php \esc_html_e( 'The presentation of the "Article" might change on different platforms. Mastodon for example shows the "Article" type as a simple link.', 'activitypub' ); ?></span>
</p> </p>
<p> <p>
<label><input type="radio" name="activitypub_object_type" id="activitypub_object_type" value="wordpress-post-format" <?php echo checked( 'wordpress-post-format', get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php esc_html_e( 'WordPress Post-Format', 'activitypub' ); ?></label> - <span class="description"><?php esc_html_e( 'Maps the WordPress Post-Format to the ActivityPub Object Type.', 'activitypub' ); ?></span> <label><input type="radio" name="activitypub_object_type" id="activitypub_object_type" value="wordpress-post-format" <?php echo \checked( 'wordpress-post-format', \get_option( 'activitypub_object_type', 'note' ) ); ?> /> <?php \esc_html_e( 'WordPress Post-Format', 'activitypub' ); ?></label> - <span class="description"><?php \esc_html_e( 'Maps the WordPress Post-Format to the ActivityPub Object Type.', 'activitypub' ); ?></span>
</p> </p>
</td> </td>
</tr> </tr>
<tr> <tr>
<th scope="row"> <th scope="row">
<?php esc_html_e( 'Hashtags', 'activitypub' ); ?> <?php \esc_html_e( 'Hashtags', 'activitypub' ); ?>
</th> </th>
<td> <td>
<p> <p>
<label><input type="checkbox" name="activitypub_use_hashtags" id="activitypub_use_hashtags" value="1" <?php echo checked( '1', get_option( 'activitypub_use_hashtags', '1' ) ); ?> /> <?php _e( 'Add hashtags in the content as native tags and replace the <code>#tag</code> with the tag-link.', 'activitypub' ); ?></label> <label><input type="checkbox" name="activitypub_use_hashtags" id="activitypub_use_hashtags" value="1" <?php echo \checked( '1', \get_option( 'activitypub_use_hashtags', '1' ) ); ?> /> <?php \_e( 'Add hashtags in the content as native tags and replace the <code>#tag</code> with the tag-link.', 'activitypub' ); ?></label>
</p> </p>
<p> <p>
<label><input type="checkbox" name="activitypub_add_tags_as_hashtags" id="activitypub_add_tags_as_hashtags" value="1" <?php echo checked( '1', get_option( 'activitypub_add_tags_as_hashtags', '0' ) ); ?> /> <?php _e( 'Add all tags as hashtags to the end of each activity.', 'activitypub' ); ?></label> <label><input type="checkbox" name="activitypub_add_tags_as_hashtags" id="activitypub_add_tags_as_hashtags" value="1" <?php echo \checked( '1', \get_option( 'activitypub_add_tags_as_hashtags', '0' ) ); ?> /> <?php \_e( 'Add all tags as hashtags to the end of each activity.', 'activitypub' ); ?></label>
</p> </p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<?php do_settings_fields( 'activitypub', 'activity' ); ?> <?php \do_settings_fields( 'activitypub', 'activity' ); ?>
<?php do_settings_sections( 'activitypub' ); ?> <?php \do_settings_sections( 'activitypub' ); ?>
<?php submit_button(); ?> <?php \submit_button(); ?>
</form> </form>
<p> <p>