Files
roi-theme/wp-content/plugins/wp-marketing-automations/includes/api/automation/class-bwfan-api-custom-search.php
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

43 lines
1.4 KiB
PHP
Executable File

<?php
class BWFAN_API_Get_Custom_Search extends BWFAN_API_Base {
public static $ins;
public static function get_instance() {
if ( null === self::$ins ) {
self::$ins = new self();
}
return self::$ins;
}
public function __construct() {
parent::__construct();
$this->method = WP_REST_Server::READABLE;
$this->route = '/custom-search/(?P<type>[a-zA-Z0-9_]+)';
}
public function process_api_call() {
do_action( 'bwfan_load_custom_search_classes' );
$type = $this->get_sanitized_arg( 'type' );
// removed get_sanitized_arg function because that was merging two or more substrings and making one
// for example : xl autonami. with get_sanitized_arg, it is becoming xlautonami, which making issue in search
$search = isset( $this->args['search'] ) && ! empty( $this->args['search'] ) ? $this->args['search'] : '';
$extra_data = $this->args;
if ( empty( $type ) ) {
return $this->error_response( __( 'Invalid or empty type', 'wp-marketing-automations' ), null, 400 );
}
if ( ! class_exists( 'BWFAN_' . $type ) ) {
return $this->error_response( __( 'Invalid or empty type', 'wp-marketing-automations' ), null, 400 );
}
$type = BWFAN_Core()->custom_search->get_custom_search( $type );
$options = $type->get_options( $search, $extra_data );
return $this->success_response( $options );
}
}
BWFAN_API_Loader::register( 'BWFAN_API_Get_Custom_Search' );