File "loop.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/advanced-custom-fields/includes/loop.php
File
size: 2.49 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
if (!defined('ABSPATH')) {
exit;
}
if (!class_exists('acf_loop')) {
class acf_loop
{
function __construct()
{
$this->loops = array();
}
function is_empty()
{
return empty($this->loops);
}
function is_loop($i = 0)
{
return isset($this->loops[$i]);
}
function get_i($i = 0)
{
if ($i === 'active') {
$i = -1;
}
if ($i === 'previous') {
$i = -2;
}
if ($i < 0) {
$i = count($this->loops) + $i;
}
return $i;
}
function add_loop($loop = array())
{
$loop = wp_parse_args($loop, array('selector' => '', 'name' => '', 'value' => false, 'field' => false, 'i' => -1, 'post_id' => 0, 'key' => ''));
$loop['value'] = acf_get_array($loop['value']);
if ($loop['i'] == -1) {
$loop['value'] = array_values($loop['value']);
}
$this->loops[] = $loop;
return $loop;
}
function update_loop($i = 'active', $key = null, $value = null)
{
$i = $this->get_i($i);
if (!$this->is_loop($i)) {
return false;
}
$this->loops[$i][$key] = $value;
return true;
}
function get_loop($i = 'active', $key = null)
{
$i = $this->get_i($i);
if (!$this->is_loop($i)) {
return false;
}
if ($key !== null) {
return $this->loops[$i][$key];
}
return $this->loops[$i];
}
function remove_loop($i = 'active')
{
$i = $this->get_i($i);
if (!$this->is_loop($i)) {
return false;
}
unset($this->loops[$i]);
$this->loops = array_values($this->loops);
if ($this->is_empty()) {
$this->loops = array();
}
}
}
acf()->loop = new acf_loop();
}
function acf_add_loop($loop = array())
{
return acf()->loop->add_loop($loop);
}
function acf_update_loop($i = 'active', $key = null, $value = null)
{
return acf()->loop->update_loop($i, $key, $value);
}
function acf_get_loop($i = 'active', $key = null)
{
return acf()->loop->get_loop($i, $key);
}
function acf_remove_loop($i = 'active')
{
return acf()->loop->remove_loop($i);
}