verygoodplugins

Untitled

Nov 16th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. function set_max_mem( $memory ) {
  2.  
  3.     if ( function_exists( 'ini_get' ) ) {
  4.         $memory_limit = ini_get( 'memory_limit' );
  5.     } else {
  6.         // Sensible default.
  7.         $memory_limit = '128M';
  8.     }
  9.  
  10.     if ( ! $memory_limit || - 1 === $memory_limit ) {
  11.         // Unlimited, set to 32GB.
  12.         $memory_limit = '128M';
  13.     }
  14.  
  15.     $memory_limit = intval( $memory_limit ) * 1024 * 1024;
  16.  
  17.     $memory_limit = $memory_limit * 0.5;
  18.     $current_memory = memory_get_usage( true );
  19.  
  20.     if ( $current_memory >= $memory_limit ) {
  21.         $return = true;
  22.     }
  23.  
  24.     return false;
  25.  
  26. }
  27.  
  28. add_filter( 'wpf_batch_memory_exceeded', 'set_max_mem' );
  29.  
  30. function set_time( $time ) {
  31.  
  32.     return 10;
  33.  
  34. }
  35.  
  36. add_filter( 'wpf_batch_default_time_limit', 'set_time' );
Add Comment
Please, Sign In to add comment