Skip to content

Commit

Permalink
Merge branch 'release/1.0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
gregpriday committed Aug 15, 2016
2 parents 9d72a64 + 5b87bdd commit 66ae0e3
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 41 deletions.
4 changes: 2 additions & 2 deletions inc/controller-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
),
array(
'title' => __('Font Family', 'so-css'),
'type' => 'font-select',
'type' => 'font_select',
'args' => array(
'property' => 'font-family',
)
Expand Down Expand Up @@ -501,4 +501,4 @@
)
),

);
);
8 changes: 4 additions & 4 deletions js/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
}

}
if (found.length < 2) {
if (selector === '@imports' || found.length < 2) {
return found;
}
else {
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -695,4 +695,4 @@

window.cssjs = fi;

})();
})();
61 changes: 59 additions & 2 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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++) {
Expand All @@ -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();
}
},

/**
Expand Down
8 changes: 7 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
41 changes: 15 additions & 26 deletions so-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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') );
Expand All @@ -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.
*
Expand Down Expand Up @@ -90,6 +85,10 @@ function action_wp_head(){
echo "</style>\n";
}

function set_plugin_textdomain(){
load_plugin_textdomain('so-css', false, plugin_dir_path( __FILE__ ). '/languages/');
}

/**
* Action to run on the admin action.
*/
Expand Down Expand Up @@ -231,7 +230,7 @@ function action_admin_footer(){

function plugin_action_links( $links ){
if( isset($links['edit']) ) unset( $links['edit'] );
$links['css_editor'] = '<a href="' . admin_url('plugins.php?page=so-widgets-plugins') . '">'.__('CSS Editor', 'so-css').'</a>';
$links['css_editor'] = '<a href="' . admin_url('themes.php?page=so_custom_css') . '">'.__('CSS Editor', 'so-css').'</a>';
$links['support'] = '<a href="https://siteorigin.com/thread/" target="_blank">'.__('Support', 'so-css').'</a>';
return $links;
}
Expand All @@ -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;
}
Expand All @@ -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 );
}
}
Expand Down Expand Up @@ -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();
SiteOrigin_CSS::single();
22 changes: 16 additions & 6 deletions tpl/page.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php $snippets = SiteOrigin_CSS::single()->get_snippets(); ?>
<?php
/**
* @var $custom_css_revisions array Saved revisions for the current theme.
*/
$snippets = SiteOrigin_CSS::single()->get_snippets(); ?>

<div class="wrap" id="siteorigin-custom-css">
<h2>
Expand Down Expand Up @@ -43,12 +47,18 @@
<div class="inside">
<ol data-confirm="<?php esc_attr_e('Are you sure you want to load this revision?', 'so-css') ?>">
<?php
if( is_array($custom_css_revisions) ) {
foreach($custom_css_revisions as $time => $css) {
if ( is_array( $custom_css_revisions ) ) {
$is_current = true;
foreach ( $custom_css_revisions as $time => $css ) {
?>
<li>
<a href="<?php echo add_query_arg(array('theme' => $theme, 'time' => $time)) ?>" class="load-css-revision"><?php echo date('j F Y @ H:i:s', $time + get_option('gmt_offset') * 60 * 60) ?></a>
(<?php printf(__('%d chars', 'so-css'), strlen($css)) ?>)
<?php if ( $is_current ) : ?>
<?php echo date('j F Y @ H:i:s', $time + get_option('gmt_offset') * 60 * 60) ?> (Current)
<?php $is_current = false; ?>
<?php else : ?>
<a href="<?php echo esc_url( add_query_arg( array( 'theme' => $theme, 'time' => $time ) ) ) ?>" class="load-css-revision"><?php echo date('j F Y @ H:i:s', $time + get_option('gmt_offset') * 60 * 60) ?></a>
(<?php printf(__('%d chars', 'so-css'), strlen($css)) ?>)
<?php endif; ?>
</li>
<?php
}
Expand Down Expand Up @@ -124,4 +134,4 @@

<div class="clear"></div>

</div>
</div>

0 comments on commit 66ae0e3

Please sign in to comment.