first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,209 @@
{
"kind": "standartfonts#standartfonts",
"items": [
{
"kind": "standartfonts#standartfonts",
"family": "Arial, Helvetica",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfonts",
"family": "Arial Black, Gadget",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Bookman Old Style",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Comic Sans MS",
"category": "cursive",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Courier",
"category": "monospace",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Garamond",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Georgia",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Impact, Charcoal",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Lucida Console, Monaco",
"category": "monospace",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Lucida Sans Unicode, Lucida Grande",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "MS Sans Serif, Geneva",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "MS Serif, New York",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Palatino Linotype, Book Antiqua, Palatino",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Tahoma, Geneva",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Times New Roman, Times",
"category": "serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Trebuchet MS, Helvetica",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
},
{
"kind": "standartfonts#standartfont",
"family": "Verdana, Geneva",
"category": "sans-serif",
"variants": [
"regular",
"italic",
"700",
"700italic"
],
"subsets": ["latin"]
}
]
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Iconpicker customizer control
*
* @package Cherry_Framework
* @subpackage Modules/Customizer
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
if ( class_exists( 'WP_Customize_Control' ) ) {
/**
* Iconpicker control for customizer
*/
class Cherry_WP_Customize_Iconpicker extends WP_Customize_Control {
/**
* Icons data array
*
* @see cherry-ui-elements/inc/ui-elements/ui-iconpicker/ui-iconpicker.php for data array format.
* @var array
*/
public $icon_data = array();
/**
* Trigger to try automatically parse icons from CSS file or not.
*
* @var boolean
*/
public $auto_parse = false;
/**
* UI instance
*
* @var object
*/
private $iconpicker = null;
/**
* Render the control's content.
*/
public function render_content() {
?>
<label>
<span class="customize-control-title">
<?php echo esc_html( $this->label ); ?>
</span>
<?php if ( isset( $this->description ) ) : ?>
<span class="description customize-control-description">
<?php echo wp_kses_post( $this->description ); ?>
</span>
<?php endif; ?>
</label>
<?php
echo str_replace(
'id="' . $this->id . '"',
'id="' . $this->id . '" ' . $this->get_link(),
$this->iconpicker->render()
);
}
/**
* Enqueue assets
*/
public function enqueue() {
$core = apply_filters( 'cherry_customizer_get_core', false );
$ui_builder = $core->init_module(
'cherry-ui-elements',
array(
'ui_elements' => array( 'iconpicker' ),
)
);
$args = array(
'type' => 'iconpicker',
'id' => $this->id,
'name' => $this->id,
'value' => $this->value(),
'icon_data' => $this->icon_data,
'auto_parse' => $this->auto_parse,
);
add_action( 'customize_controls_print_styles', array( $this, 'print_sets' ) );
$this->iconpicker = $ui_builder->get_ui_element_instance( 'iconpicker', $args );
$this->iconpicker->enqueue_assets();
}
/**
* Print JS var with sets data
*
* @return void
*/
public function print_sets() {
$this->iconpicker->prepare_icon_set();
UI_Iconpicker::$printed = false;
$this->iconpicker->print_icon_set();
}
}
}

View File

@@ -0,0 +1,379 @@
<?php
/**
* Module Name: Database Updater
* Description: Handle database updates if required.
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Db_Updater
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Db_Updater' ) ) {
/**
* Class Cherry Db Updater.
*
* @since 1.0.0
*/
class Cherry_Db_Updater {
/**
* Module arguments.
*
* @since 1.0.0
* @var array
*/
private $args = array(
'callbacks' => array(),
'slug' => null,
'version' => null,
);
/**
* Option key for DB version.
*
* @since 1.0.0
* @var string
*/
protected $version_key = '%s-db-version';
/**
* Nonce format.
*
* @since 1.0.0
* @var string
*/
protected $nonce = '_%s-db-update-nonce';
/**
* Messages array.
*
* @since 1.0.0
* @var array
*/
protected $messages = array();
/**
* Update done trigger.
*
* @since 1.0.0
* @var bool
*/
protected $updated = false;
/**
* Core instance.
*
* @since 1.0.0
* @var object
*/
public $core = null;
/**
* Cherry_Db_Updater constructor.
*
* @since 1.0.0
* @return void
*/
public function __construct( $core = null, $args = array() ) {
$this->core = $core;
$this->args = wp_parse_args( $args, $this->args );
if ( ! is_admin() || ! current_user_can( 'update_plugins' ) ) {
return;
}
add_action( 'admin_notices', array( $this, 'init_notices' ) );
add_action( 'admin_init', array( $this, 'do_update' ) );
$this->messages = array(
'error' => esc_html__( 'Module DB Updater init error in %s - version and slug is required arguments', 'cherry-framework' ),
'update' => esc_html__( 'We need to update your database to the latest version.', 'cherry-framework' ),
'updated' => esc_html__( 'Update complete, thank you for updating to the latest version!', 'cherry-framework' ),
);
}
/**
* Process DB update.
*
* @since 1.0.0
*/
public function do_update() {
if ( ! $this->is_current_update() ) {
return;
}
$callbacks = $this->prepare_callbacks();
if ( ! empty( $callbacks ) ) {
foreach ( $callbacks as $callback ) {
if ( is_callable( $callback ) ) {
call_user_func( $callback );
}
}
}
$this->set_updated();
}
/**
* Finalize update.
*
* @since 1.0.0
*/
public function set_updated() {
$this->updated = true;
$option = sprintf( $this->version_key, esc_attr( $this->args['slug'] ) );
update_option( $option, esc_attr( $this->args['version'] ) );
}
/**
* Prepare callbacks array.
*
* @since 1.0.0
* @return array
*/
private function prepare_callbacks() {
$callbacks = array();
if ( empty( $this->args['callbacks'] ) ) {
return $callbacks;
}
ksort( $this->args['callbacks'] );
foreach ( $this->args['callbacks'] as $ver => $ver_cb ) {
if ( version_compare( $this->get_current_version(), $ver, '<' ) ) {
$callbacks = array_merge( $callbacks, $ver_cb );
}
}
return $callbacks;
}
/**
* Check if we processed update for plugin passed in arguments.
*
* @since 1.0.0
* @return bool
*/
private function is_current_update() {
if ( empty( $_GET['cherry_db_update'] ) || empty( $_GET['slug'] ) || empty( $_GET['_nonce'] ) ) {
return false;
}
if ( $_GET['slug'] !== $this->args['slug'] ) {
return false;
}
$nonce_action = sprintf( $this->nonce, esc_attr( $this->args['slug'] ) );
if ( ! wp_verify_nonce( $_GET['_nonce'], $nonce_action ) ) {
return false;
}
return true;
}
/**
* Init admin notices.
*
* @since 1.0.0
* @return void
*/
public function init_notices() {
$enabled = $this->validate_module_args();
if ( ! $enabled ) {
return;
}
$slug = esc_attr( $this->args['slug'] );
if ( $this->is_update_required() ) {
$this->show_notice( $slug );
}
if ( $this->is_updated() ) {
$this->show_updated_notice( $slug );
}
}
/**
* Returns current DB version.
*
* @since 1.0.0
* @return string
*/
private function get_current_version() {
$option = sprintf( $this->version_key, esc_attr( $this->args['slug'] ) );
return get_option( $option, '1.0.0' );
}
/**
* Check if database requires update.
*
* @since 1.0.0
* @return bool
*/
private function is_update_required() {
$current = $this->get_current_version();
return version_compare( $current, esc_attr( $this->args['version'] ), '<' );
}
/**
* Check if update was succesfully done.
*
* @since 1.0.0
* @return bool
*/
private function is_updated() {
if ( ! $this->is_current_update() ) {
return false;
}
return (bool) $this->updated;
}
/**
* Validate module arguments.
*
* @since 1.0.0
* @return bool
*/
private function validate_module_args() {
if ( empty( $this->args['slug'] ) || empty( $this->args['version'] ) ) {
echo '<div class="error"><p>';
printf(
$this->messages['error'],
'<b>' . str_replace( untrailingslashit( ABSPATH ), '', $this->core->settings['base_dir'] ) . '</b>'
);
echo '</p></div>';
return false;
}
return true;
}
/**
* Show notice.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function show_notice( $slug ) {
echo '<div class="notice notice-info">';
echo '<p>';
$this->notice_title( $slug );
echo $this->messages['update'];
echo '</p>';
echo '<p>';
$this->notice_submit( $slug );
echo '</p>';
echo '</div>';
}
/**
* Show update notice.
*
* @since 1.0.0
* @return void
*/
private function show_updated_notice() {
$slug = esc_attr( $this->args['slug'] );
echo '<div class="notice notice-success is-dismissible">';
echo '<p>';
$this->notice_title( $slug );
echo $this->messages['updated'];
echo '</p>';
echo '</div>';
}
/**
* Show plugin notice submit button.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function notice_submit( $slug = '' ) {
$format = '<a href="%1s" class="button button-primary">%2$s</a>';
$label = esc_html__( 'Start Update', 'cherry-framework' );
$url = add_query_arg(
array(
'cherry_db_update' => true,
'slug' => $slug,
'_nonce' => $this->create_nonce( $slug ),
),
esc_url( admin_url( 'index.php' ) )
);
printf( $format, $url, $label );
}
/**
* Create DB update nonce.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return string
*/
private function create_nonce( $slug ) {
return wp_create_nonce( sprintf( $this->nonce, $slug ) );
}
/**
* Show plugin notice title.
*
* @since 1.0.0
* @param string $slug Plugin slug.
* @return void
*/
private function notice_title( $slug ) {
$name = str_replace( '-', ' ', $slug );
$name = ucwords( $name );
printf( '<strong>%1$s %2$s</strong> &#8211; ', $name, esc_html__( 'Data Update', 'cherry-framework' ) );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core = null, $args = array() ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,24 @@
/**
* Handler for CSS Collector
*/
function CherryCSSCollector() {
'use strict';
var style,
collectedCSS = window.CherryCollectedCSS;
if ( undefined !== collectedCSS ) {
style = document.createElement( 'style' );
style.setAttribute( 'title', collectedCSS.title );
style.setAttribute( 'type', collectedCSS.type );
style.textContent = collectedCSS.css;
document.head.appendChild( style );
}
}
CherryCSSCollector();

View File

@@ -0,0 +1 @@
function CherryCSSCollector(){"use strict";var t,e=window.CherryCollectedCSS;void 0!==e&&(t=document.createElement("style"),t.setAttribute("title",e.title),t.setAttribute("type",e.type),t.textContent=e.css,document.head.appendChild(t))}CherryCSSCollector();

View File

@@ -0,0 +1,543 @@
<?php
/**
* Module Name: Dynamic CSS
* Description: CSS parser which uses variables & functions for CSS code optimization
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Dynamic_Css' ) ) {
/**
* Dynamic CSS parser
*/
class Cherry_Dynamic_Css {
/**
* Module arguments
*
* @var array
*/
public $args = array();
/**
* Core instance
*
* @var object
*/
public $core = null;
/**
* Holder for processed variables array
*
* @var array
*/
public $variables = null;
/**
* Variable pattern
*
* @var array
*/
public $var_pattern = '/\$(([-_a-zA-Z0-9]+)(\[[\'\"]*([-_a-zA-Z0-9]+)[\'\"]*\])?({([a-z%]+)})?)/';
/**
* Function pattern
*
* @var array
*/
public $func_pattern = '/@(([a-zA-Z_]+)\(([^@\)]*)?\))/';
/**
* Collector instance holder
*
* @since 1.2.0
* @var object
*/
public static $collector = null;
/**
* Reserved words list
*
* @since 1.4.0
* @var array
*/
public $css_reserved = array(
'media',
'supports',
);
/**
* Constructor for the module
*/
function __construct( $core, $args ) {
$this->core = $core;
$this->args = wp_parse_args( $args, array(
'prefix' => 'blank',
'type' => 'theme_mod',
'parent_handle' => false,
'single' => true,
'css_files' => null,
'options' => array(),
) );
$this->init_dynamic_css();
$this->init_collector();
}
/**
* Initalize dynamic CSS with fallback compatibility.
*
* @since 1.3.0
* @return void
*/
public function init_dynamic_css() {
/**
* Not actual for now, required only for fallback compatibility.
*/
if ( empty( $this->args['parent_handle'] ) ) {
add_action( 'wp_head', array( $this, 'print_inline_css' ), 99 );
}
add_action( 'wp_enqueue_scripts', array( $this, 'add_inline_css' ), 99 );
}
/**
* Adds inline CSS into queue
*
* @since 1.3.0
* @return void
*/
public function add_inline_css() {
wp_add_inline_style( $this->args['parent_handle'], $this->get_inline_css() );
}
/**
* Initalize CSS collector class
*
* @since 1.2.0
* @return bool
*/
public function init_collector() {
if ( null !== self::$collector ) {
return true;
}
require_once 'inc/class-cherry-dynamic-css-collector.php';
ob_start();
include 'assets/min/cherry-css-collector.min.js';
$handler = ob_get_clean();
self::$collector = Cherry_Dynamic_Css_Collector::get_instance( $handler );
add_action( 'wp_footer', array( self::$collector, 'print_style' ), 11 );
add_action( 'wp_footer', array( self::$collector, 'add_js_handler' ), 11 );
return true;
}
/**
* Add new style to collector
*
* @since 1.2.0
* @param string $selector CSS selector to add styles for.
* @param array $style Styles array to add.
* @param array $media Media breakpoints.
* @return void
*/
public function add_style( $selector, $style = array(), $media = array() ) {
if ( ! $selector ) {
return;
}
self::$collector->add_style( $selector, $style, $media );
}
/**
* Get CSS variables into array
*
* @since 1.0.0
* @return array dynamic CSS variables
*/
public function get_css_varaibles() {
if ( null !== $this->variables ) {
return $this->variables;
}
$variables = $this->get_standard_vars();
$var_list = ! empty( $this->args['options'] ) ? $this->args['options'] : array();
/**
* Filter options names list to use it as varaibles
*
* @since 1.0.0
* @param array $var_list default variables list.
* @param array $this->args module arguments.
*/
$var_list = apply_filters( 'cherry_css_var_list', $var_list, $this->args );
if ( empty( $var_list ) ) {
return $variables;
}
$custom_vars = array();
foreach ( $var_list as $var ) {
$custom_vars[ $var ] = $this->get_setting( $var );
}
$variables = array_merge( $variables, $custom_vars );
/**
* Filter result variables list with values
*
* @since 1.0.0
* @param array $variables default variables list.
* @param array $this->args module arguments.
*/
$this->variables = apply_filters( 'cherry_css_variables', $variables, $this->args );
return $this->variables;
}
/**
* Get current setting by name
*
* @since 1.0.0
* @return mixed
*/
public function get_setting( $name ) {
$type = $this->args['type'];
if ( 'theme_mod' == $type ) {
$setting = get_theme_mod( $name );
return $setting;
}
if ( true != $this->args['single'] ) {
$setting = get_option( $name );
return $setting;
}
$settings = get_option( $this->args['prefix'] );
if ( ! empty( $settings ) && isset( $settings[ $name ] ) ) {
return $settings[ $name ];
}
return false;
}
/**
* Get standard WordPress variables from customizer - header image, background image etc.
*
* @since 1.0.0
* @return array
*/
public function get_standard_vars() {
$standard_vars = array(
'header_image',
'background_image',
'background_repeat',
'background_position_x',
'background_attachment',
);
$result = array();
foreach ( $standard_vars as $var ) {
$result[ $var ] = get_theme_mod( $var );
}
return $result;
}
/**
* Get avaliable functions into array
*
* @since 1.0.0
* @return array dynamic CSS variables
*/
public function get_css_functions() {
require_once 'inc/class-cherry-dynamic-css-utilities.php';
$utilities = Cherry_Dynamic_Css_Utilities::get_instance();
$func_list = array(
'darken' => array( $utilities, 'color_darken' ),
'lighten' => array( $utilities, 'color_lighten' ),
'contrast' => array( $utilities, 'color_contrast' ),
'alpha' => array( $utilities, 'color_alpha' ),
'background' => array( $utilities, 'background_css' ),
'background_url' => array( $utilities, 'background_url' ),
'typography' => array( $utilities, 'get_typography_css' ),
'box' => array( $utilities, 'get_box_model_css' ),
'emph' => array( $utilities, 'element_emphasis' ),
'font_family' => array( $utilities, 'typography_font_family' ),
'font_size' => array( $utilities, 'typography_size' ),
'container_compare' => array( $utilities, 'container_width_compare' ),
'sum' => array( $utilities, 'simple_sum' ),
'diff' => array( $utilities, 'simple_diff' ),
'menu_toogle_endpoint' => array( $utilities, 'menu_toogle_endpoint' ),
);
/**
* Filter available CSS functions list
*
* @since 1.0.0
* @param array $func_list default functions list.
* @param array $this->args module arguments.
*/
return apply_filters( 'cherry_css_func_list', $func_list, $this->args );
}
/**
* Parse CSS string and replasce varaibles and functions
*
* @since 1.0.0
* @param [type] $css CSS to parse.
* @return string
*/
public function parse( $css ) {
$replce_vars = preg_replace_callback( $this->var_pattern, array( $this, 'replace_vars' ), $css );
$replace_func = preg_replace_callback( $this->func_pattern, array( $this, 'replace_func' ), $replce_vars );
$result = preg_replace( '/\t|\r|\n|\s{2,}/', '', $replace_func );
return $result;
}
/**
* Returns complied dynamic CSS string.
*
* @since 1.3.0
* @return string|bool false
*/
public function get_inline_css() {
if ( ! $this->args['css_files'] ) {
return false;
}
if ( ! is_array( $this->args['css_files'] ) ) {
$this->args['css_files'] = array( $this->args['css_files'] );
}
/**
* Filter CSS reserved words list
*
* @since 1.4.0
* @var array
*/
$this->css_reserved = apply_filters( 'cherry_dynamic_css_reserved_words_list', $this->css_reserved );
ob_start();
foreach ( $this->args['css_files'] as $file ) {
if ( ! file_exists( $file ) ) {
continue;
}
include $file;
}
/**
* Allow to include custom dynamic CSS files
*
* @since 1.0.0
* @param array $this->args Current dynamic CSS arguments array.
* @param array $this->core Current core instance.
*/
do_action( 'cherry_dynamic_css_include_custom_files', $this->args, $this->core );
$css = ob_get_clean();
$parsed_css = $this->parse( $css );
/**
* Filter parsed dynamic CSS
*
* @since 1.0.0
* @param string $parsed_css default functions list.
* @param array $this->args module arguments.
*/
$parsed_css = apply_filters( 'cherry_dynamic_css_parsed_styles', $parsed_css, $this->args );
return $parsed_css;
}
/**
* Print inline CSS after current theme stylesheet
*
* @since 1.0.0
* @return void|bool false
*/
public function print_inline_css() {
$parsed_css = $this->get_inline_css();
if ( empty( $parsed_css ) ) {
return false;
}
printf( '<style type="text/css">%s</style>', $parsed_css );
}
/**
* Callback function to replace CSS vars
*
* @since 1.0.0
* @param [string] $matches founded vars.
*/
function replace_vars( $matches ) {
$not_found = '/* Variable not found */';
// check if variable name found
if ( empty( $matches[2] ) ) {
return $not_found;
}
$variables = $this->get_css_varaibles();
// check if var exists
if ( ! array_key_exists( $matches[2], $variables ) ) {
return $not_found;
}
$val = $variables[ $matches[2] ];
$maybe_units = '';
// check if we need to add units after value
if ( ! empty( $matches[6] ) ) {
$maybe_units = $matches[6];
}
// check if we search for array val
if ( ! empty( $matches[4] ) && is_array( $val ) && isset( $val[ $matches[4] ] ) ) {
return $val[ $matches[4] ] . $maybe_units;
}
if ( ! is_array( $val ) ) {
return $val . $maybe_units;
} else {
return $matches[0];
}
}
/**
* Callback function to replace CSS functions
*
* @since 1.0.0
* @param [string] $matches founded dunction.
*/
function replace_func( $matches ) {
$not_found = '/* Function does not exist */';
// check if functions name found
if ( empty( $matches[2] ) ) {
return $not_found;
}
$functions = $this->get_css_functions();
// check if function exists and is not CSS-reserved word
if ( ! array_key_exists( $matches[2], $functions ) ) {
if ( is_array( $this->css_reserved ) && in_array( $matches[2], $this->css_reserved ) ) {
return $matches[0];
} else {
return $not_found;
}
}
$function = $functions[ $matches[2] ];
$args = isset( $matches[3] ) ? $matches[3] : array();
if ( empty( $args ) ) {
$result = call_user_func( $function );
return $result;
}
if ( 'font_family' == $matches[2] ) {
$result = call_user_func( $function, $args );
return $result;
}
$args = str_replace( ' ', '', $args );
$args = explode( ',', $args );
if ( ! is_callable( $function ) ) {
return $not_found;
}
if ( ! empty( $args ) ) {
$args = array_map( array( $this, 'prepare_args' ), $args );
}
$result = call_user_func_array( $function, $args );
return $result;
}
/**
* Filter user function arguments
*
* @since 1.0.0
*/
function prepare_args( $item ) {
$name = str_replace( '$', '', $item );
$variables = $this->get_css_varaibles();
if ( ! array_key_exists( $name, $variables ) ) {
return $item;
}
return $variables[ $name ];
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,282 @@
<?php
/**
* Dynamic CSS collector class.
*
* @package Cherry_Framework
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Dynamic_Css_Collector' ) ) {
/**
* Define Cherry_Dynamic_Css_Collector class
*/
class Cherry_Dynamic_Css_Collector {
/**
* A reference to an instance of this class.
*
* @since 1.2.0
* @var object
*/
private static $instance = null;
/**
* Array with sorted css
*
* @var array
*/
public static $sorted_css = array();
/**
* Apropriate JS handle name
*
* @var string
*/
public static $js_handle = 'cherry-js-core';
/**
* Passed handler file content
*
* @var string
*/
public static $handler_file = null;
/**
* Set handler file on construct
*/
function __construct( $handler_file = null ) {
self::$handler_file = $handler_file;
}
/**
* Add new style to collector
*
* @param string $selector CSS selector to add styles for.
* @param array $style Styles array to add.
* @param array $media Media breakpoints.
* @return void
*/
public function add_style( $selector, $style = array(), $media = array() ) {
$this->prepare_rule(
$selector,
array(
'style' => $style,
'media' => $media,
)
);
}
/**
* Return JS handle name
*
* @return string
*/
public function get_handle() {
return apply_filters( 'cherry_dynamic_css_collector_handle', self::$js_handle );
}
/**
* Add inline JS handler
*
* @return void
*/
public function add_js_handler() {
if ( ! self::$handler_file ) {
return;
}
wp_add_inline_script( $this->get_handle(), self::$handler_file );
}
/**
* Print grabbed CSS
*
* @return void
*/
public function print_style() {
self::$sorted_css = apply_filters(
'cherry_dynamic_css_collected_styles',
self::$sorted_css
);
if ( empty( self::$sorted_css ) || ! is_array( self::$sorted_css ) ) {
return;
}
ob_start();
do_action( 'cherry_dynamic_css_before_print_collected' );
array_walk( self::$sorted_css, array( $this, 'print_breakpoint' ) );
do_action( 'cherry_dynamic_css_after_print_collected' );
$styles = ob_get_clean();
$localize_var = apply_filters( 'cherry_dynamic_css_collector_localize_object', array(
'type' => 'text/css',
'title' => 'cherry-collected-dynamic-style',
'css' => $styles,
) );
wp_localize_script( $this->get_handle(), 'CherryCollectedCSS', $localize_var );
}
/**
* Print single breakpoint
*
* @param array $rules Rules array.
* @param string $breakpoint Breakpoint name.
* @return void
*/
public function print_breakpoint( $rules, $breakpoint ) {
if ( empty( $rules ) ) {
return;
}
if ( 'all' !== $breakpoint ) {
echo '@' . esc_attr( $breakpoint ) . ' {';
}
do_action( 'cherry_dynamic_css_breakpoint_start', $breakpoint );
array_walk( $rules, array( $this, 'print_rules' ) );
do_action( 'cherry_dynamic_css_breakpoint_end', $breakpoint );
if ( 'all' !== $breakpoint ) {
echo '}';
}
}
/**
* Print rules for selector.
*
* @param array $rule Single rule.
* @param string $selector Selector name.
* @return void
*/
public function print_rules( $rule, $selector ) {
echo esc_attr( $selector ) . ' {';
do_action( 'cherry_dynamic_css_rule_start', $selector );
array_walk( $rule, array( $this, 'print_property' ) );
do_action( 'cherry_dynamic_css_rule_end', $selector );
echo '}';
}
/**
* Print single rule.
*
* @param string $value Property value.
* @param string $name Property name.
* @return void
*/
public function print_property( $value, $name ) {
printf( '%1$s:%2$s; ', $name, $value );
}
/**
* Print passed rule.
*
* @param string $selector Selector name.
* @param array $rule CSS rule data.
* @return void|bool
*/
public function prepare_rule( $selector, $rule ) {
$rule = array_merge( array(
'style' => array(),
'media' => array(),
), $rule );
if ( empty( $rule['style'] ) ) {
return false;
}
$breakpoint = $this->breakpoint_name( $rule['media'] );
if ( ! isset( self::$sorted_css[ $breakpoint ] ) ) {
self::$sorted_css[ $breakpoint ] = array();
}
if ( isset( self::$sorted_css[ $breakpoint ][ $selector ] ) ) {
self::$sorted_css[ $breakpoint ][ $selector ] = array_merge(
self::$sorted_css[ $breakpoint ][ $selector ],
$rule['style']
);
} else {
self::$sorted_css[ $breakpoint ][ $selector ] = $rule['style'];
}
}
/**
* Generate media rule name
*
* @param array $media Media breakpoints.
* @return string
*/
public function breakpoint_name( $media ) {
$has_media = false;
$min = '';
$max = '';
$sep = '';
if ( ! empty( $media['min'] ) ) {
$has_media = true;
$min = sprintf( '(min-width: %1$s)', esc_attr( $media['min'] ) );
}
if ( ! empty( $media['max'] ) ) {
$sep = true === $has_media ? ' and ' : '';
$has_media = true;
$max = sprintf( '(max-width: %1$s)', esc_attr( $media['max'] ) );
}
if ( ! $has_media ) {
return 'all';
}
return sprintf( 'media %1$s%3$s%2$s', $min, $max, $sep );
}
/**
* Returns the instance.
*
* @since 1.2.0
* @return object
*/
public static function get_instance( $handler_file = null ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $handler_file );
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,858 @@
<?php
/**
* Define CSS functions callbacks
*
* @package package_name
* @author Cherry Team
* @license GPL-3.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Dynamic_Css_Utilities' ) ) {
/**
* Define Cherry_Dynamic_Css_Utilities class
*/
class Cherry_Dynamic_Css_Utilities {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Make passed color darken.
*
* @since 1.0.0
* @param [string] $color HEX or RGB(A) color value.
* @param [float] $darken Darken percent (0-100).
* @return string Processed color.
*/
public function color_darken( $color, $darken = 0 ) {
if ( ! $color ) {
return false;
}
$prepared_data = $this->prepare_color_mod( $color, $darken );
if ( ! $prepared_data || ! is_array( $prepared_data ) ) {
return false;
}
$r = $prepared_data['r'];
$g = $prepared_data['g'];
$b = $prepared_data['b'];
$a = $prepared_data['a'];
$percent = $prepared_data['percent'];
// Calc darken vals.
$r = round( $r - 255 * $percent, 0 );
$g = round( $g - 255 * $percent, 0 );
$b = round( $b - 255 * $percent, 0 );
$r = $r < 0 ? 0 : $r;
$g = $g < 0 ? 0 : $g;
$b = $b < 0 ? 0 : $b;
if ( false !== $a ) {
return sprintf( 'rgba(%s,%s,%s,%s)', $r, $g, $b, $a );
} else {
return sprintf( 'rgb(%s,%s,%s)', $r, $g, $b );
}
}
/**
* Make passed color lighten.
*
* @since 1.0.0
* @param [string] $color HEX or RGB(A) color value.
* @param [float] $lighten Lighten percent (0-100).
* @return string Processed color.
*/
public function color_lighten( $color, $lighten = 0 ) {
if ( ! $color ) {
return false;
}
$prepared_data = $this->prepare_color_mod( $color, $lighten );
if ( ! $prepared_data || ! is_array( $prepared_data ) ) {
return false;
}
$r = $prepared_data['r'];
$g = $prepared_data['g'];
$b = $prepared_data['b'];
$a = $prepared_data['a'];
$percent = $prepared_data['percent'];
// Calc lighten vals
$r = round( $r + 255 * $percent, 0 );
$g = round( $g + 255 * $percent, 0 );
$b = round( $b + 255 * $percent, 0 );
$r = $r > 255 ? 255 : $r;
$g = $g > 255 ? 255 : $g;
$b = $b > 255 ? 255 : $b;
if ( false !== $a ) {
return sprintf( 'rgba(%s,%s,%s,%s)', $r, $g, $b, $a );
} else {
return sprintf( 'rgb(%s,%s,%s)', $r, $g, $b );
}
}
/**
* Convert passed color into RGBa with passed opacity.
*
* @since 1.0.0
* @param [string] $color Color to convert.
* @param [integer] $opacity Opacity.
* @return string
*/
public function color_alpha( $color, $opacity = 100 ) {
if ( ! $color ) {
return false;
}
$prepared_data = $this->prepare_color_mod( $color, 100 );
if ( ! $prepared_data || ! is_array( $prepared_data ) ) {
return false;
}
$r = $prepared_data['r'];
$g = $prepared_data['g'];
$b = $prepared_data['b'];
$a = intval( $opacity ) / 100;
return sprintf( 'rgba(%s,%s,%s,%s)', $r, $g, $b, $a );
}
/**
* Select contrast color for passed from 2 proposed.
*
* 1st proposed color must be light - it will selected if passed color is dark,
* 2nd selected if passed is light, so it must be darken.
*
* @since 1.0.0
* @param [string] $color Color to get contrast for.
* @param [string] $if_dark Return this if we had dark color.
* @param [string] $if_light Return this if we had light color.
* @return string Color.
*/
public function color_contrast( $color, $if_dark = '#ffffff', $if_light = '#000000' ) {
if ( ! $color ) {
return false;
}
$prepared_data = $this->prepare_color_mod( $color, 100 );
if ( ! $prepared_data || ! is_array( $prepared_data ) ) {
return false;
}
$r = $prepared_data['r'];
$g = $prepared_data['g'];
$b = $prepared_data['b'];
$luminance = 0.299 * $r + 0.587 * $g + 0.114 * $b;
if ( $luminance >= 128 ) {
return $if_light;
} else {
return $if_dark;
}
}
/**
* Prepare color to modify.
*
* Bring passed color and change percent to array
* with R, G, B color values, opacity (if provided)
* and change percentage.
*
* @since 1.0.0
* @param [string] $color HEX or RGB(A) color value.
* @param [float] $percent Modify percent (0-100).
* @return array Prepared color and modify percent.
*/
public function prepare_color_mod( $color, $percent = 0 ) {
$is_rgba = ( false !== strpos( $color, 'rgba' ) ) ? true : false;
$is_rgb = ( false !== strpos( $color, 'rgb' ) && false === $is_rgba ) ? true : false;
$is_hex = ( false === $is_rgba && false === $is_rgb ) ? true : false;
$percent = round( (double) $percent / 100, 4 );
if ( $is_hex && '#' == $color[0] ) {
$color = substr( $color, 1 );
}
// Prepare hex color.
if ( $is_hex && strlen( $color ) == 6 ) {
list( $r, $g, $b ) = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
} elseif ( $is_hex && strlen( $color ) == 3 ) {
list( $r, $g, $b ) = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
} elseif ( $is_hex ) {
return false;
}
if ( $is_hex ) {
$r = hexdec( $r );
$g = hexdec( $g );
$b = hexdec( $b );
}
$color = str_replace( ' ', '', $color );
// Prepare RGBA.
if ( $is_rgba ) {
preg_match( '/rgba\((.*)\)/', $color, $matches );
if ( ! is_array( $matches ) || empty( $matches[1] ) ) {
return false;
}
list( $r, $g, $b, $a ) = explode( ',', $matches[1] );
}
// Prepare RGB.
if ( $is_rgb ) {
preg_match( '/rgb\((.*)\)/', $color, $matches );
if ( ! is_array( $matches ) || empty( $matches[1] ) ) {
return false;
}
list( $r, $g, $b ) = explode( ',', $matches[1] );
}
$result = array(
'r' => $r,
'g' => $g,
'b' => $b,
'a' => isset( $a ) ? $a : false,
'percent' => $percent,
);
return $result;
}
/**
* Get background-image CSS property CSS by url.
*
* @param [string] $url url-value.
* @return string
*/
public function background_url( $url = '' ) {
if ( empty( $url ) ) {
return;
}
$result = 'background-image: url(' . esc_url( $url ) . ')';
return $result;
}
/**
* Get background CSS by bg data from options and selector.
* If passed multiplie images - returns retina ready CSS.
*
* @since 1.0.0
* @param [string] $selector CSS selector to apply bg for.
* @param [array] $data data-array from options.
* @return string
*/
public function get_background_css( $selector, $data ) {
if ( ! $selector ) {
return;
}
if ( ! is_array( $data ) ) {
return;
}
if ( empty( $data['image'] ) && empty( $data['color'] ) ) {
return;
}
$standard_bg = cherry_prepare_background( $data );
if ( empty( $data['image'] ) ) {
$standard_bg .= 'background-image:none;';
return $selector . '{' . $standard_bg . '}';
}
$images = explode( ',', $data['image'] );
$property_format = "%1$s {background-image: url(%2$s);%3$s}";
if ( 1 == count( $images ) && wp_attachment_is_image( $images[0] ) ) {
$img = wp_get_attachment_image_src( $images[0], 'full' );
$result = sprintf( $property_format, $selector, $img[0], $standard_bg );
return $result;
}
$img1x = null;
$img2x = null;
$width1x = 0;
$count = 2;
for ( $i = 0; $i < $count; $i++ ) {
if ( ( ! isset( $images[ $i ] ) ) || ( ! wp_attachment_is_image( $images[ $i ] ) ) ) {
continue;
}
$img = wp_get_attachment_image_src( $images[ $i ], 'full' );
if ( ! is_array( $img ) ) {
continue;
}
$img_url = $img[0];
$img_width = intval( $img[1] );
if ( null == $img1x ) {
$img1x = $img_url;
$img2x = $img_url;
$width1x = $img_width;
} elseif ( $img_width > $width1x ) {
$img2x = $img_url;
} else {
$img1x = $img_url;
}
}
$bg1 = sprintf( $property_format, $selector, $img1x, $standard_bg );
$bg2 = sprintf( $property_format, $selector, $img2x, '' );
$result = $bg1 . ' @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {' . $bg2 . '}';
return $result;
}
/**
* Sanitizes a hex color.
*
* Always adds hash to color use `sanitize_hex_color` if exist.
*
* @since 1.0.0
* @param [string] $color Maybe HEX color.
* @return string|null Sanitized color.
*/
public function sanitize_hex_color( $color ) {
$color = ltrim( $color, '#' );
$color = '#' . $color;
if ( '' === $color ) {
return '';
}
if ( function_exists( 'sanitize_hex_color' ) ) {
return sanitize_hex_color( $color );
}
// 3 or 6 hex digits, or the empty string.
if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
return $color;
}
return null;
}
/**
* Implode background properties array into CSS string.
*
* @since 1.0.0
* @param [array] $data Background data-array.
* @return string Set of background rules.
*/
public function prepare_background( $data ) {
if ( ! is_array( $data ) ) {
return;
}
unset( $data['image'] );
$result = '';
$format = 'background-%s:%s;';
foreach ( $data as $prop => $value ) {
if ( ! $value ) {
continue;
}
switch ( $prop ) {
case 'color':
$value = $this->sanitize_hex_color( $value );
break;
case 'position':
$value = str_replace( '-', ' ', $value );
break;
}
$result .= sprintf( $format, $prop, $value );
}
return $result;
}
/**
* Implode typography data array from options into CSS string.
*
* @since 1.0.0
* @param [array] $data Typography parameters array from options.
* @param [array] $mod Optional parameter - pass function name and arg to modify values inside typography array.
* @return string Font, letter-spacing, text-align, color CSS properties string.
*/
public function cherry_get_typography_css( $data, $mod = array() ) {
if ( ! is_array( $data ) || empty( $data ) ) {
return;
}
$defaults = array(
'family' => '',
'style' => '',
'color' => '',
'size' => '',
'lineheight' => '',
'letterspacing' => '',
'align' => '',
);
$data = wp_parse_args( $data, $defaults );
$result = array();
if ( '' !== $data['letterspacing'] ) {
$units = '0' != $data['letterspacing'] ? 'px' : '';
$result[] = 'letter-spacing:' . $data['letterspacing'] . $units;
}
if ( 'notdefined' != $data['align'] ) {
$result[] = 'text-align:' . $data['align'];
}
if ( '' != $data['color'] ) {
$color = $this->sanitize_hex_color( $data['color'] );
if ( 1 < count( $mod ) && ( in_array( $mod[0], array( 'cherry_colors_lighten', 'cherry_colors_darken' ) ) ) ) {
$color = $mod[0]( $color, $mod[1] );
}
$result[] = 'color:' . $color;
}
$family = stripcslashes( $data['family'] );
$family = explode( ',', $family );
array_walk( $family, array( $this, 'typography_prepare_family' ) );
$family[] = ! empty( $data['category'] ) ? $data['category'] : 'sans-serif';
$family = array_unique( $family );
$font_style = false;
$font_weight = false;
$font_size = $data['size'] . 'px';
$line_height = $data['lineheight'] . 'px';
$font_family = implode( ', ', $family );
preg_match( '/^(\d*)(\w*)/i', $data['style'], $matches );
if ( is_array( $matches ) ) {
$font_style = ( 'regular' != $matches[2] ) ? $matches[2] : false;
$font_weight = $matches[1];
}
$font = array(
$font_style,
$font_weight,
$font_size . '/' . $line_height,
$font_family,
);
$font = implode( ' ', array_filter( $font ) );
$result[] = 'font:' . ltrim( $font );
$result = implode( ';', $result ) . ';';
return $result;
}
/**
* Prepare font family for passing into typography function.
*
* @since 1.0.0
* @param [string] $item Array item.
* @param [int] $index Array item index.
* @return void
*/
public function typography_prepare_family( &$item, $index ) {
$item = trim( $item );
if ( strpos( $item, ' ' ) ) {
$item = '"' . $item . '"';
}
}
/**
* Get box model CSS from layout editor option.
*
* @since 1.0.0
* @param [array] $data Layout parameters array from options.
* @param [array] $mod Optional parameter - pass function name and arg to modify values inside layout array.
* @return string Indents, border etc.
*/
public function cherry_get_box_model_css( $data, $mod = array() ) {
if ( ! is_array( $data ) || empty( $data ) ) {
return;
}
$defaults = array(
'position' => array(),
'margin' => array(),
'border' => array(),
'padding' => array(),
'container' => array(),
);
$box_defaults = array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
);
$data = wp_parse_args( $data, $defaults );
$result = '';
// Prepare postion
$data['position'] = array_filter( $data['position'] );
if ( ! empty( $data['position'] ) ) {
$data['position'] = array_intersect_key( $data['position'], $box_defaults );
$parser_data = array(
'prefix' => '',
'allowed' => $box_defaults,
);
array_walk( $data['position'], 'cherry_prepare_box_item', $parser_data );
$result .= implode( ';', array_filter( $data['position'] ) ) . ';';
}
// Prepare indents.
$result .= cherry_prepare_css_indents( $data['margin'], 'margin' );
$result .= cherry_prepare_css_indents( $data['padding'], 'padding' );
// Prepare borders
if ( ! empty( $data['border'] ) ) {
$border_style = ! empty( $data['border']['style'] ) ? $data['border']['style'] : '';
$border_color = ! empty( $data['border']['color'] ) ? $data['border']['color'] : '';
$border_radius = ! empty( $data['border']['radius'] ) ? $data['border']['radius'] : '';
if ( '' != $border_radius ) {
$result .= 'border-radius:' . $border_radius . ';';
}
$border_format = 'border-%1$s:%2$s %3$s %4$s;';
foreach ( $data['border'] as $property => $value ) {
if ( ! array_key_exists( $property, $box_defaults ) ) {
continue;
}
if ( empty( $value ) ) {
continue;
}
$result .= sprintf(
$border_format,
$property, $value, $border_style, $border_color
);
}
}
// Prepare dimensions.
if ( ! empty( $data['container']['width'] ) ) {
$result .= 'width:' . $data['container']['width'] . ';';
}
if ( ! empty( $data['container']['height'] ) ) {
$result .= 'height:' . $data['container']['height'] . ';';
}
return $result;
}
/**
* Service function to grab CSS indents from data array into string.
*
* @since 1.0.0
* @param [array] $data data-array.
* @param [string] $property CSS property.
* @return string
*/
public function cherry_prepare_css_indents( $data, $property ) {
if ( empty( $data ) ) {
return;
}
$box_defaults = array(
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
);
$data = array_intersect_key( $data, $box_defaults );
$data = array_filter( $data );
if ( 4 == count( $data ) ) {
$result = $property . ':' . implode( ' ', $data ) . ';';
return $result;
}
$parser_data = array(
'prefix' => $property,
'allowed' => $box_defaults,
);
array_walk( $data, 'cherry_prepare_box_item', $parser_data );
$result = implode( ';', array_filter( $data ) ) . ';';
return $result;
}
/**
* Service callback function for.
*
* @since 1.0.0
* @param [string] $item Position value.
* @param [string] $key Position key.
* @param [array] $data Array of allowed positions and property prefix.
* @return void
*/
public function cherry_prepare_box_item( &$item, $key, $data ) {
if ( ! array_key_exists( $key, $data['allowed'] ) ) {
$item = false;
return;
}
if ( empty( $item ) ) {
$item = false;
return;
}
$prefix = '';
if ( ! empty( $data['prefix'] ) ) {
$prefix = $data['prefix'] . '-';
}
$item = $prefix . $key . ':' . $item;
}
/**
* Prepare font family to the using in CSS.
*
* @since 1.0.1
* @param [string] $font_family Font name.
* @return string
*/
public function typography_font_family( $font_family ) {
$font_family = trim( $font_family );
$family_args = explode( ',', $font_family );
$names = '';
$type = end( $family_args );
$type = trim( $type );
for ( $i = 0; $i < count( $family_args ) - 1; $i++ ) {
if ( strpos( $family_args[ $i ], ' ' ) ) {
$names .= "'" . $family_args[ $i ] . "',";
} else {
$names .= $family_args[ $i ] . ',';
}
}
return sprintf( '%1$s, %2$s', trim( $names, ',' ), $type );
}
/**
* Make float size.
*
* @since 1.0.0
* @param [double] $size Font size.
* @param [string] $operation Arithmetic operator (multiple, addition).
* @param [string] $func Function name (floor, ceil, round, abs).
* @param [double] $percent Font size in percent.
* @return double Size.
*/
public function typography_size( $size, $operation = ' ', $func = 'round', $percent ) {
if ( ! $size ) {
return false;
}
switch ( $operation ) {
case 'multiple' :
$size = (double) $size * (double) $percent;
break;
case 'addition' :
$size = (double) $size + (double) $percent;
break;
}
switch ( $func ) {
case 'floor' :
$size = floor( $size );
break;
case 'ceil' :
$size = ceil( $size );
break;
case 'round' :
$size = round( $size );
break;
case 'abs' :
$size = abs( $size );
break;
}
return $size;
}
/**
* Build a CSS-rule.
*
* @since 1.0.0
* @param [string|int] $value CSS-proterty value.
* @param [string] $rule CSS-proterty name.
* @return string CSS-rule.
*/
public function empty_value( $value, $rule ) {
if ( '' == $value || 'notdefined' == $value ) {
return;
}
echo $rule . ': ' . $value;
if ( is_numeric( $value ) ) {
echo 'px; ';
} else {
echo '; ';
}
}
/**
* Set element emphasis.
*
* @since 1.0.0
* @param [string] $parent Parent selector.
* @param [string] $color Color.
* @param [string] $property To define.
*/
public function element_emphasis( $parent, $color, $property ) {
$result = $parent . ' {' . $property . ':' . $color . ';}';
$result .= $parent . ':hover {' . $property . ':' . $this->color_darken( $color, 10 ) . ';}';
return $result;
}
/**
* Return width value for container.
*
* @since 1.0.0
* @param [int] $container_width A container width value.
* @param [int] $element_width Some-block (parent-block for container) width value.
* @return int Width value.
*/
public function container_width_compare( $container_width, $element_width ) {
return ( $container_width > $element_width ) ? $element_width : $container_width;
}
/**
* Sum of $a and $b.
*
* @since 1.0.0
* @param [int] $a Operand 1.
* @param [int] $b Operand 2.
* @return int Addition.
*/
public function simple_sum( $a, $b ) {
return intval( $a ) + intval( $b );
}
/**
* Difference of $a and $b.
*
* @since 1.0.0
* @param [int] $a Operand 1.
* @param [int] $b Operand 2.
* @return int Subtraction.
*/
public function simple_diff( $a, $b ) {
return intval( $a ) - intval( $b );
}
/**
* Retrieve a width to swith on mobile menu from.
*
* @since 1.0.0
* @return int Width value.
*/
public function menu_toogle_endpoint() {
/**
* Filters a value when mobile menu switched.
*
* @since 1.0.0
* @param int $value Width value.
*/
return apply_filters( 'cherry_menu_toogle_endpoint', 600 );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,374 @@
<?php
/**
* Module Name: Google Fonts Loader
* Description: Enqueue Google fonts
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Google_Fonts_Loader' ) ) {
/**
* Google fonts loader main class
*/
class Cherry_Google_Fonts_Loader {
/**
* Module slug.
*
* @var string
*/
public $module_slug = 'cherry-google-fonts-loader';
/**
* Module arguments
*
* @var array
*/
public $args = array();
/**
* Core instance
*
* @var object
*/
public $core = null;
/**
* Define fonts server URL
*
* @var string
*/
public $fonts_host = '//fonts.googleapis.com/css';
/**
* Google fonts set
*
* @var array
*/
public $google_fonts = null;
/**
* Array of stored google fonts data
*
* @var array
*/
public $fonts_data = array();
/**
* Constructor for the class
*/
function __construct( $core, $args ) {
$this->core = $core;
$this->args = wp_parse_args( $args, array(
'options' => array(),
) );
$this->fonts_host = apply_filters( 'cherry_google_fonts_cdn', $this->fonts_host );
add_action( 'customize_preview_init', array( $this, 'reset_fonts_cache' ) );
add_action( 'customize_save_after', array( $this, 'reset_fonts_cache' ) );
add_action( 'switch_theme', array( $this, 'reset_fonts_cache' ) );
if ( is_admin() ) {
return;
}
add_action( 'wp_enqueue_scripts', array( $this, 'prepare_fonts' ) );
}
/**
* Get fonts data and enqueue URL
*
* @since 1.0.0
*/
public function prepare_fonts() {
$font_url = $this->get_fonts_url();
wp_enqueue_style( 'cherry-google-fonts-' . $this->args['prefix'], $font_url );
}
/**
* Returns transient key.
*
* @return [type] [description]
*/
public function transient_key() {
return 'cherry_google_fonts_url_' . $this->args['prefix'];
}
/**
* Return theme Google fonts URL to enqueue it
*
* @since 1.0.0
* @return string
*/
public function get_fonts_url() {
$font_url = get_transient( $this->transient_key() );
if ( ! $font_url ) {
// Get typography options list
$options_set = $this->get_options_set();
// build Google fonts data array
foreach ( $options_set as $option ) {
$this->add_font( $option );
}
$font_url = $this->build_fonts_url();
if ( false == $font_url ) {
return;
}
global $wp_customize;
if ( ! isset( $wp_customize ) ) {
set_transient( $this->transient_key(), $font_url, WEEK_IN_SECONDS );
}
}
return $font_url;
}
/**
* Get options set from module arguments
*
* @return array
*/
public function get_options_set() {
return $this->args['options'];
}
/**
* Get current setting by name
*
* @since 1.0.0
* @return mixed
*/
public function get_setting( $name ) {
$type = $this->args['type'];
if ( 'theme_mod' == $type ) {
$setting = get_theme_mod( $name );
return $setting;
}
if ( true != $this->args['single'] ) {
$setting = get_option( $name );
return $setting;
}
$settings = get_option( $this->args['prefix'] );
if ( ! empty( $settings ) && isset( $settings[ $name ] ) ) {
return $settings[ $name ];
}
return false;
}
/**
* Build Google fonts stylesheet URL from stored data
*
* @since 1.0.0
*/
public function build_fonts_url() {
$font_families = array();
$subsets = array();
if ( empty( $this->fonts_data ) ) {
return false;
}
foreach ( $this->fonts_data as $family => $data ) {
$styles = implode( ',', array_unique( array_filter( $data['style'] ) ) );
$font_families[] = $family . ':' . $styles;
$subsets = array_merge( $subsets, $data['character'] );
}
$subsets = array_unique( array_filter( $subsets ) );
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( implode( ',', $subsets ) ),
);
$fonts_url = add_query_arg( $query_args, $this->fonts_host );
return $fonts_url;
}
/**
* Get single typography option value from database and store it in object property
*
* @since 1.0.0
* @param [type] $font option name to get from database.
*/
public function add_font( $font ) {
$font = wp_parse_args( $font, array(
'family' => '',
'style' => 'normal',
'weight' => '400',
'charset' => 'latin',
) );
$family = $this->get_setting( $font['family'] );
$family = explode( ',', $family );
$family = trim( $family[0], "'" );
if ( ! $this->is_google_font( $family ) ) {
return;
}
$load_style = $this->get_setting( $font['weight'] );
$font_style = $this->get_setting( $font['style'] );
if ( 'italic' === $font_style ) {
$load_style .= $font_style;
}
if ( ! isset( $this->fonts_data[ $family ] ) ) {
$this->fonts_data[ $family ] = array(
'style' => array( $load_style ),
'character' => array( $this->get_setting( $font['charset'] ) ),
);
} else {
$this->fonts_data[ $family ] = array(
'style' => $this->add_font_prop(
$load_style,
$this->fonts_data[ $family ]['style']
),
'character' => $this->add_font_prop(
$this->get_setting( $font['charset'] ),
$this->fonts_data[ $family ]['character']
),
);
}
}
/**
* Add new font property to existaing properties array
*
* @since 1.0.0
* @param [type] $new property to add.
* @param array $existing existing properties.
*/
public function add_font_prop( $new, $existing ) {
if ( ! is_array( $existing ) ) {
return array( $new );
}
if ( ! in_array( $new, $existing ) ) {
$existing[] = $new;
}
return $existing;
}
/**
* Check if selected font is google font
*
* @since 1.0.0
* @param array $font_family font family to check.
* @return boolean
*/
public function is_google_font( $font_family ) {
$google_fonts = $this->get_google_fonts();
if ( empty( $google_fonts ) ) {
$customizer = isset( $this->core->modules['cherry-customizer'] ) ? $this->core->modules['cherry-customizer'] : false;
if ( ! $customizer ) {
return false;
}
$customizer->init_fonts();
$google_fonts = $this->get_google_fonts();
if ( empty( $google_fonts ) ) {
return false;
}
}
$font_family = explode( ',', $font_family );
$font_family = trim( $font_family[0], "'" );
foreach ( $google_fonts as $font ) {
if ( $font_family === $font['family'] ) {
return true;
}
}
return false;
}
/**
* Get google fonts array
*
* @since 1.0.0
* @return array
*/
public function get_google_fonts() {
if ( null === $this->google_fonts ) {
$this->google_fonts = get_option( 'cherry_customiser_fonts_google', null );
}
return $this->google_fonts;
}
/**
* Reset fonts cache
*
* @since 1.0.0
*/
public function reset_fonts_cache() {
delete_transient( $this->transient_key() );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1 @@
.cherry-handler-notice{background:#23282d;position:fixed;margin:5px 0;box-shadow:1px 1px 5px rgba(0,0,0,0.2);box-sizing:border-box;padding:8px 15px 8px 8px;min-width:200px;overflow:hidden;color:#fff;z-index:999;border-radius:2px;-webkit-transition:all 250ms cubic-bezier(0.85, 0.04, 1, 1);transition:all 250ms cubic-bezier(0.85, 0.04, 1, 1)}.cherry-handler-notice span.dashicons{position:relative;margin-right:10px}.cherry-handler-notice span.dashicons:before{position:absolute;font-size:30px;left:-6px;top:-4px}.cherry-handler-notice.success-notice span.dashicons{color:#48c569}.cherry-handler-notice.success-notice span.dashicons:before{content:"\f147"}.cherry-handler-notice.success-notice .inner b{color:#48c569}.cherry-handler-notice.info-notice span.dashicons{color:#faa730}.cherry-handler-notice.info-notice span.dashicons:before{content:"\f534"}.cherry-handler-notice.info-notice .inner b{color:#faa730}.cherry-handler-notice.error-notice span.dashicons{color:#e54343}.cherry-handler-notice.error-notice span.dashicons:before{content:"\f158"}.cherry-handler-notice.show-state{-webkit-transition:all 500ms cubic-bezier(0.1, 0.67, 0.26, 1);transition:all 500ms cubic-bezier(0.1, 0.67, 0.26, 1)}.cherry-handler-notice .inner{display:inline-block}

View File

@@ -0,0 +1,309 @@
( function( $, CherryJsCore ) {
'use strict';
/**
* CherryAjaxHandler class
*
* @param {object} options Handler options
*/
CherryJsCore.utilites.namespace( 'CherryAjaxHandler' );
CherryJsCore.CherryAjaxHandler = function( options ) {
/**
* General default settings
*
* @type {Object}
*/
var self = this,
settings = {
'handlerId': '',
'cache': false,
'processData': true,
'url': '',
'async': false,
'beforeSendCallback': function() {},
'errorCallback': function() {},
'successCallback': function() {},
'completeCallback': function() {}
};
/**
* Checking options, settings and options merging
*
*/
if ( options ) {
$.extend( settings, options );
}
/**
* Check if handlerId ready to using
*
*/
if ( ! window[ settings.handlerId ] ) {
if ( window.console ) {
window.console.warn( 'Handler id not found' );
}
return false;
}
/**
* Set handler settings from localized global variable
*
* @type {Object}
*/
self.handlerSettings = window[ settings.handlerId ] || {};
/**
* Ajax request instance
*
* @type {Object}
*/
self.ajaxRequest = null;
/**
* Ajax processing state
*
* @type {Boolean}
*/
self.ajaxProcessing = false;
/**
* Set ajax request data
*
* @type {Object}
*/
self.data = {
'action': self.handlerSettings.action,
'nonce': self.handlerSettings.nonce
};
/**
* Check ajax url is empty
*/
if ( '' === settings.url ) {
// Check public request
if ( 'false' === self.handlerSettings.is_public ) {
settings.url = window.ajaxurl;
} else {
settings.url = window.cherryHandlerAjaxUrl.ajax_url;
}
}
/**
* Init ajax request
*
* @return {Void}
*/
self.send = function() {
if ( self.ajaxProcessing ) {
CherryJsCore.cherryHandlerUtils.noticeCreate( 'error-notice', self.handlerSettings.sys_messages.wait_processing, self.handlerSettings.is_public );
}
self.ajaxProcessing = true;
self.ajaxRequest = jQuery.ajax( {
type: self.handlerSettings.type,
url: settings.url,
data: self.data,
cache: settings.cache,
dataType: self.handlerSettings.data_type,
processData: settings.processData,
beforeSend: function( jqXHR, ajaxSettings ) {
if ( null !== self.ajaxRequest && ! settings.async ) {
self.ajaxRequest.abort();
}
if ( settings.beforeSendCallback && 'function' === typeof( settings.beforeSendCallback ) ) {
settings.beforeSendCallback( jqXHR, ajaxSettings );
}
},
error: function( jqXHR, textStatus, errorThrown ) {
$( document ).trigger( {
type: 'cherry-ajax-handler-error',
jqXHR: jqXHR,
textStatus: textStatus,
errorThrown: errorThrown
} );
if ( settings.errorCallback && 'function' === typeof( settings.errorCallback ) ) {
settings.errorCallback( jqXHR, textStatus, errorThrown );
}
},
success: function( data, textStatus, jqXHR ) {
self.ajaxProcessing = false;
$( document ).trigger( {
type: 'cherry-ajax-handler-success',
response: data,
jqXHR: jqXHR,
textStatus: textStatus
} );
if ( settings.successCallback && 'function' === typeof( settings.successCallback ) ) {
settings.successCallback( data, textStatus, jqXHR );
}
CherryJsCore.cherryHandlerUtils.noticeCreate( data.type, data.message, self.handlerSettings.is_public );
},
complete: function( jqXHR, textStatus ) {
$( document ).trigger( {
type: 'cherry-ajax-handler-complete',
jqXHR: jqXHR,
textStatus: textStatus
} );
if ( settings.completeCallback && 'function' === typeof( settings.completeCallback ) ) {
settings.completeCallback( jqXHR, textStatus );
}
}
} );
};
/**
* Send data ajax request
*
* @param {Object} data User data
* @return {Void}
*/
self.sendData = function( data ) {
var sendData = data || {};
self.data = {
'action': self.handlerSettings.action,
'nonce': self.handlerSettings.nonce,
'data': sendData
};
self.send();
};
/**
* Send form serialized data
* @param {String} formId Form selector
* @return {Void}
*/
self.sendFormData = function( formId ) {
var form = $( formId ),
data;
data = CherryJsCore.cherryHandlerUtils.serializeObject( form );
self.sendData( data );
};
};
CherryJsCore.utilites.namespace( 'cherryHandlerUtils' );
CherryJsCore.cherryHandlerUtils = {
/**
* Rendering notice message
*
* @param {String} type Message type
* @param {String} message Message content
* @return {Void}
*/
noticeCreate: function( type, message, isPublicPage ) {
var notice,
rightDelta = 0,
timeoutId,
isPublic = isPublicPage || false;
if ( ! message || 'true' === isPublic ) {
return false;
}
notice = $( '<div class="cherry-handler-notice ' + type + '"><span class="dashicons"></span><div class="inner">' + message + '</div></div>' );
$( 'body' ).prepend( notice );
reposition();
rightDelta = -1 * ( notice.outerWidth( true ) + 10 );
notice.css( { 'right': rightDelta } );
timeoutId = setTimeout( function() {
notice.css( { 'right': 10 } ).addClass( 'show-state' );
}, 100 );
timeoutId = setTimeout( function() {
rightDelta = -1 * ( notice.outerWidth( true ) + 10 );
notice.css( { right: rightDelta } ).removeClass( 'show-state' );
}, 4000 );
timeoutId = setTimeout( function() {
notice.remove();
clearTimeout( timeoutId );
}, 4500 );
function reposition() {
var topDelta = 100;
$( '.cherry-handler-notice' ).each( function() {
$( this ).css( { top: topDelta } );
topDelta += $( this ).outerHeight( true );
} );
}
},
/**
* Serialize form into
*
* @return {Object}
*/
serializeObject: function( form ) {
var self = this,
json = {},
pushCounters = {},
patterns = {
'validate': /^[a-zA-Z][a-zA-Z0-9_-]*(?:\[(?:\d*|[a-zA-Z0-9_-]+)\])*$/,
'key': /[a-zA-Z0-9_-]+|(?=\[\])/g,
'push': /^$/,
'fixed': /^\d+$/,
'named': /^[a-zA-Z0-9_-]+$/
};
this.build = function( base, key, value ) {
base[ key ] = value;
return base;
};
this.push_counter = function( key ) {
if ( undefined === pushCounters[ key ] ) {
pushCounters[ key ] = 0;
}
return pushCounters[ key ]++;
};
$.each( form.serializeArray(), function() {
var k, keys, merge, reverseKey;
// Skip invalid keys
if ( ! patterns.validate.test( this.name ) ) {
return;
}
keys = this.name.match( patterns.key );
merge = this.value;
reverseKey = this.name;
while ( undefined !== ( k = keys.pop() ) ) {
// Adjust reverseKey
reverseKey = reverseKey.replace( new RegExp( '\\[' + k + '\\]$' ), '' );
// Push
if ( k.match( patterns.push ) ) {
merge = self.build( [], self.push_counter( reverseKey ), merge );
} else if ( k.match( patterns.fixed ) ) {
merge = self.build( [], k, merge );
} else if ( k.match( patterns.named ) ) {
merge = self.build( {}, k, merge );
}
}
json = $.extend( true, json, merge );
});
return json;
}
};
}( jQuery, window.CherryJsCore ) );

View File

@@ -0,0 +1 @@
!function(e,a){"use strict";a.utilites.namespace("CherryAjaxHandler"),a.CherryAjaxHandler=function(t){var n=this,r={handlerId:"",cache:!1,processData:!0,url:"",async:!1,beforeSendCallback:function(){},errorCallback:function(){},successCallback:function(){},completeCallback:function(){}};return t&&e.extend(r,t),window[r.handlerId]?(n.handlerSettings=window[r.handlerId]||{},n.ajaxRequest=null,n.ajaxProcessing=!1,n.data={action:n.handlerSettings.action,nonce:n.handlerSettings.nonce},""===r.url&&(r.url="false"===n.handlerSettings.is_public?window.ajaxurl:window.cherryHandlerAjaxUrl.ajax_url),n.send=function(){n.ajaxProcessing&&a.cherryHandlerUtils.noticeCreate("error-notice",n.handlerSettings.sys_messages.wait_processing,n.handlerSettings.is_public),n.ajaxProcessing=!0,n.ajaxRequest=jQuery.ajax({type:n.handlerSettings.type,url:r.url,data:n.data,cache:r.cache,dataType:n.handlerSettings.data_type,processData:r.processData,beforeSend:function(e,a){null===n.ajaxRequest||r.async||n.ajaxRequest.abort(),r.beforeSendCallback&&"function"==typeof r.beforeSendCallback&&r.beforeSendCallback(e,a)},error:function(a,t,n){e(document).trigger({type:"cherry-ajax-handler-error",jqXHR:a,textStatus:t,errorThrown:n}),r.errorCallback&&"function"==typeof r.errorCallback&&r.errorCallback(a,t,n)},success:function(t,c,s){n.ajaxProcessing=!1,e(document).trigger({type:"cherry-ajax-handler-success",response:t,jqXHR:s,textStatus:c}),r.successCallback&&"function"==typeof r.successCallback&&r.successCallback(t,c,s),a.cherryHandlerUtils.noticeCreate(t.type,t.message,n.handlerSettings.is_public)},complete:function(a,t){e(document).trigger({type:"cherry-ajax-handler-complete",jqXHR:a,textStatus:t}),r.completeCallback&&"function"==typeof r.completeCallback&&r.completeCallback(a,t)}})},n.sendData=function(e){var a=e||{};n.data={action:n.handlerSettings.action,nonce:n.handlerSettings.nonce,data:a},n.send()},void(n.sendFormData=function(t){var r,c=e(t);r=a.cherryHandlerUtils.serializeObject(c),n.sendData(r)})):(window.console&&window.console.warn("Handler id not found"),!1)},a.utilites.namespace("cherryHandlerUtils"),a.cherryHandlerUtils={noticeCreate:function(a,t,n){function r(){var a=100;e(".cherry-handler-notice").each(function(){e(this).css({top:a}),a+=e(this).outerHeight(!0)})}var c,s,i=0,o=n||!1;return t&&"true"!==o?(c=e('<div class="cherry-handler-notice '+a+'"><span class="dashicons"></span><div class="inner">'+t+"</div></div>"),e("body").prepend(c),r(),i=-1*(c.outerWidth(!0)+10),c.css({right:i}),s=setTimeout(function(){c.css({right:10}).addClass("show-state")},100),s=setTimeout(function(){i=-1*(c.outerWidth(!0)+10),c.css({right:i}).removeClass("show-state")},4e3),void(s=setTimeout(function(){c.remove(),clearTimeout(s)},4500))):!1},serializeObject:function(a){var t=this,n={},r={},c={validate:/^[a-zA-Z][a-zA-Z0-9_-]*(?:\[(?:\d*|[a-zA-Z0-9_-]+)\])*$/,key:/[a-zA-Z0-9_-]+|(?=\[\])/g,push:/^$/,fixed:/^\d+$/,named:/^[a-zA-Z0-9_-]+$/};return this.build=function(e,a,t){return e[a]=t,e},this.push_counter=function(e){return void 0===r[e]&&(r[e]=0),r[e]++},e.each(a.serializeArray(),function(){var a,r,s,i;if(c.validate.test(this.name)){for(r=this.name.match(c.key),s=this.value,i=this.name;void 0!==(a=r.pop());)i=i.replace(new RegExp("\\["+a+"\\]$"),""),a.match(c.push)?s=t.build([],t.push_counter(i),s):a.match(c.fixed)?s=t.build([],a,s):a.match(c.named)&&(s=t.build({},a,s));n=e.extend(!0,n,s)}}),n}}}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,65 @@
.cherry-handler-notice{
background: #23282d;
position: fixed;
margin: 5px 0;
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
padding: 8px 15px 8px 8px;
min-width: 200px;
overflow: hidden;
color: #fff;
z-index: 999;
border-radius: 2px;
transition: all 250ms cubic-bezier(0.85, 0.04, 1, 1);
span.dashicons{
position: relative;
margin-right: 10px;
&:before{
position: absolute;
font-size: 30px;
left: -6px;
top: -4px;
}
}
&.success-notice{
span.dashicons{
color: #48c569;
&:before{
content: "\f147";
}
}
.inner{
b{
color: #48c569;
}
}
}
&.info-notice{
span.dashicons{
color: #faa730;
&:before{
content: "\f534";
}
}
.inner{
b{
color: #faa730;
}
}
}
&.error-notice{
span.dashicons{
color: #e54343;
&:before{
content: "\f158";
}
}
}
&.show-state{
-webkit-transition: all 500ms cubic-bezier(0.1, 0.67, 0.26, 1);
transition: all 500ms cubic-bezier(0.1, 0.67, 0.26, 1);
}
.inner{
display: inline-block;
}
}

View File

@@ -0,0 +1,246 @@
<?php
/**
* Module Name: Cherry handler
* Description: Initializes handlers
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Handler' ) ) {
/**
* Cherry_Handler class.
*
* @since 1.0.0
*/
class Cherry_Handler {
/**
* Core version.
*
* @since 1.5.0
* @access public
* @var string
*/
public $core_version = '';
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $module_path;
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $settings = array(
'id' => '',
'action' => '',
'capability' => '',
'is_public' => false,
'callback' => '',
'type' => 'POST',
'data_type' => 'json',
'sys_messages' => array(),
);
/**
* Class constructor.
*
* @since 1.0.0
* @param object $core Core instance.
* @param array $args Class args.
*/
public function __construct( $core, $args = array() ) {
$this->settings['sys_messages'] = array(
'invalid_base_data' => esc_html__( 'Unable to process the request without nonce or server error', 'cherry-framework' ),
'no_right' => esc_html__( 'No right for this action', 'cherry-framework' ),
'invalid_nonce' => esc_html__( 'Stop CHEATING!!!', 'cherry-framework' ),
'access_is_allowed' => esc_html__( 'Access is allowed', 'cherry-framework' ),
'wait_processing' => esc_html__( 'Please wait, processing the previous request', 'cherry-framework' ),
);
$this->settings = array_merge( $this->settings, $args );
$this->core_version = $core->get_core_version();
$this->module_path = $args['module_path'];
if ( empty( $this->settings['id'] ) ) {
echo '<h3>ID is required attr</h3>';
return false;
}
if ( empty( $this->settings['action'] ) ) {
echo '<h3>Action is required attr</h3>';
return false;
}
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
add_action( 'wp_ajax_' . $this->settings['action'], array( $this, 'handler_init' ) );
// Public action check.
if ( filter_var( $this->settings['is_public'], FILTER_VALIDATE_BOOLEAN ) ) {
add_action( 'wp_ajax_nopriv_' . $this->settings['action'], array( $this, 'handler_init' ) );
}
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'wp_print_scripts', array( $this, 'localize_script' ) );
}
/**
* Handler initialization
*
* @since 1.0.0
* @return void
*/
public function handler_init() {
$request_type = strtoupper( '_' . $this->settings['type'] );
if ( ! empty( $GLOBALS[ $request_type ] ) && array_key_exists( 'nonce', $GLOBALS[ $request_type ] ) ) {
$nonce = $GLOBALS[ $request_type ]['nonce'];
$nonce_action = ! empty( $this->settings['action'] ) ? $this->settings['action'] : 'cherry_ajax_nonce';
if ( ! wp_verify_nonce( $nonce, $nonce_action ) ) {
$response = apply_filters( 'cherry_handler_response_nonce', array(
'message' => $this->settings['sys_messages']['invalid_nonce'],
'type' => 'error-notice',
) );
wp_send_json( $response );
}
if ( ! empty( $this->settings['capability'] ) && ! current_user_can( $this->settings['capability'] ) ) {
$response = apply_filters( 'cherry_handler_response_capability', array(
'message' => $this->settings['sys_messages']['no_right'],
'type' => 'error-notice',
) );
wp_send_json( $response );
}
if ( ! empty( $this->settings['callback'] ) && is_callable( $this->settings['callback'] ) ) {
ob_start();
$data = call_user_func( $this->settings['callback'] );
if ( ! $data ) {
$data = ob_get_contents();
}
ob_end_clean();
$response = apply_filters( 'cherry_handler_response_data', array(
'message' => $this->settings['sys_messages']['access_is_allowed'],
'type' => 'success-notice',
'data' => $data,
) );
wp_send_json( $response );
}
} else {
$response = apply_filters( 'cherry_handler_invalid_data', array(
'message' => $this->settings['sys_messages']['invalid_base_data'],
'type' => 'error-notice',
) );
wp_send_json( $response );
}
}
/**
* Register and enqueue handlers js.
*
* @since 1.0.0
*/
public function enqueue_scripts() {
wp_enqueue_script(
'cherry-handler-js',
esc_url( Cherry_Core::base_url( 'assets/js/min/cherry-handler.min.js', $this->module_path ) ),
array( 'jquery' ),
$this->core_version,
true
);
wp_enqueue_style(
'cherry-handler-css',
esc_url( Cherry_Core::base_url( 'assets/css/cherry-handler-styles.min.css', $this->module_path ) ),
array(),
$this->core_version,
'all'
);
}
/**
* Prepare data for henler script.
*
* @since 1.0.0
* @return void
*/
public function localize_script() {
$nonce = $this->create_nonce( $this->settings['action'] );
wp_localize_script( 'cherry-handler-js', $this->settings['id'],
array(
'action' => $this->settings['action'],
'nonce' => $nonce,
'type' => strtoupper( $this->settings['type'] ),
'data_type' => $this->settings['data_type'],
'is_public' => $this->settings['is_public'] ? 'true' : 'false',
'sys_messages' => $this->settings['sys_messages'],
)
);
if ( $this->settings['is_public'] ) {
wp_localize_script( 'cherry-handler-js', 'cherryHandlerAjaxUrl', array(
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
) );
}
}
/**
* Create nonce by action
*
* @param string $action Nonce name.
* @return string
*/
public function create_nonce( $action = '' ) {
if ( ! empty( $action ) ) {
return wp_create_nonce( $action );
}
return wp_create_nonce( 'cherry_ajax_nonce' );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,495 @@
<?php
/**
* Module Name: Interface Builder
* Description: The module for the creation of interfaces in the WordPress admin panel
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Interface_Builder' ) ) {
/**
* Class Cherry Interface Builder.
*
* @since 1.0.0
*/
class Cherry_Interface_Builder {
/**
* Core version.
*
* @since 1.5.0
* @access public
* @var string
*/
public $core_version = '';
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $module_path;
/**
* Module settings.
*
* @since 1.0.0
* @access private
* @var array
*/
private $args = array(
'views' => array(
'section' => 'inc/views/section.php',
'component-tab-vertical' => 'inc/views/component-tab-vertical.php',
'component-tab-horizontal' => 'inc/views/component-tab-horizontal.php',
'component-toggle' => 'inc/views/component-toggle.php',
'component-accordion' => 'inc/views/component-accordion.php',
'component-repeater' => 'inc/views/component-repeater.php',
'settings' => 'inc/views/settings.php',
'control' => 'inc/views/control.php',
'settings-children-title' => 'inc/views/settings-children-title.php',
'tab-children-title' => 'inc/views/tab-children-title.php',
'toggle-children-title' => 'inc/views/toggle-children-title.php',
'form' => 'inc/views/form.php',
'html' => 'inc/views/html.php',
),
'views_args' => array(
'parent' => '',
'type' => '',
'view' => '',
'view_wrapping' => true,
'html' => '',
'scroll' => false,
'master' => false,
'title' => '',
'description' => '',
),
);
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @access private
* @var object
*/
private static $instance = null;
/**
* UI element instance.
*
* @since 1.0.0
* @access public
* @var object
*/
public $ui_elements = null;
/**
* The structure of the interface elements.
*
* @since 1.0.0
* @access private
* @var array
*/
private $structure = array();
/**
* Cherry_Interface_Builder constructor.
*
* @since 1.0.0
* @access public
* @return void
*/
public function __construct( $core, array $args = array() ) {
$this->args = array_merge_recursive(
$args,
$this->args
);
$this->core_version = $core->get_core_version();
$this->module_path = $args['module_path'];
$this->ui_elements = $core->init_module( 'cherry-ui-elements' );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
}
/**
* Register element type section.
*
* @since 1.0.0
* @access public
* @param array $args Options section.
* @return void
*/
public function register_section( array $args = array() ) {
$this->add_new_element( $args, 'section' );
}
/**
* Register element type component.
*
* @since 1.0.0
* @access public
* @param array $args Options component.
* @return void
*/
public function register_component( array $args = array() ) {
$this->add_new_element( $args, 'component' );
}
/**
* Register element type settings.
*
* @since 1.0.0
* @access public
* @param array $args Options settings.
* @return void
*/
public function register_settings( array $args = array() ) {
$this->add_new_element( $args, 'settings' );
}
/**
* Register element type control.
*
* @since 1.0.0
* @access public
* @param array $args Options control.
* @return void
*/
public function register_control( array $args = array() ) {
$this->add_new_element( $args, 'control' );
}
/**
* Register element type form.
*
* @since 1.0.0
* @access public
* @param array $args Options form.
* @return void
*/
public function register_form( array $args = array() ) {
$this->add_new_element( $args, 'form' );
}
/**
* Register element type html.
*
* @since 1.0.0
* @access public
* @param array $args Options control.
* @return void
*/
public function register_html( array $args = array() ) {
$this->add_new_element( $args, 'html' );
}
/**
* This function adds a new element to the structure.
*
* @since 1.0.0
* @access protected
* @param array $args Options new element.
* @param string $type Type new element.
* @return void
*/
protected function add_new_element( array $args = array(), $type = 'section' ) {
if ( ! isset( $args[0] ) && ! is_array( current( $args ) ) ) {
if ( 'control' !== $type && 'component' !== $type ) {
$args['type'] = $type;
}
$this->structure[ $args['id'] ] = $args;
} else {
foreach ( $args as $key => $value ) {
if ( 'control' !== $type && 'component' !== $type ) {
$value['type'] = $type;
}
$this->structure[ $key ] = $value;
}
}
}
/**
* Sorts the elements of the structure, adding child items to the parent.
*
* @since 1.0.0
* @access protected
* @param array $structure The original structure of the elements.
* @param string $parent_key The key of the parent element.
* @return array
*/
protected function sort_structure( array $structure = array(), $parent_key = null ) {
$new_array = array();
foreach ( $structure as $key => $value ) {
if (
( null === $parent_key && ! isset( $value['parent'] ) )
|| null === $parent_key && ! isset( $structure[ $value['parent'] ] )
|| ( isset( $value['parent'] ) && $value['parent'] === $parent_key )
) {
if ( ! isset( $value['id'] ) ) {
$value['id'] = $key;
}
if ( ! isset( $value['name'] ) ) {
$value['name'] = $key;
}
$new_array[ $key ] = $value;
$children = $this->sort_structure( $structure, $key );
if ( ! empty( $children ) ) {
$new_array[ $key ]['children'] = $children;
}
}
}
return $new_array;
}
/**
* Reset structure array.
* Call this method only after render.
*
* @since 1.0.1
* @return void
*/
public function reset_structure() {
$this->structure = array();
}
/**
* Get view for interface elements.
*
* @since 1.0.0
* @access protected
* @param string $type View type.
* @param array $args Input data.
* @return string
*/
protected function get_view( $type = 'control', array $args = array() ) {
if ( empty( $args['view'] ) ) {
$path = ( array_key_exists( $type, $this->args['views'] ) ) ? $this->args['views'][ $type ] : $this->args['views']['control'];
$path = is_array( $path ) ? $path[0] : $path;
$path = file_exists( $path ) ? $path : $this->module_path . $path;
} else {
$path = $args['view'];
}
return Cherry_Toolkit::render_view( $path, $args );
}
/**
* Render HTML elements.
*
* @since 1.0.0
* @access public
* @param bool $echo Input data.
* @param array $args The original structure of the elements.
* @return string
*/
public function render( $echo = true, array $args = array() ) {
if ( empty( $args ) ) {
$args = $this->structure;
}
if ( empty( $args ) ) {
return false;
}
$sorted_structure = $this->sort_structure( $args );
$output = $this->build( $sorted_structure );
$output = str_replace( array( "\r\n", "\r", "\n", "\t" ), '', $output );
$this->reset_structure();
return $this->output_method( $output, $echo );
}
/**
* Render HTML elements.
*
* @since 1.0.0
* @access protected
* @param array $args Input data.
* @return string
*/
protected function build( array $args = array() ) {
$output = '';
$views = $this->args['views'];
foreach ( $args as $key => $value ) {
$value = wp_parse_args(
$value,
$this->args['views_args']
);
$value['class'] = isset( $value['class'] ) ? $value['class'] . ' ' : '';
$value['class'] .= $value['id'] . ' ';
if ( $value['scroll'] ) {
$value['class'] .= 'cherry-scroll ';
}
if ( $value['master'] ) {
$value['class'] .= $value['master'] . ' ';
}
$type = array_key_exists( $value['type'], $views ) ? $value['type'] : 'field';
$has_child = isset( $value['children'] ) && is_array( $value['children'] ) && ! empty( $value['children'] );
switch ( $type ) {
case 'component-tab-vertical':
case 'component-tab-horizontal':
if ( $has_child ) {
$value['tabs'] = '';
foreach ( $value['children'] as $key_children => $value_children ) {
$value['tabs'] .= $this->get_view( 'tab-children-title', $value_children );
unset( $value['children'][ $key_children ]['title'] );
}
}
break;
case 'component-toggle':
case 'component-accordion':
if ( $has_child ) {
foreach ( $value['children'] as $key_children => $value_children ) {
$value['children'][ $key_children ]['title_in_view'] = $this->get_view( 'toggle-children-title', $value_children );
}
}
break;
case 'settings':
if ( isset( $value['title'] ) && $value['title'] ) {
$value['title'] = isset( $value['title_in_view'] ) ? $value['title_in_view'] : $this->get_view( 'settings-children-title', $value );
}
break;
case 'html':
$value['children'] = $value['html'];
break;
case 'form':
$value['accept-charset'] = isset( $value['accept-charset'] ) ? $value['accept-charset'] : 'utf-8';
$value['action'] = isset( $value['action'] ) ? $value['action'] : '' ;
$value['autocomplete'] = isset( $value['autocomplete'] ) ? $value['autocomplete'] : 'on';
$value['enctype'] = isset( $value['enctype'] ) ? $value['enctype'] : 'application/x-www-form-urlencoded';
$value['method'] = isset( $value['method'] ) ? $value['method'] : 'post';
$value['novalidate'] = ( isset( $value['novalidate'] ) && $value['novalidate'] ) ? 'novalidate' : '';
$value['target'] = isset( $value['target'] ) ? $value['target'] : '';
break;
case 'field':
$ui_args = $value;
$ui_args['class'] = isset( $ui_args['child_class'] ) ? $ui_args['child_class'] : '' ;
if ( isset( $ui_args['options_callback'] ) ) {
$ui_args['options'] = call_user_func( $ui_args['options_callback'] );
}
unset( $ui_args['master'] );
$value['children'] = $this->ui_elements->get_ui_element_instance( $ui_args['type'], $ui_args )->render();
break;
}
if ( $has_child ) {
$value['children'] = $this->build( $value['children'] );
}
$output .= ( $value['view_wrapping'] ) ? $this->get_view( $type, $value ) : $value['children'];
}
return $output;
}
/**
* Output HTML.
*
* @since 1.0.0
* @access protected
* @param string $output Output HTML.
* @param boolean $echo Output type.
* @return string
*/
protected function output_method( $output = '', $echo = true ) {
if ( ! filter_var( $echo, FILTER_VALIDATE_BOOLEAN ) ) {
return $output;
} else {
echo $output;
}
}
/**
* Enqueue javascript and stylesheet interface builder.
*
* @since 4.0.0
* @access public
* @return void
*/
public function enqueue_assets() {
wp_enqueue_script(
'cherry-interface-builder',
esc_url( Cherry_Core::base_url( 'inc/assets/min/cherry-interface-builder.min.js', $this->module_path ) ),
array( 'jquery' ),
$this->core_version,
true
);
wp_enqueue_style(
'cherry-interface-builder',
esc_url( Cherry_Core::base_url( 'inc/assets/min/cherry-interface-builder.min.css', $this->module_path ) ),
array(),
$this->core_version,
'all'
);
}
/**
* Returns the instance.
*
* @since 1.0.0
* @access public
* @return object
*/
public static function get_instance( $core, $args ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $core, $args );
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,17 @@
.cherry-ui-kit{
button{
*{
pointer-events: none;
}
}
}
.cherry-component{
&__content{
.cherry-settings__content{
display: none;
&.show{
display: inherit;
}
}
}
}

View File

@@ -0,0 +1,193 @@
/**
* Interface Builder
*/
;( function( $, CherryJsCore ) {
'use strict';
CherryJsCore.utilites.namespace( 'interfaceBuilder' );
CherryJsCore.interfaceBuilder = {
init: function() {
this.component.init();
$( document )
.on( 'cherryInterfaceBuilder', this.component.init.bind( this.component ) );
},
component: {
tabClass: '.cherry-tab',
accordionClass: '.cherry-accordion',
toggleClass: '.cherry-toggle',
buttonClass: '.cherry-component__button',
contentClass: '.cherry-settings__content',
buttonActiveClass: 'active',
showClass: 'show',
localStorage: {},
init: function () {
this.localStorage = this.getState() || {};
this.componentInit( this.tabClass );
this.componentInit( this.accordionClass );
this.componentInit( this.toggleClass );
this.addEvent();
},
addEvent: function() {
$( 'body' )
.off( 'click.cherryInterfaceBuilder' )
.on( 'click.cherryInterfaceBuilder',
this.tabClass + ' ' + this.buttonClass + ', ' +
this.toggleClass + ' ' + this.buttonClass + ', ' +
this.accordionClass + ' ' + this.buttonClass,
this.componentClick.bind( this )
);
},
componentInit: function( componentClass ) {
var _this = this,
components = $( componentClass ),
componentId = null,
button = null,
contentId = null,
notShow = '';
components.each( function( index, component ) {
component = $( component );
componentId = component.data( 'compotent-id' );
switch ( componentClass ) {
case _this.toggleClass:
if ( _this.localStorage[ componentId ] && _this.localStorage[ componentId ].length ) {
notShow = _this.localStorage[ componentId ].join( ', ' );
}
$( _this.contentClass, component )
.not( notShow )
.addClass( _this.showClass )
.prevAll( _this.buttonClass )
.addClass( _this.buttonActiveClass );
break;
case _this.tabClass:
case _this.accordionClass:
if ( _this.localStorage[ componentId ] ) {
contentId = _this.localStorage[ componentId ][ 0 ];
button = $( '[data-content-id="' + contentId + '"]', component );
} else {
button = $( _this.buttonClass, component ).eq( 0 );
contentId = button.data( 'content-id' );
}
_this.showElement( button, component, contentId );
break;
}
} );
},
componentClick: function( event ) {
var $target = $( event.target ),
$parent = $target.closest( this.tabClass + ', ' + this.accordionClass + ', ' + this.toggleClass ),
expr = new RegExp( this.tabClass + '|' + this.accordionClass + '|' + this.toggleClass ),
componentName = $parent[0].className.match( expr )[ 0 ].replace( ' ', '.' ),
contentId = $target.data( 'content-id' ),
componentId = $parent.data( 'compotent-id' ),
activeFlag = $target.hasClass( this.buttonActiveClass ),
itemClosed;
switch ( componentName ) {
case this.tabClass:
if ( ! activeFlag ) {
this.hideElement( $parent );
this.showElement( $target, $parent, contentId );
this.localStorage[ componentId ] = new Array( contentId );
this.setState();
}
break;
case this.accordionClass:
this.hideElement( $parent );
if ( ! activeFlag ) {
this.showElement( $target, $parent, contentId );
this.localStorage[ componentId ] = new Array( contentId );
} else {
this.localStorage[ componentId ] = {};
}
this.setState();
break;
case this.toggleClass:
$target
.toggleClass( this.buttonActiveClass )
.nextAll( contentId )
.toggleClass( this.showClass );
if ( Array.isArray( this.localStorage[ componentId ] ) ) {
itemClosed = this.localStorage[ componentId ].indexOf( contentId );
if ( -1 !== itemClosed ) {
this.localStorage[ componentId ].splice( itemClosed, 1 );
} else {
this.localStorage[ componentId ].push( contentId );
}
} else {
this.localStorage[ componentId ] = new Array( contentId );
}
this.setState();
break;
}
$target.blur();
return false;
},
showElement: function ( button, holder, contentId ) {
button
.addClass( this.buttonActiveClass );
holder
.data( 'content-id', contentId );
$( contentId, holder )
.addClass( this.showClass );
},
hideElement: function ( holder ) {
var contsntId = holder.data( 'content-id' );
$( '[data-content-id="' + contsntId + '"]', holder )
.removeClass( this.buttonActiveClass );
$( contsntId, holder )
.removeClass( this.showClass );
},
getState: function() {
try {
return JSON.parse( localStorage.getItem( 'interface-builder' ) );
} catch ( e ) {
return false;
}
},
setState: function() {
try {
localStorage.setItem( 'interface-builder', JSON.stringify( this.localStorage ) );
} catch ( e ) {
return false;
}
}
}
};
CherryJsCore.interfaceBuilder.init();
}( jQuery, window.CherryJsCore ) );

View File

@@ -0,0 +1,511 @@
$color-1: #fff; // Background color.
$widget-bg: #495159; // Background color in widgets.
$color-2: #efefef; // Background color.
$color-3: #96989a; // Description color and tabs button text color.
$color-4: #b4b7ba; //
$color-5: #f1f1f1; // Scrollbar background
$color-6: #e5e5e5; // Hover scrollbar background
$color-7: #206ff4; // Scrollbar track background
$link-color: #298ffc; // link color.
$link-hover-color: #23282d; // link hover color.
$shadow: 2px 2px 5px rgba(0,0,0,0.05); //Shadow.
$border: 1px solid rgba(0, 0, 0, 0.1) ;
$br-radius: 3px; // Border radius.
$padding: 5px;
$margin: 5px;
$max-heught: 700px;
@import "use-in-js";
html{
font-size: 13px;
}
.cherry-ui-kit{
h1{
font-weight: 700;
font-size: 2.308rem;
line-height: 2.308rem;
.dashicons{
font-size: 3rem;
line-height: inherit;
width: 20px;
margin: 0 $margin * 2 0 $margin * -0.5;
}
}
h2{
font-weight: 600;
font-size: 1.538rem;
line-height: 1.538rem;
.dashicons{
font-size: 2rem;
line-height: inherit;
width: 20px;
margin-right: $margin * 2;
}
}
h3{
font-weight: 600;
font-size: 1.231rem;
line-height: 1.231rem;
.dashicons{
font-size: 1.7rem;
line-height: inherit;
margin-right: $margin * 0.5;
}
}
h4{
font-weight: 500;
font-size: 1.077rem;
line-height: 1.077rem;
}
h5{
font-weight: 500;
font-size: 1.077rem;
line-height: 1.077rem;
}
h6{
font-weight: 400;
font-size: 1rem;
line-height: 1rem;
}
a{
color: $link-color;
text-decoration: none;
&:hover{
color: $link-hover-color;
}
&:focus{
outline: 1px solid rgba(41, 143, 252, .6);
box-shadow: 0px 0px 2px rgba(41,143,252,0.6);
}
}
&__description{
font-size: 0.9rem;
color: $color-3;
margin: $margin 0;
}
&__title{
margin: $margin*2 0;
}
&.hide{
display: none;
}
}
.cherry-control + .cherry-control, .cherry-settings + .cherry-control{
border-top: $border;
}
.cherry-section{
padding: $padding;
background-color: $color-1;
margin-left: -10px;
&__title, &__description{
margin: $margin 0 0 0;
}
& + .cherry-ui-kit {
border-top: $border;
}
@media ( min-width: 783px ) {
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
padding: $padding * 1.5;
margin: $margin * 1.5 $margin * 1.5 0 0;
&__holder{
background-color: $color-2;
border-radius: $br-radius;
padding: $padding * 1.5;
}
&__inner{
}
&__info{
background-color: $color-1;
border-radius: $br-radius;
padding: $padding * 1.5;
box-shadow: $shadow;
margin-bottom: $padding * 1.5;
}
.cherry-settings{
box-shadow: $shadow;
border-radius: $br-radius;
border: $border;
background-color: $color-1;
margin-top: $padding * 1.5;
&:first-child{
margin-top: 0;
}
}
}
@media ( min-width: 961px ) {
padding: $padding * 3;
margin: $margin * 2 $margin * 2 0 0;
&__info{
padding: $padding * 3;
margin-bottom: $padding * 3;
}
&__holder{
padding: $padding * 3;
}
.cherry-settings{
margin-top: $padding * 3;
}
}
}
.cherry-component{
padding: $padding * 2 0;
@media ( min-width: 783px ) {
padding: $padding * 1.5;
}
@media ( min-width: 961px ) {
padding: $padding * 3;
}
& + * {
border-top: $border;
}
&__title{
margin-top: 0;
}
& &__content{
.cherry-settings{
padding: 0;
border-top: none;
}
}
&__button{
display: block;
min-height: 45px;
.cherry-ui-kit__title {
color: inherit;
}
&.active, &:hover{
color: $link-color;
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
&:focus{
outline: none;
box-shadow: inset 0 0 1px 0 rgba(41,143,252,0.5);
transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
transition: all 300ms cubic-bezier(0.55, 0.055, 0.675, 0.19);
}
&.cherry-accordion, &.cherry-toggle{
.cherry-component__button{
width: 100%;
padding: $padding * 1.5 $padding * 2;
border:0;
background: none;
cursor: pointer;
position: relative;
.widget &{
background-color: $widget-bg;
color: $color-1;
}
.cherry-toggle__title {
font-weight: 700;
font-size: 14px;
float: left;
margin: 0;
}
>span[class*="icon"]{
position: absolute;
top: 50%;
right: 5px;
margin-top: -10px;
font-size: 25px;
color: $color-4;
padding: 5px 5px;
width: 10px;
height: 9px;
text-align: left;
overflow: hidden;
.widget &{
color: $color-1;
}
&.hide-icon{
&:before{
position: relative;
top: -8px;
left: -9px;
}
transform:scaleX(1);
transition: all 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
&.show-icon{
&:before{
position: relative;
top: -7px;
left: -9px;
}
transform:scaleX(0);
transition: all 300ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
}
&.active{
>span[class*="icon"]{
&.show-icon{
transform:scaleX(1);
transition-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
&.hide-icon{
transform:scaleX(0);
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
}
}
}
.cherry-component__button + .cherry-settings__content{
border-top: $border;
}
> .cherry-ui-kit__content{
& > .cherry-settings + .cherry-settings{
margin-top: $margin;
}
> .cherry-settings{
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
.widget &{
box-shadow:none;
border-radius: 0;
border-left: 0;
border-right: 0;
}
}
}
}
&.cherry-tab{
.cherry-tab__tabs{
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
border-bottom: $border;
.cherry-component__button{
order: 0;
flex: 0 1 100%;
align-self: auto;
padding: $padding * 1.5 $padding * 2;
border: 0;
background: none;
cursor: pointer;
&.active{
-ms-box-shadow: inset 0px -3px 0px 0px $link-color;
box-shadow: inset 0px -3px 0px 0px $link-color;
}
.cherry-tab__title {
font-weight: 700;
font-size: 14px;
float: left;
margin: 0;
}
& + button{
border-top: $border;
}
}
}
.cherry-tab__body{
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
background-color: $color-1;
.cherry-settings{
box-shadow: none;
border-radius: 0;
border: none;
background-color: inherit;
margin: 0;
}
}
@media ( min-width: 783px ) {
.cherry-tab__tabs{
border: solid 1px rgba(0,0,0,0.1);
.cherry-component__button{
& + button{
border-top: none;
}
}
}
.cherry-tab__body{
border: none;
.cherry-tab__content{
border: $border;
}
}
&--horizontal{
>.cherry-tab__body{
border-radius: none;
>.cherry-tab__tabs{
flex-wrap: nowrap;
flex-direction: row;
border-radius:$br-radius $br-radius 0 0;
border-bottom: none;
.cherry-component__button{
flex: 0 1 auto;
}
}
>.cherry-tab__content{
border-radius: 0 0 $br-radius $br-radius;
}
}
}
&--vertical{
>.cherry-tab__body{
display: flex;
border-radius: none;
>.cherry-tab__tabs{
flex-direction: row;
-webkit-box-flex: 0;
flex: 0 1 20%;
border-radius:$br-radius 0 0 $br-radius;
border-right: none;
.cherry-component__button{
text-align: right;
.cherry-tab__title {
width: 100%;
}
&.active{
box-shadow: inset -3px 0px 0px $link-color;
}
}
}
>.cherry-tab__content{
-webkit-box-flex: 0;
flex: 0 1 80%;
border-radius: 0 $br-radius $br-radius 0;
}
}
}
}
@media ( min-width: 1200px ) {
&--vertical{
.cherry-tab__tabs{
flex: 0 1 20%;
}
.cherry-tab__content{
flex: 0 1 80%;
}
}
}
}
.widget &{
padding: 0;
&__content{
margin: 0 $margin * -1.5 $margin * 2;
.cherry-control{
padding: $padding * 1.5 $padding * 2;
}
}
}
}
.cherry-settings{
& + & {
border-top: $border;
}
& &__title{
margin-bottom: $margin;
}
&__description, & &__title{
margin-left: $margin;
@media ( min-width: 783px ) {
margin-left: $margin * 1.5;
}
@media ( min-width: 961px ) {
margin-left: $margin * 3;
}
}
}
.cherry-control{
padding: $padding * 3 0;
margin: 0 $margin;
&__title{
margin: 0 0 $margin 0 ;
}
&__description{
margin-top: 0;
}
.cherry-ui-container {
margin: 0;
}
@media (min-width: 783px) {
padding: $padding * 4;
margin: 0 $margin * 1.5;
display: flex;
flex-flow: row nowrap;
&__info{
-webkit-box-flex: 0;
flex: 0 1 30%;
padding-right: $padding * 1.5;
}
&__content{
-webkit-box-flex: 0;
flex: 0 1 70%;
}
}
@media ( min-width: 961px ) {
padding: $padding * 6 0;
margin: 0 $margin * 3;
}
.widget & {
padding: $padding * 1.5 0;
flex-direction: column;
&__content{
-webkit-box-flex: 0;
flex: 0 1 100%;
}
&__info{
-webkit-box-flex: 0;
flex: 0 1 100%;
padding-right: 0;
}
}
}
.cherry-section.cherry-scroll > .cherry-section__holder > .cherry-section__inner,
.cherry-tab__content > .cherry-scroll,
.cherry-accordion__content > .cherry-scroll > .cherry-settings__content,
.cherry-toggle__content > .cherry-scroll > .cherry-settings__content,
{
@media ( min-width: 783px ) {
max-height: $max-heught;
overflow-y: auto;
position: relative;
&::-webkit-scrollbar {
width: 10px;
height: 10px;
&-button {
width: 0px;
height: 0px;
}
&-thumb {
background-color: $link-color;
border: none;
border-radius: $br-radius;
&:hover, &:active {
background: $color-7;
}
}
&-track {
background-color: $color-1;
border: none;
border-radius: $br-radius;
}
&-corner {
background: transparent;
}
}
}
}

View File

@@ -0,0 +1 @@
!function(t,s){"use strict";s.utilites.namespace("interfaceBuilder"),s.interfaceBuilder={init:function(){this.component.init(),t(document).on("cherryInterfaceBuilder",this.component.init.bind(this.component))},component:{tabClass:".cherry-tab",accordionClass:".cherry-accordion",toggleClass:".cherry-toggle",buttonClass:".cherry-component__button",contentClass:".cherry-settings__content",buttonActiveClass:"active",showClass:"show",localStorage:{},init:function(){this.localStorage=this.getState()||{},this.componentInit(this.tabClass),this.componentInit(this.accordionClass),this.componentInit(this.toggleClass),this.addEvent()},addEvent:function(){t("body").off("click.cherryInterfaceBuilder").on("click.cherryInterfaceBuilder",this.tabClass+" "+this.buttonClass+", "+this.toggleClass+" "+this.buttonClass+", "+this.accordionClass+" "+this.buttonClass,this.componentClick.bind(this))},componentInit:function(s){var e=this,a=t(s),o=null,i=null,n=null,l="";a.each(function(a,c){switch(c=t(c),o=c.data("compotent-id"),s){case e.toggleClass:e.localStorage[o]&&e.localStorage[o].length&&(l=e.localStorage[o].join(", ")),t(e.contentClass,c).not(l).addClass(e.showClass).prevAll(e.buttonClass).addClass(e.buttonActiveClass);break;case e.tabClass:case e.accordionClass:e.localStorage[o]?(n=e.localStorage[o][0],i=t('[data-content-id="'+n+'"]',c)):(i=t(e.buttonClass,c).eq(0),n=i.data("content-id")),e.showElement(i,c,n)}})},componentClick:function(s){var e,a=t(s.target),o=a.closest(this.tabClass+", "+this.accordionClass+", "+this.toggleClass),i=new RegExp(this.tabClass+"|"+this.accordionClass+"|"+this.toggleClass),n=o[0].className.match(i)[0].replace(" ","."),l=a.data("content-id"),c=o.data("compotent-id"),r=a.hasClass(this.buttonActiveClass);switch(n){case this.tabClass:r||(this.hideElement(o),this.showElement(a,o,l),this.localStorage[c]=new Array(l),this.setState());break;case this.accordionClass:this.hideElement(o),r?this.localStorage[c]={}:(this.showElement(a,o,l),this.localStorage[c]=new Array(l)),this.setState();break;case this.toggleClass:a.toggleClass(this.buttonActiveClass).nextAll(l).toggleClass(this.showClass),Array.isArray(this.localStorage[c])?(e=this.localStorage[c].indexOf(l),-1!==e?this.localStorage[c].splice(e,1):this.localStorage[c].push(l)):this.localStorage[c]=new Array(l),this.setState()}return a.blur(),!1},showElement:function(s,e,a){s.addClass(this.buttonActiveClass),e.data("content-id",a),t(a,e).addClass(this.showClass)},hideElement:function(s){var e=s.data("content-id");t('[data-content-id="'+e+'"]',s).removeClass(this.buttonActiveClass),t(e,s).removeClass(this.showClass)},getState:function(){try{return JSON.parse(localStorage.getItem("interface-builder"))}catch(t){return!1}},setState:function(){try{localStorage.setItem("interface-builder",JSON.stringify(this.localStorage))}catch(t){return!1}}}},s.interfaceBuilder.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,30 @@
<?php
/**
* Accordion template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-accordion <?php echo esc_attr( $__data['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ) ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-component__content cherry-accordion__content" role="group" >
<?php echo $__data['children'] ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,30 @@
<?php
/**
* Repeater template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-repeater <?php echo esc_attr( $__data['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-component__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,35 @@
<?php
/**
* Horizontal tab template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-tab cherry-tab--horizontal <?php echo esc_attr( $__data['class'] ) ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-tab__body" >
<div class="cherry-tab__tabs" role="navigation" >
<?php echo $__data['tabs']; ?>
</div>
<div class="cherry-ui-kit__content cherry-component__content cherry-tab__content" role="group" >
<?php echo $__data['children']; ?>
</div>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,35 @@
<?php
/**
* Verticall tab template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-tab cherry-tab--vertical <?php echo esc_attr( $__data['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-tab__body" >
<div class="cherry-tab__tabs" role="navigation" >
<?php echo $__data['tabs']; ?>
</div>
<div class="cherry-ui-kit__content cherry-component__content cherry-tab__content" role="group" >
<?php echo $__data['children']; ?>
</div>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,30 @@
<?php
/**
* Toggle template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-component cherry-toggle <?php echo esc_attr( $__data['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h2 class="cherry-ui-kit__title cherry-component__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-component__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-component__content cherry-toggle__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,34 @@
<?php
/**
* Control template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-control <?php echo esc_attr( $__data['class'] ); ?>">
<?php if ( ! empty( $__data['title'] ) || ! empty( $__data['description'] ) ) { ?>
<div class="cherry-control__info">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h4 class="cherry-ui-kit__title cherry-control__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h4>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-control__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
</div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-control__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,24 @@
<?php
/**
* Form template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<form class="cherry-form <?php echo esc_attr( $__data['class'] ); ?>" id="<?php echo esc_attr( $__data['id'] ); ?>" name="<?php echo esc_attr( $__data['id'] ); ?>" accept-charset="<?php echo esc_attr( $__data['accept-charset'] ); ?>" action="<?php echo esc_attr( $__data['action'] ); ?>" autocomplete="<?php echo esc_attr( $__data['autocomplete'] ); ?>" enctype="<?php echo esc_attr( $__data['enctype'] ); ?>" method="<?php echo esc_attr( $__data['method'] ); ?>" target="<?php echo esc_attr( $__data['target'] ); ?>" <?php echo esc_attr( $__data['novalidate'] ); ?> >
<?php
if ( ! empty( $__data['children'] ) ) {
echo $__data['children'];
}
?>
</form>

View File

@@ -0,0 +1,24 @@
<?php
/**
* HTML template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit <?php echo esc_attr( $__data['class'] ); ?>">
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,36 @@
<?php
/**
* Section template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-section <?php echo esc_attr( $__data['class'] ); ?>" onclick="void(0)">
<div class="cherry-section__holder">
<div class="cherry-section__inner">
<div class="cherry-section__info">
<?php if ( ! empty( $__data['title'] ) ) { ?>
<h1 class="cherry-ui-kit__title cherry-section__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h1>
<?php } ?>
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-section__description " role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
</div>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-section__content" role="group" >
<?php echo $__data['children']; ?>
</div>
<?php } ?>
</div>
</div>
</div>

View File

@@ -0,0 +1,18 @@
<?php
/**
* Settings title template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<h3 class="cherry-ui-kit__title cherry-settings__title" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h3>

View File

@@ -0,0 +1,32 @@
<?php
/**
* Settings template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cherry-ui-kit cherry-settings <?php echo esc_attr( $__data['class'] ); ?>">
<?php if ( ! empty( $__data['title'] ) ) {
echo $__data['title'];
} ?>
<?php if ( ! empty( $__data['children'] ) || ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__content cherry-settings__content" role="group" id="<?php echo esc_attr( $__data['id'] ); ?>" >
<?php if ( ! empty( $__data['description'] ) ) { ?>
<div class="cherry-ui-kit__description cherry-settings__description" role="note" ><?php echo wp_kses_post( $__data['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $__data['children'] ) ) { ?>
<?php echo $__data['children']; ?>
<?php } ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,20 @@
<?php
/**
* Tabs title template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<button class="cherry-tab__button cherry-component__button" role="button" title="<?php echo esc_attr( $__data['title'] ); ?>" aria-expanded="false" data-content-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<h3 class="cherry-ui-kit__title cherry-tab__title" aria-grabbed="true" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h3>
</button>

View File

@@ -0,0 +1,22 @@
<?php
/**
* Toggle title template.
*
* @package Cherry_Interface_Builder
* @subpackage Views
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<button class="cherry-toggle__header cherry-component__button" role="button" aria-expanded="false" data-content-id="#<?php echo esc_attr( $__data['id'] ); ?>">
<h3 class="cherry-ui-kit__title cherry-toggle__title" aria-grabbed="true" role="banner" ><?php echo wp_kses_post( $__data['title'] ); ?></h3>
<span class="dashicons dashicons-arrow-down hide-icon"></span>
<span class="dashicons dashicons-arrow-up show-icon"></span>
</button>

View File

@@ -0,0 +1,77 @@
var CherryJsCore = {};
( function( $ ) {
'use strict';
CherryJsCore = {
name: 'Cherry Js Core',
version: '1.0.0',
author: 'Cherry Team',
variable: {
$document: $( document ),
$window: $( window ),
browser_supported: true,
security: window.cherry_ajax,
loaded_assets: {
script: window.wp_load_script,
style: window.wp_load_style
},
ui_auto_init: ( 'true' === window.ui_init_object.auto_init ) ? true : false,
ui_auto_target: window.ui_init_object.targets
},
status: {
on_load: false,
is_ready: false
},
init: function(){
$( document ).on( 'ready', CherryJsCore.ready );
$( window ).on( 'load', CherryJsCore.load );
},
ready: function() {
CherryJsCore.status.is_ready = true;
// UI init after widget adding to sidebar
CherryJsCore.expressions.widget_ui_init();
},
load: function() {
CherryJsCore.status.on_load = true;
},
expressions: {
widget_ui_init: function() {
$( document ).on( 'widget-added widget-updated', function( event, data ) {
$( 'body' ).trigger( {
type: 'cherry-ui-elements-init',
_target: data
} );
} );
},
},
utilites: {
namespace: function( space_path ) {
var parts = space_path.split( '.' ),
parent = CherryJsCore,
length = parts.length,
i = 0;
for(i = 0; i < length; i += 1 ){
if( typeof parent[ parts[ i ] ] === 'undefined' ){
parent[ parts[ i ] ] = {};
}
parent = parent[ parts[ i ] ];
}
return parent;
}
}
};
CherryJsCore.init();
}(jQuery));

View File

@@ -0,0 +1 @@
var CherryJsCore={};!function(e){"use strict";(CherryJsCore={name:"Cherry Js Core",version:"1.0.0",author:"Cherry Team",variable:{$document:e(document),$window:e(window),browser_supported:!0,security:window.cherry_ajax,loaded_assets:{script:window.wp_load_script,style:window.wp_load_style},ui_auto_init:"true"===window.ui_init_object.auto_init,ui_auto_target:window.ui_init_object.targets},status:{on_load:!1,is_ready:!1},init:function(){e(document).on("ready",CherryJsCore.ready),e(window).on("load",CherryJsCore.load)},ready:function(){CherryJsCore.status.is_ready=!0,CherryJsCore.expressions.widget_ui_init()},load:function(){CherryJsCore.status.on_load=!0},expressions:{widget_ui_init:function(){e(document).on("widget-added widget-updated",function(r,t){e("body").trigger({type:"cherry-ui-elements-init",_target:t})})}},utilites:{namespace:function(e){var r=e.split("."),t=CherryJsCore,i=r.length,o=0;for(o=0;o<i;o+=1)void 0===t[r[o]]&&(t[r[o]]={}),t=t[r[o]];return t}}}).init()}(jQuery);

View File

@@ -0,0 +1,200 @@
<?php
/**
* Module Name: JS Core
* Description: Initializes global JS object which provides additional plugin functionality
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Js_Core' ) ) {
/**
* JS-core class.
*
* @since 1.0.0
* @since 1.0.1 Removed `module_directory` and `module_directory_uri` properties.
*/
class Cherry_Js_Core {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Core version.
*
* @since 1.5.0
* @access public
* @var string
*/
public $core_version = '';
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $module_path;
/**
* Default options.
*
* @since 1.0.0
* @var array
*/
private $options = array(
'product_type' => 'framework',
'src' => false,
'version' => false,
);
/**
* Class constructor.
*
* @since 1.0.0
* @param object $core Core instance.
* @param array $args Class args.
*/
public function __construct( $core, $args = array() ) {
$this->options = array_merge( $this->options, $args );
$this->core_version = $core->get_core_version();
$this->module_path = $args['module_path'];
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_cherry_scripts' ), 0 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_cherry_scripts' ), 0 );
add_action( 'wp_print_scripts', array( $this, 'localize_script' ) );
}
/**
* Register and enqueue JS-core.
*
* @since 1.0.0
*/
public function enqueue_cherry_scripts() {
if ( 'framework' === $this->options['product_type'] ) {
$src = esc_url( Cherry_Core::base_url( 'assets/js/min/cherry-js-core.min.js', $this->module_path ) );
$version = $this->core_version;
} else {
$src = ( ! empty( $this->options['src'] ) ? esc_url( $this->options['src'] ) : false );
$version = ( ! empty( $this->options['version'] ) ? absint( $this->options['src'] ) : false );
}
wp_enqueue_script(
'cherry-js-core',
$src,
array( 'jquery' ),
$this->core_version,
true
);
}
/**
* Retrieve a scripts list.
*
* @since 1.0.0
* @return $array
*/
private function get_include_script() {
return $this->add_suffix( '.js', wp_scripts()->queue );
}
/**
* Retrieve a styles list.
*
* @since 1.0.0
* @return $array
*/
private function get_include_style() {
return $this->add_suffix( '.css', wp_styles()->queue );
}
/**
* [get_ui_init_settings]
*
* @since 1.0.0
* @return $array
*/
private function get_ui_init_settings() {
// Default auto ui init settings.
$ui_init_settings = array(
'auto_init' => false,
'targets' => array(),
);
/**
* Filter to determine the list of selectors and the value of the automatic initialization ui js scripts
*
* @var array
*/
return apply_filters( 'cherry_core_js_ui_init_settings', $ui_init_settings );
}
/**
* Add suffix to array.
*
* @since 1.0.0
*/
private function add_suffix( $suffix, $array ) {
foreach ( $array as $key => $value ) {
$array[ $key ] = $value . $suffix;
}
return $array;
}
/**
* Prepare data for API script.
*
* @since 1.0.0
* @return void
*/
public function localize_script() {
wp_localize_script( 'cherry-js-core', 'wp_load_style', $this->get_include_style() );
wp_localize_script( 'cherry-js-core', 'wp_load_script', $this->get_include_script() );
wp_localize_script( 'cherry-js-core', 'cherry_ajax', wp_create_nonce( 'cherry_ajax_nonce' ) );
$ui_init_settings = $this->get_ui_init_settings();
$ui_init_settings['auto_init'] = ( true == $ui_init_settings['auto_init'] ) ? 'true' : 'false';
wp_localize_script( 'cherry-js-core', 'ui_init_object', $ui_init_settings );
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self( $core, $args );
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,68 @@
/**
* Post formats related scripts
* @use CherryJsCore
*/
( function($, CherryJsCore){
'use strict';
CherryJsCore.utilites.namespace( 'post_formats' );
CherryJsCore.post_formats = {
init: function () {
var self = this;
if ( CherryJsCore.status.document_ready ) {
self.render( self );
} else {
CherryJsCore.variable.$document.on( 'ready', self.render( self ) );
}
},
render: function ( self ) {
// Init slider scripts
self.initalize( 'slider' );
// Init popup scripts
self.initalize( 'popup' );
},
initalize: function( object ) {
$(window).load(function () {
$( '*[data-cherry' + object + '="1"]' ).each( function() {
var plugin = $( this ).data( object ),
init = $( this ).data( 'init' );
$( this ).data( 'initalized', false );
$( this ).trigger({
type: 'cherry-post-formats-custom-init',
item: $( this ),
object: object
});
if ( true === $( this ).data( 'initalized' ) ) {
return 1;
}
if ( ! plugin ) {
return !1;
}
if ( ! $.isFunction( jQuery.fn[ plugin ] ) ) {
return !1;
}
$( this )[ plugin ]( init );
});
});
}
};
CherryJsCore.post_formats.init();
} (jQuery, window.CherryJsCore) );

View File

@@ -0,0 +1 @@
!function(t,i){"use strict";i.utilites.namespace("post_formats"),i.post_formats={init:function(){var t=this;i.status.document_ready?t.render(t):i.variable.$document.on("ready",t.render(t))},render:function(t){t.initalize("slider"),t.initalize("popup")},initalize:function(i){t(window).load(function(){t("*[data-cherry"+i+'="1"]').each(function(){var n=t(this).data(i),e=t(this).data("init");return t(this).data("initalized",!1),t(this).trigger({type:"cherry-post-formats-custom-init",item:t(this),object:i}),!0===t(this).data("initalized")?1:n?t.isFunction(jQuery.fn[n])?(t(this)[n](e),void 0):!1:!1})})}},i.post_formats.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,81 @@
<?php
/**
* Facebook embed
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Facebook_Embed' ) ) {
/**
* Define Cherry_Facebook_Embed class
*/
class Cherry_Facebook_Embed {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
function __construct() {
add_filter( 'init', array( $this, 'add_facebook' ) );
}
/**
* Register Facebook provider
*
* @since 1.0.0
* @param array $providers Existing providers.
*/
public function add_facebook( $providers ) {
$endpoints = array(
'#https?://www\.facebook\.com/video.php.*#i' => 'https://www.facebook.com/plugins/video/oembed.json/',
'#https?://www\.facebook\.com/.*/videos/.*#i' => 'https://www.facebook.com/plugins/video/oembed.json/',
'#https?://www\.facebook\.com/.*/posts/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/.*/activity/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/photo(s/|.php).*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/permalink.php.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/media/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/questions/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
'#https?://www\.facebook\.com/notes/.*#i' => 'https://www.facebook.com/plugins/post/oembed.json/',
);
foreach ( $endpoints as $pattern => $endpoint ) {
wp_oembed_add_provider( $pattern, $endpoint, true );
}
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance() {
// If the single instance hasn't been set, set it now.
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
}
}

View File

@@ -0,0 +1,545 @@
<?php
/**
* Module Name: Post Meta
* Description: Manage post meta
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Post_Meta' ) ) {
/**
* Post meta management module.
*
* @since 1.0.0
* @since 1.0.2 Removed `module_directory` property.
*/
class Cherry_Post_Meta {
/**
* Module slug.
*
* @var string
*/
public $module_slug = 'cherry-post-meta';
/**
* Module arguments.
*
* @var array
*/
public $args = array();
/**
* Interface builder instance.
*
* @var object
*/
public $builder = null;
/**
* Core instance.
*
* @var object
*/
public $core = null;
/**
* Current nonce name to check.
*
* @var null
*/
public $nonce = 'cherry-meta-nonce';
/**
* Storage of meta values.
*
* @since 1.0.0
* @var array
*/
public $meta_values = array();
/**
* Constructor for the module.
*
* @since 1.0.0
*/
public function __construct( $core, $args ) {
$this->core = $core;
$this->args = wp_parse_args(
$args,
array(
'id' => 'cherry-post-metabox',
'title' => '',
'page' => array( 'post' ),
'context' => 'normal',
'priority' => 'high',
'single' => false,
'callback_args' => false,
'fields' => array(),
)
);
if ( empty( $this->args['fields'] ) ) {
return;
}
$this->builder = $this->core->init_module( 'cherry-interface-builder', array() );
$this->init_columns_actions();
if ( ! $this->builder ) {
return;
}
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 2 );
add_action( 'save_post', array( $this, 'save_meta' ), 10, 2 );
}
/**
* Initalize admin columns
*
* @return void
*/
public function init_columns_actions() {
if ( empty( $this->args['admin_columns'] ) ) {
return;
}
if ( ! is_array( $this->args['page'] ) ) {
$pages = array( $this->args['page'] );
} else {
$pages = $this->args['page'];
}
foreach ( $pages as $page ) {
add_filter( 'manage_edit-' . $page . '_columns', array( $this, 'edit_columns' ) );
add_action( 'manage_' . $page . '_posts_custom_column', array( $this, 'manage_columns' ), 10, 2 );
}
}
/**
* Edit admin columns
*
* @since 1.1.3
* @param array $columns current post table columns.
* @return array
*/
public function edit_columns( $columns ) {
foreach ( $this->args['admin_columns'] as $column_key => $column_data ) {
if ( empty( $column_data['label'] ) ) {
continue;
}
if ( ! empty( $column_data['position'] ) && 0 !== (int) $column_data['position'] ) {
$length = count( $columns );
if ( (int) $column_data['position'] > $length ) {
$columns[ $column_key ] = $column_data['label'];
}
$columns_before = array_slice( $columns, 0, (int) $column_data['position'] );
$columns_after = array_slice( $columns, (int) $column_data['position'], $length - (int) $column_data['position'] );
$columns = array_merge(
$columns_before,
array(
$column_key => $column_data['label'],
),
$columns_after
);
} else {
$columns[ $column_key ] = $column_data['label'];
}
}
return $columns;
}
/**
* Add output for custom columns.
*
* @since 1.1.3
* @param string $column current post list categories.
* @param int $post_id current post ID.
* @return void
*/
public function manage_columns( $column, $post_id ) {
if ( empty( $this->args['admin_columns'][ $column ] ) ) {
return;
}
if ( ! empty( $this->args['admin_columns'][ $column ]['callback'] ) && is_callable( $this->args['admin_columns'][ $column ]['callback'] ) ) {
call_user_func( $this->args['admin_columns'][ $column ]['callback'], $column, $post_id );
} else {
echo get_post_meta( $post_id, $column, true );
}
}
/**
* Check if defined metabox is allowed on current page
*
* @since 1.0.0
* @return boolean
*/
public function is_allowed_page() {
global $current_screen;
if ( empty( $current_screen ) ) {
return false;
}
if ( is_array( $this->args['page'] ) && ! in_array( $current_screen->id, $this->args['page'] ) ) {
return false;
}
if ( is_string( $this->args['page'] ) && $current_screen->id !== $this->args['page'] ) {
return false;
}
return true;
}
/**
* Add meta box handler
*
* @since 1.0.0
* @param [type] $post_type The post type of the current post being edited.
* @param object $post The current post object.
* @return void
*/
public function add_meta_boxes( $post_type, $post ) {
if ( ! $this->is_allowed_page() ) {
return;
}
add_meta_box(
$this->args['id'],
$this->args['title'],
array( $this, 'render_metabox' ),
$this->args['page'],
$this->args['context'],
$this->args['priority'],
$this->args['callback_args']
);
}
/**
* Render metabox funciton
*
* @since 1.0.0
* @param object $post The post object currently being edited.
* @param array $metabox Specific information about the meta box being loaded.
* @return void
*/
public function render_metabox( $post, $metabox ) {
/**
* Filter custom metabox output. Prevent from showing main box, if user output passed
*
* @var string
*/
$custom_box = apply_filters( 'cherry_post_meta_custom_box', false, $post, $metabox );
if ( false !== $custom_box ) {
echo $custom_box;
return;
}
wp_nonce_field( $this->nonce, $this->nonce );
/**
* Hook fires before metabox output started.
*/
do_action( 'cherry_post_meta_box_before' );
$this->get_fields( $post );
/**
* Hook fires after metabox output finished.
*/
do_action( 'cherry_post_meta_box_after' );
}
/**
* Get registered control fields
*
* @since 1.0.0
* @since 1.2.0 Use interface builder for HTML rendering.
* @param mixed $post Current post object.
* @return void
*/
public function get_fields( $post ) {
if ( is_array( $this->args['single'] ) && isset( $this->args['single']['key'] ) ) {
$this->meta_values = get_post_meta( $post->ID, $this->args['single']['key'], true );
}
$zero_allowed = apply_filters(
'cherry_zero_allowed_controls',
array(
'stepper',
'slider',
)
);
foreach ( $this->args['fields'] as $key => $field ) {
$default = Cherry_Toolkit::get_arg( $field, 'value', '' );
$value = $this->get_meta( $post, $key, $default );
if ( isset( $field['options_callback'] ) ) {
$field['options'] = call_user_func( $field['options_callback'] );
}
$element = Cherry_Toolkit::get_arg( $field, 'element', 'control' );
$field['id'] = Cherry_Toolkit::get_arg( $field, 'id', $key );
$field['name'] = Cherry_Toolkit::get_arg( $field, 'name', $key );
$field['type'] = Cherry_Toolkit::get_arg( $field, 'type', '' );
$field['value'] = $value;
// Fix zero values for stepper and slider
if ( ! $value && in_array( $field['type'], $zero_allowed ) ) {
$field['value'] = 0;
}
$register_callback = 'register_' . $element;
if ( method_exists( $this->builder, $register_callback ) ) {
call_user_func( array( $this->builder, $register_callback ), $field );
}
}
$this->builder->render();
}
/**
* Save additional taxonomy meta on edit or create tax
*
* @since 1.0.0
* @param int $post_id The ID of the current post being saved.
* @param object $post The post object currently being saved.
* @return void|int
*/
public function save_meta( $post_id, $post = '' ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! isset( $_POST[ $this->nonce ] ) || ! wp_verify_nonce( $_POST[ $this->nonce ], $this->nonce ) ) {
return;
}
$posts = ! empty( $this->args['page'] ) ? $this->args['page'] : array( 'post' );
$posts = is_array( $posts ) ? $posts : array( $posts );
$maybe_break = false;
foreach ( $posts as $post_type ) {
if ( get_post_type( $post_id ) !== $post_type ) {
$maybe_break = true;
continue;
}
$maybe_break = false;
$obj = get_post_type_object( $post_type );
if ( ! isset( $obj->cap->edit_posts ) || ! current_user_can( $obj->cap->edit_posts ) ) {
$maybe_break = true;
continue;
}
break;
}
if ( true === $maybe_break ) {
return;
}
if ( ! $this->is_allowed_page() ) {
return;
}
if ( ! is_object( $post ) ) {
$post = get_post();
}
/**
* Hook on current metabox saving
*/
do_action( 'cherry_save_meta_' . $this->args['id'] );
if ( is_array( $this->args['single'] ) && isset( $this->args['single']['key'] ) ) {
$this->save_meta_mod( $post_id );
} else {
$this->save_meta_option( $post_id );
}
}
/**
* Save all meta values as a one array value in `wp_postmeta` table.
*
* @since 1.1.0
* @param int $post_id Post ID.
*/
public function save_meta_mod( $post_id ) {
$meta_key = $this->args['single']['key'];
// Array of new post meta value.
$new_meta_value = array();
if ( empty( $_POST[ $meta_key ] ) ) {
return;
}
foreach ( $_POST[ $meta_key ] as $key => $value ) {
$new_meta_value[ $key ] = $this->sanitize_meta( $key, $value );
}
// Get current post meta data.
$meta_value = get_post_meta( $post_id, $meta_key, true );
if ( $new_meta_value && '' == $meta_value ) {
add_post_meta( $post_id, $meta_key, $new_meta_value, true );
} elseif ( $new_meta_value && $new_meta_value != $meta_value ) {
update_post_meta( $post_id, $meta_key, $new_meta_value );
} elseif ( empty( $new_meta_value ) && $meta_value ) {
delete_post_meta( $post_id, $meta_key, $meta_value );
}
}
/**
* Save each meta value as a single value in `wp_postmeta` table.
*
* @since 1.1.0
* @param int $post_id Post ID.
*/
public function save_meta_option( $post_id ) {
foreach ( $this->args['fields'] as $key => $field ) {
if ( isset( $field['element'] ) && 'control' !== $field['element'] ) {
continue;
}
if ( empty( $_POST[ $key ] ) ) {
update_post_meta( $post_id, $key, false );
continue;
}
$value = $this->sanitize_meta( $key, $_POST[ $key ] );
update_post_meta( $post_id, $key, $value );
}
}
/**
* Sanitize passed meta value
*
* @since 1.1.3
* @param string $key Meta key to sanitize.
* @param mixed $value Meta value.
* @return mixed
*/
public function sanitize_meta( $key, $value ) {
if ( empty( $this->args['fields'][ $key ]['sanitize_callback'] ) ) {
return $this->sanitize_deafult( $value );
}
if ( ! is_callable( $this->args['fields'][ $key ]['sanitize_callback'] ) ) {
return $this->sanitize_deafult( $value );
}
return call_user_func(
$this->args['fields'][ $key ]['sanitize_callback'],
$value,
$key,
$this->args['fields'][ $key ]
);
}
/**
* Cleare value with sanitize_text_field if not is array
*
* @since 1.1.3
* @param mixed $value Passed value.
* @return mixed
*/
public function sanitize_deafult( $value ) {
return is_array( $value ) ? $value : sanitize_text_field( $value );
}
/**
* Retrieve post meta field.
*
* @since 1.1.0
* @since 1.2.0 Process default value.
*
* @param object $post Current post object.
* @param string $key The meta key to retrieve.
* @param mixed $default Default value.
* @return string
*/
public function get_meta( $post, $key, $default = false ) {
if ( ! is_object( $post ) ) {
return '';
}
if ( is_array( $this->args['single'] ) && isset( $this->args['single']['key'] ) ) {
return isset( $this->meta_values[ $key ] ) ? $this->meta_values[ $key ] : $default;
}
$meta = get_post_meta( $post->ID, $key, false );
return ( empty( $meta ) ) ? $default : $meta[0];
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
if ( ! is_admin() ) {
return;
}
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,301 @@
<?php
/**
* Module Name: Term Meta
* Description: Manage term metadata
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Term_Meta' ) ) {
/**
* Term meta management module
*/
class Cherry_Term_Meta {
/**
* Module slug
*
* @var string
*/
public $module_slug = 'cherry-term-meta';
/**
* Module arguments
*
* @var array
*/
public $args = array();
/**
* Existing field types
*
* @var array
*/
public $field_types = array();
/**
* UI builder instance
*
* @var object
*/
public $ui_builder = null;
/**
* Already registered field.
*
* @since 1.0.2
* @var array
*/
static public $register_fields = array();
/**
* Core instance
*
* @var object
*/
public $core = null;
/**
* Constructor for the module
*/
function __construct( $core, $args ) {
$this->core = $core;
$this->args = wp_parse_args( $args, array(
'tax' => 'category',
'priority' => 10,
'fields' => array(),
) );
if ( empty( $this->args['fields'] ) ) {
return;
}
add_action( 'admin_enqueue_scripts', array( $this, 'init_ui' ), 1 );
$priority = intval( $this->args['priority'] );
$tax = esc_attr( $this->args['tax'] );
add_action( "{$tax}_add_form_fields", array( $this, 'render_add_fields' ), $priority );
add_action( "{$tax}_edit_form_fields", array( $this, 'render_edit_fields' ), $priority, 2 );
add_action( "created_{$tax}", array( $this, 'save_meta' ) );
add_action( "edited_{$tax}", array( $this, 'save_meta' ) );
}
/**
* Init UI builder.
*
* @since 1.0.0
* @return bool
*/
public function init_ui() {
global $current_screen;
if ( empty( $current_screen ) || ! in_array( $current_screen->base, array( 'edit-tags', 'term' ) ) ) {
return false;
}
array_walk( $this->args['fields'], array( $this, 'set_field_types' ) );
if ( in_array( 'slider', $this->field_types ) ) {
$this->field_types[] = 'stepper';
}
$this->ui_builder = $this->core->init_module( 'cherry-ui-elements', $this->field_types );
return true;
}
/**
* Render add term form fields
*
* @since 1.0.0
* @param [type] $taxonomy taxonomy name.
* @return void
*/
public function render_add_fields( $taxonomy ) {
$format = '<div style="padding:10px 0;">%s</div>';
echo $this->get_fields( false, $taxonomy, $format );
}
/**
* Render edit term form fields
*
* @since 1.0.0
* @param object $term current term object.
* @param [type] $taxonomy taxonomy name.
* @return void
*/
public function render_edit_fields( $term, $taxonomy ) {
$format = '<tr class="form-field cherry-term-meta-wrap"><th>&nbsp;</th><td>%s</td></tr>';
echo $this->get_fields( $term, $taxonomy, $format );
}
/**
* Get registered control fields
*
* @since 1.0.0
* @param mixed $term current term object.
* @param [type] $taxonomy current taxonomy name.
* @return string
*/
public function get_fields( $term, $taxonomy, $format = '%s' ) {
$result = '';
foreach ( $this->args['fields'] as $key => $field ) {
if ( in_array( $key, Cherry_Term_Meta::$register_fields ) ) {
continue;
} else {
Cherry_Term_Meta::$register_fields[] = $key;
}
if ( false !== $term ) {
$value = get_term_meta( $term->term_id, $key, true );
} else {
$value = '';
}
$value = ! empty( $value ) ? $value : Cherry_Toolkit::get_arg( $field, 'value', '' );
if ( isset( $field['options_callback'] ) ) {
$options = call_user_func( $field['options_callback'] );
} else {
$options = Cherry_Toolkit::get_arg( $field, 'options', array() );
}
$args = array(
'type' => Cherry_Toolkit::get_arg( $field, 'type', 'text' ),
'id' => $key,
'name' => $key,
'value' => $value,
'label' => Cherry_Toolkit::get_arg( $field, 'label', '' ),
'options' => $options,
'multiple' => Cherry_Toolkit::get_arg( $field, 'multiple', false ),
'filter' => Cherry_Toolkit::get_arg( $field, 'filter', false ),
'size' => Cherry_Toolkit::get_arg( $field, 'size', 1 ),
'null_option' => Cherry_Toolkit::get_arg( $field, 'null_option', 'None' ),
'multi_upload' => Cherry_Toolkit::get_arg( $field, 'multi_upload', true ),
'library_type' => Cherry_Toolkit::get_arg( $field, 'library_type', 'image' ),
'upload_button_text' => Cherry_Toolkit::get_arg( $field, 'upload_button_text', 'Choose' ),
'max_value' => Cherry_Toolkit::get_arg( $field, 'max_value', '100' ),
'min_value' => Cherry_Toolkit::get_arg( $field, 'min_value', '0' ),
'max' => Cherry_Toolkit::get_arg( $field, 'max', '100' ),
'min' => Cherry_Toolkit::get_arg( $field, 'min', '0' ),
'step_value' => Cherry_Toolkit::get_arg( $field, 'step_value', '1' ),
'style' => Cherry_Toolkit::get_arg( $field, 'style', 'normal' ),
'display_input' => Cherry_Toolkit::get_arg( $field, 'display_input', true ),
'controls' => Cherry_Toolkit::get_arg( $field, 'controls', array() ),
'fields' => Cherry_Toolkit::get_arg( $field, 'fields', array() ),
'auto_parse' => Cherry_Toolkit::get_arg( $field, 'auto_parse', false ),
'icon_data' => Cherry_Toolkit::get_arg( $field, 'icon_data', array() ),
'toggle' => Cherry_Toolkit::get_arg( $field, 'toggle', array(
'true_toggle' => 'On',
'false_toggle' => 'Off',
'true_slave' => '',
'false_slave' => '',
) ),
'class' => Cherry_Toolkit::get_arg( $field, 'class' ),
'required' => Cherry_Toolkit::get_arg( $field, 'required', false ),
'placeholder' => Cherry_Toolkit::get_arg( $field, 'placeholder' ),
'master' => Cherry_Toolkit::get_arg( $field, 'master' ),
'title_field' => Cherry_Toolkit::get_arg( $field, 'title_field' ),
'ui_kit' => Cherry_Toolkit::get_arg( $field, 'ui_kit', true ),
);
$current_element = $this->ui_builder->get_ui_element_instance( $args['type'], $args );
$result .= sprintf( $format, $current_element->render() );
}
return $result;
}
/**
* Store field types used in this widget into class property
*
* @since 1.0.0
* @param array $field field data.
* @param [type] $id field key.
* @return bool
*/
public function set_field_types( $field, $id ) {
if ( is_array( $field ) || ! isset( $field['type'] ) ) {
return false;
}
if ( ! in_array( $field['type'], $this->field_types ) ) {
$this->field_types[] = $field['type'];
}
return true;
}
/**
* Save additional taxonomy meta on edit or create tax
*
* @since 1.0.0
* @param int $term_id Term ID.
* @return bool
*/
public function save_meta( $term_id ) {
if ( ! current_user_can( 'edit_posts' ) ) {
return false;
}
foreach ( $this->args['fields'] as $key => $field ) {
if ( ! isset( $_POST[ $key ] ) ) {
continue;
}
if ( is_array( $_POST[ $key ] ) ) {
$new_val = array_filter( $_POST[ $key ] );
} else {
$new_val = esc_attr( $_POST[ $key ] );
}
update_term_meta( $term_id, $key, $new_val );
}
return true;
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,217 @@
<?php
/**
* Module Name: Framework Toolkit
* Description: Framework Toolkit contains various PHP utilities
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_Toolkit' ) ) {
/**
* Various PHP utilities
*/
class Cherry_Toolkit {
/**
* Module slug
*
* @var string Module slug
*/
public $module_slug = 'cherry-toolkit';
/**
* Constructor for the module
*
* @param Cherry_Core $core Core instance.
* @param array $args Module arguments.
*/
public function __construct( $core, $args ) {}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
/**
* Safely get attribute from field settings array.
*
* @since 1.0.0
* @param array $field arguments array.
* @param string|int|float $arg argument key.
* @param mixed $default default argument value.
* @return mixed
*/
public static function get_arg( $field, $arg, $default = '' ) {
if ( is_array( $field ) && isset( $field[ $arg ] ) ) {
return $field[ $arg ];
}
return $default;
}
/**
* Get class instance
*
* @param string $class_name Class name.
* @param Cherry_Core $core Core instance.
* @param array $args Additional arguments.
* @return object New class instance.
* @throws InvalidArgumentException If class does not exists.
*/
public static function get_class_instance( $class_name = '', $core, $args ) {
if ( ! class_exists( $class_name ) ) {
throw new InvalidArgumentException( 'Class "' . $class_name . '" doesn\'t exists' );
}
return new $class_name( $core, $args );
}
/**
* Render view
*
* @param string $path View path.
* @param array $data Include data.
* @return string Rendered html.
*/
public static function render_view( $path, array $data = array() ) {
// Add parameters to temporary query variable.
if ( array_key_exists( 'wp_query', $GLOBALS ) ) {
if ( is_array( $GLOBALS['wp_query']->query_vars ) ) {
$GLOBALS['wp_query']->query_vars['__data'] = $data;
}
}
ob_start();
load_template( $path, false );
$result = ltrim( ob_get_clean() );
/**
* Remove temporary wp query variable
* Yeah. I'm paranoic.
*/
if ( array_key_exists( 'wp_query', $GLOBALS ) ) {
if ( is_array( $GLOBALS['wp_query']->query_vars ) ) {
unset( $GLOBALS['wp_query']->query_vars['__data'] );
}
}
// Return the compiled view and terminate the output buffer.
return $result;
}
/**
* Remove empty elements
*
* @param array $arr --- array with empty elements.
* @return array --- array without empty elements
*/
public static function remove_empty( $arr ) {
return array_filter( $arr, array( __CLASS__, 'remove_empty_check' ) );
}
/**
* Check if empty.
* It's need for PHP 5.2.4 version
*
* @param [type] $var variable.
* @return boolean
*/
public static function remove_empty_check( $var ) {
return '' != $var;
}
/**
* Join array to string
*
* @param array $arr --- array like 'key' => 'value'.
* @return string --- joined string
*/
public static function join( $arr = array() ) {
$arr = self::remove_empty( $arr );
$result = array();
foreach ( $arr as $key => $value ) {
$result[] = sprintf( '%s="%s"', $key, $value );
}
return implode( ' ', $result );
}
/**
* Lave just right keys in array
*
* @param array $right_keys right keys to leave.
* @param array $array list.
* @return array
*/
public static function leave_right_keys( $right_keys, $array ) {
$right_keys = (array) $right_keys;
$array = (array) $array;
if ( count( $array ) ) {
foreach ( $array as $key => $value ) {
if ( ! in_array( $key, $right_keys ) ) {
unset( $array[ $key ] );
}
}
}
return $array;
}
/**
* Safely get file content by path
*
* @param string $filepath Path to file.
* @return mixed
*/
public static function get_file( $filepath ) {
if ( ! file_exists( $filepath ) ) {
return false;
}
ob_start();
include $filepath;
return ob_get_clean();
}
/**
* Remove some keys form array
*
* @param [type] $right_keys keys to remove.
* @param [type] $array where we want remove this keys.
* @return array without keys
*/
public static function remove_right_keys( $right_keys, $array ) {
$right_keys = (array) $right_keys;
$array = (array) $array;
if ( count( $right_keys ) ) {
foreach ( $right_keys as $key ) {
if ( array_key_exists( $key, $array ) ) {
unset( $array[ $key ] );
}
}
}
return $array;
}
}
}

View File

@@ -0,0 +1,110 @@
$lock-bg-color: rgba(0,0,0,0.9);
.cherry-lock-element{
user-select: none;
cursor: no-drop;
position: relative;
filter: grayscale( 100% );
&.inline-block{
display: inline-block;
}
& label{
position: relative;
}
.cherry-lable-content,
.cherry-checkbox-item,
.select2-container,
> *:first-child{
opacity: 0.5;
pointer-events: none;
}
a.cherry-lock-element__area{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2000;
cursor: no-drop;
&:focus{
outline: none;
box-shadow: none;
}
&:hover{
.cherry-lock-element__label{
animation-name: lock_show;
animation-duration: 450ms;
animation-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);
}
}
}
&__label {
opacity: 0;
display: inline-block;
background-color: $lock-bg-color;
border-radius: 5px;
color: #fff;
padding: 8px 10px;
position: absolute;
white-space: nowrap;
top: -10px;
left: 50%;
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
will-change: auto;
pointer-events: none;
font-size: 14px;
line-height: 16px;
animation-name: lock_hide;
animation-duration: 200ms;
animation-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
animation-fill-mode: both;
transform-origin: 0% 0%;
* + *{
margin-right: 5px;
}
&:after {
border: solid;
border-color: $lock-bg-color transparent;
border-width: 6px 6px 0 6px;
bottom: -5px;
margin-left: -6px;
content: "";
left: 50%;
position: absolute;
}
}
}
@keyframes lock_show {
0% {
opacity: 0;
filter: blur(5px);
transform: scale( 0 ) translate(-50%, 200% );
}
60% {
opacity: 0.8;
transform: scale( 1.1 ) translate(-50%, -130% );
}
100% {
opacity: 1;
filter: blur(0px);
transform: scale( 1 ) translate(-50%, -100% );
}
}
@keyframes lock_hide {
0% {
opacity: 1;
filter: blur(0px);
transform: scale( 1 ) translate(-50%, -100%);
}
100% {
opacity: 0;
filter: blur(3px);
transform: scale( 0 ) translate(-50%, 200%);
}
}

View File

@@ -0,0 +1,171 @@
<?php
/**
* Module Name: UI Elements
* Description: Class for the building ui elements
* Author: Cherry Team
* Author URI: http://www.cherryframework.com/
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*
* @package Cherry_Framework
* @subpackage Modules
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Cherry_UI_Elements' ) ) {
/**
* Class for the building ui elements.
*
* @since 1.0.0
* @since 1.0.3 Removed `module_directory` and `module_directory_uri` properties.
*/
class Cherry_UI_Elements {
/**
* Default arguments.
*
* @since 1.0.0
* @var array
*/
private $args = array(
'ui_elements' => array(
'text',
'textarea',
'select',
'checkbox',
'radio',
'colorpicker',
'media',
'stepper',
'switcher',
'slider',
'repeater',
'iconpicker',
'button',
'dimensions',
),
);
/**
* Core version.
*
* @since 1.5.0
* @access public
* @var string
*/
public static $core_version = '';
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
public static $module_path;
/**
* Constructor.
*
* @since 1.0.0
* @param object $core Core.
* @param array $args Arguments.
*/
public function __construct( $core, $args ) {
$this->args = array_merge( $this->args, $args );
self::$core_version = $core->get_core_version();
self::$module_path = $args['module_path'];
$this->ui_elements_require();
// Load admin assets.
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 9 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 9 );
}
/**
* Get UI-element instance.
*
* @since 1.0.0
* @param [type] $ui_slug ui element.
* @param array $args arguments.
* @return object
*/
public function get_ui_element_instance( $ui_slug, $args ) {
if ( empty( $ui_slug ) ) {
echo '<p>Set an empty slug</p>';
return false;
}
if ( ! in_array( $ui_slug, $this->args['ui_elements'] ) ) {
echo '<p> Element <b>' . $ui_slug . '</b> has not been initialized in this instance!</p>';
return false;
}
$ui_class_name = 'UI_' . ucwords( $ui_slug );
if ( ! class_exists( $ui_class_name ) ) {
echo '<p>Class <b>' . $ui_class_name . '</b> not exist!</p>';
return false;
}
return new $ui_class_name( $args );
}
/**
* Require UI-elements.
*
* @since 1.0.0
* @return void
*/
public function ui_elements_require() {
// Add I_UI interface.
if ( ! interface_exists( 'I_UI' ) ) {
require_once( self::$module_path . 'i-ui.php' );
}
require_once( self::$module_path. 'ui-element.php' );
require_once( self::$module_path . 'inc/class-cherry-lock-element.php' );
if ( ! empty( $this->args['ui_elements'] ) ) {
foreach ( $this->args['ui_elements'] as $ui_element ) {
require_once( self::$module_path . 'inc/ui-elements/ui-' . $ui_element . '/ui-' . $ui_element . '.php' );
}
}
}
/**
* Load admin assets.
*
* @since 1.0.0
*/
public function enqueue_admin_assets() {
if ( ! empty( $this->args['ui_elements'] ) ) {
foreach ( $this->args['ui_elements'] as $ui_element ) {
$ui_class_name = 'UI_' . ucwords( $ui_element );
call_user_func( array( $ui_class_name, 'enqueue_assets' ) );
}
}
}
/**
* Returns the instance.
*
* @since 1.0.0
* @return object
*/
public static function get_instance( $core, $args ) {
return new self( $core, $args );
}
}
}

View File

@@ -0,0 +1,45 @@
<?php
/**
* I'am UI interface
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
/**
* UI element interface
*/
interface I_UI {
/**
* Enqueue javascript and stylesheet to UI element.
*/
public static function enqueue_assets();
/**
* Render UI element.
*
* @return string.
*/
public function render();
/**
* Get control name
*
* @return string control name.
*/
public function get_name();
/**
* Set control name
*
* @param [type] $name new control name.
*/
public function set_name( $name );
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* Class lock the elements
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If class `Cherry5_Lock_Element` doesn't exists yet.
if ( ! class_exists( 'Cherry5_Lock_Element' ) ) {
/**
* Cherry5_Lock_Element class.
*/
class Cherry5_Lock_Element {
/**
* Default settings.
*
* @since 1.4.3
* @access private
* @var array
*/
private $defaults_args = array();
/**
* The attributes of the class.
*
* @since 1.4.3
* @access private
* @var array
*/
private $args = array();
/**
* The status of locked element.
*
* @since 1.4.3
* @access private
* @var bool
*/
private $element_lock = false;
/**
* Constructor method for the class.
*
* @since 1.4.3
* @access public
* @return void
*/
public function __construct( $args = array() ) {
if ( ! is_array( $args ) || empty( $args ) || empty( $args['lock'] ) ) {
return false;
}
$this->element_lock = true;
$this->defaults_args = apply_filters( 'cherry5_lock_element_defaults', array(
'label' => esc_html__( 'Unlocked in PRO', 'cherry-framework' ),
'url' => '#',
'html' => '<a class="cherry-lock-element__area" target="_blank" href="%1$s" title="%3$s"><span class="cherry-lock-element__label">%2$s %3$s</span></a>',
'icon' => '<i class="fa fa-unlock-alt" aria-hidden="true"></i>',
'class' => 'cherry-lock-element',
), $args );
$this->args = wp_parse_args( $args['lock'], $this->defaults_args );
}
/**
* Return lock element HTML-class.
*
* @since 1.4.3
* @access public
* @return string
*/
public function get_class( $sub_class = '' ) {
if ( ! $this->element_lock ) {
return '';
}
$classes = array(
$this->args['class'],
$sub_class,
);
$classes = array_filter( $classes );
$classes = array_map( 'esc_attr', $classes );
return ' ' . join( ' ', $classes );
}
/**
* Return disabled attribute.
*
* @since 1.4.3
* @access public
* @return string
*/
public function get_disabled_attr() {
return $this->element_lock ? ' disabled' : '';
}
/**
* Return lock element HTML-markup.
*
* @since 1.4.3
* @access public
* @return string
*/
public function get_html() {
if ( ! $this->element_lock ) {
return '';
}
return sprintf( $this->args['html'],
esc_url( $this->args['url'] ),
$this->args['icon'],
esc_attr( $this->args['label'] )
);
}
}
}

View File

@@ -0,0 +1 @@
.cherry5-ui-button{position:relative;display:inline-block;font-size:11px;line-height:18px;text-decoration:none;padding:4px 22px;color:#23282d;text-transform:uppercase;border-radius:4px;border-width:1px;border-style:solid;outline:none;cursor:pointer;transition:all 200ms linear}.cherry5-ui-button:before{position:absolute;display:block;width:100%;height:100%;top:0;left:0;border-radius:4px;background-image:linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);content:''}.cherry5-ui-button:hover:before{background-image:linear-gradient(0deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%)}.cherry5-ui-button:active:before{opacity:0}.cherry5-ui-button.cherry5-ui-button-normal-style{color:#23282d;border-color:#d7d7d7 #b7b7b7 #b7b7b7 #d7d7d7;background-color:#f0f0f0}.cherry5-ui-button.cherry5-ui-button-normal-style:active{background-color:#e1e1e1;border-color:#9e9e9e #d7d7d7 #d7d7d7 #9e9e9e}.cherry5-ui-button.cherry5-ui-button-success-style{color:#fff;border-color:#49c56a #3a9e54 #3a9e54 #49c56a;background-color:#49c66a}.cherry5-ui-button.cherry5-ui-button-success-style:active{background-color:#3ba956;border-color:#2c7940 #49c56a #49c56a #2c7940}.cherry5-ui-button.cherry5-ui-button-primary-style{color:#fff;border-color:#5b9add #3e6a99 #3e6a99 #5b9add;background-color:#2a90fc}.cherry5-ui-button.cherry5-ui-button-primary-style:active{background-color:#206ff4;border-color:#2f5175 #5b9add #5b9add #2f5175}.cherry5-ui-button.cherry5-ui-button-secondary-style{color:#fff;border-color:#777879 #41464d #41464d #777879;background-color:#495159}.cherry5-ui-button.cherry5-ui-button-secondary-style:active{background-color:#495159;border-color:#2a2d31 #777879 #777879 #2a2d31}.cherry5-ui-button.cherry5-ui-button-danger-style{color:#fff;border-color:#e54444 #b83636 #b83636 #e54444;background-color:#e64545}.cherry5-ui-button.cherry5-ui-button-danger-style:active{background-color:#c73434;border-color:#912a2a #e54444 #e54444 #912a2a}.cherry5-ui-button.cherry5-ui-button-warning-style{color:#fff;border-color:#faa832 #c98627 #c98627 #faa832;background-color:#faa832}.cherry5-ui-button.cherry5-ui-button-warning-style:active{background-color:#ee8425;border-color:#9e6a1f #faa832 #faa832 #9e6a1f}

View File

@@ -0,0 +1,66 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
.cherry5-ui-button{
@include button_base();
&.cherry5-ui-button-normal-style {
color: $dark_color;
border-color: $normal_outset_1 $normal_outset_2 $normal_outset_2 $normal_outset_1;
background-color: $normal_gradint_2;
&:active {
background-color: $normal_bg_color;
border-color: darken( $normal_outset_2, 10%) $normal_outset_1 $normal_outset_1 darken( $normal_outset_2, 10%);
}
}
&.cherry5-ui-button-success-style {
color: $light_color;
border-color: $success_outset_1 $success_outset_2 $success_outset_2 $success_outset_1;
background-color: $success_gradint_2;
&:active {
background-color: $success_bg_color;
border-color: darken( $success_outset_2, 10%) $success_outset_1 $success_outset_1 darken( $success_outset_2, 10%);
}
}
&.cherry5-ui-button-primary-style {
color: $light_color;
border-color: $primary_outset_1 $primary_outset_2 $primary_outset_2 $primary_outset_1;
background-color: $primary_gradint_2;
&:active {
background-color: $primary_bg_color;
border-color: darken( $primary_outset_2, 10%) $primary_outset_1 $primary_outset_1 darken( $primary_outset_2, 10%);
}
}
&.cherry5-ui-button-secondary-style {
color: $light_color;
border-color: $secondary_outset_1 $secondary_outset_2 $secondary_outset_2 $secondary_outset_1;
background-color: $secondary_gradint_2;
&:active {
background-color: $secondary_bg_color;
border-color: darken( $secondary_outset_2, 10%) $secondary_outset_1 $secondary_outset_1 darken( $secondary_outset_2, 10%);
}
}
&.cherry5-ui-button-danger-style{
color: $light_color;
border-color: $danger_outset_1 $danger_outset_2 $danger_outset_2 $danger_outset_1;
background-color: $danger_gradint_2;
&:active {
background-color: $danger_bg_color;
border-color: darken( $danger_outset_2, 10%) $danger_outset_1 $danger_outset_1 darken( $danger_outset_2, 10%);
}
}
&.cherry5-ui-button-warning-style{
color: $light_color;
border-color: $warning_outset_1 $warning_outset_2 $warning_outset_2 $warning_outset_1;
background-color: $warning_gradint_2;
&:active {
background-color: $warning_bg_color;
border-color: darken( $warning_outset_2, 10%) $warning_outset_1 $warning_outset_1 darken( $warning_outset_2, 10%);
}
}
}

View File

@@ -0,0 +1,40 @@
@mixin button_base() {
position: relative;
display: inline-block;
font-size: 11px;
line-height: 18px;
text-decoration: none;
padding: 4px 22px;
color: $dark_color;
text-transform: uppercase;
border-radius: $border_radius_small;
border-width: 1px;
border-style: solid;
outline: none;
cursor: pointer;
transition: all 200ms linear;
&:before {
position: absolute;
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
border-radius: $border_radius_small;
background-image: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
content: '';
}
&:hover {
&:before {
background-image: linear-gradient(0deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
}
}
&:active {
&:before {
opacity: 0;
}
}
}

View File

@@ -0,0 +1,46 @@
$light_color: #ffffff;
$dark_color: #23282d;
$normal_bg_color: #e1e1e1;
$normal_gradint_1: #ffffff;
$normal_gradint_2: #f0f0f0;
$normal_outset_1: #d7d7d7;
$normal_outset_2: #b7b7b7;
$primary_bg_color: #206ff4;
$primary_gradint_1: #5fadff;
$primary_gradint_2: #2a90fc;
$primary_outset_1: #5b9add;
$primary_outset_2: #3e6a99;
$secondary_bg_color: #495159;
$secondary_gradint_1: #4c5054;
$secondary_gradint_2: #495159;
$secondary_outset_1: #777879;
$secondary_outset_2: #41464d;
$success_bg_color: #3ba956;
$success_gradint_1: #71e18f;
$success_gradint_2: #49c66a;
$success_outset_1: #49c56a;
$success_outset_2: #3a9e54;
$danger_bg_color: #c73434;
$danger_gradint_1: #f98888;
$danger_gradint_2: #e64545;
$danger_outset_1: #e54444;
$danger_outset_2: #b83636;
$warning_bg_color: #ee8425;
$warning_gradint_1: #ffcb81;
$warning_gradint_2: #faa832;
$warning_outset_1: #faa832;
$warning_outset_2: #c98627;
$border_radius_extra_small: 2px;
$border_radius_small: 4px;
$border_radius_medium: 6px;
$border_radius_large: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);

View File

@@ -0,0 +1,86 @@
<?php
/**
* Class for the building ui-button elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'UI_Button' ) ) {
/**
* Class for the building ui-button elements.
*/
class UI_Button extends UI_Element implements I_UI {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $defaults_settings = array(
'id' => 'cherry-ui-button-id',
'name' => 'cherry-ui-button-name',
'value' => 'button',
'disabled' => false,
'form' => '',
'formaction' => '',
'button_type' => 'button',
'style' => 'normal',
'content' => 'Button',
'class' => '',
'master' => '',
);
/**
* Constructor method for the UI_Button class.
*
* @since 1.0.0
*/
function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cherry-ui-button-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
}
/**
* Render html UI_Button.
*
* @since 1.0.0
*/
public function render() {
$html = Cherry_Toolkit::render_view(
Cherry_UI_Elements::$module_path . 'inc/ui-elements/ui-button/view/button-view.php',
$this->settings
);
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Button.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_style(
'ui-button',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-button/assets/min/ui-button.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Ui-Button view
*
* @package Cherry_UI_Elements
* @subpackage View
* @author Cherry Team <cherryframework@gmail.com>
* @copyright Copyright (c) 2012 - 2017, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
$classes = array( 'cherry5-ui-button', 'cherry5-ui-button-' . $__data['style'] . '-style', $__data['master'], $__data['class'], 'ui-button' );
$classes = array_filter( $classes );
$class = trim( implode( ' ', $classes ) );
$attrs = Cherry_Toolkit::join(
array(
'type' => esc_attr( $__data['button_type'] ),
'id' => esc_attr( $__data['id'] ),
'name' => esc_attr( $__data['name'] ),
'class' => esc_attr( $class ),
'form' => esc_attr( $__data['form'] ),
'formaction' => esc_attr( $__data['formaction'] ),
)
);
if ( filter_var( $__data['disabled'], FILTER_VALIDATE_BOOLEAN ) ) {
$attrs .= ' disabled';
}
?>
<button <?php echo $attrs; ?>><?php echo $__data['content']; ?></button>

View File

@@ -0,0 +1 @@
.cherry-lock-element{user-select:none;cursor:no-drop;position:relative;filter:grayscale(100%)}.cherry-lock-element.inline-block{display:inline-block}.cherry-lock-element label{position:relative}.cherry-lock-element .cherry-lable-content,.cherry-lock-element .cherry-checkbox-item,.cherry-lock-element .select2-container,.cherry-lock-element>*:first-child{opacity:0.5;pointer-events:none}.cherry-lock-element a.cherry-lock-element__area{position:absolute;top:0;left:0;width:100%;height:100%;z-index:2000;cursor:no-drop}.cherry-lock-element a.cherry-lock-element__area:focus{outline:none;box-shadow:none}.cherry-lock-element a.cherry-lock-element__area:hover .cherry-lock-element__label{animation-name:lock_show;animation-duration:450ms;animation-timing-function:cubic-bezier(0.165, 0.84, 0.44, 1)}.cherry-lock-element__label{opacity:0;display:inline-block;background-color:rgba(0,0,0,0.9);border-radius:5px;color:#fff;padding:8px 10px;position:absolute;white-space:nowrap;top:-10px;left:50%;box-shadow:2px 2px 5px 0px rgba(0,0,0,0.5);will-change:auto;pointer-events:none;font-size:14px;line-height:16px;animation-name:lock_hide;animation-duration:200ms;animation-timing-function:cubic-bezier(0.55, 0.055, 0.675, 0.19);animation-fill-mode:both;transform-origin:0% 0%}.cherry-lock-element__label *+*{margin-right:5px}.cherry-lock-element__label:after{border:solid;border-color:rgba(0,0,0,0.9) transparent;border-width:6px 6px 0 6px;bottom:-5px;margin-left:-6px;content:"";left:50%;position:absolute}@keyframes lock_show{0%{opacity:0;filter:blur(5px);transform:scale(0) translate(-50%, 200%)}60%{opacity:0.8;transform:scale(1.1) translate(-50%, -130%)}100%{opacity:1;filter:blur(0px);transform:scale(1) translate(-50%, -100%)}}@keyframes lock_hide{0%{opacity:1;filter:blur(0px);transform:scale(1) translate(-50%, -100%)}100%{opacity:0;filter:blur(3px);transform:scale(0) translate(-50%, 200%)}}.cherry-ui-container{margin:10px 0 20px 0}label.cherry-label{margin:0 0 5px 0;display:block}.hide{display:none !important}.cherry-checkbox-item{width:20px;height:20px;display:inline-block;border-radius:2px;margin-right:10px;margin-bottom:10px;cursor:pointer;position:relative;background-color:#f1f1f1;user-select:none;transition:all 0.4s cubic-bezier(0.77, 0, 0.175, 1)}.cherry-checkbox-item .marker{position:absolute;width:20px;height:20px;top:0px;left:0px;color:#fff;font-size:20px;transition:inherit;transform:scale(0)}.cherry-checkbox-item .marker:before{transition:inherit;position:relative;left:-1px}.cherry-lable-content{display:flex}.cherry-checkbox-input[checked]+.cherry-checkbox-item{background-color:#48c569}.cherry-checkbox-input[checked]+.cherry-checkbox-item .marker{transform:scale(1)}.cherry-checkbox-label{font-size:12px;line-height:20px;color:#23282d;user-select:none}.cherry-checkbox-label:focus{outline:1px solid rgba(41,143,252,0.6);box-shadow:0px 0px 2px rgba(41,143,252,0.6)}

View File

@@ -0,0 +1 @@
!function(e,t){"use strict";t.utilites.namespace("ui_elements.checkbox"),t.ui_elements.checkbox={inputClass:'.cherry-checkbox-input[type="hidden"]:not([name*="__i__"])',labelClass:".cherry-checkbox-label, .cherry-checkbox-item",init:function(){e(document).on("ready.cherry-ui-elements-init",this.addEvent.bind(this)).on("cherry-ui-elements-init",this.initState.bind(this))},addEvent:function(){e("body").on("click.masterSlave",this.labelClass,this.switchState.bind(this)),this.initState()},initState:function(){for(var t,i,s,n=e(this.inputClass),c=n.length-1;c>=0;c--)t=e(n[c]),i=t.data(),s=t.closest("form"),jQuery.isEmptyObject(i)||e("."+i.slave,s)[t[0].checked?"removeClass":"addClass"]("hide")},switchState:function(t){var i=e(t.currentTarget).siblings(this.inputClass),s=i.data(),n=i[0].checked,c=i.closest("form");i.val(n?"false":"true").attr("checked",!n).trigger("change"),jQuery.isEmptyObject(s)||e("."+s.slave,c)[n?"addClass":"removeClass"]("hide")}},t.ui_elements.checkbox.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,58 @@
/**
* Checkbox
*/
( function( $, CherryJsCore ) {
'use strict';
CherryJsCore.utilites.namespace('ui_elements.checkbox');
CherryJsCore.ui_elements.checkbox = {
inputClass: '.cherry-checkbox-input[type="hidden"]:not([name*="__i__"])',
labelClass: '.cherry-checkbox-label, .cherry-checkbox-item',
init: function() {
$( document )
.on( 'ready.cherry-ui-elements-init', this.addEvent.bind( this ) )
.on( 'cherry-ui-elements-init', this.initState.bind( this ) );
},
addEvent: function() {
$( 'body' ).on( 'click.masterSlave', this.labelClass, this.switchState.bind( this ) );
this.initState();
},
initState: function(){
var $_input = $( this.inputClass ),
i = $_input.length - 1,
$_target,
data,
wrapper;
for ( ; i >= 0; i-- ) {
$_target = $( $_input[ i ] );
data = $_target.data();
wrapper = $_target.closest('form');
if ( jQuery.isEmptyObject( data ) ) {
continue;
} else {
$( '.' + data.slave, wrapper )[ ( $_target[0].checked ) ? 'removeClass' : 'addClass' ]( 'hide' );
}
}
},
switchState: function( event ) {
var $_input = $( event.currentTarget ).siblings( this.inputClass ),
data = $_input.data(),
flag = $_input[0].checked,
wrapper = $_input.closest('form');
$_input
.val( ( flag ) ? 'false' : 'true' )
.attr( 'checked', ( flag ) ? false : true )
.trigger( 'change' );
if ( ! jQuery.isEmptyObject( data ) ) {
$( '.' + data.slave, wrapper )[ ( flag ) ? 'addClass' : 'removeClass' ]( 'hide' );
}
}
};
CherryJsCore.ui_elements.checkbox.init();
} ( jQuery, window.CherryJsCore ) );

View File

@@ -0,0 +1,69 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
@import "../../../../assets/sass/lock";
.cherry-ui-container{
margin: 10px 0 20px 0;
}
label.cherry-label{
margin: 0 0 5px 0;
display: block;
}
.hide{
display: none !important;
}
.cherry-checkbox-item{
width: 20px;
height: 20px;
display: inline-block;
border-radius: $border_radius_extra_small;
margin-right: 10px;
margin-bottom: 10px;
cursor: pointer;
position: relative;
background-color: $grey_color_3;
user-select: none;
transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
.marker{
position: absolute;
width: 20px;
height: 20px;
top: 0px;
left: 0px;
color: #fff;
font-size: 20px;
transition:inherit;
transform: scale(0);
&:before{
transition:inherit;
position: relative;
left: -1px;
}
}
}
.cherry-lable-content {
display: flex;
}
.cherry-checkbox-input{
&[checked]{
&+.cherry-checkbox-item{
background-color: $green_color;
.marker{
transform: scale(1);
}
}
}
}
.cherry-checkbox-label{
font-size: 12px;
line-height: 20px;
color: $dark_color_1;
user-select: none;
&:focus{
outline: 1px solid rgba(41, 143, 252, .6);
box-shadow: 0px 0px 2px rgba(41,143,252,0.6);
}
}

View File

@@ -0,0 +1,184 @@
@mixin button_base() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
padding: 15px 20px;
color: #fff;
text-transform: uppercase;
border-radius: $border_radius_small;
transition: all 200ms linear;
box-shadow: $box_shadow;
&:hover {
color: #fff;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: #fff;
}
}
@mixin button_normal() {
background: $dark_color_2;
&:hover {
background: $dark_color_2_h;
}
}
@mixin button_primary() {
background: $blue_color;
&:hover {
background: $blue_color_h;
}
}
@mixin button_success() {
background: $green_color;
&:hover {
background: $green_color_h;
}
}
@mixin button_danger() {
background: $red_color;
&:hover {
background: $red_color_h;
}
}
@mixin button_warning() {
background: $orange_color;
&:hover {
background: $orange_color_h;
}
}
@mixin input() {
font-size: 14px;
line-height: 20px;
color: $dark_color_1;
background-color: $grey_color_3;
border-radius: $border_radius_extra_small;
padding: 10px 20px;
min-height: 50px;
border: 1px solid $grey_color_3;
box-shadow: none;
&:focus{
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
}
}
@mixin button_icon( $icon ) {
content: $icon;
display: inline-block;
font-family: dashicons;
font-size: 16px;
font-style: normal;
font-weight: 400;
height: 18px;
line-height: 18px;
text-align: center;
text-decoration: inherit;
transition: all 200ms linear;
vertical-align: middle;
}
@mixin button_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
}
}
@mixin button_icon_after( $icon ) {
&:after {
@include button_icon( $icon );
padding: 0 0 0 5px;
}
}
@mixin button_icon_middle( $icon ) {
&:before {
@include button_icon( $icon );
margin: 0 -5px;
}
}
@mixin link() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
color: $blue_color;
text-transform: uppercase;
transition: all 200ms linear;
&:hover {
color: $dark_color_1;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: $blue_color;
}
}
@mixin link_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
color: $grey_color_4;
}
&:hover {
&:before {
color: $blue_color;
}
}
}
@mixin container() {
padding: 30px;
border: 2px solid $grey_color_2;
background: $grey_color_3;
border-radius: $border_radius_large;
}
@mixin container_heading() {
margin: -30px -30px 30px -30px;
border-radius: $border_radius_large $border_radius_large 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
text-align: center;
background: #fff;
}
@mixin box() {
margin: 0 0 30px;
padding: 20px;
background: #fff;
box-shadow: $box_shadow_box;
border-radius: $border_radius;
}
@mixin box_heading() {
margin: -20px -20px 20px -20px;
border-radius: $border_radius_small $border_radius_small 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
background: #fff;
}

View File

@@ -0,0 +1,23 @@
$dark_color_1: #23282d;
$dark_color_2: #495159;
$dark_color_2_h: #393f45;
$grey_color_1: #96989a;
$grey_color_2: #e5e5e5;
$grey_color_3: #f1f1f1;
$grey_color_4: #b4b7ba;
$blue_color: #298ffc;
$blue_color_h: #206ff4;
$green_color: #48c569;
$green_color_h: #3ba956;
$red_color: #e54343;
$red_color_h: #c73434;
$orange_color: #faa730;
$orange_color_h: #ee8425;
$border_radius_extra_small: 2px;
$border_radius_small: 4px;
$border_radius_medium: 6px;
$border_radius_large: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);

View File

@@ -0,0 +1,154 @@
<?php
/**
* Class for the building ui-checkbox elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'UI_Checkbox' ) ) {
/**
* Class for the building UI_Checkbox elements.
*/
class UI_Checkbox extends UI_Element implements I_UI {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $defaults_settings = array(
'id' => 'cherry-ui-checkbox-id',
'name' => 'cherry-ui-checkbox-name',
'value' => array(
'checkbox-1' => 'true',
'checkbox-2' => 'true',
'checkbox-3' => 'true',
),
'options' => array(
'checkbox-1' => 'checkbox 1',
'checkbox-2' => 'checkbox 2',
'checkbox-3' => 'checkbox 3',
),
'label' => '',
'class' => '',
'master' => '',
);
/**
* Instance of this Cherry5_Lock_Element class.
*
* @since 1.0.0
* @var object
* @access private
*/
private $lock_element = null;
/**
* Constructor method for the UI_Checkbox class.
*
* @since 1.0.0
*/
function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cherry-ui-checkbox-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
$this->lock_element = new Cherry5_Lock_Element( $this->settings );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
}
/**
* Render html UI_Checkbox.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
$this->settings['master'],
$this->lock_element->get_class( 'inline-block' ),
)
);
$html .= '<div class="cherry-ui-container ' . esc_attr( $class ) . '">';
$counter = 0;
if ( $this->settings['options'] && ! empty( $this->settings['options'] ) && is_array( $this->settings['options'] ) ) {
if ( ! is_array( $this->settings['value'] ) ) {
$this->settings['value'] = array( $this->settings['value'] );
}
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
foreach ( $this->settings['options'] as $option => $option_value ) {
$lock_option = new Cherry5_Lock_Element( $option_value );
if ( ! empty( $this->settings['value'] ) ) {
$option_checked = array_key_exists( $option, $this->settings['value'] ) ? $option : '';
$item_value = ! empty( $option_checked ) ? $this->settings['value'][ $option ] : 'false';
} else {
$option_checked = '';
$item_value = 'false';
}
$checked = ( ! empty( $option_checked ) && 'true' === $item_value ) ? 'checked' : '';
$option_label = isset( $option_value ) && is_array( $option_value ) ? $option_value['label'] : $option_value;
$data_slave = isset( $option_value['slave'] ) && ! empty( $option_value['slave'] ) ? ' data-slave="' . $option_value['slave'] . '"' : '';
$html .= '<div class="cherry-checkbox-item-wrap">';
$html .= '<span class="' . $lock_option->get_class( 'inline-block' ) . '"">';
$html .= '<span class="cherry-lable-content">';
$html .= '<input type="hidden" id="' . esc_attr( $this->settings['id'] ) . '-' . $counter . '" class="cherry-checkbox-input" name="' . esc_attr( $this->settings['name'] ) . '[' . $option . ']" ' . $checked . ' value="' . esc_html( $item_value ) . '"' . $data_slave . $lock_option->get_disabled_attr() . '>';
$html .= '<div class="cherry-checkbox-item"><span class="marker dashicons dashicons-yes"></span></div>';
$html .= '<label class="cherry-checkbox-label" for="' . esc_attr( $this->settings['id'] ) . '-' . $counter . '"><span class="cherry-lable-content">' . esc_html( $option_label ) . '</span></label> ';
$html .= '</span>';
$html .= $lock_option->get_html();
$html .= '</span>';
$html .= '</div>';
$counter++;
}
}
$html .= $this->lock_element->get_html() . '</div>';
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Checkbox.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_script(
'ui-checkbox',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-checkbox/assets/min/ui-checkbox.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
wp_enqueue_style(
'ui-checkbox',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-checkbox/assets/min/ui-checkbox.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
}
}
}

View File

@@ -0,0 +1 @@
.cherry-lock-element{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:no-drop;position:relative;-webkit-filter:grayscale(100%);filter:grayscale(100%)}.cherry-lock-element.inline-block{display:inline-block}.cherry-lock-element label{position:relative}.cherry-lock-element .cherry-lable-content,.cherry-lock-element .cherry-checkbox-item,.cherry-lock-element .select2-container,.cherry-lock-element>*:first-child{opacity:0.5;pointer-events:none}.cherry-lock-element a.cherry-lock-element__area{position:absolute;top:0;left:0;width:100%;height:100%;z-index:2000;cursor:no-drop}.cherry-lock-element a.cherry-lock-element__area:focus{outline:none;box-shadow:none}.cherry-lock-element a.cherry-lock-element__area:hover .cherry-lock-element__label{-webkit-animation-name:lock_show;animation-name:lock_show;-webkit-animation-duration:450ms;animation-duration:450ms;-webkit-animation-timing-function:cubic-bezier(0.165, 0.84, 0.44, 1);animation-timing-function:cubic-bezier(0.165, 0.84, 0.44, 1)}.cherry-lock-element__label{opacity:0;display:inline-block;background-color:rgba(0,0,0,0.9);border-radius:5px;color:#fff;padding:8px 10px;position:absolute;white-space:nowrap;top:-10px;left:50%;box-shadow:2px 2px 5px 0px rgba(0,0,0,0.5);will-change:auto;pointer-events:none;font-size:14px;line-height:16px;-webkit-animation-name:lock_hide;animation-name:lock_hide;-webkit-animation-duration:200ms;animation-duration:200ms;-webkit-animation-timing-function:cubic-bezier(0.55, 0.055, 0.675, 0.19);animation-timing-function:cubic-bezier(0.55, 0.055, 0.675, 0.19);-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-transform-origin:0% 0%;-ms-transform-origin:0% 0%;transform-origin:0% 0%}.cherry-lock-element__label *+*{margin-right:5px}.cherry-lock-element__label:after{border:solid;border-color:rgba(0,0,0,0.9) transparent;border-width:6px 6px 0 6px;bottom:-5px;margin-left:-6px;content:"";left:50%;position:absolute}@-webkit-keyframes lock_show{0%{opacity:0;-webkit-filter:blur(5px);filter:blur(5px);-webkit-transform:scale(0) translate(-50%, 200%);transform:scale(0) translate(-50%, 200%)}60%{opacity:0.8;-webkit-transform:scale(1.1) translate(-50%, -130%);transform:scale(1.1) translate(-50%, -130%)}100%{opacity:1;-webkit-filter:blur(0px);filter:blur(0px);-webkit-transform:scale(1) translate(-50%, -100%);transform:scale(1) translate(-50%, -100%)}}@keyframes lock_show{0%{opacity:0;-webkit-filter:blur(5px);filter:blur(5px);-webkit-transform:scale(0) translate(-50%, 200%);transform:scale(0) translate(-50%, 200%)}60%{opacity:0.8;-webkit-transform:scale(1.1) translate(-50%, -130%);transform:scale(1.1) translate(-50%, -130%)}100%{opacity:1;-webkit-filter:blur(0px);filter:blur(0px);-webkit-transform:scale(1) translate(-50%, -100%);transform:scale(1) translate(-50%, -100%)}}@-webkit-keyframes lock_hide{0%{opacity:1;-webkit-filter:blur(0px);filter:blur(0px);-webkit-transform:scale(1) translate(-50%, -100%);transform:scale(1) translate(-50%, -100%)}100%{opacity:0;-webkit-filter:blur(3px);filter:blur(3px);-webkit-transform:scale(0) translate(-50%, 200%);transform:scale(0) translate(-50%, 200%)}}@keyframes lock_hide{0%{opacity:1;-webkit-filter:blur(0px);filter:blur(0px);-webkit-transform:scale(1) translate(-50%, -100%);transform:scale(1) translate(-50%, -100%)}100%{opacity:0;-webkit-filter:blur(3px);filter:blur(3px);-webkit-transform:scale(0) translate(-50%, 200%);transform:scale(0) translate(-50%, 200%)}}.cherry-ui-elements-lock{opacity:0.5;cursor:no-drop;pointer-events:none;-webkit-filter:grayscale(100%);filter:grayscale(100%)}.cherry-ui-container{margin:10px 0 20px 0}label.cherry-label{margin:0 0 5px 0;display:block}.cherry-ui-colorpicker-wrapper .wp-picker-container{padding:3px;border-radius:3px}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result-text{line-height:18px;text-align:right}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result{width:105px;height:26px;padding:0;border:none;margin:0;box-shadow:inset 0 0 0 3px white;border:1px solid #d5dadf}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result:focus{border:1px solid #9ba7b3;outline:none}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-color-result:after{display:none}.cherry-ui-colorpicker-wrapper .wp-picker-container .wp-picker-input-wrap{margin:1px 0}.cherry-ui-colorpicker-wrapper .wp-picker-container.wp-picker-active .wp-color-result{margin-right:6px}.cherry-ui-colorpicker-wrapper .wp-picker-container .iris-picker{position:absolute;z-index:999}

View File

@@ -0,0 +1 @@
!function(e,r){"use strict";r.utilites.namespace("ui_elements.colorpicker"),r.ui_elements.colorpicker={init:function(){e(document).on("ready",this.render).on("cherry-ui-elements-init",this.render)},render:function(r){var i=r._target?r._target:e("body"),n=e('input.cherry-ui-colorpicker:not([name*="__i__"])',i);n[0]&&n.wpColorPicker()}},r.ui_elements.colorpicker.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,26 @@
/**
* ColorPicker
*/
( function( $, CherryJsCore ) {
'use strict';
CherryJsCore.utilites.namespace('ui_elements.colorpicker');
CherryJsCore.ui_elements.colorpicker = {
init: function () {
$( document )
.on( 'ready', this.render )
.on( 'cherry-ui-elements-init', this.render );
},
render: function ( event ) {
var target = ( event._target ) ? event._target : $( 'body' ),
input = $( 'input.cherry-ui-colorpicker:not([name*="__i__"])', target );
if ( input[0] ) {
input.wpColorPicker();
}
}
};
CherryJsCore.ui_elements.colorpicker.init();
}( jQuery, window.CherryJsCore ));

View File

@@ -0,0 +1,68 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
@import "../../../../assets/sass/lock";
$font_size: 14px;
.cherry-ui-elements-lock {
opacity: 0.5;
cursor: no-drop;
pointer-events: none;
filter: grayscale( 100% );
}
.cherry-ui-container {
margin: 10px 0 20px 0;
}
label.cherry-label {
margin: 0 0 5px 0;
display: block;
}
.cherry-ui-colorpicker-wrapper {
.wp-picker-container {
padding: 3px;
border-radius: 3px;
.wp-color-result-text {
line-height: 18px;
text-align: right;
}
.wp-color-result {
width: 105px;
height: 26px;
padding: 0;
border: none;
margin: 0;
box-shadow: inset 0 0 0 3px white;
border: 1px solid #d5dadf;
&:focus {
border: 1px solid #9ba7b3;
outline: none;
}
&:after {
display: none;
}
}
.wp-picker-input-wrap {
margin: 1px 0;
}
&.wp-picker-active {
.wp-color-result {
margin-right: 6px;
}
}
.iris-picker {
position: absolute;
z-index: 999;
}
}
}

View File

@@ -0,0 +1,184 @@
@mixin button_base() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
padding: 15px 20px;
color: #fff;
text-transform: uppercase;
border-radius: $border_radius_small;
transition: all 200ms linear;
box-shadow: $box_shadow;
&:hover {
color: #fff;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: #fff;
}
}
@mixin button_normal() {
background: $dark_color_2;
&:hover {
background: $dark_color_2_h;
}
}
@mixin button_primary() {
background: $blue_color;
&:hover {
background: $blue_color_h;
}
}
@mixin button_success() {
background: $green_color;
&:hover {
background: $green_color_h;
}
}
@mixin button_danger() {
background: $red_color;
&:hover {
background: $red_color_h;
}
}
@mixin button_warning() {
background: $orange_color;
&:hover {
background: $orange_color_h;
}
}
@mixin input() {
font-size: 14px;
line-height: 20px;
color: $dark_color_1;
background-color: $grey_color_3;
border-radius: $border_radius_extra_small;
padding: 10px 20px;
min-height: 50px;
border: 1px solid $grey_color_3;
box-shadow: none;
&:focus{
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
}
}
@mixin button_icon( $icon ) {
content: $icon;
display: inline-block;
font-family: dashicons;
font-size: 16px;
font-style: normal;
font-weight: 400;
height: 18px;
line-height: 18px;
text-align: center;
text-decoration: inherit;
transition: all 200ms linear;
vertical-align: middle;
}
@mixin button_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
}
}
@mixin button_icon_after( $icon ) {
&:after {
@include button_icon( $icon );
padding: 0 0 0 5px;
}
}
@mixin button_icon_middle( $icon ) {
&:before {
@include button_icon( $icon );
margin: 0 -5px;
}
}
@mixin link() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
color: $blue_color;
text-transform: uppercase;
transition: all 200ms linear;
&:hover {
color: $dark_color_1;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: $blue_color;
}
}
@mixin link_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
color: $grey_color_4;
}
&:hover {
&:before {
color: $blue_color;
}
}
}
@mixin container() {
padding: 30px;
border: 2px solid $grey_color_2;
background: $grey_color_3;
border-radius: $border_radius_large;
}
@mixin container_heading() {
margin: -30px -30px 30px -30px;
border-radius: $border_radius_large $border_radius_large 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
text-align: center;
background: #fff;
}
@mixin box() {
margin: 0 0 30px;
padding: 20px;
background: #fff;
box-shadow: $box_shadow_box;
border-radius: $border_radius;
}
@mixin box_heading() {
margin: -20px -20px 20px -20px;
border-radius: $border_radius_small $border_radius_small 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
background: #fff;
}

View File

@@ -0,0 +1,23 @@
$dark_color_1: #23282d;
$dark_color_2: #495159;
$dark_color_2_h: #393f45;
$grey_color_1: #96989a;
$grey_color_2: #e5e5e5;
$grey_color_3: #f1f1f1;
$grey_color_4: #b4b7ba;
$blue_color: #298ffc;
$blue_color_h: #206ff4;
$green_color: #48c569;
$green_color_h: #3ba956;
$red_color: #e54343;
$red_color_h: #c73434;
$orange_color: #faa730;
$orange_color_h: #ee8425;
$border_radius_extra_small: 2px;
$border_radius_small: 4px;
$border_radius_medium: 6px;
$border_radius_large: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);

View File

@@ -0,0 +1,490 @@
/**!
* wp-color-picker-alpha
*
* Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
* Only run in input and is defined data alpha in true
*
* Version: 2.1.2
* https://github.com/kallookoo/wp-color-picker-alpha
* Licensed under the GPLv2 license.
*/
( function( $ ) {
// Variable for some backgrounds ( grid )
var image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==',
// html stuff for wpColorPicker copy of the original color-picker.js
_after = '<div class="wp-picker-holder" />',
_wrap = '<div class="wp-picker-container" />',
_button = '<input type="button" class="button button-small" />',
// Prevent CSS issues in < WordPress 4.9
_deprecated = ( wpColorPickerL10n.current !== undefined );
// Declare some global variables when is deprecated or not
if ( _deprecated ) {
var _before = '<a tabindex="0" class="wp-color-result" />';
} else {
var _before = '<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>',
_wrappingLabel = '<label></label>',
_wrappingLabelText = '<span class="screen-reader-text"></span>';
}
/**
* Overwrite Color
* for enable support rbga
*/
Color.fn.toString = function() {
if ( this._alpha < 1 )
return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
var hex = parseInt( this._color, 10 ).toString( 16 );
if ( this.error )
return '';
if ( hex.length < 6 )
hex = ( '00000' + hex ).substr( -6 );
return '#' + hex;
};
/**
* Overwrite wpColorPicker
*/
$.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
/**
* @summary Creates the color picker.
*
* Creates the color picker, sets default values, css classes and wraps it all in HTML.
*
* @since 3.5.0
*
* @access private
*
* @returns {void}
*/
_create: function() {
// Return early if Iris support is missing.
if ( ! $.support.iris ) {
return;
}
var self = this,
el = self.element;
// Override default options with options bound to the element.
$.extend( self.options, el.data() );
// Create a color picker which only allows adjustments to the hue.
if ( self.options.type === 'hue' ) {
return self._createHueOnly();
}
// Bind the close event.
self.close = $.proxy( self.close, self );
self.initialValue = el.val();
// Add a CSS class to the input field.
el.addClass( 'wp-color-picker' );
if ( _deprecated ) {
el.hide().wrap( _wrap );
self.wrap = el.parent();
self.toggler = $( _before )
.insertBefore( el )
.css( { backgroundColor : self.initialValue } )
.attr( 'title', wpColorPickerL10n.pick )
.attr( 'data-current', wpColorPickerL10n.current );
self.pickerContainer = $( _after ).insertAfter( el );
self.button = $( _button ).addClass('hidden');
} else {
/*
* Check if there's already a wrapping label, e.g. in the Customizer.
* If there's no label, add a default one to match the Customizer template.
*/
if ( ! el.parent( 'label' ).length ) {
// Wrap the input field in the default label.
el.wrap( _wrappingLabel );
// Insert the default label text.
self.wrappingLabelText = $( _wrappingLabelText )
.insertBefore( el )
.text( wpColorPickerL10n.defaultLabel );
}
/*
* At this point, either it's the standalone version or the Customizer
* one, we have a wrapping label to use as hook in the DOM, let's store it.
*/
self.wrappingLabel = el.parent();
// Wrap the label in the main wrapper.
self.wrappingLabel.wrap( _wrap );
// Store a reference to the main wrapper.
self.wrap = self.wrappingLabel.parent();
// Set up the toggle button and insert it before the wrapping label.
self.toggler = $( _before )
.insertBefore( self.wrappingLabel )
.css( { backgroundColor: self.initialValue } );
// Set the toggle button span element text.
self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick );
// Set up the Iris container and insert it after the wrapping label.
self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel );
// Store a reference to the Clear/Default button.
self.button = $( _button );
}
// Set up the Clear/Default button.
if ( self.options.defaultColor ) {
self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString );
if ( ! _deprecated ) {
self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel );
}
} else {
self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear );
if ( ! _deprecated ) {
self.button.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel );
}
}
if ( _deprecated ) {
el.wrap( '<span class="wp-picker-input-wrap" />' ).after( self.button );
} else {
// Wrap the wrapping label in its wrapper and append the Clear/Default button.
self.wrappingLabel
.wrap( '<span class="wp-picker-input-wrap hidden" />' )
.after( self.button );
/*
* The input wrapper now contains the label+input+Clear/Default button.
* Store a reference to the input wrapper: we'll use this to toggle
* the controls visibility.
*/
self.inputWrapper = el.closest( '.wp-picker-input-wrap' );
}
el.iris( {
target: self.pickerContainer,
hide: self.options.hide,
width: self.options.width,
mode: self.options.mode,
palettes: self.options.palettes,
/**
* @summary Handles the onChange event if one has been defined in the options.
*
* Handles the onChange event if one has been defined in the options and additionally
* sets the background color for the toggler element.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
* @param {HTMLElement} ui The HTMLElement containing the color picker.
*
* @returns {void}
*/
change: function( event, ui ) {
if ( self.options.alpha ) {
self.toggler.css( { 'background-image' : 'url(' + image + ')' } );
if ( _deprecated ) {
self.toggler.html( '<span class="color-alpha" />' );
} else {
self.toggler.css( {
'position' : 'relative'
} );
if ( self.toggler.find('span.color-alpha').length == 0 ) {
self.toggler.append('<span class="color-alpha" />');
}
}
self.toggler.find( 'span.color-alpha' ).css( {
'width' : '30px',
'height' : '24px',
'position' : 'absolute',
'top' : 0,
'left' : 0,
'border-top-left-radius' : '2px',
'border-bottom-left-radius' : '2px',
'background' : ui.color.toString()
} );
} else {
self.toggler.css( { backgroundColor : ui.color.toString() } );
}
if ( $.isFunction( self.options.change ) ) {
self.options.change.call( this, event, ui );
}
}
} );
el.val( self.initialValue );
self._addListeners();
// Force the color picker to always be closed on initial load.
if ( ! self.options.hide ) {
self.toggler.click();
}
},
/**
* @summary Binds event listeners to the color picker.
*
* @since 3.5.0
*
* @access private
*
* @returns {void}
*/
_addListeners: function() {
var self = this;
/**
* @summary Prevent any clicks inside this widget from leaking to the top and closing it.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returs {void}
*/
self.wrap.on( 'click.wpcolorpicker', function( event ) {
event.stopPropagation();
});
/**
* @summary Open or close the color picker depending on the class.
*
* @since 3.5
*/
self.toggler.click( function(){
if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
self.close();
} else {
self.open();
}
});
/**
* @summary Checks if value is empty when changing the color in the color picker.
*
* Checks if value is empty when changing the color in the color picker.
* If so, the background color is cleared.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returns {void}
*/
self.element.on( 'change', function( event ) {
// Empty or Error = clear
if ( $( this ).val() === '' || self.element.hasClass( 'iris-error' ) ) {
if ( self.options.alpha ) {
if ( _deprecated ) {
self.toggler.removeAttr( 'style' );
}
self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
} else {
self.toggler.css( 'backgroundColor', '' );
}
// fire clear callback if we have one
if ( $.isFunction( self.options.clear ) )
self.options.clear.call( this, event );
}
} );
/**
* @summary Enables the user to clear or revert the color in the color picker.
*
* Enables the user to either clear the color in the color picker or revert back to the default color.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returns {void}
*/
self.button.on( 'click', function( event ) {
if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
self.element.val( '' );
if ( self.options.alpha ) {
if ( _deprecated ) {
self.toggler.removeAttr( 'style' );
}
self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
} else {
self.toggler.css( 'backgroundColor', '' );
}
if ( $.isFunction( self.options.clear ) )
self.options.clear.call( this, event );
} else if ( $( this ).hasClass( 'wp-picker-default' ) ) {
self.element.val( self.options.defaultColor ).change();
}
});
},
});
/**
* Overwrite iris
*/
$.widget( 'a8c.iris', $.a8c.iris, {
_create: function() {
this._super();
// Global option for check is mode rbga is enabled
this.options.alpha = this.element.data( 'alpha' ) || false;
// Is not input disabled
if ( ! this.element.is( ':input' ) )
this.options.alpha = false;
if ( typeof this.options.alpha !== 'undefined' && this.options.alpha ) {
var self = this,
el = self.element,
_html = '<div class="iris-strip iris-slider iris-alpha-slider"><div class="iris-slider-offset iris-slider-offset-alpha"></div></div>',
aContainer = $( _html ).appendTo( self.picker.find( '.iris-picker-inner' ) ),
aSlider = aContainer.find( '.iris-slider-offset-alpha' ),
controls = {
aContainer : aContainer,
aSlider : aSlider
};
if ( typeof el.data( 'custom-width' ) !== 'undefined' ) {
self.options.customWidth = parseInt( el.data( 'custom-width' ) ) || 0;
} else {
self.options.customWidth = 100;
}
// Set default width for input reset
self.options.defaultWidth = el.width();
// Update width for input
if ( self._color._alpha < 1 || self._color.toString().indexOf('rgb') != -1 )
el.width( parseInt( self.options.defaultWidth + self.options.customWidth ) );
// Push new controls
$.each( controls, function( k, v ) {
self.controls[k] = v;
} );
// Change size strip and add margin for sliders
self.controls.square.css( { 'margin-right': '0' } );
var emptyWidth = ( self.picker.width() - self.controls.square.width() - 20 ),
stripsMargin = ( emptyWidth / 6 ),
stripsWidth = ( ( emptyWidth / 2 ) - stripsMargin );
$.each( [ 'aContainer', 'strip' ], function( k, v ) {
self.controls[v].width( stripsWidth ).css( { 'margin-left' : stripsMargin + 'px' } );
} );
// Add new slider
self._initControls();
// For updated widget
self._change();
}
},
_initControls: function() {
this._super();
if ( this.options.alpha ) {
var self = this,
controls = self.controls;
controls.aSlider.slider({
orientation : 'vertical',
min : 0,
max : 100,
step : 1,
value : parseInt( self._color._alpha * 100 ),
slide : function( event, ui ) {
// Update alpha value
self._color._alpha = parseFloat( ui.value / 100 );
self._change.apply( self, arguments );
}
});
}
},
_change: function() {
this._super();
var self = this,
el = self.element;
if ( this.options.alpha ) {
var controls = self.controls,
alpha = parseInt( self._color._alpha * 100 ),
color = self._color.toRgb(),
gradient = [
'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%',
'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%'
],
defaultWidth = self.options.defaultWidth,
customWidth = self.options.customWidth,
target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' );
// Generate background slider alpha, only for CSS3 old browser fuck!! :)
controls.aContainer.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + image + ')' } );
if ( target.hasClass( 'wp-picker-open' ) ) {
// Update alpha value
controls.aSlider.slider( 'value', alpha );
/**
* Disabled change opacity in default slider Saturation ( only is alpha enabled )
* and change input width for view all value
*/
if ( self._color._alpha < 1 ) {
controls.strip.attr( 'style', controls.strip.attr( 'style' ).replace( /rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g, 'rgb($1$3$5)' ) );
el.width( parseInt( defaultWidth + customWidth ) );
} else {
el.width( defaultWidth );
}
}
}
var reset = el.data( 'reset-alpha' ) || false;
if ( reset ) {
self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() {
self._color._alpha = 1;
self.active = 'external';
self._change();
} );
}
},
_addInputListeners: function( input ) {
var self = this,
debounceTimeout = 100,
callback = function( event ) {
var color = new Color( input.val() ),
val = input.val();
input.removeClass( 'iris-error' );
// we gave a bad color
if ( color.error ) {
// don't error on an empty input
if ( val !== '' )
input.addClass( 'iris-error' );
} else {
if ( color.toString() !== self._color.toString() ) {
// let's not do this on keyup for hex shortcodes
if ( ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) )
self._setOption( 'color', color.toString() );
}
}
};
input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) );
// If we initialized hidden, show on first focus. The rest is up to you.
if ( self.options.hide ) {
input.on( 'focus', function() {
self.show();
} );
}
}
} );
}( jQuery ) );
// Auto Call plugin is class is color-picker
jQuery( document ).ready( function( $ ) {
$( '.color-picker' ).wpColorPicker();
} );

