<?php
/**
 * Plugin Name:       Waypoint Agent
 * Plugin URI:        https://github.com/statenweb/waypoint-agent
 * Description:       Connects a WordPress site to the content-yo authority platform — reports site state to the monitor and provides read/write REST endpoints for content ingestion, draft publishing, and media management.
 * Version:           0.7.2
 * Requires at least: 6.0
 * Requires PHP:      8.0
 * Author:            Waypoint Agency
 * License:           MIT
 * Text Domain:       waypoint-agent
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// WP Offload SES: suppress the "verified sender" identity notice in the admin.
if ( ! defined( 'WPOSES_HIDE_VERIFIED' ) ) {
	define( 'WPOSES_HIDE_VERIFIED', true );
}

define( 'WAYPOINT_AGENT_VERSION', '0.7.2' );
define( 'WAYPOINT_AGENT_FILE', __FILE__ );

// Backward-compat alias — external code checking WAYPOINT_MONITOR_VERSION still works.
define( 'WAYPOINT_MONITOR_VERSION', WAYPOINT_AGENT_VERSION );
define( 'WAYPOINT_MONITOR_OPTION_TOKEN', 'waypoint_monitor_token' );
define( 'WAYPOINT_MONITOR_OPTION_REGISTERED_AT', 'waypoint_monitor_registered_at' );
define( 'WAYPOINT_MONITOR_DEFAULT_API_URL', 'https://packagemonitor.apps.waypoint.agency' );
define( 'WAYPOINT_MONITOR_RETRY_HOOK', 'waypoint_monitor_retry_register' );
define( 'WAYPOINT_MONITOR_AGENT_KEY_NAME', 'WAYPOINT_AGENT_KEY' );
define( 'WAYPOINT_MONITOR_REST_NS', 'waypoint-monitor/v1' );
define( 'WAYPOINT_MONITOR_AGENT_REST_NS', 'waypoint-agent/v1' );

$autoload = plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
if ( file_exists( $autoload ) ) {
	require_once $autoload;
}

// Activation/deactivation hooks must reference __FILE__ of the main plugin file.
register_activation_hook( __FILE__, [ '\Waypoint\Agent\Monitor\Registration', 'on_activate' ] );
register_deactivation_hook( __FILE__, [ '\Waypoint\Agent\Monitor\Registration', 'on_deactivate' ] );

if ( class_exists( \Waypoint\Agent\Plugin::class ) ) {
	( new \Waypoint\Agent\Plugin() )->attach_hooks();
}
