@@ 467-505 (lines=39) @@ | ||
464 | * |
|
465 | * @return void |
|
466 | */ |
|
467 | function give_ajax_categories_search() { |
|
468 | $results = array(); |
|
469 | ||
470 | /** |
|
471 | * Filter to modify Ajax tags search args |
|
472 | * |
|
473 | * @since 2.1 |
|
474 | * |
|
475 | * @param array $args argument for get_terms |
|
476 | * |
|
477 | * @return array $args argument for get_terms |
|
478 | */ |
|
479 | $args = (array) apply_filters( 'give_forms_categories_dropdown_args', array( |
|
480 | 'number' => 30, |
|
481 | 'name__like' => esc_sql( sanitize_text_field( $_POST['s'] ) ) |
|
482 | ) ); |
|
483 | ||
484 | $categories = get_terms( 'give_forms_category', $args ); |
|
485 | ||
486 | foreach ( $categories as $category ) { |
|
487 | $results[] = array( |
|
488 | 'id' => $category->term_id, |
|
489 | 'name' => $category->name, |
|
490 | ); |
|
491 | } |
|
492 | ||
493 | /** |
|
494 | * Filter to modify Ajax tags search result |
|
495 | * |
|
496 | * @since 2.1 |
|
497 | * |
|
498 | * @param array $results Contain the categories id and name |
|
499 | * |
|
500 | * @return array $results Contain the categories id and name |
|
501 | */ |
|
502 | $results = (array) apply_filters( 'give_forms_categories_dropdown_responce', $results ); |
|
503 | ||
504 | wp_send_json( $results ); |
|
505 | } |
|
506 | ||
507 | add_action( 'wp_ajax_give_categories_search', 'give_ajax_categories_search' ); |
|
508 | ||
@@ 516-554 (lines=39) @@ | ||
513 | * |
|
514 | * @return void |
|
515 | */ |
|
516 | function give_ajax_tags_search() { |
|
517 | $results = array(); |
|
518 | ||
519 | /** |
|
520 | * Filter to modify Ajax tags search args |
|
521 | * |
|
522 | * @since 2.1 |
|
523 | * |
|
524 | * @param array $args argument for get_terms |
|
525 | * |
|
526 | * @return array $args argument for get_terms |
|
527 | */ |
|
528 | $args = (array) apply_filters( 'give_forms_tags_dropdown_args', array( |
|
529 | 'number' => 30, |
|
530 | 'name__like' => esc_sql( sanitize_text_field( $_POST['s'] ) ) |
|
531 | ) ); |
|
532 | ||
533 | $categories = get_terms( 'give_forms_tag', $args ); |
|
534 | ||
535 | foreach ( $categories as $category ) { |
|
536 | $results[] = array( |
|
537 | 'id' => $category->term_id, |
|
538 | 'name' => $category->name, |
|
539 | ); |
|
540 | } |
|
541 | ||
542 | /** |
|
543 | * Filter to modify Ajax tags search result |
|
544 | * |
|
545 | * @since 2.1 |
|
546 | * |
|
547 | * @param array $results Contain the tags id and name |
|
548 | * |
|
549 | * @return array $results Contain the tags id and name |
|
550 | */ |
|
551 | $results = (array) apply_filters( 'give_forms_tags_dropdown_responce', $results ); |
|
552 | ||
553 | wp_send_json( $results ); |
|
554 | } |
|
555 | ||
556 | add_action( 'wp_ajax_give_tags_search', 'give_ajax_tags_search' ); |
|
557 |