ajax.php
7 years ago
columns.php
4 years ago
counter.php
4 years ago
crawler-detect.php
6 years ago
cron.php
6 years ago
dashboard.php
4 years ago
frontend.php
6 years ago
functions.php
4 years ago
query.php
6 years ago
settings.php
4 years ago
update.php
6 years ago
widgets.php
4 years ago
ajax.php
90 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 | // if PVC_SHORTINIT_INC is defined in wp-config.php load theme/pvc/includes.php file |
| 64 | // this allows to perform custom actions, for example hook into pvc_after_count_visit |
| 65 | if ( defined( 'PVC_SHORTINIT_INC' ) && PVC_SHORTINIT_INC ) { |
| 66 | require_once( ABSPATH . WPINC . '/plugin.php' ); |
| 67 | require_once( ABSPATH . WPINC . '/theme.php' ); |
| 68 | |
| 69 | // get the current theme path |
| 70 | $theme_path = get_theme_file_path(); |
| 71 | // load custom pvc includes file |
| 72 | $pvc_file_path = $theme_path . DIRECTORY_SEPARATOR . 'pvc' . DIRECTORY_SEPARATOR . 'includes.php'; |
| 73 | |
| 74 | if ( is_file( $pvc_file_path ) ) { |
| 75 | require_once( $pvc_file_path ); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | $action = esc_attr( trim( $_POST['action'] ) ); |
| 80 | |
| 81 | // a bit of security |
| 82 | $allowed_actions = array( |
| 83 | 'pvc-check-post' |
| 84 | ); |
| 85 | |
| 86 | if ( in_array( $action, $allowed_actions ) ) { |
| 87 | do_action( 'pvc_ajax_' . $action ); |
| 88 | } else { |
| 89 | die( '-1' ); |
| 90 | } |