View File

@@ -0,0 +1,129 @@
<?php
/**
* Class for the building ui-colorpicker elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'UI_Colorpicker' ) ) {
/**
* Class for the building UI_Colorpicker elements.
*/
class UI_Colorpicker extends UI_Element implements I_UI {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $defaults_settings = array(
'id' => 'cherry-ui-colorpicker-id',
'name' => 'cherry-ui-colorpicker-name',
'value' => '',
'label' => '',
'class' => '',
'master' => '',
'alpha' => false,
'lock' => false,
);
/**
* Instance of this Cherry5_Lock_Element class.
*
* @since 1.0.0
* @var object
* @access private
*/
private $lock_element = null;
/**
* Constructor method for the UI_Colorpicker class.
*
* @since 1.0.0
*/
function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cherry-ui-colorpicker-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
$this->lock_element = new Cherry5_Lock_Element( $this->settings );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
}
/**
* Render html UI_Colorpicker.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
$this->settings['master'],
)
);
$alpha = '';
if ( true === $this->settings['alpha'] ) {
$alpha = ' data-alpha=true ';
}
$html .= '<div class="cherry-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cherry-ui-colorpicker-wrapper' . $this->lock_element->get_class() .'">';
$html .= '<input type="text" id="' . esc_attr( $this->settings['id'] ) . '" class="cherry-ui-colorpicker" name="' . esc_attr( $this->settings['name'] ) . '"' . $alpha . 'value="' . esc_html( $this->settings['value'] ) . '"' . $this->lock_element->get_disabled_attr() . '/>';
$html .= $this->lock_element->get_html();
$html .= '</div>';
$html .= '</div>';
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Colorpicker.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_script(
'wp-color-picker-alpha',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-colorpicker/assets/min/wp-color-picker-alpha.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'wp-color-picker' ),
'1.2.2',
true
);
wp_enqueue_script(
'ui-colorpicker',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-colorpicker/assets/min/ui-colorpicker.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
wp_enqueue_style(
'ui-colorpicker',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-colorpicker/assets/min/ui-colorpicker.min.css', Cherry_UI_Elements::$module_path ) ),
array( 'wp-color-picker' ),
Cherry_UI_Elements::$core_version,
'all'
);
}
}
}

View File

@@ -0,0 +1 @@
.cherry-lock-element{user-select:none;cursor:no-drop;position:relative;filter:grayscale(100%)}.cherry-lock-element.inline-block{display:inline-block}.cherry-lock-element label{position:relative}.cherry-lock-element .cherry-lable-content,.cherry-lock-element .cherry-checkbox-item,.cherry-lock-element .select2-container,.cherry-lock-element>*:first-child{opacity:0.5;pointer-events:none}.cherry-lock-element a.cherry-lock-element__area{position:absolute;top:0;left:0;width:100%;height:100%;z-index:2000;cursor:no-drop}.cherry-lock-element a.cherry-lock-element__area:focus{outline:none;box-shadow:none}.cherry-lock-element a.cherry-lock-element__area:hover .cherry-lock-element__label{animation-name:lock_show;animation-duration:450ms;animation-timing-function:cubic-bezier(0.165, 0.84, 0.44, 1)}.cherry-lock-element__label{opacity:0;display:inline-block;background-color:rgba(0,0,0,0.9);border-radius:5px;color:#fff;padding:8px 10px;position:absolute;white-space:nowrap;top:-10px;left:50%;box-shadow:2px 2px 5px 0px rgba(0,0,0,0.5);will-change:auto;pointer-events:none;font-size:14px;line-height:16px;animation-name:lock_hide;animation-duration:200ms;animation-timing-function:cubic-bezier(0.55, 0.055, 0.675, 0.19);animation-fill-mode:both;transform-origin:0% 0%}.cherry-lock-element__label *+*{margin-right:5px}.cherry-lock-element__label:after{border:solid;border-color:rgba(0,0,0,0.9) transparent;border-width:6px 6px 0 6px;bottom:-5px;margin-left:-6px;content:"";left:50%;position:absolute}@keyframes lock_show{0%{opacity:0;filter:blur(5px);transform:scale(0) translate(-50%, 200%)}60%{opacity:0.8;transform:scale(1.1) translate(-50%, -130%)}100%{opacity:1;filter:blur(0px);transform:scale(1) translate(-50%, -100%)}}@keyframes lock_hide{0%{opacity:1;filter:blur(0px);transform:scale(1) translate(-50%, -100%)}100%{opacity:0;filter:blur(3px);transform:scale(0) translate(-50%, 200%)}}.cherry-ui-elements-lock{opacity:0.5;cursor:no-drop;pointer-events:none;filter:grayscale(100%)}.cherry-ui-container{margin:10px 0 20px 0}label.cherry-label{margin:0 0 5px 0;display:block}.cherry-ui-dimensions{max-width:300px}.cherry-ui-dimensions__units{margin-right:20%;display:flex;justify-content:flex-end}.cherry-ui-dimensions__unit{color:#c2cbd2;cursor:pointer;font-size:9px;text-transform:uppercase;margin:0 2px}.cherry-ui-dimensions__unit.is-active{color:#6d7882;text-decoration:underline}.cherry-ui-dimensions__values{display:flex;border:1px solid #a4afb7;border-radius:3px}.cherry-ui-dimensions__value-item{position:relative;width:20%}.cherry-ui-dimensions__value-item input{width:100%;margin:0;border:none;box-shadow:none;border-right:1px solid #a4afb7;font-size: 12px;}.cherry-ui-dimensions__value-item input:first-child{border-radius:3px 0 0 3px}.cherry-ui-dimensions__value-item input:focus{border-color:none}.cherry-ui-dimensions__value-label{width:100%;display:block;position:absolute;bottom:-18px;font-size:9px;text-transform:uppercase;text-align:center;color:#d5dadf}.cherry-ui-dimensions__is-linked{width:20%;height:28px;background-color:white;text-align:center;color:#a4afb7;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:0 3px 3px 0}.cherry-ui-dimensions__is-linked .link-icon{display:none}.cherry-ui-dimensions__is-linked .unlink-icon{display:block}.cherry-ui-dimensions__is-linked.is-linked{color:white;background-color:#a4afb7}.cherry-ui-dimensions__is-linked.is-linked .link-icon{display:block}.cherry-ui-dimensions__is-linked.is-linked .unlink-icon{display:none}

View File

@@ -0,0 +1,96 @@
/**
* Radio
*/
(function($, CherryJsCore){
'use strict';
CherryJsCore.utilites.namespace('ui_elements.dimensions');
CherryJsCore.ui_elements.dimensions = {
container: '.cherry-ui-dimensions',
isLinked: '.cherry-ui-dimensions__is-linked',
units: '.cherry-ui-dimensions__unit',
unitsInput: 'input[name*="[units]"]',
linkedInput: 'input[name*="[is_linked]"]',
valuesInput: '.cherry-ui-dimensions__val',
init: function() {
$( document ).on( 'ready', this.addEvents.bind( this ) );
this.triggers();
},
triggers: function( $target ) {
if ( $target ) {
$( document ).trigger( 'cherry-ui-elements-init', { 'target': $target } );
}
return this;
},
addEvents: function() {
$( 'body' )
// Delegate events
.on( 'click', this.isLinked, { 'self': this }, this.switchLinked )
.on( 'click', this.units, { 'self': this }, this.switchUnits )
.on( 'input', this.valuesInput + '.is-linked', { 'self': this }, this.changeLinked );
this.triggers();
},
switchLinked: function( event ) {
var self = event.data.self,
$this = $( this ),
$container = $this.closest( self.container ),
$input = $container.find( self.linkedInput ),
$values = $container.find( self.valuesInput ),
isLinked = $input.val();
if ( 0 === parseInt( isLinked ) ) {
$input.val(1);
$this.addClass( 'is-linked' );
$values.addClass( 'is-linked' );
} else {
$input.val(0);
$this.removeClass( 'is-linked' );
$values.removeClass( 'is-linked' );
}
},
switchUnits: function( event ) {
var self = event.data.self,
$this = $( this ),
unit = $this.data( 'unit' ),
$container = $this.closest( self.container ),
$input = $container.find( self.unitsInput ),
$values = $container.find( self.valuesInput ),
range = $container.data( 'range' );
if ( $this.hasClass( 'is-active' ) ) {
return;
}
$this.addClass( 'is-active' ).siblings( self.units ).removeClass( 'is-active' );
$input.val( unit );
$values.attr({
min: range[ unit ].min,
max: range[ unit ].max,
step: range[ unit ].step
});
},
changeLinked: function( event ) {
var self = event.data.self,
$this = $( this ),
$container = $this.closest( '.cherry-ui-dimensions__values' );
$( self.valuesInput, $container ).val( $this.val() )
}
};
CherryJsCore.ui_elements.dimensions.init();
}(jQuery, window.CherryJsCore));

