option_group, 'akkedli_send_pending', array( 'type' => 'boolean', 'sanitize_callback' => 'rest_sanitize_boolean', 'default' => true )); register_setting($this->option_group, 'akkedli_send_processing', array( 'type' => 'boolean', 'sanitize_callback' => 'rest_sanitize_boolean', 'default' => true )); // Add settings section add_settings_section( 'akkedli_main_section', __('Order Trigger Settings', 'akkedli-connector'), array($this, 'section_callback'), 'akkedli-connector' ); add_settings_field( 'akkedli_order_triggers', __('Send orders when status is', 'akkedli-connector'), array($this, 'order_triggers_field_callback'), 'akkedli-connector', 'akkedli_main_section' ); } /** * Section description callback */ public function section_callback() { echo '

' . esc_html__('Choose which WooCommerce order statuses should send orders to Akkedli.', 'akkedli-connector') . '

'; } /** * Order triggers field callback */ public function order_triggers_field_callback() { $send_pending = get_option('akkedli_send_pending', true); $send_processing = get_option('akkedli_send_processing', true); echo ''; echo ''; echo '

' . esc_html__('Select which order statuses should send orders to Akkedli.', 'akkedli-connector') . '

'; } /** * Get API Key */ public static function get_api_key() { if (!Akkedli_Connector_State::legacy_outbound_allowed()) { return ''; } if (null !== Akkedli_Legacy_Connection_State::load()) return Akkedli_Legacy_Connection_State::credential(); return get_option('akkedli_api_key', ''); } /** * Get Webhook URL */ public static function get_webhook_url() { if (!Akkedli_Connector_State::legacy_outbound_allowed()) { return ''; } $legacy = Akkedli_Legacy_Connection_State::load(); if (null !== $legacy) return is_array($legacy) && isset($legacy['webhook_url']) ? $legacy['webhook_url'] : ''; return get_option('akkedli_webhook_url', ''); } /** * Check if settings are configured */ public static function is_configured() { return !empty(self::get_api_key()) && !empty(self::get_webhook_url()); } /** * Check if API key is validated (via auto-connect) */ public static function is_validated() { $legacy = Akkedli_Legacy_Connection_State::load(); if (null !== $legacy) return is_array($legacy) && 'connected' === $legacy['status']; return (bool) get_option('akkedli_api_key_validated', false); } /** * Get connection timestamp */ public static function get_connected_at() { return get_option('akkedli_connected_at', ''); } }