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,40 @@
# Changelog
## 1.1.7
- FIX: Compatibility with Elementor 2.4.0
## 1.1.6
- FIX: Compatibility with Elementor 2.3.3
## 1.1.5
- ADD: RU localization
## 1.1.4
- FIX: Compatibility with Elementor 2.3.0
## 1.1.3
- ADD: 'Search Results' condition for Archives
## 1.1.2
- FIX: Magic Button modal loader
- FIX: Page settings import on template import
## 1.1.1
- UPD: Make Post Types Archive: Post condition more clear to use
## 1.1.0
- ADD: archive and single structures
- ADD: Archive Taxonomy condition
- UPD: Archive Post Type condition
- FIX: Theme template source
## 1.0.7
- ADD: new setting - Prevent Pro locations registration (avoid conflicts with themes without Elementor Pro support)
- FIX: prevent errors when Elementor is not installed
- FIX: Elementor 2.1.0 compatibility
- FIX: avoid of duplicating Active conditions
## 1.0.6
- ADD: allow to install JetPluginsWizard from dashboard

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
.jet-location-edit{position:relative}.jet-location-edit__link{position:absolute;opacity:0;top:0;left:0;right:0;bottom:0;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-transition:opacity 200ms linear;transition:opacity 200ms linear;border:4px solid #71d7f7;background:rgba(113,215,247,0.2);color:#fff;z-index:99999;cursor:pointer;font-weight:400;font-size:16px;font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif}.jet-location-edit__link-content{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-image:-webkit-gradient(linear, left top, left bottom, from(#41c9f4), to(#71d7f7));background-image:linear-gradient(to bottom, #41c9f4, #71d7f7);padding:4px 15px 6px 10px}.jet-location-edit__link .dashicons{margin-right:4px}.jet-location-edit:hover .jet-location-edit__link{color:#fff;opacity:1;text-decoration:none}.elementor-add-new-section .add-jet-template{color:#fff;background-image:none;background:#398ffc !important;font-size:13px;font-family:Arial, Helvetica, sans-serif;font-weight:normal;font-style:normal;text-transform:uppercase;line-height:1;height:40px;min-width:170px;padding:0 20px;border:none;border-radius:3px;cursor:pointer;margin-right:25px;-webkit-transition:all 0.5s;transition:all 0.5s;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;vertical-align:bottom}.elementor-add-new-section .add-jet-template svg{width:17px;margin:-2px 9px 0px -3px}.elementor-add-new-section .add-jet-template:hover{opacity:0.85;-webkit-box-shadow:0 0 2px rgba(0,0,0,0.12),0 2px 2px rgba(0,0,0,0.2);box-shadow:0 0 2px rgba(0,0,0,0.12),0 2px 2px rgba(0,0,0,0.2)}

View File

@@ -0,0 +1 @@
.jet-template-types-popup{display:none;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:fixed;top:0;left:0;right:0;bottom:0;z-index:999}.jet-template-types-popup.jet-template-types-popup-active{display:-webkit-box;display:-ms-flexbox;display:flex}.jet-template-types-popup__overlay{position:absolute;left:0;right:0;top:0;bottom:0;background:rgba(0,0,0,0.8);z-index:1;-webkit-transition:opacity 200ms linear;transition:opacity 200ms linear;opacity:0;z-index:1000}.jet-template-types-popup-active .jet-template-types-popup__overlay{opacity:1}.jet-template-types-popup__content{background:#fff;padding:40px;width:500px;position:relative;z-index:2;-webkit-transition:opacity 200ms linear;transition:opacity 200ms linear;opacity:0;z-index:1001}.jet-template-types-popup-active .jet-template-types-popup__content{opacity:1}.jet-template-types-popup__heading{margin:0 0 20px}.jet-template-types-popup__form-row{padding:0 0 20px}.jet-template-types-popup__form-row label{display:block;padding:0 0 4px}.jet-template-types-popup__form-row input,.jet-template-types-popup__form-row select{width:100%;padding:10px 20px;line-height:20px;height:auto}.jet-template-types-popup__form-actions button{width:100%}.jet-template-types-popup__error{border-color:#dc3232}.jet-conditions{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.jet-conditions-active{margin-left:10px;color:#39b54a}

View File

@@ -0,0 +1,9 @@
<svg enable-background="new 0 0 483.719 483.719" version="1.1" viewBox="0 0 483.719 483.719" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor" d="m441.76 451l-153-194.43c-6.461 4.764-14.325 7.427-22.477 7.427-3.488 0-6.952-0.481-10.326-1.438l-17.934-5.081 171.96 218.53c3.993 5.072 9.917 7.715 15.902 7.715 4.38 0 8.782-1.414 12.499-4.327 8.762-6.913 10.283-19.62 3.376-28.393z"/>
<path fill="currentColor" d="m282.49 164.19l1.961 4.943 6.3 15.899 51.397-2.399c4.948-0.244 9.035-4.14 9.511-8.917 0.554-4.912-2.619-9.582-7.395-10.852l-51.615-13.836-9.511 14.207-0.648 0.955z"/>
<path fill="currentColor" d="m207.97 248.96l-1.624-0.458-4.343 3.603-13.177 10.907 19.063 50.513c1.488 3.872 5.264 6.469 9.398 6.469l2.054-0.213c4.885-1.011 8.25-5.362 7.997-10.377l-2.926-55.781-16.442-4.663z"/>
<path fill="currentColor" d="m223.62 62.903l2.208 2.817 2.59-0.165 17.061-1.091 14.366-52.222c2.915-10.599-11.341-17.028-17.354-7.826l-29.438 45.049 10.567 13.438z"/>
<path fill="currentColor" d="m102.8 206.58l-0.173-4.449-2.623-1.665-14.458-9.152-44.231 35.364c-8.574 6.856-0.844 20.421 9.425 16.536l52.69-19.93-0.63-16.704z"/>
<path fill="currentColor" d="m93.34 97.02l16.047-5.898 5.294-1.946 0.297-1.183 4.235-16.578-47.447-31.203c-9.18-6.036-19.688 5.531-12.8 14.09l34.374 42.718z"/>
<path fill="currentColor" d="m264.77 231.43c0.508 0.143 1.01 0.214 1.516 0.214 1.551 0 3.049-0.648 4.105-1.824 1.424-1.575 1.818-3.8 1.044-5.767l-25.289-63.743 38.167-56.967c1.178-1.753 1.248-4.019 0.202-5.852-0.995-1.723-2.814-2.779-4.787-2.779-0.122 0-0.253 5e-3 -0.376 0.016l-68.447 4.358-42.376-53.911c-1.075-1.348-2.683-2.116-4.379-2.116-0.376 0-0.753 0.041-1.138 0.119-2.054 0.442-3.689 2.006-4.215 4.054l-16.993 66.432-64.373 23.665c-1.985 0.726-3.376 2.517-3.599 4.619-0.234 2.093 0.762 4.136 2.542 5.268l57.94 36.694 2.602 68.527c0.081 2.109 1.349 3.988 3.273 4.85 0.728 0.326 1.503 0.483 2.257 0.483 1.281 0 2.549-0.436 3.555-1.279l52.791-43.748 65.978 18.687z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

View File

@@ -0,0 +1,988 @@
(function( $ ) {
'use strict';
var JetThemeCoreData = window.JetThemeCoreData || {},
JetThemeEditor,
JetThemeViews,
JetThemeControlsViews,
JetThemeModules;
JetThemeViews = {
LibraryLayoutView: null,
LibraryHeaderView: null,
LibraryLoadingView: null,
LibraryErrorView: null,
LibraryBodyView: null,
LibraryCollectionView: null,
FiltersCollectionView: null,
LibraryTabsCollectionView: null,
LibraryTabsItemView: null,
FiltersItemView: null,
LibraryTemplateItemView: null,
LibraryInsertTemplateBehavior: null,
LibraryTabsCollection: null,
LibraryCollection: null,
CategoriesCollection: null,
LibraryTemplateModel: null,
CategoryModel: null,
TabModel: null,
KeywordsModel: null,
KeywordsView: null,
LibraryPreviewView: null,
LibraryHeaderBack: null,
LibraryHeaderInsertButton: null,
init: function() {
var self = this;
self.LibraryTemplateModel = Backbone.Model.extend( {
defaults: {
template_id: 0,
name: '',
title: '',
thumbnail: '',
preview: '',
source: '',
categories: [],
keywords: []
}
} );
self.CategoryModel = Backbone.Model.extend( {
defaults: {
slug: '',
title: ''
}
} );
self.CategoryModel = Backbone.Model.extend( {
defaults: {
slug: '',
title: ''
}
} );
self.TabModel = Backbone.Model.extend( {
defaults: {
slug: '',
title: ''
}
} );
self.KeywordsModel = Backbone.Model.extend( {
defaults: {
keywords: {}
}
} );
self.LibraryCollection = Backbone.Collection.extend( {
model: self.LibraryTemplateModel
} );
self.CategoriesCollection = Backbone.Collection.extend( {
model: self.CategoryModel
} );
self.LibraryTabsCollection = Backbone.Collection.extend( {
model: self.TabModel
} );
self.LibraryLoadingView = Marionette.ItemView.extend( {
id: 'jet-template-library-loading',
template: '#tmpl-jet-template-library-loading'
} );
self.LibraryErrorView = Marionette.ItemView.extend( {
id: 'jet-template-library-error',
template: '#tmpl-jet-template-library-error'
} );
self.KeywordsView = Marionette.ItemView.extend( {
id: 'jet-template-library-keywords',
template: '#tmpl-jet-template-library-keywords',
ui: {
keywords: '.jet-library-keywords'
},
events: {
'change @ui.keywords': 'onSelectKeyword'
},
onSelectKeyword: function( event ) {
var selected = event.currentTarget.selectedOptions[0].value;
JetThemeEditor.setFilter( 'keyword', selected );
}
} );
self.LibraryHeaderView = Marionette.LayoutView.extend( {
id: 'jet-template-library-header',
template: '#tmpl-jet-template-library-header',
ui: {
closeModal: '#jet-template-library-header-close-modal'
},
events: {
'click @ui.closeModal': 'onCloseModalClick'
},
regions: {
headerTabs: '#jet-template-library-header-tabs',
headerActions: '#jet-template-library-header-actions'
},
onCloseModalClick: function() {
JetThemeEditor.closeModal();
}
} );
self.LibraryPreviewView = Marionette.ItemView.extend( {
template: '#tmpl-jet-template-library-preview',
id: 'jet-template-library-preview',
ui: {
img: 'img'
},
onRender: function() {
this.ui.img.attr( 'src', this.getOption( 'preview' ) );
}
} );
self.LibraryHeaderBack = Marionette.ItemView.extend( {
template: '#tmpl-jet-template-library-header-back',
id: 'jet-template-library-header-back',
ui: {
button: 'button'
},
events: {
'click @ui.button': 'onBackClick',
},
onBackClick: function() {
JetThemeEditor.setPreview( 'back' );
}
} );
self.LibraryInsertTemplateBehavior = Marionette.Behavior.extend( {
ui: {
insertButton: '.jet-template-library-template-insert'
},
events: {
'click @ui.insertButton': 'onInsertButtonClick'
},
onInsertButtonClick: function() {
var templateModel = this.view.model,
options = {};
JetThemeEditor.layout.showLoadingView();
elementor.templates.requestTemplateContent(
templateModel.get( 'source' ),
templateModel.get( 'template_id' ),
{
data: {
tab: JetThemeEditor.getTab(),
page_settings: true
},
success: function( data ) {
if ( data.licenseError ) {
JetThemeEditor.layout.showLicenseError();
return;
}
JetThemeEditor.closeModal();
elementor.channels.data.trigger( 'template:before:insert', templateModel );
if ( null !== JetThemeEditor.atIndex ) {
options.at = JetThemeEditor.atIndex;
}
elementor.sections.currentView.addChildModel( data.content, options );
if ( data.page_settings ) {
elementor.settings.page.model.set( data.page_settings );
}
elementor.channels.data.trigger( 'template:after:insert', templateModel );
JetThemeEditor.atIndex = null;
}
}
);
}
} );
self.LibraryHeaderInsertButton = Marionette.ItemView.extend( {
template: '#tmpl-jet-template-library-insert-button',
id: 'jet-template-library-insert-button',
behaviors: {
insertTemplate: {
behaviorClass: self.LibraryInsertTemplateBehavior
}
}
} );
self.LibraryTemplateItemView = Marionette.ItemView.extend( {
template: '#tmpl-jet-template-library-item',
className: function() {
var urlClass = ' jet-template-has-url',
sourceClass = ' elementor-template-library-template-';
if ( '' === this.model.get( 'preview' ) ) {
urlClass = ' jet-template-no-url';
}
if ( 'jet-local' === this.model.get( 'source' ) ) {
sourceClass += 'local';
} else {
sourceClass += 'remote';
}
return 'elementor-template-library-template' + sourceClass + urlClass;
},
ui: function() {
return {
previewButton: '.elementor-template-library-template-preview',
cloneButton: '.jet-clone-to-library',
};
},
events: function() {
return {
'click @ui.previewButton': 'onPreviewButtonClick',
'click @ui.cloneButton': 'onCloneButtonClick'
};
},
onPreviewButtonClick: function() {
if ( '' === this.model.get( 'preview' ) ) {
return;
}
JetThemeEditor.setPreview( this.model );
},
onCloneButtonClick: function() {
JetThemeEditor.layout.showLoadingView();
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_theme_core_clone_template',
template: this.model.attributes,
tab: JetThemeEditor.getTab()
}
}).done( function( response ) {
if ( true === response.success ) {
JetThemeEditor.channels.layout.trigger( 'template:cloned' );
JetThemeEditor.tabs.local.data = {};
JetThemeEditor.setTab( 'local' );
} else {
JetThemeEditor.setTab( JetThemeEditor.getTab() );
}
});
},
behaviors: {
insertTemplate: {
behaviorClass: self.LibraryInsertTemplateBehavior
}
}
} );
self.FiltersItemView = Marionette.ItemView.extend( {
template: '#tmpl-jet-template-library-filters-item',
className: function() {
return 'jet-filter-item';
},
ui: function() {
return {
filterLabels: '.jet-template-library-filter-label'
};
},
events: function() {
return {
'click @ui.filterLabels': 'onFilterClick'
};
},
onFilterClick: function( event ) {
var $clickedInput = jQuery( event.target );
JetThemeEditor.setFilter( 'category', $clickedInput.val() );
}
} );
self.LibraryTabsItemView = Marionette.ItemView.extend( {
template: '#tmpl-jet-template-library-tabs-item',
className: function() {
return 'elementor-template-library-menu-item';
},
ui: function() {
return {
tabsLabels: 'label',
tabsInput: 'input'
};
},
events: function() {
return {
'click @ui.tabsLabels': 'onTabClick'
};
},
onRender: function() {
if ( this.model.get( 'slug' ) === JetThemeEditor.getTab() ) {
this.ui.tabsInput.attr( 'checked', 'checked' );
}
},
onTabClick: function( event ) {
var $clickedInput = jQuery( event.target );
JetThemeEditor.setTab( $clickedInput.val() );
JetThemeEditor.setFilter( 'keyword', '' );
}
} );
self.LibraryCollectionView = Marionette.CompositeView.extend( {
template: '#tmpl-jet-template-library-templates',
id: 'jet-template-library-templates',
childViewContainer: '#jet-template-library-templates-container',
initialize: function() {
this.listenTo( JetThemeEditor.channels.templates, 'filter:change', this._renderChildren );
},
filter: function( childModel ) {
var filter = JetThemeEditor.getFilter( 'category' ),
keyword = JetThemeEditor.getFilter( 'keyword' );
if ( ! filter && ! keyword ) {
return true;
}
if ( keyword && ! filter ) {
return _.contains( childModel.get( 'keywords' ), keyword );
}
if ( filter && ! keyword ) {
return _.contains( childModel.get( 'categories' ), filter );
}
return _.contains( childModel.get( 'categories' ), filter ) && _.contains( childModel.get( 'keywords' ), keyword );
},
getChildView: function( childModel ) {
return self.LibraryTemplateItemView;
},
onRenderCollection: function() {
var container = this.$childViewContainer,
items = this.$childViewContainer.children(),
tab = JetThemeEditor.getTab();
if ( 'jet_page' === tab || 'local' === tab ) {
return;
}
setTimeout( function() {
self.masonry.init({
container: container,
items: items,
});
}, 200 );
}
} );
self.LibraryTabsCollectionView = Marionette.CompositeView.extend( {
template: '#tmpl-jet-template-library-tabs',
childViewContainer: '#jet-template-library-tabs-items',
initialize: function() {
this.listenTo( JetThemeEditor.channels.layout, 'tamplate:cloned', this._renderChildren );
},
getChildView: function( childModel ) {
return self.LibraryTabsItemView;
}
} );
self.FiltersCollectionView = Marionette.CompositeView.extend( {
id: 'jet-template-library-filters',
template: '#tmpl-jet-template-library-filters',
childViewContainer: '#jet-template-library-filters-container',
getChildView: function( childModel ) {
return self.FiltersItemView;
}
} );
self.LibraryBodyView = Marionette.LayoutView.extend( {
id: 'jet-template-library-content',
className: function() {
return 'library-tab-' + JetThemeEditor.getTab();
},
template: '#tmpl-jet-template-library-content',
regions: {
contentTemplates: '.jet-templates-list',
contentFilters: '.jet-filters-list',
contentKeywords: '.jet-keywords-list'
}
} );
self.LibraryLayoutView = Marionette.LayoutView.extend( {
el: '#jet-template-library-modal',
regions: JetThemeCoreData.modalRegions,
initialize: function() {
this.getRegion( 'modalHeader' ).show( new self.LibraryHeaderView() );
this.listenTo( JetThemeEditor.channels.tabs, 'filter:change', this.switchTabs );
this.listenTo( JetThemeEditor.channels.layout, 'preview:change', this.switchPreview );
},
switchTabs: function() {
this.showLoadingView();
JetThemeEditor.setFilter( 'keyword', '' );
JetThemeEditor.requestTemplates( JetThemeEditor.getTab() );
},
switchPreview: function() {
var header = this.getHeaderView(),
preview = JetThemeEditor.getPreview();
if ( 'back' === preview ) {
header.headerTabs.show( new self.LibraryTabsCollectionView( {
collection: JetThemeEditor.collections.tabs
} ) );
header.headerActions.empty();
JetThemeEditor.setTab( JetThemeEditor.getTab() );
return;
}
if ( 'initial' === preview ) {
header.headerActions.empty();
return;
}
this.getRegion( 'modalContent' ).show( new self.LibraryPreviewView( {
'preview': preview.get( 'preview' )
} ) );
header.headerTabs.show( new self.LibraryHeaderBack() );
header.headerActions.show( new self.LibraryHeaderInsertButton( {
model: preview
} ) );
},
getHeaderView: function() {
return this.getRegion( 'modalHeader' ).currentView;
},
getContentView: function() {
return this.getRegion( 'modalContent' ).currentView;
},
showLoadingView: function() {
this.modalContent.show( new self.LibraryLoadingView() );
},
showLicenseError: function() {
this.modalContent.show( new self.LibraryErrorView() );
},
showTemplatesView: function( templatesCollection, categoriesCollection, keywords ) {
this.getRegion( 'modalContent' ).show( new self.LibraryBodyView() );
var contentView = this.getContentView(),
header = this.getHeaderView(),
keywordsModel = new self.KeywordsModel( {
keywords: keywords
} );
JetThemeEditor.collections.tabs = new self.LibraryTabsCollection( JetThemeEditor.getTabs() );
header.headerTabs.show( new self.LibraryTabsCollectionView( {
collection: JetThemeEditor.collections.tabs
} ) );
contentView.contentTemplates.show( new self.LibraryCollectionView( {
collection: templatesCollection
} ) );
contentView.contentFilters.show( new self.FiltersCollectionView( {
collection: categoriesCollection
} ) );
contentView.contentKeywords.show( new self.KeywordsView( { model: keywordsModel } ) );
}
} );
},
masonry: {
self: {},
elements: {},
init: function( settings ) {
var self = this;
self.settings = $.extend( self.getDefaultSettings(), settings );
self.elements = self.getDefaultElements();
self.run();
},
getSettings: function( key ) {
if ( key ) {
return this.settings[ key ];
} else {
return this.settings;
}
},
getDefaultSettings: function() {
return {
container: null,
items: null,
columnsCount: 3,
verticalSpaceBetween: 30
};
},
getDefaultElements: function() {
return {
$container: jQuery( this.getSettings( 'container' ) ),
$items: jQuery( this.getSettings( 'items' ) )
};
},
run: function() {
var heights = [],
distanceFromTop = this.elements.$container.position().top,
settings = this.getSettings(),
columnsCount = settings.columnsCount;
distanceFromTop += parseInt( this.elements.$container.css( 'margin-top' ), 10 );
this.elements.$container.height( '' );
this.elements.$items.each( function( index ) {
var row = Math.floor( index / columnsCount ),
indexAtRow = index % columnsCount,
$item = jQuery( this ),
itemPosition = $item.position(),
itemHeight = $item[0].getBoundingClientRect().height + settings.verticalSpaceBetween;
if ( row ) {
var pullHeight = itemPosition.top - distanceFromTop - heights[ indexAtRow ];
pullHeight -= parseInt( $item.css( 'margin-top' ), 10 );
pullHeight *= -1;
$item.css( 'margin-top', pullHeight + 'px' );
heights[ indexAtRow ] += itemHeight;
} else {
heights.push( itemHeight );
}
} );
this.elements.$container.height( Math.max.apply( Math, heights ) );
}
}
};
JetThemeControlsViews = {
JetSearchView: null,
init: function() {
var self = this;
self.JetSearchView = window.elementor.modules.controls.BaseData.extend( {
onReady: function() {
var action = this.model.attributes.action,
queryParams = this.model.attributes.query_params;
this.ui.select.find( 'option' ).each(function(index, el) {
$( this ).attr( 'selected', true );
});
this.ui.select.select2( {
ajax: {
url: function() {
var query = '';
if ( queryParams.length > 0 ) {
$.each( queryParams, function( index, param ) {
if ( window.elementor.settings.page.model.attributes[ param ] ) {
query += '&' + param + '=' + window.elementor.settings.page.model.attributes[ param ];
}
});
}
return ajaxurl + '?action=' + action + query;
},
dataType: 'json'
},
placeholder: 'Please enter 3 or more characters',
minimumInputLength: 3
} );
},
onBeforeDestroy: function() {
if ( this.ui.select.data( 'select2' ) ) {
this.ui.select.select2( 'destroy' );
}
this.$el.remove();
}
} );
window.elementor.addControlView( 'jet_search', self.JetSearchView );
}
};
JetThemeModules = {
getDataToSave: function( data ) {
data.id = window.elementor.config.post_id;
return data;
},
init: function() {
if ( window.elementor.settings.jet_template ) {
window.elementor.settings.jet_template.getDataToSave = this.getDataToSave;
}
if ( window.elementor.settings.jet_page ) {
window.elementor.settings.jet_page.getDataToSave = this.getDataToSave;
window.elementor.settings.jet_page.changeCallbacks = {
custom_header: function() {
this.save( function() {
elementor.reloadPreview();
elementor.once( 'preview:loaded', function() {
elementor.getPanelView().setPage( 'jet_page_settings' );
} );
} );
},
custom_footer: function() {
this.save( function() {
elementor.reloadPreview();
elementor.once( 'preview:loaded', function() {
elementor.getPanelView().setPage( 'jet_page_settings' );
} );
} );
}
};
}
}
};
JetThemeEditor = {
modal: false,
layout: false,
collections: {},
tabs: {},
defaultTab: '',
channels: {},
atIndex: null,
init: function() {
window.elementor.on(
'preview:loaded',
window._.bind( JetThemeEditor.onPreviewLoaded, JetThemeEditor )
);
JetThemeViews.init();
JetThemeControlsViews.init();
//JetThemeModules.init();
},
onPreviewLoaded: function() {
this.initMagicButton();
window.elementor.$previewContents.on(
'click.addJetTemplate',
'.add-jet-template',
_.bind( this.showTemplatesModal, this )
);
this.channels = {
templates: Backbone.Radio.channel( 'JET_THEME_EDITOR:templates' ),
tabs: Backbone.Radio.channel( 'JET_THEME_EDITOR:tabs' ),
layout: Backbone.Radio.channel( 'JET_THEME_EDITOR:layout' ),
};
this.tabs = JetThemeCoreData.tabs;
this.defaultTab = JetThemeCoreData.defaultTab;
},
initMagicButton: function() {
var $addNewSection = window.elementor.$previewContents.find( '.elementor-add-new-section' ),
addJetTemplate = '<button class="add-jet-template" type="button">' + JetThemeCoreData.libraryButton + '</button>',
$addJetTemplate;
if ( $addNewSection.length && JetThemeCoreData.libraryButton ) {
$addJetTemplate = $( addJetTemplate ).prependTo( $addNewSection );
}
window.elementor.$previewContents.on(
'click.addJetTemplate',
'.elementor-editor-section-settings .elementor-editor-element-add',
function() {
var $this = $( this ),
$section = $this.closest( '.elementor-top-section' ),
modelID = $section.data( 'model-cid' );
if ( window.elementor.sections.currentView.collection.length ) {
$.each( window.elementor.sections.currentView.collection.models, function( index, model ) {
if ( modelID === model.cid ) {
JetThemeEditor.atIndex = index;
}
});
}
if ( JetThemeCoreData.libraryButton ) {
setTimeout( function() {
var $addNew = $section.prev( '.elementor-add-section' ).find( '.elementor-add-new-section' );
$addNew.prepend( addJetTemplate );
}, 100 );
}
}
);
},
getFilter: function( name ) {
return this.channels.templates.request( 'filter:' + name );
},
setFilter: function( name, value ) {
this.channels.templates.reply( 'filter:' + name, value );
this.channels.templates.trigger( 'filter:change' );
},
getTab: function() {
return this.channels.tabs.request( 'filter:tabs' );
},
setTab: function( value, silent ) {
this.channels.tabs.reply( 'filter:tabs', value );
if ( ! silent ) {
this.channels.tabs.trigger( 'filter:change' );
}
},
getTabs: function() {
var tabs = [];
_.each( this.tabs, function( item, slug ) {
tabs.push({
slug: slug,
title: item.title
});
} );
return tabs;
},
getPreview: function( name ) {
return this.channels.layout.request( 'preview' );
},
setPreview: function( value, silent ) {
this.channels.layout.reply( 'preview', value );
if ( ! silent ) {
this.channels.layout.trigger( 'preview:change' );
}
},
getKeywords: function() {
var keywords = [];
_.each( this.keywords, function( title, slug ) {
tabs.push({
slug: slug,
title: title
});
} );
return keywords;
},
showTemplatesModal: function() {
this.getModal().show();
if ( ! this.layout ) {
this.layout = new JetThemeViews.LibraryLayoutView();
this.layout.showLoadingView();
}
this.setTab( this.defaultTab, true );
this.requestTemplates( this.defaultTab );
this.setPreview( 'initial' );
},
requestTemplates: function( tabName ) {
var self = this,
tab = self.tabs[ tabName ];
self.setFilter( 'category', false );
if ( tab.data.templates && tab.data.categories ) {
self.layout.showTemplatesView( tab.data.templates, tab.data.categories, tab.data.keywords );
} else {
$.ajax({
url: ajaxurl,
type: 'get',
dataType: 'json',
data: {
action: 'jet_theme_get_templates',
tab: tabName,
},
success: function( response ) {
var templates = new JetThemeViews.LibraryCollection( response.data.templates ),
categories = new JetThemeViews.CategoriesCollection( response.data.categories );
self.tabs[ tabName ].data = {
templates: templates,
categories: categories,
keywords: response.data.keywords
};
self.layout.showTemplatesView( templates, categories, response.data.keywords );
}
});
}
},
closeModal: function() {
this.getModal().hide();
},
getModal: function() {
if ( ! this.modal ) {
this.modal = elementor.dialogsManager.createWidget( 'lightbox', {
id: 'jet-template-library-modal',
closeButton: false
} );
}
return this.modal;
}
};
$( window ).on( 'elementor:init', JetThemeEditor.init );
})( jQuery );

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,123 @@
(function( $, pluginsData ) {
'use strict';
var JetPluginsPage = {
init: function() {
var self = this;
$( document )
.on( 'click.JetPluginsPage', 'a[data-action="install"]', self.installPlugin )
.on( 'click.JetPluginsPage', 'a[data-action="activate"]', self.activatePlugin )
.on( 'click.JetPluginsPage', 'a[data-action="update"]', self.updatePlugin );
},
showError: function( $button, message ) {
$button.closest( '.jet-plugin' ).find( '.jet-plugin__errors' ).html( message );
},
installPlugin: function( event ) {
event.preventDefault();
var $this = $( this ),
plugin = $this.data( 'plugin' );
$this.html( pluginsData.installing );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_install_plugin',
plugin: plugin
}
}).done( function( response ) {
if ( true === response.success ) {
$this.html( pluginsData.activate );
$this.data( 'activate' );
$this.attr( 'data-action', 'activate' );
$this.closest( '.jet-plugin' ).find( '.user-version b' ).html( response.data.version );
} else {
JetPluginsPage.showError( $this, response.data.errorMessage );
$this.html( pluginsData.failed );
}
});
},
activatePlugin: function( event ) {
event.preventDefault();
var $this = $( this ),
plugin = $this.data( 'plugin' );
$this.html( pluginsData.activating );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_activate_plugin',
plugin: plugin
}
}).done( function( response ) {
if ( true === response.success ) {
$this.replaceWith( pluginsData.activated );
} else {
JetPluginsPage.showError( $this, response.data.errorMessage );
$this.html( pluginsData.failed );
}
});
},
updatePlugin: function( event ) {
event.preventDefault();
var $this = $( this ),
plugin = $this.data( 'plugin' );
$this.html( pluginsData.updating );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_update_plugin',
plugin: plugin
}
}).done( function( response ) {
if ( true === response.success ) {
$this.closest( '.jet-plugin' ).find( '.user-version b' ).html( response.data.newVersion );
$this.replaceWith( pluginsData.updated );
} else {
JetPluginsPage.showError( $this, response.data.errorMessage );
$this.html( pluginsData.failed );
}
});
}
};
JetPluginsPage.init();
})( jQuery, window.JetPluginsData );

