2018-08-18 12:35:39 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Plugin Name: ActivityPub
|
|
|
|
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
|
|
|
|
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
|
2019-11-24 21:26:00 +01:00
|
|
|
* Version: 0.9.0
|
2018-08-18 12:35:39 +02:00
|
|
|
* Author: Matthias Pfefferle
|
|
|
|
* Author URI: https://notiz.blog/
|
|
|
|
* License: MIT
|
|
|
|
* License URI: http://opensource.org/licenses/MIT
|
2019-02-24 13:01:28 +01:00
|
|
|
* Requires PHP: 5.6
|
2018-08-18 12:35:39 +02:00
|
|
|
* Text Domain: activitypub
|
|
|
|
* Domain Path: /languages
|
|
|
|
*/
|
|
|
|
|
2019-02-24 12:07:41 +01:00
|
|
|
namespace Activitypub;
|
|
|
|
|
2018-08-18 12:35:39 +02:00
|
|
|
/**
|
2019-02-24 13:01:28 +01:00
|
|
|
* Initialize plugin
|
2018-08-18 12:35:39 +02:00
|
|
|
*/
|
2019-02-24 12:07:41 +01:00
|
|
|
function init() {
|
2019-09-27 10:12:59 +02:00
|
|
|
\defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' );
|
2019-01-22 20:51:22 +01:00
|
|
|
|
2019-08-21 10:38:43 +02:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/table/followers-list.php';
|
2019-02-24 12:07:41 +01:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/class-signature.php';
|
2019-11-18 20:57:00 +01:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/peer/class-followers.php';
|
2018-08-18 12:35:39 +02:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/functions.php';
|
|
|
|
|
2019-08-18 21:54:11 +02:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/class-activity-dispatcher.php';
|
|
|
|
\Activitypub\Activity_Dispatcher::init();
|
|
|
|
|
2019-11-18 20:57:00 +01:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/model/class-activity.php';
|
|
|
|
require_once dirname( __FILE__ ) . '/includes/model/class-post.php';
|
|
|
|
\Activitypub\Model\Post::init();
|
2019-02-02 23:56:05 +01:00
|
|
|
|
2018-08-18 12:35:39 +02:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/class-activitypub.php';
|
2019-08-18 21:54:11 +02:00
|
|
|
\Activitypub\Activitypub::init();
|
2018-09-05 22:03:57 +02:00
|
|
|
|
|
|
|
// Configure the REST API route
|
2019-02-24 12:07:41 +01:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/rest/class-outbox.php';
|
|
|
|
\Activitypub\Rest\Outbox::init();
|
|
|
|
|
|
|
|
require_once dirname( __FILE__ ) . '/includes/rest/class-inbox.php';
|
|
|
|
\Activitypub\Rest\Inbox::init();
|
|
|
|
|
|
|
|
require_once dirname( __FILE__ ) . '/includes/rest/class-followers.php';
|
|
|
|
\Activitypub\Rest\Followers::init();
|
|
|
|
|
2019-03-12 22:20:04 +01:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/rest/class-following.php';
|
|
|
|
\Activitypub\Rest\Following::init();
|
|
|
|
|
2019-02-24 12:07:41 +01:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/rest/class-webfinger.php';
|
|
|
|
\Activitypub\Rest\Webfinger::init();
|
|
|
|
|
|
|
|
require_once dirname( __FILE__ ) . '/includes/rest/class-nodeinfo.php';
|
|
|
|
\Activitypub\Rest\NodeInfo::init();
|
2018-12-09 21:54:57 +01:00
|
|
|
|
2019-02-24 12:07:41 +01:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/class-admin.php';
|
|
|
|
\Activitypub\Admin::init();
|
2019-01-22 20:51:22 +01:00
|
|
|
|
2019-03-02 21:10:42 +01:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/class-hashtag.php';
|
|
|
|
\Activitypub\Hashtag::init();
|
2019-08-18 23:27:06 +02:00
|
|
|
|
2019-09-28 14:17:58 +02:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/class-debug.php';
|
|
|
|
\Activitypub\Debug::init();
|
|
|
|
|
2019-09-30 07:59:19 +02:00
|
|
|
require_once dirname( __FILE__ ) . '/includes/class-health-check.php';
|
|
|
|
\Activitypub\Health_Check::init();
|
2018-08-18 12:35:39 +02:00
|
|
|
}
|
2019-02-24 12:07:41 +01:00
|
|
|
add_action( 'plugins_loaded', '\Activitypub\init' );
|
2018-12-09 21:54:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add rewrite rules
|
|
|
|
*/
|
2019-02-24 12:07:41 +01:00
|
|
|
function add_rewrite_rules() {
|
2019-09-27 10:12:59 +02:00
|
|
|
if ( ! \class_exists( 'Webfinger' ) ) {
|
|
|
|
\add_rewrite_rule( '^.well-known/webfinger', 'index.php?rest_route=/activitypub/1.0/webfinger', 'top' );
|
2018-12-09 21:54:57 +01:00
|
|
|
}
|
|
|
|
|
2019-09-27 10:12:59 +02:00
|
|
|
if ( ! \class_exists( 'Nodeinfo' ) ) {
|
|
|
|
\add_rewrite_rule( '^.well-known/nodeinfo', 'index.php?rest_route=/activitypub/1.0/nodeinfo/discovery', 'top' );
|
|
|
|
\add_rewrite_rule( '^.well-known/x-nodeinfo2', 'index.php?rest_route=/activitypub/1.0/nodeinfo2', 'top' );
|
2018-12-09 21:54:57 +01:00
|
|
|
}
|
|
|
|
}
|
2019-09-27 10:12:59 +02:00
|
|
|
\add_action( 'init', '\Activitypub\add_rewrite_rules', 1 );
|
2018-12-09 21:54:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush rewrite rules;
|
|
|
|
*/
|
2019-02-24 12:07:41 +01:00
|
|
|
function flush_rewrite_rules() {
|
|
|
|
\Activitypub\add_rewrite_rules();
|
2019-03-02 20:31:55 +01:00
|
|
|
\flush_rewrite_rules();
|
2018-12-09 21:54:57 +01:00
|
|
|
}
|
2019-09-27 10:12:59 +02:00
|
|
|
\register_activation_hook( __FILE__, '\Activitypub\flush_rewrite_rules' );
|
|
|
|
\register_deactivation_hook( __FILE__, '\flush_rewrite_rules' );
|