@@ -664,6 +681,7 @@ function themes_dashboard(){
else
$splash = $t->get_stylesheet();
+ $class[] = 'x-item-size-10';
$args = array(
'id' => $theme,
diff --git a/editor/editor.settings.php b/editor/editor.settings.php
index 4e4ec8cb..ea07d1bd 100644
--- a/editor/editor.settings.php
+++ b/editor/editor.settings.php
@@ -18,31 +18,131 @@ function pl_setting( $key, $args = array() ){
}
-/**
- *
- *
- * PageLines Settings
- *
- *
- */
-class PageLinesOpts extends PageLinesData {
+function pl_setting_update( $args_or_key, $value = false, $mode = 'draft', $scope = 'global' ){
+ $settings_handler = new PageLinesSettings;
+
+ if( is_array($args_or_key) ){
+ $args = $args_or_key;
+ } else {
+
+ $args = array(
+ 'key' => $args_or_key,
+ 'val' => $value,
+ 'mode' => $mode,
+ 'scope' => $scope
+ );
+
+ }
+
+ $settings_handler->update_setting( $args );
+
+}
- var $pl_settings = PL_SETTINGS;
- var $default = array( 'draft' => array(), 'live' => array() );
+/*
+ * This class contains all methods for interacting with WordPress' data system
+ * It has no dependancy so it can be used as a substitute for WordPress native functions
+ * The options system inherits from it.
+ */
+class PageLinesData {
+
+ function meta($id, $key, $default = false){
- function __construct( PageLinesPage $page, EditorDraft $draft ){
+ $val = get_post_meta($id, $key, true);
+
+ if( !$val ){
+
+ $val = $default;
+
+ } elseif( is_array($val) && is_array($default)) {
+
+ $val = wp_parse_args( $val, $default );
+
+ }
+
+ return $val;
+
+ }
+
+ function meta_update($id, $key, $value){
+
+ update_post_meta($id, $key, $value);
+
+ }
+
+
+ function opt( $key, $default = false, $parse = false ){
- $this->page = $page;
- $this->draft = $draft;
+ $val = get_option($key);
+
+ if( !$val ){
+
+ $val = $default;
+
+ } elseif( $parse && is_array($val) && is_array($default)) {
+
+ $val = wp_parse_args( $val, $default );
+
+ }
+
+ return $val;
- $this->local = $this->local_settings();
- $this->type = $this->type_settings();
- $this->global = $this->global_settings();
- $this->set = $this->page_settings();
+ }
+
+ function opt_update( $key, $value ){
+
+ update_option($key, $value);
}
+ function user( $user_id, $key, $default = false ){
+
+ $val = get_user_meta($user_id, $key, true);
+
+ if( !$val ){
+
+ $val = $default;
+
+ } elseif( is_array($val) && is_array($default)) {
+
+ $val = wp_parse_args( $val, $default );
+
+ }
+
+ return $val;
+
+ }
+
+ function user_update( $user_id, $key, $value ){
+ update_user_meta( $user_id, $key, $value );
+ }
+
+
+}
+
+/*
+ * PageLines Settings Interface
+ */
+class PageLinesSettings extends PageLinesData {
+
+ var $pl_settings = PL_SETTINGS;
+ var $default = array( 'draft' => array(), 'live' => array() );
+
+ function global_settings(){
+
+ $set = $this->opt( $this->pl_settings );
+
+ // Have to move this to an action because ploption calls pl_setting before all settings are loaded
+ if( !$set || empty($set['draft']) || empty($set['live']) )
+ add_action('pl_after_settings_load', array(&$this, 'set_default_settings'));
+
+ return $this->get_by_mode($set);
+
+ }
+
+ /*
+ * Resets global options to an empty set
+ */
function reset_global( ){
$set = $this->opt( PL_SETTINGS, $this->default );
@@ -53,6 +153,9 @@ function reset_global( ){
}
+ /*
+ * Resets local options to an empty set based on ID (works for type ID)
+ */
function reset_local( $metaID ){
$set = $this->meta( $metaID, PL_SETTINGS, $this->default );
@@ -63,15 +166,102 @@ function reset_local( $metaID ){
}
+ /*
+ * Sets default values for global settings
+ */
+ function set_default_settings(){
+
+ $set = $this->opt( $this->pl_settings );
+
+ $settings_defaults = $this->get_default_settings();
+
+ if( !$set )
+ $set = $this->default;
+
+ if(empty($set['draft']))
+ $set['draft'] = $settings_defaults;
+
+ if(empty($set['live']))
+ $set['live'] = $settings_defaults;
+
+ $this->opt_update( $this->pl_settings, $set);
+
+ }
- function page_settings(){
+ /*
+ * Grabs global settings engine array, and default values (set in array)
+ */
+ function get_default_settings(){
+ $settings_object = new EditorSettings;
- $set = $this->parse_settings( $this->local, $this->parse_settings($this->type, $this->global));
+ $settings = $settings_object->get_set();
+
+
+ $defaults = array();
+ foreach($settings as $tab => $tab_settings){
+ foreach($tab_settings['opts'] as $index => $opt){
+ if($opt['type'] == 'multi'){
+ foreach($opt['opts'] as $subi => $sub_opt){
+ if(isset($sub_opt['default'])){
+ $defaults[ $sub_opt['key'] ] = array( $sub_opt['default'] );
+ }
+ }
+ }
+ if(isset($opt['default'])){
+ $defaults[ $opt['key'] ] = array( $opt['default'] );
+ }
+ }
+ }
+
+ return $defaults;
+ }
+
+
- return $set;
+ /*
+ * Update a PageLines setting using arguments
+ */
+ function update_setting( $args = array() ){
+
+ $defaults = array(
+ 'key' => '',
+ 'val' => '',
+ 'mode' => 'draft',
+ 'scope' => 'global'
+ );
+
+ $a = wp_parse_args( $args, $defaults );
+
+ $scope = $a['scope'];
+ $mode = $a['mode'];
+ $key = $a['key'];
+ $val = $a['val'];
+
+ // Allow for an array of key/value pairs
+ $set = ( !is_array($val) && $key != '' ) ? array( $key => $value ) : $val;
+
+ if( $scope == 'global'){
+
+ $settings = $this->opt( $this->pl_settings, $this->default );
+
+ if( isset($settings[ $mode ]) ){
+
+ $settings[ $mode ] = wp_parse_args($set, $settings[ $mode ]);
+
+ pl_opt_update( PL_SETTINGS, $option_set );
+
+ }
+
+ }
}
+
+ /*
+ * Parse settings taking the top values over the bottom
+ * Deep parsing: Parses arguments on nested arrays then deals with overriding
+ * Checkboxes: Handles checkboxes by using 'flip' value settings to toggle the value
+ */
function parse_settings( $top, $bottom ){
@@ -134,6 +324,37 @@ function parse_settings( $top, $bottom ){
return $parsed_args;
}
+
+}
+
+
+
+/**
+ * PageLines *Page Specific* Settings Interface
+ * Has a dependancy on the PageLinesPage object and EditorDraft object
+ */
+class PageLinesOpts extends PageLinesSettings {
+
+ function __construct( PageLinesPage $page, EditorDraft $draft ){
+
+ $this->page = $page;
+ $this->draft = $draft;
+
+ $this->local = $this->local_settings();
+ $this->type = $this->type_settings();
+ $this->global = $this->global_settings();
+ $this->set = $this->page_settings();
+
+ }
+
+
+ function page_settings(){
+
+ $set = $this->parse_settings( $this->local, $this->parse_settings($this->type, $this->global));
+
+ return $set;
+
+ }
function setting( $key ){
@@ -175,63 +396,7 @@ function get_setting( $key, $args = array() ){
}
- function global_settings(){
-
- $set = $this->opt( $this->pl_settings );
- // Have to move this to an action because ploption calls pl_setting before all settings are loaded
- if( !$set || empty($set['draft']) || empty($set['live']) )
- add_action('pl_after_settings_load', array(&$this, 'set_default_settings'));
-
- return $this->get_by_mode($set);
-
- }
-
- function set_default_settings(){
-
- $set = $this->opt( $this->pl_settings );
-
- $settings_defaults = $this->get_default_settings();
-
- if( !$set )
- $set = $this->default;
-
- if(empty($set['draft']))
- $set['draft'] = $settings_defaults;
-
- if(empty($set['live']))
- $set['live'] = $settings_defaults;
-
- $this->opt_update( $this->pl_settings, $set);
-
- }
-
-
- function get_default_settings(){
- $settings_object = new EditorSettings;
-
- $settings = $settings_object->get_set();
-
-
- $defaults = array();
- foreach($settings as $tab => $tab_settings){
- foreach($tab_settings['opts'] as $index => $opt){
- if($opt['type'] == 'multi'){
- foreach($opt['opts'] as $subi => $sub_opt){
- if(isset($sub_opt['default'])){
- $defaults[ $sub_opt['key'] ] = array( $sub_opt['default'] );
- }
- }
- }
- if(isset($opt['default'])){
- $defaults[ $opt['key'] ] = array( $opt['default'] );
- }
- }
- }
-
- return $defaults;
- }
-
function get_by_mode( $set ){
$set = wp_parse_args( $set, $this->default );
@@ -245,63 +410,9 @@ function get_by_mode( $set ){
}
-/*
- * This class contains all methods for interacting with WordPress' data system
- * It has no dependancy so it can be used as a substitute for WordPress native functions
- * The options system inherits from it.
- */
-class PageLinesData {
-
- function meta($id, $key, $default = false){
- $val = get_post_meta($id, $key, true);
- if( !$val ){
-
- $val = $default;
-
- } elseif( is_array($val) && is_array($default)) {
-
- $val = wp_parse_args( $val, $default );
- }
-
- return $val;
-
- }
-
- function meta_update($id, $key, $value){
-
- update_post_meta($id, $key, $value);
-
- }
-
-
- function opt( $key, $default = false, $parse = false ){
-
- $val = get_option($key);
-
- if( !$val ){
-
- $val = $default;
-
- } elseif( $parse && is_array($val) && is_array($default)) {
-
- $val = wp_parse_args( $val, $default );
-
- }
-
- return $val;
-
- }
-
- function opt_update( $key, $value ){
-
- update_option($key, $value);
-
- }
-
-}
diff --git a/editor/editor.themes.php b/editor/editor.themes.php
index 79ba94c5..80537484 100644
--- a/editor/editor.themes.php
+++ b/editor/editor.themes.php
@@ -2,17 +2,81 @@
-class EditorThemesHandler {
+class EditorThemeHandler {
+ var $preview_slug = 'pl-theme-preview';
- function activate(){
+ function activate( $response ){
+
+ $new = $response['post']['stylesheet'];
+
+ $theme = wp_get_theme( $new );
+
+ if ( !$new || !$theme->exists() || !$theme->is_allowed() ){
+ $response['error'] = 'Theme does not exist or is not allowed';
+ return $response;
+ }
+
+
+ switch_theme( $theme->get_stylesheet() );
+
+ $response['success'] = 'Theme Switched!';
+ $response['new'] = $new;
+
+ return $response;
+ }
+
+ function set_preview(){
+
+ $new = $response['post']['stylesheet'];
+
+ $theme = wp_get_theme( $new );
+
+ if ( !$new || !$theme->exists() || !$theme->is_allowed() ){
+ $response['error'] = 'Theme does not exist or is not allowed';
+ return $response;
+ } else {
+ echo 'here';
+ pl_update_setting($this->preview_slug, $new);
+
+ return $response;
+
+ }
}
+
+ function maybe_load_preview( $active_stylesheet ){
+
+ $preview_theme = $this->determine_theme( $active_stylesheet );
- function preview(){
+ if ( $preview_theme ){
+
+ $preview_theme_object = wp_get_theme( $preview_theme );
+
+ add_action('before_toolbox_panel', array(&$this, 'add_preview_banner'));
+
+ return $preview_theme_object->get_stylesheet();
+
+ } else
+ return $active_stylesheet;
+
+
}
+ function determine_theme( $active_stylesheet ){
+ $preview_stylesheet = pl_setting( $this->preview_slug );
+
+ if( $preview_stylesheet && $preview_stylesheet != $active_stylesheet )
+ return $preview_stylesheet;
+ else
+ return false;
+ }
+ function add_preview_banner(){
+
+ echo ' this is the end of the world.... >> ';
+ }
+
}
\ No newline at end of file
diff --git a/editor/js/pl.ajax.js b/editor/js/pl.ajax.js
index c0525f53..00b8659e 100644
--- a/editor/js/pl.ajax.js
+++ b/editor/js/pl.ajax.js
@@ -10,49 +10,91 @@
run: function( args ){
var that = this
- , refresh = args.refresh || false
- , savingDialog = args.savingText || 'Saving'
- , refreshingDialog = args.refreshText || 'Refreshing Page'
- , defaultData = {
+ , theData = {
action: 'pl_editor_actions'
, mode: 'default'
- , flag: 'default'
+ , run: 'default'
, pageID: $.pl.config.pageID
, typeID: $.pl.config.typeID
, log: false
+ , confirm: false
+ , confirmText: 'Are you sure?'
+ , savingText: 'Saving'
+ , refresh: false
+ , refreshText: 'Refreshing page...'
+ , toolboxOpen: $.toolbox('open')
+
}
- , theData = $.extend(true, defaultData, args.theData)
-
+
+ // merge args into theData, overwriting theData w/ args
+ $.extend(theData, args)
+
+ if( theData.confirm ){
+
+ if( theData.toolboxOpen )
+ $.toolbox('hide')
+
+ bootbox.confirm( theData.confirmText, function( result ){
+
+ if(result == true){
+ that.runAction( theData )
+ } else {
+
+ if( theData.toolboxOpen )
+ $('body').toolbox('show')
+ }
+
+ })
+
+ } else {
+
+ that.runAction( theData )
+
+ }
+
+
+ return ''
+ }
+
+ , runAction: function( theData ){
+
+ var that = this
+
$.ajax( {
- type: 'POST'
- , url: ajaxurl
- , data: theData
- , beforeSend: function(){
- $('.btn-saving').addClass('active')
+ type: 'POST'
+ , url: ajaxurl
+ , data: theData
+ , beforeSend: function(){
+
+ $('.btn-saving').addClass('active')
- if(refresh)
- bootbox.dialog( that.dialogText( savingDialog ), [ ], {animate: false})
- }
- , success: function( response ){
+ if( theData.refresh ){
+ $.toolbox('hide')
+ bootbox.dialog( that.dialogText( theData.savingText ), [ ], {animate: false})
+ }
+
+
+ }
+ , success: function( response ){
- that.success( response )
+ that.runSuccess( response )
- if(refresh){
- bootbox.dialog( that.dialogText( refreshingDialog ), [ ], {animate: false})
- location.reload()
+ if( theData.refresh ){
+ bootbox.dialog( that.dialogText( theData.refreshText ), [ ], {animate: false})
+ location.reload()
+ }
+
}
-
- }
- })
-
- return ''
+ })
}
- , success: function( response ){
+ , runSuccess: function( response ){
var that = this
+ , rsp = $.parseJSON( response )
+ , log = (rsp.post) ? rsp.post.log || false : ''
- if(response.post.log == true)
- console.log(response)
+ if(log == 'true')
+ console.log(rsp)
that.ajaxSuccess(response)
}
diff --git a/editor/js/pl.editor.js b/editor/js/pl.editor.js
index 882be00f..2814790e 100644
--- a/editor/js/pl.editor.js
+++ b/editor/js/pl.editor.js
@@ -24,8 +24,6 @@
$.plAJAX.init()
-
-
this.bindUIActions()
}
@@ -122,7 +120,7 @@
})
}
- , activate: function(event, ui){
+ , activate: function(e, ui){
var theTab = ui.newTab
, tabAction = theTab.attr('data-tab-action') || ''
@@ -137,6 +135,13 @@
, 'lineWrapping': true
})
+ } else if ( tabFlag == 'link-storefront' ){
+
+ e.preventDefault()
+
+ $('.btn-pl-extend')
+ .trigger('click')
+
}
}
@@ -302,7 +307,7 @@
}
- , loadButtons: function( panel ){
+ , loadButtons: function( panel, data ){
var buttons = ''
if(panel == 'x-store'){
@@ -310,7 +315,7 @@
buttons += sprintf('
Overview ')
buttons += sprintf('
Demo ')
} else if ( panel == 'x-themes' ){
- buttons += $.plThemes.actionButtons()
+ buttons += $.plThemes.actionButtons( data )
} else if ( panel == 'x-sections' ){
buttons += sprintf('
Drag Thumb to Page ')
}
@@ -349,7 +354,8 @@
var that = this
$('.x-extension').on('click.extensionItem', function(){
- var theIsotope = $(this).parent()
+ var theExtension = $(this)
+ , theIsotope = $(this).parent()
, theID = $(this).data('extend-id')
, filterClass = '.'+theID
, ext = $.pl.config.extensions[theID] || false
@@ -359,7 +365,7 @@
var splash = sprintf('
', ext.splash)
, btnClose = sprintf('
', theID)
- , btns = sprintf('
%s
', that.loadButtons( panel ))
+ , btns = sprintf('
%s
', that.loadButtons( panel, theExtension.data() ))
, desc = sprintf('
Description
%s', ext.desc)
, extPane = $( sprintf('
%s', theID, splash, btns, desc, btnClose) )
diff --git a/editor/js/pl.themes.js b/editor/js/pl.themes.js
index c334da79..1387f680 100644
--- a/editor/js/pl.themes.js
+++ b/editor/js/pl.themes.js
@@ -8,23 +8,47 @@ $.plThemes = {
$('.btn-theme-activate').on('click', function(){
var args = {
mode: 'themes'
- , flag: 'activate'
+ , run: 'activate'
+ , confirm: true
+ , confirmText: '
Are you sure?
This will activate this theme sitewide.
'
, savingText: 'Activating Theme'
+ , refresh: true
, refreshText: 'Successfully Activated. Refreshing page'
+ , log: true
+ , stylesheet: $(this).data('stylesheet')
}
var response = $.plAJAX.run( args )
})
$('.btn-theme-preview').on('click', function(){
- console.log('hi2')
+ var args = {
+ mode: 'themes'
+ , run: 'preview'
+ , confirm: true
+ , confirmText: '
Activate Theme Preview?
This will activate a theme preview sitewide.
(while in draft mode)
'
+ , savingText: 'Loading Theme Preview'
+ , refresh: false
+ , refreshText: 'Successfully Loaded. Refreshing page'
+ , log: true
+ , stylesheet: $(this).data('stylesheet')
+ }
+
+ var response = $.plAJAX.run( args )
})
}
- , actionButtons: function(){
+ , actionButtons: function( data ){
var buttons = ''
- buttons += sprintf('
Activate ')
- buttons += sprintf('
Preview ')
+ , theme = sprintf('data-stylesheet="%s"', data.stylesheet)
+
+ buttons += sprintf('
Activate ', theme)
+
+
+ // Can't get this to work because of a PHP loading issue
+ // Must move to a plugin that loads before the 'stylesheet' is set for a child theme.
+ //
+ // buttons += sprintf('
Preview ', theme)
return buttons
}
diff --git a/editor/js/pl.toolbox.js b/editor/js/pl.toolbox.js
index 3c0b79aa..138e2596 100644
--- a/editor/js/pl.toolbox.js
+++ b/editor/js/pl.toolbox.js
@@ -58,6 +58,7 @@
this.isShown = true
store.set('toolboxShown', true)
+
this.keyboard()
@@ -99,6 +100,8 @@
$('body')
.removeClass('toolbox-open')
+
+
this.keyboard()
this.$panel
@@ -275,6 +278,16 @@
/* MODAL PLUGIN DEFINITION
* ======================= */
+ $.toolbox = function( option ){
+
+ if(typeof option == 'string' && option == 'open')
+ return ( $('body').hasClass('toolbox-open') ) ? true : false
+ else
+ return $('body').toolbox( option )
+
+
+ }
+
$.fn.toolbox = function ( option ) {
return this.each( function() {
@@ -316,4 +329,5 @@
$.fn.toolbox.Constructor = ToolBox
+
}(window.jQuery);
\ No newline at end of file
diff --git a/functions.php b/functions.php
index 6d4e5805..538afe21 100644
--- a/functions.php
+++ b/functions.php
@@ -18,5 +18,4 @@
*
* @todo Define version
*/
-
require_once(get_template_directory() . '/includes/init.php');
\ No newline at end of file
diff --git a/less/pl-editor.less b/less/pl-editor.less
index 887e2c11..d34a8cf1 100644
--- a/less/pl-editor.less
+++ b/less/pl-editor.less
@@ -112,7 +112,7 @@
top: 0;
left: 0;
width: 100%;
- z-index: 999;
+ z-index: @zindexEditor;
background: @interfaceBG;
text-shadow: 0 -1px 0 @interfaceBG;
text-align: center;
diff --git a/less/variables.less b/less/variables.less
index e4673034..7abc7a9f 100755
--- a/less/variables.less
+++ b/less/variables.less
@@ -83,12 +83,15 @@
// Z-index master list
// -------------------------
-@zindexDropdown: 1000;
-@zindexPopover: 1010;
-@zindexTooltip: 1020;
-@zindexFixedNavbar: 1030;
-@zindexModalBackdrop: 1040;
-@zindexModal: 1050;
+@zindexDropdown: 1000;
+@zindexNavbar: 1001;
+@zindexEditor: 1005;
+@zindexPopover: 1010;
+@zindexTooltip: 1020;
+
+@zindexFixedNavbar: 1030;
+@zindexModalBackdrop: 1040;
+@zindexModal: 1050;
// GRID
// --------------------------------------------------
diff --git a/sections/navbar/style.less b/sections/navbar/style.less
index e4bdff3f..a419f27a 100644
--- a/sections/navbar/style.less
+++ b/sections/navbar/style.less
@@ -15,7 +15,7 @@ body.navbar_fixed {
/* Basic formatting
************************************************************/
.section-navbar {
- z-index: @zindexFixedNavbar - 1;
+ z-index: @zindexNavbar;
margin: 0 auto;
width: 100%;
font-family: @altFontFamily;