Skip to content

Commit

Permalink
Bump to v1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mauryaratan committed May 22, 2014
1 parent c16aaa8 commit 16a24c1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 28 deletions.
11 changes: 7 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: mauryaratan, codestag
Donate link: http://codest.ag/scs-donate
Tags: sidebars, custom-sidebars, mauryaratan, codestag, shortcodes, widgets
Requires at least: 3.3
Stable tag: 1.0.6
Tested up to: 3.9
Stable tag: 1.0.7
Tested up to: 4.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -20,7 +20,7 @@ To display the sidebar with shortcode you can use ``[stag_sidebar id="custom-sid
[vimeo https://vimeo.com/86626101]

= Import/Export =
We have added compatibility with [Widget Importer & Exporter](http://wordpress.org/plugins/widget-importer-exporter), which gives you the freedom to import and export custom widget areas when moving widgets from one site to another or backing up the widgets.
We have added compatibility with [Widget Importer & Exporter](https://wordpress.org/plugins/widget-importer-exporter), which gives you the freedom to import and export custom widget areas when moving widgets from one site to another or backing up the widgets.

If you'd like to check out the code and contribute, [join us on GitHub](https://github.com/mauryaratan/stag-custom-sidebars). Pull requests, issues, and plugin recommendations are more than welcome!

Expand Down Expand Up @@ -62,8 +62,11 @@ Bugs can be reported either in our support forum or preferably on the [Stag Cust

== Changelog ==

= 1.0.7 - May 22, 2014 =
* Added compatibilty with Widget Customizer

= 1.0.6 - February 18, 2014 =
* Ability to import/export custom widgets area via [Widget Importer & Exporter](http://wordpress.org/plugins/widget-importer-exporter)
* Ability to import/export custom widgets area via [Widget Importer & Exporter](https://wordpress.org/plugins/widget-importer-exporter)
* Performance tweaks

= 1.0.5 - December 21, 2013 =
Expand Down
68 changes: 44 additions & 24 deletions stag-custom-sidebars.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Plugin Name: Stag Custom Sidebars
* Plugin URI: http://wordpress.org/plugins/stag-custom-sidebars
* Description: Create custom dynamic sidebars and use anywhere with shortcodes.
* Version: 1.0.6
* Version: 1.0.7
* Author: Ram Ratan Maurya
* Author URI: http://mauryaratan.me
* Requires at least: 3.3
* Tested up to: 3.8
* Tested up to: 4.0
* License: GPLv2 or later
*
* Text Domain: stag
Expand All @@ -21,21 +21,21 @@
*
* @package Stag_Custom_Sidebars
* @author Ram Ratan Maurya
* @version 1.0.6
* @copyright 2013 Ram Ratan Maurya
* @version 1.0.7
* @copyright 2014 Ram Ratan Maurya
*/
final class Stag_Custom_Sidebars {

/**
* @var Stag_Custom_Sidebars The single instance of the class
* @since 1.0.6
* @since 1.0.7
*/
protected static $_instance = null;

/**
* @var string
*/
public $version = '1.0.6';
public $version = '1.0.7';

/**
* @var string
Expand Down Expand Up @@ -88,7 +88,7 @@ function __construct() {

// Load plugin text domain
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );

add_action( 'admin_footer', array( &$this, 'template_custom_widget_area' ), 200 );
add_action( 'load-widgets.php', array( &$this, 'load_scripts_styles' ) , 5 );

Expand All @@ -100,11 +100,13 @@ function __construct() {
add_filter( 'wie_unencoded_export_data', array( &$this, 'export_data' ) );
add_filter( 'wie_import_results', array( &$this, 'reset_custom_key' ) );
add_action( 'wie_import_data', array( &$this, 'before_wie_import' ) );

add_action( 'customize_controls_print_scripts', array( &$this, 'customize_controls_print_scripts' ) );
}

/**
* Internationalization.
*
*
* @return void
*/
function load_plugin_textdomain () {
Expand Down Expand Up @@ -221,37 +223,37 @@ public function delete_sidebar_area() {

/**
* Check user entered widget area name and manage conflicts.
*
*
* @param string $name User entered name
* @return string Processed name
*/
public function get_name($name) {
if ( empty( $GLOBALS['wp_registered_sidebars'] ) ) {
return $name;
}

$taken = array();

foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar ) {
$taken[] = $sidebar['name'];
}

if( empty($this->sidebars) ) $this->sidebars = array();
$taken = array_merge($taken, $this->sidebars);

if ( in_array( $name, $taken ) ) {
$counter = substr($name, -1);
$counter = substr($name, -1);
$new_name = "";

if ( ! is_numeric($counter) ) {
$new_name = $name . " 1";
} else {
$new_name = substr($name, 0, -1) . ((int) $counter + 1);
}

$name = $this->get_name($new_name);
}

return $name;
}

Expand All @@ -268,7 +270,7 @@ public function register_custom_sidebars() {
$args = apply_filters( 'stag_custom_sidebars_widget_args', array(
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widgettitle">',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
)
);
Expand All @@ -285,7 +287,7 @@ public function register_custom_sidebars() {

/**
* Shortcode handler.
*
*
* @param array $atts Array of attributes
* @return string $output returns the modified html string
*/
Expand All @@ -305,9 +307,9 @@ public function stag_sidebar_shortcode( $atts ) {
echo "<section id='{$id}' class='stag-custom-widget-area {$class}'>";
dynamic_sidebar( $id );
echo "</section>";

do_action( 'stag_custom_sidebars_after' );

$output = ob_get_clean();
}

Expand All @@ -318,10 +320,10 @@ public function stag_sidebar_shortcode( $atts ) {
* Set a custom array key in export data.
*
* Inject all custom sidebar areas created on site under export data of "Widget Importer and Exporter".
*
*
* @uses Widget_Importer_Exporter
* @link http://wordpress.org/plugins/widget-importer-exporter
*
*
* @since 1.0.6
* @param array $sidebars An array containing sidebars' widget data.
* @return array $sidebars Modified array, adds custom array key set during export.
Expand All @@ -340,7 +342,7 @@ public function export_data( $sidebars ) {
*
* @uses Widget_Importer_Exporter
* @link http://wordpress.org/plugins/widget-importer-exporter
*
*
* @since 1.0.6
* @param array $results An array containing sidebars' widget data.
* @return array $results Modified array, deletes custom array key set during export.
Expand All @@ -358,7 +360,7 @@ public function reset_custom_key( $results ) {
* Also register new custom widgets areas.
*
* @global $wp_registered_sidebars
*
*
* @param object $data Contains widget import data.
* @return array $data Modified widget import data.
*/
Expand Down Expand Up @@ -387,6 +389,24 @@ function before_wie_import( $data ) {

return $data;
}

/**
* Tweak style for Widget customizer.
*
* @since 1.0.7.
* @return void
*/
function customize_controls_print_scripts() {
// Get custom sidebar keys
$sidebars = array_keys( get_option('stag_custom_sidebars') );

echo "<style type='text/css'>\n";
foreach ( $sidebars as $sidebar_id ) :
echo "#accordion-section-sidebar-widgets-{$sidebar_id} { display: list-item !important; height: auto !important; }\n";
echo "#accordion-section-sidebar-widgets-{$sidebar_id} .widget-top { opacity: 1 !important; }\n";
endforeach;
echo "</style>\n";
}
}

/**
Expand Down

0 comments on commit 16a24c1

Please sign in to comment.