Set ACTIVITYPUB_REST_NAMESPACE
outside of init
Needed to prevent activation errors.
This commit is contained in:
parent
ec3f8454c1
commit
6a0fc43a05
3 changed files with 6 additions and 2 deletions
|
@ -15,6 +15,8 @@
|
|||
|
||||
namespace Activitypub;
|
||||
|
||||
\defined( 'ACTIVITYPUB_REST_NAMESPACE' ) || \define( 'ACTIVITYPUB_REST_NAMESPACE', 'activitypub/1.0' );
|
||||
|
||||
/**
|
||||
* Initialize plugin
|
||||
*/
|
||||
|
@ -25,8 +27,6 @@ function init() {
|
|||
\defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|(?<=<p>)|(?<=<br>)|^)#([A-Za-z0-9_]+)(?:(?=\s|[[:punct:]]|$))' );
|
||||
\defined( 'ACTIVITYPUB_USERNAME_REGEXP' ) || \define( 'ACTIVITYPUB_USERNAME_REGEXP', '(?:([A-Za-z0-9_-]+)@((?:[A-Za-z0-9_-]+\.)+[A-Za-z]+))' );
|
||||
\defined( 'ACTIVITYPUB_CUSTOM_POST_CONTENT' ) || \define( 'ACTIVITYPUB_CUSTOM_POST_CONTENT', "<strong>[ap_title]</strong>\n\n[ap_content]\n\n[ap_hashtags]\n\n[ap_shortlink]" );
|
||||
\defined( 'ACTIVITYPUB_REST_NAMESPACE' ) || \define( 'ACTIVITYPUB_REST_NAMESPACE', 'activitypub/1.0' );
|
||||
|
||||
\define( 'ACTIVITYPUB_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
\define( 'ACTIVITYPUB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
||||
\define( 'ACTIVITYPUB_PLUGIN_FILE', plugin_dir_path( __FILE__ ) . '/' . basename( __FILE__ ) );
|
||||
|
|
|
@ -80,6 +80,8 @@ class Outbox {
|
|||
// phpcs:ignore
|
||||
$json->totalItems = 0;
|
||||
|
||||
// We can query this more directly based on the supplied post types.
|
||||
// And cache these counts and invalidate them on publish_post.
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$count_posts = \wp_count_posts( $post_type );
|
||||
$json->totalItems += \intval( $count_posts->publish ); // phpcs:ignore
|
||||
|
@ -142,6 +144,7 @@ class Outbox {
|
|||
'required' => true,
|
||||
'type' => 'integer',
|
||||
'validate_callback' => function( $param, $request, $key ) {
|
||||
// this is probably ok on multisite still?
|
||||
return user_can( $param, 'publish_posts' );
|
||||
},
|
||||
);
|
||||
|
|
|
@ -62,6 +62,7 @@ class Webfinger {
|
|||
}
|
||||
|
||||
$user = \get_user_by( 'login', \esc_sql( $resource_identifier ) );
|
||||
/// YIKES NOPE NOPE NOT ON DOTCOM!
|
||||
|
||||
if ( ! $user || ! \user_can( $user, 'publish_posts' ) ) {
|
||||
return new WP_Error( 'activitypub_user_not_found', \__( 'User not found', 'activitypub' ), array( 'status' => 404 ) );
|
||||
|
|
Loading…
Reference in a new issue