Plugin Directory

Changeset 3453271


Ignore:
Timestamp:
02/03/2026 08:22:32 PM (2 months ago)
Author:
omadaops
Message:

Release version 1.2.0

Location:
omadaai
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • omadaai/tags/1.2.0/includes/api/class-widget-config-api.php

    r3441122 r3453271  
    2626                ],
    2727                'agent_id' => [
    28                     'description' => __( 'Agent ID (UUID)', 'omadaai' ),
     28                    'description' => __( 'Agent ID', 'omadaai' ),
    2929                    'type'        => 'string',
    3030                    'required'    => false,
    3131                    '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 );
    3333                    },
    3434                ],
     
    4747                    'validate_callback' => function( $value ) {
    4848                        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';
    4962                    },
    5063                ],
     
    123136        $workspace_id = sanitize_text_field( $request->get_param( 'workspace_id' ) );
    124137        $access_token = sanitize_text_field( $request->get_param( 'access_token' ) );
     138        $script_url   = sanitize_text_field( $request->get_param( 'script_url' ) );
    125139
    126140        if ( empty( $agent_id ) || empty( $workspace_id ) || empty( $access_token ) ) {
     
    145159            'workspace_id'  => $workspace_id,
    146160            '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',
    148164            'updated_at'    => current_time( 'mysql' ),
    149165        ];
  • omadaai/tags/1.2.0/includes/class-admin.php

    r3441122 r3453271  
    7373        $uuid_regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i';
    7474
    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' );
    7777        }
    7878
  • omadaai/trunk/includes/api/class-widget-config-api.php

    r3441122 r3453271  
    2626                ],
    2727                'agent_id' => [
    28                     'description' => __( 'Agent ID (UUID)', 'omadaai' ),
     28                    'description' => __( 'Agent ID', 'omadaai' ),
    2929                    'type'        => 'string',
    3030                    'required'    => false,
    3131                    '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 );
    3333                    },
    3434                ],
     
    4747                    'validate_callback' => function( $value ) {
    4848                        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';
    4962                    },
    5063                ],
     
    123136        $workspace_id = sanitize_text_field( $request->get_param( 'workspace_id' ) );
    124137        $access_token = sanitize_text_field( $request->get_param( 'access_token' ) );
     138        $script_url   = sanitize_text_field( $request->get_param( 'script_url' ) );
    125139
    126140        if ( empty( $agent_id ) || empty( $workspace_id ) || empty( $access_token ) ) {
     
    145159            'workspace_id'  => $workspace_id,
    146160            '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',
    148164            'updated_at'    => current_time( 'mysql' ),
    149165        ];
  • omadaai/trunk/includes/class-admin.php

    r3441122 r3453271  
    7373        $uuid_regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i';
    7474
    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' );
    7777        }
    7878
Note: See TracChangeset for help on using the changeset viewer.