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/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 +})(); diff --git a/js/editor.js b/js/editor.js index 2cb3313..7feb588 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; @@ -769,6 +775,50 @@ this.updateMainEditor( false ); }, + /** + * Adds the @import rule value if it doesn't already exist. + * + * @param atRule + * @param value + */ + addImport: function (value) { + + // get @import rules + // check if any have the same value + // if not, then add the new @ rule + + 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: '@imports', + styles: value, + type: 'imports' + }; + // 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 * @param rule @@ -852,7 +902,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++) { @@ -879,7 +934,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/readme.txt b/readme.txt index 707700b..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 @@ -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 diff --git a/so-css.php b/so-css.php index 0a3004d..c594cb7 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 @@ -45,7 +47,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') ); @@ -55,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. * @@ -90,6 +85,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. */ @@ -231,7 +230,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; } @@ -242,7 +241,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 +256,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 ); } } @@ -426,23 +425,13 @@ function inline_inspector_scripts(){ } } - /** - * Get a URL to tweet out the changes - */ - function get_tweet_url(){ - $tweet = __('I changed my site design using @SiteOrigin CSS (http://siteorigin.com/css/). What do you think?', 'so-css'); - $tweet .= ' '; - $tweet .= get_site_url(); - - return add_query_arg( - 'text', - urlencode($tweet), - 'https://twitter.com/intent/tweet' - ); - + 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); } } // Initialize the single -SiteOrigin_CSS::single(); \ No newline at end of file +SiteOrigin_CSS::single(); 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 +