View File

@@ -0,0 +1,115 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
@import "../../../../assets/sass/lock";
.cherry-ui-elements-lock{
opacity: 0.5;
cursor: no-drop;
pointer-events: none;
filter: grayscale( 100% );
}
.cherry-ui-container{
margin: 10px 0 20px 0;
}
label.cherry-label{
margin: 0 0 5px 0;
display: block;
}
.cherry-ui-dimensions {
max-width: 300px;
&__units {
margin-right: 20%;
display: flex;
justify-content: flex-end;
}
&__unit {
color: #c2cbd2;
cursor: pointer;
font-size: 9px;
text-transform: uppercase;
margin: 0 2px;
&.is-active {
color: #6d7882;
text-decoration: underline;
}
}
&__values {
display: flex;
border: 1px solid #a4afb7;
border-radius: 3px;
}
&__value-item {
position: relative;
width: 20%;
input {
width: 100%;
margin: 0;
border: none;
box-shadow: none;
border-right: 1px solid #a4afb7;
font-size: 12px;
&:first-child {
border-radius: 3px 0 0 3px;
}
&:focus {
border-color: none;
}
}
}
&__value-label {
width: 100%;
display: block;
position: absolute;
bottom: -18px;
font-size: 9px;
text-transform: uppercase;
text-align: center;
color: #d5dadf;
}
&__is-linked {
width: 20%;
height: 28px;
background-color: white;
text-align: center;
color: #a4afb7;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
border-radius: 0 3px 3px 0;
.link-icon {
display: none;
}
.unlink-icon {
display: block;
}
&.is-linked {
color: white;
background-color: #a4afb7;
.link-icon {
display: block;
}
.unlink-icon {
display: none;
}
}
}
}

