PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.8
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.8
8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 All 46 releases
gamipress / integrations / easy-digital-downloads / includes / ajax-functions.php

ajax-functions.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.8, at integrations/easy-digital-downloads/includes/ajax-functions.php

49 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Ajax Functions
4 *
5 * @package GamiPress\Easy_Digital_Downloads\Ajax_Functions
6 * @since 1.1.2
7 */
8
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 // Return download variations dropdown for requirements UI
13 function gamipress_edd_ajax_get_download_variations() {
14
15 $download_id = $_POST['post_id'];
16 $site_id = $_POST['site_id'];
17
18 if ( !isset ( $_POST['selected'] ) ) {
19 $selected = 0;
20 } else {
21 $selected = $_POST['selected'];
22 }
23
24 if( gamipress_is_network_wide_active() && $site_id !== get_current_blog_id() ) {
25 switch_to_blog( $site_id );
26 $download = edd_get_download( $download_id );
27 restore_current_blog();
28 } else {
29 $download = edd_get_download( $download_id );
30 }
31
32 // Bail if download doesn't exists
33 if( ! $download ) {
34 die();
35 }
36
37 $output = gamipress_edd_get_download_variations_dropdown( $download_id, $selected, $site_id );
38
39 // Bail if download has no variations
40 if( empty( $output ) ) {
41 echo '<span style="color: #a00;">This download has no variations</span>';
42 die();
43 }
44
45 echo $output;
46 die();
47
48 }
49 add_action( 'wp_ajax_gamipress_edd_get_download_variations', 'gamipress_edd_ajax_get_download_variations' );