pterotype/includes/init.php

82 lines
2.8 KiB
PHP
Raw Normal View History

<?php
2018-10-21 02:34:20 +00:00
namespace pterotype\init;
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';
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';
require_once plugin_dir_path( __FILE__ ) . 'client/posts.php';
require_once plugin_dir_path( __FILE__ ) . 'client/comments.php';
require_once plugin_dir_path( __FILE__ ) . 'client/identity.php';
require_once plugin_dir_path( __FILE__ ) . 'server/async.php';
require_once plugin_dir_path( __FILE__ ) . 'pgp.php';
add_action( 'rest_api_init', function() {
2018-10-21 02:34:20 +00:00
\pterotype\api\register_routes();
} );
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' );
$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-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();
if ( ! empty( 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-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
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-10-21 02:34:20 +00:00
add_action( 'parse_request', '\pterotype\webfinger\parse_request', 111 );
2018-10-21 02:34:20 +00:00
add_filter( 'query_vars', '\pterotype\webfinger\query_vars' );
2018-10-24 23:25:47 +00:00
add_filter( 'query_vars', '\pterotype\api\query_vars' );
2018-10-21 02:34:20 +00:00
add_action( 'well_known_webfinger', '\pterotype\webfinger\handle' );
2018-10-21 02:34:20 +00:00
add_action( 'transition_post_status', '\pterotype\posts\handle_post_status_change', 10, 3 );
add_action(
'transition_comment_status', '\pterotype\comments\handle_transition_comment_status', 10, 3
);
add_action( 'comment_post', '\pterotype\comments\handle_comment_post', 10, 2 );
add_action( 'edit_comment', '\pterotype\comments\handle_edit_comment', 10, 1 );
add_action( 'template_redirect', '\pterotype\api\handle_non_api_requests' );
add_action( 'update_option_blogname', function() {
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
} );
add_action( 'update_option_blogdescription', function() {
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
} );
$theme = \get_option( 'stylesheet' );
add_action( "update_option_theme_mods_$theme", function() {
\pterotype\identity\update_identity( PTEROTYPE_BLOG_ACTOR_SLUG );
} );
?>