View File

@@ -0,0 +1,15 @@
@mixin input() {
font-size: 14px;
line-height: 20px;
color: $dark_color;
background-color: $bg_color;
border-radius: $border_radius_extra_small;
padding: 10px 20px;
min-height: 50px;
border: 1px solid $border_color;
box-shadow: none;
&:focus{
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
}
}

View File

@@ -0,0 +1,7 @@
$light_color: #ffffff;
$dark_color: #23282d;
$bg_color: #f1f1f1;
$border_color: #dcdcdc;
$border_radius_extra_small: 2px;

View File

@@ -0,0 +1,260 @@
<?php
/**
* Class for the building ui-dimensions elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'UI_Dimensions' ) ) {
/**
* Class for the building ui-dimensions elements.
*/
class UI_Dimensions extends UI_Element implements I_UI {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $defaults_settings = array(
'type' => 'dimensions',
'id' => 'cherry-ui-dimensions-id',
'name' => 'cherry-ui-dimensions-name',
'value' => array(),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
'step' => 1,
),
),
'label' => '',
'dimension_labels' => array(
'top' => 'Top',
'right' => 'Right',
'bottom' => 'Bottom',
'left' => 'Left',
),
'class' => '',
'master' => '',
'required' => false,
'lock' => false,
);
protected $default_value = array(
'units' => 'px',
'is_linked' => true,
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
);
/**
* Instance of this Cherry5_Lock_Element class.
*
* @since 1.0.0
* @var object
* @access private
*/
private $lock_element = null;
/**
* Constructor method for the UI_Text class.
*
* @since 1.0.0
*/
function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cherry-ui-dimensions-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
$this->lock_element = new Cherry5_Lock_Element( $this->settings );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
}
/**
* Get required attribute.
*
* @since 1.0.0
* @return string
*/
public function get_required() {
if ( $this->settings['required'] ) {
return 'required="required"';
}
return '';
}
/**
* Render html UI_Text.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
$this->settings['master'],
$this->lock_element->get_class(),
)
);
if ( empty( $this->settings['value'] ) ) {
$this->settings['value'] = $this->default_value;
} else {
$this->settings['value'] = array_merge( $this->default_value, $this->settings['value'] );
}
$html .= '<div class="cherry-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= $this->get_fields();
$html .= $this->lock_element->get_html();
$html .= '</div>';
return $html;
}
/**
* Return UI fileds
* @return [type] [description]
*/
public function get_fields() {
$hidden = '<input type="hidden" name="%1$s" id="%3$s" value="%2$s">';
$number = '<div class="cherry-ui-dimensions__value-item"><input type="number" name="%1$s" id="%3$s" value="%2$s" min="%4$s" max="%5$s" step="%6$s" class="cherry-ui-dimensions__val%7$s"><span class="cherry-ui-dimensions__value-label">%8$s</span></div>';
$value = $this->settings['value'];
$value = array_merge( $this->default_value, $value );
$result = sprintf(
'<div class="cherry-ui-dimensions" data-range=\'%s\'>',
json_encode( $this->settings['range'] )
);
foreach ( array( 'units', 'is_linked' ) as $field ) {
$result .= sprintf(
$hidden,
$this->get_name_attr( $field ), $value[ $field ], $this->get_id_attr( $field )
);
}
$result .= $this->get_units();
$result .= '<div class="cherry-ui-dimensions__values">';
$value['is_linked'] = filter_var( $value['is_linked'], FILTER_VALIDATE_BOOLEAN );
foreach ( array( 'top', 'right', 'bottom', 'left' ) as $field ) {
$result .= sprintf(
$number,
$this->get_name_attr( $field ),
$value[ $field ],
$this->get_id_attr( $field ),
$this->settings['range'][ $value['units'] ]['min'],
$this->settings['range'][ $value['units'] ]['max'],
$this->settings['range'][ $value['units'] ]['step'],
( true === $value['is_linked'] ? ' is-linked' : '' ),
$this->settings['dimension_labels'][ $field ]
);
}
$result .= sprintf(
'<div class="cherry-ui-dimensions__is-linked%s"><span class="dashicons dashicons-admin-links link-icon"></span><span class="dashicons dashicons-editor-unlink unlink-icon"></span></div>',
( true === $value['is_linked'] ? ' is-linked' : '' )
);
$result .= '</div>';
$result .= '</div>';
return $result;
}
/**
* Returns units selector
*
* @return string
*/
public function get_units() {
$units = array_keys( $this->settings['range'] );
$switcher = 'can-switch';
if ( 1 === count( $units ) ) {
$switcher = '';
}
$item = '<span class="cherry-ui-dimensions__unit%2$s" data-unit="%1$s">%1$s</span>';
$result = '';
foreach ( $units as $unit ) {
$result .= sprintf(
$item,
$unit,
( $this->settings['value']['units'] === $unit ? ' is-active' : '' )
);
}
return sprintf( '<div class="cherry-ui-dimensions__units">%s</div>', $result );
}
/**
* Retrurn full name attibute by name
*
* @param [type] $name [description]
* @return [type] [description]
*/
public function get_name_attr( $name = '' ) {
return sprintf( '%s[%s]', esc_attr( $this->settings['name'] ), esc_attr( $name ) );
}
/**
* Retrurn full ID attibute by name
*
* @param [type] $name [description]
* @return [type] [description]
*/
public function get_id_attr( $name = '' ) {
return sprintf( '%s_%s', esc_attr( $this->settings['name'] ), esc_attr( $name ) );
}
/**
* Enqueue javascript and stylesheet UI_Text.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_style(
'ui-dimensions',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-dimensions/assets/min/ui-dimensions.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
wp_enqueue_script(
'ui-dimensions',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-dimensions/assets/ui-dimensions.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
}
}
}

View File

@@ -0,0 +1 @@
!function(e,t,n){"use strict";t.utilites.namespace("ui_elements.iconpicker"),t.ui_elements.iconpicker={iconSets:{},iconSetsKey:"cherry5-icon-sets",init:function(){e(document).on("cherry-ajax-handler-success",this.setIconsSets.bind(this)).on("ready.iconpicker",this.setIconsSets.bind(this,window.cherry5IconSets)).on("ready.iconpicker",this.render.bind(this)).on("cherry-ui-elements-init",this.render.bind(this))},setIconsSets:function(e){var t,i=this;e&&(t=e.response?e.response.cherry5IconSets:e,n.each(t,function(e,t){i.iconSets[t]=e}),i.setState(i.iconSetsKey,i.iconSets))},getIconsSets:function(){var e=this.getState(this.iconSetsKey);e&&(this.iconSets=e)},render:function(t){var n,i,s,c=t._target?t._target:e("body"),o=e('.cherry-ui-iconpicker:not([name*="__i__"])',c),r=this;o[0]&&(this.getIconsSets(),o.each(function(){n=e(this),i=n.data("set"),s=r.iconSets[i],n.length&&s.icons&&n.iconpicker({icons:s.icons,iconBaseClass:s.iconBase,iconClassPrefix:s.iconPrefix,animation:!1,fullClassFormatter:function(e){return s.iconBase+" "+s.iconPrefix+e}}).on("iconpickerUpdated",function(){e(this).trigger("change")}),s&&e("head").append('<link rel="stylesheet" type="text/css" href="'+s.iconCSS+'"">')}))},getState:function(e){try{return JSON.parse(window.sessionStorage.getItem(e))}catch(e){return!1}},setState:function(e,t){try{window.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){return!1}}},t.ui_elements.iconpicker.init()}(jQuery,window.CherryJsCore,window._);

View File

@@ -0,0 +1,102 @@
/**
* Iconpicker
*/
(function( $, CherryJsCore, underscore ) {
'use strict';
CherryJsCore.utilites.namespace( 'ui_elements.iconpicker' );
CherryJsCore.ui_elements.iconpicker = {
iconSets: {},
iconSetsKey: 'cherry5-icon-sets',
init: function() {
$( document )
.on( 'cherry-ajax-handler-success', this.setIconsSets.bind( this ) )
.on( 'ready.iconpicker', this.setIconsSets.bind( this, window.cherry5IconSets ) )
.on( 'ready.iconpicker', this.render.bind( this ) )
.on( 'cherry-ui-elements-init', this.render.bind( this ) );
},
setIconsSets: function( iconSets ) {
var icon,
_this = this;
if ( iconSets ) {
icon = ( iconSets.response ) ? iconSets.response.cherry5IconSets : iconSets;
underscore.each(
icon,
function( element, index ) {
_this.iconSets[ index ] = element;
}
);
_this.setState( _this.iconSetsKey, _this.iconSets );
}
},
getIconsSets: function() {
var iconSets = this.getState( this.iconSetsKey );
if ( iconSets ) {
this.iconSets = iconSets;
}
},
render: function( event ) {
var target = ( event._target ) ? event._target : $( 'body' ),
$picker = $( '.cherry-ui-iconpicker:not([name*="__i__"])', target ),
$this,
set,
setData,
_this = this;
if ( $picker[0] ) {
this.getIconsSets();
$picker.each( function() {
$this = $( this );
set = $this.data( 'set' );
setData = _this.iconSets[set];
if ( $this.length && setData.icons ) {
$this.iconpicker({
icons: setData.icons,
iconBaseClass: setData.iconBase,
iconClassPrefix: setData.iconPrefix,
animation: false,
fullClassFormatter: function( val ) {
return setData.iconBase + ' ' + setData.iconPrefix + val;
}
}).on( 'iconpickerUpdated', function() {
$( this ).trigger( 'change' );
});
}
if ( setData ) {
$( 'head' ).append( '<link rel="stylesheet" type="text/css" href="' + setData.iconCSS + '"">' );
}
} );
}
},
getState: function( key ) {
try {
return JSON.parse( window.sessionStorage.getItem( key ) );
} catch ( e ) {
return false;
}
},
setState: function( key, data ) {
try {
window.sessionStorage.setItem( key, JSON.stringify( data ) );
} catch ( e ) {
return false;
}
}
};
CherryJsCore.ui_elements.iconpicker.init();
}( jQuery, window.CherryJsCore, window._ ) );

