Filters the memory limit allocated for WP-Cron event processing.
Parameters
$filtered_limit
int|string- Maximum memory limit to allocate for WP-Cron.
DefaultWP_MAX_MEMORY_LIMIT
or the original php.inimemory_limit
, whichever is higher.
Accepts an integer (bytes), or a shorthand string notation, such as'256M'
.
Source
$filtered_limit = apply_filters( 'cron_memory_limit', $filtered_limit );
Changelog
Version | Description |
---|---|
6.3.0 | Introduced. |
In this example, we’re assuming you are working within a WordPress environment and you want to adjust the memory limit for cron tasks. The
apply_filters
function allows you to apply a series of filters to a specific value, in this case, the memory limit. Thecustom_cron_memory_limit
function acts as a filter callback, adjusting the memory limit by adding 128M to it.When you call
apply_filters('cron_memory_limit', ini_get('memory_limit'))
WordPress will execute your custom function and pass the current memory limit value as an argument. Your function will then modify the limit and return the adjusted value, which will be used wherever theapply_filters
function is called. Finally, the adjusted memory limit is echoed out in the example.