Widget Importer & Exporter - Version 1.2

Version Description

Download this release

Release Info

Developer stevengliebe
Plugin Icon 128x128 Widget Importer & Exporter
Version 1.2
Comparing to
See all releases

Code changes from version 1.1.4 to 1.2

includes/import.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @package Widget_Importer_Exporter
6
  * @subpackage Functions
7
- * @copyright Copyright (c) 2013, DreamDolphin Media, LLC
8
  * @link https://github.com/stevengliebe/widget-importer-exporter
9
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
  * @since 0.3
@@ -176,9 +176,22 @@ function wie_import_data( $data ) {
176
  $widget_message = __( 'Site does not support widget', 'widget-importer-exporter' ); // explain why widget not imported
177
  }
178
 
179
- // Filter to modify settings before import
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  // Do before identical check because changes may make it identical to end result (such as URL replacements)
181
- $widget = apply_filters( 'wie_widget_settings', $widget );
182
 
183
  // Does widget with identical settings already exist in same sidebar?
184
  if ( ! $fail && isset( $widget_instances[$id_base] ) ) {
@@ -212,7 +225,7 @@ function wie_import_data( $data ) {
212
  // Add widget instance
213
  $single_widget_instances = get_option( 'widget_' . $id_base ); // all instances for that widget ID base, get fresh every time
214
  $single_widget_instances = ! empty( $single_widget_instances ) ? $single_widget_instances : array( '_multiwidget' => 1 ); // start fresh if have to
215
- $single_widget_instances[] = (array) $widget; // add it
216
 
217
  // Get the key it was given
218
  end( $single_widget_instances );
@@ -255,7 +268,7 @@ function wie_import_data( $data ) {
255
 
256
  // Result for widget instance
257
  $results[$sidebar_id]['widgets'][$widget_instance_id]['name'] = isset( $available_widgets[$id_base]['name'] ) ? $available_widgets[$id_base]['name'] : $id_base; // widget name or ID if name not available (not supported by site)
258
- $results[$sidebar_id]['widgets'][$widget_instance_id]['title'] = $widget->title ? $widget->title : __( 'No Title', 'widget-importer-exporter' ); // show "No Title" if widget instance is untitled
259
  $results[$sidebar_id]['widgets'][$widget_instance_id]['message_type'] = $widget_message_type;
260
  $results[$sidebar_id]['widgets'][$widget_instance_id]['message'] = $widget_message;
261
 
4
  *
5
  * @package Widget_Importer_Exporter
6
  * @subpackage Functions
7
+ * @copyright Copyright (c) 2013 - 2015, DreamDolphin Media, LLC
8
  * @link https://github.com/stevengliebe/widget-importer-exporter
9
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10
  * @since 0.3
176
  $widget_message = __( 'Site does not support widget', 'widget-importer-exporter' ); // explain why widget not imported
177
  }
178
 
179
+ // Filter to modify settings object before conversion to array and import
180
+ // Leave this filter here for backwards compatibility with manipulating objects (before conversion to array below)
181
+ // Ideally the newer wie_widget_settings_array below will be used instead of this
182
+ $widget = apply_filters( 'wie_widget_settings', $widget ); // object
183
+
184
+ // Convert multidimensional objects to multidimensional arrays
185
+ // Some plugins like Jetpack Widget Visibility store settings as multidimensional arrays
186
+ // Without this, they are imported as objects and cause fatal error on Widgets page
187
+ // If this creates problems for plugins that do actually intend settings in objects then may need to consider other approach: https://wordpress.org/support/topic/problem-with-array-of-arrays
188
+ // It is probably much more likely that arrays are used than objects, however
189
+ $widget = json_decode( json_encode( $widget ), true );
190
+
191
+ // Filter to modify settings array
192
+ // This is preferred over the older wie_widget_settings filter above
193
  // Do before identical check because changes may make it identical to end result (such as URL replacements)
194
+ $widget = apply_filters( 'wie_widget_settings_array', $widget );
195
 
196
  // Does widget with identical settings already exist in same sidebar?
197
  if ( ! $fail && isset( $widget_instances[$id_base] ) ) {
225
  // Add widget instance
226
  $single_widget_instances = get_option( 'widget_' . $id_base ); // all instances for that widget ID base, get fresh every time
227
  $single_widget_instances = ! empty( $single_widget_instances ) ? $single_widget_instances : array( '_multiwidget' => 1 ); // start fresh if have to
228
+ $single_widget_instances[] = $widget; // add it
229
 
230
  // Get the key it was given
231
  end( $single_widget_instances );
268
 
269
  // Result for widget instance
270
  $results[$sidebar_id]['widgets'][$widget_instance_id]['name'] = isset( $available_widgets[$id_base]['name'] ) ? $available_widgets[$id_base]['name'] : $id_base; // widget name or ID if name not available (not supported by site)
271
+ $results[$sidebar_id]['widgets'][$widget_instance_id]['title'] = ! empty( $widget['title'] ) ? $widget['title'] : __( 'No Title', 'widget-importer-exporter' ); // show "No Title" if widget instance is untitled
272
  $results[$sidebar_id]['widgets'][$widget_instance_id]['message_type'] = $widget_message_type;
273
  $results[$sidebar_id]['widgets'][$widget_instance_id]['message'] = $widget_message;
274
 
languages/widget-importer-exporter.pot CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Widget Importer & Exporter\n"
4
- "POT-Creation-Date: 2013-07-12 18:21-0600\n"
5
- "PO-Revision-Date: 2013-07-12 18:21-0600\n"
6
  "Last-Translator: churchthemes.com\n"
7
  "Language-Team: \n"
8
- "Language: English\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.5.7\n"
13
  "X-Poedit-KeywordsList: __;_e;_n:1,2;_nx:1,2;_x:1,2c;_ex:1,2c;esc_attr__;"
14
  "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
15
  "_nx_noop:1,2,3c\n"
@@ -30,38 +30,34 @@ msgstr ""
30
  msgid "Import data could not be read. Please try a different file."
31
  msgstr ""
32
 
33
- #: ../includes/import.php:151
34
- msgid "Sidebar does not exist in theme"
35
  msgstr ""
36
 
37
- #: ../includes/import.php:173
38
  msgid "Site does not support widget"
39
  msgstr ""
40
 
41
- #: ../includes/import.php:192
42
  msgid "Widget already exists"
43
  msgstr ""
44
 
45
- #: ../includes/import.php:227
46
  msgid "Imported"
47
  msgstr ""
48
 
49
- #: ../includes/import.php:230
50
  msgid "Imported to Inactive"
51
  msgstr ""
52
 
53
- #: ../includes/import.php:237
54
  msgid "No Title"
55
  msgstr ""
56
 
57
- #: ../includes/page.php:27 ../includes/page.php:63
58
  msgid "Widget Importer & Exporter"
59
  msgstr ""
60
 
61
- #: ../includes/page.php:28
62
- msgid "Widget Import/Export"
63
- msgstr ""
64
-
65
  #: ../includes/page.php:73
66
  msgctxt "heading"
67
  msgid "Import Widgets"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Widget Importer & Exporter\n"
4
+ "POT-Creation-Date: 2015-02-23 09:31-0600\n"
5
+ "PO-Revision-Date: 2015-02-23 09:31-0600\n"
6
  "Last-Translator: churchthemes.com\n"
7
  "Language-Team: \n"
8
+ "Language: en\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.7.4\n"
13
  "X-Poedit-KeywordsList: __;_e;_n:1,2;_nx:1,2;_x:1,2c;_ex:1,2c;esc_attr__;"
14
  "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
15
  "_nx_noop:1,2,3c\n"
30
  msgid "Import data could not be read. Please try a different file."
31
  msgstr ""
32
 
33
+ #: ../includes/import.php:154
34
+ msgid "Sidebar does not exist in theme (using Inactive)"
35
  msgstr ""
36
 
37
+ #: ../includes/import.php:176
38
  msgid "Site does not support widget"
39
  msgstr ""
40
 
41
+ #: ../includes/import.php:212
42
  msgid "Widget already exists"
43
  msgstr ""
44
 
45
+ #: ../includes/import.php:261
46
  msgid "Imported"
47
  msgstr ""
48
 
49
+ #: ../includes/import.php:264
50
  msgid "Imported to Inactive"
51
  msgstr ""
52
 
53
+ #: ../includes/import.php:271
54
  msgid "No Title"
55
  msgstr ""
56
 
57
+ #: ../includes/page.php:27 ../includes/page.php:28 ../includes/page.php:63
58
  msgid "Widget Importer & Exporter"
59
  msgstr ""
60
 
 
 
 
 
61
  #: ../includes/page.php:73
62
  msgctxt "heading"
63
  msgid "Import Widgets"
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: stevengliebe, churchthemes
3
  Tags: widgets, widget, importer, exporter, import, export, backup
4
  Requires at least: 3.5
5
- Tested up to: 4.0
6
  Stable tag: trunk
7
  License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
8
 
2
  Contributors: stevengliebe, churchthemes
3
  Tags: widgets, widget, importer, exporter, import, export, backup
4
  Requires at least: 3.5
5
+ Tested up to: 4.1
6
  Stable tag: trunk
7
  License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
8
 
widget-importer-exporter.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Widget Importer & Exporter
4
  * Plugin URI: https://github.com/stevengliebe/widget-importer-exporter
5
  * Description: Imports and exports widgets.
6
- * Version: 1.1.4
7
  * Author: Steven Gliebe
8
  * Author URI: http://stevengliebe.com
9
  * License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
@@ -11,7 +11,7 @@
11
  * Domain Path: /languages
12
  *
13
  * @package Widget_Importer_Exporter
14
- * @copyright Copyright (c) 2013, DreamDolphin Media, LLC
15
  * @link https://github.com/stevengliebe/widget-importer-exporter
16
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17
  */
3
  * Plugin Name: Widget Importer & Exporter
4
  * Plugin URI: https://github.com/stevengliebe/widget-importer-exporter
5
  * Description: Imports and exports widgets.
6
+ * Version: 1.2
7
  * Author: Steven Gliebe
8
  * Author URI: http://stevengliebe.com
9
  * License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11
  * Domain Path: /languages
12
  *
13
  * @package Widget_Importer_Exporter
14
+ * @copyright Copyright (c) 2013 - 2015, DreamDolphin Media, LLC
15
  * @link https://github.com/stevengliebe/widget-importer-exporter
16
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17
  */