View File

@@ -0,0 +1,39 @@
(function( $, settingsData ) {
'use strict';
var JetSettingsPage = {
init: function() {
var self = this;
$( document )
.on( 'click.JetSettingsPage', '#jet_activate_license', self.activateLicese )
.on( 'click.JetSettingsPage', '#jet_deactivate_license', self.deactivateLicese );
},
activateLicese: function() {
var $licenseInput = $( '#jet_core_license' ),
licesne = $licenseInput.val();
if ( ! licesne ) {
$licenseInput.addClass( 'jet-error' );
$( '.jet-core-license__errors' ).html( settingsData.messages.empty );
} else {
window.location = settingsData.activateUrl.replace( '%license_key%', licesne );
}
},
deactivateLicese: function() {
window.location = settingsData.deactivateUrl;
}
};
JetSettingsPage.init();
})( jQuery, window.JetSettingsData );

View File

@@ -0,0 +1,86 @@
(function( $, skinsData ) {
'use strict';
var JetSkinsPage = {
init: function() {
var self = this;
$( document )
.on( 'click.JetSkinsPage', 'a[data-action="install-wizard"]', self.installWizard )
.on( 'click.JetSkinsPage', 'a[data-action="activate-wizard"]', self.activateWizard );
},
showError: function( $button, message ) {
$button.next( '.jet-install-wizard__msg' ).html( message );
},
installWizard: function( event ) {
event.preventDefault();
var $this = $( this );
$this.html( skinsData.installing );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_install_plugins_wizard',
}
}).done( function( response ) {
if ( true === response.success ) {
$this.html( skinsData.activate );
$this.data( 'action', 'activate-wizard' );
$this.attr( 'data-action', 'activate-wizard' );
} else {
JetSkinsPage.showError( $this, response.data.errorMessage );
$this.html( skinsData.failed );
}
});
},
activateWizard: function( event ) {
event.preventDefault();
var $this = $( this );
$this.html( skinsData.activating );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_activate_plugins_wizard'
}
}).done( function( response ) {
if ( true === response.success ) {
$this.replaceWith( response.data.pageContent );
window.location.reload();
} else {
JetSkinsPage.showError( $this, response.data.errorMessage );
$this.html( skinsData.failed );
}
});
},
};
JetSkinsPage.init();
})( jQuery, window.JetSkinsData );

View File

@@ -0,0 +1,63 @@
(function( $ ) {
'use strict';
var JetTemplatesType = {
errorClass: 'jet-template-types-popup__error',
init: function() {
var self = this;
$( document )
.on( 'click.JetTemplatesType', '.page-title-action', self.openPopup )
.on( 'click.JetTemplatesType', '.jet-template-types-popup__overlay', self.closePopup )
.on( 'click.JetTemplatesType', '#templates_type_submit', self.validateForm )
.on( 'change.JetTemplatesType', '#template_type', self.changeType );
},
openPopup: function( event ) {
event.preventDefault();
$( '.jet-template-types-popup' ).addClass( 'jet-template-types-popup-active' );
},
closePopup: function() {
$( '.jet-template-types-popup' ).removeClass( 'jet-template-types-popup-active' );
},
changeType: function() {
var $this = $( this ),
value = $this.find( 'option:selected' ).val();
if ( '' !== value ) {
$this.removeClass( JetTemplatesType.errorClass );
}
},
validateForm: function() {
var $this = $( this ),
$form = $this.closest( '#templates_type_form' ),
$type = $form.find( '#template_type' ),
$name = $form.find( '#template_name' ),
type = $type.find( 'option:selected' ).val();
$type.removeClass( JetTemplatesType.errorClass );
if ( '' !== type ) {
$form.submit();
} else {
$type.addClass( JetTemplatesType.errorClass );
}
}
};
JetTemplatesType.init();
})( jQuery );

View File

@@ -0,0 +1 @@
!function(e){"use strict";var t={errorClass:"jet-template-types-popup__error",init:function(){e(document).on("click.JetTemplatesType",".page-title-action",this.openPopup).on("click.JetTemplatesType",".jet-template-types-popup__overlay",this.closePopup).on("click.JetTemplatesType","#templates_type_submit",this.validateForm).on("change.JetTemplatesType","#template_type",this.changeType)},openPopup:function(t){t.preventDefault(),e(".jet-template-types-popup").addClass("jet-template-types-popup-active")},closePopup:function(){e(".jet-template-types-popup").removeClass("jet-template-types-popup-active")},changeType:function(){var p=e(this);""!==p.find("option:selected").val()&&p.removeClass(t.errorClass)},validateForm:function(){var p=e(this).closest("#templates_type_form"),s=p.find("#template_type"),a=(p.find("#template_name"),s.find("option:selected").val());s.removeClass(t.errorClass),""!==a?p.submit():s.addClass(t.errorClass)}};t.init()}(jQuery);

View File

@@ -0,0 +1,159 @@
(function( $, themeData ) {
'use strict';
var JetThemePage = {
xhr: null,
init: function() {
var self = this;
$( document )
.on( 'click.JetThemePage', 'a[data-action="update-theme"]', self.updateTheme )
.on( 'click.JetThemePage', 'button[data-action="install-child"]', self.installChild )
.on( 'click.JetThemePage', '.jet-backup-delete', self.confirmDelete )
.on( 'click.JetThemePage', 'button[data-action="activate-child"]', self.activateChild );
$( window ).on( 'cx-switcher-change', self.updateBackupsSetting );
},
confirmDelete: function( event ) {
event.preventDefault();
var $this = $( this );
if ( confirm( 'Are you sure you want to delete this file?' ) ) {
window.location = $this.attr( 'href' );
}
},
updateBackupsSetting: function( event ) {
var controlName = event.controlName,
controlStatus = event.controlStatus;
if ( 'jet_core_auto_backup' !== controlName ) {
return;
}
if ( null !== JetThemePage.xhr ) {
JetThemePage.xhr.abort();
}
JetThemePage.xhr = $.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_update_backup_status',
new_value: controlStatus,
}
}).done( function( response ) {
JetThemePage.xhr = null;
});
},
updateTheme: function( event ) {
event.preventDefault();
var $this = $( this );
$this.html( themeData.updating );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_update_theme'
}
}).done( function( response ) {
if ( true === response.success ) {
$( '.jet-theme__update-notice' ).remove();
$( '.jet-theme__version-val' ).html( response.data.newVersion );
} else {
$this.replaceWith( themeData.failed );
$( '.jet-theme__errors' ).html( response.data.errorMessage );
}
if ( response.data.backupsList ) {
$( '.jet-backups-wrap' ).html( response.data.backupsList );
}
});
},
installChild: function( event ) {
event.preventDefault();
var $this = $( this );
$this.html( themeData.installing );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_install_child_theme'
}
}).done( function( response ) {
if ( true === response.success ) {
$this.html( themeData.activate );
$this.data( 'action', 'activate-child' );
$this.attr( 'data-action', 'activate-child' );
$this.data( 'theme', response.data.theme );
$( '.jet-child-theme__status span' ).html( themeData.installed );
} else {
$this.replaceWith( themeData.failed );
$( '.jet-child-theme__errors' ).html( response.data.errorMessage );
}
});
},
activateChild: function( event ) {
event.preventDefault();
var $this = $( this );
$this.html( themeData.activating );
$.ajax({
url: ajaxurl,
type: 'post',
dataType: 'json',
data: {
action: 'jet_core_activate_child_theme'
}
}).done( function( response ) {
if ( true === response.success ) {
$this.remove();
$( '.jet-child-theme__status span' ).html( themeData.activated );
} else {
$this.replaceWith( themeData.failed );
$( '.jet-child-theme__errors' ).html( response.data.errorMessage );
}
});
}
};
JetThemePage.init();
})( jQuery, window.JetThemeData );

View File

@@ -0,0 +1,25 @@
// Editor colors
$editor-darkest:#495157;
$editor-darker: #556068;
$editor-dark: #6d7882;
$editor-light: #a4afb7;
$editor-lighter: #c2cbd2;
$editor-lightest: #d5dadf;
$editor-accent: #9b0a46;
$editor-background: #e6e9ec;
$editor-background-light: #f1f3f5;
$editor-orange: #fcb92c;
$editor-danger: #f00;
$editor-warning: #b01b1b;
$editor-success: #39b54a;
$editor-info: #71d7f7;
// Panel style
$panel-top-shadow: -2px -5px 8px rgba(0, 0, 0, 0.1);
$panel-bottom-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
$ui_success_color: #3ba956;

View File

@@ -0,0 +1,354 @@
@import "variables";
$link-color: #298ffc;
$text-color: #23282d;
.jet-core-dashboard {
.cx-tab.cx-tab--vertical {
padding: 0;
> .cx-tab__body {
.cx-tab__button {
color: $text-color;
display: block;
box-sizing: border-box;
order: 0;
flex: 0 1 100%;
align-self: auto;
padding: 8px 15px;
border: 0;
background: none;
cursor: pointer;
position: relative;
text-align: left;
transition: all 150ms linear;
display: flex;
align-items: center;
outline: none;
border: none;
box-shadow: none;
&.active{
&:after {
display: none;
}
}
.cx-tab__title {
font-weight: 600;
font-size: 14px;
line-height: 19px;
margin: 0;
transition: all 150ms linear;
}
.cx-tab__icon {
transition: all 150ms linear;
margin: 0 10px 0 0;
color: #c4ccd7;
}
& + .cx-tab__button {
&:before {
display: none;
}
}
}
.cx-tab__button:hover,
.cx-tab__button.active {
background: #f6f7f9;
.cx-tab__icon,
.cx-tab__title {
color: $link-color;
}
}
> .cx-tab__tabs {
flex: 0 1 12%;
padding: 20px;
}
> .cx-tab__content {
flex: 0 1 88%;
padding: 20px;
.cx-component {
padding: 0;
}
}
}
}
.jet-core-license {
&__form {
display: flex;
align-items: center;
padding: 15px 0;
}
&__input {
min-width: 250px;
margin: 0 10px 0 0;
outline: none;
}
&__status {
font-weight: bold;
&.status-success {
color: $ui_success_color;
}
}
label {
padding: 10px 0 5px;
display: block;
font-weight: bold;
}
}
.cx-button {
outline: none;
}
.cx-button-success-style:hover,
.cx-button-primary-style:hover {
color: #fff;
}
.jet-plugins-actions {
padding: 0 0 25px;
.cx-button {
margin: 0 10px 0 0;
}
}
.jet-plugin {
display: flex;
align-items: flex-start;
padding: 25px 0;
border-top: 1px solid rgba( 0, 0, 0, 0.1 );
&:last-child {
padding-bottom: 10px;
}
&.jet-core {
border-top: none;
padding-top: 0;
}
&__thumb {
display: block;
margin-right: 20px;
}
&__title {
margin: 0 0 5px;
font-size: 16px;
color: $text-color;
font-weight: 500;
}
&__version {
color: $text-color;
b {
font-weight: normal;
}
}
&__actions {
padding: 5px 0 0 0;
a + a {
margin: 0 0 0 15px;
}
}
&__errors {
color: red;
}
}
.jet-theme {
padding: 0 0 25px;
border-bottom: 1px solid rgba( 0, 0, 0, .1 );
margin: 0 0 20px;
max-width: 600px;
&__content {
display: flex;
flex-wrap: wrap;
}
&__thumb {
width: 600px;
height: auto;
display: block;
border: 1px solid rgba( 0, 0, 0, .1 );
margin: 0 0 25px;
}
&__name {
font-size: 16px;
font-weight: 500;
margin: 0 0 15px;
flex: 0 0 100%;
max-width: 100%;
}
&__status {
margin: 0 8px 0 0;
}
&__version {
display: flex;
&-val {
margin: 0 8px 0 0;
}
}
}
.jet-child-theme {
padding: 0 0 25px;
border-bottom: 1px solid rgba( 0, 0, 0, .1 );
max-width: 600px;
&__name {
font-size: 16px;
font-weight: 500;
margin: 0 0 15px;
}
}
.cx-control {
padding: 25px 0 20px;
}
.tab-theme {
.cx-control {
max-width: 600px;
.cx-control__info {
flex: 0 1 70%;
}
.cx-control__content {
flex: 0 1 30%;
overflow: hidden;
.cx-ui-container {
float: right;
}
}
}
}
.jet_core_create_backup {
padding: 30px 0 0 0;
}
.jet-backups {
padding: 15px 0 0 0;
max-width: 600px;
table {
border-collapse: collapse;
tr {
padding: 0;
margin: 0;
}
thead {
th {
padding: 4px 10px;
font-weight: 500;
font-size: 13px;
line-height: 20px;
text-align: left;
}
}
tbody {
td {
padding: 4px 10px;
font-size: 13px;
line-height: 20px;
}
tr:nth-child(odd) {
background: #f6f7f9;
}
}
}
.jet-backups-file {
width: 190px;
}
.jet-backups-date {
width: 220px;
}
.jet-backups-actions {
width: 170px;
a + a {
margin: 0 0 0 10px;
}
}
}
.jet-skins-actions {
padding: 0 0 10px 0;
a + a {
margin: 0 0 0 10px;
}
}
.jet-skins {
display: flex;
flex-wrap: wrap;
margin: 0 -10px;
}
.jet-skin {
padding: 10px;
flex: 0 0 290px;
max-width: 290px;
&__wrap {
border: 1px solid rgba( 0, 0, 0, .1 );
padding: 20px;
}
&__thumb {
display: block;
&-img {
display: block;
width: 100%;
height: auto;
}
}
&__title {
margin: 10px 0 15px;
font-size: 16px;
font-weight: 500;
}
&__actions {
display: flex;
justify-content: space-between;
.cx-button {
width: 70px;
text-align: center;
}
}
}
.jet-guide-title {
font-size: 16px;
font-weight: 500;
margin: 0 0 15px;
}
.jet-guide-content {
margin: 0 0 30px;
}
.jet-guide-links {
&__item {
border-top: 1px solid rgba( 0, 0, 0, .1 );
padding: 12px 0;
display: flex;
align-items: center;
justify-content: space-between;
max-width: 600px;
&:first-child {
border-top: none;
}
&:last-child {
padding-bottom: 0;
}
&-link {
width: 160px;
text-align: center;
padding-left: 0;
padding-right: 0;
}
&-desc {
display: flex;
align-items: center;
.dashicons {
margin: 0 10px 0 0;
opacity: .2;
}
}
}
}
}
.jet-install-wizard {
&__content {
padding: 0 0 20px;
}
}

