updated plugin ActivityPub version 8.3.0
This commit is contained in:
@ -2,14 +2,26 @@
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"name": "activitypub/follow-me",
|
||||
"apiVersion": 3,
|
||||
"version": "1.0.0",
|
||||
"version": "8.3.0",
|
||||
"title": "Follow me on the Fediverse",
|
||||
"category": "widgets",
|
||||
"description": "Display your Fediverse profile so that visitors can follow you.",
|
||||
"textdomain": "activitypub",
|
||||
"icon": "groups",
|
||||
"keywords": [
|
||||
"fediverse",
|
||||
"activitypub",
|
||||
"follow",
|
||||
"mastodon"
|
||||
],
|
||||
"example": {
|
||||
"attributes": {
|
||||
"className": "is-style-default"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"html": false,
|
||||
"interactivity": true,
|
||||
"color": {
|
||||
"gradients": true,
|
||||
"link": true,
|
||||
@ -25,34 +37,38 @@
|
||||
"color": true,
|
||||
"style": true
|
||||
},
|
||||
"shadow": true,
|
||||
"typography": {
|
||||
"fontSize": true,
|
||||
"__experimentalDefaultControls": {
|
||||
"fontSize": true
|
||||
}
|
||||
},
|
||||
"innerBlocks": {
|
||||
"allowedBlocks": [
|
||||
"core/button"
|
||||
]
|
||||
}
|
||||
},
|
||||
"styles": [
|
||||
{
|
||||
"name": "default",
|
||||
"label": "Default",
|
||||
"isDefault": true
|
||||
},
|
||||
{
|
||||
"name": "button-only",
|
||||
"label": "Button"
|
||||
},
|
||||
{
|
||||
"name": "profile",
|
||||
"label": "Profile"
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"selectedUser": {
|
||||
"type": "string",
|
||||
"default": "site"
|
||||
},
|
||||
"buttonOnly": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"buttonText": {
|
||||
"type": "string",
|
||||
"default": "Follow"
|
||||
},
|
||||
"buttonSize": {
|
||||
"type": "string",
|
||||
"default": "default",
|
||||
"enum": [
|
||||
"small",
|
||||
"default",
|
||||
"compact"
|
||||
]
|
||||
"default": "blog"
|
||||
}
|
||||
},
|
||||
"usesContext": [
|
||||
@ -60,9 +76,8 @@
|
||||
"postId"
|
||||
],
|
||||
"editorScript": "file:./index.js",
|
||||
"viewScript": "file:./view.js",
|
||||
"style": [
|
||||
"file:./style-view.css",
|
||||
"wp-components"
|
||||
]
|
||||
"viewScriptModule": "file:./view.js",
|
||||
"viewScript": "wp-api-fetch",
|
||||
"style": "file:./style-index.css",
|
||||
"render": "file:./render.php"
|
||||
}
|
||||
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '8f1a6f7e5f76d58a3204');
|
||||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'a7a6cb736043a8fe087f');
|
||||
|
||||
File diff suppressed because one or more lines are too long
255
wp-content/plugins/activitypub/build/follow-me/render.php
Normal file
255
wp-content/plugins/activitypub/build/follow-me/render.php
Normal file
@ -0,0 +1,255 @@
|
||||
<?php
|
||||
/**
|
||||
* Server-side rendering of the `activitypub/follow-me` block.
|
||||
*
|
||||
* @package ActivityPub
|
||||
*/
|
||||
|
||||
use Activitypub\Blocks;
|
||||
use Activitypub\Collection\Actors;
|
||||
use Activitypub\Collection\Followers;
|
||||
|
||||
use function Activitypub\is_activitypub_request;
|
||||
|
||||
if ( is_activitypub_request() || is_feed() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* @var array $attributes Block attributes. */
|
||||
$attributes = wp_parse_args( $attributes );
|
||||
|
||||
/* @var WP_Block $block Parsed block.*/
|
||||
$block = $block ?? null;
|
||||
|
||||
/* @var string $content Inner blocks content. */
|
||||
$content = $content ?? '';
|
||||
|
||||
// Get the user ID from the selected user attribute.
|
||||
$user_id = Blocks::get_user_id( $attributes['selectedUser'] ?? 'blog' );
|
||||
$actor = Actors::get_by_id( $user_id );
|
||||
if ( is_wp_error( $actor ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a unique ID for the block.
|
||||
$block_id = 'activitypub-follow-me-block-' . wp_unique_id();
|
||||
|
||||
// Get block style information.
|
||||
$style = wp_get_global_styles();
|
||||
$background_color = $attributes['backgroundColor'] ?? $style['color']['background'] ?? '';
|
||||
$button_style = $attributes['style'] ?? array();
|
||||
|
||||
// Set up the Interactivity API config.
|
||||
wp_interactivity_config(
|
||||
'activitypub/follow-me',
|
||||
array(
|
||||
'namespace' => ACTIVITYPUB_REST_NAMESPACE,
|
||||
'i18n' => array(
|
||||
'copy' => __( 'Copy', 'activitypub' ),
|
||||
'copied' => __( 'Copied!', 'activitypub' ),
|
||||
'emptyProfileError' => __( 'Please enter a profile URL or handle.', 'activitypub' ),
|
||||
'genericError' => __( 'An error occurred. Please try again.', 'activitypub' ),
|
||||
'invalidProfileError' => __( 'Please enter a valid profile URL or handle.', 'activitypub' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Add the block wrapper attributes.
|
||||
$wrapper_attributes = array(
|
||||
'id' => $block_id,
|
||||
'class' => 'activitypub-follow-me-block-wrapper',
|
||||
'data-wp-interactive' => 'activitypub/follow-me',
|
||||
'data-wp-init' => 'callbacks.initButtonStyles',
|
||||
);
|
||||
if ( isset( $attributes['buttonOnly'] ) ) {
|
||||
$wrapper_attributes['class'] .= ' is-style-button-only';
|
||||
}
|
||||
|
||||
$wrapper_context = wp_interactivity_data_wp_context(
|
||||
array(
|
||||
'backgroundColor' => $background_color,
|
||||
'blockId' => $block_id,
|
||||
'buttonStyle' => $button_style,
|
||||
'copyButtonText' => __( 'Copy', 'activitypub' ),
|
||||
'errorMessage' => '',
|
||||
'isError' => false,
|
||||
'isLoading' => false,
|
||||
'modal' => array( 'isOpen' => false ),
|
||||
'remoteProfile' => '',
|
||||
'userId' => $user_id,
|
||||
'webfinger' => '@' . $actor->get_webfinger(),
|
||||
)
|
||||
);
|
||||
|
||||
if ( empty( $content ) ) {
|
||||
$button_text = $attributes['buttonText'] ?? __( 'Follow', 'activitypub' );
|
||||
$content = '<div class="wp-block-button"><a class="wp-element-button wp-block-button__link">' . esc_html( $button_text ) . '</a></div>';
|
||||
} else {
|
||||
$content = implode( PHP_EOL, wp_list_pluck( $block->parsed_block['innerBlocks'], 'innerHTML' ) );
|
||||
}
|
||||
|
||||
$content = Blocks::add_directions(
|
||||
$content,
|
||||
array( 'class_name' => 'wp-element-button' ),
|
||||
array(
|
||||
'data-wp-on--click' => 'actions.toggleModal',
|
||||
'data-wp-on--keydown' => 'actions.onKeydown',
|
||||
'data-wp-bind--aria-expanded' => 'context.modal.isOpen',
|
||||
'aria-label' => __( 'Follow me on the Fediverse', 'activitypub' ),
|
||||
'aria-haspopup' => 'dialog',
|
||||
'aria-controls' => $block_id . '-modal-title',
|
||||
'role' => 'button',
|
||||
'tabindex' => '0',
|
||||
)
|
||||
);
|
||||
|
||||
$header_image = $actor->get_image();
|
||||
$has_header = ! empty( $header_image['url'] ) && str_contains( $attributes['className'] ?? '', 'is-style-profile' );
|
||||
|
||||
$stats = array(
|
||||
'posts' => $user_id ? count_user_posts( $user_id, 'post', true ) : (int) wp_count_posts()->publish,
|
||||
'followers' => Followers::count( $user_id ),
|
||||
);
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div class="activitypub-dialog__section">
|
||||
<h4><?php esc_html_e( 'My Profile', 'activitypub' ); ?></h4>
|
||||
<div class="activitypub-dialog__description">
|
||||
<?php esc_html_e( 'Paste my profile into the search field of your favorite open social app or platform.', 'activitypub' ); ?>
|
||||
</div>
|
||||
<div class="activitypub-dialog__button-group">
|
||||
<label for="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>" class="screen-reader-text">
|
||||
<?php esc_html_e( 'My Fediverse handle', 'activitypub' ); ?>
|
||||
</label>
|
||||
<input
|
||||
aria-readonly="true"
|
||||
class="wp-block-search__input"
|
||||
id="<?php echo esc_attr( $block_id . '-profile-handle' ); ?>"
|
||||
readonly
|
||||
tabindex="-1"
|
||||
type="text"
|
||||
value="<?php echo esc_attr( '@' . $actor->get_webfinger() ); ?>"
|
||||
/>
|
||||
<button
|
||||
aria-label="<?php esc_attr_e( 'Copy handle to clipboard', 'activitypub' ); ?>"
|
||||
class="wp-element-button"
|
||||
data-wp-on--click="actions.copyToClipboard"
|
||||
type="button"
|
||||
>
|
||||
<span data-wp-text="context.copyButtonText"></span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="activitypub-dialog__section">
|
||||
<h4><?php esc_html_e( 'Your Profile', 'activitypub' ); ?></h4>
|
||||
<div class="activitypub-dialog__description">
|
||||
<?php esc_html_e( 'Or, if you know your own profile, we can start things that way!', 'activitypub' ); ?>
|
||||
<?php Blocks::render_modal_help(); ?>
|
||||
</div>
|
||||
<div class="activitypub-dialog__button-group">
|
||||
<label for="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>" class="screen-reader-text">
|
||||
<?php esc_html_e( 'Your Fediverse profile', 'activitypub' ); ?>
|
||||
</label>
|
||||
<input
|
||||
class="wp-block-search__input"
|
||||
data-wp-bind--aria-invalid="context.isError"
|
||||
data-wp-bind--value="context.remoteProfile"
|
||||
data-wp-on--input="actions.updateRemoteProfile"
|
||||
data-wp-on--keydown="actions.handleKeyDown"
|
||||
id="<?php echo esc_attr( $block_id . '-remote-profile' ); ?>"
|
||||
placeholder="<?php esc_attr_e( '@username@example.com', 'activitypub' ); ?>"
|
||||
type="text"
|
||||
/>
|
||||
<button
|
||||
aria-label="<?php esc_attr_e( 'Follow', 'activitypub' ); ?>"
|
||||
class="wp-element-button"
|
||||
data-wp-bind--disabled="context.isLoading"
|
||||
data-wp-on--click="actions.submitRemoteProfile"
|
||||
type="button"
|
||||
>
|
||||
<span data-wp-bind--hidden="context.isLoading"><?php esc_html_e( 'Follow', 'activitypub' ); ?></span>
|
||||
<span data-wp-bind--hidden="!context.isLoading"><?php esc_html_e( 'Loading…', 'activitypub' ); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
class="activitypub-dialog__error"
|
||||
data-wp-bind--hidden="!context.isError"
|
||||
data-wp-text="context.errorMessage"
|
||||
></div>
|
||||
</div>
|
||||
<?php
|
||||
$modal_content = ob_get_clean();
|
||||
|
||||
?>
|
||||
<div
|
||||
<?php echo get_block_wrapper_attributes( $wrapper_attributes ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
||||
<?php echo $wrapper_context; // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
||||
>
|
||||
<div class="activitypub-profile p-author h-card">
|
||||
<?php if ( $has_header ) : ?>
|
||||
<div class="activitypub-profile__header" style="background-image: url('<?php echo esc_url( $header_image['url'] ); ?>');"></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="activitypub-profile__body">
|
||||
<img
|
||||
class="activitypub-profile__avatar u-photo"
|
||||
src="<?php echo esc_url( $actor->get_icon()['url'] ); ?>"
|
||||
alt="<?php echo esc_attr( $actor->get_name() ); ?>"
|
||||
/>
|
||||
|
||||
<div class="activitypub-profile__content">
|
||||
<div class="activitypub-profile__info">
|
||||
<div class="activitypub-profile__name p-name"><?php echo esc_html( $actor->get_name() ); ?></div>
|
||||
<?php /** Using `data-wp-text` to avoid @see enrich_content_data() turning it into a mention. */ ?>
|
||||
<div class="activitypub-profile__handle p-nickname p-x-webfinger" data-wp-text="context.webfinger"></div>
|
||||
</div>
|
||||
|
||||
<?php echo $content; // phpcs:ignore WordPress.Security.EscapeOutput ?>
|
||||
|
||||
<?php if ( $actor->get_summary() ) : ?>
|
||||
<div class="activitypub-profile__bio p-note">
|
||||
<?php echo wp_kses_post( $actor->get_summary() ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="activitypub-profile__stats">
|
||||
<?php if ( null !== $stats['posts'] ) : ?>
|
||||
<div>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: Number of posts */
|
||||
esc_html( _n( '%s post', '%s posts', (int) $stats['posts'], 'activitypub' ) ),
|
||||
'<strong>' . esc_html( number_format_i18n( $stats['posts'] ) ) . '</strong>'
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ( null !== $stats['followers'] ) : ?>
|
||||
<div>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: Number of followers */
|
||||
esc_html( _n( '%s follower', '%s followers', (int) $stats['followers'], 'activitypub' ) ),
|
||||
'<strong>' . esc_html( number_format_i18n( $stats['followers'] ) ) . '</strong>'
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// Render the modal using the Blocks class.
|
||||
Blocks::render_modal(
|
||||
array(
|
||||
'id' => $block_id . '-modal',
|
||||
'content' => $modal_content,
|
||||
/* translators: %s: Profile name. */
|
||||
'title' => sprintf( esc_html__( 'Follow %s', 'activitypub' ), esc_html( $actor->get_name() ) ),
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
.activitypub__modal.components-modal__frame{background-color:#f7f7f7;color:#333}.activitypub__modal.components-modal__frame .components-modal__header-heading,.activitypub__modal.components-modal__frame h4{color:#333;letter-spacing:inherit;word-spacing:inherit}.activitypub__modal.components-modal__frame .components-modal__header .components-button:hover{color:var(--color-white)}.activitypub__dialog{max-width:40em}.activitypub__dialog h4{line-height:1;margin:0}.activitypub__dialog .activitypub-dialog__section{margin-bottom:2em}.activitypub__dialog .activitypub-dialog__remember{margin-top:1em}.activitypub__dialog .activitypub-dialog__description{font-size:var(--wp--preset--font-size--normal,.75rem);margin:.33em 0 1em}.activitypub__dialog .activitypub-dialog__button-group{align-items:flex-end;display:flex;justify-content:flex-end}.activitypub__dialog .activitypub-dialog__button-group svg{height:21px;margin-left:.5em;width:21px}.activitypub__dialog .activitypub-dialog__button-group input{background-color:var(--wp--preset--color--white);border-radius:0 50px 50px 0;border-width:1px;border:1px solid var(--wp--preset--color--black);color:var(--wp--preset--color--black);flex:1;font-size:16px;height:inherit;line-height:1;margin-left:0;padding:15px 23px}.activitypub__dialog .activitypub-dialog__button-group button{align-self:center;background-color:var(--wp--preset--color--black);border-radius:50px 0 0 50px;border-width:1px;color:var(--wp--preset--color--white);font-size:16px;height:inherit;line-height:1;margin-right:0;padding:15px 23px;text-decoration:none}.activitypub__dialog .activitypub-dialog__button-group button:hover{border:inherit}.activitypub-follow-me-block-wrapper{width:100%}.activitypub-follow-me-block-wrapper.has-background .activitypub-profile,.activitypub-follow-me-block-wrapper.has-border-color .activitypub-profile{padding-right:1rem;padding-left:1rem}.activitypub-follow-me-block-wrapper .activitypub-profile{align-items:center;display:flex;padding:1rem 0}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__avatar{border-radius:50%;height:75px;margin-left:1rem;width:75px}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__content{flex:1;min-width:0}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__handle,.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__name{line-height:1.2;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__name{font-size:1.25em}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__follow{align-self:center;background-color:var(--wp--preset--color--black);color:var(--wp--preset--color--white)}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__follow:not(:only-child){margin-right:1rem}
|
||||
@ -1 +0,0 @@
|
||||
.activitypub__modal.components-modal__frame{background-color:#f7f7f7;color:#333}.activitypub__modal.components-modal__frame .components-modal__header-heading,.activitypub__modal.components-modal__frame h4{color:#333;letter-spacing:inherit;word-spacing:inherit}.activitypub__modal.components-modal__frame .components-modal__header .components-button:hover{color:var(--color-white)}.activitypub__dialog{max-width:40em}.activitypub__dialog h4{line-height:1;margin:0}.activitypub__dialog .activitypub-dialog__section{margin-bottom:2em}.activitypub__dialog .activitypub-dialog__remember{margin-top:1em}.activitypub__dialog .activitypub-dialog__description{font-size:var(--wp--preset--font-size--normal,.75rem);margin:.33em 0 1em}.activitypub__dialog .activitypub-dialog__button-group{align-items:flex-end;display:flex;justify-content:flex-end}.activitypub__dialog .activitypub-dialog__button-group svg{height:21px;margin-right:.5em;width:21px}.activitypub__dialog .activitypub-dialog__button-group input{background-color:var(--wp--preset--color--white);border-radius:50px 0 0 50px;border-width:1px;border:1px solid var(--wp--preset--color--black);color:var(--wp--preset--color--black);flex:1;font-size:16px;height:inherit;line-height:1;margin-right:0;padding:15px 23px}.activitypub__dialog .activitypub-dialog__button-group button{align-self:center;background-color:var(--wp--preset--color--black);border-radius:0 50px 50px 0;border-width:1px;color:var(--wp--preset--color--white);font-size:16px;height:inherit;line-height:1;margin-left:0;padding:15px 23px;text-decoration:none}.activitypub__dialog .activitypub-dialog__button-group button:hover{border:inherit}.activitypub-follow-me-block-wrapper{width:100%}.activitypub-follow-me-block-wrapper.has-background .activitypub-profile,.activitypub-follow-me-block-wrapper.has-border-color .activitypub-profile{padding-left:1rem;padding-right:1rem}.activitypub-follow-me-block-wrapper .activitypub-profile{align-items:center;display:flex;padding:1rem 0}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__avatar{border-radius:50%;height:75px;margin-right:1rem;width:75px}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__content{flex:1;min-width:0}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__handle,.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__name{line-height:1.2;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__name{font-size:1.25em}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__follow{align-self:center;background-color:var(--wp--preset--color--black);color:var(--wp--preset--color--white)}.activitypub-follow-me-block-wrapper .activitypub-profile .activitypub-profile__follow:not(:only-child){margin-left:1rem}
|
||||
@ -1 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '635ed3e6db3230ae865f');
|
||||
<?php return array('dependencies' => array('@wordpress/interactivity'), 'version' => '5b88efee3f3b7a1605df', 'type' => 'module');
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user