View File

@@ -0,0 +1,336 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
@import "../../../../assets/sass/lock";
.cherry-ui-elements-lock{
opacity: 0.5;
cursor: no-drop;
pointer-events: none;
filter: grayscale( 100% );
}
.cherry-ui-iconpicker-group {
position: relative;
.full &{
max-width: 100%;
}
.fixed &{
max-width: 150px;
}
.input-group-addon {
position: absolute;
width: 20px;
height: 20px;
left: 0px;
top: 0px;
background: $grey_color_3;
font-size: 14px;
line-height: 20px;
text-align: center;
border-radius: 3px 0 0 3px;
border-right: 1px solid #dddcdc;
margin: 3px;
.fa {
line-height: 20px;
}
}
.cherry-ui-text{
@include input();
padding: 0px 0px 0px 30px;
}
}
.iconpicker-popover.popover {
position: absolute;
top: 0;
left: 0;
display: none;
max-width: none;
padding: 1px;
text-align: left;
width: 242px;
background: #f0f0f0;
z-index: 999;
}
.iconpicker-popover.popover.top,
.iconpicker-popover.popover.topLeftCorner,
.iconpicker-popover.popover.topLeft,
.iconpicker-popover.popover.topRight,
.iconpicker-popover.popover.topRightCorner {
margin-top: -10px;
}
.iconpicker-popover.popover.right,
.iconpicker-popover.popover.rightTop,
.iconpicker-popover.popover.rightBottom {
margin-left: 10px;
}
.iconpicker-popover.popover.bottom,
.iconpicker-popover.popover.bottomRightCorner,
.iconpicker-popover.popover.bottomRight,
.iconpicker-popover.popover.bottomLeft,
.iconpicker-popover.popover.bottomLeftCorner {
margin-top: 10px;
}
.iconpicker-popover.popover.left,
.iconpicker-popover.popover.leftBottom,
.iconpicker-popover.popover.leftTop {
margin-left: -10px;
}
.iconpicker-popover.popover.inline {
margin: 0 0 14px 0;
position: relative;
display: inline-block;
opacity: 1;
top: auto;
left: auto;
bottom: auto;
right: auto;
max-width: 100%;
box-shadow: none;
z-index: auto;
vertical-align: top;
}
.iconpicker-popover.popover.inline > .arrow {
display: none;
}
.dropdown-menu .iconpicker-popover.inline {
margin: 0;
border: none;
}
.dropdown-menu.iconpicker-container {
padding: 0;
}
.iconpicker-popover.popover .popover-title {
padding: 14px;
font-size: 14px;
line-height: 16px;
border-bottom: 1px solid #ebebeb;
background-color: #f0f0f0;
}
.iconpicker-popover.popover .popover-title input[type=search].iconpicker-search {
margin: 0 0 2px 0;
}
.iconpicker-popover.popover .popover-title-text ~ input[type=search].iconpicker-search {
margin-top: 14px;
}
.iconpicker-popover.popover .popover-content {
padding: 0px;
text-align: center;
}
.iconpicker-popover .popover-footer {
float: none;
clear: both;
padding: 14px;
text-align: right;
margin: 0;
border-top: 1px solid #ebebeb;
background-color: #f0f0f0;
}
.iconpicker-popover .popover-footer:before,
.iconpicker-popover .popover-footer:after {
content: " ";
display: table;
}
.iconpicker-popover .popover-footer:after {
clear: both;
}
.iconpicker-popover .popover-footer .iconpicker-btn {
margin-left: 10px;
}
.iconpicker-popover .popover-footer input[type=search].iconpicker-search {
margin-bottom: 14px;
}
.iconpicker-popover.popover > .arrow,
.iconpicker-popover.popover > .arrow:after {
position: absolute;
display: block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
}
.iconpicker-popover.popover > .arrow {
border-width: 11px;
}
.iconpicker-popover.popover > .arrow:after {
border-width: 10px;
content: "";
}
.iconpicker-popover.popover.top > .arrow,
.iconpicker-popover.popover.topLeft > .arrow,
.iconpicker-popover.popover.topRight > .arrow {
left: 50%;
margin-left: -11px;
border-bottom-width: 0;
border-top-color: #f0f0f0;
bottom: -11px;
}
.iconpicker-popover.popover.top > .arrow:after,
.iconpicker-popover.popover.topLeft > .arrow:after,
.iconpicker-popover.popover.topRight > .arrow:after {
content: " ";
bottom: 1px;
margin-left: -10px;
border-bottom-width: 0;
border-top-color: #ffffff;
}
.iconpicker-popover.popover.topLeft > .arrow {
left: 14px;
margin-left: 0;
}
.iconpicker-popover.popover.topRight > .arrow {
left: auto;
right: 14px;
margin-left: 0;
}
.iconpicker-popover.popover.right > .arrow,
.iconpicker-popover.popover.rightTop > .arrow,
.iconpicker-popover.popover.rightBottom > .arrow {
top: 50%;
left: -11px;
margin-top: -11px;
border-left-width: 0;
border-right-color: #f0f0f0;
}
.iconpicker-popover.popover.right > .arrow:after,
.iconpicker-popover.popover.rightTop > .arrow:after,
.iconpicker-popover.popover.rightBottom > .arrow:after {
content: " ";
left: 1px;
bottom: -10px;
border-left-width: 0;
border-right-color: #ffffff;
}
.iconpicker-popover.popover.rightTop > .arrow {
top: auto;
bottom: 14px;
margin-top: 0;
}
.iconpicker-popover.popover.rightBottom > .arrow {
top: 14px;
margin-top: 0;
}
.iconpicker-popover.popover.bottom > .arrow,
.iconpicker-popover.popover.bottomRight > .arrow,
.iconpicker-popover.popover.bottomLeft > .arrow {
left: 50%;
margin-left: -11px;
border-top-width: 0;
border-bottom-color: #f0f0f0;
top: -11px;
}
.iconpicker-popover.popover.bottom > .arrow:after,
.iconpicker-popover.popover.bottomRight > .arrow:after,
.iconpicker-popover.popover.bottomLeft > .arrow:after {
content: " ";
top: 1px;
margin-left: -10px;
border-top-width: 0;
border-bottom-color: #f0f0f0;
}
.iconpicker-popover.popover.bottomLeft > .arrow {
left: 14px;
margin-left: 0;
}
.iconpicker-popover.popover.bottomRight > .arrow {
left: auto;
right: 14px;
margin-left: 0;
}
.iconpicker-popover.popover.left > .arrow,
.iconpicker-popover.popover.leftBottom > .arrow,
.iconpicker-popover.popover.leftTop > .arrow {
top: 50%;
right: -11px;
margin-top: -11px;
border-right-width: 0;
border-left-color: #f0f0f0;
}
.iconpicker-popover.popover.left > .arrow:after,
.iconpicker-popover.popover.leftBottom > .arrow:after,
.iconpicker-popover.popover.leftTop > .arrow:after {
content: " ";
right: 1px;
border-right-width: 0;
border-left-color: #ffffff;
bottom: -10px;
}
.iconpicker-popover.popover.leftBottom > .arrow {
top: 14px;
margin-top: 0;
}
.iconpicker-popover.popover.leftTop > .arrow {
top: auto;
bottom: 14px;
margin-top: 0;
}
.iconpicker {
position: relative;
text-align: left;
text-shadow: none;
line-height: 0;
display: block;
margin: 0;
overflow: hidden;
}
.iconpicker * {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
position: relative;
}
.iconpicker:before,
.iconpicker:after {
content: " ";
display: table;
}
.iconpicker:after {
clear: both;
}
.iconpicker .iconpicker-items {
position: relative;
clear: both;
float: none;
padding: 10px 0 0 10px;
background: #fff;
margin: 0;
overflow: hidden;
overflow-y: auto;
min-height: 55px;
max-height: 275px;
}
.iconpicker .iconpicker-items:before,
.iconpicker .iconpicker-items:after {
content: " ";
display: table;
}
.iconpicker .iconpicker-items:after {
clear: both;
}
.iconpicker .iconpicker-item {
float: left;
width: 28px;
height: 28px;
line-height: 28px;
margin: 0 7px 7px 0;
text-align: center;
cursor: pointer;
border-radius: 3px;
font-size: 18px;
color: #444;
box-shadow: 0 0 0 1px #dddddd;
.fa {
line-height: 28px;
}
}
.iconpicker .iconpicker-item:hover:not(.iconpicker-selected) {
background-color: #eeeeee;
}
.iconpicker .iconpicker-item.iconpicker-selected {
box-shadow: none;
background: #ddd;
}
.iconpicker-component {
cursor: pointer;
}

