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 = '
'; } 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(); ?>