View File

@@ -0,0 +1,4 @@
@import 'variables';
@import 'modules/templates-modal';
@import 'modules/templates-tabs';
@import 'modules/templates-filters';

View File

@@ -0,0 +1,203 @@
#jet-template-library-content {
display: flex;
height: calc( 100% - 20px );
.jet-filters-list {
width: 15%;
padding: 25px 10px 10px;
height: 100%;
overflow: auto;
}
.jet-templates-wrap {
width: 85%;
}
.jet-templates-list {
height: 100%;
overflow: auto;
}
.jet-keywords-list {
padding-left: 10px;
}
.jet-template-library-filter-label {
display: block;
position: relative;
text-align: left;
padding: 12px 0;
text-transform: uppercase;
input[type="radio"] {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: 0;
opacity: 0;
display: block;
width: 100%;
height: 100%;
}
&:hover span,
input:checked + span {
color: $editor-accent;
}
}
.jet-filter-item {
border-top: 1px solid #d5dadf;
&:first-child {
border-top: none;
}
}
&.library-tab-local {
.jet-filters-list {
display: none;
}
.jet-templates-wrap {
width: 100%;
}
.jet-template-library-template-insert {
padding: 5px 12px;
i {
margin-right: 2px;
}
span {
font-size: 11px;
}
}
.elementor-template-library-template-controls {
width: 120px;
}
.elementor-template-library-template-name {
width: 200px;
}
}
}
#jet-template-library-templates-container {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
.elementor-template-library-template {
position: relative;
}
.elementor-template-library-template-remote {
width: calc( 33.3333% - 30px );
margin: 15px;
}
#jet-template-library-content:not(.library-tab-local) & {
.elementor-template-library-template-controls {
position: absolute;
left: 0;
bottom: 0;
right: 0;
display: flex;
justify-content: space-between;
padding: 0 10px 9px 8px;
z-index: 10;
}
.jet-template-library-template-insert {
padding: 0;
margin: 0;
color: $editor-success;
background: none;
width: auto;
text-transform: none;
font-size: 12px;
&:hover {
box-shadow: none;
color: darken( $editor-success, 15% );
}
}
.elementor-template-library-template-name {
padding: 5px 0 0 0;
display: block !important;
}
.elementor-template-library-template-name-holder {
height: 23px;
}
.template-library-activate-license {
display: none;
color: $editor-orange;
font-size: 12px;
&:hover {
color: darken( $editor-orange, 15% );
}
}
.jet-clone-to-library {
background: none;
border: none;
padding: 0;
margin: 0;
color: $editor-accent;
cursor: pointer;
display: none;
font-size: 12px;
box-shadow: none;
outline: none;
font-weight: bold;
i {
margin: 0 2px 0 0;
font-size: 12px;
font-weight: normal;
}
&:hover {
color: darken( $editor-accent, 15% );
}
}
.elementor-template-library-template:hover {
.elementor-template-library-template-name {
opacity: 0;
}
}
}
.library-tab-jet_page & {
.elementor-template-library-template-remote {
width: calc( 25% - 20px );
margin: 10px;
&
.elementor-template-library-template-preview {
}
.elementor-template-library-template-action {
padding: 8px;
}
}
}
.jet-template-no-url {
.elementor-template-library-template-preview {
cursor: default !important;
opacity: 0 !important;
}
.fa-search-plus {
display: none !important;
}
}
.elementor-template-library-template:hover {
.jet-clone-to-library {
display: block !important;
}
.template-library-activate-license {
display: block !important;
}
}
}
.elementor-template-library-template-screenshot {
img {
width: 100%;
max-width: 100%;
height: auto;
display: block;
}
}
#jet-template-library-preview {
img {
width: 100%;
max-width: 100%;
height: auto;
}
}

View File

@@ -0,0 +1,184 @@
#jet-template-library-modal {
.dialog-widget-content {
width: 90%;
max-width: 1200px;
background-color: $editor-background-light;
}
.dialog-widget-header,
.dialog-header {
padding: 0;
background-color: #fff;
box-shadow: $panel-bottom-shadow;
position: relative; // Show the shadow above the scrolled list
z-index: 1;
}
.dialog-buttons-wrapper {
display: none;
}
.dialog-message {
height: 630px;
max-height: 85vh;
overflow: auto;
padding: 15px;
}
a {
&,
&:hover {
color: inherit;
}
}
a.elementor-template-library-blank-footer-link {
transition: color .5s;
&:hover {
color: $editor-accent;
}
}
.elementor-button {
text-transform: uppercase;
}
::-webkit-scrollbar {
width: 6px;
height: 0;
border-radius: 3px;
}
::-webkit-scrollbar-button {
width: 0px;
height: 10px;
}
::-webkit-scrollbar-thumb {
background-color: #d5dadf;
border: 0px none #d5dadf;
border-radius: 0;
border-radius: 3px;
}
::-webkit-scrollbar-track {
border: 0px none #fff;
border-radius: 0;
}
::-webkit-scrollbar-corner {
background: transparent;
}
}
#jet-template-library-header {
display: flex;
justify-content: space-between;
.jet-template-library-back {
background: none;
border: none;
border-right: 1px solid $editor-background;
padding: 15px 20px 15px 15px;
line-height: 20px;
font-size: 13px;
font-weight: bold;
outline: none;
transition: all 200ms linear;
cursor: pointer;
color: $editor-dark;
&:not(:hover) {
color: $editor-light;
}
}
.elementor-button {
padding: 8px 10px;
margin: 9px 10px 0 0;
}
}
#jet-template-library-header-close-modal {
width: 45px;
border-left: 1px solid $editor-background;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 200ms linear;
i {
color: $editor-light;
font-size: 16px;
}
&:hover {
i {
color: $editor-dark;
}
}
}
#jet-template-library-header-actions {
.template-library-activate-license {
display: block;
margin: 17px 20px 0 0;
color: $editor-orange;
&:hover {
color: darken( $editor-orange, 15% );
}
}
}
#jet-template-library-modal {
.elementor-loader {
position: relative;
.elementor-loader-box:first-of-type {
left: 40px;
top: 40px;
width: 14px;
height: 70px;
}
.elementor-loader-box:not(:first-of-type) {
right: 40px;
height: 14px;
width: 42px;
}
.elementor-loader-box:nth-of-type(2) {
top: 40px;
}
.elementor-loader-box:nth-of-type(3) {
top: 68px;
}
.elementor-loader-box:nth-of-type(4) {
bottom: 40px;
}
}
.elementor-library-error {
margin: 18% 0 0 0;
&-message {
font-size: 18px;
padding: 0 0 20px;
}
&-link {
a {
display: inline-block;
color: #fff;
background-image: none;
background: $editor-orange;
font-size: 13px;
font-weight: normal;
font-style: normal;
text-transform: uppercase;
line-height: 1;
height: 40px;
line-height: 40px;
min-width: 170px;
padding: 0 20px;
border: none;
border-radius: 3px;
cursor: pointer;
-webkit-transition: all 0.5s;
transition: all 0.5s;
&:hover {
opacity: 0.85;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.12), 0 2px 2px rgba(0, 0, 0, 0.2);
}
}
}
}
}

View File

@@ -0,0 +1,41 @@
#jet-template-library-header {
min-height: 52px;
}
#jet-template-library-tabs-items {
.elementor-template-library-menu-item {
display: inline-block;
position: relative;
text-align: left;
padding: 0;
width: auto;
font-size: 13px;
color: $editor-dark;
input[type="radio"] {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: 0;
opacity: 0;
display: block;
width: 100%;
height: 100%;
}
span {
display: block;
padding: 20px 19px 16px 19px;
border-bottom: 3px solid transparent;
}
&:hover span,
input:checked + span {
background: #fafafa;
border-bottom: 3px solid $editor-accent;
}
}
}
#jet-template-library-header-tabs {
flex: 1 1 auto;
text-align: left;
}

View File

@@ -0,0 +1,76 @@
@import 'variables';
.jet-location-edit {
position: relative;
&__link {
position: absolute;
opacity: 0;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: center;
align-items: center;
transition: opacity 200ms linear;
border: 4px solid $editor-info;
background: rgba( red( $editor-info ), green( $editor-info ), blue( $editor-info ), .2 );
color: #fff;
z-index: 99999;
cursor: pointer;
font-weight: 400;
font-size: 16px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
&-content {
display: flex;
justify-content: center;
align-items: center;
background-image: linear-gradient(to bottom, darken($editor-info, 10%), $editor-info);
padding: 4px 15px 6px 10px;
}
.dashicons {
margin-right: 4px;
}
}
&:hover .jet-location-edit__link {
color: #fff;
opacity: 1;
text-decoration: none;
}
}
.elementor-add-new-section {
.add-jet-template {
color: #fff;
background-image: none;
background: #398ffc !important;
font-size: 13px;
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
font-style: normal;
text-transform: uppercase;
line-height: 1;
height: 40px;
min-width: 170px;
padding: 0 20px;
border: none;
-webkit-border-radius: 3px;
border-radius: 3px;
cursor: pointer;
margin-right: 25px;
transition: all 0.5s;
display: inline-flex;
align-items: center;
vertical-align: bottom;
svg {
width: 17px;
margin: -2px 9px 0px -3px;
}
&:hover {
opacity: 0.85;
box-shadow: 0 0 2px rgba(0, 0, 0, 0.12), 0 2px 2px rgba(0, 0, 0, 0.2);
}
}
}

View File

@@ -0,0 +1,80 @@
@import 'variables';
.jet-template-types-popup {
display: none;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
&.jet-template-types-popup-active {
display: flex;
}
&__overlay {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background: rgba( 0, 0, 0, .8 );
z-index: 1;
transition: opacity 200ms linear;
opacity: 0;
z-index: 1000;
.jet-template-types-popup-active & {
opacity: 1;
}
}
&__content {
background: #fff;
padding: 40px;
width: 500px;
position: relative;
z-index: 2;
transition: opacity 200ms linear;
opacity: 0;
z-index: 1001;
.jet-template-types-popup-active & {
opacity: 1;
}
}
&__heading {
margin: 0 0 20px;
}
&__form {
&-row {
padding: 0 0 20px;
label {
display: block;
padding: 0 0 4px;
}
input,
select {
width: 100%;
padding: 10px 20px;
line-height: 20px;
height: auto;
}
}
&-actions {
button {
width: 100%;
}
}
}
&__error {
border-color: #dc3232;
}
}
.jet-conditions {
display: flex;
align-items: center;
&-active {
margin-left: 10px;
color: $editor-success;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,212 @@
@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;
}
}
}
@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 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%);
}
}
@mixin input() {
font-size: 12px;
line-height: 16px;
color: $dark_color;
background-color: $bg_color;
border-radius: $border_radius_extra_small;
padding: 5px;
min-height: 28px;
border: 1px solid $border_color;
box-shadow: none;
&:focus{
border-color: darken( $border_color, 20% );
box-shadow: none;
}
}
@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_small;
}
@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,17 @@
.cx-ui-kit{
button{
*{
pointer-events: none;
}
}
}
.cx-component{
&__content{
.cx-settings__content{
display: none;
&.show{
display: inherit;
}
}
}
}

View File

@@ -0,0 +1,86 @@
$bg_color: #f1f1f1;
$border_color: #dcdcdc;
$bg_color_2: #e5e5e5;
$primary_color: #2a90fc;
$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: #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;
$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);
$light_color: #ffffff;
$dark_color: #23282d;
$switcher_bg_color: #f1f1f1;
$switcher_border_color: #dcdcdc;
$true_state_gradint_1: #71e18f;
$true_state_gradint_2: #49c66a;
$true_state_outset_1: #43b05f;
$true_state_outset_2: #3b9b54;
$false_state_gradint_1: #f98888;
$false_state_gradint_2: #e64545;
$false_state_outset_1: #e54545;
$false_state_outset_2: #c13b3b;

View File

@@ -0,0 +1,63 @@
.cx-button{
@include button_base();
&.cx-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%);
}
}
&.cx-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%);
}
}
&.cx-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%);
}
}
&.cx-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%);
}
}
&.cx-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%);
}
}
&.cx-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,55 @@
.cx-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;
}
}
}
.cx-label-content {
display: flex;
}
.cx-checkbox-input{
&[checked]{
&+.cx-checkbox-item{
background-color: $green_color;
.marker{
transform: scale(1);
}
}
}
}
.cx-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,50 @@
$font_size: 14px;
.cx-ui-colorpicker-wrapper {
.wp-picker-container {
padding: 3px;
border-radius: 3px;
.wp-color-result-text {
line-height: 18px;
text-align: right;
display: none;
}
.wp-color-result {
width: 60px;
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,105 @@
.cx-ui-container{
margin: 10px 0 20px 0;
}
label.cx-label{
margin: 0 0 5px 0;
display: block;
}
.cx-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,325 @@
.cx-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;
}
}
.cx-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,141 @@
.cx-ui-media-wrap {
.cx-upload-preview {
display: block;
margin: 0 0 5px 0;
.cx-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;
}
.cx-remove-image {
display: block;
}
}
}
.cx-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;
}
.cx-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% );
}
}
.cx-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,91 @@
input.cx-radio-input{
display: none;
}
.cx-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.cx-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);
}
}
}
.cx-radio-item {
.cx-radio-input:checked{
& + label{
span{
i{
transform: scale(1);
}
}
}
}
}
.cx-radio-img {
float: left;
margin: 10px 5px 0 5px;
text-align: center;
max-width: 60px;
font-size: 12px;
position: relative;
.cx-lable-content {
display: flex;
flex-flow: column;
}
label{
display: inline-block;
}
img {
width: 100%;
height: auto;
margin: 0 0 5px 0;
pointer-events: none;
}
}
.cx-radio-img{
.cx-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;
}
}
}
}

View File

@@ -0,0 +1,140 @@
.cx-ui-repeater-container {
label.cx-label{
margin: 0 0 5px 0;
display: block;
}
}
.cx-ui-repeater {
&-add {
@include link();
@include link_icon_before( '\f132' );
}
&-item {
padding: 10px 10px 10px 30px;
position: relative;
}
&-remove {
position: absolute;
width: 20px;
height: 20px;
right: 18px;
top: 13px;
border-radius: 50%;
border: 1px solid currentColor;
color: red;
font-size: 18px;
line-height: 20px;
text-align: center;
cursor: pointer;
&:before {
content: "\00D7";
}
&:hover {
color: black;
}
}
}
.cx-ui-kit {
&.cx-ui-repeater-container {
@include container();
}
> label.cx-label {
@include container_heading();
}
.cx-ui-repeater {
&-item {
@include box();
}
&-actions-box {
@include box_heading();
padding: 15px 20px;
cursor: move;
position: relative;
text-align: center;
min-height: 18px;
}
&-toggle {
position: absolute;
color: $grey_color_4;
width: 20px;
height: 20px;
font-size: 22px;
line-height: 20px;
text-align: center;
vertical-align: middle;
cursor: pointer;
text-decoration: none;
box-shadow: none;
outline: none;
top: 13px;
left: 18px;
&:before {
content: "\f142";
transition: all 200ms linear;
font-family: dashicons;
vertical-align: middle;
}
&:hover {
color: $dark_color_1;
}
}
&-remove {
position: absolute;
border: none;
color: $grey_color_4;
font-size: 20px;
line-height: 20px;
width: 20px;
height: 20px;
text-align: center;
vertical-align: middle;
text-decoration: none;
box-shadow: none;
outline: none;
top: 13px;
right: 18px;
&:before {
content: "\f158";
transition: all 200ms linear;
font-family: dashicons;
vertical-align: middle;
}
&:hover {
color: $dark_color_1;
}
}
&-title{
width: 70%;
overflow: hidden;
text-overflow: ellipsis;
display: inline-block;
font-size: 14px;
}
&-add {
&:focus {
outline: none;
box-shadow: none;
}
}
}
.cx-ui-repeater-min {
padding-bottom: 0;
> .cheryr-ui-repeater-content-box {
display: none;
}
> .cx-ui-repeater-actions-box {
margin-bottom: 0;
border-bottom: none;
background: none;
.cx-ui-repeater-toggle {
&:before {
content: "\f140";
}
}
}
}
}

View File

@@ -0,0 +1,134 @@
select.cx-ui-select{
width: 100%;
outline: 0 none;
@include input();
&:focus{
box-shadow: none;
}
}
select.select2-hidden-accessible{
display: none;
}
.cx-ui-select-wrapper {
.select2{
color: $dark_color;
background-color: white;
border-radius: $border_radius_extra_small;
border: 1px solid $border_color;
.selection{
.select2-selection{
&.select2-selection--single{
background-color: transparent;
border: none;
border-radius: $border_radius_extra_small;
height: 28px;
.select2-selection__rendered{
padding: 5px;
font-size: 12px;
line-height: 18px;
}
.select2-selection__arrow{
height: 24px;
}
}
&.select2-selection--multiple{
background-color: transparent;
border: none;
border-radius: $border_radius_extra_small;
min-height: 25px;
.select2-selection__rendered{
font-size: 12px;
line-height: 14px;
padding: 0;
display: block;
&:focus {
outline: none;
}
.select2-selection__choice{
line-height: 14px;
margin: 2px;
border: none;
background-color: #e4e4e4;
border-radius: $border_radius_extra_small;
color: darken( $dark_color, 50% );
padding: 4px;
.select2-selection__choice__remove{
color: $remove_color;
margin-right: 5px;
font-size: 14px;
}
}
.select2-selection__clear{
}
.select2-search{
margin: 0;
.select2-search__field{
padding: 0;
border: none;
box-shadow: none;
line-height: 19px;
}
}
}
}
}
}
}
.select2-container{
.select2-dropdown{
background-color: white;
border: 1px solid $border_color;
border-radius: $border_radius_extra_small;
box-shadow: 0px 5px 21px rgba(0,0,0,0.1);
margin-top: 1px;
z-index: 500001;
.select2-search__field{
border: 1px solid $border_color;
box-shadow: none;
border-radius: $border_radius_extra_small;
margin: 0;
height: 25px;
&:focus{
outline: none;
}
}
.select2-results {
.select2-results__options{
.select2-results__option{
&[aria-selected=true]{
color: darken( $dark_color, 50% );
background-color: $dark_color;
}
&--highlighted{
color: #fff;
background-color: $primary_color;
}
}
.li[aria-disabled=true]{
display: none;
}
}
}
}
}
}

View File

@@ -0,0 +1,106 @@
.cx-slider-wrap{
display: flex;
flex-wrap: wrap;
.cx-slider-input{
flex: 0 1 10%;
min-width: 100px;
max-width: 200px;
}
.cx-slider-holder{
flex: 0 1 90%;
min-width: 200px;
max-width: 300px;
margin-right: 10px;
input[type=range] {
-webkit-appearance: none;
width: 100%;
margin: 10px 0;
}
input[type=range]:focus {
outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 5px;
cursor: pointer;
box-shadow: none;
background: #a4afb7;
border-radius: 25px;
border: none;
}
input[type=range]::-webkit-slider-thumb {
box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.3);
height: 16px;
width: 16px;
margin-top: -6px;
border-radius: 15px;
background: white;
cursor: pointer;
-webkit-appearance: none;
transition: all 250ms cubic-bezier(0.645, 0.045, 0.355, 1);
}
input[type=range]:focus::-webkit-slider-runnable-track {
background: #a4afb7;
}
input[type=range]::-moz-range-track {
width: 100%;
height: 5px;
cursor: pointer;
box-shadow: none;
background: #a4afb7;
border-radius: 25px;
border: none;
}
input[type=range]::-moz-range-thumb {
box-shadow: none;
border: none;
height: 16px;
width: 16px;
border-radius: 15px;
background: #a4afb7;
cursor: pointer;
}
input[type=range]::-ms-track {
width: 100%;
height: 10px;
cursor: pointer;
background: $grey_color_3;
border-color: transparent;
color: transparent;
}
input[type=range]::-ms-fill-lower {
background: $grey_color_3;
border: none;
border-radius: 50px;
box-shadow: none;
}
input[type=range]::-ms-fill-upper {
background: $green_color;
border: none;
border-radius: 50px;
box-shadow: none;
}
input[type=range]::-ms-thumb {
box-shadow: none;
border: none;
height: 10px;
width: 10px;
border-radius: 15px;
background: #495159;
cursor: pointer;
}
input[type=range]:focus::-ms-fill-lower {
background: $grey_color_3;
}
input[type=range]:focus::-ms-fill-upper {
background: $green_color;
}
}
.cx-input{
margin: 0;
width: 100%;
}
}

View File

@@ -0,0 +1,13 @@
.cx-ui-stepper{
position: relative;
max-width: 100px;
input[type=number]{
@include input();
}
}
.cx-ui-stepper-input{
min-width: 70px;
max-width: 70px;
text-align: left;
}

View File

@@ -0,0 +1,110 @@
.cx-switcher-wrap {
width: 54px;
height: 20px;
position: relative;
cursor: pointer;
user-select: none;
background-color: white;
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
transform: translateZ(0);
.bg-cover {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #eceeef;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 0 2px rgba(0, 0, 0, 0.15);
pointer-events: none;
border-radius: 25px;
content: '';
z-index: 1;
transition: all 0.4s ease;
transform: translateZ(0);
}
label {
display: block;
z-index: 2;
span {
font-size: 7px;
line-height: 12px;
text-transform: uppercase;
color: #a4afb7;
text-align: center;
display: block;
opacity: 1;
transition: all 0.4s ease;
}
}
.sw-enable {
padding: 4px 4px 5px 12px;
span {
opacity: 0;
}
}
.sw-disable {
padding: 4px 12px 5px 4px;
span {
opacity: 1;
}
}
.state-marker {
background-color: white;
display: block;
position: absolute;
width: 18px;
height: 18px;
margin: 1px;
top: 0;
left: 0;
border-radius: 50%;
transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1);
box-sizing: border-box;
z-index: 3;
}
.cx-input-switcher {
display: none;
}
.cx-input-switcher-true:checked {
~ .sw-enable{
span{
opacity: 1;
color: white;
text-shadow: 0 1px rgba(0, 0, 0, 0.2);
}
}
~ .sw-disable{
span{
opacity: 0;
}
}
~ .state-marker {
left: 100%;
margin-left: -19px;
}
~ .bg-cover {
background-color: #49c66a;
}
}
}

View File

@@ -0,0 +1,3 @@
input.cx-ui-text{
@include input();
}

