diff --git a/typerocket-v5.php b/typerocket-v5.php index 426cfd80..60d34c74 100644 --- a/typerocket-v5.php +++ b/typerocket-v5.php @@ -3,7 +3,7 @@ Plugin Name: TypeRocket - Andromeda Plugin URI: https://typerocket.com/ Description: TypeRocket is a framework that joins refined UI elements and modern programming architecture together. -Version: 5.1.11 +Version: 5.1.12 Requires at least: 6.0 Requires PHP: 7.4 Author: TypeRocket @@ -34,7 +34,7 @@ public function __construct() return; } - define('TYPEROCKET_PLUGIN_VERSION', '5.1.11'); + define('TYPEROCKET_PLUGIN_VERSION', '5.1.12'); define('TYPEROCKET_PLUGIN_INSTALL', __DIR__); if(!defined('TYPEROCKET_ROOT_WP')) diff --git a/typerocket/composer.lock b/typerocket/composer.lock index 3724dd15..d3af71f1 100644 --- a/typerocket/composer.lock +++ b/typerocket/composer.lock @@ -883,16 +883,16 @@ }, { "name": "typerocket/core", - "version": "v5.1.30", + "version": "v5.1.36", "source": { "type": "git", "url": "https://github.com/TypeRocket/core.git", - "reference": "3e1e2f85d459927a7224e681d012ec6eb973dec8" + "reference": "c589a9710285ada75dabcd5f123ae45935583697" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/TypeRocket/core/zipball/3e1e2f85d459927a7224e681d012ec6eb973dec8", - "reference": "3e1e2f85d459927a7224e681d012ec6eb973dec8", + "url": "https://api.github.com/repos/TypeRocket/core/zipball/c589a9710285ada75dabcd5f123ae45935583697", + "reference": "c589a9710285ada75dabcd5f123ae45935583697", "shasum": "" }, "require": { @@ -933,9 +933,9 @@ "support": { "docs": "https://typerocket.com/docs/v5/", "issues": "https://github.com/TypeRocket/core/issues", - "source": "https://github.com/TypeRocket/core/tree/v5.1.30" + "source": "https://github.com/TypeRocket/core/tree/v5.1.36" }, - "time": "2022-09-02T14:58:01+00:00" + "time": "2022-09-03T00:23:16+00:00" }, { "name": "woocommerce/action-scheduler", diff --git a/typerocket/vendor/composer/autoload_classmap.php b/typerocket/vendor/composer/autoload_classmap.php index e67bad8e..fa97fa52 100644 --- a/typerocket/vendor/composer/autoload_classmap.php +++ b/typerocket/vendor/composer/autoload_classmap.php @@ -1109,6 +1109,7 @@ 'TypeRocket\\Database\\ResultsPostMeta' => $vendorDir . '/typerocket/core/src/Database/ResultsPostMeta.php', 'TypeRocket\\Database\\ResultsTermMeta' => $vendorDir . '/typerocket/core/src/Database/ResultsTermMeta.php', 'TypeRocket\\Database\\ResultsUserMeta' => $vendorDir . '/typerocket/core/src/Database/ResultsUserMeta.php', + 'TypeRocket\\Database\\SqlRaw' => $vendorDir . '/typerocket/core/src/Database/SqlRaw.php', 'TypeRocket\\Database\\SqlRunner' => $vendorDir . '/typerocket/core/src/Database/SqlRunner.php', 'TypeRocket\\Elements\\BaseFields' => $vendorDir . '/typerocket/core/src/Elements/BaseFields.php', 'TypeRocket\\Elements\\BaseForm' => $vendorDir . '/typerocket/core/src/Elements/BaseForm.php', diff --git a/typerocket/vendor/composer/autoload_static.php b/typerocket/vendor/composer/autoload_static.php index b50fbd20..9c7711a3 100644 --- a/typerocket/vendor/composer/autoload_static.php +++ b/typerocket/vendor/composer/autoload_static.php @@ -1217,6 +1217,7 @@ class ComposerStaticInit1ea299e54fdefaef41f855b3138bc6c1 'TypeRocket\\Database\\ResultsPostMeta' => __DIR__ . '/..' . '/typerocket/core/src/Database/ResultsPostMeta.php', 'TypeRocket\\Database\\ResultsTermMeta' => __DIR__ . '/..' . '/typerocket/core/src/Database/ResultsTermMeta.php', 'TypeRocket\\Database\\ResultsUserMeta' => __DIR__ . '/..' . '/typerocket/core/src/Database/ResultsUserMeta.php', + 'TypeRocket\\Database\\SqlRaw' => __DIR__ . '/..' . '/typerocket/core/src/Database/SqlRaw.php', 'TypeRocket\\Database\\SqlRunner' => __DIR__ . '/..' . '/typerocket/core/src/Database/SqlRunner.php', 'TypeRocket\\Elements\\BaseFields' => __DIR__ . '/..' . '/typerocket/core/src/Elements/BaseFields.php', 'TypeRocket\\Elements\\BaseForm' => __DIR__ . '/..' . '/typerocket/core/src/Elements/BaseForm.php', diff --git a/typerocket/vendor/composer/installed.json b/typerocket/vendor/composer/installed.json index c22bcdc1..610250f3 100644 --- a/typerocket/vendor/composer/installed.json +++ b/typerocket/vendor/composer/installed.json @@ -2720,17 +2720,17 @@ }, { "name": "typerocket/core", - "version": "v5.1.30", - "version_normalized": "5.1.30.0", + "version": "v5.1.36", + "version_normalized": "5.1.36.0", "source": { "type": "git", "url": "https://github.com/TypeRocket/core.git", - "reference": "3e1e2f85d459927a7224e681d012ec6eb973dec8" + "reference": "c589a9710285ada75dabcd5f123ae45935583697" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/TypeRocket/core/zipball/3e1e2f85d459927a7224e681d012ec6eb973dec8", - "reference": "3e1e2f85d459927a7224e681d012ec6eb973dec8", + "url": "https://api.github.com/repos/TypeRocket/core/zipball/c589a9710285ada75dabcd5f123ae45935583697", + "reference": "c589a9710285ada75dabcd5f123ae45935583697", "shasum": "" }, "require": { @@ -2744,7 +2744,7 @@ "require-dev": { "phpunit/phpunit": "^9.5" }, - "time": "2022-09-02T14:58:01+00:00", + "time": "2022-09-03T00:23:16+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2773,7 +2773,7 @@ "support": { "docs": "https://typerocket.com/docs/v5/", "issues": "https://github.com/TypeRocket/core/issues", - "source": "https://github.com/TypeRocket/core/tree/v5.1.30" + "source": "https://github.com/TypeRocket/core/tree/v5.1.36" }, "install-path": "../typerocket/core" }, diff --git a/typerocket/vendor/composer/installed.php b/typerocket/vendor/composer/installed.php index 6c1d38e3..6ec43cd9 100644 --- a/typerocket/vendor/composer/installed.php +++ b/typerocket/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'typerocket/typerocket', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '16d7b32849959ed21b03dd89cd2b89093f607555', + 'reference' => '8af26d78efedd20566140445c9d388c3834a0913', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -368,9 +368,9 @@ 'dev_requirement' => true, ), 'typerocket/core' => array( - 'pretty_version' => 'v5.1.30', - 'version' => '5.1.30.0', - 'reference' => '3e1e2f85d459927a7224e681d012ec6eb973dec8', + 'pretty_version' => 'v5.1.36', + 'version' => '5.1.36.0', + 'reference' => 'c589a9710285ada75dabcd5f123ae45935583697', 'type' => 'library', 'install_path' => __DIR__ . '/../typerocket/core', 'aliases' => array(), @@ -379,7 +379,7 @@ 'typerocket/typerocket' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '16d7b32849959ed21b03dd89cd2b89093f607555', + 'reference' => '8af26d78efedd20566140445c9d388c3834a0913', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), diff --git a/typerocket/vendor/typerocket/core/src/Database/Query.php b/typerocket/vendor/typerocket/core/src/Database/Query.php index 6edeea6c..26c94485 100644 --- a/typerocket/vendor/typerocket/core/src/Database/Query.php +++ b/typerocket/vendor/typerocket/core/src/Database/Query.php @@ -1439,6 +1439,10 @@ protected function compileTable() */ protected function tickSqlName($column) { + if($column instanceof SqlRaw) { + return $column; + } + $c = preg_replace($this->columnPattern, '', $column); if(!Str::contains('`', $column)) { diff --git a/typerocket/vendor/typerocket/core/src/Database/SqlRaw.php b/typerocket/vendor/typerocket/core/src/Database/SqlRaw.php new file mode 100644 index 00000000..353a35eb --- /dev/null +++ b/typerocket/vendor/typerocket/core/src/Database/SqlRaw.php @@ -0,0 +1,38 @@ +sql = $sql; + } + + /** + * To String + * + * @return string|null + */ + public function __toString() + { + return $this->sql; + } + + /** + * @param mixed ...$args + * + * @return static + */ + public static function new(...$args) + { + return new static(...$args); + } +} \ No newline at end of file diff --git a/typerocket/vendor/typerocket/core/src/Models/Model.php b/typerocket/vendor/typerocket/core/src/Models/Model.php index 95fa5ae8..344c2ecb 100644 --- a/typerocket/vendor/typerocket/core/src/Models/Model.php +++ b/typerocket/vendor/typerocket/core/src/Models/Model.php @@ -1691,6 +1691,54 @@ public function count($column = null) return $this->query->count($column); } + /** + * Sum + * + * @param string $column + * + * @return array|bool|false|int|null|object + */ + public function sum( $column ) + { + return $this->query->sum($column); + } + + /** + * Min + * + * @param string $column + * + * @return array|bool|false|int|null|object + */ + public function min( $column ) + { + return $this->query->min($column); + } + + /** + * Max + * + * @param string $column + * + * @return array|bool|false|int|null|object + */ + public function max( $column ) + { + return $this->query->max($column); + } + + /** + * Average + * + * @param string $column + * + * @return array|bool|false|int|null|object + */ + public function avg( $column ) + { + return $this->query->avg($column); + } + /** * Select only specific columns * diff --git a/typerocket/vendor/typerocket/core/src/Models/WPUser.php b/typerocket/vendor/typerocket/core/src/Models/WPUser.php index 395edc0f..b6920514 100644 --- a/typerocket/vendor/typerocket/core/src/Models/WPUser.php +++ b/typerocket/vendor/typerocket/core/src/Models/WPUser.php @@ -99,6 +99,16 @@ public function posts( $modelClass = WPPost::class ) return $this->hasMany( $modelClass, 'post_author'); } + /** + * @param $capability + * + * @return Model|WPUser + */ + public function whereCapabilityLike($capability) + { + return $this->whereMeta( 'wp_capabilities', 'like', '%:"'.$capability.'";%' ); + } + /** * Find WP_User Instance * diff --git a/typerocket/vendor/typerocket/core/src/Utility/Data.php b/typerocket/vendor/typerocket/core/src/Utility/Data.php index 1edf5e7e..44cf2dac 100644 --- a/typerocket/vendor/typerocket/core/src/Utility/Data.php +++ b/typerocket/vendor/typerocket/core/src/Utility/Data.php @@ -5,6 +5,20 @@ class Data { + /** + * Return the default value of the given value. + * + * @param mixed $value + * @param null|array $args + * + * @return mixed + * @throws \ReflectionException + */ + public static function value($value, ?array $args = null) + { + return $value instanceof \Closure ? (new Resolver)->resolveCallable($value, $args) : $value; + } + /** * Nil * @@ -110,7 +124,7 @@ public static function emptyOrBlankRecursive($value) : bool /** * Dots Walk * - * Traverse array with dot notation. + * Traverse array with dot notation with wilds (*). * * @param string|array $dots dot notation key.next.final * @param array|object $array an array to traverse @@ -140,6 +154,47 @@ public static function walk($dots, $array, $default = null) return $array; } + /** + * Get + * + * Get value using dot notation without wilds (*). + * + * @param object|array $data an array to traverse + * @param string|array $dots dot notation key.next.final or array of dots + * @param mixed|null $default + * + * @return mixed + */ + public static function get($data, $dots, $default = null) + { + $dots = (array) $dots; + $index = count($dots) > 1; + $return = null; + + foreach ($dots as $dot) { + $traverse = explode('.', $dot); + $search = $data; + + foreach ($traverse as $step) { + $v = is_object($search) ? ($search->$step ?? null) : ($search[$step] ?? null); + + if ( !isset($v) && ! is_string($search) ) { + $search = $default; + break; + } + $search = $v ?? $default; + } + + if($index) { + $return[$dot] = $search; + } else { + $return = $search; + } + } + + return $return; + } + /** * Index Data by Unique Value * diff --git a/typerocket/vendor/typerocket/core/src/Utility/PersistentCache.php b/typerocket/vendor/typerocket/core/src/Utility/PersistentCache.php index 48e95b1c..991ec76d 100644 --- a/typerocket/vendor/typerocket/core/src/Utility/PersistentCache.php +++ b/typerocket/vendor/typerocket/core/src/Utility/PersistentCache.php @@ -38,7 +38,7 @@ public static function new($folder = 'app') public function get($key, $default = null) { try { - return $this->getData($this->getFile($key)) ?? Value::get($default); + return $this->getData($this->getFile($key)) ?? Data::value($default); } catch (\Exception $e) { return null; } @@ -77,7 +77,7 @@ public function getOtherwisePut($key, $default, $time = 9999999999) if(!$data) { try { - $data = Value::get($default); + $data = Data::value($default); $this->put($key, $data, $time); } catch (\ReflectionException $e) { return null; diff --git a/typerocket/vendor/typerocket/core/src/Utility/RuntimeCache.php b/typerocket/vendor/typerocket/core/src/Utility/RuntimeCache.php index 0bcca8c4..566e0e26 100644 --- a/typerocket/vendor/typerocket/core/src/Utility/RuntimeCache.php +++ b/typerocket/vendor/typerocket/core/src/Utility/RuntimeCache.php @@ -66,7 +66,7 @@ public function getOtherwisePut($key, $default = null, $namespace = null) return $value; } - return $this->add($key, Value::get($default), $namespace); + return $this->add($key, Data::value($default), $namespace); } /** diff --git a/typerocket/vendor/typerocket/core/src/Utility/Str.php b/typerocket/vendor/typerocket/core/src/Utility/Str.php index c3b204b3..aaba4f7d 100644 --- a/typerocket/vendor/typerocket/core/src/Utility/Str.php +++ b/typerocket/vendor/typerocket/core/src/Utility/Str.php @@ -3,6 +3,10 @@ class Str { + public const UTF8 = 'UTF-8'; + public const ASCII = 'ASCII'; + public const LATIN1 = 'ISO-8859-1'; + /** * @param string $str * @@ -10,7 +14,7 @@ class Str */ public static function uppercaseWords($str) { - return mb_convert_case($str, MB_CASE_TITLE, 'UTF-8'); + return mb_convert_case($str, MB_CASE_TITLE, static::UTF8); } /** @@ -32,6 +36,20 @@ public static function classNames($defaults, $classes = null, $failed = '') return $defaults . ' ' . $result; } + /** + * Quiet + * + * Is null or is blank after trim. + * + * @param string|null $string + * + * @return bool + */ + public static function quiet(?string $string) + { + return !isset($string) || (trim($string) === ''); + } + /** * Blank * @@ -41,9 +59,9 @@ public static function classNames($defaults, $classes = null, $failed = '') * * @return bool */ - public static function blank(?string $value) : bool + public static function blank(?string $string) : bool { - return !isset($value) || $value === ''; + return !isset($string) || $string === ''; } /** @@ -282,4 +300,113 @@ public static function makeWords($subject, $uppercase, $separator = '_') return $uppercase ? static::uppercaseWords($words) : $words; } + /** + * Limit Length + * + * @param string $string + * @param int $limit + * @param string $end + * + * @return string + */ + public static function limit(string $string, int $limit, string $end = '') : string + { + $length = static::length($string, static::UTF8); + + if ($length <= $limit) { + return $string; + } + + $width = mb_strwidth($string, static::UTF8) - $length; + + return rtrim(mb_strimwidth($string, 0, $limit + $width, '', static::UTF8)).$end; + } + + /** + * Length + * + * @param string $string + * @param string|null $encoding + * + * @return int + */ + public static function length($string, ?string $encoding = null) : int + { + if ($encoding) { + return mb_strlen($string, $encoding); + } + + return mb_strlen($string); + } + + /** + * Maxed + * + * Is string max length + * + * @param string $string + * @param int $max + * @param string|null $encoding + * + * @return bool + */ + public static function maxed($string, int $max, ?string $encoding = null) : bool + { + return !(static::length($string, $encoding) <= $max); + } + + /** + * Min + * + * Is string min length + * + * @param string $string + * @param int $min + * @param string|null $encoding + * + * @return bool + */ + public static function min($string, int $min, ?string $encoding = null) : bool + { + return static::length($string, $encoding) >= $min; + } + + /** + * Convert the given string to lower-case. + * + * @param string $string + * @param string|null $encoding + * + * @return string + */ + public static function lower($string, ?string $encoding = null) + { + return mb_strtolower($string, $encoding ?? static::UTF8); + } + + /** + * Get Encoding + * + * @param string|null $encoding + * + * @return string + */ + public static function encoding(?string $encoding = null) : string + { + $encoding = $encoding ?? mb_internal_encoding(); + return ! static::quiet($encoding) ? $encoding : static::UTF8; + } + + /** + * Reverse + * + * @param string $string + * + * @return string + */ + public static function reverse(string $string) : string + { + return implode(array_reverse(mb_str_split($string))); + } + } \ No newline at end of file diff --git a/typerocket/vendor/typerocket/core/src/Utility/Value.php b/typerocket/vendor/typerocket/core/src/Utility/Value.php index 4a39e092..e63702f8 100644 --- a/typerocket/vendor/typerocket/core/src/Utility/Value.php +++ b/typerocket/vendor/typerocket/core/src/Utility/Value.php @@ -1,8 +1,9 @@ resolveCallable($value, $args) : $value; + return Data::value($value, $args); } /** @@ -27,32 +28,18 @@ public static function get($value, $args = null) */ public static function nils($value) { - if($value instanceof Nil) { - return new Nil($value->get()); - } - - return new Nil($value); + return Data::nil($value); } /** * @param object|array $data an array to traverse - * @param string $dots dot notation key.next.final + * @param string|array $dots dot notation key.next.final * @param mixed|null $default * * @return mixed */ public static function data($data, $dots, $default = null) { - $traverse = explode('.', $dots); - foreach ($traverse as $step) { - $v = is_object($data) ? ($data->$step ?? null) : ($data[$step] ?? null); - - if ( !isset($v) && ! is_string($data) ) { - return $default; - } - $data = $v ?? $default; - } - - return $data; + return Data::get(...func_get_args()); } } \ No newline at end of file