Skip to content

Commit

Permalink
Zukit updated to version 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-rudakov committed Apr 13, 2021
2 parents 2ceb9bd + 776751a commit a119e54
Show file tree
Hide file tree
Showing 43 changed files with 1,413 additions and 937 deletions.
43 changes: 43 additions & 0 deletions zukit/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
#### 1.2.0 / 2021-04-13
* refactoring `zukit_Singleton` to use `zukit_Logging` and `zukit_Scripts` traits
* added support for __Zukit__ version
* refactoring logging to work with `Zu Plus`
* all `log**` methods are moved to debug trait
* replaced `log_error` calls to `logс` from the new trait
* added `dump_log` method which can be overridden in a child class
* added `logfile_clean` method
* improved `debug_print` for menu and submenus arrays

* implemented `MoreActionsSlot` slot for additional actions
* support for the `hasMoreActions` key
* implemented `ZukitActionButton` component to make it easier to work with actions
* support for the `moreData` parameter in `ZukitSkeleton` component
* refactoring `selectOption` and `toggleOption` for more complete and consistent data support
* added support for array and logical operator in the `depends` argument

* added `simpleMarkdown` function for strings
* added `raw` and `json` params for `simpleMarkdown` function
* used `simpleMarkdown` in `help` elements
* used `simpleMarkdown` in notices
* replaced HTML in notices with markdown

* added `shrinked` mode for `ZukitTable` component
* added support for cell params, `markdown` and `link` cell
* added option to get table without `head`
* improved table css

* added `validate_url` method to __snippets__
* added `icons` set to __Zukit__ export
* force `$deps` to be an array in scripts params
* implemented `doing_rest` method
* added `getExternalData` function
* fixed `_doing_it_wrong` calls
* fixed bug with clearing when `debounce` is enabled in `AdvTextControl` component
* added states sync when `value` was changed outside the `AdvTextControl` component
* fixed bug with combined `data` and `status` in `onSuccessAjax` function
* fixed bug with `backdrop` color

* changed the license from GNU to MIT
* added banner and badges from img.shields.io
* other small fixes

#### 1.1.6 / 2021-03-26
* added inline style for submenu separators
* added `fillMissing` prop for `SelectItemControl` component
Expand Down
360 changes: 21 additions & 339 deletions zukit/LICENSE

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions zukit/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Zukit
# Zukit: The Developer Framework for WordPress.

