Created
March 24, 2025 14:22
-
-
Save ideadude/9e80ca6b6bf4c4264afd58ce5a7453e0 to your computer and use it in GitHub Desktop.
Increase memory and execution time for WP admins and crons.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Increase memory and execution time for WP admins and crons | |
* Add this code into a custom plugin or code snippet. | |
*/ | |
function my_init_memory() { | |
if( current_user_can( 'manage_options' ) ) { | |
ini_set( 'max_execution_time', 300 ); //300 seconds = 5 minutes | |
ini_set( 'memory_limit', '812M' ); | |
} elseif ( wp_doing_cron() ) { | |
ini_set( 'max_execution_time', 300 ); //300 seconds = 5 minutes | |
ini_set( 'memory_limit', '300M' ); | |
} | |
} | |
add_action( 'init', 'my_init_memory', 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment