| Server IP : 172.67.159.97 / Your IP : 216.73.217.154 Web Server : nginx/1.24.0 System : Linux wordpress-sites 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/rebeccaone.com/wp-content/plugins/cornerstone/includes/loopers/ |
Upload File : |
<?php
/**
* Arbirtary Range Looper
*/
add_action('after_setup_theme', function() {
cs_looper_provider_register('range', [
'label' => __('Range', 'cornerstone'),
'values' => [
'min' => 1,
'max' => 10,
'steps' => 1,
],
'controls' => [
// Min
[
'key' => 'min',
'type' => 'text',
'label' => __('Min', 'cornerstone'),
'description' => __('The start of the range. Can be a letter like a or A as well', 'cornerstone'),
],
// Max
[
'key' => 'max',
'type' => 'text',
'label' => __('Max', 'cornerstone'),
'description' => __('The end of the range. Can be a letter like z or Z as well', 'cornerstone'),
],
// Steps
[
'key' => 'steps',
'type' => 'text',
'label' => __('Steps', 'cornerstone'),
'description' => __('The amount to increment the number by when going from min to max. If you are using letters you will not be able to use decimals', 'cornerstone'),
],
],
// Uses range() from min and max
'filter' => function($result, $args = []) {
$min = cs_get_array_value($args, 'min', 1);
$max = cs_get_array_value($args, 'max', 10);
$steps = (float)cs_get_array_value($args, 'steps', 1);
// Character based ranges have to use int
if (!is_numeric($min) || !is_numeric($max)) {
$steps = (int) $steps;
}
// Cannot use 0 or an infinite value
if (empty($steps) || $steps <= 0) {
return [];
}
// Return the range
$items = range($min, $max, $steps);
return $items;
},
]);
});