View File

@@ -0,0 +1,5 @@
textarea.cx-ui-textarea{
width: 100%;
@include input();
height: 100px;
}

View File

@@ -0,0 +1,548 @@
$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: 0px 5px 21px rgba(0, 0, 0, 0.1); //Shadow.
$border: 1px solid rgba(0, 0, 0, 0.1) ;
$br-radius: 5px; // Border radius.
$padding: 5px;
$margin: 10px;
$max-height: 700px;
@import "components/use-in-js";
@import "components/variables";
@import "components/mixins";
@import "controls/button";
@import "controls/checkbox";
@import "controls/colorpicker";
@import "controls/iconpicker";
@import "controls/media";
@import "controls/radio";
@import "controls/repeater";
@import "controls/select";
@import "controls/slider";
@import "controls/stepper";
@import "controls/switcher";
@import "controls/text";
@import "controls/textarea";
@import "controls/dimensions";
.cherry-ui-container{
margin: 10px 0 20px 0
}
label.cherry-label{
margin: 0 0 5px 0;
display: block;
}
.hide{
display: none !important;
}
.cx-ui-kit{
font-size: 13px;
h1{
font-weight: 700;
line-height: 1.2em;
margin: 0;
.dashicons{
font-size: 3em;
line-height: inherit;
width: 20px;
margin: 0 $margin * 2 0 $margin * -0.5;
}
}
h2{
font-weight: 600;
font-size: 1.538em;
line-height: 1.538em;
.dashicons{
font-size: 2em;
line-height: inherit;
width: 20px;
margin-right: $margin * 2;
}
}
h3{
font-weight: 600;
font-size: 1.231em;
line-height: 1.231em;
.dashicons{
font-size: 1.7em;
line-height: inherit;
margin-right: $margin * 0.5;
}
}
h4{
font-weight: 500;
font-size: 1.077em;
line-height: 1.077em;
}
h5{
font-weight: 500;
font-size: 1.077em;
line-height: 1.077em;
}
h6{
font-weight: 400;
font-size: 1em;
line-height: 1em;
}
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.9em;
color: $color-3;
margin: $margin 0;
}
&__title{
margin: $margin*2 0;
}
&.hide{
display: none;
}
}
.cx-control + .cx-control, .cx-settings + .cx-control{
border-top: $border;
}
.cx-section{
padding: $padding;
background-color: $color-1;
margin-left: -10px;
&__title, &__description{
margin: $margin 0 0 0;
}
& + .cx-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;
}
.cx-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;
}
.cx-settings{
margin-top: $padding * 3;
}
}
}
.cx-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{
.cx-settings{
padding: 0;
border-top: none;
}
}
&__button{
display: block;
min-height: 45px;
.cx-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 0px 0px 10px 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);
}
&.cx-accordion, &.cx-toggle{
.cx-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;
}
.cx-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);
}
}
}
}
.cx-component__button + .cx-settings__content{
border-top: $border;
}
> .cx-ui-kit__content{
& > .cx-settings + .cx-settings{
margin-top: $margin;
}
> .cx-settings{
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
.widget &{
box-shadow:none;
border-radius: 0;
border-left: 0;
border-right: 0;
}
}
}
}
&.cx-tab{
.cx-tab__tabs{
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;
border-bottom: $border;
.cx-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;
}
.cx-tab__title {
font-weight: 700;
font-size: 14px;
float: left;
margin: 0;
}
& + button{
border-top: $border;
}
}
}
.cx-tab__body{
box-shadow:$shadow;
border-radius: $br-radius;
border: $border;
background-color: $color-1;
.cx-settings{
box-shadow: none;
border-radius: 0;
border: none;
background-color: inherit;
margin: 0;
}
}
@media ( min-width: 783px ) {
.cx-tab__tabs{
border: solid 1px rgba(0,0,0,0.1);
.cx-component__button{
& + button{
border-top: none;
}
}
}
.cx-tab__body{
border: none;
.cx-tab__content{
border: $border;
}
}
&--horizontal{
>.cx-tab__body{
border-radius: none;
>.cx-tab__tabs{
flex-wrap: nowrap;
flex-direction: row;
border-radius:$br-radius $br-radius 0 0;
border-bottom: none;
.cx-component__button{
flex: 0 1 auto;
}
}
>.cx-tab__content{
border-radius: 0 0 $br-radius $br-radius;
}
}
}
&--vertical{
>.cx-tab__body{
display: flex;
border-radius: none;
>.cx-tab__tabs{
flex-direction: row;
-webkit-box-flex: 0;
flex: 0 1 20%;
border-radius:$br-radius 0 0 $br-radius;
border-right: none;
.cx-component__button{
text-align: right;
.cx-tab__title {
width: 100%;
}
&.active{
box-shadow: inset -3px 0px 0px $link-color;
}
}
}
>.cx-tab__content{
-webkit-box-flex: 0;
flex: 0 1 80%;
border-radius: 0 $br-radius $br-radius 0;
}
}
}
}
@media ( min-width: 1200px ) {
&--vertical{
.cx-tab__tabs{
flex: 0 1 20%;
}
.cx-tab__content{
flex: 0 1 80%;
}
}
}
}
.widget &{
padding: 0;
&__content{
margin: 0 $margin * -1.5 $margin * 2;
.cx-control{
padding: $padding * 1.5 $padding * 2;
}
}
}
}
.cx-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;
}
}
}
.cx-control {
padding: $padding * 1.5 $padding * 2;
&__title{
margin: 0 0 $margin 0 ;
}
&__description{
margin-top: 0;
}
.cx-ui-container {
margin: 0;
}
@media (min-width: 783px) {
padding: $padding * 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 * 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;
}
}
&-hidden {
display: none;
}
}
.cx-section.cx-scroll > .cx-section__holder > .cx-section__inner,
.cx-tab__content > .cx-scroll,
.cx-accordion__content > .cx-scroll > .cx-settings__content,
.cx-toggle__content > .cx-scroll > .cx-settings__content {
@media ( min-width: 783px ) {
max-height: $max-height;
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,573 @@
<?php
/**
* Interface Builder module
*
* Version: 1.0.1
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Interface_Builder' ) ) {
/**
* Class Cherry Interface Builder.
*
* @since 1.0.0
*/
class CX_Interface_Builder {
/**
* Module directory path.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $path;
/**
* Module directory URL.
*
* @since 1.5.0
* @access protected
* @var srting.
*/
protected $url;
/**
* Module version
*
* @var string
*/
protected $version = '1.0.1';
/**
* Conditions
*
* @var array
*/
public $conditions = array();
/**
* [$conditions description]
* @var array
*/
public $fields_value = array();
/**
* Module settings.
*
* @since 1.0.0
* @access private
* @var array
*/
private $args = array(
'path' => '',
'url' => '',
'views' => array(
'section' => 'views/section.php',
'component-tab-vertical' => 'views/component-tab-vertical.php',
'component-tab-horizontal' => 'views/component-tab-horizontal.php',
'component-toggle' => 'views/component-toggle.php',
'component-accordion' => 'views/component-accordion.php',
'component-repeater' => 'views/component-repeater.php',
'settings' => 'views/settings.php',
'control' => 'views/control.php',
'settings-children-title' => 'views/settings-children-title.php',
'tab-children-title' => 'views/tab-children-title.php',
'toggle-children-title' => 'views/toggle-children-title.php',
'form' => 'views/form.php',
'html' => 'views/html.php',
),
'views_args' => array(
'parent' => '',
'type' => '',
'view' => '',
'view_wrapping' => true,
'html' => '',
'scroll' => false,
'title' => '',
'description' => '',
'condition' => array(),
),
);
/**
* 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 $controls = null;
/**
* The structure of the interface elements.
*
* @since 1.0.0
* @access private
* @var array
*/
private $structure = array();
/**
* Dependencies array
* @var array
*/
private $deps = array(
'css' => array(),
'js' => array( 'jquery' ),
);
/**
* Cherry_Interface_Builder constructor.
*
* @since 1.0.0
* @access public
* @return void
*/
public function __construct( array $args = array() ) {
$this->path = $args['path'];
$this->url = $args['url'];
$this->args = array_merge(
$this->args,
$args
);
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
require trailingslashit( $this->path ) . 'inc/class-cx-controls-manager.php';
$this->controls = new CX_Controls_Manager( $this->path, $this->url );
}
/**
* 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;
}
if ( ! isset( $args['name'] ) && isset( $args['id'] ) ) {
$args['name'] = $args['id'];
}
if ( 'control' === $type ) {
$instance = $this->controls->register_control( $args['type'], $args );
$args['instance'] = $instance;
$this->add_dependencies( $instance );
}
if ( array_key_exists( 'conditions', $args ) ) {
$this->conditions[ $args['id'] ] = $args['conditions'];
}
if ( array_key_exists( 'value', $args ) ) {
$this->fields_value[ $args['id'] ] = $args['value'];
}
$this->structure[ $args['id'] ] = $args;
} else {
foreach ( $args as $key => $value ) {
if ( 'control' !== $type && 'component' !== $type ) {
$value['type'] = $type;
}
if ( ! isset( $value['id'] ) ) {
$value['id'] = $key;
}
if ( ! isset( $value['name'] ) ) {
$value['name'] = $key;
}
if ( 'control' === $type ) {
$instance = $this->controls->register_control( $value['type'], $value );
$value['instance'] = $instance;
$this->add_dependencies( $instance );
}
if ( array_key_exists( 'conditions', $value ) ) {
$this->conditions[ $key ] = $value['conditions'];
}
if ( array_key_exists( 'value', $value ) ) {
$this->fields_value[ $key ] = $value['value'];
}
$this->structure[ $key ] = $value;
}
}
}
/**
* Add control dependencies to global builder deps
*
* @param [type] $control [description]
*/
protected function add_dependencies( $control ) {
if ( ! $control instanceof CX_Controls_Base ) {
return;
}
$this->deps['js'] = array_merge( $this->deps['js'], $control->get_script_depends() );
$this->deps['css'] = array_merge( $this->deps['css'], $control->get_style_depends() );
}
/**
* 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 )
) {
$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->path . $path;
} else {
$path = $args['view'];
}
ob_start();
include $path;
return ob_get_clean();
}
/**
* 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'] .= 'cx-scroll ';
}
$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'] : '' ;
$control = isset( $ui_args['instance'] ) ? $ui_args['instance'] : false;
if ( $control ) {
$value['children'] = $control->render();
} else {
$value['children'] = 'Control not found';
}
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() {
$suffix = '';
if ( defined( 'SCRIPT_DEBUG' ) && false === SCRIPT_DEBUG ) {
$suffix = '.min';
}
$js_deps = array_unique( $this->deps['js'] );
$css_deps = array_unique( $this->deps['css'] );
wp_enqueue_script(
'cx-interface-builder',
$this->url . 'assets/js/cx-interface-builder' . $suffix . '.js',
$js_deps,
$this->version,
true
);
wp_localize_script( 'cx-interface-builder', 'cxInterfaceBuilder',
array(
'conditions' => $this->conditions,
'fields' => $this->fields_value,
)
);
wp_enqueue_style(
'cx-interface-builder',
$this->url . 'assets/css/cx-interface-builder.css',
$css_deps,
$this->version,
'all'
);
}
}
}

View File

@@ -0,0 +1,171 @@
<?php
/**
* Control base class
*/
/**
* CX_Controls_Base abstract class
*/
if ( ! class_exists( 'CX_Controls_Base' ) ) {
/**
* CX_Controls_Base Abstract Class
*
* @since 1.0.0
*/
abstract class CX_Controls_Base {
/**
* Base URL
*
* @var null
*/
public $base_url = null;
/**
* Settings list
*
* @since 1.0.0
* @var array
*/
protected $settings = array();
/**
* Default settings array
*
* @var array
*/
public $defaults_settings = array();
/**
* Constructor method for the CX_Controls_Base class.
*
* @since 1.0.0
*/
public function __construct( $args = array() ) {
$this->defaults_settings['id'] = 'cx-control-' . uniqid();
$this->settings = wp_parse_args( $args, $this->defaults_settings );
$this->init();
add_action( 'wp_enqueue_scripts', array( $this, 'register_depends' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'register_depends' ) );
}
/**
* Render methos. Each UI element must implement own method
* @return [type] [description]
*/
abstract public function render();
/**
* Optional additional initializtion for control. Can be overriden from child class if needed.
* @return [type] [description]
*/
public function init() {}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array();
}
/**
* Register required dependencies
*
* @return void
*/
public function register_depends() {}
/**
* Retrun styles dependencies list for current control.
*
* @return array
*/
public function get_style_depends() {
return array();
}
/**
* Set up base URL for next usage
*
* @param string $url array
*/
public function set_base_url( $url = '' ) {
$this->base_url = $url;
}
/**
* Get control value
*
* @since 1.0.0
* @return string control value.
*/
public function get_value() {
return $this->settings['value'];
}
/**
* Set control value
*
* @since 1.0.0
* @param [type] $value new.
*/
public function set_value( $value ) {
$this->settings['value'] = $value;
}
/**
* Get control name
*
* @since 1.0.0
* @return string control name.
*/
public function get_name() {
return $this->settings['name'];
}
/**
* Set control name
*
* @since 1.0.0
* @param [type] $name new control name.
* @throws Exception Invalid control name.
*/
public function set_name( $name ) {
$name = (string) $name;
if ( '' !== $name ) {
$this->settings['name'] = $name;
} else {
throw new Exception( "Invalid control name '" . $name . "'. Name can't be empty." );
}
}
/**
* Returns attributes string from attributes array
*
* @return string
*/
public function get_attr_string( $attr = array() ) {
$result = array();
foreach ( $attr as $key => $value ) {
if ( $key === $value ) {
$result[] = $key;
} else {
$result[] = sprintf( '%1$s="%2$s"', $key, $value );
}
}
return implode( ' ', $result );
}
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* UI controls manager class
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Controls_Manager' ) ) {
/**
* Define CX_Controls_Manager class
*/
class CX_Controls_Manager {
/**
* Path to controls folder for current Inteface Builder instance
*
* @var string
*/
private $base_path = '';
/**
* Path to controls folder for current Inteface Builder instance
*
* @var string
*/
private $base_url = '';
/**
* Constructor for the class
*/
public function __construct( $base_path = null, $base_url = null ) {
$this->base_path = trailingslashit( $base_path );
$this->base_url = trailingslashit( $base_url );
require $this->base_path . 'inc/class-cx-controls-base.php';
$this->load_controls();
}
/**
* Automatically load found conrols
*
* @return void
*/
public function load_controls() {
foreach ( glob( $this->base_path . 'inc/controls/*.php' ) as $file ) {
require $file;
}
}
/**
* Register new control instance
*
* @return object
*/
public function register_control( $type = 'text', $args = array() ) {
$prefix = 'CX_Control_';
$classname = $prefix . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $type ) ) );
if ( ! class_exists( $classname ) ) {
return false;
}
$instance = new $classname( $args );
$instance->set_base_url( $this->base_url );
return $instance;
}
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Class for the building ui-button elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Button' ) ) {
/**
* Class for the building ui-button elements.
*/
class CX_Control_Button extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $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' => '',
);
/**
* Render html UI_Button.
*
* @since 1.0.0
*/
public function render() {
$classes = array(
'cx-button',
'cx-button-' . $this->settings['style'] . '-style',
$this->settings['class'],
);
$classes = array_filter( $classes );
$class = trim( implode( ' ', $classes ) );
$attrs = array(
'type' => esc_attr( $this->settings['button_type'] ),
'id' => esc_attr( $this->settings['id'] ),
'name' => esc_attr( $this->settings['name'] ),
'class' => esc_attr( $class ),
'form' => esc_attr( $this->settings['form'] ),
'formaction' => esc_attr( $this->settings['formaction'] ),
);
if ( filter_var( $this->settings['disabled'], FILTER_VALIDATE_BOOLEAN ) ) {
$attrs['disabled'] = 'disabled';
}
$html = sprintf(
'<button %1$s>%2$s</button>',
$this->get_attr_string( $attrs ),
$this->settings['content']
);
return $html;
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Class for the building checkbox elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Checkbox' ) ) {
/**
* Class for the building CX_Control_Checkbox elements.
*/
class CX_Control_Checkbox extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-checkbox-id',
'name' => 'cx-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' => '',
);
/**
* Render html UI_Checkbox.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-control-container ' . esc_attr( $class ) . '">';
$counter = 0;
if ( isset( $this->settings['options_callback'] ) ) {
$this->settings['options'] = call_user_func( $this->settings['options_callback'] );
}
if ( ! 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="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
foreach ( $this->settings['options'] as $option => $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 ) && filter_var( $item_value, FILTER_VALIDATE_BOOLEAN ) ) ? 'checked' : '';
$item_value = filter_var( $item_value, FILTER_VALIDATE_BOOLEAN ) ? 'true' : 'false';
$option_label = isset( $option_value ) && is_array( $option_value ) ? $option_value['label'] : $option_value;
$html .= '<div class="cx-checkbox-item-wrap">';
$html .= '<span class="cx-label-content">';
$html .= '<input type="hidden" id="' . esc_attr( $this->settings['id'] ) . '-' . $counter . '" class="cx-checkbox-input" name="' . esc_attr( $this->settings['name'] ) . '[' . $option . ']" ' . $checked . ' value="' . $item_value . '">';
$html .= '<span class="cx-checkbox-item"><span class="marker dashicons dashicons-yes"></span></span>';
$html .= '<label class="cx-checkbox-label" for="' . esc_attr( $this->settings['id'] ) . '-' . $counter . '"><span class="cx-label-content">' . esc_html( $option_label ) . '</span></label> ';
$html .= '</span>';
$html .= '</div>';
$counter++;
}
}
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* Class for the building colorpicker elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Colorpicker' ) ) {
/**
* Class for the building CX_Control_Colorpicker elements.
*/
class CX_Control_Colorpicker extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-colorpicker-id',
'name' => 'cx-colorpicker-name',
'value' => '',
'label' => '',
'class' => '',
);
/**
* Register control dependencies
*
* @return [type] [description]
*/
public function register_depends() {
wp_register_script(
'cx-colorpicker-alpha',
$this->base_url . 'assets/lib/colorpicker/wp-color-picker-alpha.min.js',
array( 'wp-color-picker' ),
'1.0.0',
true
);
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'cx-colorpicker-alpha' );
}
/**
* Retrun styles dependencies list for current control.
*
* @return array
*/
public function get_style_depends() {
return array( 'wp-color-picker' );
}
/**
* Render html UI_Colorpicker.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cx-ui-colorpicker-wrapper">';
$html .= '<input type="text" id="' . esc_attr( $this->settings['id'] ) . '" class="cx-ui-colorpicker" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '"/>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,200 @@
<?php
/**
* Class for the building dimensions elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Dimensions' ) ) {
/**
* Class for the building ui-dimensions elements.
*/
class CX_Control_Dimensions extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-dimensions-id',
'name' => 'cx-dimensions-name',
'value' => array(),
'range' => array(
'px' => array(
'min' => 0,
'max' => 100,
'step' => 1,
),
),
'dimension_labels' => array(
'top' => 'Top',
'right' => 'Right',
'bottom' => 'Bottom',
'left' => 'Left',
),
'label' => '',
'class' => '',
'required' => false,
);
protected $default_value = array(
'units' => 'px',
'is_linked' => true,
'top' => '',
'right' => '',
'bottom' => '',
'left' => '',
);
/**
* Get required attribute.
*
* @since 1.0.0
* @return string
*/
public function get_required() {
if ( $this->settings['required'] ) {
return 'required="required"';
}
return '';
}
/**
* Render html UI_Dimension.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['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="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= $this->get_fields();
$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="cx-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="cx-ui-dimensions__val%7$s"><span class="cx-ui-dimensions__value-label">%8$s</span></div>';
$value = $this->settings['value'];
$value = array_merge( $this->default_value, $value );
$result = sprintf(
'<div class="cx-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="cx-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="cx-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="cx-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="cx-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 ) );
}
}
}

View File

@@ -0,0 +1,352 @@
<?php
/**
* Class for the building iconpicker elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Iconpicker' ) ) {
/**
* Class for the building ui-iconpicker elements.
*/
class CX_Control_Iconpicker extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'type' => 'iconpicker',
'id' => 'cx-iconpicker-id',
'name' => 'cx-iconpicker-name',
'value' => '',
'placeholder' => '',
'icon_data' => array(),
'auto_parse' => false,
'label' => '',
'class' => '',
'master' => '',
'width' => 'fixed',
'required' => false,
);
/**
* 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();
/**
* Temporary icons holder
*
* @var null
*/
public $temp_icons = null;
/**
* Init
* @return [type] [description]
*/
public function init() {
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( 'cx_handler_response_data', array( $this, 'send_icon_set' ), 10, 1 );
}
/**
* Register control dependencies
*
* @return [type] [description]
*/
public function register_depends() {
wp_register_script(
'cx-iconpicker',
$this->base_url . 'assets/lib/iconpicker/jquery-iconpicker.js',
array( 'jquery' ),
'1.0.0',
true
);
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'cx-iconpicker' );
}
/**
* 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 = '';
$class = implode( ' ',
array(
$this->settings['class'],
$this->settings['width'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-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="cx-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 .= '</div>';
/**
* Maybe add js repeater template to response
*
* @var bool
*/
$add_js_to_response = apply_filters( 'cx_control/add_data_to_element', false );
if ( $add_js_to_response ) {
ob_start();
$this->print_icon_set();
$icons = ob_get_clean();
$in_repeater = apply_filters( 'cx_control/is_repeater', false );
if ( $in_repeater ) {
$this->temp_icons = $icons;
add_filter( 'cx_control/add_repeater_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 cx-ui-text cx-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( WP_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['CxIconSets'] ) ) {
$data['CxIconSets'] = array();
}
foreach ( self::$sets as $key => $value ) {
$data['CxIconSets'][ $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.CxIconSets ) { window.CxIconSets = {} } window.CxIconSets.%1$s = %2$s</script>',
$set,
$json
);
}
}
}
}

View File

