Version Description
Download this release
Release Info
Developer | stevengliebe |
Plugin | Widget Importer & Exporter |
Version | 1.0 |
Comparing to | |
See all releases |
Code changes from version 0.8 to 1.0
- languages/important.txt +8 -5
- languages/widget-importer-exporter-es_ES.mo +0 -0
- languages/widget-importer-exporter-es_ES.po +113 -0
- readme.txt +10 -25
- trunk/css/style.css +42 -0
- trunk/includes/export.php +143 -0
- trunk/includes/import.php +256 -0
- trunk/includes/mime-types.php +33 -0
- trunk/includes/page.php +203 -0
- trunk/includes/widgets.php +47 -0
- trunk/languages/important.txt +9 -0
- trunk/languages/widget-importer-exporter-es_ES.mo +0 -0
- trunk/languages/widget-importer-exporter-es_ES.po +113 -0
- trunk/languages/widget-importer-exporter.pot +102 -0
- trunk/license.txt +339 -0
- trunk/readme.txt +51 -0
- trunk/widget-importer-exporter.php +249 -0
- widget-importer-exporter.php +1 -1
languages/important.txt
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
-
Do not add your own translations to this directory. They will be lost during plugin
|
2 |
-
The only .mo files that should be loaded from here are pre-made translations
|
3 |
-
|
4 |
|
5 |
-
Store your translations at
|
6 |
-
|
|
|
|
|
|
1 |
+
Do not add your own translations to this directory. They will be lost during plugin
|
2 |
+
updates. The only .mo files that should be loaded from here are pre-made translations
|
3 |
+
that come with the plugin.
|
4 |
|
5 |
+
Store your translations at:
|
6 |
+
wp-content/languages/plugins/widget-importer-exporter-$locale.mo
|
7 |
+
(e.g. widget-importer-exporter-en_US.mo) to keep them safe from loss during updates.
|
8 |
+
|
9 |
+
Please feel free to submit your translation to this project.
|
languages/widget-importer-exporter-es_ES.mo
ADDED
Binary file
|
languages/widget-importer-exporter-es_ES.po
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Widget Importer & Exporter en español\n"
|
4 |
+
"POT-Creation-Date: 2013-07-17 11:59+0100\n"
|
5 |
+
"PO-Revision-Date: 2013-07-17 12:52+0100\n"
|
6 |
+
"Last-Translator: Eduardo Larequi <elarequi@gmail.com>\n"
|
7 |
+
"Language-Team: PNTE <blogs@educacion.navarra.es>\n"
|
8 |
+
"Language: Spanish\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;_c\n"
|
16 |
+
"X-Poedit-Basepath: ..\n"
|
17 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
18 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
19 |
+
"X-Poedit-SearchPath-0: .\n"
|
20 |
+
|
21 |
+
#: includes/import.php:34
|
22 |
+
msgid "You must upload a <b>.wie</b> file generated by this plugin."
|
23 |
+
msgstr "Debes subir un fichero <b>.wie</b>, generado por este plugin."
|
24 |
+
|
25 |
+
#: includes/import.php:77
|
26 |
+
msgid "Import file could not be found. Please try again."
|
27 |
+
msgstr ""
|
28 |
+
"El fichero de importación no ha podido ser encontrado. Por favor, inténtalo "
|
29 |
+
"de nuevo."
|
30 |
+
|
31 |
+
#: includes/import.php:112
|
32 |
+
msgid "Import data could not be read. Please try a different file."
|
33 |
+
msgstr ""
|
34 |
+
"El fichero de importación no ha podido ser leído. Por favor, inténtalo de "
|
35 |
+
"nuevo con un fichero diferente."
|
36 |
+
|
37 |
+
#: includes/import.php:153
|
38 |
+
msgid "Sidebar does not exist in theme (using Inactive)"
|
39 |
+
msgstr ""
|
40 |
+
"La barra lateral no existe en el tema (sus widgets se importarán como "
|
41 |
+
"inactivos)"
|
42 |
+
|
43 |
+
#: includes/import.php:175
|
44 |
+
msgid "Site does not support widget"
|
45 |
+
msgstr "El sitio no soporta este widget"
|
46 |
+
|
47 |
+
#: includes/import.php:198
|
48 |
+
msgid "Widget already exists"
|
49 |
+
msgstr "El widget ya existe"
|
50 |
+
|
51 |
+
#: includes/import.php:232
|
52 |
+
msgid "Imported"
|
53 |
+
msgstr "Importado"
|
54 |
+
|
55 |
+
#: includes/import.php:235
|
56 |
+
msgid "Imported to Inactive"
|
57 |
+
msgstr "Importado como inactivo"
|
58 |
+
|
59 |
+
#: includes/import.php:242
|
60 |
+
msgid "No Title"
|
61 |
+
msgstr "Sin título"
|
62 |
+
|
63 |
+
#: includes/page.php:27 includes/page.php:63
|
64 |
+
msgid "Widget Importer & Exporter"
|
65 |
+
msgstr "Widget Importer & Exporter"
|
66 |
+
|
67 |
+
#: includes/page.php:28
|
68 |
+
msgid "Widget Import/Export"
|
69 |
+
msgstr "Importar y exportar widgets"
|
70 |
+
|
71 |
+
#: includes/page.php:73
|
72 |
+
msgctxt "heading"
|
73 |
+
msgid "Import Widgets"
|
74 |
+
msgstr "Importar widgets"
|
75 |
+
|
76 |
+
#: includes/page.php:76
|
77 |
+
msgid "Please select a <b>.wie</b> file generated by this plugin."
|
78 |
+
msgstr ""
|
79 |
+
"Por favor, selecciona un fichero <b>.wie</b>, generado por este plugin."
|
80 |
+
|
81 |
+
#: includes/page.php:85
|
82 |
+
msgctxt "button"
|
83 |
+
msgid "Import Widgets"
|
84 |
+
msgstr "Importar widgets"
|
85 |
+
|
86 |
+
#: includes/page.php:96
|
87 |
+
msgctxt "heading"
|
88 |
+
msgid "Export Widgets"
|
89 |
+
msgstr "Exportar widgets"
|
90 |
+
|
91 |
+
#: includes/page.php:99
|
92 |
+
msgid "Click below to generate a <b>.wie</b> file for all active widgets."
|
93 |
+
msgstr ""
|
94 |
+
"Haz clic el el botón que tienes a continuación, para generar un fichero <b>."
|
95 |
+
"wie</b>, para todos los widgets activos."
|
96 |
+
|
97 |
+
#: includes/page.php:103
|
98 |
+
msgctxt "button"
|
99 |
+
msgid "Export Widgets"
|
100 |
+
msgstr "Exportar widgets"
|
101 |
+
|
102 |
+
#: includes/page.php:145
|
103 |
+
msgctxt "heading"
|
104 |
+
msgid "Import Results"
|
105 |
+
msgstr "Resultados de la exportación"
|
106 |
+
|
107 |
+
#: includes/page.php:150
|
108 |
+
#, php-format
|
109 |
+
msgid ""
|
110 |
+
"You can manage your <a href=\"%s\">Widgets</a> or <a href=\"%s\">Go Back</a>."
|
111 |
+
msgstr ""
|
112 |
+
"Puedes gestionar tus <a href=\"%s\">widgets</a> o <a href=\"%s\">volver "
|
113 |
+
"atrás</a>."
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: stevengliebe, churchthemes
|
3 |
Tags: widgets, widget, importer, exporter, import, export, backup
|
4 |
Requires at least: 3.5
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag:
|
7 |
License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
8 |
|
9 |
Import and export your widgets.
|
@@ -22,6 +22,13 @@ Importation takes into consideration sidebars not existing in the current theme
|
|
22 |
|
23 |
Widget Importer & Exporter can create an export file (in JSON format with .wie extension) out of currently active widgets. This file can be imported into other sites using this plugin or used to restore widgets to the same site later.
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
= Developers =
|
26 |
|
27 |
The ``wie_before_import`` action fires after a file is uploaded but before the data is imported. ``wie_after_import`` fires after the data is imported. Other filters are used throughout. Let me know if you need more actions or filters.
|
@@ -41,26 +48,4 @@ After activation, go to *Tools > Widget Import/Export*
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
-
|
45 |
-
* Add wie_widget_settings filter
|
46 |
-
|
47 |
-
= 0.7 =
|
48 |
-
* Various fixes, improvements
|
49 |
-
|
50 |
-
= 0.6 =
|
51 |
-
* Import hooks, translation file, code clean up
|
52 |
-
|
53 |
-
= 0.5 =
|
54 |
-
* Finished importing
|
55 |
-
|
56 |
-
= 0.4 =
|
57 |
-
* Import error checking and results table
|
58 |
-
|
59 |
-
= 0.3 =
|
60 |
-
* Uploading finished
|
61 |
-
|
62 |
-
= 0.2 =
|
63 |
-
* Minor clean up
|
64 |
-
|
65 |
-
= 0.1 =
|
66 |
-
* First release - export only
|
2 |
Contributors: stevengliebe, churchthemes
|
3 |
Tags: widgets, widget, importer, exporter, import, export, backup
|
4 |
Requires at least: 3.5
|
5 |
+
Tested up to: 3.6
|
6 |
+
Stable tag: trunk
|
7 |
License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
8 |
|
9 |
Import and export your widgets.
|
22 |
|
23 |
Widget Importer & Exporter can create an export file (in JSON format with .wie extension) out of currently active widgets. This file can be imported into other sites using this plugin or used to restore widgets to the same site later.
|
24 |
|
25 |
+
= Translations =
|
26 |
+
|
27 |
+
The following translations are included.
|
28 |
+
|
29 |
+
* English (default)
|
30 |
+
* Spanish (es_ES) by [Eduardo Larequi](http://www.labitacoradeltigre.com/)
|
31 |
+
|
32 |
= Developers =
|
33 |
|
34 |
The ``wie_before_import`` action fires after a file is uploaded but before the data is imported. ``wie_after_import`` fires after the data is imported. Other filters are used throughout. Let me know if you need more actions or filters.
|
48 |
|
49 |
== Changelog ==
|
50 |
|
51 |
+
See [release tags](https://github.com/stevengliebe/widget-importer-exporter/tags) on GitHub.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/css/style.css
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
/* Cell padding */
|
3 |
+
|
4 |
+
#wie-import-results td {
|
5 |
+
padding: 2px 30px 2px 0;
|
6 |
+
}
|
7 |
+
|
8 |
+
/* Sidebar name */
|
9 |
+
|
10 |
+
.wie-import-results-sidebar-name {
|
11 |
+
font-weight: bold;
|
12 |
+
}
|
13 |
+
|
14 |
+
/* Widget instance title */
|
15 |
+
|
16 |
+
.wie-import-results-widget-title {
|
17 |
+
font-style: italic;
|
18 |
+
}
|
19 |
+
|
20 |
+
/* Message (sidebar and widget) */
|
21 |
+
|
22 |
+
.wie-import-results-sidebar .wie-import-results-message {
|
23 |
+
font-weight: bold;
|
24 |
+
}
|
25 |
+
|
26 |
+
.wie-import-results-message-success {
|
27 |
+
color: #1c8a1f;
|
28 |
+
}
|
29 |
+
|
30 |
+
.wie-import-results-message-warning {
|
31 |
+
color: #eb860f;
|
32 |
+
}
|
33 |
+
|
34 |
+
.wie-import-results-message-error {
|
35 |
+
color: #cc2626;
|
36 |
+
}
|
37 |
+
|
38 |
+
/* Empty row after each sidebar/widget set */
|
39 |
+
|
40 |
+
.wie-import-results-space {
|
41 |
+
height: 8px;
|
42 |
+
}
|
trunk/includes/export.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Export Functions
|
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.1
|
11 |
+
*/
|
12 |
+
|
13 |
+
// No direct access
|
14 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Generate export data
|
18 |
+
*
|
19 |
+
* @since 0.1
|
20 |
+
* @return string Export file contents
|
21 |
+
*/
|
22 |
+
function wie_generate_export_data() {
|
23 |
+
|
24 |
+
// Get all available widgets site supports
|
25 |
+
$available_widgets = wie_available_widgets();
|
26 |
+
|
27 |
+
// Get all widget instances for each widget
|
28 |
+
$widget_instances = array();
|
29 |
+
foreach ( $available_widgets as $widget_data ) {
|
30 |
+
|
31 |
+
// Get all instances for this ID base
|
32 |
+
$instances = get_option( 'widget_' . $widget_data['id_base'] );
|
33 |
+
|
34 |
+
// Have instances
|
35 |
+
if ( ! empty( $instances ) ) {
|
36 |
+
|
37 |
+
// Loop instances
|
38 |
+
foreach ( $instances as $instance_id => $instance_data ) {
|
39 |
+
|
40 |
+
// Key is ID (not _multiwidget)
|
41 |
+
if ( is_numeric( $instance_id ) ) {
|
42 |
+
$unique_instance_id = $widget_data['id_base'] . '-' . $instance_id;
|
43 |
+
$widget_instances[$unique_instance_id] = $instance_data;
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
51 |
+
|
52 |
+
// Gather sidebars with their widget instances
|
53 |
+
$sidebars_widgets = get_option( 'sidebars_widgets' ); // get sidebars and their unique widgets IDs
|
54 |
+
$sidebars_widget_instances = array();
|
55 |
+
foreach ( $sidebars_widgets as $sidebar_id => $widget_ids ) {
|
56 |
+
|
57 |
+
// Skip inactive widgets
|
58 |
+
if ( 'wp_inactive_widgets' == $sidebar_id ) {
|
59 |
+
continue;
|
60 |
+
}
|
61 |
+
|
62 |
+
// Skip if no data or not an array (array_version)
|
63 |
+
if ( ! is_array( $widget_ids ) || empty( $widget_ids ) ) {
|
64 |
+
continue;
|
65 |
+
}
|
66 |
+
|
67 |
+
// Loop widget IDs for this sidebar
|
68 |
+
foreach ( $widget_ids as $widget_id ) {
|
69 |
+
|
70 |
+
// Is there an instance for this widget ID?
|
71 |
+
if ( isset( $widget_instances[$widget_id] ) ) {
|
72 |
+
|
73 |
+
// Add to array
|
74 |
+
$sidebars_widget_instances[$sidebar_id][$widget_id] = $widget_instances[$widget_id];
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
// Filter pre-encoded data
|
83 |
+
$data = apply_filters( 'wie_unencoded_export_data', $sidebars_widget_instances );
|
84 |
+
|
85 |
+
// Encode the data for file contents
|
86 |
+
$encoded_data = json_encode( $data );
|
87 |
+
|
88 |
+
// Return contents
|
89 |
+
return apply_filters( 'wie_generate_export_data', $encoded_data );
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Send export file to user
|
95 |
+
*
|
96 |
+
* Triggered by URL like /wp-admin/tools.php?page=widget-importer-exporter&export=1
|
97 |
+
*
|
98 |
+
* The data is JSON with .wie extension in order not to confuse export files with other plugins.
|
99 |
+
*
|
100 |
+
* @since 0.1
|
101 |
+
*/
|
102 |
+
function wie_send_export_file() {
|
103 |
+
|
104 |
+
// Export requested
|
105 |
+
if ( ! empty( $_GET['export'] ) ) {
|
106 |
+
|
107 |
+
// Build filename
|
108 |
+
// Single Site: yoursite.com-widgets.wie
|
109 |
+
// Multisite: site.multisite.com-widgets.wie or multisite.com-site-widgets.wie
|
110 |
+
$site_url = site_url( '', 'http' );
|
111 |
+
$site_url = trim( $site_url, '/\\' ); // remove trailing slash
|
112 |
+
$filename = str_replace( 'http://', '', $site_url ); // remove http://
|
113 |
+
$filename = str_replace( array( '/', '\\' ), '-', $filename ); // replace slashes with -
|
114 |
+
$filename .= '-widgets.wie'; // append
|
115 |
+
$filename = apply_filters( 'wie_export_filename', $filename );
|
116 |
+
|
117 |
+
// Generate export file contents
|
118 |
+
$file_contents = wie_generate_export_data();
|
119 |
+
$filesize = strlen( $file_contents );
|
120 |
+
|
121 |
+
// Headers to prompt "Save As"
|
122 |
+
header( 'Content-Type: application/octet-stream' );
|
123 |
+
header( 'Content-Disposition: attachment; filename=' . $filename );
|
124 |
+
header( 'Expires: 0' );
|
125 |
+
header( 'Cache-Control: must-revalidate' );
|
126 |
+
header( 'Pragma: public' );
|
127 |
+
header( 'Content-Length: ' . $filesize );
|
128 |
+
|
129 |
+
// Clear buffering just in case
|
130 |
+
@ob_end_clean();
|
131 |
+
flush();
|
132 |
+
|
133 |
+
// Output file contents
|
134 |
+
echo $file_contents;
|
135 |
+
|
136 |
+
// Stop execution
|
137 |
+
exit;
|
138 |
+
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
add_action( 'load-tools_page_widget-importer-exporter', 'wie_send_export_file' );
|
trunk/includes/import.php
ADDED
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Import Functions
|
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
|
11 |
+
*/
|
12 |
+
|
13 |
+
// No direct access
|
14 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Upload import file
|
18 |
+
*
|
19 |
+
* @since 0.3
|
20 |
+
*/
|
21 |
+
function wie_upload_import_file() {
|
22 |
+
|
23 |
+
// Check nonce for security since form was posted
|
24 |
+
if ( ! empty( $_POST ) && ! empty( $_FILES['wie_import_file'] ) && check_admin_referer( 'wie_import', 'wie_import_nonce' ) ) { // check_admin_referer prints fail page and dies
|
25 |
+
|
26 |
+
// Uploaded file
|
27 |
+
$uploaded_file = $_FILES['wie_import_file'];
|
28 |
+
|
29 |
+
// Check file type
|
30 |
+
// This will also fire if no file uploaded
|
31 |
+
$wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'], false );
|
32 |
+
if ( 'wie' != $wp_filetype['ext'] && ! wp_match_mime_types( 'wie', $wp_filetype['type'] ) ) {
|
33 |
+
wp_die(
|
34 |
+
__( 'You must upload a <b>.wie</b> file generated by this plugin.', 'widget-importer-exporter' ),
|
35 |
+
'',
|
36 |
+
array( 'back_link' => true )
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
// Check and move file to uploads dir, get file data
|
41 |
+
// Will show die with WP errors if necessary (file too large, quota exceeded, etc.)
|
42 |
+
$overrides = array( 'test_form' => false );
|
43 |
+
$file_data = wp_handle_upload( $uploaded_file, $overrides );
|
44 |
+
if ( isset( $file_data['error'] ) ) {
|
45 |
+
wp_die(
|
46 |
+
$file_data['error'],
|
47 |
+
'',
|
48 |
+
array( 'back_link' => true )
|
49 |
+
);
|
50 |
+
}
|
51 |
+
|
52 |
+
// Process import file
|
53 |
+
wie_process_import_file( $file_data['file'] );
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
add_action( 'load-tools_page_widget-importer-exporter', 'wie_upload_import_file' );
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Process import file
|
63 |
+
*
|
64 |
+
* This parses a file and triggers importation of its widgets.
|
65 |
+
*
|
66 |
+
* @since 0.3
|
67 |
+
* @param string $file Path to .wie file uploaded
|
68 |
+
* @global string $wie_import_results
|
69 |
+
*/
|
70 |
+
function wie_process_import_file( $file ) {
|
71 |
+
|
72 |
+
global $wie_import_results;
|
73 |
+
|
74 |
+
// File exists?
|
75 |
+
if ( ! file_exists( $file ) ) {
|
76 |
+
wp_die(
|
77 |
+
__( 'Import file could not be found. Please try again.', 'widget-importer-exporter' ),
|
78 |
+
'',
|
79 |
+
array( 'back_link' => true )
|
80 |
+
);
|
81 |
+
}
|
82 |
+
|
83 |
+
// Get file contents and decode
|
84 |
+
$data = file_get_contents( $file );
|
85 |
+
$data = json_decode( $data );
|
86 |
+
|
87 |
+
// Delete import file
|
88 |
+
unlink( $file );
|
89 |
+
|
90 |
+
// Import the widget data
|
91 |
+
// Make results available for display on import/export page
|
92 |
+
$wie_import_results = wie_import_data( $data );
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Import widget JSON data
|
98 |
+
*
|
99 |
+
* @since 0.4
|
100 |
+
* @global array $wp_registered_sidebars
|
101 |
+
* @param object $data JSON widget data from .wie file
|
102 |
+
* @return array Results array
|
103 |
+
*/
|
104 |
+
function wie_import_data( $data ) {
|
105 |
+
|
106 |
+
global $wp_registered_sidebars;
|
107 |
+
|
108 |
+
// Have valid data?
|
109 |
+
// If no data or could not decode
|
110 |
+
if ( empty( $data ) || ! is_object( $data ) ) {
|
111 |
+
wp_die(
|
112 |
+
__( 'Import data could not be read. Please try a different file.', 'widget-importer-exporter' ),
|
113 |
+
'',
|
114 |
+
array( 'back_link' => true )
|
115 |
+
);
|
116 |
+
}
|
117 |
+
|
118 |
+
// Hook before import
|
119 |
+
do_action( 'wie_before_import' );
|
120 |
+
|
121 |
+
// Get all available widgets site supports
|
122 |
+
$available_widgets = wie_available_widgets();
|
123 |
+
|
124 |
+
// Get all existing widget instances
|
125 |
+
$widget_instances = array();
|
126 |
+
foreach ( $available_widgets as $widget_data ) {
|
127 |
+
$widget_instances[$widget_data['id_base']] = get_option( 'widget_' . $widget_data['id_base'] );
|
128 |
+
}
|
129 |
+
|
130 |
+
// Begin results
|
131 |
+
$results = array();
|
132 |
+
|
133 |
+
// Loop import data's sidebars
|
134 |
+
foreach ( $data as $sidebar_id => $widgets ) {
|
135 |
+
|
136 |
+
// Skip inactive widgets
|
137 |
+
// (should not be in export file)
|
138 |
+
if ( 'wp_inactive_widgets' == $sidebar_id ) {
|
139 |
+
continue;
|
140 |
+
}
|
141 |
+
|
142 |
+
// Check if sidebar is available on this site
|
143 |
+
// Otherwise add widgets to inactive, and say so
|
144 |
+
if ( isset( $wp_registered_sidebars[$sidebar_id] ) ) {
|
145 |
+
$sidebar_available = true;
|
146 |
+
$use_sidebar_id = $sidebar_id;
|
147 |
+
$sidebar_message_type = 'success';
|
148 |
+
$sidebar_message = '';
|
149 |
+
} else {
|
150 |
+
$sidebar_available = false;
|
151 |
+
$use_sidebar_id = 'wp_inactive_widgets'; // add to inactive if sidebar does not exist in theme
|
152 |
+
$sidebar_message_type = 'error';
|
153 |
+
$sidebar_message = __( 'Sidebar does not exist in theme (using Inactive)', 'widget-importer-exporter' );
|
154 |
+
}
|
155 |
+
|
156 |
+
// Result for sidebar
|
157 |
+
$results[$sidebar_id]['name'] = ! empty( $wp_registered_sidebars[$sidebar_id]['name'] ) ? $wp_registered_sidebars[$sidebar_id]['name'] : $sidebar_id; // sidebar name if theme supports it; otherwise ID
|
158 |
+
$results[$sidebar_id]['message_type'] = $sidebar_message_type;
|
159 |
+
$results[$sidebar_id]['message'] = $sidebar_message;
|
160 |
+
$results[$sidebar_id]['widgets'] = array();
|
161 |
+
|
162 |
+
// Loop widgets
|
163 |
+
foreach ( $widgets as $widget_instance_id => $widget ) {
|
164 |
+
|
165 |
+
$fail = false;
|
166 |
+
|
167 |
+
// Get id_base (remove -# from end) and instance ID number
|
168 |
+
$id_base = preg_replace( '/-[0-9]+$/', '', $widget_instance_id );
|
169 |
+
$instance_id_number = str_replace( $id_base . '-', '', $widget_instance_id );
|
170 |
+
|
171 |
+
// Does site support this widget?
|
172 |
+
if ( ! $fail && ! isset( $available_widgets[$id_base] ) ) {
|
173 |
+
$fail = true;
|
174 |
+
$widget_message_type = 'error';
|
175 |
+
$widget_message = __( 'Site does not support widget', 'widget-importer-exporter' ); // explain why widget not imported
|
176 |
+
}
|
177 |
+
|
178 |
+
// Filter to modify settings before import
|
179 |
+
// Do before identical check because changes may make it identical to end result (such as URL replacements)
|
180 |
+
$widget = apply_filters( 'wie_widget_settings', $widget );
|
181 |
+
|
182 |
+
// Does widget with identical settings already exist in same sidebar?
|
183 |
+
if ( ! $fail && isset( $widget_instances[$id_base] ) ) {
|
184 |
+
|
185 |
+
// Get existing widgets in this sidebar
|
186 |
+
$sidebars_widgets = get_option( 'sidebars_widgets' );
|
187 |
+
$sidebar_widgets = isset( $sidebars_widgets[$use_sidebar_id] ) ? $sidebars_widgets[$use_sidebar_id] : array(); // check Inactive if that's where will go
|
188 |
+
|
189 |
+
// Loop widgets with ID base
|
190 |
+
$single_widget_instances = ! empty( $widget_instances[$id_base] ) ? $widget_instances[$id_base] : array();
|
191 |
+
foreach ( $single_widget_instances as $check_id => $check_widget ) {
|
192 |
+
|
193 |
+
// Is widget in same sidebar and has identical settings?
|
194 |
+
if ( in_array( "$id_base-$check_id", $sidebar_widgets ) && (array) $widget == $check_widget ) {
|
195 |
+
|
196 |
+
$fail = true;
|
197 |
+
$widget_message_type = 'warning';
|
198 |
+
$widget_message = __( 'Widget already exists', 'widget-importer-exporter' ); // explain why widget not imported
|
199 |
+
|
200 |
+
break;
|
201 |
+
|
202 |
+
}
|
203 |
+
|
204 |
+
}
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
// No failure
|
209 |
+
if ( ! $fail ) {
|
210 |
+
|
211 |
+
// Add widget instance
|
212 |
+
$single_widget_instances = get_option( 'widget_' . $id_base ); // all instances for that widget ID base, get fresh every time
|
213 |
+
$single_widget_instances = ! empty( $single_widget_instances ) ? $single_widget_instances : array( '_multiwidget' => 1 ); // start fresh if have to
|
214 |
+
$single_widget_instances[] = (array) $widget; // add it
|
215 |
+
|
216 |
+
// Get the key it was given
|
217 |
+
end( $single_widget_instances );
|
218 |
+
$new_instance_id_number = key( $single_widget_instances );
|
219 |
+
|
220 |
+
// Update option with new widget
|
221 |
+
update_option( 'widget_' . $id_base, $single_widget_instances );
|
222 |
+
|
223 |
+
// Assign widget instance to sidebar
|
224 |
+
$sidebars_widgets = get_option( 'sidebars_widgets' ); // which sidebars have which widgets, get fresh every time
|
225 |
+
$new_instance_id = $id_base . '-' . $new_instance_id_number; // use ID number from new widget instance
|
226 |
+
$sidebars_widgets[$use_sidebar_id][] = $new_instance_id; // add new instance to sidebar
|
227 |
+
update_option( 'sidebars_widgets', $sidebars_widgets ); // save the amended data
|
228 |
+
|
229 |
+
// Success message
|
230 |
+
if ( $sidebar_available ) {
|
231 |
+
$widget_message_type = 'success';
|
232 |
+
$widget_message = __( 'Imported', 'widget-importer-exporter' );
|
233 |
+
} else {
|
234 |
+
$widget_message_type = 'warning';
|
235 |
+
$widget_message = __( 'Imported to Inactive', 'widget-importer-exporter' );
|
236 |
+
}
|
237 |
+
|
238 |
+
}
|
239 |
+
|
240 |
+
// Result for widget instance
|
241 |
+
$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)
|
242 |
+
$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
|
243 |
+
$results[$sidebar_id]['widgets'][$widget_instance_id]['message_type'] = $widget_message_type;
|
244 |
+
$results[$sidebar_id]['widgets'][$widget_instance_id]['message'] = $widget_message;
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
}
|
249 |
+
|
250 |
+
// Hook after import
|
251 |
+
do_action( 'wie_after_import' );
|
252 |
+
|
253 |
+
// Return results
|
254 |
+
return apply_filters( 'wie_import_results', $results );
|
255 |
+
|
256 |
+
}
|
trunk/includes/mime-types.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Mime Types
|
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.1
|
11 |
+
*/
|
12 |
+
|
13 |
+
// No direct access
|
14 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Add mime type for upload
|
18 |
+
*
|
19 |
+
* Make sure the WordPress install will accept .wie uploads.
|
20 |
+
*
|
21 |
+
* @since 0.1
|
22 |
+
* @param array $mime_types Currently uploadable mime types
|
23 |
+
* @return array Mime types with additions
|
24 |
+
*/
|
25 |
+
function wie_add_mime_types( $mime_types ) {
|
26 |
+
|
27 |
+
$mime_types['wie'] = 'application/json';
|
28 |
+
|
29 |
+
return $mime_types;
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
add_filter( 'upload_mimes', 'wie_add_mime_types' );
|
trunk/includes/page.php
ADDED
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Page Functions
|
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.1
|
11 |
+
*/
|
12 |
+
|
13 |
+
// No direct access
|
14 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Add import/export page under Tools
|
18 |
+
*
|
19 |
+
* Also enqueue Stylesheet for this page only.
|
20 |
+
*
|
21 |
+
* @since 0.1
|
22 |
+
*/
|
23 |
+
function wie_add_import_export_page() {
|
24 |
+
|
25 |
+
// Add page
|
26 |
+
$page_hook = add_management_page(
|
27 |
+
__( 'Widget Importer & Exporter', 'widget-importer-exporter' ), // page title
|
28 |
+
__( 'Widget Import/Export', 'widget-importer-exporter' ), // menu title
|
29 |
+
'manage_options', // capability
|
30 |
+
'widget-importer-exporter', // menu slug
|
31 |
+
'wie_import_export_page_content' // callback for displaying page content
|
32 |
+
);
|
33 |
+
|
34 |
+
// Enqueue stylesheet
|
35 |
+
add_action( 'admin_print_styles-' . $page_hook, 'wie_enqueue_styles' );
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
add_action( 'admin_menu', 'wie_add_import_export_page' ); // register post type
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Enqueue stylesheets for import/export page
|
43 |
+
*
|
44 |
+
* @since 0.1
|
45 |
+
*/
|
46 |
+
function wie_enqueue_styles() {
|
47 |
+
wp_enqueue_style( 'wie-main', WIE_URL . '/' . WIE_CSS_DIR . '/style.css', false, WIE_VERSION ); // bust cache on update
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Import/export page content
|
52 |
+
*
|
53 |
+
* @since 0.1
|
54 |
+
*/
|
55 |
+
function wie_import_export_page_content() {
|
56 |
+
|
57 |
+
?>
|
58 |
+
|
59 |
+
<div class="wrap">
|
60 |
+
|
61 |
+
<?php screen_icon(); ?>
|
62 |
+
|
63 |
+
<h2><?php _e( 'Widget Importer & Exporter', 'widget-importer-exporter' ); ?></h2>
|
64 |
+
|
65 |
+
<?php
|
66 |
+
// Show import results if have them
|
67 |
+
if ( wie_have_import_results() ) {
|
68 |
+
wie_show_import_results();
|
69 |
+
return; // don't show content below
|
70 |
+
}
|
71 |
+
?>
|
72 |
+
|
73 |
+
<h3 class="title"><?php _ex( 'Import Widgets', 'heading', 'widget-importer-exporter' ); ?></h3>
|
74 |
+
|
75 |
+
<p>
|
76 |
+
<?php _e( 'Please select a <b>.wie</b> file generated by this plugin.', 'widget-importer-exporter' ); ?>
|
77 |
+
</p>
|
78 |
+
|
79 |
+
<form method="post" enctype="multipart/form-data">
|
80 |
+
|
81 |
+
<?php wp_nonce_field( 'wie_import', 'wie_import_nonce' ); ?>
|
82 |
+
|
83 |
+
<input type="file" name="wie_import_file" id="wie-import-file" />
|
84 |
+
|
85 |
+
<?php submit_button( _x( 'Import Widgets', 'button', 'widget-importer-exporter' ) ); ?>
|
86 |
+
|
87 |
+
</form>
|
88 |
+
|
89 |
+
<?php if ( ! empty( $wie_import_results ) ) : ?>
|
90 |
+
<p id="wie-import-results">
|
91 |
+
<?php echo $wie_import_results; ?>
|
92 |
+
</p>
|
93 |
+
<br />
|
94 |
+
<?php endif; ?>
|
95 |
+
|
96 |
+
<h3 class="title"><?php _ex( 'Export Widgets', 'heading', 'widget-importer-exporter' ); ?></h3>
|
97 |
+
|
98 |
+
<p>
|
99 |
+
<?php _e( 'Click below to generate a <b>.wie</b> file for all active widgets.', 'widget-importer-exporter' ); ?>
|
100 |
+
</p>
|
101 |
+
|
102 |
+
<p class="submit">
|
103 |
+
<a href="<?php echo esc_url( admin_url( basename( $_SERVER['PHP_SELF'] ) . '?page=' . $_GET['page'] . '&export=1' ) ); ?>" id="wie-export-button" class="button button-primary"><?php _ex( 'Export Widgets', 'button', 'widget-importer-exporter' ); ?></a>
|
104 |
+
</p>
|
105 |
+
|
106 |
+
</div>
|
107 |
+
|
108 |
+
<?php
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Have import results to show?
|
114 |
+
*
|
115 |
+
* @since 0.3
|
116 |
+
* @global string $wie_import_results
|
117 |
+
* @return bool True if have import results to show
|
118 |
+
*/
|
119 |
+
function wie_have_import_results() {
|
120 |
+
|
121 |
+
global $wie_import_results;
|
122 |
+
|
123 |
+
if ( ! empty( $wie_import_results ) ) {
|
124 |
+
return true;
|
125 |
+
}
|
126 |
+
|
127 |
+
return false;
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Show import results
|
133 |
+
*
|
134 |
+
* This is shown in place of import/export page's regular content.
|
135 |
+
*
|
136 |
+
* @since 0.3
|
137 |
+
* @global string $wie_import_results
|
138 |
+
*/
|
139 |
+
function wie_show_import_results() {
|
140 |
+
|
141 |
+
global $wie_import_results;
|
142 |
+
|
143 |
+
?>
|
144 |
+
|
145 |
+
<h3 class="title"><?php _ex( 'Import Results', 'heading', 'widget-importer-exporter' ); ?></h3>
|
146 |
+
|
147 |
+
<p>
|
148 |
+
<?php
|
149 |
+
printf(
|
150 |
+
__( 'You can manage your <a href="%s">Widgets</a> or <a href="%s">Go Back</a>.', 'widget-importer-exporter' ),
|
151 |
+
admin_url( 'widgets.php' ),
|
152 |
+
admin_url( basename( $_SERVER['PHP_SELF'] ) . '?page=' . $_GET['page'] )
|
153 |
+
);
|
154 |
+
?>
|
155 |
+
</p>
|
156 |
+
|
157 |
+
<table id="wie-import-results">
|
158 |
+
|
159 |
+
<?php
|
160 |
+
// Loop sidebars
|
161 |
+
$results = $wie_import_results;
|
162 |
+
foreach ( $results as $sidebar ) :
|
163 |
+
?>
|
164 |
+
|
165 |
+
<tr class="wie-import-results-sidebar">
|
166 |
+
<td colspan="2" class="wie-import-results-sidebar-name">
|
167 |
+
<?php echo $sidebar['name']; // sidebar name if theme supports it; otherwise ID ?>
|
168 |
+
</td>
|
169 |
+
<td class="wie-import-results-sidebar-message wie-import-results-message wie-import-results-message-<?php echo $sidebar['message_type']; ?>">
|
170 |
+
<?php echo $sidebar['message']; // sidebar may not exist in theme ?>
|
171 |
+
</td>
|
172 |
+
</tr>
|
173 |
+
|
174 |
+
<?php
|
175 |
+
// Loop widgets
|
176 |
+
foreach ( $sidebar['widgets'] as $widget ) :
|
177 |
+
?>
|
178 |
+
|
179 |
+
<tr class="wie-import-results-widget">
|
180 |
+
<td class="wie-import-results-widget-name">
|
181 |
+
<?php echo $widget['name']; // widget name or ID if name not available (not supported by site) ?>
|
182 |
+
</td>
|
183 |
+
<td class="wie-import-results-widget-title">
|
184 |
+
<?php echo $widget['title']; // shows "No Title" if widget instance is untitled ?>
|
185 |
+
</td>
|
186 |
+
<td class="wie-import-results-widget-message wie-import-results-message wie-import-results-message-<?php echo $widget['message_type']; ?>">
|
187 |
+
<?php echo $widget['message']; // sidebar may not exist in theme ?>
|
188 |
+
</td>
|
189 |
+
</tr>
|
190 |
+
|
191 |
+
<?php endforeach; ?>
|
192 |
+
|
193 |
+
<tr class="wie-import-results-space">
|
194 |
+
<td colspan="100%"></td>
|
195 |
+
</tr>
|
196 |
+
|
197 |
+
<?php endforeach; ?>
|
198 |
+
|
199 |
+
</table>
|
200 |
+
|
201 |
+
<?php
|
202 |
+
|
203 |
+
}
|
trunk/includes/widgets.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Widget Functions
|
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.4
|
11 |
+
*/
|
12 |
+
|
13 |
+
// No direct access
|
14 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Available widgets
|
18 |
+
*
|
19 |
+
* Gather site's widgets into array with ID base, name, etc.
|
20 |
+
* Used by export and import functions.
|
21 |
+
*
|
22 |
+
* @since 0.4
|
23 |
+
* @global array $wp_registered_widget_updates
|
24 |
+
* @return array Widget information
|
25 |
+
*/
|
26 |
+
function wie_available_widgets() {
|
27 |
+
|
28 |
+
global $wp_registered_widget_controls;
|
29 |
+
|
30 |
+
$widget_controls = $wp_registered_widget_controls;
|
31 |
+
|
32 |
+
$available_widgets = array();
|
33 |
+
|
34 |
+
foreach ( $widget_controls as $widget ) {
|
35 |
+
|
36 |
+
if ( ! empty( $widget['id_base'] ) && ! isset( $available_widgets[$widget['id_base']] ) ) { // no dupes
|
37 |
+
|
38 |
+
$available_widgets[$widget['id_base']]['id_base'] = $widget['id_base'];
|
39 |
+
$available_widgets[$widget['id_base']]['name'] = $widget['name'];
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
return apply_filters( 'wie_available_widgets', $available_widgets );
|
46 |
+
|
47 |
+
}
|
trunk/languages/important.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Do not add your own translations to this directory. They will be lost during plugin
|
2 |
+
updates. The only .mo files that should be loaded from here are pre-made translations
|
3 |
+
that come with the plugin.
|
4 |
+
|
5 |
+
Store your translations at:
|
6 |
+
wp-content/languages/plugins/widget-importer-exporter-$locale.mo
|
7 |
+
(e.g. widget-importer-exporter-en_US.mo) to keep them safe from loss during updates.
|
8 |
+
|
9 |
+
Please feel free to submit your translation to this project.
|
trunk/languages/widget-importer-exporter-es_ES.mo
ADDED
Binary file
|
trunk/languages/widget-importer-exporter-es_ES.po
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Widget Importer & Exporter en español\n"
|
4 |
+
"POT-Creation-Date: 2013-07-17 11:59+0100\n"
|
5 |
+
"PO-Revision-Date: 2013-07-17 12:52+0100\n"
|
6 |
+
"Last-Translator: Eduardo Larequi <elarequi@gmail.com>\n"
|
7 |
+
"Language-Team: PNTE <blogs@educacion.navarra.es>\n"
|
8 |
+
"Language: Spanish\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;_c\n"
|
16 |
+
"X-Poedit-Basepath: ..\n"
|
17 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
18 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
19 |
+
"X-Poedit-SearchPath-0: .\n"
|
20 |
+
|
21 |
+
#: includes/import.php:34
|
22 |
+
msgid "You must upload a <b>.wie</b> file generated by this plugin."
|
23 |
+
msgstr "Debes subir un fichero <b>.wie</b>, generado por este plugin."
|
24 |
+
|
25 |
+
#: includes/import.php:77
|
26 |
+
msgid "Import file could not be found. Please try again."
|
27 |
+
msgstr ""
|
28 |
+
"El fichero de importación no ha podido ser encontrado. Por favor, inténtalo "
|
29 |
+
"de nuevo."
|
30 |
+
|
31 |
+
#: includes/import.php:112
|
32 |
+
msgid "Import data could not be read. Please try a different file."
|
33 |
+
msgstr ""
|
34 |
+
"El fichero de importación no ha podido ser leído. Por favor, inténtalo de "
|
35 |
+
"nuevo con un fichero diferente."
|
36 |
+
|
37 |
+
#: includes/import.php:153
|
38 |
+
msgid "Sidebar does not exist in theme (using Inactive)"
|
39 |
+
msgstr ""
|
40 |
+
"La barra lateral no existe en el tema (sus widgets se importarán como "
|
41 |
+
"inactivos)"
|
42 |
+
|
43 |
+
#: includes/import.php:175
|
44 |
+
msgid "Site does not support widget"
|
45 |
+
msgstr "El sitio no soporta este widget"
|
46 |
+
|
47 |
+
#: includes/import.php:198
|
48 |
+
msgid "Widget already exists"
|
49 |
+
msgstr "El widget ya existe"
|
50 |
+
|
51 |
+
#: includes/import.php:232
|
52 |
+
msgid "Imported"
|
53 |
+
msgstr "Importado"
|
54 |
+
|
55 |
+
#: includes/import.php:235
|
56 |
+
msgid "Imported to Inactive"
|
57 |
+
msgstr "Importado como inactivo"
|
58 |
+
|
59 |
+
#: includes/import.php:242
|
60 |
+
msgid "No Title"
|
61 |
+
msgstr "Sin título"
|
62 |
+
|
63 |
+
#: includes/page.php:27 includes/page.php:63
|
64 |
+
msgid "Widget Importer & Exporter"
|
65 |
+
msgstr "Widget Importer & Exporter"
|
66 |
+
|
67 |
+
#: includes/page.php:28
|
68 |
+
msgid "Widget Import/Export"
|
69 |
+
msgstr "Importar y exportar widgets"
|
70 |
+
|
71 |
+
#: includes/page.php:73
|
72 |
+
msgctxt "heading"
|
73 |
+
msgid "Import Widgets"
|
74 |
+
msgstr "Importar widgets"
|
75 |
+
|
76 |
+
#: includes/page.php:76
|
77 |
+
msgid "Please select a <b>.wie</b> file generated by this plugin."
|
78 |
+
msgstr ""
|
79 |
+
"Por favor, selecciona un fichero <b>.wie</b>, generado por este plugin."
|
80 |
+
|
81 |
+
#: includes/page.php:85
|
82 |
+
msgctxt "button"
|
83 |
+
msgid "Import Widgets"
|
84 |
+
msgstr "Importar widgets"
|
85 |
+
|
86 |
+
#: includes/page.php:96
|
87 |
+
msgctxt "heading"
|
88 |
+
msgid "Export Widgets"
|
89 |
+
msgstr "Exportar widgets"
|
90 |
+
|
91 |
+
#: includes/page.php:99
|
92 |
+
msgid "Click below to generate a <b>.wie</b> file for all active widgets."
|
93 |
+
msgstr ""
|
94 |
+
"Haz clic el el botón que tienes a continuación, para generar un fichero <b>."
|
95 |
+
"wie</b>, para todos los widgets activos."
|
96 |
+
|
97 |
+
#: includes/page.php:103
|
98 |
+
msgctxt "button"
|
99 |
+
msgid "Export Widgets"
|
100 |
+
msgstr "Exportar widgets"
|
101 |
+
|
102 |
+
#: includes/page.php:145
|
103 |
+
msgctxt "heading"
|
104 |
+
msgid "Import Results"
|
105 |
+
msgstr "Resultados de la exportación"
|
106 |
+
|
107 |
+
#: includes/page.php:150
|
108 |
+
#, php-format
|
109 |
+
msgid ""
|
110 |
+
"You can manage your <a href=\"%s\">Widgets</a> or <a href=\"%s\">Go Back</a>."
|
111 |
+
msgstr ""
|
112 |
+
"Puedes gestionar tus <a href=\"%s\">widgets</a> o <a href=\"%s\">volver "
|
113 |
+
"atrás</a>."
|
trunk/languages/widget-importer-exporter.pot
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
16 |
+
"X-Poedit-Basepath: .\n"
|
17 |
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
18 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
19 |
+
"X-Poedit-SearchPath-0: ..\n"
|
20 |
+
|
21 |
+
#: ../includes/import.php:34
|
22 |
+
msgid "You must upload a <b>.wie</b> file generated by this plugin."
|
23 |
+
msgstr ""
|
24 |
+
|
25 |
+
#: ../includes/import.php:77
|
26 |
+
msgid "Import file could not be found. Please try again."
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#: ../includes/import.php:112
|
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"
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: ../includes/page.php:76
|
71 |
+
msgid "Please select a <b>.wie</b> file generated by this plugin."
|
72 |
+
msgstr ""
|
73 |
+
|
74 |
+
#: ../includes/page.php:85
|
75 |
+
msgctxt "button"
|
76 |
+
msgid "Import Widgets"
|
77 |
+
msgstr ""
|
78 |
+
|
79 |
+
#: ../includes/page.php:96
|
80 |
+
msgctxt "heading"
|
81 |
+
msgid "Export Widgets"
|
82 |
+
msgstr ""
|
83 |
+
|
84 |
+
#: ../includes/page.php:99
|
85 |
+
msgid "Click below to generate a <b>.wie</b> file for all active widgets."
|
86 |
+
msgstr ""
|
87 |
+
|
88 |
+
#: ../includes/page.php:103
|
89 |
+
msgctxt "button"
|
90 |
+
msgid "Export Widgets"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: ../includes/page.php:145
|
94 |
+
msgctxt "heading"
|
95 |
+
msgid "Import Results"
|
96 |
+
msgstr ""
|
97 |
+
|
98 |
+
#: ../includes/page.php:150
|
99 |
+
#, php-format
|
100 |
+
msgid ""
|
101 |
+
"You can manage your <a href=\"%s\">Widgets</a> or <a href=\"%s\">Go Back</a>."
|
102 |
+
msgstr ""
|
trunk/license.txt
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
<one line to give the program's name and a brief idea of what it does.>
|
294 |
+
Copyright (C) <year> <name of author>
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
<signature of Ty Coon>, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
trunk/readme.txt
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Widget Importer & Exporter ===
|
2 |
+
Contributors: stevengliebe, churchthemes
|
3 |
+
Tags: widgets, widget, importer, exporter, import, export, backup
|
4 |
+
Requires at least: 3.5
|
5 |
+
Tested up to: 3.6
|
6 |
+
Stable tag: trunk
|
7 |
+
License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
8 |
+
|
9 |
+
Import and export your widgets.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Widget Importer & Exporter is useful for moving widgets from one WordPress site to another, backing up widgets and for theme developers to provide users with sample widgets.
|
14 |
+
|
15 |
+
= Importing =
|
16 |
+
|
17 |
+
Importing is a matter of uploading an export file created by the plugin. The results of an import are shown in a nicely formatted table with an explanation of what happened with each sidebar and widget.
|
18 |
+
|
19 |
+
Importation takes into consideration sidebars not existing in the current theme (widgets imported as *Inactive*), widgets that already exist in the same sidebar (widgets not duplicated) and widgets that are not supported by the site (widgets not imported).
|
20 |
+
|
21 |
+
= Exporting =
|
22 |
+
|
23 |
+
Widget Importer & Exporter can create an export file (in JSON format with .wie extension) out of currently active widgets. This file can be imported into other sites using this plugin or used to restore widgets to the same site later.
|
24 |
+
|
25 |
+
= Translations =
|
26 |
+
|
27 |
+
The following translations are included.
|
28 |
+
|
29 |
+
* English (default)
|
30 |
+
* Spanish (es_ES) by [Eduardo Larequi](http://www.labitacoradeltigre.com/)
|
31 |
+
|
32 |
+
= Developers =
|
33 |
+
|
34 |
+
The ``wie_before_import`` action fires after a file is uploaded but before the data is imported. ``wie_after_import`` fires after the data is imported. Other filters are used throughout. Let me know if you need more actions or filters.
|
35 |
+
|
36 |
+
Please jump on [GitHub](https://github.com/stevengliebe/widget-importer-exporter) to report issues and follow development.
|
37 |
+
|
38 |
+
== Installation ==
|
39 |
+
|
40 |
+
Please see [Installing Plugins](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins) in the WordPress Codex.
|
41 |
+
|
42 |
+
After activation, go to *Tools > Widget Import/Export*
|
43 |
+
|
44 |
+
== Screenshots ==
|
45 |
+
|
46 |
+
1. Main import/export screen
|
47 |
+
2. Results from an import
|
48 |
+
|
49 |
+
== Changelog ==
|
50 |
+
|
51 |
+
See [release tags](https://github.com/stevengliebe/widget-importer-exporter/tags) on GitHub.
|
trunk/widget-importer-exporter.php
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
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.0
|
7 |
+
* Author: Steven Gliebe
|
8 |
+
* Author URI: http://stevengliebe.com
|
9 |
+
* License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
10 |
+
*
|
11 |
+
* @package Widget_Importer_Exporter
|
12 |
+
* @copyright Copyright (c) 2013, DreamDolphin Media, LLC
|
13 |
+
* @link https://github.com/stevengliebe/widget-importer-exporter
|
14 |
+
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
15 |
+
*/
|
16 |
+
|
17 |
+
// No direct access
|
18 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Main class
|
22 |
+
*
|
23 |
+
* @since 0.1
|
24 |
+
*/
|
25 |
+
class Widget_Importer_Exporter {
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Plugin data from get_plugins()
|
29 |
+
*
|
30 |
+
* @since 0.1
|
31 |
+
* @var object
|
32 |
+
*/
|
33 |
+
public $plugin_data;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Includes to load
|
37 |
+
*
|
38 |
+
* @since 0.1
|
39 |
+
* @var array
|
40 |
+
*/
|
41 |
+
public $includes;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Constructor
|
45 |
+
*
|
46 |
+
* Add actions for methods that define constants, load translation and load includes.
|
47 |
+
*
|
48 |
+
* @since 0.1
|
49 |
+
* @access public
|
50 |
+
*/
|
51 |
+
public function __construct() {
|
52 |
+
|
53 |
+
// Set plugin data
|
54 |
+
add_action( 'plugins_loaded', array( &$this, 'set_plugin_data' ), 1 );
|
55 |
+
|
56 |
+
// Define constants
|
57 |
+
add_action( 'plugins_loaded', array( &$this, 'define_constants' ), 1 );
|
58 |
+
|
59 |
+
// Load language file
|
60 |
+
add_action( 'plugins_loaded', array( &$this, 'load_textdomain' ), 1 );
|
61 |
+
|
62 |
+
// Set includes
|
63 |
+
add_action( 'plugins_loaded', array( &$this, 'set_includes' ), 1 );
|
64 |
+
|
65 |
+
// Load includes
|
66 |
+
add_action( 'plugins_loaded', array( &$this, 'load_includes' ), 1 );
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Set plugin data
|
72 |
+
*
|
73 |
+
* This data is used by constants.
|
74 |
+
*
|
75 |
+
* @since 0.1
|
76 |
+
* @access public
|
77 |
+
*/
|
78 |
+
public function set_plugin_data() {
|
79 |
+
|
80 |
+
// Load plugin.php if get_plugins() not available
|
81 |
+
if ( ! function_exists( 'get_plugins' ) ) {
|
82 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
83 |
+
}
|
84 |
+
|
85 |
+
// Get path to plugin's directory
|
86 |
+
$plugin_dir = plugin_basename( dirname( __FILE__ ) );
|
87 |
+
|
88 |
+
// Get plugin data
|
89 |
+
$plugin_data = current( get_plugins( '/' . $plugin_dir ) );
|
90 |
+
|
91 |
+
// Set plugin data
|
92 |
+
$this->plugin_data = apply_filters( 'wie_plugin_data', $plugin_data );
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Define constants
|
98 |
+
*
|
99 |
+
* @since 0.1
|
100 |
+
* @access public
|
101 |
+
*/
|
102 |
+
public function define_constants() {
|
103 |
+
|
104 |
+
// Plugin details
|
105 |
+
define( 'WIE_VERSION', $this->plugin_data['Version'] ); // plugin version
|
106 |
+
define( 'WIE_FILE', __FILE__ ); // plugin's main file path
|
107 |
+
define( 'WIE_DIR', dirname( plugin_basename( WIE_FILE ) ) ); // plugin's directory
|
108 |
+
define( 'WIE_PATH', untrailingslashit( plugin_dir_path( WIE_FILE ) ) ); // plugin's directory path
|
109 |
+
define( 'WIE_URL', untrailingslashit( plugin_dir_url( WIE_FILE ) ) ); // plugin's directory URL
|
110 |
+
|
111 |
+
// Directories
|
112 |
+
define( 'WIE_INC_DIR', 'includes' ); // includes directory
|
113 |
+
define( 'WIE_CSS_DIR', 'css' ); // stylesheets directory
|
114 |
+
define( 'WIE_LANG_DIR', 'languages' ); // languages directory
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Load language file
|
120 |
+
*
|
121 |
+
* This will load the MO file for the current locale.
|
122 |
+
* The translation file must be named widget-importer-exporter-$locale.mo.
|
123 |
+
*
|
124 |
+
* First it will check to see if the MO file exists in wp-content/languages/plugins.
|
125 |
+
* If not, then the 'languages' direcory inside the plugin will be used.
|
126 |
+
* It is ideal to keep translation files outside of the plugin to avoid loss during updates.
|
127 |
+
*
|
128 |
+
* To Do: load_plugin_textdomain() will presumably be updated as load_theme_textdomain() was to
|
129 |
+
* natively support external loading from WP_LANG_DIR. When this is so, simplify this function.
|
130 |
+
* http://core.trac.wordpress.org/changeset/22346
|
131 |
+
*
|
132 |
+
* @since 0.1
|
133 |
+
* @access public
|
134 |
+
*/
|
135 |
+
public function load_textdomain() {
|
136 |
+
|
137 |
+
// Textdomain
|
138 |
+
$domain = 'widget-importer-exporter';
|
139 |
+
|
140 |
+
// WordPress core locale filter
|
141 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
142 |
+
|
143 |
+
// Does external MO file exist? Load it
|
144 |
+
// This is ideal since it is not wiped out by plugin updates
|
145 |
+
$external_mofile = WP_LANG_DIR . '/plugins/'. $domain . '-' . $locale . '.mo';
|
146 |
+
if ( file_exists( $external_mofile ) ) {
|
147 |
+
load_textdomain( $domain, $external_mofile );
|
148 |
+
}
|
149 |
+
|
150 |
+
// Otherwise use MO file stored in plugin
|
151 |
+
// This is not ideal except for pre-made, unedited translations included with the plugin
|
152 |
+
else {
|
153 |
+
$languages_dir = WIE_DIR . '/' . trailingslashit( WIE_LANG_DIR ); // ensure trailing slash
|
154 |
+
load_plugin_textdomain( $domain, false, $languages_dir );
|
155 |
+
}
|
156 |
+
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Set includes
|
161 |
+
*
|
162 |
+
* @since 0.1
|
163 |
+
* @access public
|
164 |
+
*/
|
165 |
+
public function set_includes() {
|
166 |
+
|
167 |
+
$this->includes = apply_filters( 'wie_includes', array(
|
168 |
+
|
169 |
+
// Admin only
|
170 |
+
'admin' => array(
|
171 |
+
|
172 |
+
// Functions
|
173 |
+
WIE_INC_DIR . '/export.php',
|
174 |
+
WIE_INC_DIR . '/import.php',
|
175 |
+
WIE_INC_DIR . '/mime-types.php',
|
176 |
+
WIE_INC_DIR . '/page.php',
|
177 |
+
WIE_INC_DIR . '/widgets.php'
|
178 |
+
|
179 |
+
)
|
180 |
+
|
181 |
+
) );
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Load includes
|
187 |
+
*
|
188 |
+
* Include files based on whether or not condition is met.
|
189 |
+
*
|
190 |
+
* @since 0.1
|
191 |
+
* @access public
|
192 |
+
*/
|
193 |
+
public function load_includes() {
|
194 |
+
|
195 |
+
// Get includes
|
196 |
+
$includes = $this->includes;
|
197 |
+
|
198 |
+
// Loop conditions
|
199 |
+
foreach ( $includes as $condition => $files ) {
|
200 |
+
|
201 |
+
$do_includes = false;
|
202 |
+
|
203 |
+
// Check condition
|
204 |
+
switch( $condition ) {
|
205 |
+
|
206 |
+
// Admin Only
|
207 |
+
case 'admin':
|
208 |
+
|
209 |
+
if ( is_admin() ) {
|
210 |
+
$do_includes = true;
|
211 |
+
}
|
212 |
+
|
213 |
+
break;
|
214 |
+
|
215 |
+
// Frontend Only
|
216 |
+
case 'frontend':
|
217 |
+
|
218 |
+
if ( ! is_admin() ) {
|
219 |
+
$do_includes = true;
|
220 |
+
}
|
221 |
+
|
222 |
+
break;
|
223 |
+
|
224 |
+
// Admin or Frontend (always)
|
225 |
+
default:
|
226 |
+
|
227 |
+
$do_includes = true;
|
228 |
+
|
229 |
+
break;
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
// Loop files if condition met
|
234 |
+
if ( $do_includes ) {
|
235 |
+
|
236 |
+
foreach ( $files as $file ) {
|
237 |
+
require_once trailingslashit( WIE_PATH ) . $file;
|
238 |
+
}
|
239 |
+
|
240 |
+
}
|
241 |
+
|
242 |
+
}
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
// Instantiate the main class
|
249 |
+
new Widget_Importer_Exporter();
|
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: 0
|
7 |
* Author: Steven Gliebe
|
8 |
* Author URI: http://stevengliebe.com
|
9 |
* License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
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.0
|
7 |
* Author: Steven Gliebe
|
8 |
* Author URI: http://stevengliebe.com
|
9 |
* License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|