id = 'aisp_order_tools'; $this->label = __( 'Order Tools', 'aisp-order-tools-for-woocommerce' ); parent::__construct(); add_filter( 'woocommerce_get_sections_' . $this->id, [ $this, 'get_sections' ] ); add_filter( 'woocommerce_get_settings_' . $this->id, [ $this, 'get_settings' ], 10, 2 ); add_action( 'woocommerce_update_options_' . $this->id, [ $this, 'save' ] ); add_action( 'woocommerce_admin_field_aisp_html', [ $this, 'render_custom_html_field' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] ); } public function render_custom_html_field( $value ) { if ( isset( $value['html'] ) ) { echo wp_kses_post( $value['html'] ); } } public function get_sections() { return [ '' => __( 'Phone order', 'aisp-order-tools-for-woocommerce' ), 'notifications' => __( 'Notifications', 'aisp-order-tools-for-woocommerce' ), 'other-tools' => __( 'Other tools', 'aisp-order-tools-for-woocommerce' ), ]; } public function get_settings( $current_section = '' ) { switch ( $current_section ) { case 'notifications': return ( new Settings_Notifications() )->get_settings(); case 'other-tools': return ( new AISP_Settings_OtherTools() )->get_settings(); ; case 'phoneorder': default: return ( new Settings_PhoneOrder() )->get_settings(); } } public function enqueue_admin_assets( $hook ) { if ( 'woocommerce_page_wc-settings' !== $hook ) { return; } wp_enqueue_style( 'aisp-otools-admin-settings', AISP_OTOOLS_URL . 'assets/css/admin-settings.css', [], AISP_OTOOLS_VERSION ); wp_enqueue_script( 'aisp-otools-admin-settings', AISP_OTOOLS_URL . 'assets/js/admin-settings.js', [ 'jquery' ], AISP_OTOOLS_VERSION, true ); } }