@@ -0,0 +1,154 @@
<?php
/**
* Class for the building ui-media elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Media' ) ) {
/**
* Class for the building CX_Control_Media elements.
*/
class CX_Control_Media extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-media-id',
'name' => 'cx-ui-media-name',
'value' => '',
'multi_upload' => true,
'library_type' => '', // image, video, sound
'upload_button_text' => 'Choose Media',
'label' => '',
'class' => '',
);
/**
* Register control dependencies
*
* @return [type] [description]
*/
public function register_depends() {
wp_enqueue_media();
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'jquery-ui-sortable' );
}
/**
* Render html CX_Control_Media.
*
* @since 1.0.0
*/
public function render() {
$html = '';
if ( ! current_user_can( 'upload_files' ) ) {
return $html;
}
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-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="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cx-ui-media-wrap">';
$html .= '<div class="cx-upload-preview" >';
$html .= '<div class="cx-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="cx-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="cx-remove-image" href="#" title=""><i class="dashicons dashicons-no"></i></a>';
$html .= '</div>';
$html .= '</div>';
}
}
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="cx-element-wrap">';
$html .= '<input type="hidden" id="' . esc_attr( $this->settings['id'] ) . '" class="cx-upload-input" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '">';
$html .= '<button type="button" class="upload-button cx-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'] ) . '">' . esc_attr( $this->settings['upload_button_text'] ) . '</button>';
$html .= '<div class="clear"></div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,121 @@
<?php
/**
* Class for the building ui-radio elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cxframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cxframework.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( 'CX_Control_Radio' ) ) {
/**
* Class for the building CX_Control_Radio elements.
*/
class CX_Control_Radio extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-radio-id',
'name' => 'cx-ui-radio-name',
'value' => 'radio-2',
'options' => array(
'radio-1' => array(
'label' => 'Radio 1',
'img_src' => '',
),
'radio-2' => array(
'label' => 'Radio 2',
'img_src' => '',
),
'radio-3' => array(
'label' => 'Radio 3',
'img_src' => '',
),
),
'label' => '',
'class' => '',
);
/**
* Render html UI_Radio.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
if ( isset( $this->settings['options_callback'] ) ) {
$this->settings['options'] = call_user_func( $this->settings['options_callback'] );
}
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '" >';
if ( $this->settings['options'] && ! empty( $this->settings['options'] ) && is_array( $this->settings['options'] ) ) {
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . $this->settings['label'] . '</label> ';
}
$html .= '<div class="cx-radio-group">';
foreach ( $this->settings['options'] as $option => $option_value ) {
$checked = $option == $this->settings['value'] ? ' checked' : '';
$radio_id = $this->settings['id'] . '-' . $option;
$img = isset( $option_value['img_src'] ) && ! empty( $option_value['img_src'] ) ? '<img src="' . esc_url( $option_value['img_src'] ) . '" alt="' . esc_html( $option_value['label'] ) . '">' : '<span class="cx-radio-item"><i></i></span>';
$class_box = isset( $option_value['img_src'] ) && ! empty( $option_value['img_src'] ) ? 'cx-radio-img' : 'cx-radio-item' ;
$html .= '<div class="' . $class_box . '">';
$html .= '<input type="radio" id="' . esc_attr( $radio_id ) . '" class="cx-radio-input" name="' . esc_attr( $this->settings['name'] ) . '" ' . checked( $option, $this->settings['value'], false ) . ' value="' . esc_attr( $option ) . '"/>';
$label_content = $img . $option_value['label'];
$html .= '<label for="' . esc_attr( $radio_id ) . '"><span class="cx-lable-content">' . $label_content . '</span></label> ';
$html .= '</div>';
}
$html .= '<div class="clear"></div>';
$html .= '</div>';
}
$html .= '</div>';
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Radio.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_style(
'ui-radio',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-radio/assets/min/ui-radio.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
wp_enqueue_script(
'ui-radio-min',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-radio/assets/min/ui-radio.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
}
}
}

View File

@@ -0,0 +1,331 @@
<?php
/**
* Class for the building ui-repeater elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Repeater' ) ) {
/**
* Class for the building ui-repeater elements.
*/
class CX_Control_Repeater extends CX_Controls_Base {
/**
* Default settings
*
* @var array
*/
public $defaults_settings = array(
'type' => 'repeater',
'id' => 'cx-ui-repeater-id',
'name' => 'cx-ui-repeater-name',
'value' => array(),
'fields' => array(),
'label' => '',
'add_label' => 'Add Item',
'class' => '',
'ui_kit' => true,
'required' => false,
'title_field' => '',
);
/**
* Stored data to process it while renderinr row
*
* @var array
*/
public $data = array();
/**
* Repeater instances counter
*
* @var integer
*/
public static $instance_id = 0;
/**
* Current onstance TMPL name
*
* @var string
*/
public $tmpl_name = '';
/**
* Holder for templates to print it in bottom of customizer page
*
* @var string
*/
public static $customizer_tmpl_to_print = null;
/**
* Is tmpl scripts already printed in customizer
*
* @var boolean
*/
public static $customizer_tmpl_printed = false;
/**
* Init.
*
* @since 1.0.0
*/
public function init() {
$this->set_tmpl_data();
add_action( 'admin_footer', array( $this, 'print_js_template' ), 0 );
add_action( 'customize_controls_print_footer_scripts', array( $this, 'fix_customizer_tmpl' ), 9999 );
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'jquery-ui-sortable', 'wp-util' );
}
/**
* Get required attribute.
*
* @return string required attribute
*/
public function get_required() {
if ( $this->settings['required'] ) {
return 'required="required"';
}
return '';
}
/**
* Render html UI_Repeater.
*
* @since 1.0.1
*/
public function render() {
$html = '';
$class = $this->settings['class'];
$ui_kit = ! empty( $this->settings['ui_kit'] ) ? 'cx-ui-kit' : '';
$value = ! empty( $this->settings['value'] ) ? count( $this->settings['value'] ) : 0 ;
$title_field = ! empty( $this->settings['title_field'] ) ? 'data-title-field="' . $this->settings['title_field'] . '"' : '' ;
add_filter( 'cx_control/is_repeater', '__return_true' );
$html .= sprintf( '<div class="cx-ui-repeater-container cx-ui-container %1$s %2$s">',
$ui_kit,
esc_attr( $class )
);
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= sprintf(
'<div class="cx-ui-repeater-list" data-name="%1$s" data-index="%2$s" data-widget-id="__i__" %3$s id="%4$s">',
$this->get_tmpl_name(),
$value,
$title_field,
esc_attr( $this->settings['id'] )
);
if ( is_array( $this->settings['value'] ) ) {
$index = 0;
foreach ( $this->settings['value'] as $data ) {
$html .= $this->render_row( $index, false, $data );
$index++;
}
}
$html .= '</div>';
$html .= sprintf(
'<a href="#" class="cx-ui-repeater-add">%1$s</a>',
esc_html( $this->settings['add_label'] )
);
$html .= '</div>';
/**
* Maybe add js repeater template to response
*
* @var bool
*/
$add_js_to_response = apply_filters( 'cx_control/add_data_to_element', false );
if ( $add_js_to_response ) {
$html .= $this->get_js_template();
}
$html .= $this->get_additional_data();
remove_all_filters( 'cx_control/is_repeater' );
return $html;
}
/**
* Get additional data to return
* @return [type] [description]
*/
public function get_additional_data() {
$data = apply_filters( 'cx_control/add_repeater_data', array() );
if ( ! empty( $data ) ) {
return implode( ' ', $data );
}
}
/**
* Render single row for repeater
*
* @param string $index Current row index.
* @param number $widget_index It contains widget index.
* @param array $data Values to paste.
* @since 1.0.1
*/
public function render_row( $index, $widget_index, $data ) {
$this->data = $data;
$html = '<div class="cx-ui-repeater-item" >';
$html .= '<div class="cx-ui-repeater-actions-box">';
$html .= '<a href="#" class="cx-ui-repeater-remove"></a>';
$html .= '<span class="cx-ui-repeater-title">' . $this->get_row_title() . '</span>';
$html .= '<a href="#" class="cx-ui-repeater-toggle"></a>';
$html .= '</div>';
$html .= '<div class="cheryr-ui-repeater-content-box">';
foreach ( $this->settings['fields'] as $field ) {
$html .= '<div class="' . $field['id'] . '-wrap">';
$html .= $this->render_field( $index, $widget_index, $field );
$html .= '</div>';
}
$html .= '</div>';
$html .= '</div>';
$this->data = array();
return $html;
}
/**
* Get repeater item title
*
* @return string
* @since 1.0.1
*/
public function get_row_title() {
if ( empty( $this->settings['title_field'] ) ) {
return '';
}
if ( ! empty( $this->data[ $this->settings['title_field'] ] ) ) {
return $this->data[ $this->settings['title_field'] ];
}
return '';
}
/**
* Render single repeater field
*
* @param string $index Current row index.
* @param number $widget_index It contains widget index.
* @param array $field Values to paste.
* @return string
*/
public function render_field( $index, $widget_index, $field ) {
if ( empty( $field['type'] ) || empty( $field['name'] ) ) {
return '"type" and "name" are required fields for UI_Repeater items';
}
$field = wp_parse_args( $field, array(
'value' => '',
) );
$parent_name = str_replace( '__i__', $widget_index, $this->settings['name'] );
$field['id'] = sprintf( '%s-%s', $field['id'], $index );
$field['value'] = isset( $this->data[ $field['name'] ] ) ? $this->data[ $field['name'] ] : $field['value'];
$field['name'] = sprintf( '%1$s[item-%2$s][%3$s]', $parent_name, $index, $field['name'] );
$ui_class_name = 'CX_Control_' . ucwords( $field['type'] );
if ( ! class_exists( $ui_class_name ) ) {
return '<p>Class <b>' . $ui_class_name . '</b> not exist!</p>';
}
$ui_item = new $ui_class_name( $field );
return $ui_item->render();
}
/**
* Get TMPL name for current repeater instance.
*
* @return string
*/
public function get_tmpl_name() {
return $this->tmpl_name;
}
/**
* Set current repeater instance ID
*
* @return void
*/
public function set_tmpl_data() {
self::$instance_id++;
$this->tmpl_name = sprintf( 'repeater-template-%s', self::$instance_id );
global $wp_customize;
if ( isset( $wp_customize ) ) {
self::$customizer_tmpl_to_print .= $this->get_js_template();
}
}
/**
* Print JS template for current repeater instance
*
* @return void
*/
public function print_js_template() {
echo $this->get_js_template();
}
/**
* Get JS template to print
*
* @return string
*/
public function get_js_template() {
return sprintf(
'<script type="text/html" id="tmpl-%1$s">%2$s</script>',
$this->get_tmpl_name(),
$this->render_row( '{{{data.index}}}', '{{{data.widgetId}}}', array() )
);
}
/**
* Outputs JS templates on customizer page
*
* @return void
*/
public function fix_customizer_tmpl() {
if ( true === self::$customizer_tmpl_printed ) {
return;
}
self::$customizer_tmpl_printed = true;
echo self::$customizer_tmpl_to_print;
}
}
}

View File

@@ -0,0 +1,185 @@
<?php
/**
* Class for the building ui-select elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Select' ) ) {
/**
* Class for the building CX_Control_Select elements.
*/
class CX_Control_Select extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-select-id',
'name' => 'cx-ui-select-name',
'multiple' => false,
'filter' => false,
'size' => 1,
'inline_style' => 'width: 100%',
'value' => 'select-8',
'placeholder' => null,
'options' => array(
'select-1' => 'select 1',
'select-2' => 'select 2',
'select-3' => 'select 3',
'select-4' => 'select 4',
'select-5' => array(
'label' => 'Group 1',
),
'optgroup-1' => array(
'label' => 'Group 1',
'group_options' => array(
'select-6' => 'select 6',
'select-7' => 'select 7',
'select-8' => 'select 8',
),
),
'optgroup-2' => array(
'label' => 'Group 2',
'group_options' => array(
'select-9' => 'select 9',
'select-10' => 'select 10',
'select-11' => 'select 11',
),
),
),
'label' => '',
'class' => '',
);
/**
* Register control dependencies
*
* @return [type] [description]
*/
public function register_depends() {
wp_register_script(
'cx-select2',
$this->base_url . 'assets/lib/select2/select2.min.js',
array( 'jquery' ),
'4.0.5',
true
);
wp_register_style(
'cx-select2',
$this->base_url . 'assets/lib/select2/select2.min.css',
array(),
'4.0.5',
'all'
);
}
/**
* Retrun scripts dependencies list for current control.
*
* @return array
*/
public function get_script_depends() {
return array( 'cx-select2' );
}
/**
* Retrun styles dependencies list for current control.
*
* @return array
*/
public function get_style_depends() {
return array( 'cx-select2' );
}
/**
* Render html UI_Select.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
if ( isset( $this->settings['options_callback'] ) ) {
$this->settings['options'] = call_user_func( $this->settings['options_callback'] );
}
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
$html .= '<div class="cx-ui-select-wrapper">';
( $this->settings['filter'] ) ? $filter_state = 'data-filter="true"' : $filter_state = 'data-filter="false"' ;
( $this->settings['multiple'] ) ? $multi_state = 'multiple="multiple"' : $multi_state = '' ;
( $this->settings['multiple'] ) ? $name = $this->settings['name'] . '[]' : $name = $this->settings['name'] ;
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . $this->settings['label'] . '</label> ';
}
$inline_style = $this->settings['inline_style'] ? 'style="' . esc_attr( $this->settings['inline_style'] ) . '"' : '' ;
$html .= '<select id="' . esc_attr( $this->settings['id'] ) . '" class="cx-ui-select" name="' . esc_attr( $name ) . '" size="' . esc_attr( $this->settings['size'] ) . '" ' . $multi_state . ' ' . $filter_state . ' data-placeholder="' . esc_attr( $this->settings['placeholder'] ) . '" ' . $inline_style . '>';
if ( $this->settings['options'] && ! empty( $this->settings['options'] ) && is_array( $this->settings['options'] ) ) {
foreach ( $this->settings['options'] as $option => $option_value ) {
if ( ! is_array( $this->settings['value'] ) ) {
$this->settings['value'] = array( $this->settings['value'] );
}
if ( false === strpos( $option, 'optgroup' ) ) {
$selected_state = '';
if ( $this->settings['value'] && ! empty( $this->settings['value'] ) ) {
foreach ( $this->settings['value'] as $key => $value ) {
$selected_state = selected( $value, $option, false );
if ( " selected='selected'" == $selected_state ) {
break;
}
}
}
if ( is_array( $option_value ) ) {
$label = $option_value['label'];
} else {
$label = $option_value;
}
$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected_state . '>' . esc_html( $label ) . '</option>';
} else {
$html .= '<optgroup label="' . esc_attr( $option_value['label'] ) . '">';
$selected_state = '';
foreach ( $option_value['group_options'] as $group_item => $group_value ) {
foreach ( $this->settings['value'] as $key => $value ) {
$selected_state = selected( $value, $group_item, false );
if ( " selected='selected'" == $selected_state ) {
break;
}
}
$html .= '<option value="' . esc_attr( $group_item ) . '" ' . $selected_state . '>' . esc_html( $group_value ) . '</option>';
}
$html .= '</optgroup>';
}
}
}
$html .= '</select>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* Class for the building ui slider elements .
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Slider' ) ) {
/**
* Class for the building UI_Slider elements.
*/
class CX_Control_Slider extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-slider-id',
'name' => 'cx-ui-slider-name',
'max_value' => 100,
'min_value' => 0,
'value' => 50,
'step_value' => 1,
'label' => '',
'class' => '',
);
/**
* Render html UI_Slider.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
$ui_stepper = new CX_Control_Stepper(
array(
'id' => $this->settings['id'] . '-stepper',
'name' => $this->settings['name'],
'max_value' => $this->settings['max_value'],
'min_value' => $this->settings['min_value'],
'value' => $this->settings['value'],
'step_value' => $this->settings['step_value'],
)
);
$ui_stepper_html = $ui_stepper->render();
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cx-slider-wrap">';
$html .= '<div class="cx-slider-holder">';
$html .= '<input type="range" class="cx-slider-unit" step="' . esc_attr( $this->settings['step_value'] ) . '" min="' . esc_attr( $this->settings['min_value'] ) . '" max="' . esc_attr( $this->settings['max_value'] ) . '" value="' . esc_attr( $this->settings['value'] ) . '">';
$html .= '</div>';
$html .= '<div class="cx-slider-input">';
$html .= $ui_stepper_html;
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
/**
* Enqueue javascript and stylesheet UI_Slider.
*
* @since 1.0.0
*/
public static function enqueue_assets() {
wp_enqueue_script(
'ui-slider',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-slider/assets/min/ui-slider.min.js', Cherry_UI_Elements::$module_path ) ),
array( 'jquery' ),
Cherry_UI_Elements::$core_version,
true
);
wp_enqueue_style(
'ui-slider',
esc_url( Cherry_Core::base_url( 'inc/ui-elements/ui-slider/assets/min/ui-slider.min.css', Cherry_UI_Elements::$module_path ) ),
array(),
Cherry_UI_Elements::$core_version,
'all'
);
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Class for the building ui stepper elements.
*
* @package Cherry_Framework
* @subpackage Class
* @author Cherry Team <support@cxframework.com>
* @copyright Copyright (c) 2012 - 2015, Cherry Team
* @link http://www.cxframework.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( 'CX_Control_Stepper' ) ) {
/**
* Class for the building CX_Control_Stepper elements.
*/
class CX_Control_Stepper extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-stepper-id',
'name' => 'cx-ui-stepper-name',
'value' => '0',
'max_value' => '100',
'min_value' => '0',
'step_value' => '1',
'label' => '',
'class' => '',
'placeholder' => '',
);
/**
* Render html UI_Stepper.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<div class="cx-ui-stepper">';
$html .= '<input type="number" id="' . esc_attr( $this->settings['id'] ) . '" class="cx-ui-stepper-input" pattern="[0-5]+([\.,][0-5]+)?" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '" min="' . esc_html( $this->settings['min_value'] ) . '" max="' . esc_html( $this->settings['max_value'] ) . '" step="' . esc_html( $this->settings['step_value'] ) . '" placeholder="' . esc_attr( $this->settings['placeholder'] ) . '">';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Class for the building ui swither elements .
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Switcher' ) ) {
/**
* Class for the building CX_Control_Switcher elements.
*/
class CX_Control_Switcher extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-swither-id',
'name' => 'cx-ui-swither-name',
'value' => true,
'toggle' => array(
'true_toggle' => 'On',
'false_toggle' => 'Off',
),
'label' => '',
'class' => '',
);
/**
* Render html UI_Switcher.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$value = filter_var( $this->settings['value'], FILTER_VALIDATE_BOOLEAN );
$html .= '<div class="cx-switcher-wrap">';
$html .= '<input type="radio" id="' . esc_attr( $this->settings['id'] ) . '-true" class="cx-input-switcher cx-input-switcher-true" name="' . esc_attr( $this->settings['name'] ) . '" ' . checked( true, $value, false ) . ' value="true">';
$html .= '<input type="radio" id="' . esc_attr( $this->settings['id'] ) . '-false" class="cx-input-switcher cx-input-switcher-false" name="' . esc_attr( $this->settings['name'] ) . '" ' . checked( false, $value, false ) . ' value="false">';
$html .= '<span class="bg-cover"></span>';
$html .= '<label class="sw-enable"><span>' . esc_html( $this->settings['toggle']['true_toggle'] ) . '</span></label>';
$html .= '<label class="sw-disable"><span>' . esc_html( $this->settings['toggle']['false_toggle'] ) . '</span></label>';
$html .= '<span class="state-marker"></span>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* Class for the building ui-text elements.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Text' ) ) {
/**
* Class for the building ui-text elements.
*/
class CX_Control_Text extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'type' => 'text',
'id' => 'cx-ui-input-id',
'name' => 'cx-ui-input-name',
'value' => '',
'placeholder' => '',
'label' => '',
'class' => '',
'required' => false,
);
/**
* 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'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . esc_html( $this->settings['label'] ) . '</label> ';
}
$html .= '<input type="' . esc_attr( $this->settings['type'] ) . '" id="' . esc_attr( $this->settings['id'] ) . '" class="widefat cx-ui-text" name="' . esc_attr( $this->settings['name'] ) . '" value="' . esc_html( $this->settings['value'] ) . '" placeholder="' . esc_attr( $this->settings['placeholder'] ) . '" ' . $this->get_required() . '>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Class for the building ui-textarea elements
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'CX_Control_Textarea' ) ) {
/**
* Class for the building CX_Control_Textarea elements.
*/
class CX_Control_Textarea extends CX_Controls_Base {
/**
* Default settings.
*
* @since 1.0.0
* @var array
*/
public $defaults_settings = array(
'id' => 'cx-ui-textarea-id',
'name' => 'cx-ui-textarea-name',
'value' => '',
'placeholder' => '',
'rows' => '10',
'cols' => '20',
'label' => '',
'class' => '',
);
/**
* Render html UI_Textarea.
*
* @since 1.0.0
*/
public function render() {
$html = '';
$class = implode( ' ',
array(
$this->settings['class'],
)
);
$html .= '<div class="cx-ui-container ' . esc_attr( $class ) . '">';
if ( '' !== $this->settings['label'] ) {
$html .= '<label class="cx-label" for="' . esc_attr( $this->settings['id'] ) . '">' . $this->settings['label'] . '</label> ';
}
$html .= '<textarea id="' . esc_attr( $this->settings['id'] ) . '" class="cx-ui-textarea" name="' . esc_attr( $this->settings['name'] ) . '" rows="' . esc_attr( $this->settings['rows'] ) . '" cols="' . esc_attr( $this->settings['cols'] ) . '" placeholder="' . esc_attr( $this->settings['placeholder'] ) . '">' . esc_html( $this->settings['value'] ) . '</textarea>';
$html .= '</div>';
return $html;
}
}
}

View File

