fauzanjeg

prevent increase CPU usage by ajax

Oct 12th, 2021 (edited)
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. /* prevent increase CPU usage by ajax */
  2. if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
  3.     $by_pass = array(
  4.         'oembed-cache',
  5.         'image-editor',
  6.         'delete-comment',
  7.         'delete-tag',
  8.         'delete-link',
  9.         'delete-meta',
  10.         'delete-post',
  11.         'trash-post',
  12.         'untrash-post',
  13.         'delete-page',
  14.         'dim-comment',
  15.         'add-link-category',
  16.         'add-tag',
  17.         'get-tagcloud',
  18.         'get-comments',
  19.         'replyto-comment',
  20.         'edit-comment',
  21.         'add-menu-item',
  22.         'add-meta',
  23.         'add-user',
  24.         'closed-postboxes',
  25.         'hidden-columns',
  26.         'update-welcome-panel',
  27.         'menu-get-metabox',
  28.         'wp-link-ajax',
  29.         'menu-locations-save',
  30.         'menu-quick-search',
  31.         'meta-box-order',
  32.         'get-permalink',
  33.         'sample-permalink',
  34.         'inline-save',
  35.         'inline-save-tax',
  36.         'find_posts',
  37.         'widgets-order',
  38.         'save-widget',
  39.         'delete-inactive-widgets',
  40.         'set-post-thumbnail',
  41.         'date_format',
  42.         'time_format',
  43.         'wp-remove-post-lock',
  44.         'dismiss-wp-pointer',
  45.         'upload-attachment',
  46.         'get-attachment',
  47.         'query-attachments',
  48.         'save-attachment',
  49.         'save-attachment-compat',
  50.         'send-link-to-editor',
  51.         'send-attachment-to-editor',
  52.         'save-attachment-order',
  53.         'media-create-image-subsizes',
  54.         'heartbeat',
  55.         'get-revision-diffs',
  56.         'save-user-color-scheme',
  57.         'update-widget',
  58.         'query-themes',
  59.         'parse-embed',
  60.         'set-attachment-thumbnail',
  61.         'parse-media-shortcode',
  62.         'destroy-sessions',
  63.         'install-plugin',
  64.         'update-plugin',
  65.         'crop-image',
  66.         'generate-password',
  67.         'save-wporg-username',
  68.         'delete-plugin',
  69.         'search-plugins',
  70.         'search-install-plugins',
  71.         'activate-plugin',
  72.         'update-theme',
  73.         'delete-theme',
  74.         'install-theme',
  75.         'get-post-thumbnail-html',
  76.         'get-community-events',
  77.         'edit-theme-plugin-file',
  78.         'wp-privacy-export-personal-data',
  79.         'wp-privacy-erase-personal-data',
  80.         'health-check-site-status-result',
  81.         'health-check-dotorg-communication',
  82.         'health-check-is-in-debug-mode',
  83.         'health-check-background-updates',
  84.         'health-check-loopback-requests',
  85.         'health-check-get-sizes',
  86.         'toggle-auto-updates',
  87.         'send-password-reset',
  88.         /* Start custom action */
  89.         'vc_media_editor_add_image',
  90.     );
  91.     if ( isset( $_POST['action'] ) && in_array( $_POST['action'], $by_pass ) ) {
  92.         return;
  93.     }
  94.     wp_die( '0', 400 );
  95. }
Add Comment
Please, Sign In to add comment