array( 'type' => 'string', 'description' => __( 'Absolute URL to inspect. Must belong to the connected Search Console property.', 'acrossai-abilities-manager' ), ), 'mode' => array( 'type' => 'string', 'enum' => array( 'schedule', 'now' ), 'default' => 'schedule', 'description' => __( 'schedule queues the work; now runs it immediately and spends daily Google quota.', 'acrossai-abilities-manager' ), ), ); } protected function output_properties(): array { return array( 'url' => array( 'type' => 'string' ), 'mode' => array( 'type' => 'string' ), 'scheduled' => array( 'type' => 'boolean' ), 'result' => array( 'type' => 'object' ), ); } protected function required_input(): array { return array( 'url' ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => false, 'idempotent' => false ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { $url = isset( $input['url'] ) ? esc_url_raw( trim( (string) $input['url'] ) ) : ''; if ( '' === $url ) { return new WP_Error( 'invalid_input', __( 'url is required.', 'acrossai-abilities-manager' ) ); } $mode = isset( $input['mode'] ) && 'now' === $input['mode'] ? 'now' : 'schedule'; $result = Analytics_Repository::inspect_url( $url, $mode ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = 'now' === $mode ? sprintf( /* translators: %s: inspected URL */ __( 'Inspected %s immediately. One Google URL Inspection quota unit was consumed.', 'acrossai-abilities-manager' ), $url ) : sprintf( /* translators: %s: inspected URL */ __( 'Queued %s for inspection. Read the result later with rank-math/get-index-status.', 'acrossai-abilities-manager' ), $url ); return $result; } }