<?php if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } if ( ! class_exists( 'acf_loop' ) ) : #[AllowDynamicProperties] class acf_loop { /** * This function will setup the class functionality * * @type function * @date 5/03/2014 * @since 5.0.0 * * @param n/a * @return n/a */ function __construct() { // vars $this->loops = array(); } /** * This function will return true if no loops exist * * @type function * @date 3/03/2016 * @since 5.3.2 * * @param n/a * @return (boolean) */ function is_empty() { return empty( $this->loops ); } /** * This function will return true if a loop exists for the given array index * * @type function * @date 3/03/2016 * @since 5.3.2 * * @param $i (int) * @return (boolean) */ function is_loop( $i = 0 ) { return isset( $this->loops[ $i ] ); } /** * This function will return a valid array index for the given $i * * @type function * @date 3/03/2016 * @since 5.3.2 * * @param $i (mixed) * @return (int) */ function get_i( $i = 0 ) { // 'active' if ( $i === 'active' ) { $i = -1; } // 'previous' if ( $i === 'previous' ) { $i = -2; } // allow negative to look at end of loops if ( $i < 0 ) { $i = count( $this->loops ) + $i; } // return return $i; } /** * This function will add a new loop * * @type function * @date 3/03/2016 * @since 5.3.2 * * @param $loop (array) * @return n/a */ function add_loop( $loop = array() ) { // defaults $loop = wp_parse_args( $loop, array( 'selector' => '', 'name' => '', 'value' => false, 'field' => false, 'i' => -1, 'post_id' => 0, 'key' => '', ) ); // ensure array $loop['value'] = acf_get_array( $loop['value'] ); // Re-index values if this loop starts from index 0. // This allows ajax previews to work ($_POST data contains random unique array keys) if ( $loop['i'] == -1 ) { $loop['value'] = array_values( $loop['value'] ); } // append $this->loops[] = $loop; // return return $loop; } /** * This function will update a loop's setting * * @type function * @date 3/03/2016 * @since 5.3.2 * * @param $i (mixed) * @param $key (string) the loop setting name * @param $value (mixed) the loop setting value * @return (boolean) true on success */ function update_loop( $i = 'active', $key = null, $value = null ) { // i $i = $this->get_i( $i ); // bail early if no set if ( ! $this->is_loop( $i ) ) { return false; } // set $this->loops[ $i ][ $key ] = $value; // return return true; } /** * This function will return a loop, or loop's setting for a given index & key * * @type function * @date 3/03/2016 * @since 5.3.2 * * @param $i (mixed) * @param $key (string) the loop setting name * @return (mixed) false on failure */ function get_loop( $i = 'active', $key = null ) { // i $i = $this->get_i( $i ); // bail early if no set if ( ! $this->is_loop( $i ) ) { return false; } // check for key if ( $key !== null ) { return $this->loops[ $i ][ $key ]; } // return return $this->loops[ $i ]; } /** * This function will remove a loop * * @type function * @date 3/03/2016 * @since 5.3.2 * * @param $i (mixed) * @return (boolean) true on success */ function remove_loop( $i = 'active' ) { // i $i = $this->get_i( $i ); // bail early if no set if ( ! $this->is_loop( $i ) ) { return false; } // remove unset( $this->loops[ $i ] ); // reset keys $this->loops = array_values( $this->loops ); // PHP 7.2 no longer resets array keys for empty value if ( $this->is_empty() ) { $this->loops = array(); } } } // initialize acf()->loop = new acf_loop(); endif; // class_exists check /** * alias of acf()->loop->add_loop() * * @type function * @date 6/10/13 * @since 5.0.0 * * @param n/a * @return n/a */ function acf_add_loop( $loop = array() ) { return acf()->loop->add_loop( $loop ); } /** * alias of acf()->loop->update_loop() * * @type function * @date 6/10/13 * @since 5.0.0 * * @param n/a * @return n/a */ function acf_update_loop( $i = 'active', $key = null, $value = null ) { return acf()->loop->update_loop( $i, $key, $value ); } /** * alias of acf()->loop->get_loop() * * @type function * @date 6/10/13 * @since 5.0.0 * * @param n/a * @return n/a */ function acf_get_loop( $i = 'active', $key = null ) { return acf()->loop->get_loop( $i, $key ); } /** * alias of acf()->loop->remove_loop() * * @type function * @date 6/10/13 * @since 5.0.0 * * @param n/a * @return n/a */ function acf_remove_loop( $i = 'active' ) { return acf()->loop->remove_loop( $i ); }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Blocks | Folder | 0755 |
|
|
admin | Folder | 0755 |
|
|
ajax | Folder | 0755 |
|
|
api | Folder | 0755 |
|
|
fields | Folder | 0755 |
|
|
forms | Folder | 0755 |
|
|
legacy | Folder | 0755 |
|
|
locations | Folder | 0755 |
|
|
post-types | Folder | 0755 |
|
|
rest-api | Folder | 0755 |
|
|
walkers | Folder | 0755 |
|
|
acf-bidirectional-functions.php | File | 9.19 KB | 0644 |
|
acf-field-functions.php | File | 38.86 KB | 0644 |
|
acf-field-group-functions.php | File | 13.52 KB | 0644 |
|
acf-form-functions.php | File | 3.78 KB | 0644 |
|
acf-helper-functions.php | File | 16.14 KB | 0644 |
|
acf-hook-functions.php | File | 5.37 KB | 0644 |
|
acf-input-functions.php | File | 11.32 KB | 0644 |
|
acf-internal-post-type-functions.php | File | 18.2 KB | 0644 |
|
acf-meta-functions.php | File | 10.15 KB | 0644 |
|
acf-post-functions.php | File | 889 B | 0644 |
|
acf-post-type-functions.php | File | 7.25 KB | 0644 |
|
acf-taxonomy-functions.php | File | 6.3 KB | 0644 |
|
acf-user-functions.php | File | 2.32 KB | 0644 |
|
acf-utility-functions.php | File | 3.07 KB | 0644 |
|
acf-value-functions.php | File | 10.3 KB | 0644 |
|
acf-wp-functions.php | File | 6.53 KB | 0644 |
|
assets.php | File | 15.68 KB | 0644 |
|
class-acf-data.php | File | 6.68 KB | 0644 |
|
class-acf-internal-post-type.php | File | 22.65 KB | 0644 |
|
class-acf-site-health.php | File | 20.13 KB | 0644 |
|
compatibility.php | File | 12.32 KB | 0644 |
|
deprecated.php | File | 3.97 KB | 0644 |
|
fields.php | File | 12.29 KB | 0644 |
|
index.php | File | 43 B | 0644 |
|
l10n.php | File | 3.7 KB | 0644 |
|
local-fields.php | File | 15.96 KB | 0644 |
|
local-json.php | File | 14.3 KB | 0644 |
|
local-meta.php | File | 6.09 KB | 0644 |
|
locations.php | File | 8.19 KB | 0644 |
|
loop.php | File | 5.01 KB | 0644 |
|
media.php | File | 7.09 KB | 0644 |
|
rest-api.php | File | 383 B | 0644 |
|
revisions.php | File | 12.33 KB | 0644 |
|
third-party.php | File | 4.25 KB | 0644 |
|
upgrades.php | File | 11.13 KB | 0644 |
|
validation.php | File | 7.4 KB | 0644 |
|
wpml.php | File | 8 KB | 0644 |
|