pterotype/includes/init.php

41 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace init;
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';
add_action( 'rest_api_init', function() {
\api\register_routes();
} );
add_action( 'user_register', function( $user_id ) {
$slug = get_the_author_meta( 'user_nicename', $user_id );
2018-09-27 22:17:40 +00:00
\actors\create_actor_user( $slug, 'user' );
} );
2018-09-19 15:16:41 +00:00
add_action( 'pterotype_init', function() {
2018-10-09 12:50:21 +00:00
\schema\run_migrations();
2018-09-27 22:17:40 +00:00
\actors\initialize_actors();
2018-10-09 12:58:25 +00:00
if ( WP_DEBUG ) {
2018-10-12 12:42:36 +00:00
$log_dir = plugin_dir_path( __FILE__ ) . '../log';
if ( ! file_exists( $log_dir ) ) {
mkdir( $log_dir, 0777, true );
}
file_put_contents( $log_dir, ob_get_contents() );
2018-10-09 12:58:25 +00:00
}
} );
2018-09-19 21:44:21 +00:00
add_action( 'pterotype_load', function() {
\schema\run_migrations();
2018-09-19 21:44:21 +00:00
} );
2018-10-02 17:27:29 +00:00
add_action( 'generate_rewrite_rules', '\webfinger\generate_rewrite_rules', 111 );
add_action( 'parse_request', '\webfinger\parse_request', 111 );
add_filter( 'query_vars', '\webfinger\query_vars' );
add_action( 'well_known_webfinger', '\webfinger\handle' );
add_action( 'transition_post_status', '\posts\handle_post_status_change', 10, 3 );
?>