View File

@@ -0,0 +1,183 @@
@mixin button_base() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
padding: 15px 20px;
color: #fff;
text-transform: uppercase;
border-radius: $border_radius_small;
transition: all 200ms linear;
box-shadow: $box_shadow;
&:hover {
color: #fff;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: #fff;
}
}
@mixin button_normal() {
background: $dark_color_2;
&:hover {
background: $dark_color_2_h;
}
}
@mixin button_primary() {
background: $blue_color;
&:hover {
background: $blue_color_h;
}
}
@mixin button_success() {
background: $green_color;
&:hover {
background: $green_color_h;
}
}
@mixin button_danger() {
background: $red_color;
&:hover {
background: $red_color_h;
}
}
@mixin button_warning() {
background: $orange_color;
&:hover {
background: $orange_color_h;
}
}
@mixin input() {
font-size: 12px;
line-height: 16px;
color: $dark_color_1;
background-color: $grey_color_3;
border-radius: $border_radius_extra_small;
min-height: 26px;
border: 1px solid $grey_color_3;
box-shadow: none;
&:focus{
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
}
}
@mixin button_icon( $icon ) {
content: $icon;
display: inline-block;
font-family: dashicons;
font-size: 16px;
font-style: normal;
font-weight: 400;
height: 18px;
line-height: 18px;
text-align: center;
text-decoration: inherit;
transition: all 200ms linear;
vertical-align: middle;
}
@mixin button_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
}
}
@mixin button_icon_after( $icon ) {
&:after {
@include button_icon( $icon );
padding: 0 0 0 5px;
}
}
@mixin button_icon_middle( $icon ) {
&:before {
@include button_icon( $icon );
margin: 0 -5px;
}
}
@mixin link() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
color: $blue_color;
text-transform: uppercase;
transition: all 200ms linear;
&:hover {
color: $dark_color_1;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: $blue_color;
}
}
@mixin link_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
color: $grey_color_4;
}
&:hover {
&:before {
color: $blue_color;
}
}
}
@mixin container() {
padding: 30px;
border: 2px solid $grey_color_2;
background: $grey_color_3;
border-radius: $border_radius_large;
}
@mixin container_heading() {
margin: -30px -30px 30px -30px;
border-radius: $border_radius_large $border_radius_large 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
text-align: center;
background: #fff;
}
@mixin box() {
margin: 0 0 30px;
padding: 20px;
background: #fff;
box-shadow: $box_shadow_box;
border-radius: $border_radius;
}
@mixin box_heading() {
margin: -20px -20px 20px -20px;
border-radius: $border_radius_small $border_radius_small 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
background: #fff;
}

