PluginProbe
Datafeedr API / 1.0.124
Datafeedr API v1.0.124
1.4.2 1.0.125 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 1.0.30 1.0.31 1.0.32 1.0.33 All 181 releases
datafeedr-api / functions / ajax.php

ajax.php in Datafeedr API 1.0.124, at functions/ajax.php

35 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5 if ( is_admin() ) {
6 add_action( 'wp_ajax_dfrapi_delete_cached_api_data', 'dfrapi_delete_cached_api_data' );
7 }
8
9 /**
10 * Delete cached API data.
11 */
12 function dfrapi_delete_cached_api_data() {
13 check_ajax_referer( 'dfrapi_ajax_nonce', 'dfrapi_security' );
14 // Only delete if user has API requests remaining. This is because we'll need to make 1 request to rebuild 'dfrapi_account'.
15 $status = dfrapi_api_get_status();
16 if ( !array_key_exists( 'dfrapi_api_error', $status ) ) {
17 delete_option( 'dfrapi_account' );
18 $transient_options = get_option( 'dfrapi_transient_whitelist' );
19 if ( !empty( $transient_options ) ) {
20 foreach ( $transient_options as $name ) {
21 $use_cache = wp_using_ext_object_cache( false );
22 delete_transient( $name );
23 wp_using_ext_object_cache( $use_cache );
24 }
25 }
26 // Update account status immediately in case there are not enough API
27 // requests remaining in order to do so later.
28 $status = dfrapi_api_get_status();
29 update_option( 'dfrapi_account', $status );
30 }
31 _e( 'Cached API data deleted successfully.', DFRAPI_DOMAIN );
32 die;
33 }
34
35