ajax.php
8 years ago
columns.php
8 years ago
counter.php
8 years ago
crawler-detect.php
8 years ago
cron.php
8 years ago
dashboard.php
8 years ago
frontend.php
8 years ago
functions.php
8 years ago
query.php
8 years ago
settings.php
8 years ago
update.php
8 years ago
widgets.php
8 years ago
ajax.php
74 lines
| 1 | <?php |
| 2 | // mimic the actuall admin-ajax |
| 3 | define( 'DOING_AJAX', true ); |
| 4 | |
| 5 | if ( ! isset( $_POST['action'] ) ) |
| 6 | die( '-1' ); |
| 7 | |
| 8 | // hide errors if any |
| 9 | ini_set( 'html_errors', 0 ); |
| 10 | |
| 11 | // we need only basics |
| 12 | define( 'SHORTINIT', true ); |
| 13 | |
| 14 | // get wp-load.php location |
| 15 | $path = explode( 'wp-content', __FILE__ ); |
| 16 | |
| 17 | if ( is_file( reset( $path ) . 'wp-load.php' ) ) { |
| 18 | require_once( reset( $path ) . 'wp-load.php' ); |
| 19 | } else { |
| 20 | die( '-1' ); |
| 21 | } |
| 22 | |
| 23 | // typical headers |
| 24 | header( 'Content-Type: text/html' ); |
| 25 | send_nosniff_header(); |
| 26 | |
| 27 | // disable caching |
| 28 | header( 'Cache-Control: no-cache' ); |
| 29 | header( 'Pragma: no-cache' ); |
| 30 | |
| 31 | // include only the files and function we need |
| 32 | require_once( ABSPATH . 'wp-config.php' ); |
| 33 | |
| 34 | require_once( ABSPATH . WPINC . '/post.php' ); |
| 35 | require_once( ABSPATH . WPINC . '/formatting.php' ); |
| 36 | require_once( ABSPATH . WPINC . '/capabilities.php' ); |
| 37 | require_once( ABSPATH . WPINC . '/query.php' ); |
| 38 | require_once( ABSPATH . WPINC . '/taxonomy.php' ); |
| 39 | require_once( ABSPATH . WPINC . '/meta.php' ); |
| 40 | require_once( ABSPATH . WPINC . '/functions.php' ); |
| 41 | require_once( ABSPATH . WPINC . '/link-template.php' ); |
| 42 | require_once( ABSPATH . WPINC . '/class-wp-post.php' ); |
| 43 | require_once( ABSPATH . WPINC . '/kses.php' ); |
| 44 | require_once( ABSPATH . WPINC . '/rest-api.php' ); |
| 45 | // required for wp user |
| 46 | require_once( ABSPATH . WPINC . '/user.php' ); |
| 47 | require_once( ABSPATH . WPINC . '/vars.php' ); |
| 48 | require_once( ABSPATH . WPINC . '/class-wp-session-tokens.php' ); |
| 49 | require_once( ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php' ); |
| 50 | require_once( ABSPATH . WPINC . '/class-wp-roles.php' ); |
| 51 | require_once( ABSPATH . WPINC . '/class-wp-role.php' ); |
| 52 | require_once( ABSPATH . WPINC . '/class-wp-user.php' ); |
| 53 | require_once( ABSPATH . WPINC . '/pluggable.php' ); |
| 54 | |
| 55 | // get constants |
| 56 | wp_plugin_directory_constants(); |
| 57 | wp_cookie_constants(); |
| 58 | wp_ssl_constants(); |
| 59 | |
| 60 | // include Post Views Counter core |
| 61 | require_once( WP_PLUGIN_DIR . '/post-views-counter/post-views-counter.php' ); |
| 62 | |
| 63 | $action = esc_attr( trim( $_POST['action'] ) ); |
| 64 | |
| 65 | // a bit of security |
| 66 | $allowed_actions = array( |
| 67 | 'pvc-check-post' |
| 68 | ); |
| 69 | |
| 70 | if ( in_array( $action, $allowed_actions ) ) { |
| 71 | do_action( 'pvc_ajax_' . $action ); |
| 72 | } else { |
| 73 | die( '-1' ); |
| 74 | } |