PageRenderTime 44ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/blog/wp-admin/admin-ajax.php

https://bitbucket.org/sergiohzlz/reportaprod
PHP | 71 lines | 37 code | 15 blank | 19 comment | 6 complexity | 8c655122919a1cb29c3012330303a79e MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * WordPress AJAX Process Execution.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. *
  8. * @link http://codex.wordpress.org/AJAX_in_Plugins
  9. */
  10. /**
  11. * Executing AJAX process.
  12. *
  13. * @since 2.1.0
  14. */
  15. define( 'DOING_AJAX', true );
  16. define( 'WP_ADMIN', true );
  17. // Require an action parameter
  18. if ( empty( $_REQUEST['action'] ) )
  19. die( '0' );
  20. /** Load WordPress Bootstrap */
  21. require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
  22. /** Load WordPress Administration APIs */
  23. require_once( ABSPATH . 'wp-admin/includes/admin.php' );
  24. /** Load Ajax Handlers for WordPress Core */
  25. require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );
  26. @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
  27. @header( 'X-Robots-Tag: noindex' );
  28. send_nosniff_header();
  29. do_action( 'admin_init' );
  30. $core_actions_get = array(
  31. 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
  32. 'autocomplete-user', 'dashboard-widgets', 'logged-in',
  33. );
  34. $core_actions_post = array(
  35. 'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
  36. 'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
  37. 'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
  38. 'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'autosave', 'closed-postboxes',
  39. 'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
  40. 'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
  41. 'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
  42. 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
  43. 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment',
  44. );
  45. // Register core Ajax calls.
  46. if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )
  47. add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );
  48. if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
  49. add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
  50. add_action( 'wp_ajax_nopriv_autosave', 'wp_ajax_nopriv_autosave', 1 );
  51. if ( is_user_logged_in() )
  52. do_action( 'wp_ajax_' . $_REQUEST['action'] ); // Authenticated actions
  53. else
  54. do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] ); // Non-admin actions
  55. // Default status
  56. die( '0' );