| @ -1,2 +1 @@ | |||||
| node_modules | node_modules | ||||
| vendor | |||||
| @ -0,0 +1,7 @@ | |||||
| <?php | |||||
| // autoload.php @generated by Composer | |||||
| require_once __DIR__ . '/composer/autoload_real.php'; | |||||
| return ComposerAutoloaderInit9f7096e25fc06c4ca0a938c1141f1f3b::getLoader(); | |||||
| @ -0,0 +1,445 @@ | |||||
| <?php | |||||
| /* | |||||
| * This file is part of Composer. | |||||
| * | |||||
| * (c) Nils Adermann <naderman@naderman.de> | |||||
| * Jordi Boggiano <j.boggiano@seld.be> | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| */ | |||||
| namespace Composer\Autoload; | |||||
| /** | |||||
| * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. | |||||
| * | |||||
| * $loader = new \Composer\Autoload\ClassLoader(); | |||||
| * | |||||
| * // register classes with namespaces | |||||
| * $loader->add('Symfony\Component', __DIR__.'/component'); | |||||
| * $loader->add('Symfony', __DIR__.'/framework'); | |||||
| * | |||||
| * // activate the autoloader | |||||
| * $loader->register(); | |||||
| * | |||||
| * // to enable searching the include path (eg. for PEAR packages) | |||||
| * $loader->setUseIncludePath(true); | |||||
| * | |||||
| * In this example, if you try to use a class in the Symfony\Component | |||||
| * namespace or one of its children (Symfony\Component\Console for instance), | |||||
| * the autoloader will first look for the class under the component/ | |||||
| * directory, and it will then fallback to the framework/ directory if not | |||||
| * found before giving up. | |||||
| * | |||||
| * This class is loosely based on the Symfony UniversalClassLoader. | |||||
| * | |||||
| * @author Fabien Potencier <fabien@symfony.com> | |||||
| * @author Jordi Boggiano <j.boggiano@seld.be> | |||||
| * @see http://www.php-fig.org/psr/psr-0/ | |||||
| * @see http://www.php-fig.org/psr/psr-4/ | |||||
| */ | |||||
| class ClassLoader | |||||
| { | |||||
| // PSR-4 | |||||
| private $prefixLengthsPsr4 = array(); | |||||
| private $prefixDirsPsr4 = array(); | |||||
| private $fallbackDirsPsr4 = array(); | |||||
| // PSR-0 | |||||
| private $prefixesPsr0 = array(); | |||||
| private $fallbackDirsPsr0 = array(); | |||||
| private $useIncludePath = false; | |||||
| private $classMap = array(); | |||||
| private $classMapAuthoritative = false; | |||||
| private $missingClasses = array(); | |||||
| private $apcuPrefix; | |||||
| public function getPrefixes() | |||||
| { | |||||
| if (!empty($this->prefixesPsr0)) { | |||||
| return call_user_func_array('array_merge', $this->prefixesPsr0); | |||||
| } | |||||
| return array(); | |||||
| } | |||||
| public function getPrefixesPsr4() | |||||
| { | |||||
| return $this->prefixDirsPsr4; | |||||
| } | |||||
| public function getFallbackDirs() | |||||
| { | |||||
| return $this->fallbackDirsPsr0; | |||||
| } | |||||
| public function getFallbackDirsPsr4() | |||||
| { | |||||
| return $this->fallbackDirsPsr4; | |||||
| } | |||||
| public function getClassMap() | |||||
| { | |||||
| return $this->classMap; | |||||
| } | |||||
| /** | |||||
| * @param array $classMap Class to filename map | |||||
| */ | |||||
| public function addClassMap(array $classMap) | |||||
| { | |||||
| if ($this->classMap) { | |||||
| $this->classMap = array_merge($this->classMap, $classMap); | |||||
| } else { | |||||
| $this->classMap = $classMap; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Registers a set of PSR-0 directories for a given prefix, either | |||||
| * appending or prepending to the ones previously set for this prefix. | |||||
| * | |||||
| * @param string $prefix The prefix | |||||
| * @param array|string $paths The PSR-0 root directories | |||||
| * @param bool $prepend Whether to prepend the directories | |||||
| */ | |||||
| public function add($prefix, $paths, $prepend = false) | |||||
| { | |||||
| if (!$prefix) { | |||||
| if ($prepend) { | |||||
| $this->fallbackDirsPsr0 = array_merge( | |||||
| (array) $paths, | |||||
| $this->fallbackDirsPsr0 | |||||
| ); | |||||
| } else { | |||||
| $this->fallbackDirsPsr0 = array_merge( | |||||
| $this->fallbackDirsPsr0, | |||||
| (array) $paths | |||||
| ); | |||||
| } | |||||
| return; | |||||
| } | |||||
| $first = $prefix[0]; | |||||
| if (!isset($this->prefixesPsr0[$first][$prefix])) { | |||||
| $this->prefixesPsr0[$first][$prefix] = (array) $paths; | |||||
| return; | |||||
| } | |||||
| if ($prepend) { | |||||
| $this->prefixesPsr0[$first][$prefix] = array_merge( | |||||
| (array) $paths, | |||||
| $this->prefixesPsr0[$first][$prefix] | |||||
| ); | |||||
| } else { | |||||
| $this->prefixesPsr0[$first][$prefix] = array_merge( | |||||
| $this->prefixesPsr0[$first][$prefix], | |||||
| (array) $paths | |||||
| ); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Registers a set of PSR-4 directories for a given namespace, either | |||||
| * appending or prepending to the ones previously set for this namespace. | |||||
| * | |||||
| * @param string $prefix The prefix/namespace, with trailing '\\' | |||||
| * @param array|string $paths The PSR-4 base directories | |||||
| * @param bool $prepend Whether to prepend the directories | |||||
| * | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function addPsr4($prefix, $paths, $prepend = false) | |||||
| { | |||||
| if (!$prefix) { | |||||
| // Register directories for the root namespace. | |||||
| if ($prepend) { | |||||
| $this->fallbackDirsPsr4 = array_merge( | |||||
| (array) $paths, | |||||
| $this->fallbackDirsPsr4 | |||||
| ); | |||||
| } else { | |||||
| $this->fallbackDirsPsr4 = array_merge( | |||||
| $this->fallbackDirsPsr4, | |||||
| (array) $paths | |||||
| ); | |||||
| } | |||||
| } elseif (!isset($this->prefixDirsPsr4[$prefix])) { | |||||
| // Register directories for a new namespace. | |||||
| $length = strlen($prefix); | |||||
| if ('\\' !== $prefix[$length - 1]) { | |||||
| throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | |||||
| } | |||||
| $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | |||||
| $this->prefixDirsPsr4[$prefix] = (array) $paths; | |||||
| } elseif ($prepend) { | |||||
| // Prepend directories for an already registered namespace. | |||||
| $this->prefixDirsPsr4[$prefix] = array_merge( | |||||
| (array) $paths, | |||||
| $this->prefixDirsPsr4[$prefix] | |||||
| ); | |||||
| } else { | |||||
| // Append directories for an already registered namespace. | |||||
| $this->prefixDirsPsr4[$prefix] = array_merge( | |||||
| $this->prefixDirsPsr4[$prefix], | |||||
| (array) $paths | |||||
| ); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Registers a set of PSR-0 directories for a given prefix, | |||||
| * replacing any others previously set for this prefix. | |||||
| * | |||||
| * @param string $prefix The prefix | |||||
| * @param array|string $paths The PSR-0 base directories | |||||
| */ | |||||
| public function set($prefix, $paths) | |||||
| { | |||||
| if (!$prefix) { | |||||
| $this->fallbackDirsPsr0 = (array) $paths; | |||||
| } else { | |||||
| $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Registers a set of PSR-4 directories for a given namespace, | |||||
| * replacing any others previously set for this namespace. | |||||
| * | |||||
| * @param string $prefix The prefix/namespace, with trailing '\\' | |||||
| * @param array|string $paths The PSR-4 base directories | |||||
| * | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function setPsr4($prefix, $paths) | |||||
| { | |||||
| if (!$prefix) { | |||||
| $this->fallbackDirsPsr4 = (array) $paths; | |||||
| } else { | |||||
| $length = strlen($prefix); | |||||
| if ('\\' !== $prefix[$length - 1]) { | |||||
| throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | |||||
| } | |||||
| $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | |||||
| $this->prefixDirsPsr4[$prefix] = (array) $paths; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Turns on searching the include path for class files. | |||||
| * | |||||
| * @param bool $useIncludePath | |||||
| */ | |||||
| public function setUseIncludePath($useIncludePath) | |||||
| { | |||||
| $this->useIncludePath = $useIncludePath; | |||||
| } | |||||
| /** | |||||
| * Can be used to check if the autoloader uses the include path to check | |||||
| * for classes. | |||||
| * | |||||
| * @return bool | |||||
| */ | |||||
| public function getUseIncludePath() | |||||
| { | |||||
| return $this->useIncludePath; | |||||
| } | |||||
| /** | |||||
| * Turns off searching the prefix and fallback directories for classes | |||||
| * that have not been registered with the class map. | |||||
| * | |||||
| * @param bool $classMapAuthoritative | |||||
| */ | |||||
| public function setClassMapAuthoritative($classMapAuthoritative) | |||||
| { | |||||
| $this->classMapAuthoritative = $classMapAuthoritative; | |||||
| } | |||||
| /** | |||||
| * Should class lookup fail if not found in the current class map? | |||||
| * | |||||
| * @return bool | |||||
| */ | |||||
| public function isClassMapAuthoritative() | |||||
| { | |||||
| return $this->classMapAuthoritative; | |||||
| } | |||||
| /** | |||||
| * APCu prefix to use to cache found/not-found classes, if the extension is enabled. | |||||
| * | |||||
| * @param string|null $apcuPrefix | |||||
| */ | |||||
| public function setApcuPrefix($apcuPrefix) | |||||
| { | |||||
| $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; | |||||
| } | |||||
| /** | |||||
| * The APCu prefix in use, or null if APCu caching is not enabled. | |||||
| * | |||||
| * @return string|null | |||||
| */ | |||||
| public function getApcuPrefix() | |||||
| { | |||||
| return $this->apcuPrefix; | |||||
| } | |||||
| /** | |||||
| * Registers this instance as an autoloader. | |||||
| * | |||||
| * @param bool $prepend Whether to prepend the autoloader or not | |||||
| */ | |||||
| public function register($prepend = false) | |||||
| { | |||||
| spl_autoload_register(array($this, 'loadClass'), true, $prepend); | |||||
| } | |||||
| /** | |||||
| * Unregisters this instance as an autoloader. | |||||
| */ | |||||
| public function unregister() | |||||
| { | |||||
| spl_autoload_unregister(array($this, 'loadClass')); | |||||
| } | |||||
| /** | |||||
| * Loads the given class or interface. | |||||
| * | |||||
| * @param string $class The name of the class | |||||
| * @return bool|null True if loaded, null otherwise | |||||
| */ | |||||
| public function loadClass($class) | |||||
| { | |||||
| if ($file = $this->findFile($class)) { | |||||
| includeFile($file); | |||||
| return true; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Finds the path to the file where the class is defined. | |||||
| * | |||||
| * @param string $class The name of the class | |||||
| * | |||||
| * @return string|false The path if found, false otherwise | |||||
| */ | |||||
| public function findFile($class) | |||||
| { | |||||
| // class map lookup | |||||
| if (isset($this->classMap[$class])) { | |||||
| return $this->classMap[$class]; | |||||
| } | |||||
| if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { | |||||
| return false; | |||||
| } | |||||
| if (null !== $this->apcuPrefix) { | |||||
| $file = apcu_fetch($this->apcuPrefix.$class, $hit); | |||||
| if ($hit) { | |||||
| return $file; | |||||
| } | |||||
| } | |||||
| $file = $this->findFileWithExtension($class, '.php'); | |||||
| // Search for Hack files if we are running on HHVM | |||||
| if (false === $file && defined('HHVM_VERSION')) { | |||||
| $file = $this->findFileWithExtension($class, '.hh'); | |||||
| } | |||||
| if (null !== $this->apcuPrefix) { | |||||
| apcu_add($this->apcuPrefix.$class, $file); | |||||
| } | |||||
| if (false === $file) { | |||||
| // Remember that this class does not exist. | |||||
| $this->missingClasses[$class] = true; | |||||
| } | |||||
| return $file; | |||||
| } | |||||
| private function findFileWithExtension($class, $ext) | |||||
| { | |||||
| // PSR-4 lookup | |||||
| $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; | |||||
| $first = $class[0]; | |||||
| if (isset($this->prefixLengthsPsr4[$first])) { | |||||
| $subPath = $class; | |||||
| while (false !== $lastPos = strrpos($subPath, '\\')) { | |||||
| $subPath = substr($subPath, 0, $lastPos); | |||||
| $search = $subPath . '\\'; | |||||
| if (isset($this->prefixDirsPsr4[$search])) { | |||||
| $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); | |||||
| foreach ($this->prefixDirsPsr4[$search] as $dir) { | |||||
| if (file_exists($file = $dir . $pathEnd)) { | |||||
| return $file; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| // PSR-4 fallback dirs | |||||
| foreach ($this->fallbackDirsPsr4 as $dir) { | |||||
| if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { | |||||
| return $file; | |||||
| } | |||||
| } | |||||
| // PSR-0 lookup | |||||
| if (false !== $pos = strrpos($class, '\\')) { | |||||
| // namespaced class name | |||||
| $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) | |||||
| . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); | |||||
| } else { | |||||
| // PEAR-like class name | |||||
| $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; | |||||
| } | |||||
| if (isset($this->prefixesPsr0[$first])) { | |||||
| foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { | |||||
| if (0 === strpos($class, $prefix)) { | |||||
| foreach ($dirs as $dir) { | |||||
| if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |||||
| return $file; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| // PSR-0 fallback dirs | |||||
| foreach ($this->fallbackDirsPsr0 as $dir) { | |||||
| if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |||||
| return $file; | |||||
| } | |||||
| } | |||||
| // PSR-0 include paths. | |||||
| if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { | |||||
| return $file; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * Scope isolated include. | |||||
| * | |||||
| * Prevents access to $this/self from included files. | |||||
| */ | |||||
| function includeFile($file) | |||||
| { | |||||
| include $file; | |||||
| } | |||||
| @ -0,0 +1,21 @@ | |||||
| Copyright (c) Nils Adermann, Jordi Boggiano | |||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
| of this software and associated documentation files (the "Software"), to deal | |||||
| in the Software without restriction, including without limitation the rights | |||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||||
| copies of the Software, and to permit persons to whom the Software is furnished | |||||
| to do so, subject to the following conditions: | |||||
| The above copyright notice and this permission notice shall be included in all | |||||
| copies or substantial portions of the Software. | |||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||||
| THE SOFTWARE. | |||||
| @ -0,0 +1,9 @@ | |||||
| <?php | |||||
| // autoload_classmap.php @generated by Composer | |||||
| $vendorDir = dirname(dirname(__FILE__)); | |||||
| $baseDir = dirname($vendorDir); | |||||
| return array( | |||||
| ); | |||||
| @ -0,0 +1,10 @@ | |||||
| <?php | |||||
| // autoload_files.php @generated by Composer | |||||
| $vendorDir = dirname(dirname(__FILE__)); | |||||
| $baseDir = dirname($vendorDir); | |||||
| return array( | |||||
| '413614dbc06bade22a685c0ebe14027c' => $vendorDir . '/wordplate/acf/src/helpers.php', | |||||
| ); | |||||
| @ -0,0 +1,9 @@ | |||||
| <?php | |||||
| // autoload_namespaces.php @generated by Composer | |||||
| $vendorDir = dirname(dirname(__FILE__)); | |||||
| $baseDir = dirname($vendorDir); | |||||
| return array( | |||||
| ); | |||||
| @ -0,0 +1,10 @@ | |||||
| <?php | |||||
| // autoload_psr4.php @generated by Composer | |||||
| $vendorDir = dirname(dirname(__FILE__)); | |||||
| $baseDir = dirname($vendorDir); | |||||
| return array( | |||||
| 'WordPlate\\Acf\\' => array($vendorDir . '/wordplate/acf/src'), | |||||
| ); | |||||
| @ -0,0 +1,73 @@ | |||||
| <?php | |||||
| // autoload_real.php @generated by Composer | |||||
| class ComposerAutoloaderInit9f7096e25fc06c4ca0a938c1141f1f3b | |||||
| { | |||||
| private static $loader; | |||||
| public static function loadClassLoader($class) | |||||
| { | |||||
| if ('Composer\Autoload\ClassLoader' === $class) { | |||||
| require __DIR__ . '/ClassLoader.php'; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * @return \Composer\Autoload\ClassLoader | |||||
| */ | |||||
| public static function getLoader() | |||||
| { | |||||
| if (null !== self::$loader) { | |||||
| return self::$loader; | |||||
| } | |||||
| spl_autoload_register(array('ComposerAutoloaderInit9f7096e25fc06c4ca0a938c1141f1f3b', 'loadClassLoader'), true, true); | |||||
| self::$loader = $loader = new \Composer\Autoload\ClassLoader(); | |||||
| spl_autoload_unregister(array('ComposerAutoloaderInit9f7096e25fc06c4ca0a938c1141f1f3b', 'loadClassLoader')); | |||||
| $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); | |||||
| if ($useStaticLoader) { | |||||
| require_once __DIR__ . '/autoload_static.php'; | |||||
| call_user_func(\Composer\Autoload\ComposerStaticInit9f7096e25fc06c4ca0a938c1141f1f3b::getInitializer($loader)); | |||||
| } else { | |||||
| $map = require __DIR__ . '/autoload_namespaces.php'; | |||||
| foreach ($map as $namespace => $path) { | |||||
| $loader->set($namespace, $path); | |||||
| } | |||||
| $map = require __DIR__ . '/autoload_psr4.php'; | |||||
| foreach ($map as $namespace => $path) { | |||||
| $loader->setPsr4($namespace, $path); | |||||
| } | |||||
| $classMap = require __DIR__ . '/autoload_classmap.php'; | |||||
| if ($classMap) { | |||||
| $loader->addClassMap($classMap); | |||||
| } | |||||
| } | |||||
| $loader->register(true); | |||||
| if ($useStaticLoader) { | |||||
| $includeFiles = Composer\Autoload\ComposerStaticInit9f7096e25fc06c4ca0a938c1141f1f3b::$files; | |||||
| } else { | |||||
| $includeFiles = require __DIR__ . '/autoload_files.php'; | |||||
| } | |||||
| foreach ($includeFiles as $fileIdentifier => $file) { | |||||
| composerRequire9f7096e25fc06c4ca0a938c1141f1f3b($fileIdentifier, $file); | |||||
| } | |||||
| return $loader; | |||||
| } | |||||
| } | |||||
| function composerRequire9f7096e25fc06c4ca0a938c1141f1f3b($fileIdentifier, $file) | |||||
| { | |||||
| if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { | |||||
| require $file; | |||||
| $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,35 @@ | |||||
| <?php | |||||
| // autoload_static.php @generated by Composer | |||||
| namespace Composer\Autoload; | |||||
| class ComposerStaticInit9f7096e25fc06c4ca0a938c1141f1f3b | |||||
| { | |||||
| public static $files = array ( | |||||
| '413614dbc06bade22a685c0ebe14027c' => __DIR__ . '/..' . '/wordplate/acf/src/helpers.php', | |||||
| ); | |||||
| public static $prefixLengthsPsr4 = array ( | |||||
| 'W' => | |||||
| array ( | |||||
| 'WordPlate\\Acf\\' => 14, | |||||
| ), | |||||
| ); | |||||
| public static $prefixDirsPsr4 = array ( | |||||
| 'WordPlate\\Acf\\' => | |||||
| array ( | |||||
| 0 => __DIR__ . '/..' . '/wordplate/acf/src', | |||||
| ), | |||||
| ); | |||||
| public static function getInitializer(ClassLoader $loader) | |||||
| { | |||||
| return \Closure::bind(function () use ($loader) { | |||||
| $loader->prefixLengthsPsr4 = ComposerStaticInit9f7096e25fc06c4ca0a938c1141f1f3b::$prefixLengthsPsr4; | |||||
| $loader->prefixDirsPsr4 = ComposerStaticInit9f7096e25fc06c4ca0a938c1141f1f3b::$prefixDirsPsr4; | |||||
| }, null, ClassLoader::class); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,70 @@ | |||||
| [ | |||||
| { | |||||
| "name": "wordplate/acf", | |||||
| "version": "8.4.0", | |||||
| "version_normalized": "8.4.0.0", | |||||
| "source": { | |||||
| "type": "git", | |||||
| "url": "https://github.com/wordplate/extended-acf.git", | |||||
| "reference": "1f8bc3dd04bb83142fd4ea54f56ef9c14fbb7d27" | |||||
| }, | |||||
| "dist": { | |||||
| "type": "zip", | |||||
| "url": "https://api.github.com/repos/wordplate/extended-acf/zipball/1f8bc3dd04bb83142fd4ea54f56ef9c14fbb7d27", | |||||
| "reference": "1f8bc3dd04bb83142fd4ea54f56ef9c14fbb7d27", | |||||
| "shasum": "" | |||||
| }, | |||||
| "require": { | |||||
| "php": "^7.2" | |||||
| }, | |||||
| "require-dev": { | |||||
| "phpunit/phpunit": "^8.0 || ^9.0", | |||||
| "squizlabs/php_codesniffer": "^3.5" | |||||
| }, | |||||
| "time": "2020-06-05T08:47:30+00:00", | |||||
| "type": "library", | |||||
| "extra": { | |||||
| "branch-alias": { | |||||
| "dev-master": "8.4-dev" | |||||
| } | |||||
| }, | |||||
| "installation-source": "dist", | |||||
| "autoload": { | |||||
| "psr-4": { | |||||
| "WordPlate\\Acf\\": "src/" | |||||
| }, | |||||
| "files": [ | |||||
| "src/helpers.php" | |||||
| ] | |||||
| }, | |||||
| "notification-url": "https://packagist.org/downloads/", | |||||
| "license": [ | |||||
| "MIT" | |||||
| ], | |||||
| "authors": [ | |||||
| { | |||||
| "name": "Vincent Klaiber", | |||||
| "email": "hello@doubledip.se" | |||||
| }, | |||||
| { | |||||
| "name": "Chris Andersson", | |||||
| "email": "hello@puredazzle.se" | |||||
| } | |||||
| ], | |||||
| "description": "Register advanced custom fields with object oriented PHP", | |||||
| "keywords": [ | |||||
| "acf", | |||||
| "advanced", | |||||
| "custom", | |||||
| "fields", | |||||
| "wordplate", | |||||
| "wordpress" | |||||
| ], | |||||
| "funding": [ | |||||
| { | |||||
| "url": "https://github.com/wordplate/wordplate", | |||||
| "type": "custom" | |||||
| } | |||||
| ] | |||||
| } | |||||
| ] | |||||
| @ -0,0 +1,9 @@ | |||||
| MIT License | |||||
| Copyright (c) Vincent Klaiber <hello@doubledip.se> | |||||
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |||||
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||||
| @ -0,0 +1,56 @@ | |||||
| { | |||||
| "name": "wordplate/acf", | |||||
| "description": "Register advanced custom fields with object oriented PHP", | |||||
| "keywords": [ | |||||
| "acf", | |||||
| "advanced", | |||||
| "custom", | |||||
| "fields", | |||||
| "wordplate", | |||||
| "wordpress" | |||||
| ], | |||||
| "license": "MIT", | |||||
| "authors": [ | |||||
| { | |||||
| "name": "Vincent Klaiber", | |||||
| "email": "hello@doubledip.se" | |||||
| }, | |||||
| { | |||||
| "name": "Chris Andersson", | |||||
| "email": "hello@puredazzle.se" | |||||
| } | |||||
| ], | |||||
| "require": { | |||||
| "php": "^7.2" | |||||
| }, | |||||
| "require-dev": { | |||||
| "phpunit/phpunit": "^8.0 || ^9.0", | |||||
| "squizlabs/php_codesniffer": "^3.5" | |||||
| }, | |||||
| "config": { | |||||
| "preferred-install": "dist" | |||||
| }, | |||||
| "extra": { | |||||
| "branch-alias": { | |||||
| "dev-master": "8.4-dev" | |||||
| } | |||||
| }, | |||||
| "autoload": { | |||||
| "psr-4": { | |||||
| "WordPlate\\Acf\\": "src/" | |||||
| }, | |||||
| "files": [ | |||||
| "src/helpers.php" | |||||
| ] | |||||
| }, | |||||
| "autoload-dev": { | |||||
| "psr-4": { | |||||
| "WordPlate\\Tests\\Acf\\": "tests/" | |||||
| }, | |||||
| "files": [ | |||||
| "tests/helpers.php" | |||||
| ] | |||||
| }, | |||||
| "minimum-stability": "dev", | |||||
| "prefer-stable": true | |||||
| } | |||||
| @ -0,0 +1,117 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf; | |||||
| class ConditionalLogic | |||||
| { | |||||
| /** @var string */ | |||||
| protected $name; | |||||
| /** @var string */ | |||||
| protected $operator; | |||||
| /** @var string */ | |||||
| protected $parentKey; | |||||
| /** @var mixed */ | |||||
| protected $value; | |||||
| public function __construct(string $name) | |||||
| { | |||||
| $this->name = $name; | |||||
| } | |||||
| public static function if(string $name): self | |||||
| { | |||||
| return new self($name); | |||||
| } | |||||
| public function greaterThan(int $value): self | |||||
| { | |||||
| $this->operator = '>'; | |||||
| $this->value = $value; | |||||
| return $this; | |||||
| } | |||||
| public function lessThan(int $value): self | |||||
| { | |||||
| $this->operator = '<'; | |||||
| $this->value = $value; | |||||
| return $this; | |||||
| } | |||||
| /** @param mixed $value */ | |||||
| public function equals($value): self | |||||
| { | |||||
| $this->operator = '=='; | |||||
| $this->value = $value; | |||||
| return $this; | |||||
| } | |||||
| /** @param mixed $value */ | |||||
| public function notEquals($value): self | |||||
| { | |||||
| $this->operator = '!='; | |||||
| $this->value = $value; | |||||
| return $this; | |||||
| } | |||||
| /** @param mixed $value */ | |||||
| public function contains($value): self | |||||
| { | |||||
| $this->operator = '==contains'; | |||||
| $this->value = $value; | |||||
| return $this; | |||||
| } | |||||
| public function empty(): self | |||||
| { | |||||
| $this->operator = '==empty'; | |||||
| return $this; | |||||
| } | |||||
| public function notEmpty(): self | |||||
| { | |||||
| $this->operator = '!=empty'; | |||||
| return $this; | |||||
| } | |||||
| public function setParentKey(string $parentKey): void | |||||
| { | |||||
| $this->parentKey = $parentKey; | |||||
| } | |||||
| public function toArray(): array | |||||
| { | |||||
| $key = sprintf('%s_%s', $this->parentKey, Key::sanitize($this->name)); | |||||
| $rule = [ | |||||
| 'field' => sprintf('field_%s', Key::hash($key)), | |||||
| 'operator' => $this->operator, | |||||
| ]; | |||||
| if ($this->value) { | |||||
| $rule['value'] = $this->value; | |||||
| } | |||||
| return $rule; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,50 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf; | |||||
| class Config | |||||
| { | |||||
| /** @var array */ | |||||
| protected $items; | |||||
| public function __construct(array $items) | |||||
| { | |||||
| $this->items = $items; | |||||
| } | |||||
| public function has(string $key): bool | |||||
| { | |||||
| return array_key_exists($key, $this->items); | |||||
| } | |||||
| /** @param mixed $value */ | |||||
| public function set(string $key, $value): void | |||||
| { | |||||
| $this->items[$key] = $value; | |||||
| } | |||||
| /** | |||||
| * @param mixed $default | |||||
| * @return mixed | |||||
| */ | |||||
| public function get(string $key, $default = null) | |||||
| { | |||||
| return $this->items[$key] ?? $default; | |||||
| } | |||||
| public function all(): array | |||||
| { | |||||
| return $this->items; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,62 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf; | |||||
| use InvalidArgumentException; | |||||
| class FieldGroup | |||||
| { | |||||
| /** @var \WordPlate\Acf\Config */ | |||||
| protected $config; | |||||
| public function __construct(array $config) | |||||
| { | |||||
| $requiredKeys = ['title', 'fields', 'location']; | |||||
| foreach ($requiredKeys as $key) { | |||||
| if (!array_key_exists($key, $config)) { | |||||
| throw new InvalidArgumentException("Missing field group configuration key [$key]."); | |||||
| } | |||||
| } | |||||
| $this->config = new Config($config); | |||||
| } | |||||
| public function toArray(): array | |||||
| { | |||||
| if ($this->config->has('key')) { | |||||
| $key = Key::sanitize($this->config->get('key')); | |||||
| } else { | |||||
| $key = Key::sanitize($this->config->get('title')); | |||||
| } | |||||
| if (!$this->config->has('style')) { | |||||
| $this->config->set('style', 'seamless'); | |||||
| } | |||||
| $this->config->set('fields', array_map(function ($field) use ($key) { | |||||
| $field->setParentKey($key); | |||||
| return $field->toArray(); | |||||
| }, $this->config->get('fields'))); | |||||
| $this->config->set('location', array_map(function ($location) { | |||||
| return $location->toArray(); | |||||
| }, $this->config->get('location'))); | |||||
| $this->config->set('key', Key::generate($key, 'group')); | |||||
| return $this->config->all(); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,39 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\Endpoint; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| class Accordion extends Field | |||||
| { | |||||
| use Endpoint; | |||||
| use Instructions; | |||||
| protected $type = 'accordion'; | |||||
| public function multiExpand(): self | |||||
| { | |||||
| $this->config->set('multi_expand', true); | |||||
| return $this; | |||||
| } | |||||
| public function open(): self | |||||
| { | |||||
| $this->config->set('open', true); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait ButtonLabel | |||||
| { | |||||
| public function buttonLabel(string $label): self | |||||
| { | |||||
| $this->config->set('button_label', $label); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait CharacterLimit | |||||
| { | |||||
| public function characterLimit(int $limit): self | |||||
| { | |||||
| $this->config->set('maxlength', $limit); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Choices | |||||
| { | |||||
| public function choices(array $choices): self | |||||
| { | |||||
| $this->config->set('choices', $choices); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,28 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait ConditionalLogic | |||||
| { | |||||
| public function conditionalLogic(array $rules): self | |||||
| { | |||||
| $conditionalLogic = $this->config->get('conditional_logic', []); | |||||
| $conditionalLogic[] = $rules; | |||||
| $this->config->set('conditional_logic', $conditionalLogic); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,31 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait DateTimeFormat | |||||
| { | |||||
| public function displayFormat(string $format): self | |||||
| { | |||||
| $this->config->set('display_format', $format); | |||||
| return $this; | |||||
| } | |||||
| public function returnFormat(string $format): self | |||||
| { | |||||
| $this->config->set('return_format', $format); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,27 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait DefaultValue | |||||
| { | |||||
| /** | |||||
| * @param mixed $value | |||||
| */ | |||||
| public function defaultValue($value): self | |||||
| { | |||||
| $this->config->set('default_value', $value); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,43 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Dimensions | |||||
| { | |||||
| public function height(?int $min = null, ?int $max = null): self | |||||
| { | |||||
| if ($min !== null) { | |||||
| $this->config->set('min_height', $min); | |||||
| } | |||||
| if ($max !== null) { | |||||
| $this->config->set('max_height', $max); | |||||
| } | |||||
| return $this; | |||||
| } | |||||
| public function width(?int $min = null, ?int $max = null): self | |||||
| { | |||||
| if ($min !== null) { | |||||
| $this->config->set('min_width', $min); | |||||
| } | |||||
| if ($max !== null) { | |||||
| $this->config->set('max_width', $max); | |||||
| } | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,30 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| use InvalidArgumentException; | |||||
| trait DirectionLayout | |||||
| { | |||||
| public function layout(string $layout): self | |||||
| { | |||||
| if (!in_array($layout, ['vertical', 'horizontal'])) { | |||||
| throw new InvalidArgumentException("Invalid argument layout [$layout]."); | |||||
| } | |||||
| $this->config->set('layout', $layout); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Endpoint | |||||
| { | |||||
| public function endpoint(): self | |||||
| { | |||||
| $this->config->set('endpoint', true); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,34 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait FileSize | |||||
| { | |||||
| /** | |||||
| * @param int|string|null $min | |||||
| * @param int|string|null $max | |||||
| */ | |||||
| public function fileSize($min = null, $max = null): self | |||||
| { | |||||
| if ($min !== null) { | |||||
| $this->config->set('min_size', $min); | |||||
| } | |||||
| if ($max !== null) { | |||||
| $this->config->set('max_size', $max); | |||||
| } | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,31 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait FilterBy | |||||
| { | |||||
| public function postTypes(array $postTypes): self | |||||
| { | |||||
| $this->config->set('post_type', $postTypes); | |||||
| return $this; | |||||
| } | |||||
| public function taxonomies(array $taxonomies): self | |||||
| { | |||||
| $this->config->set('taxonomy', $taxonomies); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Height | |||||
| { | |||||
| public function height(int $height): self | |||||
| { | |||||
| $this->config->set('height', $height); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Instructions | |||||
| { | |||||
| public function instructions(string $instructions): self | |||||
| { | |||||
| $this->config->set('instructions', $instructions); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,35 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| use InvalidArgumentException; | |||||
| trait Layout | |||||
| { | |||||
| /** | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function layout(string $layout): self | |||||
| { | |||||
| if (!in_array($layout, ['block', 'row', 'table'])) { | |||||
| throw new InvalidArgumentException("Invalid argument layout [$layout]."); | |||||
| } | |||||
| $key = __CLASS__ === 'WordPlate\Acf\Fields\Layout' ? 'display' : 'layout'; | |||||
| $this->config->set($key, $layout); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| use InvalidArgumentException; | |||||
| trait Library | |||||
| { | |||||
| /** | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function library(string $library): self | |||||
| { | |||||
| if (!in_array($library, ['all', 'uploadedTo'])) { | |||||
| throw new InvalidArgumentException("Invalid argument library [$library]."); | |||||
| } | |||||
| $this->config->set('library', $library); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Message | |||||
| { | |||||
| public function message(string $message): self | |||||
| { | |||||
| $this->config->set('message', $message); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait MimeTypes | |||||
| { | |||||
| public function mimeTypes(array $mimeTypes): self | |||||
| { | |||||
| $this->config->set('mime_types', implode(',', $mimeTypes)); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,31 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait MinMax | |||||
| { | |||||
| public function max(int $max): self | |||||
| { | |||||
| $this->config->set('max', $max); | |||||
| return $this; | |||||
| } | |||||
| public function min(int $min): self | |||||
| { | |||||
| $this->config->set('min', $min); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Multiple | |||||
| { | |||||
| public function allowMultiple(): self | |||||
| { | |||||
| $this->config->set('multiple', true); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| use InvalidArgumentException; | |||||
| trait NewLines | |||||
| { | |||||
| /** | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function newLines(string $newLines): self | |||||
| { | |||||
| if (!in_array($newLines, ['br', 'wpautop'])) { | |||||
| throw new InvalidArgumentException("Invalid argument new lines [$newLines]."); | |||||
| } | |||||
| $this->config->set('new_lines', $newLines); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Nullable | |||||
| { | |||||
| public function allowNull(): self | |||||
| { | |||||
| $this->config->set('allow_null', true); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,31 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Pending | |||||
| { | |||||
| public function append(string $value): self | |||||
| { | |||||
| $this->config->set('append', $value); | |||||
| return $this; | |||||
| } | |||||
| public function prepend(string $value): self | |||||
| { | |||||
| $this->config->set('prepend', $value); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Placeholder | |||||
| { | |||||
| public function placeholder(string $placeholder): self | |||||
| { | |||||
| $this->config->set('placeholder', $placeholder); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Required | |||||
| { | |||||
| public function required(): self | |||||
| { | |||||
| $this->config->set('required', true); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| use InvalidArgumentException; | |||||
| trait ReturnFormat | |||||
| { | |||||
| /** | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function returnFormat(string $format): self | |||||
| { | |||||
| if (!in_array($format, ['array', 'id', 'label', 'object', 'url', 'value'])) { | |||||
| throw new InvalidArgumentException("Invalid argument return format [$format]."); | |||||
| } | |||||
| $this->config->set('return_format', $format); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Step | |||||
| { | |||||
| public function step(int $step): self | |||||
| { | |||||
| $this->config->set('step', $step); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait SubFields | |||||
| { | |||||
| public function fields(array $fields): self | |||||
| { | |||||
| $this->config->set('sub_fields', $fields); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait WeekDay | |||||
| { | |||||
| public function weekStartsOn(int $day): self | |||||
| { | |||||
| $this->config->set('first_day', $day); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,24 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields\Attributes; | |||||
| trait Wrapper | |||||
| { | |||||
| public function wrapper(array $wrapper): self | |||||
| { | |||||
| $this->config->set('wrapper', $wrapper); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,37 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\Choices; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\DirectionLayout; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class ButtonGroup extends Field | |||||
| { | |||||
| use Choices; | |||||
| use DefaultValue; | |||||
| use DirectionLayout; | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'button_group'; | |||||
| } | |||||
| @ -0,0 +1,37 @@ | |||||
| <?php | |||||
| /* | |||||
| * This file is part of WordPlate. | |||||
| * | |||||
| * (c) Vincent Klaiber <hello@doubledip.se> | |||||
| * | |||||
| * For the full copyright and license information; use please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\Choices; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\DirectionLayout; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Checkbox extends Field | |||||
| { | |||||
| use Choices; | |||||
| use DefaultValue; | |||||
| use DirectionLayout; | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'checkbox'; | |||||
| } | |||||
| @ -0,0 +1,31 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class ColorPicker extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DefaultValue; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'color_picker'; | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /* | |||||
| * This file is part of WordPlate. | |||||
| * | |||||
| * (c) Vincent Klaiber <hello@doubledip.se> | |||||
| * | |||||
| * For the full copyright and license information; use please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DateTimeFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\WeekDay; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class DatePicker extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DateTimeFormat; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use WeekDay; | |||||
| use Wrapper; | |||||
| protected $type = 'date_picker'; | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DateTimeFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\WeekDay; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class DateTimePicker extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DateTimeFormat; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use WeekDay; | |||||
| use Wrapper; | |||||
| protected $type = 'date_time_picker'; | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /* | |||||
| * This file is part of WordPlate. | |||||
| * | |||||
| * (c) Vincent Klaiber <hello@doubledip.se> | |||||
| * | |||||
| * For the full copyright and license information; use please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Pending; | |||||
| use WordPlate\Acf\Fields\Attributes\Placeholder; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Email extends Field | |||||
| { | |||||
| use Instructions; | |||||
| use ConditionalLogic; | |||||
| use Pending; | |||||
| use Placeholder; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'email'; | |||||
| } | |||||
| @ -0,0 +1,100 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Config; | |||||
| use WordPlate\Acf\Key; | |||||
| abstract class Field | |||||
| { | |||||
| /** @var \WordPlate\Acf\Config */ | |||||
| protected $config; | |||||
| /** @var string */ | |||||
| protected $keyPrefix = 'field'; | |||||
| /** @var string */ | |||||
| protected $parentKey; | |||||
| /** @var string */ | |||||
| protected $type; | |||||
| public function __construct(string $label, ?string $name = null) | |||||
| { | |||||
| $this->config = new Config([ | |||||
| 'label' => $label, | |||||
| 'name' => $name ?? sanitize_title($label), | |||||
| ]); | |||||
| } | |||||
| /** @return static */ | |||||
| public static function make(string $label, ?string $name = null): self | |||||
| { | |||||
| return new static($label, $name); | |||||
| } | |||||
| public function setParentKey(string $parentKey): void | |||||
| { | |||||
| $this->parentKey = $parentKey; | |||||
| } | |||||
| public function toArray(): array | |||||
| { | |||||
| $key = sprintf('%s_%s', $this->parentKey, Key::sanitize($this->config->get('name'))); | |||||
| if (!empty($this->type)) { | |||||
| $this->config->set('type', $this->type); | |||||
| } | |||||
| if ($this->config->has('conditional_logic')) { | |||||
| $this->config->set('conditional_logic', array_map(function ($rules) { | |||||
| return array_map(function ($rule) { | |||||
| $rule->setParentKey($this->parentKey); | |||||
| return $rule->toArray(); | |||||
| }, $rules); | |||||
| }, $this->config->get('conditional_logic'))); | |||||
| } | |||||
| if ($this->config->has('layouts')) { | |||||
| $this->config->set('layouts', array_map(function ($layout) use ($key) { | |||||
| $layout->setParentKey($key); | |||||
| return $layout->toArray(); | |||||
| }, $this->config->get('layouts'))); | |||||
| } | |||||
| if ($this->config->has('sub_fields')) { | |||||
| $this->config->set('sub_fields', array_map(function ($field) use ($key) { | |||||
| $field->setParentKey($key); | |||||
| return $field->toArray(); | |||||
| }, $this->config->get('sub_fields'))); | |||||
| } | |||||
| if ($this->config->has('collapsed')) { | |||||
| foreach ($this->config->get('sub_fields', []) as $field) { | |||||
| if ($field['name'] === $this->config->get('collapsed')) { | |||||
| $this->config->set('collapsed', $field['key']); | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| $this->config->set('key', Key::generate($key, $this->keyPrefix)); | |||||
| return $this->config->all(); | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,37 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\FileSize; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Library; | |||||
| use WordPlate\Acf\Fields\Attributes\MimeTypes; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class File extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use FileSize; | |||||
| use Instructions; | |||||
| use Library; | |||||
| use MimeTypes; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'file'; | |||||
| } | |||||
| @ -0,0 +1,40 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ButtonLabel; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\MinMax; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class FlexibleContent extends Field | |||||
| { | |||||
| use ButtonLabel; | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use MinMax; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'flexible_content'; | |||||
| public function layouts(array $layouts): self | |||||
| { | |||||
| $this->config->set('layouts', $layouts); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,56 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use InvalidArgumentException; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Dimensions; | |||||
| use WordPlate\Acf\Fields\Attributes\FileSize; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Library; | |||||
| use WordPlate\Acf\Fields\Attributes\MimeTypes; | |||||
| use WordPlate\Acf\Fields\Attributes\MinMax; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Gallery extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Dimensions; | |||||
| use FileSize; | |||||
| use Instructions; | |||||
| use Library; | |||||
| use MimeTypes; | |||||
| use MinMax; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'gallery'; | |||||
| /** | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function insert(string $insert): self | |||||
| { | |||||
| if (!in_array($insert, ['append', 'prepend'])) { | |||||
| throw new InvalidArgumentException("Invalid argument insert [$insert]"); | |||||
| } | |||||
| $this->config->set('insert', $insert); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,46 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Height; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class GoogleMap extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Height; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'google_map'; | |||||
| public function center(float $latitude, float $longitude): self | |||||
| { | |||||
| $this->config->set('center_lat', $latitude); | |||||
| $this->config->set('center_lng', $longitude); | |||||
| return $this; | |||||
| } | |||||
| public function zoom(int $zoom): self | |||||
| { | |||||
| $this->config->set('zoom', $zoom); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Layout; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\SubFields; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Group extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Layout; | |||||
| use SubFields; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'group'; | |||||
| } | |||||
| @ -0,0 +1,46 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Dimensions; | |||||
| use WordPlate\Acf\Fields\Attributes\FileSize; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Library; | |||||
| use WordPlate\Acf\Fields\Attributes\MimeTypes; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Image extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Dimensions; | |||||
| use FileSize; | |||||
| use Instructions; | |||||
| use Library; | |||||
| use MimeTypes; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'image'; | |||||
| public function previewSize(string $size): self | |||||
| { | |||||
| $this->config->set('preview_size', $size); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,27 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\Layout as Display; | |||||
| use WordPlate\Acf\Fields\Attributes\MinMax; | |||||
| use WordPlate\Acf\Fields\Attributes\SubFields; | |||||
| class Layout extends Field | |||||
| { | |||||
| use Display; | |||||
| use MinMax; | |||||
| use SubFields; | |||||
| protected $keyPrefix = 'layout'; | |||||
| } | |||||
| @ -0,0 +1,31 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Link extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'link'; | |||||
| } | |||||
| @ -0,0 +1,32 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\Message as MessageAttribute; | |||||
| use WordPlate\Acf\Fields\Attributes\NewLines; | |||||
| class Message extends Field | |||||
| { | |||||
| use MessageAttribute; | |||||
| use NewLines; | |||||
| protected $type = 'message'; | |||||
| public function escapeHtml(): self | |||||
| { | |||||
| $this->config->set('esc_html', true); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,39 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\MinMax; | |||||
| use WordPlate\Acf\Fields\Attributes\Pending; | |||||
| use WordPlate\Acf\Fields\Attributes\Placeholder; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Step; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Number extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DefaultValue; | |||||
| use Instructions; | |||||
| use MinMax; | |||||
| use Pending; | |||||
| use Placeholder; | |||||
| use Step; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'number'; | |||||
| } | |||||
| @ -0,0 +1,38 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Height; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Oembed extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Height; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'oembed'; | |||||
| public function width(int $width): self | |||||
| { | |||||
| $this->config->set('width', $width); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,42 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\FilterBy; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Multiple; | |||||
| use WordPlate\Acf\Fields\Attributes\Nullable; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class PageLink extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use FilterBy; | |||||
| use Instructions; | |||||
| use Multiple; | |||||
| use Nullable; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'page_link'; | |||||
| public function allowArchives(bool $value = true): self | |||||
| { | |||||
| $this->config->set('allow_archives', $value); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Pending; | |||||
| use WordPlate\Acf\Fields\Attributes\Placeholder; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Password extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Pending; | |||||
| use Placeholder; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'password'; | |||||
| } | |||||
| @ -0,0 +1,37 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\FilterBy; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Multiple; | |||||
| use WordPlate\Acf\Fields\Attributes\Nullable; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class PostObject extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use FilterBy; | |||||
| use Instructions; | |||||
| use Multiple; | |||||
| use Nullable; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'post_object'; | |||||
| } | |||||
| @ -0,0 +1,37 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\Choices; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\DirectionLayout; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Radio extends Field | |||||
| { | |||||
| use Choices; | |||||
| use DefaultValue; | |||||
| use DirectionLayout; | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'radio'; | |||||
| } | |||||
| @ -0,0 +1,37 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\MinMax; | |||||
| use WordPlate\Acf\Fields\Attributes\Pending; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Step; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Range extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DefaultValue; | |||||
| use Instructions; | |||||
| use MinMax; | |||||
| use Step; | |||||
| use Pending; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'range'; | |||||
| } | |||||
| @ -0,0 +1,49 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\FilterBy; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\MinMax; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Relationship extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use FilterBy; | |||||
| use Instructions; | |||||
| use MinMax; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'relationship'; | |||||
| public function elements(array $elements): self | |||||
| { | |||||
| $this->config->set('elements', $elements); | |||||
| return $this; | |||||
| } | |||||
| public function filters(array $filters): self | |||||
| { | |||||
| $this->config->set('filters', $filters); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,44 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ButtonLabel; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Layout; | |||||
| use WordPlate\Acf\Fields\Attributes\MinMax; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\SubFields; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Repeater extends Field | |||||
| { | |||||
| use ButtonLabel; | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Layout; | |||||
| use MinMax; | |||||
| use SubFields; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'repeater'; | |||||
| public function collapsed(string $name): self | |||||
| { | |||||
| $this->config->set('collapsed', $name); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,47 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\Choices; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Multiple; | |||||
| use WordPlate\Acf\Fields\Attributes\Nullable; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Select extends Field | |||||
| { | |||||
| use Choices; | |||||
| use DefaultValue; | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Multiple; | |||||
| use Nullable; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'select'; | |||||
| public function stylisedUi(bool $useAjax = false): self | |||||
| { | |||||
| $this->config->set('ui', true); | |||||
| $this->config->set('ajax', $useAjax); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,35 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use InvalidArgumentException; | |||||
| use WordPlate\Acf\Fields\Attributes\Endpoint; | |||||
| class Tab extends Field | |||||
| { | |||||
| use Endpoint; | |||||
| protected $type = 'tab'; | |||||
| public function placement(string $placement): self | |||||
| { | |||||
| if (!in_array($placement, ['left', 'top'])) { | |||||
| throw new InvalidArgumentException("Invalid argument placement [$placement]."); | |||||
| } | |||||
| $this->config->set('placement', $placement); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,76 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use InvalidArgumentException; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Nullable; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Taxonomy extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Nullable; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'taxonomy'; | |||||
| /** | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function appearance(string $fieldType): self | |||||
| { | |||||
| if (!in_array($fieldType, ['checkbox', 'multi_select', 'select', 'radio'])) { | |||||
| throw new InvalidArgumentException("Invalid argument field type [$fieldType]."); | |||||
| } | |||||
| $this->config->set('field_type', $fieldType); | |||||
| return $this; | |||||
| } | |||||
| public function createTerms(): self | |||||
| { | |||||
| $this->config->set('add_term', true); | |||||
| return $this; | |||||
| } | |||||
| public function loadTerms(): self | |||||
| { | |||||
| $this->config->set('load_terms', true); | |||||
| return $this; | |||||
| } | |||||
| public function saveTerms(): self | |||||
| { | |||||
| $this->config->set('save_terms', true); | |||||
| return $this; | |||||
| } | |||||
| public function taxonomy(string $taxonomy): self | |||||
| { | |||||
| $this->config->set('taxonomy', $taxonomy); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,37 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\CharacterLimit; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Pending; | |||||
| use WordPlate\Acf\Fields\Attributes\Placeholder; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Text extends Field | |||||
| { | |||||
| use CharacterLimit; | |||||
| use ConditionalLogic; | |||||
| use DefaultValue; | |||||
| use Instructions; | |||||
| use Pending; | |||||
| use Placeholder; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'text'; | |||||
| } | |||||
| @ -0,0 +1,44 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\CharacterLimit; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\NewLines; | |||||
| use WordPlate\Acf\Fields\Attributes\Placeholder; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Textarea extends Field | |||||
| { | |||||
| use CharacterLimit; | |||||
| use ConditionalLogic; | |||||
| use DefaultValue; | |||||
| use Instructions; | |||||
| use NewLines; | |||||
| use Placeholder; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'textarea'; | |||||
| public function rows(int $rows): self | |||||
| { | |||||
| $this->config->set('rows', $rows); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,36 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DateTimeFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class TimePicker extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DateTimeFormat; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| /** | |||||
| * The field type. | |||||
| * | |||||
| * @var string | |||||
| */ | |||||
| protected $type = 'time_picker'; | |||||
| } | |||||
| @ -0,0 +1,48 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Message; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class TrueFalse extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DefaultValue; | |||||
| use Instructions; | |||||
| use Message; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'true_false'; | |||||
| public function stylisedUi(?string $onText = null, ?string $offText = null): self | |||||
| { | |||||
| $this->config->set('ui', true); | |||||
| if ($onText !== null) { | |||||
| $this->config->set('ui_on_text', $onText); | |||||
| } | |||||
| if ($offText !== null) { | |||||
| $this->config->set('ui_off_text', $offText); | |||||
| } | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,33 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Placeholder; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Url extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DefaultValue; | |||||
| use Instructions; | |||||
| use Placeholder; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'url'; | |||||
| } | |||||
| @ -0,0 +1,42 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Multiple; | |||||
| use WordPlate\Acf\Fields\Attributes\Nullable; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\ReturnFormat; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class User extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use Instructions; | |||||
| use Multiple; | |||||
| use Nullable; | |||||
| use Required; | |||||
| use ReturnFormat; | |||||
| use Wrapper; | |||||
| protected $type = 'user'; | |||||
| public function roles(array $roles): self | |||||
| { | |||||
| $this->config->set('role', $roles); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,60 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf\Fields; | |||||
| use InvalidArgumentException; | |||||
| use WordPlate\Acf\Fields\Attributes\ConditionalLogic; | |||||
| use WordPlate\Acf\Fields\Attributes\DefaultValue; | |||||
| use WordPlate\Acf\Fields\Attributes\Instructions; | |||||
| use WordPlate\Acf\Fields\Attributes\Required; | |||||
| use WordPlate\Acf\Fields\Attributes\Wrapper; | |||||
| class Wysiwyg extends Field | |||||
| { | |||||
| use ConditionalLogic; | |||||
| use DefaultValue; | |||||
| use Instructions; | |||||
| use Required; | |||||
| use Wrapper; | |||||
| protected $type = 'wysiwyg'; | |||||
| public function mediaUpload(bool $mediaUpload): self | |||||
| { | |||||
| $this->config->set('media_upload', $mediaUpload); | |||||
| return $this; | |||||
| } | |||||
| /** | |||||
| * @throws \InvalidArgumentException | |||||
| */ | |||||
| public function tabs(string $tabs): self | |||||
| { | |||||
| if (!in_array($tabs, ['all', 'visual', 'text'])) { | |||||
| throw new InvalidArgumentException("Invalid argument tabs [$tabs]."); | |||||
| } | |||||
| $this->config->set('tabs', $tabs); | |||||
| return $this; | |||||
| } | |||||
| public function toolbar(string $toolbar): self | |||||
| { | |||||
| $this->config->set('toolbar', $toolbar); | |||||
| return $this; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,58 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf; | |||||
| use InvalidArgumentException; | |||||
| class Key | |||||
| { | |||||
| protected static $keys = []; | |||||
| public static function generate(string $key, string $prefix): string | |||||
| { | |||||
| $key = sprintf('%s_%s', $prefix, static::hash($key)); | |||||
| static::validate($key, $prefix); | |||||
| static::$keys[] = $key; | |||||
| return $key; | |||||
| } | |||||
| public static function hash(string $key): string | |||||
| { | |||||
| return hash('fnv1a32', $key); | |||||
| } | |||||
| public static function sanitize(string $key): string | |||||
| { | |||||
| return str_replace('-', '_', sanitize_title($key)); | |||||
| } | |||||
| /** @throws \InvalidArgumentException */ | |||||
| public static function validate(string $key, string $prefix): string | |||||
| { | |||||
| // Validate if the key is unique or not. | |||||
| if (in_array($key, self::$keys)) { | |||||
| throw new InvalidArgumentException("The key [$key] is not unique."); | |||||
| } | |||||
| // Validate if the key contains the the given prefix or not. | |||||
| if (strpos($key, $prefix) === false) { | |||||
| throw new InvalidArgumentException("The key must be prefixed with [$prefix]."); | |||||
| } | |||||
| return $key; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,51 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| namespace WordPlate\Acf; | |||||
| class Location | |||||
| { | |||||
| protected $rules = []; | |||||
| public function __construct(string $param, string $operator, ?string $value = null) | |||||
| { | |||||
| $this->rules[] = compact('param', 'operator', 'value'); | |||||
| } | |||||
| public static function if(string $param, string $operator, ?string $value = null): self | |||||
| { | |||||
| if (func_num_args() === 2) { | |||||
| $value = $operator; | |||||
| $operator = '=='; | |||||
| } | |||||
| return new self($param, $operator, $value); | |||||
| } | |||||
| public function and(string $param, string $operator, ?string $value = null): self | |||||
| { | |||||
| if (func_num_args() === 2) { | |||||
| $value = $operator; | |||||
| $operator = '=='; | |||||
| } | |||||
| $this->rules[] = compact('param', 'operator', 'value'); | |||||
| return $this; | |||||
| } | |||||
| public function toArray(): array | |||||
| { | |||||
| return $this->rules; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,77 @@ | |||||
| <?php | |||||
| /** | |||||
| * Copyright (c) Vincent Klaiber. | |||||
| * | |||||
| * For the full copyright and license information, please view the LICENSE | |||||
| * file that was distributed with this source code. | |||||
| * | |||||
| * @see https://github.com/wordplate/extended-acf | |||||
| */ | |||||
| declare(strict_types=1); | |||||
| use WordPlate\Acf\FieldGroup; | |||||
| if (!function_exists('field')) { | |||||
| /** | |||||
| * Shorthand for the_field and the_sub_field functions. | |||||
| * | |||||
| * @param string $name | |||||
| * @param int|\WP_Post|null $post | |||||
| * | |||||
| * @return mixed | |||||
| */ | |||||
| function field(string $name, $post = null) | |||||
| { | |||||
| if (!function_exists('get_field')) { | |||||
| return; | |||||
| } | |||||
| if ($post) { | |||||
| $value = get_field($name, $post); | |||||
| } else { | |||||
| $value = get_sub_field($name) ?: get_field($name); | |||||
| } | |||||
| return empty($value) ? null : $value; | |||||
| } | |||||
| } | |||||
| if (!function_exists('option')) { | |||||
| /** | |||||
| * Shorthand for the_field option function. | |||||
| * | |||||
| * @param string $name | |||||
| * | |||||
| * @return mixed | |||||
| */ | |||||
| function option(string $name) | |||||
| { | |||||
| if (!function_exists('get_field')) { | |||||
| return; | |||||
| } | |||||
| $value = get_field($name, 'option'); | |||||
| return empty($value) ? null : $value; | |||||
| } | |||||
| } | |||||
| if (!function_exists('register_extended_field_group')) { | |||||
| /** | |||||
| * Register ACF field group. | |||||
| * | |||||
| * @param array $config | |||||
| * | |||||
| * @return void | |||||
| */ | |||||
| function register_extended_field_group(array $config): void | |||||
| { | |||||
| if (function_exists('register_field_group')) { | |||||
| $fieldGroup = new FieldGroup($config); | |||||
| register_field_group($fieldGroup->toArray()); | |||||
| } | |||||
| } | |||||
| } | |||||