@@ -0,0 +1,23 @@
<?php
/**
* Accordion template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit cx-component cx-accordion <?php echo esc_attr( $args['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $args['id'] ) ?>">
<?php if ( ! empty( $args['title'] ) ) { ?>
<h2 class="cx-ui-kit__title cx-component__title" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__description cx-component__description" role="note" ><?php echo wp_kses_post( $args['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $args['children'] ) ) { ?>
<div class="cx-ui-kit__content cx-component__content cx-accordion__content" role="group" >
<?php echo $args['children'] ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,23 @@
<?php
/**
* Repeater template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit cx-component cx-repeater <?php echo esc_attr( $args['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $args['id'] ); ?>">
<?php if ( ! empty( $args['title'] ) ) { ?>
<h2 class="cx-ui-kit__title cx-component__title" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__description cx-component__description" role="note" ><?php echo wp_kses_post( $args['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $args['children'] ) ) { ?>
<div class="cx-ui-kit__content cx-component__content" role="group" >
<?php echo $args['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,28 @@
<?php
/**
* Horizontal tab template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit cx-component cx-tab cx-tab--horizontal <?php echo esc_attr( $args['class'] ) ?>" data-compotent-id="#<?php echo esc_attr( $args['id'] ); ?>">
<?php if ( ! empty( $args['title'] ) ) { ?>
<h2 class="cx-ui-kit__title cx-component__title" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__description cx-component__description" role="note" ><?php echo wp_kses_post( $args['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $args['children'] ) ) { ?>
<div class="cx-tab__body" >
<div class="cx-tab__tabs" role="navigation" >
<?php echo $args['tabs']; ?>
</div>
<div class="cx-ui-kit__content cx-component__content cx-tab__content" role="group" >
<?php echo $args['children']; ?>
</div>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,28 @@
<?php
/**
* Verticall tab template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit cx-component cx-tab cx-tab--vertical <?php echo esc_attr( $args['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $args['id'] ); ?>">
<?php if ( ! empty( $args['title'] ) ) { ?>
<h2 class="cx-ui-kit__title cx-component__title" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__description cx-component__description" role="note" ><?php echo wp_kses_post( $args['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $args['children'] ) ) { ?>
<div class="cx-tab__body" >
<div class="cx-tab__tabs" role="navigation" >
<?php echo $args['tabs']; ?>
</div>
<div class="cx-ui-kit__content cx-component__content cx-tab__content" role="group" >
<?php echo $args['children']; ?>
</div>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,23 @@
<?php
/**
* Toggle template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit cx-component cx-toggle <?php echo esc_attr( $args['class'] ); ?>" data-compotent-id="#<?php echo esc_attr( $args['id'] ); ?>">
<?php if ( ! empty( $args['title'] ) ) { ?>
<h2 class="cx-ui-kit__title cx-component__title" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h2>
<?php } ?>
<?php if ( ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__description cx-component__description" role="note" ><?php echo wp_kses_post( $args['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $args['children'] ) ) { ?>
<div class="cx-ui-kit__content cx-component__content cx-toggle__content" role="group" >
<?php echo $args['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,27 @@
<?php
/**
* Control template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit cx-control cx-control-<?php echo esc_attr( $args['type'] ); ?>" data-control-name="<?php echo esc_attr( $args['name'] ); ?>">
<?php if ( ! empty( $args['title'] ) || ! empty( $args['description'] ) ) { ?>
<div class="cx-control__info">
<?php if ( ! empty( $args['title'] ) ) { ?>
<h4 class="cx-ui-kit__title cx-control__title" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h4>
<?php } ?>
<?php if ( ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__description cx-control__description" role="note" ><?php echo wp_kses_post( $args['description'] ); ?></div>
<?php } ?>
</div>
<?php } ?>
<?php if ( ! empty( $args['children'] ) ) { ?>
<div class="cx-ui-kit__content cx-control__content" role="group" >
<?php echo $args['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,17 @@
<?php
/**
* Form template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<form class="cx-form <?php echo esc_attr( $args['class'] ); ?>" id="<?php echo esc_attr( $args['id'] ); ?>" name="<?php echo esc_attr( $args['id'] ); ?>" accept-charset="<?php echo esc_attr( $args['accept-charset'] ); ?>" action="<?php echo esc_attr( $args['action'] ); ?>" autocomplete="<?php echo esc_attr( $args['autocomplete'] ); ?>" enctype="<?php echo esc_attr( $args['enctype'] ); ?>" method="<?php echo esc_attr( $args['method'] ); ?>" target="<?php echo esc_attr( $args['target'] ); ?>" <?php echo esc_attr( $args['novalidate'] ); ?> >
<?php
if ( ! empty( $args['children'] ) ) {
echo $args['children'];
}
?>
</form>

View File

@@ -0,0 +1,17 @@
<?php
/**
* HTML template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit <?php echo esc_attr( $args['class'] ); ?>">
<?php if ( ! empty( $args['children'] ) ) { ?>
<div class="cx-ui-kit__content" role="group" >
<?php echo $args['children']; ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,29 @@
<?php
/**
* Section template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit cx-section <?php echo esc_attr( $args['class'] ); ?>" onclick="void(0)">
<div class="cx-section__holder">
<div class="cx-section__inner">
<div class="cx-section__info">
<?php if ( ! empty( $args['title'] ) ) { ?>
<h1 class="cx-ui-kit__title cx-section__title" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h1>
<?php } ?>
<?php if ( ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__description cx-section__description " role="note" ><?php echo wp_kses_post( $args['description'] ); ?></div>
<?php } ?>
</div>
<?php if ( ! empty( $args['children'] ) ) { ?>
<div class="cx-ui-kit__content cx-section__content" role="group" >
<?php echo $args['children']; ?>
</div>
<?php } ?>
</div>
</div>
</div>

View File

@@ -0,0 +1,11 @@
<?php
/**
* Settings title template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<h3 class="cx-ui-kit__title cx-settings__title" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h3>

View File

@@ -0,0 +1,25 @@
<?php
/**
* Settings template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<div class="cx-ui-kit cx-settings <?php echo esc_attr( $args['class'] ); ?>">
<?php if ( ! empty( $args['title'] ) ) {
echo $args['title'];
} ?>
<?php if ( ! empty( $args['children'] ) || ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__content cx-settings__content" role="group" id="<?php echo esc_attr( $args['id'] ); ?>" >
<?php if ( ! empty( $args['description'] ) ) { ?>
<div class="cx-ui-kit__description cx-settings__description" role="note" ><?php echo wp_kses_post( $args['description'] ); ?></div>
<?php } ?>
<?php if ( ! empty( $args['children'] ) ) { ?>
<?php echo $args['children']; ?>
<?php } ?>
</div>
<?php } ?>
</div>

View File

@@ -0,0 +1,13 @@
<?php
/**
* Tabs title template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<button class="cx-tab__button cx-component__button" role="button" title="<?php echo esc_attr( $args['title'] ); ?>" aria-expanded="false" data-content-id="#<?php echo esc_attr( $args['id'] ); ?>">
<h3 class="cx-ui-kit__title cx-tab__title" aria-grabbed="true" role="banner" ><?php echo wp_kses_post( $args['title'] ); ?></h3>
</button>

View File

@@ -0,0 +1,15 @@
<?php
/**
* Toggle title template.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
?>
<button class="cx-toggle__header cx-component__button" role="button" aria-expanded="false" data-content-id="#<?php echo esc_attr( $args['id'] ); ?>">
<h3 class="cx-ui-kit__title cx-toggle__title" aria-grabbed="true" role="banner" ><?php echo wp_kses_post( $args['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,216 @@
<?php
/**
* Cherry X framework loader class.
*
* How to use:
*
* 1. Copy and include this class into your theme/plugin
* 2. Add unique prefix for the class name, e.g. - Twentyseventeen_Jet_Theme_Core_CX_Loader
* 3. Initialize loader on after_setup_theme hook with priority -20, Example:
*
* add_action( 'after_setup_theme', 'twentyseventeen_framework_loader', -20 );
* function twentyseventeen_framework_loader() {
* require get_theme_file_path( 'framework/loader.php' );
* new Twentyseventeen_Jet_Theme_Core_CX_Loader(
* array(
* get_theme_file_path( 'framework/modules/module-1/module-1.php' ),
* get_theme_file_path( 'framework/modules/module-2/module-2.php' ),
* get_theme_file_path( 'framework/modules/module-3/module-3.php' ),
* )
* );
* }
*
* Notes:
*
* 1. This class only select latest version of each module from all Cherry X frameworks loaded in current environment
* 2. You should manually initialize selected modules later, when them will be needed you, but not eralier than after_setup_theme hook with priority 0.
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_CX_Loader' ) ) {
/**
* Define Jet_Theme_Core_CX_Loader class
*/
class Jet_Theme_Core_CX_Loader {
/**
* Key for object cache where are stored information about all modules in current environment
*
* @var string
*/
private $key = 'cherry_x_modules';
/**
* Holder for modules list of current loader instance.
*
* @var array
*/
private $modules = array();
/**
* Holder for modules slugs list of current loader instance.
*
* @var array
*/
private $modules_slugs = array();
/**
* Included modules paths and URLs
*
* @var array
*/
private $included_modules = array();
/**
* Loads latest versions of all modules passed into modules array
*
* @param array $modules List of loaded modules. Format:
* array(
* get_theme_file_path( 'framework/modules/module-1/module-1.php' ),
* get_theme_file_path( 'framework/modules/module-2/module-2.php' ),
* get_theme_file_path( 'framework/modules/module-3/module-3.php' ),
* )
*/
public function __construct( array $modules = array() ) {
$this->modules = $modules;
add_action( 'after_setup_theme', array( $this, 'store_versions' ), -10 );
add_action( 'after_setup_theme', array( $this, 'include_modules' ), -1 );
}
/**
* Store versions for modules passed in current instance into global modules versions list
*
* @return void
*/
public function store_versions() {
foreach ( $this->modules as $module ) {
$this->store_module_version( $module );
}
}
/**
* Include latest versions of modules in current loader instance.
* All available version preiously stored by 'store_versions' methods of each loader instance.
*
* @return boolean
*/
public function include_modules() {
$modules_data = wp_cache_get( $this->key );
foreach ( $this->modules_slugs as $slug ) {
if ( empty( $modules_data[ $slug ] ) ) {
continue;
}
$path = $this->get_latest_version_path( $modules_data[ $slug ] );
if ( file_exists( $path ) ) {
$dir = pathinfo( $path, PATHINFO_DIRNAME );
$this->included_modules[ $slug ] = array(
'path' => trailingslashit( $dir ),
'url' => trailingslashit(
str_replace(
'\\',
'/',
str_replace( untrailingslashit( ABSPATH ), esc_url( home_url() ), $dir )
)
),
);
require_once $path;
}
}
return true;
}
/**
* Retireve path and URL of included module directory
*
* @param [type] $file [description]
* @return [type] [description]
*/
public function get_included_module_data( $file ) {
return isset( $this->included_modules[ $file ] ) ? $this->included_modules[ $file ] : false;
}
/**
* Select latest version path from all available.
*
* @param array $module_versions All available vaerions paths for selected module
* @return string Module path.
*/
private function get_latest_version_path( array $module_versions = array() ) {
// Immediately return path if array contain sinle element.
if ( 1 === count( $module_versions ) ) {
$module_versions = array_values( $module_versions );
return $module_versions[0];
}
// Sort array by version and return highest
uksort( $module_versions, 'version_compare' );
return end( $module_versions );
}
/**
* Store passed module version and path into global modules data.
*
* @param string $module_path Module path
* @return boolean
*/
private function store_module_version( $module_path = null ) {
$slug = basename( $module_path );
$modules_data = wp_cache_get( $this->key );
$modules_data = ! empty( $modules_data ) ? $modules_data : array();
if ( empty( $modules_data[ $slug ] ) ) {
$modules_data[ $slug ] = array();
}
$filedata = get_file_data( $module_path, array(
'version' => 'Version',
) );
if ( empty( $filedata['version'] ) ) {
// If version not passed in file header, so module defined not correctly and not be included
return false;
}
$current_version = $filedata['version'];
if ( empty( $modules_data[ $slug ][ $current_version ] ) ) {
$modules_data[ $slug ][ $current_version ] = $module_path;
}
$this->modules_slugs[] = $slug;
wp_cache_set( $this->key, $modules_data, '', 1 );
return true;
}
}
}

View File

@@ -0,0 +1,149 @@
<?php
/**
* Class description
*
* @package package_name
* @author Cherry Team
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Ajax_Handlers' ) ) {
/**
* Define Jet_Theme_Core_Ajax_Handlers class
*/
class Jet_Theme_Core_Ajax_Handlers {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
public function __construct() {
// Register private actions
$priv_actions = array(
'jet_theme_search_posts' => array( $this, 'search_posts' ),
'jet_theme_search_pages' => array( $this, 'search_pages' ),
'jet_theme_search_cats' => array( $this, 'search_cats' ),
'jet_theme_search_tags' => array( $this, 'search_tags' ),
'jet_theme_search_terms' => array( $this, 'search_terms' ),
);
foreach ( $priv_actions as $tag => $callback ) {
add_action( 'wp_ajax_' . $tag, $callback );
}
}
/**
* Serch page
*
* @return [type] [description]
*/
public function search_pages() {
if ( ! current_user_can( 'edit_posts' ) ) {
wp_send_json( array() );
}
$query = isset( $_GET['q'] ) ? esc_attr( $_GET['q'] ) : '';
wp_send_json( array(
'results' => Jet_Theme_Core_Utils::search_posts_by_type( 'page', $query ),
) );
}
/**
* Serch post
*
* @return [type] [description]
*/
public function search_posts() {
if ( ! current_user_can( 'edit_posts' ) ) {
wp_send_json( array() );
}
$query = isset( $_GET['q'] ) ? esc_attr( $_GET['q'] ) : '';
$post_type = isset( $_GET['preview_post_type'] ) ? esc_attr( $_GET['preview_post_type'] ) : 'post';
wp_send_json( array(
'results' => Jet_Theme_Core_Utils::search_posts_by_type( $post_type, $query ),
) );
}
/**
* Serch category
*
* @return [type] [description]
*/
public function search_cats() {
if ( ! current_user_can( 'edit_posts' ) ) {
wp_send_json( array() );
}
$query = isset( $_GET['q'] ) ? esc_attr( $_GET['q'] ) : '';
wp_send_json( array(
'results' => Jet_Theme_Core_Utils::search_terms_by_tax( 'category', $query ),
) );
}
/**
* Serch tag
*
* @return [type] [description]
*/
public function search_tags() {
if ( ! current_user_can( 'edit_posts' ) ) {
wp_send_json( array() );
}
$query = isset( $_GET['q'] ) ? esc_attr( $_GET['q'] ) : '';
wp_send_json( array(
'results' => Jet_Theme_Core_Utils::search_terms_by_tax( 'post_tag', $query ),
) );
}
/**
* Serach terms from passed taxonomies
* @return [type] [description]
*/
public function search_terms() {
if ( ! current_user_can( 'edit_posts' ) ) {
wp_send_json( array() );
}
$query = isset( $_GET['q'] ) ? esc_attr( $_GET['q'] ) : '';
$tax = isset( $_GET['conditions_archive-tax_tax'] ) ? $_GET['conditions_archive-tax_tax'] : '';
$tax = explode( ',', $tax );
wp_send_json( array(
'results' => Jet_Theme_Core_Utils::search_terms_by_tax( $tax, $query ),
) );
}
}
}

View File

@@ -0,0 +1,376 @@
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_API' ) ) {
/**
* Define Jet_Theme_Core_API class
*/
class Jet_Theme_Core_API {
private $config = array();
private $enabled = null;
private $error_message = '';
/**
* Constructor for the class
*/
function __construct() {
$this->config = jet_theme_core()->config->get( 'api' );
}
/**
* Check if remote API is enabled
*
* @return boolean [description]
*/
public function is_enabled() {
if ( null !== $this->enabled ) {
return $this->enabled;
}
if ( empty( $this->config['enabled'] ) || true !== $this->config['enabled'] ) {
$this->enabled = false;
return $this->enabled;
}
if ( empty( $this->config['base'] ) || empty( $this->config['path'] ) || empty( $this->config['endpoints'] ) ) {
$this->enabled = false;
return $this->enabled;
}
$this->enabled = true;
return $this->enabled;
}
/**
* Retrieve URL to spescific endpoint.
*
* @param [type] $for [description]
* @return [type] [description]
*/
public function api_url( $for ) {
if ( ! $this->is_enabled() ) {
return false;
}
if ( empty( $this->config['endpoints'][ $for ] ) ) {
return false;
}
return $this->config['base'] . $this->config['path'] . $this->config['endpoints'][ $for ];
}
/**
* Returns API base URL
*
* @return string
*/
public function api_base() {
if ( ! $this->is_enabled() ) {
return apply_filters( 'jet-theme-core/api/base-url', false );
}
$base_url = $this->config['base'];
return apply_filters( 'jet-theme-core/api/base-url', $base_url );
}
/**
* Retrieve request arguments for API request
*
* @return array
*/
public function request_args() {
return array(
'timeout' => 60,
'sslverify' => false
);
}
/**
* Get remote system info by key.
*
* @param string|array $key [description]
* @return [type] [description]
*/
public function get_info( $key = '' ) {
$api_url = $this->api_url( 'info' );
if ( ! $api_url ) {
return false;
}
$response = wp_remote_get( $api_url, $this->request_args() );
$body = wp_remote_retrieve_body( $response );
$body = json_decode( $body, true );
if ( ! $body || ! isset( $body['success'] ) || true !== $body['success'] ) {
return false;
}
if ( ! $key ) {
unset( $body['success'] );
return $body;
}
if ( is_string( $key ) ) {
return isset( $body[ $key ] ) ? $body[ $key ] : false;
}
if ( is_array( $key ) ) {
$result = array();
foreach ( $key as $_key ) {
$result[ $_key ] = isset( $body[ $_key ] ) ? $body[ $_key ] : false;
}
return $result;
}
}
/**
* Try to activate passed license key for current server
*
* @param string $license [description]
* @return [type] [description]
*/
public function acitvate_license( $license = '' ) {
if ( ! $this->is_enabled() ) {
return $this->set_error( esc_html__( 'Remote API is disabled.', 'jet-theme-core' ) );
}
if ( empty( $license ) ) {
return $this->set_error( esc_html__( 'Empty license key.', 'jet-theme-core' ) );
}
$response = $this->license_request( 'activate_license', $license );
$result = wp_remote_retrieve_body( $response );
$result = json_decode( $result, true );
if ( ! isset( $result['success'] ) ) {
return $this->set_error( esc_html__( 'Internal error, please try again later.', 'jet-theme-core' ) );
}
if ( true === $result['success'] ) {
if ( 'valid' === $result['license'] ) {
return true;
} else {
return $this->set_error( null, 'default' );
}
} else {
if ( ! empty( $result['error'] ) ) {
return $this->set_error( null, $result['error'] );
} else {
return $this->set_error( null, 'default' );
}
}
}
/**
* Try to deactivate passed license key for current server
*
* @param string $license [description]
* @return [type] [description]
*/
public function deacitvate_license( $license = '' ) {
if ( ! $this->is_enabled() ) {
return $this->set_error( esc_html__( 'Remote API is disabled.', 'jet-theme-core' ) );
}
if ( empty( $license ) ) {
return $this->set_error( esc_html__( 'Empty license key.', 'jet-theme-core' ) );
}
$response = $this->license_request( 'deactivate_license', $license );
$result = wp_remote_retrieve_body( $response );
$result = json_decode( $result, true );
if ( ! isset( $result['success'] ) ) {
return $this->set_error( esc_html__( 'Internal error, please try again later.', 'jet-theme-core' ) );
}
if ( true === $result['success'] ) {
return true;
} else {
if ( ! empty( $result['error'] ) ) {
return $this->set_error( null, $result['error'] );
} else {
return $this->set_error( null, 'default' );
}
}
}
/**
* Retrirve error message by error code
*
* @return string
*/
public function get_error_by_code( $code ) {
$messages = array(
'missing' => __( 'Your license is missing. Please check your key again.', 'jet-theme-core' ),
'no_activations_left' => sprintf( __( '<strong>You have no more activations left.</strong> <a href="%s" target="_blank">Please upgrade to a more advanced license</a> (you\'ll only need to cover the difference).', 'jet-theme-core' ), $this->upgrade_url() ),
'expired' => sprintf( __( '<strong>Your License Has Expired.</strong> <a href="%s" target="_blank">Renew your license today</a> to keep getting feature updates, premium support and unlimited access to the template library.', 'jet-theme-core' ), $this->renew_url() ),
'revoked' => __( '<strong>Your license key has been cancelled</strong> (most likely due to a refund request). Please consider acquiring a new license.', 'jet-theme-core' ),
'disabled' => __( '<strong>Your license key has been cancelled</strong> (most likely due to a refund request). Please consider acquiring a new license.', 'jet-theme-core' ),
'invalid' => __( '<strong>Your license key doesn\'t match your current domain</strong>. This is most likely due to a change in the domain URL of your site (including HTTPS/SSL migration). Please deactivate the license and then reactivate it again.', 'jet-theme-core' ),
'site_inactive' => __( '<strong>Your license key doesn\'t match your current domain</strong>. This is most likely due to a change in the domain URL. Please deactivate the license and then reactivate it again.', 'jet-theme-core' ),
'inactive' => __( '<strong>Your license key doesn\'t match your current domain</strong>. This is most likely due to a change in the domain URL of your site (including HTTPS/SSL migration). Please deactivate the license and then reactivate it again.', 'jet-theme-core' ),
);
$default = __( 'An error occurred. Please check your internet connection and try again. If the problem persists, contact our support.', 'jet-theme-core' );
return isset( $messages[ $code ] ) ? $messages[ $code ] : $default;
}
/**
* Returns upgrade URL
*
* @return string
*/
public function upgrade_url() {
return $this->config['base'];
}
/**
* Returns upgrade URL
*
* @return string
*/
public function renew_url() {
return $this->config['base'];
}
/**
* Set error message and return false.
*
* @param [type] $message [description]
*/
public function set_error( $message, $code = null ) {
if ( ! $code ) {
$this->error_message = $message;
} else {
$this->error_message = $this->get_error_by_code( $code );
}
return false;
}
/**
* Returns error message
*
* @return [type] [description]
*/
public function get_activation_error() {
return $this->error_message;
}
/**
* Perform a remote request with passed action for passed license key
*
* @param string $action EDD action to perform (activate_license, check_license etc)
* @param string $license License key
* @return WP_Error|array
*/
public function license_request( $action, $license ) {
$url = add_query_arg(
array(
'edd_action' => $action,
'item_id' => ( ! empty( $this->config['id'] ) ? $this->config['id'] : false ),
'license' => $license,
'url' => urlencode( home_url( '/' ) ),
),
$this->config['base']
);
$args = apply_filters( 'jet-theme-core/license-request/args', $this->request_args() );
return wp_remote_get( $url, $args );
}
/**
* Check status for passed license key
*
* @param string $license License key to check.
* @return string
*/
public function license_status( $license ) {
if ( ! $this->is_enabled() ) {
return array(
'success' => false,
'message' => esc_html__( 'Remote API is disabled', 'jet-theme-core' ),
);
}
if ( empty( $license ) ) {
return array(
'success' => false,
'message' => esc_html__( 'Empty license key', 'jet-theme-core' ),
);
}
$response = $this->license_request( 'check_license', $license );
$result = wp_remote_retrieve_body( $response );
$result = json_decode( $result, true );
if ( ! isset( $result['success'] ) ) {
return array(
'success' => false,
'message' => $this->get_error_by_code( 'default' ),
);
}
if ( true === $result['success'] && 'valid' === $result['license'] ) {
return array(
'success' => true,
'message' => esc_html__( 'Active', 'jet-theme-core' ),
);
} else {
$code = isset( $result['error'] ) ? $result['error'] : $result['license'];
return array(
'success' => false,
'message' => $this->get_error_by_code( $code ),
);
}
}
}
}

