diff --git a/README.md b/README.md index 8c8ff56..21d37c8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ * Tags: admin bar, admin, development, staging * Requires at least: 4.0 * Tested up to: 4.5.3 -* Stable tag: 0.9.0 +* Stable tag: 0.9.4 * License: GNU General Public License v2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -48,6 +48,10 @@ function sites_filter( $sites ) { ## Changelog ## +### 0.9.4 ### +* added an export and import option +* minor improvements + ### 0.9.3 ### * Removed Scheme URL from saved options * added filter 'apermo-adminbar-sites' to give the option of saving the settings in a theme diff --git a/apermo-adminbar.php b/apermo-adminbar.php index 64346db..c68f775 100644 --- a/apermo-adminbar.php +++ b/apermo-adminbar.php @@ -6,7 +6,7 @@ * * @wordpress-plugin * Plugin Name: Apermo AdminBar - * Version: 0.9.3 + * Version: 0.9.4 * Description: A simple plugin that allows you to add custom links to the AdminBar, navigation between your live and dev systems * Author: Christoph Daum * Author URI: http://apermo.de/ @@ -132,6 +132,8 @@ public function init() { // Allow to add (or remove) further page types via filter. $this->allowed_page_types = apply_filters( 'apermo-adminbar-types', $types ); + // 'all' is reserved, it is used for the serialized data, and it would possibly create side effects. + unset( $this->allowed_page_types['all'] ); $this->load_sites(); if ( count( $this->sites ) ) { add_action( 'admin_bar_menu', array( $this, 'admin_bar_filter' ), 99 ); @@ -327,7 +329,7 @@ public function settings_init() { 'apermo_adminbar_sites_section_' . $key, $data['label'], function( $data ) { - echo esc_html( $data['description'] ); + return esc_html( $data['description'] ); }, 'apermo_adminbar' ); @@ -359,6 +361,28 @@ function( $data ) { array( 'key' => $key, 'data' => $data ) ); } + + add_settings_section( + 'apermo_adminbar_sites_section_serialized', + __( 'Export/Import', 'apermo-adminbar' ), + function(){}, + 'apermo_adminbar' + ); + add_settings_field( + 'apermo_adminbar_sites_import', + __( 'Import', 'apermo-adminbar' ), + array( $this, 'import_render' ), + 'apermo_adminbar', + 'apermo_adminbar_sites_section_serialized' + ); + + add_settings_field( + 'apermo_adminbar_sites_export', + __( 'Export', 'apermo-adminbar' ), + array( $this, 'export_render' ), + 'apermo_adminbar', + 'apermo_adminbar_sites_section_serialized' + ); } /** @@ -436,6 +460,30 @@ public function color_render( $args ) { + +

+ + + sites ) ) { ?> +

+
sites ); ?>
+ +

+ sanitize( $all ); + + if ( is_array( $output ) && count( $output ) ) { + return $output; + } + } + + unset( $input['all'] ); + } + // Check all incoming pages. foreach ( $input as $key => $data ) { // Probably useless, but safety is the mother of the Porzellankiste.