register_settings(); } /** * Add admin menus * * @since 1.0.0 */ public function add_menus() { // Add settings page under the Slides menu add_submenu_page( 'edit.php?post_type=hssm_slide', __( 'Slide Manager Settings', 'hi-school-slide-manager' ), __( 'Settings', 'hi-school-slide-manager' ), 'manage_options', 'hssm-settings', array( $this, 'settings_page' ) ); // Add API documentation page add_submenu_page( 'edit.php?post_type=hssm_slide', __( 'API Documentation', 'hi-school-slide-manager' ), __( 'API Docs', 'hi-school-slide-manager' ), 'manage_options', 'hssm-api-docs', array( $this, 'api_docs_page' ) ); } /** * Register plugin settings * * @since 1.0.0 */ public function register_settings() { // Register settings register_setting( 'hssm_settings', 'hssm_plugin_mode' ); register_setting( 'hssm_settings', 'hssm_api_url' ); register_setting( 'hssm_settings', 'hssm_client_site_slug' ); register_setting( 'hssm_settings', 'hssm_notification_emails' ); register_setting( 'hssm_settings', 'hssm_cache_duration' ); register_setting( 'hssm_settings', 'hssm_api_keys' ); // Add settings sections add_settings_section( 'hssm_general', __( 'General Settings', 'hi-school-slide-manager' ), array( $this, 'general_section_callback' ), 'hssm-settings' ); add_settings_section( 'hssm_notifications', __( 'Email Notifications', 'hi-school-slide-manager' ), array( $this, 'notifications_section_callback' ), 'hssm-settings' ); add_settings_section( 'hssm_api', __( 'API Settings', 'hi-school-slide-manager' ), array( $this, 'api_section_callback' ), 'hssm-settings' ); // Add settings fields add_settings_field( 'hssm_plugin_mode', __( 'Plugin Mode', 'hi-school-slide-manager' ), array( $this, 'plugin_mode_field' ), 'hssm-settings', 'hssm_general' ); add_settings_field( 'hssm_api_url', __( 'Manager API URL', 'hi-school-slide-manager' ), array( $this, 'api_url_field' ), 'hssm-settings', 'hssm_general' ); add_settings_field( 'hssm_client_site_slug', __( 'Client Site Slug', 'hi-school-slide-manager' ), array( $this, 'client_site_slug_field' ), 'hssm-settings', 'hssm_general' ); add_settings_field( 'hssm_cache_duration', __( 'Cache Duration', 'hi-school-slide-manager' ), array( $this, 'cache_duration_field' ), 'hssm-settings', 'hssm_general' ); add_settings_field( 'hssm_notification_emails', __( 'Notification Recipients', 'hi-school-slide-manager' ), array( $this, 'notification_emails_field' ), 'hssm-settings', 'hssm_notifications' ); add_settings_field( 'hssm_api_keys', __( 'API Keys', 'hi-school-slide-manager' ), array( $this, 'api_keys_field' ), 'hssm-settings', 'hssm_api' ); } /** * Settings page callback * * @since 1.0.0 */ public function settings_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } // Handle form submission if ( isset( $_POST['submit'] ) || isset( $_POST['generate_api_key'] ) || isset( $_POST['delete_api_key'] ) ) { check_admin_referer( 'hssm_settings' ); $this->handle_settings_save(); } ?>

GET /wp-json/hssm/v1/slides/{site}

GET 
Headers: X-HSSM-API-Key: your-api-key

GET /wp-json/hssm/v1/sites

GET 
Headers: X-HSSM-API-Key: your-api-key

GET /wp-json/hssm/v1/slide/{id}

GET /wp-json/hssm/v1/health

{
  "id": 123,
  "title": "Slide Title",
  "subtitle": "Slide Subtitle",
  "content": "Slide content...",
  "buttons": [
    {
      "text": "Learn More",
      "url": "https://example.com"
    }
  ],
  "order": 0,
  "background_image": {
    "id": 456,
    "url": "https://example.com/image.jpg",
    "width": 1920,
    "height": 800,
    "alt": "Image description",
    "sizes": {
      "full": "https://example.com/image.jpg",
      "large": "https://example.com/image-1024x428.jpg"
    }
  },
  "schedule": {
    "start_date": "2025-01-01 00:00:00",
    "end_date": "2025-12-31 23:59:59",
    "auto_publish": true,
    "auto_unpublish": true
  },
  "target_sites": [
    {
      "slug": "hi-school",
      "name": "Hi-School Pharmacy"
    }
  ],
  "client": {
    "slug": "client-name",
    "name": "Client Name"
  },
  "status": "publish",
  "created": "2025-01-01 12:00:00",
  "modified": "2025-01-01 12:00:00"
}
' . __( 'General plugin settings.', 'hi-school-slide-manager' ) . '

'; } /** * Notifications section callback */ public function notifications_section_callback() { echo '

' . __( 'Configure email notifications for new slides.', 'hi-school-slide-manager' ) . '

'; } /** * API section callback */ public function api_section_callback() { echo '

' . __( 'Manage API keys for companion sites.', 'hi-school-slide-manager' ) . '

'; } /** * Plugin mode field */ public function plugin_mode_field() { $value = get_option( 'hssm_plugin_mode', 'manager' ); ?>

'; echo '

' . __( 'The REST API base URL of the Manager site.', 'hi-school-slide-manager' ) . '

'; } /** * Client site slug field */ public function client_site_slug_field() { $value = get_option( 'hssm_client_site_slug', '' ); ?>

'; echo '' . __( 'Recommended cache duration for API responses (seconds)', 'hi-school-slide-manager' ) . ''; } /** * Notification emails field */ public function notification_emails_field() { $emails = get_option( 'hssm_notification_emails', array() ); echo '
'; echo '' . __( 'Enter email addresses (one per line) to receive notifications when new slides are published.', 'hi-school-slide-manager' ) . ''; } /** * API keys field */ public function api_keys_field() { $api_keys = get_option( 'hssm_api_keys', array() ); echo '
'; if ( empty( $api_keys ) ) { echo '

' . __( 'No API keys generated yet.', 'hi-school-slide-manager' ) . '

'; } else { echo ''; echo ''; echo ''; foreach ( $api_keys as $index => $key ) { echo ''; echo ''; echo ''; echo ''; } echo '
' . __( 'API Key', 'hi-school-slide-manager' ) . '' . __( 'Actions', 'hi-school-slide-manager' ) . '
' . esc_html( $key ) . ''; echo ' '; echo ''; echo ''; echo '
'; } echo '

'; echo '

' . __( 'API keys are used by companion sites to authenticate and fetch slides.', 'hi-school-slide-manager' ) . '

'; echo '
'; // Add JavaScript for copy functionality ?>