View File

@@ -0,0 +1,235 @@
<?php
/**
* Class description
*
* @package package_name
* @author Cherry Team
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Assets' ) ) {
/**
* Define Jet_Theme_Core_Assets class
*/
class Jet_Theme_Core_Assets {
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
public function __construct() {
add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'editor_scripts' ), 0 );
add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_styles' ) );
add_action( 'elementor/editor/footer', array( $this, 'print_templates' ) );
add_action( 'elementor/preview/enqueue_styles', array( $this, 'preview_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'template_type_form_assets' ) );
}
public function suffix() {
return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
}
/**
* Template type popup assets
*
* @return void
*/
public function template_type_form_assets() {
$screen = get_current_screen();
if ( $screen->id !== 'edit-' . jet_theme_core()->templates->slug() ) {
return;
}
wp_enqueue_script(
'jet-templates-type-form',
jet_theme_core()->plugin_url( 'assets/js/templates-type' . $this->suffix() . '.js' ),
array( 'jquery' ),
jet_theme_core()->get_version(),
true
);
wp_enqueue_style(
'jet-templates-type-form',
jet_theme_core()->plugin_url( 'assets/css/templates-type.css' ),
array(),
jet_theme_core()->get_version()
);
add_action( 'admin_footer', array( $this, 'print_template_types_popup' ), 999 );
}
/**
* Print template type form HTML
*
* @return void
*/
public function print_template_types_popup() {
$template_types = jet_theme_core()->templates_manager->get_library_types();
$default_option = array(
'' => esc_html__( 'Select...', $domain = 'default' )
);
$template_types = $default_option + $template_types;
$selected = isset( $_GET[ jet_theme_core()->templates->type_tax ] ) ? $_GET[ jet_theme_core()->templates->type_tax ] : '';
$action = add_query_arg(
array(
'action' => 'jet_create_new_template',
),
esc_url( admin_url( 'admin.php' ) )
);
include jet_theme_core()->get_template( 'template-types-popup.php' );
}
/**
* Load preview assets
*
* @return void
*/
public function preview_styles() {
wp_enqueue_style(
'jet-theme-core-preview',
jet_theme_core()->plugin_url( 'assets/css/preview.css' ),
array(),
jet_theme_core()->get_version()
);
}
/**
* Enqueue elemnetor editor scripts
*
* @return void
*/
public function editor_scripts() {
wp_enqueue_script(
'jet-theme-core-editor',
jet_theme_core()->plugin_url( 'assets/js/editor' . $this->suffix() . '.js' ),
array( 'jquery', 'underscore', 'backbone-marionette' ),
jet_theme_core()->get_version(),
true
);
$icon = $this->get_library_icon();
$button = jet_theme_core()->config->get( 'library_button' );
wp_localize_script( 'jet-theme-core-editor', 'JetThemeCoreData', apply_filters(
'jet-theme-core/assets/editor/localize',
array(
'libraryButton' => ( false !== $button ) ? $icon . $button : false,
'modalRegions' => $this->get_modal_regions(),
'license' => array(
'activated' => true,
'link' => '',
),
)
) );
}
/**
* Returns modal regions
* @return [type] [description]
*/
public function get_modal_regions() {
if ( defined( 'ELEMENTOR_VERSION' ) && version_compare( ELEMENTOR_VERSION, '2.1.0-beta1', '>=' ) ) {
return array(
'modalHeader' => '.dialog-header',
'modalContent' => '.dialog-message',
);
} else {
return array(
'modalContent' => '.dialog-message',
'modalHeader' => '.dialog-widget-header',
);
}
}
/**
* Get library icon markup
*
* @return string
*/
public function get_library_icon() {
ob_start();
include jet_theme_core()->plugin_path( 'assets/img/library-icon.svg' );
$icon = ob_get_clean();
return apply_filters( 'jet-theme-core/library-button/icon', $icon );
}
/**
* Enqueue elemnetor editor-related styles
*
* @return void
*/
public function editor_styles() {
wp_enqueue_style(
'jet-theme-core-editor',
jet_theme_core()->plugin_url( 'assets/css/editor.css' ),
array(),
jet_theme_core()->get_version()
);
}
/**
* Prints editor templates
*
* @return void
*/
public function print_templates() {
foreach ( glob( jet_theme_core()->plugin_path( 'templates/editor/*.php' ) ) as $file ) {
$name = basename( $file, '.php' );
ob_start();
include $file;
printf( '<script type="text/html" id="tmpl-jet-%1$s">%2$s</script>', $name, ob_get_clean() );
}
}
/**
* 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,461 @@
<?php
/**
* Class description
*
* @package package_name
* @author Cherry Team
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Backups' ) ) {
/**
* Define Jet_Theme_Core_Backups class
*/
class Jet_Theme_Core_Backups {
/**
* Path to backup file
* @var string
*/
public $path;
/**
* Theme files to backup
* @var array
*/
public $files = array();
/**
* Messages holder
* @var string
*/
public $message = null;
/**
* A reference to an instance of this class.
*
* @since 1.0.0
* @var object
*/
private static $instance = null;
/**
* Constructor for the class
*/
public function __construct() {
// connect filesystem
$this->fs_connect();
// set path
$upload_dir = wp_upload_dir();
$upload_base_dir = $upload_dir['basedir'];
$this->path = trailingslashit( $upload_base_dir ) . 'kava-backups';
}
/**
* Try to create backup archive
*
* @since 1.0.0
* @return bool
*/
public function make_backup( $theme, $version ) {
global $wp_filesystem;
if ( ! current_user_can( 'manage_options' ) ) {
return false;
}
include_once( ABSPATH . '/wp-admin/includes/class-pclzip.php' );
if ( ! $this->check_path() ) {
return false;
}
$this->protect_path();
ini_set( 'max_execution_time', -1 );
set_time_limit( 0 );
$zip_name = $this->path . '/' . $theme . '-' . $version . '.zip';
$files = $this->get_files( $theme );
$files = implode( ',', $files );
$remove_path = $wp_filesystem->wp_themes_dir();
$zip = new PclZip( $zip_name );
$result = $zip->create( $files, PCLZIP_OPT_REMOVE_PATH, $remove_path );
if ( ! $result ) {
return false;
}
return str_replace( ABSPATH, home_url( '/' ), $zip_name );
}
/**
* Get backup files list
*
* @since 1.0.0
* @return array
*/
public function get_files( $theme ) {
global $wp_filesystem;
$path = $wp_filesystem->wp_themes_dir() . $theme;
$this->parse_dir( $path );
return $this->files;
}
/**
* Recursive function, that parse passed directory and add found files into 'file' property.
*
* @since 1.0.0
* @param string $dir path to directory to search files in.
* @return void|bool false
*/
public function parse_dir( $dir ) {
global $wp_filesystem;
$files = $wp_filesystem->dirlist( $dir );
if ( ! is_array( $files ) ) {
return false;
}
foreach ( $wp_filesystem->dirlist( $dir ) as $name => $data ) {
$current_path = trailingslashit( $dir ) . $name;
if ( 'd' == $data['type'] ) {
$this->parse_dir( $current_path );
continue;
}
$this->files[] = $current_path;
}
}
/**
* Check if backup directory exists and create it if not
*
* @since 1.0.0
* @return bool
*/
public function check_path() {
global $wp_filesystem;
$path = $this->prepare_path( $this->path );
if ( $wp_filesystem->exists( $path ) ) {
return true;
}
return $wp_filesystem->mkdir( $path );
}
/**
* Create .htaccess file in updates backup dir to protect it from direct access
*
* @since 1.0.0
* @return void|bool
*/
public function protect_path() {
global $wp_filesystem;
$path = $this->prepare_path( $this->path );
$file = $path . '/.htaccess';
if ( $wp_filesystem->exists( $file ) ) {
return true;
}
$wp_filesystem->put_contents( $file, 'deny from all' );
}
/**
* Prepeare path for using with filesystem API
*
* @since 1.0.0
* @param string $path path to prepare.
* @return string
*/
public function prepare_path( $path ) {
global $wp_filesystem;
return str_replace( ABSPATH, $wp_filesystem->abspath(), $path );
}
/**
* Get avaliable backups list
*
* @since 1.0.0
* @return array
*/
public function get_backups() {
global $wp_filesystem;
$path = $this->prepare_path( $this->path );
$files = $wp_filesystem->dirlist( $path );
$result = array();
if ( ! is_array( $files ) ) {
return $result;
}
if ( isset( $files['.htaccess'] ) ) {
unset( $files['.htaccess'] );
}
foreach ( $files as $file => $data ) {
if ( 'zip' !== pathinfo( $file, PATHINFO_EXTENSION ) ) {
continue;
}
$result[] = array(
'name' => $file,
'date' => date( 'M d Y, H:i', $data['lastmodunix'] ),
);
}
usort( $result, array( $this, 'date_compare' ) );
return $result;
}
/**
* Compare backups by date
*
* @since 1.0.0
* @param array $a 1st value.
* @param array $b 2nd value.
* @return bool
*/
public function date_compare( $a, $b ) {
$t1 = strtotime( $a['date'] );
$t2 = strtotime( $b['date'] );
return $t2 - $t1;
}
/**
* Download backup by filename
*
* @since 1.0.0
* @param string $file backup filename.
* @return void|bool false
*/
public function download_backup( $file ) {
if ( ! current_user_can( 'manage_options' ) ) {
$this->message = __( 'Permission denied', 'jet-theme-core' );
return false;
}
global $wp_filesystem;
$path = $this->prepare_path( $this->path );
$filepath = $path . '/' . $file;
if ( ! $wp_filesystem->exists( $filepath ) ) {
$this->message = __( 'File not exists', 'jet-theme-core' );
return false;
}
session_write_close();
header( 'Pragma: public' );
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Cache-Control: public' );
header( 'Content-Description: File Transfer' );
header( 'Content-type: application/octet-stream' );
header( 'Content-Disposition: attachment; filename="' . $file . '"' );
header( 'Content-Transfer-Encoding: binary' );
header( 'Content-Length: ' . @filesize( $filepath ) );
$this->readfile_chunked( $filepath ) or header( 'Location: ' . $filepath );
exit();
}
/**
* Delete existing backup by filename
*
* @since 1.0.0
* @param string $file backup filename.
* @return bool
*/
public function delete_backup( $file ) {
if ( ! current_user_can( 'manage_options' ) ) {
$this->message = __( 'Permission denied', 'jet-theme-core' );
return false;
}
global $wp_filesystem;
$path = $this->prepare_path( $this->path );
$filepath = $path . '/' . $file;
if ( ! $wp_filesystem->exists( $filepath ) ) {
$this->message = __( 'File not exists', 'jet-theme-core' );
return false;
}
$delete = $wp_filesystem->delete( $filepath );
if ( false === $delete ) {
$this->message = __( 'Can\'t delete selected backup', 'jet-theme-core' );
}
return $delete;
}
/**
* Chunked file reading
*
* @since 1.0.0
* @param string $file fileptah.
* @param boolean $retbytes return bytes number or not.
* @return bool|int
*/
public function readfile_chunked( $file, $retbytes = true ) {
$chunksize = 1024 * 1024;
$buffer = '';
$cnt = 0;
$handle = @fopen( $file, 'r' );
if ( $size = @filesize( $file ) ) {
header( 'Content-Length: ' . $size );
}
if ( false === $handle ) {
return false;
}
while ( ! @feof( $handle ) ) {
$buffer = @fread( $handle, $chunksize );
echo $buffer;
ob_flush();
flush();
if ( $retbytes ) {
$cnt += strlen( $buffer );
}
}
$status = @fclose( $handle );
if ( $retbytes && $status ) {
return $cnt;
}
return $status;
}
/**
* Check if backup manager returned any messages during processing
*
* @since 1.0.0
* @return string
*/
public function get_message() {
return (string) $this->message;
}
/**
* Connect to the filesystem.
*
* @since 1.0.0
*
* @param array $directories Optional. A list of directories. If any of these do
* not exist, a {@see WP_Error} object will be returned.
* Default empty array.
* @param bool $allow_relaxed_file_ownership Whether to allow relaxed file ownership.
* Default false.
* @return bool|WP_Error True if able to connect, false or a {@see WP_Error} otherwise.
*/
public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) {
global $wp_filesystem;
if ( ! function_exists( 'request_filesystem_credentials' ) ) {
include_once ( ABSPATH . '/wp-admin/includes/file.php' );
}
$url = admin_url( 'options.php' );
if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, false, array(), $allow_relaxed_file_ownership ) ) ) {
return false;
}
if ( ! empty( $directories[0] ) ) {
$dirs = $directories[0];
} else {
$dirs = array();
}
if ( ! WP_Filesystem( $credentials, $dirs, $allow_relaxed_file_ownership ) ) {
$error = true;
if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->get_error_code() ) {
$error = $wp_filesystem->errors;
}
return false;
}
if ( ! is_object( $wp_filesystem ) ) {
return new WP_Error( 'fs_unavailable', $this->strings['fs_unavailable'] );
}
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors );
}
foreach ( (array) $directories as $dir ) {
switch ( $dir ) {
case ABSPATH:
if ( ! $wp_filesystem->abspath() ) {
return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] );
}
break;
case WP_CONTENT_DIR:
if ( ! $wp_filesystem->wp_content_dir() ) {
return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
}
break;
case WP_PLUGIN_DIR:
if ( ! $wp_filesystem->wp_plugins_dir() ) {
return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] );
}
break;
case get_theme_root():
if ( ! $wp_filesystem->wp_themes_dir() ) {
return new WP_Error( 'fs_no_themes_dir', $this->strings['fs_no_themes_dir'] );
}
break;
default:
if ( ! $wp_filesystem->find_folder( $dir ) ) {
return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) );
}
break;
}
}
return true;
}
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Archive_All' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Archive_All class
*/
class Jet_Theme_Core_Conditions_Archive_All extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'archive-all';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'All Archives', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'archive';
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
return is_archive();
}
}
}

View File

@@ -0,0 +1,122 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Archive_Category' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Archive_Category class
*/
class Jet_Theme_Core_Conditions_Archive_Category extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'archive-category';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Category Archives', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'archive';
}
public function get_controls() {
return array(
'cats' => array(
'label' => __( 'Select Categories', 'jet-theme-core' ),
'type' => 'jet_search',
'action' => 'jet_theme_search_cats',
'label_block' => true,
'multiple' => true,
'description' => __( 'Leave empty to apply for all categories', 'jet-theme-core' ),
'saved' => $this->get_saved_cats(),
),
);
}
public function get_saved_cats() {
$template_id = get_the_ID();
$saved = get_post_meta( $template_id, '_elementor_page_settings', true );
if ( ! empty( $saved['conditions_archive-category_cats'] ) ) {
$terms = get_terms( array(
'include' => $saved['conditions_archive-category_cats'],
'taxonomy' => 'category',
'hide_empty' => false,
) );
if ( empty( $terms ) ) {
return array();
} else {
return wp_list_pluck( $terms, 'name', 'term_id' );
}
} else {
return array();
}
}
public function verbose_args( $args ) {
if ( empty( $args['cats'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
$terms = get_terms( array(
'include' => $args['cats'],
'taxonomy' => 'category',
'hide_empty' => false,
) );
foreach ( $terms as $term ) {
$result .= $sep . $term->name;
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['cats'] ) ) {
return is_category();
}
return is_category( $args['cats'] );
}
}
}

View File

@@ -0,0 +1,98 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Archive_Post_Type' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Archive_Post_Type class
*/
class Jet_Theme_Core_Conditions_Archive_Post_Type extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'archive-post-type';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Post Type Archives', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'archive';
}
public function get_controls() {
return array(
'types' => array(
'label' => esc_html__( 'Post Type', 'jet-theme-core' ),
'type' => Elementor\Controls_Manager::SELECT2,
'default' => 'post',
'options' => Jet_Theme_Core_Utils::get_post_types(),
'multiple' => true,
),
);
}
public function verbose_args( $args ) {
if ( empty( $args['types'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
foreach ( $args['types'] as $post_type ) {
$obj = get_post_type_object( $post_type );
$label = ! empty( $obj ) ? $obj->labels->singular_name : $post_type;
$result .= $sep . $label;
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['types'] ) ) {
return is_post_type_archive();
}
$types = $args['types'];
if ( in_array( 'post', $types ) && 'post' === get_post_type() ) {
return is_archive() || is_home();
}
return is_post_type_archive( $types ) || ( is_tax() && in_array( get_post_type(), $types ) );
}
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Archive_Search' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Archive_Search class
*/
class Jet_Theme_Core_Conditions_Archive_Search extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'archive-search';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Search Results', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'archive';
}
public function get_controls() {
return array();
}
public function verbose_args( $args ) {
return '';
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
return is_search();
}
}
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Archive_Tag' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Archive_Tag class
*/
class Jet_Theme_Core_Conditions_Archive_Tag extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'archive-tag';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Tag Archives', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'archive';
}
public function get_controls() {
return array(
'tags' => array(
'label' => __( 'Select Tags', 'jet-theme-core' ),
'type' => 'jet_search',
'action' => 'jet_theme_search_tags',
'label_block' => true,
'multiple' => true,
'description' => __( 'Leave empty to apply for all tags', 'jet-theme-core' ),
'saved' => $this->get_saved_tags(),
),
);
}
public function get_saved_tags() {
$template_id = get_the_ID();
$saved = get_post_meta( $template_id, '_elementor_page_settings', true );
if ( ! empty( $saved['conditions_archive-tag_tags'] ) ) {
$terms = get_terms( array(
'include' => $saved['conditions_archive-tag_tags'],
'taxonomy' => 'post_tag',
'hide_empty' => false,
) );
if ( empty( $terms ) ) {
return array();
} else {
return wp_list_pluck( $terms, 'name', 'term_id' );
}
} else {
return array();
}
}
public function verbose_args( $args ) {
if ( empty( $args['tags'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
$terms = get_terms( array(
'include' => $args['tags'],
'taxonomy' => 'post_tag',
'hide_empty' => false,
) );
foreach ( $terms as $term ) {
$result .= $sep . $term->name;
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['tags'] ) ) {
return is_tag();
}
return is_tag( $args['tags'] );
}
}
}

View File

@@ -0,0 +1,144 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Archive_Tax' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Archive_Tax class
*/
class Jet_Theme_Core_Conditions_Archive_Tax extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'archive-tax';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Custom Taxonomy Archives', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'archive';
}
public function get_controls() {
return array(
'tax' => array(
'label' => esc_html__( 'Taxonomy', 'jet-theme-core' ),
'type' => Elementor\Controls_Manager::SELECT2,
'default' => '',
'options' => Jet_Theme_Core_Utils::get_taxonomies(),
'multiple' => true,
),
'terms' => array(
'label' => __( 'Select Terms', 'jet-theme-core' ),
'type' => 'jet_search',
'action' => 'jet_theme_search_terms',
'query_params' => array( 'conditions_archive-tax_tax' ),
'label_block' => true,
'multiple' => true,
'description' => __( 'Leave empty to apply for all terms', 'jet-theme-core' ),
'saved' => $this->get_saved_tags(),
),
);
}
public function get_saved_tags() {
$template_id = get_the_ID();
$saved = get_post_meta( $template_id, '_elementor_page_settings', true );
if ( empty( $saved['conditions_archive-tax_tax'] ) ) {
return array();
}
$tax = $saved['conditions_archive-tax_tax'];
if ( ! empty( $saved['conditions_archive-tax_terms'] ) ) {
$terms = get_terms( array(
'include' => $saved['conditions_archive-tax_terms'],
'taxonomy' => $tax,
'hide_empty' => false,
) );
if ( empty( $terms ) ) {
return array();
} else {
return wp_list_pluck( $terms, 'name', 'term_id' );
}
} else {
return array();
}
}
public function verbose_args( $args ) {
if ( empty( $args['tax'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
$terms = get_terms( array(
'include' => $args['tax'],
'taxonomy' => 'post_tag',
'hide_empty' => false,
) );
foreach ( $terms as $term ) {
$result .= $sep . $term->name;
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['tax'] ) ) {
return is_tax();
}
if ( ! empty( $args['tax'] ) && empty( $args['terms'] ) ) {
return is_tax( $args['tax'] );
}
if ( ! empty( $args['terms'] ) ) {
return is_tax( $args['tax'], $args['terms'] );
}
}
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* Class description
*
* @package package_name
* @author Cherry Team
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Base' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Base class
*/
abstract class Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
abstract public function get_id();
/**
* Condition label
*
* @return string
*/
abstract public function get_label();
/**
* Condition group
*
* @return string
*/
abstract public function get_group();
/**
* Condition check callback
*
* @return bool
*/
abstract public function check( $args );
/**
* Returns parent codition ID for current condition
*
* @return array
*/
public function get_childs() {
return array();
}
/**
* Returns parent codition ID for current condition
*
* @return array
*/
public function get_controls() {
return array();
}
/**
* Returns human-reading information about active arguments for condition
*
* @param arrayu $args
* @return string
*/
public function verbose_args( $args ) {
return '';
}
}
}

View File

