started ) { return; } $this->started = true; add_action( 'plugins_loaded', array( $this, 'maybe_upgrade' ), 5 ); add_action( 'init', array( $this, 'load_textdomain' ) ); add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) ); add_filter( 'plugin_action_links_' . CONNECTCUE_BASENAME, array( $this, 'action_links' ) ); $frontend = new Frontend(); $frontend->register_hooks(); if ( is_admin() ) { $admin = new Admin(); $admin->register_hooks(); } do_action( 'connectcue_loaded' ); } public function maybe_upgrade(): void { $current_version = (string) get_option( Options::VERSION_OPTION, '' ); if ( CONNECTCUE_VERSION === $current_version ) { return; } Options::migrate_legacy(); Options::ensure_defaults(); update_option( Options::VERSION_OPTION, CONNECTCUE_VERSION, false ); } public function load_textdomain(): void { load_plugin_textdomain( 'connectcue', false, dirname( CONNECTCUE_BASENAME ) . '/languages' ); } public function register_rest_routes(): void { register_rest_route( 'connectcue/v1', '/ping', array( 'methods' => 'GET', 'callback' => array( $this, 'health_check' ), 'permission_callback' => '__return_true', ) ); } public function health_check( WP_REST_Request $request ): WP_REST_Response { $response = new WP_REST_Response( array( 'ok' => true, 'timestamp' => time(), ), 200 ); $response->header( 'Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0' ); /** * Filters the public health-check response. * * @param WP_REST_Response $response REST response. * @param WP_REST_Request $request REST request. */ return apply_filters( 'connectcue_health_response', $response, $request ); } /** * Add plugin row action links. * * @param array $links Existing links. * @return array */ public function action_links( array $links ): array { $custom = array( 'settings' => sprintf( '%s', esc_url( admin_url( 'admin.php?page=connectcue-settings' ) ), esc_html__( 'Settings', 'connectcue' ) ), ); return $custom + $links; } }