PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.3
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.3
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
← All changes | integrations/armember/includes/ajax-functions.php +58 -0 5.8.3 → 6.0.3 View file →
@@ -1,0 +1,58 @@
1 +<?php
2 +/**
3 + * Ajax Functions
4 + *
5 + * @package AutomatorWP\Integrations\Mailchimp\Ajax_Functions
6 + * @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]>
7 + * @since 1.0.0
8 + */
9 +// Exit if accessed directly
10 +if( !defined( 'ABSPATH' ) ) exit;
11 +
12 +/**
13 + * Ajax function for selecting membership plans
14 + *
15 + * @since 1.0.0
16 + */
17 +function automatorwp_armember_ajax_get_plans() {
18 + // Security check, forces to die if not security passed
19 + check_ajax_referer( 'automatorwp_admin', 'nonce' );
20 +
21 + // Permissions check
22 + if( ! current_user_can( automatorwp_get_manager_capability() ) ) {
23 + wp_send_json_error( __( 'You\'re not allowed to perform this action.', 'automatorwp' ) );
24 + }
25 +
26 + global $wpdb;
27 +
28 + // Pull back the search string
29 + $search = isset( $_REQUEST['q'] ) ? $wpdb->esc_like( sanitize_text_field( $_REQUEST['q'] ) ) : '';
30 +
31 + $plans = automatorwp_armember_get_plan( );
32 +
33 + $results = array();
34 +
35 + // Parse tag results to match select2 results
36 + foreach ( $plans as $plan ) {
37 +
38 + if( ! empty( $search ) ) {
39 + if( strpos( strtolower( $plan['name'] ), strtolower( $search ) ) === false ) {
40 + continue;
41 + }
42 + }
43 +
44 + $results[] = array(
45 + 'id' => $plan['id'],
46 + 'text' => $plan['name']
47 + );
48 + }
49 +
50 + // Prepend option none
51 + $results = automatorwp_ajax_parse_extra_options( $results );
52 +
53 + // Return our results
54 + wp_send_json_success( $results );
55 + die;
56 +
57 +}
58 +add_action( 'wp_ajax_automatorwp_armember_get_plans', 'automatorwp_armember_ajax_get_plans' );