PluginProbe
WPIDE – File Manager & Code Editor / 3.1
WPIDE – File Manager & Code Editor v3.1
3.5.8 3.5.7 2.0.14 2.0.15 2.0.16 2.0.2 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1 2.2 2.3 2.3.1 2.3.2 2.4.0 2.5 2.6 3.0 3.1 3.2 3.3 3.4 All 54 releases
wpide / ajax.php

ajax.php in WPIDE – File Manager & Code Editor 3.1, at ajax.php

77 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * WPIDE CUSTOM AJAX HANDLER
4 * admin-ajax.php is usually slower depending on the number of registered ajax functions
5 * This is a custom ajax handler that will mimic the actual admin-ajax
6 */
7
8 define('DOING_AJAX', true);
9 if ( ! defined( 'WP_ADMIN' ) ) {
10 define( 'WP_ADMIN', true );
11 }
12
13 // Fix to avoid notice in wp-includes/vars.php on line 32
14 $_SERVER['PHP_SELF'] = '/wp-admin/';
15
16 /** Load WordPress Bootstrap */
17 require_once realpath(__DIR__.'/../../../') . '/wp-load.php';
18
19 /** Allow for cross-domain requests (from the front end). */
20 send_origin_headers();
21
22 header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
23 header( 'X-Robots-Tag: noindex' );
24
25 // Require a valid action parameter.
26 if ( empty( $_REQUEST['action'] ) || ! is_scalar( $_REQUEST['action'] ) ) {
27 wp_die( '0', 400 );
28 }
29
30 /** Load WordPress Administration APIs */
31 require_once ABSPATH . 'wp-admin/includes/admin.php';
32
33 send_nosniff_header();
34 nocache_headers();
35
36 /** This action is documented in wp-admin/admin.php */
37 do_action( 'admin_init' );
38
39 $action = sanitize_text_field($_REQUEST['action']);
40
41 if ( is_user_logged_in() ) {
42
43 // If no action is registered, return a Bad Request response.
44 if ( ! has_action( "wpide_ajax_{$action}" ) ) {
45 wp_die( '0', 400 );
46 }
47
48 /**
49 * Fires authenticated Ajax actions for logged-in users.
50 *
51 * The dynamic portion of the hook name, `$action`, refers
52 * to the name of the Ajax action callback being fired.
53 *
54 * @since 2.1.0
55 */
56 do_action( "wpide_ajax_{$action}" );
57
58 } else {
59
60 // If no action is registered, return a Bad Request response.
61 if ( ! has_action( "wpide_ajax_nopriv_{$action}" ) ) {
62 wp_die( '0', 400 );
63 }
64
65 /**
66 * Fires non-authenticated Ajax actions for logged-out users.
67 *
68 * The dynamic portion of the hook name, `$action`, refers
69 * to the name of the Ajax action callback being fired.
70 *
71 * @since 2.8.0
72 */
73 do_action( "wpide_ajax_nopriv_{$action}" );
74 }
75
76 // Default status.
77 wp_die( '0' );