2018-08-23 02:07:06 +00:00
|
|
|
<?php
|
2018-10-21 02:34:20 +00:00
|
|
|
namespace pterotype\init;
|
2018-08-23 02:07:06 +00:00
|
|
|
|
2018-10-17 11:08:48 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'util.php';
|
2018-09-27 22:46:21 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'server/api.php';
|
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'server/actors.php';
|
2018-10-09 11:06:26 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'schema.php';
|
2018-10-02 17:27:29 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'server/webfinger.php';
|
2018-10-07 23:12:45 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'client/posts.php';
|
2018-10-23 22:52:36 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'client/comments.php';
|
2018-11-01 11:36:07 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'client/identity.php';
|
2018-10-18 11:34:27 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'server/async.php';
|
2018-10-26 13:23:19 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'pgp.php';
|
2018-11-05 12:42:02 +00:00
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'admin/admin.php';
|
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'admin/settings.php';
|
2018-08-23 02:07:06 +00:00
|
|
|
|
2018-11-10 04:39:52 +00:00
|
|
|
if ( ! function_exists( 'opengraph_metadata' ) ) {
|
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'lib/opengraph.php';
|
|
|
|
}
|
|
|
|
|
2018-08-23 02:07:06 +00:00
|
|
|
add_action( 'rest_api_init', function() {
|
2018-10-21 02:34:20 +00:00
|
|
|
\pterotype\api\register_routes();
|
2018-08-23 02:07:06 +00:00
|
|
|
} );
|
|
|
|
|
2018-09-04 01:22:23 +00:00
|
|
|
add_action( 'user_register', function( $user_id ) {
|
|
|
|
$slug = get_the_author_meta( 'user_nicename', $user_id );
|
2018-10-26 10:49:40 +00:00
|
|
|
\pterotype\actors\create_actor( $slug, 'user' );
|
2018-10-26 11:07:49 +00:00
|
|
|
$actor_id = \pterotype\actors\get_actor_id( $slug );
|
|
|
|
$keys_created = \pterotype\pgp\get_public_key( $slug );
|
|
|
|
if ( ! $keys_created ) {
|
|
|
|
$keys = \pterotype\pgp\gen_key( $slug );
|
|
|
|
\pterotype\pgp\persist_key( $actor_id, $keys['publickey'], $keys['privatekey'] );
|
|
|
|
}
|
2018-09-04 01:22:23 +00:00
|
|
|
} );
|
|
|
|
|
2018-09-19 15:16:41 +00:00
|
|
|
add_action( 'pterotype_init', function() {
|
2018-10-21 02:34:20 +00:00
|
|
|
\pterotype\schema\run_migrations();
|
2018-10-21 12:52:56 +00:00
|
|
|
\pterotype\actors\initialize_actors();
|
2018-11-27 13:58:24 +00:00
|
|
|
if ( ob_get_contents() ) {
|
2018-11-04 12:45:12 +00:00
|
|
|
\error_log( ob_get_contents() );
|
2018-10-09 12:58:25 +00:00
|
|
|
}
|
2018-08-23 02:07:06 +00:00
|
|
|
} );
|
2018-09-19 21:44:21 +00:00
|
|
|
|
|
|
|
add_action( 'pterotype_load', function() {
|
2018-10-21 02:34:20 +00:00
|
|
|
\pterotype\schema\run_migrations();
|
2018-10-21 12:52:56 +00:00
|
|
|
\pterotype\async\init_tasks();
|
2018-09-19 21:44:21 +00:00
|
|
|
} );
|
2018-10-02 17:27:29 +00:00
|
|
|
|
2018-11-03 18:30:16 +00:00
|
|
|
add_action( 'pterotype_uninstall', function() {
|
|
|
|
\pterotype\schema\purge_all_data();
|
|
|
|
} );
|
|
|
|
|
2018-10-21 02:34:20 +00:00
|
|
|
add_action( 'generate_rewrite_rules', '\pterotype\webfinger\generate_rewrite_rules', 111 );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-21 02:34:20 +00:00
|
|
|
add_action( 'parse_request', '\pterotype\webfinger\parse_request', 111 );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-21 02:34:20 +00:00
|
|
|
add_filter( 'query_vars', '\pterotype\webfinger\query_vars' );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-24 23:25:47 +00:00
|
|
|
add_filter( 'query_vars', '\pterotype\api\query_vars' );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-21 02:34:20 +00:00
|
|
|
add_action( 'well_known_webfinger', '\pterotype\webfinger\handle' );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-21 02:34:20 +00:00
|
|
|
add_action( 'transition_post_status', '\pterotype\posts\handle_post_status_change', 10, 3 );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-23 22:52:36 +00:00
|
|
|
add_action(
|
|
|
|
'transition_comment_status', '\pterotype\comments\handle_transition_comment_status', 10, 3
|
|
|
|
);
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-23 22:52:36 +00:00
|
|
|
add_action( 'comment_post', '\pterotype\comments\handle_comment_post', 10, 2 );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-23 22:52:36 +00:00
|
|
|
add_action( 'edit_comment', '\pterotype\comments\handle_edit_comment', 10, 1 );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-10-21 13:41:17 +00:00
|
|
|
add_action( 'template_redirect', '\pterotype\api\handle_non_api_requests' );
|
2018-11-03 18:30:16 +00:00
|
|
|
|
2018-11-01 11:36:07 +00:00
|
|
|
add_action( 'update_option_blogname', function() {
|
|
|
|
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
|
2018-11-03 18:30:16 +00:00
|
|
|
} );
|
|
|
|
|
2018-11-01 11:36:07 +00:00
|
|
|
add_action( 'update_option_blogdescription', function() {
|
|
|
|
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
|
2018-11-03 18:30:16 +00:00
|
|
|
} );
|
|
|
|
|
2018-11-02 10:44:13 +00:00
|
|
|
$theme = \get_option( 'stylesheet' );
|
|
|
|
add_action( "update_option_theme_mods_$theme", function() {
|
|
|
|
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
|
2018-11-03 18:30:16 +00:00
|
|
|
} );
|
2018-11-05 12:42:02 +00:00
|
|
|
|
2018-11-06 13:18:04 +00:00
|
|
|
add_action( 'update_option_pterotype_blog_name', function() {
|
|
|
|
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
|
|
|
|
} );
|
|
|
|
|
|
|
|
add_action( 'update_option_pterotype_blog_description', function() {
|
|
|
|
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
|
|
|
|
} );
|
|
|
|
|
2018-11-08 13:50:29 +00:00
|
|
|
add_action( 'update_option_pterotype_blog_icon', function() {
|
|
|
|
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
|
|
|
|
} );
|
|
|
|
|
2018-11-05 12:42:02 +00:00
|
|
|
add_action( 'admin_menu', function() {
|
|
|
|
\pterotype\admin\register_admin_page();
|
|
|
|
\pterotype\settings\register_settings_sections();
|
|
|
|
\pterotype\settings\register_settings_fields();
|
|
|
|
} );
|
2018-11-10 03:27:28 +00:00
|
|
|
|
|
|
|
add_filter( 'get_avatar', '\pterotype\comments\get_avatar_filter', 10, 5 );
|
2018-08-23 02:07:06 +00:00
|
|
|
?>
|