_Framework serves as the basis for creating plugins or themes for WordPress._
[![Zukit Version](https://img.shields.io/github/package-json/v/picasso/zukit?style=for-the-badge)]()
[![Zukit: Tested WP Version](https://img.shields.io/github/package-json/requiresWP/picasso/zukit?color=4ab866&label=wordpress%20tested&style=for-the-badge)]()
[![Zukit Required PHP Version](https://img.shields.io/github/package-json/requiresPHP/picasso/zukit?color=bc2a8d&label=php&style=for-the-badge)](https://www.php.net/)
[![License](https://img.shields.io/github/license/picasso/zukit?color=fcbf00&style=for-the-badge)](https://github.com/picasso/zukit/blob/master/LICENSE)

The __Zukit__ framework serves as the basis for creating plugins or themes for WordPress.
Implements basic functionality for managing scripts and creating plugin or theme settings page based on Gutenberg functionality.

![ZuKit - The Developer Framework for WordPress.](https://raw.githubusercontent.com/wiki/picasso/zukit/assets/banner-1544x500.png)


## Install

To _use_ __Zukit__ framework in your project, you need to load its classes before referring to the class that inherits the framework methods. There are many ways to do this, but the easiest one is [to install the framework](https://github.com/picasso/zukit/wiki/%5BMisc%5D-Install) as a `subtree` in your project.
Expand Down
2 changes: 1 addition & 1 deletion zukit/dist/zukit-blocks.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions zukit/dist/zukit-blocks.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion zukit/dist/zukit.css

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions zukit/dist/zukit.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion zukit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "zukit",
"version": "1.1.6",
"version": "1.2.0",
"requiresWP": "5.7.0",
"requiresPHP": ">=7.1.0",
"repository": {
"type": "git",
"url": "https://github.com/picasso/zukit.git"
Expand Down
75 changes: 23 additions & 52 deletions zukit/snippets/hub.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php
include_once('traits/slugs.php');
include_once('traits/thumbnails.php');
include_once('traits/lang.php');
include_once('traits/inline.php');
include_once('traits/minify.php');
include_once('traits/date.php');
include_once('traits/classes.php');
include_once('traits/content.php');
include_once('traits/date.php');
include_once('traits/inline.php');
include_once('traits/lang.php');
include_once('traits/loader.php');
include_once('traits/minify.php');
include_once('traits/slugs.php');
include_once('traits/thumbnails.php');
include_once('traits/useful.php');

class zukit_Snippets extends zukit_Singleton {
class zukit_Snippets extends zukit_SingletonLogging {

use zusnippets_Content,
use zusnippets_Classes,
zusnippets_Content,
zusnippets_Date,
zusnippets_InlineStyle,
zusnippets_Lang,
Expand All @@ -23,52 +25,9 @@ class zukit_Snippets extends zukit_Singleton {

protected function construct_more() {
$this->prefix = 'zu_snippets';
$this->version = '1.1.6';
$this->version = '1.1.8';
$this->init_advanced_style();
}

// Classes manipulations --------------------------------------------------]

public function split_classes($classes, $as_is = false) {
$classes = is_array($classes) ? $classes : preg_split('/[\s,]+/', $classes);
$classes = array_map('trim', $classes);
return $as_is ? $classes : array_unique(array_filter($classes));
}

public function merge_classes($classes, $join = true) {
$classes = $this->split_classes($classes, $join ? false : true);
return $join ? implode(' ', $classes) : $classes;
}

public function remove_classes($classes, $remove = [], $join = true) {
$classes = $this->split_classes($classes);
foreach($remove as $test) if(in_array($test, $classes)) unset($classes[array_search($test, $classes)]);
return $join ? implode(' ', $classes) : $classes;
}

public function add_body_class($my_classes, $prefix = '') {
add_filter('body_class', function($classes) use ($my_classes, $prefix) {
$my_classes = $this->prefix_an_clean_class($classes, $my_classes, $prefix);
$classes[] = $this->merge_classes($my_classes);
return array_filter($classes);
});
}

public function add_admin_body_class($my_classes, $prefix = '') {
add_filter('admin_body_class', function($classes) use ($my_classes, $prefix) {
$classes = $this->split_classes($classes);
$my_classes = $this->prefix_an_clean_class($classes, $my_classes, $prefix);
return $this->merge_classes(array_merge($classes, array_filter($my_classes)));
});
}

private function prefix_an_clean_class($classes, $my_classes, $prefix) {
$my_classes = $this->split_classes($my_classes);
// add prefix to all classes
if(!empty($prefix)) $my_classes = preg_filter('/^/', $prefix, $my_classes);
// remove all already existing classes
return $this->remove_classes($my_classes, $classes, false);
}
}

// Common Interface to helpers ------------------------------------------------]
Expand Down Expand Up @@ -107,3 +66,15 @@ function zu_printf(...$params) {
print($output);
}
}

if(!function_exists('_zu_log')) {
function _zu_log(...$params) {
zu_snippets()->log_with(0, null, ...$params);
}
function _zu_logc($context, ...$params) {
zu_snippets()->log_with(0, $context, ...$params);
}
function _zu_logd($info, $var) {
zu_snippets()->logd($info, $var);
}
}
46 changes: 46 additions & 0 deletions zukit/snippets/traits/classes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
trait zusnippets_Classes {

// Classes manipulations --------------------------------------------------]

public function split_classes($classes, $as_is = false) {
$classes = is_array($classes) ? $classes : preg_split('/[\s,]+/', $classes);
$classes = array_map('trim', $classes);
return $as_is ? $classes : array_unique(array_filter($classes));
}

public function merge_classes($classes, $join = true) {
$classes = $this->split_classes($classes, $join ? false : true);
return $join ? implode(' ', $classes) : $classes;
}

public function remove_classes($classes, $remove = [], $join = true) {
$classes = $this->split_classes($classes);
foreach($remove as $test) if(in_array($test, $classes)) unset($classes[array_search($test, $classes)]);
return $join ? implode(' ', $classes) : $classes;
}

public function add_body_class($my_classes, $prefix = '') {
add_filter('body_class', function($classes) use ($my_classes, $prefix) {
$my_classes = $this->prefix_an_clean_class($classes, $my_classes, $prefix);
$classes[] = $this->merge_classes($my_classes);
return array_filter($classes);
});
}

public function add_admin_body_class($my_classes, $prefix = '') {
add_filter('admin_body_class', function($classes) use ($my_classes, $prefix) {
$classes = $this->split_classes($classes);
$my_classes = $this->prefix_an_clean_class($classes, $my_classes, $prefix);
return $this->merge_classes(array_merge($classes, array_filter($my_classes)));
});
}

private function prefix_an_clean_class($classes, $my_classes, $prefix) {
$my_classes = $this->split_classes($my_classes);
// add prefix to all classes
if(!empty($prefix)) $my_classes = preg_filter('/^/', $prefix, $my_classes);
// remove all already existing classes
return $this->remove_classes($my_classes, $classes, false);
}
}
2 changes: 1 addition & 1 deletion zukit/snippets/traits/inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ trait zusnippets_InlineStyle {
private $advanced_style = [];
private $admin_style = [];
private $fonts = [];
private $without_minify = false;
private $without_minify = false; // set 'true' for debuging

private function init_advanced_style() {
if(is_admin()) add_action('admin_footer', [$this, 'maybe_add_advanced_styles']);
Expand Down
3 changes: 1 addition & 2 deletions zukit/snippets/traits/thumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ public function get_background_image($image_url = null, $post_id = null, $with_q
}

public function get_background_color($post_or_attachment_id = null) {

$color = $this->get_dominant($post_or_attachment_id);
$color = function_exists('zumedia') ? zumedia()->get_dominant_by_id($post_or_attachment_id) : 'black';
$color_bg = empty($color) ? '' : 'background-color:'.$color.';';
return $color_bg;
}
Expand Down
22 changes: 18 additions & 4 deletions zukit/snippets/traits/useful.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ public function insert_svg_from_file($path, $name, $params) {
empty($subdir) ? '' : '/'
);
if(!file_exists($filepath)) {

$this->log_error([
$this->logc('?SVG file not found!', [
'path' => $path,
'name' => $name,
'params' => $params,
'filepath' => $filepath,
], 'SVG file not found!');

]);
return '';
}

Expand All @@ -72,6 +70,22 @@ public function insert_svg_from_file($path, $name, $params) {
return $this->remove_space_between_tags($svg);
}

// Checks the validity of the URL
// With default parameters, URLs without protocol and domain are considered valid (relative URLs)
// using arguments, you can specify whether the presence of the domain and the protocol is necessary
public function validate_url($value, $maybe_without_domain = true, $maybe_without_protocol = true) {
$protocol = preg_match('#^https?://#i', $value) ? preg_replace('#(^https?://)(.*)#i', '$1', $value) : '';
$domain_missing = !preg_match('#((?:(?:(?:\w[\.\-\+]?)*)\w)+)((?:(?:(?:\w[\.\-\+]?){0,62})\w)+)\.(\w{2,6})#', $value);
$site_url = ltrim(get_site_url(null, '', 'http'), 'http://');

$test_url = sprintf('%1$s%2$s%3$s',
$maybe_without_protocol && empty($protocol) ? 'https://' : $protocol,
empty($protocol) && $maybe_without_domain && $domain_missing ? $site_url : '',
str_replace($protocol, '', $domain_missing ? preg_replace('#^([^/])#', ' $1', $value) : $value)
);
return filter_var($test_url, FILTER_VALIDATE_URL) !== false;
}

public function to_bool($value) {
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
}
Expand Down
Binary file added zukit/src/images/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added zukit/src/images/idraw/banner.idraw
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion zukit/src/sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ $folders-blue: rgb(0, 117, 175);
$link-color-hover: rgba($folders-blue, 0.8);
$link-color-selected: #016087;
$breadcrumb-color: $wp-gray-700;

$text-shadow-for-white: 0 1px 3px rgba(black, 0.3) !default;

$facebook-color: #3b5998;
$twitter-color: #00aced;
Expand Down Expand Up @@ -215,6 +215,7 @@ $admin-control-font-family: Ubuntu,'Open Sans','Helvetica Neue',sans-serif;
$admin-control-selected-color: rgba($admin-control-highlight-color, 0.3);
$admin-control-text-color: $admin-dark;

$admin-border-radius: 3px;
$admin-button-wrapper-padding: 3px;
$admin-button-wrapper-margin: 4px;
$admin-control-border-box-size: 3px;
Expand Down
8 changes: 6 additions & 2 deletions zukit/src/sass/components/_adv-text-control.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ $advtext-help-margin: -16px; // margin 8px * 2
.components-button {
height: $advtext-button-height;
width: $advtext-button-width;
min-width: $advtext-button-width;
color: $custom-button-text-color;
background-color: $custom-button-color;
border: 1px solid $custom-button-border-color;
border-radius: 0 3px 3px 0;
box-shadow: none;
transition: background-color $transition-time $transition-function;
position: relative;

span.dashicons {
padding-left: 2px;
.dashicon {
margin: 0;
padding-left: 1px;
}

&.__with-label {
Expand Down
24 changes: 24 additions & 0 deletions zukit/src/sass/components/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,29 @@ $table-basic-font-size: 14px;
&.__zu_strong {
font-weight: 700;
}
&.__zu_shrink, &.__zu_fixwidth {
flex-grow: 0;
flex-basis: auto;
}
&.__zu_fixwidth {
width: 10%;
// flex-grow: 0;
// flex-basis: auto;
}
&.__zu_markdown {
// margin: 0;
// font-size: $table-basic-font-size;
// font-style: normal;
// text-align: ;

}
&.__zu_link {
a {
text-decoration: none;
}
}
&.__zu_filler {
flex-grow: 3;
}
}
}
Loading

0 comments on commit a119e54

Please sign in to comment.