From 860ae6ce4a62105fb6454ca64c866dcd8b8d8a5f Mon Sep 17 00:00:00 2001 From: Greg Priday Date: Tue, 5 Jul 2016 08:20:41 +0200 Subject: [PATCH 01/12] Fixed action link Resolves GH-33 --- so-css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/so-css.php b/so-css.php index 0a3004d..ee6737f 100644 --- a/so-css.php +++ b/so-css.php @@ -231,7 +231,7 @@ function action_admin_footer(){ function plugin_action_links( $links ){ if( isset($links['edit']) ) unset( $links['edit'] ); - $links['css_editor'] = ''.__('CSS Editor', 'so-css').''; + $links['css_editor'] = ''.__('CSS Editor', 'so-css').''; $links['support'] = ''.__('Support', 'so-css').''; return $links; } From 2fc569f78f076e1c05bd01a0d9de5aec7bed09f7 Mon Sep 17 00:00:00 2001 From: Greg Priday Date: Tue, 5 Jul 2016 08:21:35 +0200 Subject: [PATCH 02/12] Removed unused function and code cleanup --- so-css.php | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/so-css.php b/so-css.php index ee6737f..d33449b 100644 --- a/so-css.php +++ b/so-css.php @@ -45,7 +45,7 @@ function __construct(){ if( isset($_GET['so_css_preview']) && !is_admin() ) { - add_action('plugins_loaded', array($this, 'disable_ngg_resource_manager')); + add_action( 'plugins_loaded', array($this, 'disable_ngg_resource_manager') ); add_filter( 'show_admin_bar', '__return_false' ); add_filter( 'wp_enqueue_scripts', array($this, 'enqueue_inspector_scripts') ); add_filter( 'wp_footer', array($this, 'inspector_templates') ); @@ -242,7 +242,7 @@ function display_admin_page(){ $custom_css = get_option( 'siteorigin_custom_css[' . $theme . ']', '' ); $custom_css_revisions = get_option('siteorigin_custom_css_revisions[' . $theme . ']'); - if(!empty($_GET['theme']) && $_GET['theme'] == $theme && !empty($_GET['time']) && !empty($custom_css_revisions[$_GET['time']])) { + if( !empty( $_GET['theme'] ) && $_GET['theme'] == $theme && !empty( $_GET['time'] ) && !empty( $custom_css_revisions[$_GET['time']] ) ) { $custom_css = $custom_css_revisions[$_GET['time']]; $revision = true; } @@ -257,7 +257,7 @@ function admin_action_hide_getting_started(){ if( !isset($_GET['_wpnonce']) || !wp_verify_nonce( $_GET['_wpnonce'], 'hide' ) ) return; $user = wp_get_current_user(); - if( !empty($user) ) { + if( !empty( $user ) ) { update_user_meta( $user->ID, 'socss_hide_gs', true ); } } @@ -425,23 +425,6 @@ function inline_inspector_scripts(){ Date: Tue, 5 Jul 2016 10:37:47 +0200 Subject: [PATCH 03/12] Support for GlotPress Resolves GH-30 --- so-css.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/so-css.php b/so-css.php index d33449b..e2f77d2 100644 --- a/so-css.php +++ b/so-css.php @@ -8,6 +8,7 @@ Plugin URI: https://siteorigin.com/css/ License: GPL3 License URI: https://www.gnu.org/licenses/gpl-3.0.txt +Text Domain: so-css */ // Handle the legacy CSS editor that came with SiteOrigin themes @@ -28,6 +29,7 @@ function __construct(){ $this->snippet_paths = array(); // Main header actions + add_action( 'plugins_loaded', array($this, 'set_plugin_textdomain') ); add_action( 'wp_head', array($this, 'action_wp_head'), 20 ); // All the admin actions @@ -90,6 +92,10 @@ function action_wp_head(){ echo "\n"; } + function set_plugin_textdomain(){ + load_plugin_textdomain('so-css', false, plugin_dir_path( __FILE__ ). '/languages/'); + } + /** * Action to run on the admin action. */ From 1d8068b92c80aaa235c81bccb352aa55ec13683a Mon Sep 17 00:00:00 2001 From: Greg Priday Date: Tue, 5 Jul 2016 10:45:11 +0200 Subject: [PATCH 04/12] Moved function to less prominent position --- so-css.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/so-css.php b/so-css.php index e2f77d2..1e09492 100644 --- a/so-css.php +++ b/so-css.php @@ -57,13 +57,6 @@ function __construct(){ } } - function disable_ngg_resource_manager() { - if( !current_user_can('edit_theme_options') ) return; - - //The NextGen Gallery plugin does some weird interfering with the output buffer. - define('NGG_DISABLE_RESOURCE_MANAGER', true); - } - /** * Get a singleton of the SiteOrigin CSS. * @@ -431,6 +424,13 @@ function inline_inspector_scripts(){ Date: Wed, 6 Jul 2016 11:53:02 +0200 Subject: [PATCH 05/12] To fix #34 visual editor breaking when more than 1 `@import` statement. --- js/css.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/css.js b/js/css.js index c65abcb..5510f70 100755 --- a/js/css.js +++ b/js/css.js @@ -240,7 +240,7 @@ } } - if (found.length < 2) { + if (selector === '@imports' || found.length < 2) { return found; } else { @@ -279,8 +279,8 @@ } var found = this.findBySelector(cssObjectArray, obj.selector); //found compressed - if ( found.length !== 0 ) { - compressed.push(found[0]); + if ( found.length > 0 ) { + compressed = compressed.concat(found); done[obj.selector] = true; } } @@ -695,4 +695,4 @@ window.cssjs = fi; -})(); \ No newline at end of file +})(); From 58e933fbee012ced1eb4d0d549db51fe4605afcc Mon Sep 17 00:00:00 2001 From: Braam Genis Date: Thu, 7 Jul 2016 11:57:22 +0200 Subject: [PATCH 06/12] Don't link the latest/current custom CSS revision. --- tpl/page.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tpl/page.php b/tpl/page.php index 33f000a..047b6a9 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -1,4 +1,8 @@ -get_snippets(); ?> +get_snippets(); ?>

@@ -43,12 +47,18 @@
    $css) { + if ( is_array( $custom_css_revisions ) ) { + $is_current = true; + foreach ( $custom_css_revisions as $time => $css ) { ?>
  1. - - () + + (Current) + + + + () +
-

\ No newline at end of file + From eb28d98557f615c2d25793d572f2ad284c20d6aa Mon Sep 17 00:00:00 2001 From: Braam Genis Date: Thu, 28 Jul 2016 14:23:53 +0200 Subject: [PATCH 07/12] Bit of cleanup. --- inc/controller-config.php | 4 ++-- js/editor.js | 10 +++++++++- so-css.php | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/inc/controller-config.php b/inc/controller-config.php index e0a0d06..eab263a 100644 --- a/inc/controller-config.php +++ b/inc/controller-config.php @@ -110,7 +110,7 @@ ), array( 'title' => __('Font Family', 'so-css'), - 'type' => 'font-select', + 'type' => 'font_select', 'args' => array( 'property' => 'font-family', ) @@ -501,4 +501,4 @@ ) ), -); \ No newline at end of file +); diff --git a/js/editor.js b/js/editor.js index 2cb3313..a25eb49 100644 --- a/js/editor.js +++ b/js/editor.js @@ -669,6 +669,12 @@ */ render: function () { var thisView = this; + + // Clean up for potential re-renders + this.$('.section-tabs').empty(); + this.$('.sections').empty(); + this.$('.toolbar select').off(); + thisView.propertyControllers = []; var controllers = socssOptions.propertyControllers; @@ -879,7 +885,9 @@ if (typeof activeSelector === 'undefined') { activeSelector = dropdown.find('option').eq(0).attr('val'); } - dropdown.val(activeSelector).change(); + if(!_.isEmpty(activeSelector)) { + dropdown.val(activeSelector).change(); + } }, /** diff --git a/so-css.php b/so-css.php index e2f77d2..77b2589 100644 --- a/so-css.php +++ b/so-css.php @@ -434,4 +434,4 @@ function inline_inspector_scripts(){ } // Initialize the single -SiteOrigin_CSS::single(); \ No newline at end of file +SiteOrigin_CSS::single(); From eb9e28e8b4d5ec65adf536c38b45fbe5c9d8ea4b Mon Sep 17 00:00:00 2001 From: Braam Genis Date: Wed, 3 Aug 2016 11:07:52 +0200 Subject: [PATCH 08/12] Add ability to set @ rule values, but only supporting @imports for now. Will expand later. --- js/editor.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/js/editor.js b/js/editor.js index a25eb49..b0750f6 100644 --- a/js/editor.js +++ b/js/editor.js @@ -775,6 +775,42 @@ this.updateMainEditor( false ); }, + /** + * Adds the @ rule value if it doesn't already exist. + * Currently this only supports @imports, but should be expanded to include other @ rules later. + * + * @param atRule + * @param value + */ + setAtRuleValue: function (atRule, value) { + if(atRule !== 'imports') { + return; + } + + // get @ rules + // check if any have the same value + // if not, then add the new @ rule + var exists = _.chain( this.parsed ) + .filter( function ( rule ) { + return rule.selector.charAt( 0 ) === '@'; + } ) + .any( function ( rule ) { + return rule.type === atRule && rule.styles === value; + } ).value(); + + if ( !exists ) { + var newRule = { + selector: '@' + atRule, + styles: value, + type: atRule + }; + // Add it to the top! + this.parsed.unshift( newRule ); + } + + this.updateMainEditor( false ); + }, + /** * Get the rule value for the active selector * @param rule From 862cf057b5dd972e2a57923c09267586c862f747 Mon Sep 17 00:00:00 2001 From: Braam Genis Date: Wed, 3 Aug 2016 11:18:19 +0200 Subject: [PATCH 09/12] Exclude @imports from active selector dropdown. --- js/editor.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/editor.js b/js/editor.js index b0750f6..c00fa44 100644 --- a/js/editor.js +++ b/js/editor.js @@ -894,7 +894,12 @@ var dropdown = this.$('.toolbar select').empty(); for (var i = 0; i < this.parsed.length; i++) { var rule = this.parsed[i]; - + + // Exclude @imports statements + if(rule.type === 'imports') { + continue; + } + if( typeof rule.subStyles !== 'undefined' ) { for (var j = 0; j < rule.subStyles.length; j++) { From 6e271c11eeeffb0968826e27d860a864ad6f8ff1 Mon Sep 17 00:00:00 2001 From: Braam Genis Date: Mon, 8 Aug 2016 10:18:23 +0200 Subject: [PATCH 10/12] Removed general 'setAtRule' value function and replace with more specific functions for dealing with '@import' statements. --- js/editor.js | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/js/editor.js b/js/editor.js index c00fa44..7feb588 100644 --- a/js/editor.js +++ b/js/editor.js @@ -776,40 +776,48 @@ }, /** - * Adds the @ rule value if it doesn't already exist. - * Currently this only supports @imports, but should be expanded to include other @ rules later. + * Adds the @import rule value if it doesn't already exist. * * @param atRule * @param value */ - setAtRuleValue: function (atRule, value) { - if(atRule !== 'imports') { - return; - } + addImport: function (value) { - // get @ rules + // get @import rules // check if any have the same value // if not, then add the new @ rule - var exists = _.chain( this.parsed ) - .filter( function ( rule ) { - return rule.selector.charAt( 0 ) === '@'; - } ) - .any( function ( rule ) { - return rule.type === atRule && rule.styles === value; - } ).value(); + + var importRules = _.filter( this.parsed, function ( selector ) { + return selector.selector.startsWith('@import'); + } ); + var exists = _.any( importRules, function ( rule ) { + return rule.styles === value; + } ); if ( !exists ) { var newRule = { - selector: '@' + atRule, + selector: '@imports', styles: value, - type: atRule + type: 'imports' }; - // Add it to the top! + // Add it to the top! @import statements must precede other rule types. this.parsed.unshift( newRule ); } this.updateMainEditor( false ); }, + + /** + * Find @import which completely or partially contains the specified value. + * + * @param value + */ + findImport: function(value) { + + return _.find( this.parsed, function ( selector ) { + return selector.selector.startsWith('@import') && selector.styles.indexOf(value) > -1; + } ); + }, /** * Get the rule value for the active selector From dce2d7124269e7ac26e6034ea9c2b5d180075adb Mon Sep 17 00:00:00 2001 From: Greg Priday Date: Sun, 14 Aug 2016 09:36:16 +0200 Subject: [PATCH 11/12] Readme updates --- readme.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/readme.txt b/readme.txt index 707700b..c925291 100644 --- a/readme.txt +++ b/readme.txt @@ -62,6 +62,12 @@ We offer free support on the [SiteOrigin support forums](https://siteorigin.com/ == Changelog == += 1.0.8 - 15 August 2016 = +* Fixed action link. +* Support for GlotPress. +* Removed unused code. +* Handling of @imports for future addons. + = 1.0.7 - 4 July 2016 = * Ensure user can copy/paste in editor via context menu. * Added plugin action links From 5b87bdd6d3e6abede6d3ed3fc67baade25db01c9 Mon Sep 17 00:00:00 2001 From: Greg Priday Date: Mon, 15 Aug 2016 08:41:59 +0200 Subject: [PATCH 12/12] Updated tested tag. --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index c925291..155a18a 100644 --- a/readme.txt +++ b/readme.txt @@ -1,7 +1,7 @@ === SiteOrigin CSS === Tags: css, design, edit, customize Requires at least: 3.9 -Tested up to: 4.4.1 +Tested up to: 4.6 Stable tag: trunk Build time: unbuilt License: GPLv2 or later