View File

@@ -0,0 +1,23 @@
$dark_color_1: #23282d;
$dark_color_2: #495159;
$dark_color_2_h: #393f45;
$grey_color_1: #96989a;
$grey_color_2: #e5e5e5;
$grey_color_3: #f1f1f1;
$grey_color_4: #b4b7ba;
$blue_color: #298ffc;
$blue_color_h: #206ff4;
$green_color: #48c569;
$green_color_h: #3ba956;
$red_color: #e54343;
$red_color_h: #c73434;
$orange_color: #faa730;
$orange_color_h: #ee8425;
$border_radius_extra_small: 2px;
$border_radius_small: 4px;
$border_radius_medium: 6px;
$border_radius_large: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);

View File

@@ -0,0 +1,377 @@
<?php
/**
* Class for the building ui-iconpicker elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'UI_Iconpicker' ) ) {
/**
* Class for the building ui-iconpicker elements.
*/
class UI_Iconpicker extends UI_Element implements I_UI {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $defaults_settings = array(
'type' => 'iconpicker',
'id' => 'cherry-ui-input-id',
'name' => 'cherry-ui-input-name',
'value' => '',
'placeholder' => '',
'icon_data' => array(),
'auto_parse' => false,
'label' => '',
'class' => '',
'master' => '',
'width' => 'fixed', // full, fixed
'required' => false,
'lock' => false,
);
/**
* Instance of this Cherry5_Lock_Element class.
*
* @since 1.0.0
* @var object
* @access private
*/
private $lock_element = null;
/**
* Default icon data settings.
*
* @var array
*/
private $default_icon_data = array(
'icon_set' => '',
'icon_css' => '',
'icon_base' => 'icon',
'icon_prefix' => '',
'icons' => '',
);
/**
* Icons sets
*
* @var array
*/
public static $sets = array();
/**
* Check if sets already printed
*
* @var boolean
*/
public static $printed = false;
/**
* Array of already printed sets to check it before printing current
*
* @var array
*/
public static $printed_sets = array();
public $temp_icons = null;
/**
* Constructor method for the UI_Iconpicker class.
*
* @since 1.0.0
*/
function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cherry-ui-input-icon-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
$this->lock_element = new Cherry5_Lock_Element( $this->settings );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
add_action( 'admin_footer', array( $this, 'print_icon_set' ), 1 );
add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_icon_set' ), 9999 );
add_filter( 'cherry_handler_response_data', array( $this, 'send_icon_set' ), 10, 1 );
}
/**
* Get required attribute
*
* @return string required attribute
*/
public function get_required() {
if ( $this->settings['required'] ) {
return 'required="required"';
}
return '';
}
/**
* Render html UI_Iconpicker.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$lock_lable = ! empty( $this->settings['lock']['label'] )? sprintf('<div class="cherry-lock-label">%1$s</div>', $this->settings['lock']['label'] ) : '' ;
$class = implode( ' ',
array(
$this->settings['class'],
$this->settings['master'],
$this->settings['width'],
$this->lock_element->get_class( 'inline-block' ),
)
);
$html .= '<div class="cherry-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$this->settings['icon_data'] = wp_parse_args(
$this->settings['icon_data'],
$this->default_icon_data
);
$html .= '<div class="cherry-ui-iconpicker-group">';
if ( $this->validate_icon_data( $this->settings['icon_data'] ) ) {
$html .= $this->render_picker();
} else {
$html .= 'Incorrect Icon Data Settings';
}
$html .= '</div>';
$html .= $this->lock_element->get_html();
$html .= '</div>';
/**
* Maybe add js repeater template to response
*
* @var bool
*/
$add_js_to_response = apply_filters( 'cherry_ui_add_data_to_element', false );
if ( $add_js_to_response ) {
ob_start();
$this->print_icon_set();
$icons = ob_get_clean();
$in_repeater = apply_filters( 'cherry_ui_is_repeater', false );
if ( $in_repeater ) {
$this->temp_icons = $icons;
add_filter( 'cherry_ui_add_repater_data', array( $this, 'store_icons' ) );
} else {
$html .= $icons;
}
}
return $html;
}
public function store_icons( $data = array() ) {
if ( ! is_array( $data ) ) {
$data = array();
}
$data[] = $this->temp_icons;
return $data;
}
/**
* Returns iconpicker html markup
*
* @return string
*/
private function render_picker() {
$format = '<span class="input-group-addon"></span><input type="text" name="%1$s" id="%2$s" value="%3$s" class="widefat cherry-ui-text cherry-ui-iconpicker %4$s" data-set="%5$s">';
$this->prepare_icon_set();
return sprintf(
$format,
$this->settings['name'],
$this->settings['id'],
$this->settings['value'],
$this->settings['class'],
$this->settings['icon_data']['icon_set']
);
}
/**
* Return JS markup for icon set variable.
*
* @return void
*/
public function prepare_icon_set() {
if ( empty( $this->settings['icon_data']['icons'] ) ) {
$this->maybe_parse_set_from_css();
}
if ( ! array_key_exists( $this->settings['icon_data']['icon_set'], self::$sets ) ) {
self::$sets[ $this->settings['icon_data']['icon_set'] ] = array(
'iconCSS' => $this->settings['icon_data']['icon_css'],
'iconBase' => $this->settings['icon_data']['icon_base'],
'iconPrefix' => $this->settings['icon_data']['icon_prefix'],
'icons' => $this->settings['icon_data']['icons'],
);
}
}
/**
* Check if 'parse_set' is true and try to get icons set from CSS file
*
* @return void
*/
private function maybe_parse_set_from_css() {
if ( true !== $this->settings['auto_parse'] || empty( $this->settings['icon_data']['icon_css'] ) ) {
return;
}
ob_start();
$path = str_replace( content_url(), WP_CONTENT_DIR, $this->settings['icon_data']['icon_css'] );
if ( file_exists( $path ) ) {
include $path;
}
$result = ob_get_clean();
preg_match_all( '/\.([-_a-zA-Z0-9]+):before[, {]/', $result, $matches );
if ( ! is_array( $matches ) || empty( $matches[1] ) ) {
return;
}
if ( is_array( $this->settings['icon_data']['icons'] ) ) {
$this->settings['icon_data']['icons'] = array_merge(
$this->settings['icon_data']['icons'],
$matches[1]
);
} else {
$this->settings['icon_data']['icons'] = $matches[1];
}
}
/**
* Checks if all required icon data fields are passed
*
* @param array $data Icon data.
* @return bool
*/
private function validate_icon_data( $data ) {
$validate = array_diff( $this->default_icon_data, array( 'icon_base', 'icon_prefix' ) );
foreach ( $validate as $key => $field ) {
if ( empty( $data[ $key ] ) ) {
return false;
}
return true;
}
}
/**
* Function sends the icons into ajax response.
*
* @param array $data Icon data.
* @return array
*/
public function send_icon_set( $data ) {
if ( empty( $data['cherryIconsSets'] ) ) {
$data['cherry5IconSets'] = array();
}
foreach ( self::$sets as $key => $value ) {
$data['cherry5IconSets'][ $key ] = $value;
}
return $data;
}
/**
* Print icon sets
*
* @return void
*/
public function print_icon_set() {
if ( empty( self::$sets ) || true === self::$printed ) {
return;
}
self::$printed = true;
foreach ( self::$sets as $set => $data ) {
if ( in_array( $set, self::$printed_sets ) ) {
continue;
}
self::$printed_sets[] = $set;
$json = json_encode( $data );
printf( '<script> if ( ! window.cherry5IconSets ) { window.cherry5IconSets = {} } window.cherry5IconSets.%1$s = %2$s</script>', $set, $json );
}
}
/**
* Enqueue javascript and stylesheet UI_Iconpicker
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_style(
'ui-iconpicker',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-iconpicker/assets/min/ui-iconpicker.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
wp_enqueue_script(
'jquery-iconpicker',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-iconpicker/assets/min/jquery-iconpicker.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
wp_enqueue_script(
'ui-iconpicker',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-iconpicker/assets/min/ui-iconpicker.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
}
}
}

View File

@@ -0,0 +1 @@
!function(e,a){"use strict";a.utilites.namespace("ui_elements.media"),a.ui_elements.media={init:function(){e(document).on("ready",this.render).on("cherry-ui-elements-init",this.render)},render:function(a){var i=a._target?a._target:e("body"),r=e(".cherry-upload-button",i);r.each(function(){var a=e(this),i=a.closest(".cherry-ui-media-wrap"),r={input:e(".cherry-upload-input",i),img_holder:e(".cherry-upload-preview",i),title_text:a.data("title"),multiple:a.data("multi-upload"),library_type:a.data("library-type")},t=wp.media.frames.file_frame=wp.media({title:r.title_text,button:{text:r.title_text},multiple:r.multiple,library:{type:r.library_type}});if(!i.has('input[name*="__i__"]')[0]){a.off("click.cherry-media").on("click.cherry-media",function(){return t.open(),!1}),t.on("select",function(){var a=t.state().get("selection").toJSON(),i=0,s="",c=e(".cherry-all-images-wrap",r.img_holder),n="",l="";for(r.multiple&&(s=r.input.val(),l=",",n=c.html());a[i];){var o=a[i],d=o.id,p=o.mime,m="",u="";switch(p){case"image/jpeg":case"image/png":case"image/gif":void 0!==o.sizes&&(m=o.sizes.thumbnail?o.sizes.thumbnail.url:o.sizes.full.url),u='<img src="'+m+'" alt="" data-img-attr="'+d+'">';break;case"image/x-icon":u='<span class="dashicons dashicons-format-image"></span>';break;case"video/mpeg":case"video/mp4":case"video/quicktime":case"video/webm":case"video/ogg":u='<span class="dashicons dashicons-format-video"></span>';break;case"audio/mpeg":case"audio/wav":case"audio/ogg":u='<span class="dashicons dashicons-format-audio"></span>'}n+='<div class="cherry-image-wrap"><div class="inner"><div class="preview-holder" data-id-attr="'+d+'"><div class="centered">'+u+'</div></div><a class="cherry-remove-image" href="#"><i class="dashicons dashicons-no"></i></a><span class="title">'+o.title+"</span></div></div>",s+=l+d,i++}r.input.val(s.replace(/(^,)/,"")).trigger("change"),c.html(n)});var s=function(a){var i=a.closest(".cherry-ui-media-wrap"),r=e(".cherry-upload-input",i),t=a.parent().parent(".cherry-image-wrap"),s=e(".preview-holder",t).data("id-attr"),c=r.attr("value"),n=new RegExp(""+s+"(,*)","i");c=c.replace(n,""),c=c.replace(/(,$)/,""),r.attr({value:c}).trigger("change"),t.remove()};i.on("click",".cherry-remove-image",function(){return s(e(this)),!1})}}),e(".cherry-all-images-wrap",i).sortable({items:"div.cherry-image-wrap",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"cherry-media-thumb-sortable-placeholder",start:function(){},stop:function(){},update:function(){var a="";e(".cherry-image-wrap",this).each(function(){var i=e(".preview-holder",this).data("id-attr");a=a+i+","}),a=a.substr(0,a.lastIndexOf(",")),e(this).parent().siblings(".cherry-element-wrap").find("input.cherry-upload-input").val(a).trigger("change")}})}},a.ui_elements.media.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,51 @@
@mixin button_base() {
position: relative;
display: inline-block;
font-size: 11px;
line-height: 18px;
font-weight: 900;
text-decoration: none;
padding: 4px 22px;
color: $dark_color;
text-transform: uppercase;
border-radius: $border_radius_small;
border-width: 1px;
border-style: solid;
outline: none;
cursor: pointer;
transition: all 200ms linear;
&:before {
position: absolute;
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
border-radius: $border_radius_small;
background-image: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
content: '';
}
&:hover {
&:before {
background-image: linear-gradient(0deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%);
}
}
&:active {
&:before {
opacity: 0;
}
}
}
@mixin secondary_button() {
color: $light_color;
border-color: $secondary_outset_1 $secondary_outset_2 $secondary_outset_2 $secondary_outset_1;
background-color: $secondary_gradint_2;
&:active {
background-color: $secondary_bg_color;
border-color: darken( $secondary_outset_2, 10%) $secondary_outset_1 $secondary_outset_1 darken( $secondary_outset_2, 10%);
}
}

View File

@@ -0,0 +1,52 @@
$bg_color: #f1f1f1;
$border_color: #dcdcdc;
$blue_color: #298ffc;
$remove_color: #e54343;
$light_color: #ffffff;
$dark_color: #23282d;
$normal_bg_color: #e1e1e1;
$normal_gradint_1: #ffffff;
$normal_gradint_2: #f0f0f0;
$normal_outset_1: #d7d7d7;
$normal_outset_2: #b7b7b7;
$primary_bg_color: #206ff4;
$primary_gradint_1: #5fadff;
$primary_gradint_2: #2a90fc;
$primary_outset_1: #5b9add;
$primary_outset_2: #3e6a99;
$secondary_bg_color: #495159;
$secondary_gradint_1: #4c5054;
$secondary_gradint_2: #495159;
$secondary_outset_1: #777879;
$secondary_outset_2: #2f343a;
$success_bg_color: #3ba956;
$success_gradint_1: #71e18f;
$success_gradint_2: #49c66a;
$success_outset_1: #49c56a;
$success_outset_2: #3a9e54;
$danger_bg_color: #c73434;
$danger_gradint_1: #f98888;
$danger_gradint_2: #e64545;
$danger_outset_1: #e54444;
$danger_outset_2: #b83636;
$warning_bg_color: #ee8425;
$warning_gradint_1: #ffcb81;
$warning_gradint_2: #faa832;
$warning_outset_1: #faa832;
$warning_outset_2: #c98627;
$border_radius_extra_small: 2px;
$border_radius_small: 4px;
$border_radius_medium: 6px;
$border_radius_large: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);

View File

@@ -0,0 +1,156 @@
/**
* Media
*/
(function( $, CherryJsCore){
'use strict';
CherryJsCore.utilites.namespace('ui_elements.media');
CherryJsCore.ui_elements.media = {
init: function () {
$( document )
.on( 'ready', this.render )
.on( 'cherry-ui-elements-init', this.render );
},
render: function ( event ) {
var target = ( event._target ) ? event._target : $( 'body' ),
buttons = $('.cherry-upload-button', target);
buttons.each( function() {
var button = $( this ),
button_parent = button.closest('.cherry-ui-media-wrap'),
settings = {
input: $('.cherry-upload-input', button_parent),
img_holder: $('.cherry-upload-preview', button_parent),
title_text: button.data('title'),
multiple: button.data('multi-upload'),
library_type: button.data('library-type'),
},
cherry_uploader = wp.media.frames.file_frame = wp.media({
title: settings.title_text,
button: { text: settings.title_text },
multiple: settings.multiple,
library : { type : settings.library_type }
});
if ( ! button_parent.has('input[name*="__i__"]')[ 0 ] ) {
button.off( 'click.cherry-media' ).on( 'click.cherry-media', function() {
cherry_uploader.open();
return !1;
} ); // end click
cherry_uploader.on('select', function() {
var attachment = cherry_uploader.state().get('selection').toJSON(),
count = 0,
input_value = '',
new_img_object = $('.cherry-all-images-wrap', settings.img_holder),
new_img = '',
delimiter = '';
if ( settings.multiple ) {
input_value = settings.input.val();
delimiter = ',';
new_img = new_img_object.html();
}
while( attachment[ count ] ) {
var img_data = attachment[count],
return_data = img_data.id,
mimeType = img_data.mime,
img_src = '',
thumb = '';
switch (mimeType) {
case 'image/jpeg':
case 'image/png':
case 'image/gif':
if( img_data.sizes !== undefined){
img_src = img_data.sizes.thumbnail ? img_data.sizes.thumbnail.url : img_data.sizes.full.url;
}
thumb = '<img src="' + img_src + '" alt="" data-img-attr="'+return_data+'">';
break;
case 'image/x-icon':
thumb = '<span class="dashicons dashicons-format-image"></span>';
break;
case 'video/mpeg':
case 'video/mp4':
case 'video/quicktime':
case 'video/webm':
case 'video/ogg':
thumb = '<span class="dashicons dashicons-format-video"></span>';
break;
case 'audio/mpeg':
case 'audio/wav':
case 'audio/ogg':
thumb = '<span class="dashicons dashicons-format-audio"></span>';
break;
}
new_img += '<div class="cherry-image-wrap">'+
'<div class="inner">'+
'<div class="preview-holder" data-id-attr="' + return_data +'"><div class="centered">' + thumb + '</div></div>'+
'<a class="cherry-remove-image" href="#"><i class="dashicons dashicons-no"></i></a>'+
'<span class="title">' + img_data.title + '</span>'+
'</div>'+
'</div>';
input_value += delimiter+return_data;
count++;
}
settings.input.val(input_value.replace(/(^,)/, '')).trigger( 'change' );
new_img_object.html(new_img);
} );
var removeMediaPreview = function( item ) {
var button_parent = item.closest('.cherry-ui-media-wrap'),
input = $('.cherry-upload-input', button_parent),
img_holder = item.parent().parent('.cherry-image-wrap'),
img_attr = $('.preview-holder', img_holder).data('id-attr'),
input_value = input.attr('value'),
pattern = new RegExp(''+img_attr+'(,*)', 'i');
input_value = input_value.replace(pattern, '');
input_value = input_value.replace(/(,$)/, '');
input.attr({'value':input_value}).trigger( 'change' );
img_holder.remove();
};
// This function remove upload image
button_parent.on('click', '.cherry-remove-image', function () {
removeMediaPreview( $(this) );
return !1;
});
}
} ); // end each
// Image ordering
$('.cherry-all-images-wrap', target).sortable( {
items: 'div.cherry-image-wrap',
cursor: 'move',
scrollSensitivity: 40,
forcePlaceholderSize: true,
forceHelperSize: false,
helper: 'clone',
opacity: 0.65,
placeholder: 'cherry-media-thumb-sortable-placeholder',
start:function(){},
stop:function(){},
update: function() {
var attachment_ids = '';
$('.cherry-image-wrap', this).each(
function() {
var attachment_id = $('.preview-holder', this).data( 'id-attr' );
attachment_ids = attachment_ids + attachment_id + ',';
}
);
attachment_ids = attachment_ids.substr(0, attachment_ids.lastIndexOf(',') );
$(this).parent().siblings('.cherry-element-wrap').find('input.cherry-upload-input').val( attachment_ids ).trigger( 'change' );
}
} );
// End Image ordering
}
};
CherryJsCore.ui_elements.media.init();
}( jQuery , window.CherryJsCore ) );

