Changeset 3453271
- Timestamp:
- 02/03/2026 08:22:32 PM (2 months ago)
- Location:
- omadaai
- Files:
-
- 4 edited
- 1 copied
-
tags/1.2.0 (copied) (copied from omadaai/trunk)
-
tags/1.2.0/includes/api/class-widget-config-api.php (modified) (4 diffs)
-
tags/1.2.0/includes/class-admin.php (modified) (1 diff)
-
trunk/includes/api/class-widget-config-api.php (modified) (4 diffs)
-
trunk/includes/class-admin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
omadaai/tags/1.2.0/includes/api/class-widget-config-api.php
r3441122 r3453271 26 26 ], 27 27 'agent_id' => [ 28 'description' => __( 'Agent ID (UUID)', 'omadaai' ),28 'description' => __( 'Agent ID', 'omadaai' ), 29 29 'type' => 'string', 30 30 'required' => false, 31 31 'validate_callback' => function( $value ) { 32 return empty( $value ) || ( bool) preg_match( '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', $value);32 return empty( $value ) || ( is_string( $value ) && strlen( trim( $value ) ) > 0 ); 33 33 }, 34 34 ], … … 47 47 'validate_callback' => function( $value ) { 48 48 return empty( $value ) || ( strpos( $value, 'pk-' ) === 0 ); 49 }, 50 ], 51 'script_url' => [ 52 'description' => __( 'Widget script URL (HTTPS, ending with .js)', 'omadaai' ), 53 'type' => 'string', 54 'required' => false, 55 'validate_callback' => function( $value ) { 56 if ( empty( $value ) ) { 57 return true; 58 } 59 return filter_var( $value, FILTER_VALIDATE_URL ) 60 && strpos( $value, 'https://' ) === 0 61 && substr( $value, -3 ) === '.js'; 49 62 }, 50 63 ], … … 123 136 $workspace_id = sanitize_text_field( $request->get_param( 'workspace_id' ) ); 124 137 $access_token = sanitize_text_field( $request->get_param( 'access_token' ) ); 138 $script_url = sanitize_text_field( $request->get_param( 'script_url' ) ); 125 139 126 140 if ( empty( $agent_id ) || empty( $workspace_id ) || empty( $access_token ) ) { … … 145 159 'workspace_id' => $workspace_id, 146 160 'access_token' => $access_token, 147 'script_url' => 'https://chatwidget.omada-prod.io/v1.0/prod-omadacdn.js', 161 'script_url' => ! empty( $script_url ) 162 ? esc_url_raw( $script_url ) 163 : 'https://chatwidget.omada-prod.io/v1.0/prod-omadacdn.js', 148 164 'updated_at' => current_time( 'mysql' ), 149 165 ]; -
omadaai/tags/1.2.0/includes/class-admin.php
r3441122 r3453271 73 73 $uuid_regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i'; 74 74 75 if ( empty( $input['agent_id'] ) || ! preg_match( $uuid_regex, $input['agent_id'] )) {76 $errors[] = __( 'Agent ID must be a valid UUID.', 'omadaai' );75 if ( empty( $input['agent_id'] ) || ! is_string( $input['agent_id'] ) || strlen( trim( $input['agent_id'] ) ) === 0 ) { 76 $errors[] = __( 'Agent ID is required.', 'omadaai' ); 77 77 } 78 78 -
omadaai/trunk/includes/api/class-widget-config-api.php
r3441122 r3453271 26 26 ], 27 27 'agent_id' => [ 28 'description' => __( 'Agent ID (UUID)', 'omadaai' ),28 'description' => __( 'Agent ID', 'omadaai' ), 29 29 'type' => 'string', 30 30 'required' => false, 31 31 'validate_callback' => function( $value ) { 32 return empty( $value ) || ( bool) preg_match( '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', $value);32 return empty( $value ) || ( is_string( $value ) && strlen( trim( $value ) ) > 0 ); 33 33 }, 34 34 ], … … 47 47 'validate_callback' => function( $value ) { 48 48 return empty( $value ) || ( strpos( $value, 'pk-' ) === 0 ); 49 }, 50 ], 51 'script_url' => [ 52 'description' => __( 'Widget script URL (HTTPS, ending with .js)', 'omadaai' ), 53 'type' => 'string', 54 'required' => false, 55 'validate_callback' => function( $value ) { 56 if ( empty( $value ) ) { 57 return true; 58 } 59 return filter_var( $value, FILTER_VALIDATE_URL ) 60 && strpos( $value, 'https://' ) === 0 61 && substr( $value, -3 ) === '.js'; 49 62 }, 50 63 ], … … 123 136 $workspace_id = sanitize_text_field( $request->get_param( 'workspace_id' ) ); 124 137 $access_token = sanitize_text_field( $request->get_param( 'access_token' ) ); 138 $script_url = sanitize_text_field( $request->get_param( 'script_url' ) ); 125 139 126 140 if ( empty( $agent_id ) || empty( $workspace_id ) || empty( $access_token ) ) { … … 145 159 'workspace_id' => $workspace_id, 146 160 'access_token' => $access_token, 147 'script_url' => 'https://chatwidget.omada-prod.io/v1.0/prod-omadacdn.js', 161 'script_url' => ! empty( $script_url ) 162 ? esc_url_raw( $script_url ) 163 : 'https://chatwidget.omada-prod.io/v1.0/prod-omadacdn.js', 148 164 'updated_at' => current_time( 'mysql' ), 149 165 ]; -
omadaai/trunk/includes/class-admin.php
r3441122 r3453271 73 73 $uuid_regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i'; 74 74 75 if ( empty( $input['agent_id'] ) || ! preg_match( $uuid_regex, $input['agent_id'] )) {76 $errors[] = __( 'Agent ID must be a valid UUID.', 'omadaai' );75 if ( empty( $input['agent_id'] ) || ! is_string( $input['agent_id'] ) || strlen( trim( $input['agent_id'] ) ) === 0 ) { 76 $errors[] = __( 'Agent ID is required.', 'omadaai' ); 77 77 } 78 78
Note: See TracChangeset
for help on using the changeset viewer.