| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: ActivityPub |
| 4 |
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/ |
| 5 |
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format. |
| 6 |
* Version: 0.7.1 |
| 7 |
* Author: Matthias Pfefferle |
| 8 |
* Author URI: https://notiz.blog/ |
| 9 |
* License: MIT |
| 10 |
* License URI: http://opensource.org/licenses/MIT |
| 11 |
* Requires PHP: 5.6 |
| 12 |
* Text Domain: activitypub |
| 13 |
* Domain Path: /languages |
| 14 |
*/ |
| 15 |
|
| 16 |
namespace Activitypub; |
| 17 |
|
| 18 |
/** |
| 19 |
* Initialize plugin |
| 20 |
*/ |
| 21 |
function init() { |
| 22 |
defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(^|\s|\/>)#([^\s<>]+)\b' ); |
| 23 |
|
| 24 |
require_once dirname( __FILE__ ) . '/includes/class-signature.php'; |
| 25 |
require_once dirname( __FILE__ ) . '/includes/class-activity.php'; |
| 26 |
require_once dirname( __FILE__ ) . '/includes/db/class-followers.php'; |
| 27 |
require_once dirname( __FILE__ ) . '/includes/functions.php'; |
| 28 |
|
| 29 |
require_once dirname( __FILE__ ) . '/includes/class-post.php'; |
| 30 |
\Activitypub\Post::init(); |
| 31 |
|
| 32 |
require_once dirname( __FILE__ ) . '/includes/class-activitypub.php'; |
| 33 |
\Activitypub\ActivityPub::init(); |
| 34 |
|
| 35 |
// Configure the REST API route |
| 36 |
require_once dirname( __FILE__ ) . '/includes/rest/class-outbox.php'; |
| 37 |
\Activitypub\Rest\Outbox::init(); |
| 38 |
|
| 39 |
require_once dirname( __FILE__ ) . '/includes/rest/class-inbox.php'; |
| 40 |
\Activitypub\Rest\Inbox::init(); |
| 41 |
|
| 42 |
require_once dirname( __FILE__ ) . '/includes/rest/class-followers.php'; |
| 43 |
\Activitypub\Rest\Followers::init(); |
| 44 |
|
| 45 |
require_once dirname( __FILE__ ) . '/includes/rest/class-following.php'; |
| 46 |
\Activitypub\Rest\Following::init(); |
| 47 |
|
| 48 |
require_once dirname( __FILE__ ) . '/includes/rest/class-webfinger.php'; |
| 49 |
\Activitypub\Rest\Webfinger::init(); |
| 50 |
|
| 51 |
require_once dirname( __FILE__ ) . '/includes/rest/class-nodeinfo.php'; |
| 52 |
\Activitypub\Rest\NodeInfo::init(); |
| 53 |
|
| 54 |
require_once dirname( __FILE__ ) . '/includes/class-admin.php'; |
| 55 |
\Activitypub\Admin::init(); |
| 56 |
|
| 57 |
require_once dirname( __FILE__ ) . '/includes/class-hashtag.php'; |
| 58 |
\Activitypub\Hashtag::init(); |
| 59 |
} |
| 60 |
add_action( 'plugins_loaded', '\Activitypub\init' ); |
| 61 |
|
| 62 |
/** |
| 63 |
* Add rewrite rules |
| 64 |
*/ |
| 65 |
function add_rewrite_rules() { |
| 66 |
if ( ! class_exists( 'Webfinger' ) ) { |
| 67 |
add_rewrite_rule( '^.well-known/webfinger', 'index.php?rest_route=/activitypub/1.0/webfinger', 'top' ); |
| 68 |
} |
| 69 |
|
| 70 |
if ( ! class_exists( 'Nodeinfo' ) ) { |
| 71 |
add_rewrite_rule( '^.well-known/nodeinfo', 'index.php?rest_route=/activitypub/1.0/nodeinfo/discovery', 'top' ); |
| 72 |
add_rewrite_rule( '^.well-known/x-nodeinfo2', 'index.php?rest_route=/activitypub/1.0/nodeinfo2', 'top' ); |
| 73 |
} |
| 74 |
} |
| 75 |
add_action( 'init', '\Activitypub\add_rewrite_rules', 1 ); |
| 76 |
|
| 77 |
/** |
| 78 |
* Flush rewrite rules; |
| 79 |
*/ |
| 80 |
function flush_rewrite_rules() { |
| 81 |
\Activitypub\add_rewrite_rules(); |
| 82 |
\flush_rewrite_rules(); |
| 83 |
} |
| 84 |
register_activation_hook( __FILE__, '\Activitypub\flush_rewrite_rules' ); |
| 85 |
register_deactivation_hook( __FILE__, '\flush_rewrite_rules' ); |
| 86 |
|