View File

@@ -0,0 +1,157 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
@import "../../../../assets/sass/lock";
.cherry-ui-elements-lock{
opacity: 0.5;
cursor: no-drop;
pointer-events: none;
filter: grayscale( 100% );
}
.cherry-ui-container {
margin: 10px 0 20px 0;
}
label.cherry-label {
margin: 0 0 5px 0;
display: block;
}
.cherry-ui-media-wrap {
.cherry-upload-preview {
display: block;
margin: 0 0 5px 0;
.cherry-image-wrap {
position: relative;
display: inline-block;
vertical-align: top;
width: 128px;
height: 128px;
.inner {
width: 110px;
height: 110px;
margin: 3px;
position: relative;
border: 1px solid #d5dadf;
padding: 5px;
overflow: hidden;
.preview-holder {
width: 100%;
height: 100%;
position: relative;
background: $bg_color;
box-sizing: border-box;
.centered {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
transform: translate(50%,50%);
}
img {
max-width: 100%;
height: auto;
transform: translate(-50%,-50%);
}
span {
width: auto;
height: auto;
font-size: 60px;
transform: translate(-50%,-50%);
}
}
.title {
position: absolute;
display: none;
width: 100px;
padding: 5px;
margin: 5px;
bottom: 0;
left: 0;
color: #fff;
background: #a4afb7;
text-align: center;
font-size: 11px;
overflow: hidden;
}
}
&:hover {
.inner {
border-color: #d5dadf;
}
.title {
display: block;
}
.cherry-remove-image {
display: block;
}
}
}
.cherry-media-thumb-sortable-placeholder {
width: 120px;
height: 120px;
margin: 3px;
vertical-align: top;
border: 1px dashed $border_color;
display: inline-block;
background-color: $bg_color;
}
}
.upload-button {
float: left;
}
.cherry-remove-image {
width: 25px;
height: 25px;
color: $remove_color;
display: block;
position: absolute;
top: 5px;
right: 5px;
cursor: pointer;
text-decoration: none;
outline: 0;
display: none;
i {
width: 25px;
height: 25px;
font-size: 25px;
}
&:hover {
color: darken( $remove_color, 10% );
}
}
.cherry-bgsetting {
float: left;
width: 32%;
margin-right: 1%;
&:nth-child(3n+1) {
width: 34%;
margin-right: 0;
}
select {
margin-bottom: 10px;
}
}
}
.button-default_ {
@include button_base();
@include secondary_button();
}

View File

@@ -0,0 +1,195 @@
<?php
/**
* Class for the building ui-media elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cherryframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cherryframework.com/
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'UI_Media' ) ) {
/**
* Class for the building UI_Media elements.
*/
class UI_Media extends UI_Element implements I_UI {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
private $defaults_settings = array(
'id' => 'cherry-ui-media-id',
'name' => 'cherry-ui-media-name',
'value' => '',
'multi_upload' => true,
'library_type' => '', // image, video, sound
'upload_button_text' => 'Choose Media',
'label' => '',
'class' => '',
'master' => '',
'lock' => false,
);
/**
* Instance of this Cherry5_Lock_Element class.
*
* @since 1.0.0
* @var object
* @access private
*/
private $lock_element = null;
/**
* Constructor method for the UI_Media class.
*
* @since 1.0.0
*/
public function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cherry-ui-media-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
$this->lock_element = new Cherry5_Lock_Element( $this->settings );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
}
/**
* Render html UI_Media.
*
* @since 1.0.0
*/
public function render() {
$html = '';
if ( current_user_can( 'upload_files' ) ) {
$class = implode( ' ',
array(
$this->settings['class'],
$this->settings['master'],
$this->lock_element->get_class( 'inline-block' ),
)
);
$html .= '<div class="cherry-ui-container ' . esc_attr( $class ) . '">';
if ( '' != $this->settings['value'] ) {
$this->settings['value'] = str_replace( ' ', '', $this->settings['value'] );
$medias = explode( ',', $this->settings['value'] );
} else {
$this->settings['value'] = '';
$medias = array();
}
$img_style = ! $this->settings['value'] ? 'style="display:none;"' : '' ;
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cherry-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cherry-ui-media-wrap">';
$html .= '<div class="cherry-upload-preview" >';
$html .= '<div class="cherry-all-images-wrap">';
if ( is_array( $medias ) && ! empty( $medias ) ) {
foreach ( $medias as $medias_key => $medias_value ) {
$media_title = get_the_title( $medias_value );
$mime_type = get_post_mime_type( $medias_value );
$tmp = wp_get_attachment_metadata( $medias_value );
$img_src = '';
$thumb = '';
switch ( $mime_type ) {
case 'image/jpeg':
case 'image/png':
case 'image/gif':
$img_src = wp_get_attachment_image_src( $medias_value, 'thumbnail' );
$img_src = $img_src[0];
$thumb = '<img src="' . esc_html( $img_src ) . '" alt="">';
break;
case 'image/x-icon':
$thumb = '<span class="dashicons dashicons-format-image"></span>';
break;
case 'video/mpeg':
case 'video/mp4':
case 'video/quicktime':
case 'video/webm':
case 'video/ogg':
$thumb = '<span class="dashicons dashicons-format-video"></span>';
break;
case 'audio/mpeg':
case 'audio/wav':
case 'audio/ogg':
$thumb = '<span class="dashicons dashicons-format-audio"></span>';
break;
}
$html .= '<div class="cherry-image-wrap">';
$html .= '<div class="inner">';
$html .= '<div class="preview-holder" data-id-attr="' . esc_attr( $medias_value ) . '">';
$html .= '<div class="centered">';
$html .= $thumb;
$html .= '</div>';
$html .= '</div>';
$html .= '<span class="title">' . $media_title . '</span>';
$html .= '<a class="cherry-remove-image" href="#" title=""><i class="dashicons dashicons-no"></i></a>';
$html .= '</div>';
$html .= '</div>';
}
}
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="cherry-element-wrap">';
$html .= '<input type="hidden" id="' . esc_attr( $this->settings['id'] ) . '" class="cherry-upload-input" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '"' . $this->lock_element->get_disabled_attr() . '>';
$html .= '<button type="button" class="upload-button cherry-upload-button button-default_" value="' . esc_attr( $this->settings['upload_button_text'] ) . '" data-title="' . esc_attr( $this->settings['upload_button_text'] ) . '" data-multi-upload="' . esc_attr( $this->settings['multi_upload'] ) . '" data-library-type="' . esc_attr( $this->settings['library_type'] ) . '"' . $this->lock_element->get_disabled_attr() . '>' . esc_attr( $this->settings['upload_button_text'] ) . '</button>';
$html .= '<div class="clear"></div>';
$html .= '</div>';
$html .= '</div>';
$html .= $this->lock_element->get_html();
$html .= '</div>';
}
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Media.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
if ( current_user_can( 'upload_files' ) ) {
wp_enqueue_media();
wp_enqueue_script(
'ui-media',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-media/assets/min/ui-media.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery', 'jquery-ui-sortable' ),
Cherry_UI_Elements::$core_version,
true
);
wp_enqueue_style(
'ui-media',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-media/assets/min/ui-media.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
}
}
}
}

View File

@@ -0,0 +1 @@
.cherry-lock-element{user-select:none;cursor:no-drop;position:relative;filter:grayscale(100%)}.cherry-lock-element.inline-block{display:inline-block}.cherry-lock-element label{position:relative}.cherry-lock-element .cherry-lable-content,.cherry-lock-element .cherry-checkbox-item,.cherry-lock-element .select2-container,.cherry-lock-element>*:first-child{opacity:0.5;pointer-events:none}.cherry-lock-element a.cherry-lock-element__area{position:absolute;top:0;left:0;width:100%;height:100%;z-index:2000;cursor:no-drop}.cherry-lock-element a.cherry-lock-element__area:focus{outline:none;box-shadow:none}.cherry-lock-element a.cherry-lock-element__area:hover .cherry-lock-element__label{animation-name:lock_show;animation-duration:450ms;animation-timing-function:cubic-bezier(0.165, 0.84, 0.44, 1)}.cherry-lock-element__label{opacity:0;display:inline-block;background-color:rgba(0,0,0,0.9);border-radius:5px;color:#fff;padding:8px 10px;position:absolute;white-space:nowrap;top:-10px;left:50%;box-shadow:2px 2px 5px 0px rgba(0,0,0,0.5);will-change:auto;pointer-events:none;font-size:14px;line-height:16px;animation-name:lock_hide;animation-duration:200ms;animation-timing-function:cubic-bezier(0.55, 0.055, 0.675, 0.19);animation-fill-mode:both;transform-origin:0% 0%}.cherry-lock-element__label *+*{margin-right:5px}.cherry-lock-element__label:after{border:solid;border-color:rgba(0,0,0,0.9) transparent;border-width:6px 6px 0 6px;bottom:-5px;margin-left:-6px;content:"";left:50%;position:absolute}@keyframes lock_show{0%{opacity:0;filter:blur(5px);transform:scale(0) translate(-50%, 200%)}60%{opacity:0.8;transform:scale(1.1) translate(-50%, -130%)}100%{opacity:1;filter:blur(0px);transform:scale(1) translate(-50%, -100%)}}@keyframes lock_hide{0%{opacity:1;filter:blur(0px);transform:scale(1) translate(-50%, -100%)}100%{opacity:0;filter:blur(3px);transform:scale(0) translate(-50%, 200%)}}.cherry-ui-container{margin:10px 0 20px 0}label.cherry-label{margin:0 0 5px 0;display:block}.hide{display:none !important}input.cherry-radio-input{display:none}.cherry-radio-item{margin-bottom:10px}.cherry-radio-item:last-child{margin-bottom:0}.cherry-radio-item label{display:inline-block;font-size:12px;line-height:14px;color:#23282d}.cherry-radio-item span.cherry-radio-item{width:16px;height:16px;border-radius:25px;margin-right:10px;cursor:pointer;position:relative;background-color:white;display:inline-block;float:left;box-shadow:1px 1px 6px rgba(0,0,0,0.2)}.cherry-radio-item span.cherry-radio-item i{width:8px;height:8px;background-color:#495159;margin:4px;border-radius:20px;display:inline-block;transform:scale(0);transition:all 0.4s cubic-bezier(0.77, 0, 0.175, 1)}.cherry-radio-item .cherry-radio-input:checked+label span i{transform:scale(1)}.cherry-radio-img{float:left;margin:10px 5px 0 5px;text-align:center;max-width:60px;font-size:12px;position:relative}.cherry-radio-img .cherry-lable-content{display:flex;flex-flow:column}.cherry-radio-img label{display:inline-block}.cherry-radio-img img{width:100%;height:auto;margin:0 0 5px 0;pointer-events:none}.cherry-radio-img .cherry-radio-input:checked+label{font-weight:bold}.cherry-radio-img .cherry-radio-input:checked+label .check{display:block}.cherry-radio-img .cherry-radio-input:checked+label img{box-shadow:0 0 0 2px #fffeff,0 0 0 5px #49c66a}

View File

@@ -0,0 +1 @@
!function(t,e){"use strict";e.utilites.namespace("ui_elements.radio"),e.ui_elements.radio={inputClass:'.cherry-radio-input:not([name*="__i__"])',containerClass:".cherry-ui-container",wrapperClass:".widget, .postbox, .cherry-form, .cherry-ui-repeater-item",init:function(){t(document).on("ready.cherry-ui-elements-init",this.addEvent.bind(this)).on("cherry-ui-elements-init",this.setState.bind(this))},addEvent:function(){t("body").on("click.masterSlave",this.inputClass,this.switchState.bind(this)),this.setState({_target:t("body")})},setState:function(e){this.switchState({currentTarget:t(this.inputClass,e._target)})},switchState:function(e){for(var i,s,n,r=t(e.currentTarget).closest(this.containerClass),a=t(this.inputClass,r),c=a.length-1;c>=0;c--)i=t(a[c]),n=i.data(),s=i.closest(this.wrapperClass),jQuery.isEmptyObject(n)||t("."+n.slave,s)[i[0].checked?"removeClass":"addClass"]("hide")}},e.ui_elements.radio.init()}(jQuery,window.CherryJsCore);

View File

@@ -0,0 +1,184 @@
@mixin button_base() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
padding: 15px 20px;
color: #fff;
text-transform: uppercase;
border-radius: $border_radius_small;
transition: all 200ms linear;
box-shadow: $box_shadow;
&:hover {
color: #fff;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: #fff;
}
}
@mixin button_normal() {
background: $dark_color_2;
&:hover {
background: $dark_color_2_h;
}
}
@mixin button_primary() {
background: $blue_color;
&:hover {
background: $blue_color_h;
}
}
@mixin button_success() {
background: $green_color;
&:hover {
background: $green_color_h;
}
}
@mixin button_danger() {
background: $red_color;
&:hover {
background: $red_color_h;
}
}
@mixin button_warning() {
background: $orange_color;
&:hover {
background: $orange_color_h;
}
}
@mixin input() {
font-size: 14px;
line-height: 20px;
color: $dark_color_1;
background-color: $grey_color_3;
border-radius: $border_radius_extra_small;
padding: 10px 20px;
min-height: 50px;
border: 1px solid $grey_color_3;
box-shadow: none;
&:focus{
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
}
}
@mixin button_icon( $icon ) {
content: $icon;
display: inline-block;
font-family: dashicons;
font-size: 16px;
font-style: normal;
font-weight: 400;
height: 18px;
line-height: 18px;
text-align: center;
text-decoration: inherit;
transition: all 200ms linear;
vertical-align: middle;
}
@mixin button_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
}
}
@mixin button_icon_after( $icon ) {
&:after {
@include button_icon( $icon );
padding: 0 0 0 5px;
}
}
@mixin button_icon_middle( $icon ) {
&:before {
@include button_icon( $icon );
margin: 0 -5px;
}
}
@mixin link() {
display: inline-block;
text-decoration: none;
font-size: 12px;
line-height: 20px;
font-weight: bold;
color: $blue_color;
text-transform: uppercase;
transition: all 200ms linear;
&:hover {
color: $dark_color_1;
box-shadow: none;
}
&:focus,
&:active {
outline: none;
border-color: rgba(41, 143, 252, .6);
box-shadow: 0 0 2px rgba(41, 143, 252, .6);
color: $blue_color;
}
}
@mixin link_icon_before( $icon ) {
&:before {
@include button_icon( $icon );
padding: 0 5px 0 0;
color: $grey_color_4;
}
&:hover {
&:before {
color: $blue_color;
}
}
}
@mixin container() {
padding: 30px;
border: 2px solid $grey_color_2;
background: $grey_color_3;
border-radius: $border_radius_large;
}
@mixin container_heading() {
margin: -30px -30px 30px -30px;
border-radius: $border_radius_large $border_radius_large 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
text-align: center;
background: #fff;
}
@mixin box() {
margin: 0 0 30px;
padding: 20px;
background: #fff;
box-shadow: $box_shadow_box;
border-radius: $border_radius;
}
@mixin box_heading() {
margin: -20px -20px 20px -20px;
border-radius: $border_radius_small $border_radius_small 0 0;
border-bottom: 1px solid $grey_color_2;
padding: 20px 30px;
font-weight: bold;
font-size: 16px;
line-height: 18px;
background: #fff;
}

View File

@@ -0,0 +1,21 @@
$dark_color_1: #23282d;
$dark_color_2: #495159;
$dark_color_2_h: #393f45;
$grey_color_1: #96989a;
$grey_color_2: #e5e5e5;
$grey_color_3: #f1f1f1;
$grey_color_4: #b4b7ba;
$blue_color: #298ffc;
$blue_color_h: #206ff4;
$green_color: #48c569;
$green_color_h: #3ba956;
$red_color: #e54343;
$red_color_h: #c73434;
$orange_color: #faa730;
$orange_color_h: #ee8425;
$border_radius: 4px;
$border_radius_2x: 8px;
$box_shadow: 0 5px 13px rgba(0,0,0,.18);
$box_shadow_box: 0 8px 21px rgba(0,0,0,.1);

View File

@@ -0,0 +1,48 @@
/**
* Radio
*/
(function($, CherryJsCore){
'use strict';
CherryJsCore.utilites.namespace('ui_elements.radio');
CherryJsCore.ui_elements.radio = {
inputClass: '.cherry-radio-input:not([name*="__i__"])',
containerClass: '.cherry-ui-container',
wrapperClass: '.widget, .postbox, .cherry-form, .cherry-ui-repeater-item',
init: function () {
$( document )
.on( 'ready.cherry-ui-elements-init', this.addEvent.bind( this ) )
.on( 'cherry-ui-elements-init', this.setState.bind( this ) );
},
addEvent: function () {
$( 'body' ).on( 'click.masterSlave', this.inputClass, this.switchState.bind( this ) );
this.setState( { '_target': $( 'body' ) } );
},
setState: function ( event ) {
this.switchState( { 'currentTarget': $( this.inputClass, event._target ) } );
},
switchState: function ( event ) {
var parent = $( event.currentTarget ).closest( this.containerClass ),
children = $( this.inputClass, parent ),
i = children.length - 1,
$_target,
wrapper,
data;
for (; i >= 0; i--) {
$_target = $( children[ i ] );
data = $_target.data();
wrapper = $_target.closest( this.wrapperClass );
if ( jQuery.isEmptyObject( data ) ) {
continue;
} else {
$( '.' + data.slave, wrapper )[ ( $_target[ 0 ].checked ) ? 'removeClass' : 'addClass' ]( 'hide' );
}
}
}
};
CherryJsCore.ui_elements.radio.init();
}(jQuery, window.CherryJsCore));

View File

@@ -0,0 +1,105 @@
@import "ui-kit/variables";
@import "ui-kit/mixins";
@import "../../../../assets/sass/lock";
.cherry-ui-container{
margin: 10px 0 20px 0;
}
label.cherry-label{
margin: 0 0 5px 0;
display: block;
}
.hide{
display: none !important;
}
input.cherry-radio-input{
display: none;
}
.cherry-radio-item{
margin-bottom: 10px;
&:last-child{
margin-bottom: 0;
}
label {
display: inline-block;
font-size: 12px;
line-height: 14px;
color: $dark_color_1;
}
span.cherry-radio-item {
width: 16px;
height: 16px;
border-radius: 25px;
margin-right: 10px;
cursor: pointer;
position: relative;
background-color: white;
display: inline-block;
float: left;
box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.2);
i {
width: 8px;
height: 8px;
background-color: #495159;
margin: 4px;
border-radius: 20px;
display: inline-block;
transform: scale(0);
transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
}
}
}
.cherry-radio-item {
.cherry-radio-input:checked{
& + label{
span{
i{
transform: scale(1);
}
}
}
}
}
.cherry-radio-img {
float: left;
margin: 10px 5px 0 5px;
text-align: center;
max-width: 60px;
font-size: 12px;
position: relative;
.cherry-lable-content {
display: flex;
flex-flow: column;
}
label{
display: inline-block;
}
img {
width: 100%;
height: auto;
margin: 0 0 5px 0;
pointer-events: none;
}
}
.cherry-radio-img{
.cherry-radio-input:checked{
& + label{
font-weight: bold;
.check{
display: block;
}
img{
box-shadow: 0 0 0 2px rgba(255, 254, 255, 1), 0 0 0 5px #49c66a;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More