@@ -0,0 +1,557 @@
<?php
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Manager' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Manager class
*/
class Jet_Theme_Core_Conditions_Manager {
private $_conditions = array();
private $_matched_conditions = array();
private $_processed_childs = array();
public $conditions_key = 'jet_site_conditions';
public function __construct() {
$this->register_conditions();
add_action( 'elementor/editor/after_save', array( $this, 'update_site_conditions' ) );
add_action( 'wp_trash_post', array( $this, 'remove_post_from_site_conditions' ) );
}
public function update_site_conditions( $post_id ) {
$post = get_post( $post_id );
if ( jet_theme_core()->templates->slug() !== $post->post_type ) {
return;
}
$type = get_post_meta( $post_id, '_elementor_template_type', true );
$sanitized = $this->get_post_conditions( $post_id );
$saved = get_option( $this->conditions_key, array() );
$saved = $this->remove_post_from_conditions_array( $post_id, $saved );
if ( ! isset( $saved[ $type ] ) ) {
$saved[ $type ] = array();
}
$saved[ $type ][ $post_id ] = $sanitized;
update_option( $this->conditions_key, $saved, true );
}
public function get_site_conditions() {
return get_option( $this->conditions_key, array() );
}
public function get_post_conditions( $post_id ) {
$group = '';
$conditions = get_post_meta( $post_id, '_elementor_page_settings', true );
$sanitized = array();
if ( ! $conditions ) {
$conditions = array();
}
foreach ( $conditions as $condition => $value ) {
if ( false === strpos( $condition, 'conditions_' ) ) {
continue;
}
if ( 'conditions_top' === $condition ) {
$group = $value;
$sanitized['main'] = $group;
continue;
}
if ( 'conditions_sub_' . $group === $condition ) {
$sanitized[ $value ] = $this->get_condition_args( $value, $conditions );
continue;
}
}
return $sanitized;
}
/**
* Check if post currently presented in conditions array and remove it if yes.
*
* @param integer $post_id [description]
* @param array $conditions [description]
* @return [type] [description]
*/
public function remove_post_from_conditions_array( $post_id = 0, $conditions = array() ) {
foreach ( $conditions as $type => $type_conditions ) {
if ( array_key_exists( $post_id, $type_conditions ) ) {
unset( $conditions[ $type ][ $post_id ] );
}
}
return $conditions;
}
public function remove_post_from_site_conditions( $post_id = 0 ) {
$conditions = get_option( $this->conditions_key, array() );
$conditions = $this->remove_post_from_conditions_array( $post_id, $conditions );
update_option( $this->conditions_key, $conditions, true );
}
/**
* Find condition arguments in saved data
*
* @param [type] $cid [description]
* @param [type] $conditions [description]
* @return [type] [description]
*/
public function get_condition_args( $cid, $conditions ) {
$args = array();
$prefix = 'conditions_' . $cid . '_';
foreach ( $conditions as $condition => $value ) {
if ( false === strpos( $condition, $prefix ) ) {
continue;
}
$args[ str_replace( $prefix, '', $condition ) ] = $value;
}
return $args;
}
public function register_conditions() {
$base_path = jet_theme_core()->plugin_path( 'includes/conditions/' );
require $base_path . 'base.php';
$default = array(
// Singular conditions
'Jet_Theme_Core_Conditions_Front' => $base_path . 'singular-front-page.php',
'Jet_Theme_Core_Conditions_Singular_Post_Type' => $base_path . 'singular-post-type.php',
'Jet_Theme_Core_Conditions_Singular_Post' => $base_path . 'singular-post.php',
'Jet_Theme_Core_Conditions_Singular_Post_From_Category' => $base_path . 'singular-post-from-cat.php',
'Jet_Theme_Core_Conditions_Singular_Post_From_Tag' => $base_path . 'singular-post-from-tag.php',
'Jet_Theme_Core_Conditions_Singular_Page' => $base_path . 'singular-page.php',
'Jet_Theme_Core_Conditions_Singular_Page_Child' => $base_path . 'singular-page-child.php',
'Jet_Theme_Core_Conditions_Singular_Page_Template' => $base_path . 'singular-page-template.php',
'Jet_Theme_Core_Conditions_Singular_404' => $base_path . 'singular-404.php',
// Archive conditions
'Jet_Theme_Core_Conditions_Archive_All' => $base_path . 'archive-all.php',
'Jet_Theme_Core_Conditions_Archive_Post_Type' => $base_path . 'archive-post-type.php',
'Jet_Theme_Core_Conditions_Archive_Category' => $base_path . 'archive-category.php',
'Jet_Theme_Core_Conditions_Archive_Tag' => $base_path . 'archive-tag.php',
'Jet_Theme_Core_Conditions_Archive_Tax' => $base_path . 'archive-tax.php',
'Jet_Theme_Core_Conditions_Archive_Search' => $base_path . 'archive-search.php',
);
foreach ( $default as $class => $file ) {
require $file;
$this->register_condition( $class );
}
/**
* You could register custom conditions on this hook.
* Note - each condition should be presented like instance of class 'Jet_Theme_Core_Conditions_Base'
*/
do_action( 'jet-theme-core/conditions/register', $this );
}
public function register_condition( $class ) {
$instance = new $class;
$this->_conditions[ $instance->get_id() ] = $instance;
}
public function get_condition( $condition_id ) {
return isset( $this->_conditions[ $condition_id ] ) ? $this->_conditions[ $condition_id ] : false;
}
/**
* Returns conditions groups
*
* @return void
*/
public function get_groups() {
return array(
'entire' => __( 'Entire Site', 'jet-theme-core' ),
'singular' => __( 'Singular', 'jet-theme-core' ),
'archive' => __( 'Archive', 'jet-theme-core' ),
);
}
/**
* Regsiter apropriate condition controls
*
* @return [type] [description]
*/
public function register_condition_controls( $controls_manager ) {
if ( ! $controls_manager ) {
return;
}
$prepared_data = $this->prepare_conditions_for_controls();
$default = array( '' => esc_html__( 'Select...', 'jet-theme-core' ) );
$general = $default + $this->get_groups();
$controls_manager->add_control(
'conditions_top',
array(
'label' => esc_html__( 'General', 'jet-theme-core' ),
'type' => Elementor\Controls_Manager::SELECT,
'default' => '',
'options' => $general,
)
);
foreach ( $prepared_data as $group => $options ) {
if ( empty( $options ) ) {
continue;
}
$condition = array(
'conditions_top' => $group,
);
$control_name = 'conditions_sub_' . $group;
$controls_manager->add_control(
$control_name,
array(
'label' => $general[ $group ],
'type' => Elementor\Controls_Manager::SELECT,
'default' => '',
'options' => $this->esc_options( $options ),
'condition' => $condition,
)
);
$this->register_child_options_group( $options, $controls_manager, $control_name, $condition );
}
}
/**
* Get options list from options data
*
* @param [type] $data [description]
* @return [type] [description]
*/
public function esc_options( $data ) {
$result = array();
foreach ( $data as $id => $item ) {
$result[ $id ] = $item['label'];
}
return $result;
}
public function esc_child_options( $childs ) {
$result = array();
foreach ( $childs as $child ) {
$instance = $this->get_condition( $child );
$result[ $child ] = $instance->get_label();
}
return $result;
}
public function register_child_options_group( $options, $controls_manager, $parent_id, $parent_condition ) {
foreach ( $options as $cid => $data ) {
$this->register_child_controls( $cid, $controls_manager, $parent_id, $parent_condition );
if ( empty( $data['childs'] ) ) {
continue;
}
$condition = array_merge(
$parent_condition,
array(
$parent_id => $cid
)
);
$instance = $this->get_condition( $cid );
$control_name = 'conditions_sub_' . $cid;
$controls_manager->add_control(
$control_name,
array(
'label' => $instance->get_label(),
'type' => Elementor\Controls_Manager::SELECT,
'default' => '',
'options' => $this->esc_child_options( $data['childs'] ),
'condition' => $condition,
)
);
$this->register_child_options_item( $data['childs'], $controls_manager, $control_name, $condition );
}
}
public function register_child_options_item( $items, $controls_manager, $parent_id, $parent_condition ) {
foreach ( $items as $cid ) {
$instance = $this->get_condition( $cid );
$childs = $instance->get_childs();
$this->register_child_controls( $cid, $controls_manager, $parent_id, $parent_condition );
if ( empty( $childs ) ) {
continue;
}
$condition = array_merge(
$parent_condition,
array(
$parent_id => $cid
)
);
$control_name = 'conditions_sub_' . $cid;
$controls_manager->add_control(
$control_name,
array(
'label' => $instance->get_label(),
'type' => Elementor\Controls_Manager::SELECT,
'default' => '',
'options' => $this->esc_child_options( $childs ),
'condition' => $condition,
)
);
$this->register_child_options_item( $childs, $controls_manager, $control_name, $condition );
}
}
public function register_child_controls( $condition_id, $controls_manager, $parent_id, $parent_condition ) {
$instance = $this->get_condition( $condition_id );
$controls = $instance->get_controls();
if ( empty( $controls ) ) {
return;
}
foreach ( $controls as $control_id => $control_options ) {
$id = 'conditions_' . $condition_id . '_' . $control_id;
$child_cond = ! empty( $control_options['condition'] ) ? $control_options['condition'] : array();
$control_options['condition'] = array_merge(
$child_cond,
array( $parent_id => $condition_id ),
$parent_condition
);
$controls_manager->add_control( $id, $control_options );
}
}
/**
* Prepare registerred conditions for controls
*
* @return array
*/
public function prepare_conditions_for_controls() {
$sorted_conditions = array();
foreach ( $this->_conditions as $cid => $instance ) {
if ( in_array( $cid, $this->_processed_childs ) ) {
continue;
}
$group = $instance->get_group();
$childs = $instance->get_childs();
if ( ! isset( $sorted_conditions[ $group ] ) ) {
$sorted_conditions[ $group ] = array();
}
$current = array(
'label' => $instance->get_label(),
);
if ( ! empty( $childs ) ) {
$current['childs'] = $this->add_condition_childs( $childs );
}
$sorted_conditions[ $group ][ $cid ] = $current;
}
return $sorted_conditions;
}
/**
* Add child conditions to stack
*/
public function add_condition_childs( $childs ) {
$result = array();
foreach ( $childs as $cid ) {
$instance = $this->get_condition( $cid );
$childs = $instance->get_childs();
$current = array(
'label' => $instance->get_label(),
);
if ( ! empty( $childs ) ) {
$current['childs'] = $this->add_condition_childs( $childs );
}
$result[ $cid ] = $current;
if ( ! in_array( $cid, $this->_processed_childs ) ) {
$this->_processed_childs[] = $cid;
}
}
return $result;
}
/**
* Run condtions check for passed type. Return {template_id} on firs condition match.
* If not matched - return false
*
* @return int|bool
*/
public function find_matched_conditions( $type ) {
if ( isset( $this->_matched_conditions[ $type ] ) ) {
return $this->_matched_conditions[ $type ];
}
$conditions = get_option( $this->conditions_key, array() );
if ( empty( $conditions[ $type ] ) ) {
$this->_matched_conditions[ $type ] = false;
return false;
}
$entire = false;
foreach ( $conditions[ $type ] as $template_id => $template_conditions ) {
if ( empty( $template_conditions['main'] ) ) {
continue;
}
if ( 'entire' === $template_conditions['main'] ) {
$this->_matched_conditions[ $type ] = $template_id;
$entire = $template_id;
continue;
}
foreach ( $template_conditions as $cid => $args ) {
$instance = $this->get_condition( $cid );
if ( ! $instance ) {
continue;
}
$check = call_user_func( array( $instance, 'check' ), $args );
if ( true === $check ) {
$this->_matched_conditions[ $type ] = $template_id;
return $template_id;
}
}
}
if ( $entire ) {
return $entire;
}
$this->_matched_conditions[ $type ] = false;
return false;
}
/**
* Get active conditions for passed post
*
* @param [type] $post_id [description]
* @return [type] [description]
*/
public function post_conditions_verbose( $post_id = null ) {
$conditions = $this->get_post_conditions( $post_id );
if ( empty( $conditions['main'] ) ) {
return;
}
if ( 'entire' === $conditions['main'] ) {
return __( 'Entire Site', 'jet-theme-core' );
}
unset( $conditions['main'] );
$condition_keys = array_keys( $conditions );
$verbose = '';
foreach ( $condition_keys as $key ) {
$instance = $this->get_condition( $key );
$verbose_args = $instance->verbose_args( $conditions[ $key ] );
if ( ! empty( $verbose_args ) ) {
$verbose_args = ': ' . $verbose_args;
}
$verbose .= sprintf( '<div>%1$s%2$s</div>', $instance->get_label(), $verbose_args );
}
return $verbose;
}
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Singular_404' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Singular_404 class
*/
class Jet_Theme_Core_Conditions_Singular_404 extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-404';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( '404 Page', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
return is_404();
}
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Front' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Front class
*/
class Jet_Theme_Core_Conditions_Front extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-front-page';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Front Page', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
return is_front_page();
}
}
}

View File

@@ -0,0 +1,139 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Singular_Page_Child' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Singular_Page_Child class
*/
class Jet_Theme_Core_Conditions_Singular_Page_Child extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-page-child';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Page, Child of', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
public function get_controls() {
return array(
'pages' => array(
'label' => __( 'Select Parent', 'jet-theme-core' ),
'type' => 'jet_search',
'action' => 'jet_theme_search_pages',
'label_block' => true,
'multiple' => false,
'saved' => $this->get_saved_pages(),
),
);
}
public function get_saved_pages() {
$template_id = get_the_ID();
$saved = get_post_meta( $template_id, '_elementor_page_settings', true );
if ( ! empty( $saved['conditions_singular-page-child_pages'] ) ) {
if ( ! is_array( $saved['conditions_singular-page-child_pages'] ) ) {
$pages = array( $saved['conditions_singular-page-child_pages'] );
} else {
$pages = $saved['conditions_singular-page-child_pages'];
}
$posts = get_posts( array(
'post_type' => 'page',
'post__in' => $pages,
'ignore_sticky_posts' => true,
) );
if ( empty( $posts ) ) {
return array();
} else {
return wp_list_pluck( $posts, 'post_title', 'ID' );
}
} else {
return array();
}
}
public function verbose_args( $args ) {
if ( empty( $args['pages'] ) ) {
return __( 'Not Selected', 'jet-theme-core' );
}
$result = '';
$sep = '';
if ( ! is_array( $args['pages'] ) ) {
$parents = array( $args['pages'] );
} else {
$parents = $args['pages'];
}
foreach ( $parents as $page ) {
$result .= $sep . get_the_title( $page );
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['pages'] ) ) {
return false;
}
if ( ! is_page() ) {
return false;
}
if ( ! is_array( $args['pages'] ) ) {
$parents = array( $args['pages'] );
} else {
$parents = $args['pages'];
}
global $post;
return in_array( $post->post_parent, $parents );
}
}
}

View File

@@ -0,0 +1,93 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Singular_Page_Template' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Singular_Page_Template class
*/
class Jet_Theme_Core_Conditions_Singular_Page_Template extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-page-template';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Page Template', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
public function get_controls() {
$templates = wp_get_theme()->get_page_templates();
$templates = array( '' => __( 'Select...', 'jet-theme-core' ) ) + $templates;
return array(
'template' => array(
'label' => __( 'Select Template', 'jet-theme-core' ),
'type' => Elementor\Controls_Manager::SELECT,
'default' => '',
'options' => $templates,
),
);
}
public function verbose_args( $args ) {
if ( empty( $args['template'] ) ) {
return __( 'Not Selected', 'jet-theme-core' );
}
return $args['template'];
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['template'] ) ) {
return false;
}
if ( ! is_page() ) {
return false;
}
global $post;
$page_template_slug = get_page_template_slug( $post->ID );
return $page_template_slug === $args['template'];
}
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Singular_Page' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Singular_Page class
*/
class Jet_Theme_Core_Conditions_Singular_Page extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-page';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Page', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
public function get_controls() {
return array(
'pages' => array(
'label' => __( 'Select Pages', 'jet-theme-core' ),
'type' => 'jet_search',
'action' => 'jet_theme_search_pages',
'label_block' => true,
'multiple' => true,
'description' => __( 'Leave empty to apply for all pages', 'jet-theme-core' ),
'saved' => $this->get_saved_pages(),
),
);
}
public function get_saved_pages() {
$template_id = get_the_ID();
$saved = get_post_meta( $template_id, '_elementor_page_settings', true );
if ( ! empty( $saved['conditions_singular-page_pages'] ) ) {
$posts = get_posts( array(
'post_type' => 'page',
'post__in' => $saved['conditions_singular-page_pages'],
'ignore_sticky_posts' => true,
) );
if ( empty( $posts ) ) {
return array();
} else {
return wp_list_pluck( $posts, 'post_title', 'ID' );
}
} else {
return array();
}
}
public function verbose_args( $args ) {
if ( empty( $args['pages'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
foreach ( $args['pages'] as $page ) {
$result .= $sep . get_the_title( $page );
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['pages'] ) ) {
return is_page();
}
return is_page( $args['pages'] );
}
}
}

View File

@@ -0,0 +1,127 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Singular_Post_From_Category' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Singular_Post_From_Category class
*/
class Jet_Theme_Core_Conditions_Singular_Post_From_Category extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-post-from-cat';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Posts from Category', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
public function get_controls() {
return array(
'cats' => array(
'label' => __( 'Select Categories', 'jet-theme-core' ),
'type' => 'jet_search',
'action' => 'jet_theme_search_cats',
'label_block' => true,
'multiple' => true,
'saved' => $this->get_saved_cats(),
),
);
}
public function get_saved_cats() {
$template_id = get_the_ID();
$saved = get_post_meta( $template_id, '_elementor_page_settings', true );
if ( ! empty( $saved['conditions_singular-post-from-cat_cats'] ) ) {
$terms = get_terms( array(
'include' => $saved['conditions_singular-post-from-cat_cats'],
'taxonomy' => 'category',
'hide_empty' => false,
) );
if ( empty( $terms ) ) {
return array();
} else {
return wp_list_pluck( $terms, 'name', 'term_id' );
}
} else {
return array();
}
}
public function verbose_args( $args ) {
if ( empty( $args['cats'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
$terms = get_terms( array(
'include' => $args['cats'],
'taxonomy' => 'category',
'hide_empty' => false,
) );
foreach ( $terms as $term ) {
$result .= $sep . $term->name;
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['cats'] ) ) {
return false;
}
if ( ! is_single() ) {
return false;
}
global $post;
return in_category( $args['cats'], $post );
}
}
}

View File

@@ -0,0 +1,127 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Singular_Post_From_Tag' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Singular_Post_From_Tag class
*/
class Jet_Theme_Core_Conditions_Singular_Post_From_Tag extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-post-from-tag';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Posts from Tag', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
public function get_controls() {
return array(
'tags' => array(
'label' => __( 'Select Tags', 'jet-theme-core' ),
'type' => 'jet_search',
'action' => 'jet_theme_search_tags',
'label_block' => true,
'multiple' => true,
'saved' => $this->get_saved_tags(),
),
);
}
public function get_saved_tags() {
$template_id = get_the_ID();
$saved = get_post_meta( $template_id, '_elementor_page_settings', true );
if ( ! empty( $saved['conditions_singular-post-from-tag_tags'] ) ) {
$terms = get_terms( array(
'include' => $saved['conditions_singular-post-from-tag_tags'],
'taxonomy' => 'post_tag',
'hide_empty' => false,
) );
if ( empty( $terms ) ) {
return array();
} else {
return wp_list_pluck( $terms, 'name', 'term_id' );
}
} else {
return array();
}
}
public function verbose_args( $args ) {
if ( empty( $args['tags'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
$terms = get_terms( array(
'include' => $args['tags'],
'taxonomy' => 'post_tag',
'hide_empty' => false,
) );
foreach ( $terms as $term ) {
$result .= $sep . $term->name;
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['tags'] ) ) {
return false;
}
if ( ! is_single() ) {
return false;
}
global $post;
return has_tag( $args['tags'], $post );
}
}
}

View File

@@ -0,0 +1,91 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Singular_Post_Type' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Singular_Post_Type class
*/
class Jet_Theme_Core_Conditions_Singular_Post_Type extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-post-type';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Post Type', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
public function get_controls() {
return array(
'types' => array(
'label' => esc_html__( 'Post Type', 'jet-theme-core' ),
'type' => Elementor\Controls_Manager::SELECT2,
'default' => 'post',
'options' => Jet_Theme_Core_Utils::get_post_types(),
'multiple' => true,
),
);
}
public function verbose_args( $args ) {
if ( empty( $args['types'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
foreach ( $args['types'] as $post_type ) {
$obj = get_post_type_object( $post_type );
$result .= $sep . $obj->labels->singular_name;
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['types'] ) ) {
return is_singular();
}
return is_singular( $args['types'] );
}
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* Is front page condition
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
if ( ! class_exists( 'Jet_Theme_Core_Conditions_Singular_Post' ) ) {
/**
* Define Jet_Theme_Core_Conditions_Singular_Post class
*/
class Jet_Theme_Core_Conditions_Singular_Post extends Jet_Theme_Core_Conditions_Base {
/**
* Condition slug
*
* @return string
*/
public function get_id() {
return 'singular-post';
}
/**
* Condition label
*
* @return string
*/
public function get_label() {
return __( 'Post', 'jet-theme-core' );
}
/**
* Condition group
*
* @return string
*/
public function get_group() {
return 'singular';
}
public function get_controls() {
return array(
'posts' => array(
'label' => __( 'Select Posts', 'jet-theme-core' ),
'type' => 'jet_search',
'action' => 'jet_theme_search_posts',
'label_block' => true,
'multiple' => true,
'description' => __( 'Leave empty to apply for all posts', 'jet-theme-core' ),
'saved' => $this->get_saved_posts(),
),
);
}
public function get_saved_posts() {
$template_id = get_the_ID();
$saved = get_post_meta( $template_id, '_elementor_page_settings', true );
if ( ! empty( $saved['conditions_singular-post_posts'] ) ) {
$posts = get_posts( array(
'post_type' => 'post',
'post__in' => $saved['conditions_singular-post_posts'],
'ignore_sticky_posts' => true,
) );
if ( empty( $posts ) ) {
return array();
} else {
return wp_list_pluck( $posts, 'post_title', 'ID' );
}
} else {
return array();
}
}
public function verbose_args( $args ) {
if ( empty( $args['posts'] ) ) {
return __( 'All', 'jet-theme-core' );
}
$result = '';
$sep = '';
foreach ( $args['posts'] as $post ) {
$result .= $sep . get_the_title( $post );
$sep = ', ';
}
return $result;
}
/**
* Condition check callback
*
* @return bool
*/
public function check( $args ) {
if ( empty( $args['posts'] ) ) {
return is_single();
}
return is_single( $args['posts'] );
}
}
}

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