← All changes
|
integrations/generator/includes/ajax-functions.php
+51
-0
5.7.9.2
→
6.0.3
View file →
| @@ -1,0 +1,51 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Ajax Functions | |
| 4 | + * | |
| 5 | + * @package AutomatorWP\FluentForm\Ajax_Functions | |
| 6 | + * @since 1.0.0 | |
| 7 | + */ | |
| 8 | +// Exit if accessed directly | |
| 9 | +if( !defined( 'ABSPATH' ) ) exit; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Ajax function for selecting algorithms | |
| 13 | + * | |
| 14 | + * @since 1.0.0 | |
| 15 | + */ | |
| 16 | +function automatorwp_generator_ajax_get_algorithms() { | |
| 17 | + // Security check | |
| 18 | + check_ajax_referer( 'automatorwp_admin', 'nonce' ); | |
| 19 | + | |
| 20 | + // Permissions check | |
| 21 | + if( ! current_user_can( automatorwp_get_manager_capability() ) ) { | |
| 22 | + wp_send_json_error( __( 'You\'re not allowed to perform this action.', 'automatorwp' ) ); | |
| 23 | + } | |
| 24 | + | |
| 25 | + global $wpdb; | |
| 26 | + | |
| 27 | + // Pull back the search string | |
| 28 | + $search = isset( $_REQUEST['q'] ) ? $wpdb->esc_like( $_REQUEST['q'] ) : ''; | |
| 29 | + | |
| 30 | + $results = array(); | |
| 31 | + | |
| 32 | + // Get the algorithms | |
| 33 | + $algorithms = hash_algos(); | |
| 34 | + | |
| 35 | + foreach( $algorithms as $key => $value ) { | |
| 36 | + | |
| 37 | + $results[] = array( | |
| 38 | + 'id' => $key, | |
| 39 | + 'text' => $value, | |
| 40 | + ); | |
| 41 | + } | |
| 42 | + | |
| 43 | + // Prepend option none | |
| 44 | + $results = automatorwp_ajax_get_ajax_results_option_none( $results ); | |
| 45 | + | |
| 46 | + // Return our results | |
| 47 | + wp_send_json_success( $results ); | |
| 48 | + die; | |
| 49 | + | |
| 50 | +} | |
| 51 | +add_action( 'wp_ajax_automatorwp_generator_get_algorithms', 'automatorwp_generator_ajax_get_algorithms', 5 ); | |