Skip to content

Commit 58c19de

Browse files
authored
Merge pull request #180 from pfefferle/feature-guidance
add some guidance
2 parents 6cd68a8 + 9869daf commit 58c19de

24 files changed

+558
-125
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@master
1212
- name: WordPress Plugin Deploy
13-
uses: 10up/action-wordpress-plugin-deploy@master
13+
uses: 10up/action-wordpress-plugin-deploy@stable
1414
env:
1515
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
1616
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}

.github/workflows/phpunit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Unit Testing
2-
on:
2+
on:
33
push:
44
pull_request:
55
jobs:
@@ -15,7 +15,7 @@ jobs:
1515
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
1616
strategy:
1717
matrix:
18-
php-versions: ['5.6', '7.2', '7.3', '7.4', '8.0', '8.1']
18+
php-versions: ['5.6', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v2
@@ -24,7 +24,7 @@ jobs:
2424
with:
2525
php-version: ${{ matrix.php-versions }}
2626
coverage: none
27-
tools: composer, phpunit-polyfills
27+
tools: composer, phpunit-polyfills
2828
extensions: mysql
2929
- name: Install Composer dependencies for PHP
3030
uses: "ramsey/composer-install@v1"

.github/workflows/update-assets.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@master
1212
- name: WordPress.org plugin asset/readme update
13-
uses: 10up/action-wordpress-plugin-asset-update@master
13+
uses: 10up/action-wordpress-plugin-asset-update@stable
1414
env:
1515
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
1616
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ composer.lock
55
.DS_Store
66
.idea/
77
.php_cs.cache
8+
.vscode/settings.json
89
.phpunit.result.cache
9-

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ActivityPub #
2-
**Contributors:** [pfefferle](https://profiles.wordpress.org/pfefferle), [mediaformat](https://profiles.wordpress.org/mediaformat)
2+
**Contributors:** [pfefferle](https://profiles.wordpress.org/pfefferle/), [mediaformat](https://profiles.wordpress.org/mediaformat/)
33
**Donate link:** https://notiz.blog/donate/
44
**Tags:** OStatus, fediverse, activitypub, activitystream
55
**Requires at least:** 4.7

activitypub.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ function init() {
2222
\defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|(?<=<p>)|(?<=<br>)|^)#([A-Za-z0-9_]+)(?:(?=\s|[[:punct:]]|$))' );
2323
\defined( 'ACTIVITYPUB_ALLOWED_HTML' ) || \define( 'ACTIVITYPUB_ALLOWED_HTML', '<strong><a><p><ul><ol><li><code><blockquote><pre><img>' );
2424
\defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "<p><strong>%title%</strong></p>\n\n%content%\n\n<p>%hashtags%</p>\n\n<p>%shortlink%</p>" );
25+
\define( 'ACTIVITYPUB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
26+
\define( 'ACTIVITYPUB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
27+
\define( 'ACTIVITYPUB_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) );
2528

2629
require_once \dirname( __FILE__ ) . '/includes/table/followers-list.php';
2730
require_once \dirname( __FILE__ ) . '/includes/class-signature.php';
31+
require_once \dirname( __FILE__ ) . '/includes/class-webfinger.php';
2832
require_once \dirname( __FILE__ ) . '/includes/peer/class-followers.php';
2933
require_once \dirname( __FILE__ ) . '/includes/functions.php';
3034

@@ -107,7 +111,7 @@ function add_rewrite_rules() {
107111
\add_rewrite_rule( '^.well-known/webfinger', 'index.php?rest_route=/activitypub/1.0/webfinger', 'top' );
108112
}
109113

110-
if ( ! \class_exists( 'Nodeinfo' ) ) {
114+
if ( ! \class_exists( 'Nodeinfo' ) || ! (bool) \get_option( 'blog_public', 1 ) ) {
111115
\add_rewrite_rule( '^.well-known/nodeinfo', 'index.php?rest_route=/activitypub/1.0/nodeinfo/discovery', 'top' );
112116
\add_rewrite_rule( '^.well-known/x-nodeinfo2', 'index.php?rest_route=/activitypub/1.0/nodeinfo2', 'top' );
113117
}

assets/css/activitypub-admin.css

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
.settings_page_activitypub .notice {
2+
max-width: 800px;
3+
margin: 0 auto;
4+
}
5+
6+
.activitypub-settings-header {
7+
text-align: center;
8+
margin: 0 0 1rem;
9+
background: #fff;
10+
border-bottom: 1px solid #dcdcde;
11+
}
12+
13+
.activitypub-settings-title-section {
14+
display: flex;
15+
align-items: center;
16+
justify-content: center;
17+
clear: both;
18+
padding-top: 8px;
19+
}
20+
21+
.settings_page_activitypub #wpcontent {
22+
padding-left: 0;
23+
}
24+
25+
.activitypub-settings-tabs-wrapper {
26+
display: -ms-inline-grid;
27+
-ms-grid-columns: 1fr 1fr;
28+
vertical-align: top;
29+
display: inline-grid;
30+
grid-template-columns: 1fr 1fr;
31+
}
32+
33+
.activitypub-settings-tab.active {
34+
box-shadow: inset 0 -3px #3582c4;
35+
font-weight: 600;
36+
}
37+
38+
.activitypub-settings-tab {
39+
display: block;
40+
text-decoration: none;
41+
color: inherit;
42+
padding: .5rem 1rem 1rem;
43+
margin: 0 1rem;
44+
transition: box-shadow .5s ease-in-out;
45+
}
46+
47+
.wp-header-end {
48+
visibility: hidden;
49+
margin: -2px 0 0;
50+
}
51+
52+
summary {
53+
cursor: pointer;
54+
text-decoration: underline;
55+
color: #2271b1;
56+
}
57+
58+
.activitypub-settings-accordion {
59+
border: 1px solid #c3c4c7;
60+
}
61+
62+
.activitypub-settings-accordion-heading {
63+
margin: 0;
64+
border-top: 1px solid #c3c4c7;
65+
font-size: inherit;
66+
line-height: inherit;
67+
font-weight: 600;
68+
color: inherit;
69+
}
70+
71+
.activitypub-settings-accordion-heading:first-child {
72+
border-top: none;
73+
}
74+
75+
.activitypub-settings-accordion-panel {
76+
margin: 0;
77+
padding: 1em 1.5em;
78+
background: #fff;
79+
}
80+
81+
.activitypub-settings-accordion-trigger {
82+
background: #fff;
83+
border: 0;
84+
color: #2c3338;
85+
cursor: pointer;
86+
display: flex;
87+
font-weight: 400;
88+
margin: 0;
89+
padding: 1em 3.5em 1em 1.5em;
90+
min-height: 46px;
91+
position: relative;
92+
text-align: left;
93+
width: 100%;
94+
align-items: center;
95+
justify-content: space-between;
96+
-webkit-user-select: auto;
97+
user-select: auto;
98+
}
99+
100+
.activitypub-settings-accordion-trigger {
101+
color: #2c3338;
102+
cursor: pointer;
103+
font-weight: 400;
104+
text-align: left;
105+
}
106+
107+
.activitypub-settings-accordion-trigger .title {
108+
pointer-events: none;
109+
font-weight: 600;
110+
flex-grow: 1;
111+
}
112+
113+
.activitypub-settings-accordion-trigger .icon, .activitypub-settings-accordion-viewed .icon {
114+
border: solid #50575e medium;
115+
border-width: 0 2px 2px 0;
116+
height: .5rem;
117+
pointer-events: none;
118+
position: absolute;
119+
right: 1.5em;
120+
top: 50%;
121+
transform: translateY(-70%) rotate(45deg);
122+
width: .5rem;
123+
}
124+
125+
.activitypub-settings-accordion-trigger[aria-expanded="true"] .icon {
126+
transform: translateY(-30%) rotate(-135deg);
127+
}
128+
129+
.activitypub-settings-accordion-trigger:active, .activitypub-settings-accordion-trigger:hover {
130+
background: #f6f7f7;
131+
}
132+
133+
.activitypub-settings-accordion-trigger:focus {
134+
color: #1d2327;
135+
border: none;
136+
box-shadow: none;
137+
outline-offset: -1px;
138+
outline: 2px solid #2271b1;
139+
background-color: #f6f7f7;
140+
}

assets/js/activitypub-admin.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
jQuery( function( $ ) {
2+
// Accordion handling in various areas.
3+
$( '.activitypub-settings-accordion' ).on( 'click', '.activitypub-settings-accordion-trigger', function() {
4+
var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) );
5+
6+
if ( isExpanded ) {
7+
$( this ).attr( 'aria-expanded', 'false' );
8+
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', true );
9+
} else {
10+
$( this ).attr( 'aria-expanded', 'true' );
11+
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', false );
12+
}
13+
} );
14+
15+
$(document).on( 'wp-plugin-install-success', function( event, response ) {
16+
setTimeout( function() {
17+
$( '.activate-now' ).removeClass( 'thickbox open-plugin-details-modal' );
18+
}, 1200 );
19+
} );
20+
} );

includes/class-admin.php

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ public static function init() {
1414
\add_action( 'admin_menu', array( '\Activitypub\Admin', 'admin_menu' ) );
1515
\add_action( 'admin_init', array( '\Activitypub\Admin', 'register_settings' ) );
1616
\add_action( 'show_user_profile', array( '\Activitypub\Admin', 'add_fediverse_profile' ) );
17+
\add_action( 'admin_enqueue_scripts', array( '\Activitypub\Admin', 'enqueue_scripts' ) );
1718
}
1819

1920
/**
2021
* Add admin menu entry
2122
*/
2223
public static function admin_menu() {
2324
$settings_page = \add_options_page(
24-
'ActivityPub',
25+
'Welcome',
2526
'ActivityPub',
2627
'manage_options',
2728
'activitypub',
@@ -39,7 +40,27 @@ public static function admin_menu() {
3940
* Load settings page
4041
*/
4142
public static function settings_page() {
42-
\load_template( \dirname( __FILE__ ) . '/../templates/settings.php' );
43+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
44+
if ( empty( $_GET['tab'] ) ) {
45+
$tab = 'welcome';
46+
} else {
47+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
48+
$tab = sanitize_key( $_GET['tab'] );
49+
}
50+
51+
switch ( $tab ) {
52+
case 'settings':
53+
\load_template( \dirname( __FILE__ ) . '/../templates/settings.php' );
54+
break;
55+
case 'welcome':
56+
default:
57+
wp_enqueue_script( 'plugin-install' );
58+
add_thickbox();
59+
wp_enqueue_script( 'updates' );
60+
61+
\load_template( \dirname( __FILE__ ) . '/../templates/welcome.php' );
62+
break;
63+
}
4364
}
4465

4566
/**
@@ -122,23 +143,7 @@ public static function register_settings() {
122143
}
123144

124145
public static function add_settings_help_tab() {
125-
\get_current_screen()->add_help_tab(
126-
array(
127-
'id' => 'overview',
128-
'title' => \__( 'Overview', 'activitypub' ),
129-
'content' =>
130-
'<p>' . \__( 'ActivityPub is a decentralized social networking protocol based on the ActivityStreams 2.0 data format. ActivityPub is an official W3C recommended standard published by the W3C Social Web Working Group. It provides a client to server API for creating, updating and deleting content, as well as a federated server to server API for delivering notifications and subscribing to content.', 'activitypub' ) . '</p>',
131-
)
132-
);
133-
134-
\get_current_screen()->set_help_sidebar(
135-
'<p><strong>' . \__( 'For more information:', 'activitypub' ) . '</strong></p>' .
136-
'<p>' . \__( '<a href="https://activitypub.rocks/">Test Suite</a>', 'activitypub' ) . '</p>' .
137-
'<p>' . \__( '<a href="https://www.w3.org/TR/activitypub/">W3C Spec</a>', 'activitypub' ) . '</p>' .
138-
'<p>' . \__( '<a href="https://github.com/pfefferle/wordpress-activitypub/issues">Give us feedback</a>', 'activitypub' ) . '</p>' .
139-
'<hr />' .
140-
'<p>' . \__( '<a href="https://notiz.blog/donate">Donate</a>', 'activitypub' ) . '</p>'
141-
);
146+
require_once \dirname( __FILE__ ) . '/help.php';
142147
}
143148

144149
public static function add_followers_list_help_tab() {
@@ -147,8 +152,15 @@ public static function add_followers_list_help_tab() {
147152

148153
public static function add_fediverse_profile( $user ) {
149154
?>
150-
<h2><?php \esc_html_e( 'Fediverse', 'activitypub' ); ?></h2>
155+
<h2 id="activitypub"><?php \esc_html_e( 'ActivityPub', 'activitypub' ); ?></h2>
151156
<?php
152157
\Activitypub\get_identifier_settings( $user->ID );
153158
}
159+
160+
public static function enqueue_scripts( $hook_suffix ) {
161+
if ( false !== strpos( $hook_suffix, 'activitypub' ) ) {
162+
wp_enqueue_style( 'activitypub-admin-styles', plugins_url( 'assets/css/activitypub-admin.css', ACTIVITYPUB_PLUGIN_FILE ), array(), '1.0.0' );
163+
wp_enqueue_script( 'activitypub-admin-styles', plugins_url( 'assets/js/activitypub-admin.js', ACTIVITYPUB_PLUGIN_FILE ), array( 'jquery' ), '1.0.0', false );
164+
}
165+
}
154166
}

includes/class-debug.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ public static function init() {
1717
}
1818

1919
public static function log_remote_post_responses( $response, $url, $body, $user_id ) {
20+
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
2021
\error_log( "Request to: {$url} with response: " . \print_r( $response, true ) );
2122
}
2223

2324
public static function write_log( $log ) {
2425
if ( \is_array( $log ) || \is_object( $log ) ) {
26+
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log, WordPress.PHP.DevelopmentFunctions.error_log_print_r
2527
\error_log( \print_r( $log, true ) );
2628
} else {
29+
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
2730
\error_log( $log );
2831
}
2932
}

0 commit comments

Comments
 (0)