Version Description
- Initial release on WP.org.
=
Download this release
Release Info
Developer | WPAllImport |
Plugin | Import Settings into WordPress SEO by Yoast |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- README.md +20 -0
- rapid-addon.php +978 -0
- readme.txt +80 -0
- yoast-addon.php +169 -0
README.md
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Yoast WordPress SEO Add-On
|
2 |
+
|
3 |
+
##Custom fields used by plugin:
|
4 |
+
|
5 |
+
| Name | Custom Field | Values |
|
6 |
+
| -------------------- | ------------------------------------ | ----------------------------------------------------------------------------- |
|
7 |
+
| Focus Keyword | _yoast_wpseo_focuskw | Text string |
|
8 |
+
| SEO Title | _yoast_wpseo_title | Text string |
|
9 |
+
| Meta Description | _yoast_wpseo_metadesc | Text string |
|
10 |
+
| Meta Robots Index | _yoast_wpseo_meta-robots-noindex | Blank for default, 1 for noindex, or 2 for index |
|
11 |
+
| Meta Robots Follow | _yoast_wpseo_meta-robots-nofollow | Blank for follow, 1 for nofollow |
|
12 |
+
| Meta Robots Advanced | _yoast_wpseo_meta-robots-adv | Blank for default, none, noodp, noydir, noimageindex, noarchive, or nosnippet |
|
13 |
+
| Include in Sitemap | _yoast_wpseo_sitemap-include | Blank for auto, always, or never |
|
14 |
+
| Sitemap Priority | _yoast_wpseo_sitemap-prio | Blank for auto, 1 to .1 |
|
15 |
+
| Canonical URL | _yoast_wpseo_canonical | Canonical URL of post |
|
16 |
+
| 301 Redirect | _yoast_wpseo_redirect | URL to redirect post to |
|
17 |
+
| Facebook Title | _yoast_wpseo_opengraph-title | Text string |
|
18 |
+
| Facebook Description | _yoast_wpseo_opengraph | Text string |
|
19 |
+
| Facebook Image | _yoast_wpseo_opengraph-image | URL to image |
|
20 |
+
|
rapid-addon.php
ADDED
@@ -0,0 +1,978 @@
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('RapidAddon')) {
|
4 |
+
|
5 |
+
class RapidAddon {
|
6 |
+
|
7 |
+
public $name;
|
8 |
+
public $slug;
|
9 |
+
public $fields;
|
10 |
+
public $options = array();
|
11 |
+
public $accordions = array();
|
12 |
+
public $image_sections = array();
|
13 |
+
public $import_function;
|
14 |
+
public $notice_text;
|
15 |
+
public $logger = null;
|
16 |
+
public $image_options = array(
|
17 |
+
'download_images' => 'yes',
|
18 |
+
'download_featured_delim' => ',',
|
19 |
+
'download_featured_image' => '',
|
20 |
+
'featured_image' => '',
|
21 |
+
'featured_delim' => ',',
|
22 |
+
'search_existing_images' => 1,
|
23 |
+
'is_featured' => 0,
|
24 |
+
'create_draft' => 'no',
|
25 |
+
'set_image_meta_title' => 0,
|
26 |
+
'image_meta_title_delim' => ',',
|
27 |
+
'image_meta_title' => '',
|
28 |
+
'set_image_meta_caption' => 0,
|
29 |
+
'image_meta_caption_delim' => ',',
|
30 |
+
'image_meta_caption' => '',
|
31 |
+
'set_image_meta_alt' => 0,
|
32 |
+
'image_meta_alt_delim' => ',',
|
33 |
+
'image_meta_alt' => '',
|
34 |
+
'set_image_meta_description' => 0,
|
35 |
+
'image_meta_description_delim' => ',',
|
36 |
+
'image_meta_description' => '',
|
37 |
+
'auto_rename_images' => 0,
|
38 |
+
'auto_rename_images_suffix' => '',
|
39 |
+
'auto_set_extension' => 0,
|
40 |
+
'new_extension' => ''
|
41 |
+
);
|
42 |
+
|
43 |
+
function __construct($name, $slug) {
|
44 |
+
|
45 |
+
$this->name = $name;
|
46 |
+
$this->slug = $slug;
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
function set_import_function($name) {
|
51 |
+
$this->import_function = $name;
|
52 |
+
}
|
53 |
+
|
54 |
+
function is_active_addon($post_type = null) {
|
55 |
+
|
56 |
+
$addon_active = false;
|
57 |
+
|
58 |
+
if ($post_type != null) {
|
59 |
+
if (@in_array($post_type, $this->active_post_types) or empty($this->active_post_types)) {
|
60 |
+
$addon_active = true;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
if ($addon_active){
|
65 |
+
|
66 |
+
$current_theme = wp_get_theme();
|
67 |
+
$theme_name = $current_theme->get('Name');
|
68 |
+
|
69 |
+
$addon_active = (@in_array($theme_name, $this->active_themes) or empty($this->active_themes)) ? true : false;
|
70 |
+
|
71 |
+
if ( $addon_active and ! empty($this->active_plugins) ){
|
72 |
+
|
73 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
74 |
+
|
75 |
+
foreach ($this->active_plugins as $plugin) {
|
76 |
+
if ( ! is_plugin_active($plugin) ) {
|
77 |
+
$addon_active = false;
|
78 |
+
break;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
if ($this->when_to_run == "always") {
|
86 |
+
return true;
|
87 |
+
}
|
88 |
+
|
89 |
+
return $addon_active;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
*
|
94 |
+
* Add-On Initialization
|
95 |
+
*
|
96 |
+
* @param array $conditions - list of supported themes and post types
|
97 |
+
*
|
98 |
+
*/
|
99 |
+
function run($conditions = array()) {
|
100 |
+
|
101 |
+
if (empty($conditions)) {
|
102 |
+
$this->when_to_run = "always";
|
103 |
+
}
|
104 |
+
|
105 |
+
@$this->active_post_types = ( ! empty($conditions['post_types'])) ? $conditions['post_types'] : array();
|
106 |
+
@$this->active_themes = ( ! empty($conditions['themes'])) ? $conditions['themes'] : array();
|
107 |
+
@$this->active_plugins = ( ! empty($conditions['plugins'])) ? $conditions['plugins'] : array();
|
108 |
+
|
109 |
+
add_filter('pmxi_addons', array($this, 'wpai_api_register'));
|
110 |
+
add_filter('wp_all_import_addon_parse', array($this, 'wpai_api_parse'));
|
111 |
+
add_filter('wp_all_import_addon_import', array($this, 'wpai_api_import'));
|
112 |
+
add_filter('pmxi_options_options', array($this, 'wpai_api_options'));
|
113 |
+
add_filter('wp_all_import_image_sections', array($this, 'additional_sections'), 10, 1);
|
114 |
+
add_action('pmxi_extend_options_featured', array($this, 'wpai_api_metabox'), 10, 1);
|
115 |
+
add_action('admin_init', array($this, 'admin_notice_ignore'));
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
function parse($data) {
|
120 |
+
|
121 |
+
$parsedData = $this->helper_parse($data, $this->options_array());
|
122 |
+
return $parsedData;
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
function add_field($field_slug, $field_name, $field_type, $enum_values = null, $tooltip = "") {
|
128 |
+
|
129 |
+
$field = array("name" => $field_name, "type" => $field_type, "enum_values" => $enum_values, "tooltip" => $tooltip, "is_sub_field" => false, "is_main_field" => false, "slug" => $field_slug);
|
130 |
+
|
131 |
+
$this->fields[$field_slug] = $field;
|
132 |
+
|
133 |
+
if ( ! empty($enum_values) ){
|
134 |
+
foreach ($enum_values as $key => $value) {
|
135 |
+
if (is_array($value))
|
136 |
+
{
|
137 |
+
if ($field['type'] == 'accordion')
|
138 |
+
{
|
139 |
+
$this->fields[$value['slug']]['is_sub_field'] = true;
|
140 |
+
}
|
141 |
+
else
|
142 |
+
{
|
143 |
+
foreach ($value as $n => $param) {
|
144 |
+
if (is_array($param) and ! empty($this->fields[$param['slug']])){
|
145 |
+
$this->fields[$param['slug']]['is_sub_field'] = true;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
return $field;
|
154 |
+
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
*
|
159 |
+
* Add an option to WP All Import options list
|
160 |
+
*
|
161 |
+
* @param string $slug - option name
|
162 |
+
* @param string $default_value - default option value
|
163 |
+
*
|
164 |
+
*/
|
165 |
+
function add_option($slug, $default_value = ''){
|
166 |
+
$this->options[$slug] = $default_value;
|
167 |
+
}
|
168 |
+
|
169 |
+
function options_array() {
|
170 |
+
|
171 |
+
$options_list = array();
|
172 |
+
|
173 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
174 |
+
$options_list[$field_slug] = '';
|
175 |
+
}
|
176 |
+
|
177 |
+
if ( ! empty($this->options) ){
|
178 |
+
foreach ($this->options as $slug => $value) {
|
179 |
+
$options_arr[$slug] = $value;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
$options_arr[$this->slug] = $options_list;
|
184 |
+
|
185 |
+
return $options_arr;
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
function wpai_api_options($all_options) {
|
190 |
+
|
191 |
+
$all_options = $all_options + $this->options_array();
|
192 |
+
|
193 |
+
return $all_options;
|
194 |
+
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
function wpai_api_register($addons) {
|
199 |
+
|
200 |
+
if (empty($addons[$this->slug])) {
|
201 |
+
$addons[$this->slug] = 1;
|
202 |
+
}
|
203 |
+
|
204 |
+
return $addons;
|
205 |
+
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
function wpai_api_parse($functions) {
|
210 |
+
|
211 |
+
$functions[$this->slug] = array($this, 'parse');
|
212 |
+
return $functions;
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
function wpai_api_import($functions) {
|
218 |
+
|
219 |
+
$functions[$this->slug] = array($this, 'import');
|
220 |
+
return $functions;
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
|
225 |
+
|
226 |
+
function import($importData, $parsedData) {
|
227 |
+
|
228 |
+
if (!$this->is_active_addon($importData['post_type'])) {
|
229 |
+
return;
|
230 |
+
}
|
231 |
+
|
232 |
+
$import_options = $importData['import']['options'][$this->slug];
|
233 |
+
|
234 |
+
// echo "<pre>";
|
235 |
+
// print_r($import_options);
|
236 |
+
// echo "</pre>";
|
237 |
+
|
238 |
+
if ( ! empty($parsedData) ) {
|
239 |
+
|
240 |
+
$this->logger = $importData['logger'];
|
241 |
+
|
242 |
+
$post_id = $importData['pid'];
|
243 |
+
$index = $importData['i'];
|
244 |
+
|
245 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
246 |
+
|
247 |
+
if ($field_params['type'] == 'image') {
|
248 |
+
|
249 |
+
// import the specified image, then set the value of the field to the image ID in the media library
|
250 |
+
|
251 |
+
$image_url_or_path = $parsedData[$field_slug][$index];
|
252 |
+
|
253 |
+
$download = $import_options['download_image'][$field_slug];
|
254 |
+
|
255 |
+
$uploaded_image = PMXI_API::upload_image($post_id, $image_url_or_path, $download, $importData['logger'], true);
|
256 |
+
|
257 |
+
$data[$field_slug] = array(
|
258 |
+
"attachment_id" => $uploaded_image,
|
259 |
+
"image_url_or_path" => $image_url_or_path,
|
260 |
+
"download" => $download
|
261 |
+
);
|
262 |
+
|
263 |
+
} else {
|
264 |
+
|
265 |
+
// set the field data to the value of the field after it's been parsed
|
266 |
+
$data[$field_slug] = $parsedData[$field_slug][$index];
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
// apply mapping rules if they exist
|
271 |
+
if ($import_options['mapping'][$field_slug]) {
|
272 |
+
$mapping_rules = json_decode($import_options['mapping'][$field_slug], true);
|
273 |
+
|
274 |
+
if (!empty($mapping_rules) and is_array($mapping_rules)) {
|
275 |
+
foreach ($mapping_rules as $rule_number => $map_to) {
|
276 |
+
if (!empty($map_to[trim($data[$field_slug])])){
|
277 |
+
$data[$field_slug] = trim($map_to[trim($data[$field_slug])]);
|
278 |
+
break;
|
279 |
+
}
|
280 |
+
}
|
281 |
+
}
|
282 |
+
}
|
283 |
+
// --------------------
|
284 |
+
|
285 |
+
|
286 |
+
}
|
287 |
+
|
288 |
+
call_user_func($this->import_function, $post_id, $data, $importData['import']);
|
289 |
+
}
|
290 |
+
|
291 |
+
}
|
292 |
+
|
293 |
+
|
294 |
+
function wpai_api_metabox($post_type) {
|
295 |
+
|
296 |
+
if (!$this->is_active_addon($post_type)) {
|
297 |
+
return;
|
298 |
+
}
|
299 |
+
|
300 |
+
echo $this->helper_metabox_top($this->name);
|
301 |
+
|
302 |
+
$current_values = $this->helper_current_field_values();
|
303 |
+
|
304 |
+
$visible_fields = 0;
|
305 |
+
|
306 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
307 |
+
if ($field_params['is_sub_field']) continue;
|
308 |
+
$visible_fields++;
|
309 |
+
}
|
310 |
+
|
311 |
+
$counter = 0;
|
312 |
+
|
313 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
314 |
+
|
315 |
+
// do not render sub fields
|
316 |
+
if ($field_params['is_sub_field']) continue;
|
317 |
+
|
318 |
+
$counter++;
|
319 |
+
|
320 |
+
$this->render_field($field_params, $field_slug, $current_values, $visible_fields == $counter);
|
321 |
+
|
322 |
+
//if ( $field_params['type'] != 'accordion' ) echo "<br />";
|
323 |
+
|
324 |
+
}
|
325 |
+
|
326 |
+
echo $this->helper_metabox_bottom();
|
327 |
+
|
328 |
+
if ( ! empty($this->image_sections) ){
|
329 |
+
|
330 |
+
foreach ($this->image_sections as $section) {
|
331 |
+
$section_options = array();
|
332 |
+
foreach ($this->image_options as $slug => $value) {
|
333 |
+
$section_options[$section['slug'] . $slug] = $value;
|
334 |
+
}
|
335 |
+
PMXI_API::add_additional_images_section($section['title'], $section['slug'], $this->helper_current_field_values($section_options), '', true, false, $section['type']);
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
+
function render_field($field_params, $field_slug, $current_values, $in_the_bottom = false){
|
342 |
+
|
343 |
+
if ($field_params['type'] == 'text') {
|
344 |
+
|
345 |
+
PMXI_API::add_field(
|
346 |
+
'simple',
|
347 |
+
$field_params['name'],
|
348 |
+
array(
|
349 |
+
'tooltip' => $field_params['tooltip'],
|
350 |
+
'field_name' => $this->slug."[".$field_slug."]",
|
351 |
+
'field_value' => $current_values[$this->slug][$field_slug]
|
352 |
+
)
|
353 |
+
);
|
354 |
+
|
355 |
+
} else if ($field_params['type'] == 'textarea') {
|
356 |
+
|
357 |
+
PMXI_API::add_field(
|
358 |
+
'textarea',
|
359 |
+
$field_params['name'],
|
360 |
+
array(
|
361 |
+
'tooltip' => $field_params['tooltip'],
|
362 |
+
'field_name' => $this->slug."[".$field_slug."]",
|
363 |
+
'field_value' => $current_values[$this->slug][$field_slug]
|
364 |
+
)
|
365 |
+
);
|
366 |
+
|
367 |
+
} else if ($field_params['type'] == 'image') {
|
368 |
+
|
369 |
+
PMXI_API::add_field(
|
370 |
+
'image',
|
371 |
+
$field_params['name'],
|
372 |
+
array(
|
373 |
+
'tooltip' => $field_params['tooltip'],
|
374 |
+
'field_name' => $this->slug."[".$field_slug."]",
|
375 |
+
'field_value' => $current_values[$this->slug][$field_slug],
|
376 |
+
'download_image' => $current_values[$this->slug]['download_image'][$field_slug],
|
377 |
+
'field_key' => $field_slug,
|
378 |
+
'addon_prefix' => $this->slug
|
379 |
+
|
380 |
+
)
|
381 |
+
);
|
382 |
+
|
383 |
+
} else if ($field_params['type'] == 'radio') {
|
384 |
+
|
385 |
+
PMXI_API::add_field(
|
386 |
+
'enum',
|
387 |
+
$field_params['name'],
|
388 |
+
array(
|
389 |
+
'tooltip' => $field_params['tooltip'],
|
390 |
+
'field_name' => $this->slug."[".$field_slug."]",
|
391 |
+
'field_value' => $current_values[$this->slug][$field_slug],
|
392 |
+
'enum_values' => $field_params['enum_values'],
|
393 |
+
'mapping' => true,
|
394 |
+
'field_key' => $field_slug,
|
395 |
+
'mapping_rules' => $current_values[$this->slug]['mapping'][$field_slug],
|
396 |
+
'xpath' => $current_values[$this->slug]['xpaths'][$field_slug],
|
397 |
+
'addon_prefix' => $this->slug,
|
398 |
+
'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values)
|
399 |
+
)
|
400 |
+
);
|
401 |
+
|
402 |
+
} else if($field_params['type'] == 'accordion') {
|
403 |
+
|
404 |
+
PMXI_API::add_field(
|
405 |
+
'accordion',
|
406 |
+
$field_params['name'],
|
407 |
+
array(
|
408 |
+
'tooltip' => $field_params['tooltip'],
|
409 |
+
'field_name' => $this->slug."[".$field_slug."]",
|
410 |
+
'field_key' => $field_slug,
|
411 |
+
'addon_prefix' => $this->slug,
|
412 |
+
'sub_fields' => $this->get_sub_fields($field_params, $field_slug, $current_values),
|
413 |
+
'in_the_bottom' => $in_the_bottom
|
414 |
+
)
|
415 |
+
);
|
416 |
+
|
417 |
+
}
|
418 |
+
|
419 |
+
|
420 |
+
}
|
421 |
+
/**
|
422 |
+
*
|
423 |
+
* Helper function for nested radio fields
|
424 |
+
*
|
425 |
+
*/
|
426 |
+
function get_sub_fields($field_params, $field_slug, $current_values){
|
427 |
+
$sub_fields = array();
|
428 |
+
if ( ! empty($field_params['enum_values']) ){
|
429 |
+
foreach ($field_params['enum_values'] as $key => $value) {
|
430 |
+
$sub_fields[$key] = array();
|
431 |
+
if (is_array($value)){
|
432 |
+
if ($field_params['type'] == 'accordion'){
|
433 |
+
$sub_fields[$key][] = $this->convert_field($value, $current_values);
|
434 |
+
}
|
435 |
+
else
|
436 |
+
{
|
437 |
+
foreach ($value as $k => $sub_field) {
|
438 |
+
if (is_array($sub_field) and ! empty($this->fields[$sub_field['slug']]))
|
439 |
+
{
|
440 |
+
$sub_fields[$key][] = $this->convert_field($sub_field, $current_values);
|
441 |
+
}
|
442 |
+
}
|
443 |
+
}
|
444 |
+
}
|
445 |
+
}
|
446 |
+
}
|
447 |
+
return $sub_fields;
|
448 |
+
}
|
449 |
+
|
450 |
+
function convert_field($sub_field, $current_values){
|
451 |
+
$field = array();
|
452 |
+
switch ($this->fields[$sub_field['slug']]['type']) {
|
453 |
+
case 'text':
|
454 |
+
$field = array(
|
455 |
+
'type' => 'simple',
|
456 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
457 |
+
'params' => array(
|
458 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
459 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
460 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
461 |
+
'is_main_field' => $sub_field['is_main_field']
|
462 |
+
)
|
463 |
+
);
|
464 |
+
break;
|
465 |
+
case 'textarea':
|
466 |
+
$field = array(
|
467 |
+
'type' => 'textarea',
|
468 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
469 |
+
'params' => array(
|
470 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
471 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
472 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
473 |
+
'is_main_field' => $sub_field['is_main_field']
|
474 |
+
)
|
475 |
+
);
|
476 |
+
break;
|
477 |
+
case 'image':
|
478 |
+
$field = array(
|
479 |
+
'type' => 'image',
|
480 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
481 |
+
'params' => array(
|
482 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
483 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
484 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
485 |
+
'download_image' => $current_values[$this->slug]['download_image'][$sub_field['slug']],
|
486 |
+
'field_key' => $sub_field['slug'],
|
487 |
+
'addon_prefix' => $this->slug,
|
488 |
+
'is_main_field' => $sub_field['is_main_field']
|
489 |
+
)
|
490 |
+
);
|
491 |
+
break;
|
492 |
+
case 'radio':
|
493 |
+
$field = array(
|
494 |
+
'type' => 'enum',
|
495 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
496 |
+
'params' => array(
|
497 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
498 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
499 |
+
'field_value' => $current_values[$this->slug][$sub_field['slug']],
|
500 |
+
'enum_values' => $this->fields[$sub_field['slug']]['enum_values'],
|
501 |
+
'mapping' => true,
|
502 |
+
'field_key' => $sub_field['slug'],
|
503 |
+
'mapping_rules' => $current_values[$this->slug]['mapping'][$sub_field['slug']],
|
504 |
+
'xpath' => $current_values[$this->slug]['xpaths'][$sub_field['slug']],
|
505 |
+
'addon_prefix' => $this->slug,
|
506 |
+
'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
|
507 |
+
'is_main_field' => $sub_field['is_main_field']
|
508 |
+
)
|
509 |
+
);
|
510 |
+
break;
|
511 |
+
case 'accordion':
|
512 |
+
$field = array(
|
513 |
+
'type' => 'accordion',
|
514 |
+
'label' => $this->fields[$sub_field['slug']]['name'],
|
515 |
+
'params' => array(
|
516 |
+
'tooltip' => $this->fields[$sub_field['slug']]['tooltip'],
|
517 |
+
'field_name' => $this->slug."[".$sub_field['slug']."]",
|
518 |
+
'field_key' => $sub_field['slug'],
|
519 |
+
'addon_prefix' => $this->slug,
|
520 |
+
'sub_fields' => $this->get_sub_fields($this->fields[$sub_field['slug']], $sub_field['slug'], $current_values),
|
521 |
+
'in_the_bottom' => false
|
522 |
+
)
|
523 |
+
);
|
524 |
+
break;
|
525 |
+
default:
|
526 |
+
# code...
|
527 |
+
break;
|
528 |
+
}
|
529 |
+
return $field;
|
530 |
+
}
|
531 |
+
|
532 |
+
|
533 |
+
|
534 |
+
/* Get values of the add-ons fields for use in the metabox */
|
535 |
+
|
536 |
+
function helper_current_field_values($default = array()) {
|
537 |
+
|
538 |
+
if (empty($default)){
|
539 |
+
|
540 |
+
$options = array(
|
541 |
+
'mapping' => array(),
|
542 |
+
'xpaths' => array()
|
543 |
+
);
|
544 |
+
|
545 |
+
foreach ($this->fields as $field_slug => $field_params) {
|
546 |
+
$options[$field_slug] = '';
|
547 |
+
if (!empty($field_params['enum_values'])){
|
548 |
+
foreach ($field_params['enum_values'] as $key => $value) {
|
549 |
+
$options[$field_slug] = $key;
|
550 |
+
break;
|
551 |
+
}
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
$default = array($this->slug => $options);
|
556 |
+
|
557 |
+
}
|
558 |
+
|
559 |
+
$input = new PMXI_Input();
|
560 |
+
|
561 |
+
$id = $input->get('id');
|
562 |
+
|
563 |
+
$import = new PMXI_Import_Record();
|
564 |
+
if ( ! $id or $import->getById($id)->isEmpty()) { // specified import is not found
|
565 |
+
$post = $input->post(
|
566 |
+
$default
|
567 |
+
);
|
568 |
+
}
|
569 |
+
else {
|
570 |
+
$post = $input->post(
|
571 |
+
$import->options
|
572 |
+
+ $default
|
573 |
+
);
|
574 |
+
}
|
575 |
+
|
576 |
+
$is_loaded_template = (!empty(PMXI_Plugin::$session->is_loaded_template)) ? PMXI_Plugin::$session->is_loaded_template : false;
|
577 |
+
|
578 |
+
$load_options = $input->post('load_template');
|
579 |
+
|
580 |
+
if ($load_options) { // init form with template selected
|
581 |
+
|
582 |
+
$template = new PMXI_Template_Record();
|
583 |
+
if ( ! $template->getById($is_loaded_template)->isEmpty()) {
|
584 |
+
$post = (!empty($template->options) ? $template->options : array()) + $default;
|
585 |
+
}
|
586 |
+
|
587 |
+
} elseif ($load_options == -1){
|
588 |
+
|
589 |
+
$post = $default;
|
590 |
+
|
591 |
+
}
|
592 |
+
|
593 |
+
return $post;
|
594 |
+
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
*
|
599 |
+
* Add accordion options
|
600 |
+
*
|
601 |
+
*
|
602 |
+
*/
|
603 |
+
function add_options( $main_field = false, $title = '', $fields = array() ){
|
604 |
+
|
605 |
+
if ( ! empty($fields) )
|
606 |
+
{
|
607 |
+
|
608 |
+
if ($main_field){
|
609 |
+
|
610 |
+
$main_field['is_main_field'] = true;
|
611 |
+
$fields[] = $main_field;
|
612 |
+
|
613 |
+
}
|
614 |
+
|
615 |
+
return $this->add_field('accordion_' . $fields[0]['slug'], $title, 'accordion', $fields);
|
616 |
+
|
617 |
+
}
|
618 |
+
|
619 |
+
}
|
620 |
+
|
621 |
+
function helper_metabox_top($name) {
|
622 |
+
|
623 |
+
return '
|
624 |
+
<style type="text/css">
|
625 |
+
.wpallimport-plugin .wpallimport-addon div.input {
|
626 |
+
margin-bottom: 15px;
|
627 |
+
}
|
628 |
+
.wpallimport-plugin .wpallimport-addon .custom-params tr td.action{
|
629 |
+
width: auto !important;
|
630 |
+
}
|
631 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-custom-fields-actions{
|
632 |
+
right:0 !important;
|
633 |
+
}
|
634 |
+
.wpallimport-plugin .wpallimport-addon table tr td.wpallimport-enum-input-wrapper{
|
635 |
+
width: 80%;
|
636 |
+
}
|
637 |
+
.wpallimport-plugin .wpallimport-addon table tr td.wpallimport-enum-input-wrapper input{
|
638 |
+
width: 100%;
|
639 |
+
}
|
640 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-custom-fields-actions{
|
641 |
+
float: right;
|
642 |
+
right: 30px;
|
643 |
+
position: relative;
|
644 |
+
border: 1px solid #ddd;
|
645 |
+
margin-bottom: 10px;
|
646 |
+
}
|
647 |
+
|
648 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options {
|
649 |
+
margin-bottom: 15px;
|
650 |
+
}
|
651 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options .wpallimport-content-section{
|
652 |
+
padding-bottom: 8px;
|
653 |
+
margin:0;
|
654 |
+
border: none;
|
655 |
+
padding-top: 1px;
|
656 |
+
background: #f1f2f2;
|
657 |
+
}
|
658 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options .wpallimport-collapsed-header{
|
659 |
+
padding-left: 13px;
|
660 |
+
}
|
661 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options .wpallimport-collapsed-header h3{
|
662 |
+
font-size: 14px;
|
663 |
+
margin: 6px 0;
|
664 |
+
}
|
665 |
+
|
666 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options-full-width{
|
667 |
+
bottom: -40px;
|
668 |
+
margin-bottom: 0;
|
669 |
+
margin-left: -25px;
|
670 |
+
margin-right: -25px;
|
671 |
+
position: relative;
|
672 |
+
}
|
673 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options-full-width .wpallimport-content-section{
|
674 |
+
margin:0;
|
675 |
+
border-top:1px solid #ddd;
|
676 |
+
border-bottom: none;
|
677 |
+
border-right: none;
|
678 |
+
border-left: none;
|
679 |
+
background: #f1f2f2;
|
680 |
+
}
|
681 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-sub-options-full-width .wpallimport-collapsed-header h3{
|
682 |
+
margin: 14px 0;
|
683 |
+
}
|
684 |
+
|
685 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-dependent-options{
|
686 |
+
margin-left: 1px;
|
687 |
+
margin-right: -1px;
|
688 |
+
}
|
689 |
+
.wpallimport-plugin .wpallimport-addon .wpallimport-dependent-options .wpallimport-content-section{
|
690 |
+
border: 1px solid #ddd;
|
691 |
+
border-top: none;
|
692 |
+
}
|
693 |
+
</style>
|
694 |
+
<div class="wpallimport-collapsed wpallimport-section wpallimport-addon '.$this->slug.' closed">
|
695 |
+
<div class="wpallimport-content-section">
|
696 |
+
<div class="wpallimport-collapsed-header">
|
697 |
+
<h3>'.__($name,'pmxi_plugin').'</h3>
|
698 |
+
</div>
|
699 |
+
<div class="wpallimport-collapsed-content" style="padding: 0;">
|
700 |
+
<div class="wpallimport-collapsed-content-inner">
|
701 |
+
<table class="form-table" style="max-width:none;">
|
702 |
+
<tr>
|
703 |
+
<td colspan="3">';
|
704 |
+
}
|
705 |
+
|
706 |
+
function helper_metabox_bottom() {
|
707 |
+
|
708 |
+
return ' </td>
|
709 |
+
</tr>
|
710 |
+
</table>
|
711 |
+
</div>
|
712 |
+
</div>
|
713 |
+
</div>
|
714 |
+
</div>';
|
715 |
+
|
716 |
+
}
|
717 |
+
|
718 |
+
/**
|
719 |
+
*
|
720 |
+
* simply add an additional section for attachments
|
721 |
+
*
|
722 |
+
*/
|
723 |
+
function import_files( $slug, $title ){
|
724 |
+
$this->import_images( $slug, $title, 'files');
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
*
|
729 |
+
* simply add an additional section
|
730 |
+
*
|
731 |
+
*/
|
732 |
+
function import_images( $slug, $title, $type = 'images' ){
|
733 |
+
|
734 |
+
if ( empty($title) or empty($slug) ) return;
|
735 |
+
|
736 |
+
$section_slug = 'pmxi_' . $slug;
|
737 |
+
|
738 |
+
$this->image_sections[] = array(
|
739 |
+
'title' => $title,
|
740 |
+
'slug' => $section_slug,
|
741 |
+
'type' => $type
|
742 |
+
);
|
743 |
+
|
744 |
+
foreach ($this->image_options as $option_slug => $value) {
|
745 |
+
$this->add_option($section_slug . $option_slug, $value);
|
746 |
+
}
|
747 |
+
|
748 |
+
if (count($this->image_sections) > 1){
|
749 |
+
add_filter('wp_all_import_is_show_add_new_images', array($this, 'filter_is_show_add_new_images'), 10, 2);
|
750 |
+
}
|
751 |
+
|
752 |
+
add_filter('wp_all_import_is_allow_import_images', array($this, 'is_allow_import_images'), 10, 2);
|
753 |
+
|
754 |
+
if (function_exists($slug)) add_action( $section_slug, $slug, 10, 4);
|
755 |
+
}
|
756 |
+
/**
|
757 |
+
*
|
758 |
+
* filter to allow import images for free edition of WP All Import
|
759 |
+
*
|
760 |
+
*/
|
761 |
+
function is_allow_import_images($is_allow, $post_type){
|
762 |
+
return ($this->is_active_addon($post_type)) ? true : $is_allow;
|
763 |
+
}
|
764 |
+
|
765 |
+
/**
|
766 |
+
*
|
767 |
+
* filter to control additional images sections
|
768 |
+
*
|
769 |
+
*/
|
770 |
+
function additional_sections($sections){
|
771 |
+
if ( ! empty($this->image_sections) ){
|
772 |
+
foreach ($this->image_sections as $add_section) {
|
773 |
+
$sections[] = $add_section;
|
774 |
+
}
|
775 |
+
}
|
776 |
+
|
777 |
+
return $sections;
|
778 |
+
}
|
779 |
+
/**
|
780 |
+
*
|
781 |
+
* remove the 'Don't touch existing images, append new images' when more than one image section is in use.
|
782 |
+
*
|
783 |
+
*/
|
784 |
+
function filter_is_show_add_new_images($is_show, $post_type){
|
785 |
+
return ($this->is_active_addon($post_type)) ? false : $is_show;
|
786 |
+
}
|
787 |
+
|
788 |
+
/**
|
789 |
+
*
|
790 |
+
* disable the default images section
|
791 |
+
*
|
792 |
+
*/
|
793 |
+
function disable_default_images($post_type = false){
|
794 |
+
|
795 |
+
add_filter('wp_all_import_is_images_section_enabled', array($this, 'is_enable_default_images_section'), 10, 2);
|
796 |
+
|
797 |
+
}
|
798 |
+
function is_enable_default_images_section($is_enabled, $post_type){
|
799 |
+
|
800 |
+
return ($this->is_active_addon($post_type)) ? false : true;
|
801 |
+
|
802 |
+
}
|
803 |
+
|
804 |
+
function helper_parse($parsingData, $options) {
|
805 |
+
|
806 |
+
extract($parsingData);
|
807 |
+
|
808 |
+
$data = array(); // parsed data
|
809 |
+
|
810 |
+
if ( ! empty($import->options[$this->slug])){
|
811 |
+
|
812 |
+
$this->logger = $parsingData['logger'];
|
813 |
+
|
814 |
+
$cxpath = $xpath_prefix . $import->xpath;
|
815 |
+
|
816 |
+
foreach ($options[$this->slug] as $option_name => $option_value) {
|
817 |
+
|
818 |
+
if ( ! empty($import->options[$this->slug][$option_name]) ) {
|
819 |
+
|
820 |
+
if ($import->options[$this->slug][$option_name] == "xpath") {
|
821 |
+
if ($import->options[$this->slug]['xpaths'][$option_name] == ""){
|
822 |
+
$count and $this->data[$option_name] = array_fill(0, $count, "");
|
823 |
+
} else {
|
824 |
+
$data[$option_name] = XmlImportParser::factory($xml, $cxpath, $import->options[$this->slug]['xpaths'][$option_name], $file)->parse($records);
|
825 |
+
$tmp_files[] = $file;
|
826 |
+
}
|
827 |
+
} else {
|
828 |
+
$data[$option_name] = XmlImportParser::factory($xml, $cxpath, $import->options[$this->slug][$option_name], $file)->parse();
|
829 |
+
$tmp_files[] = $file;
|
830 |
+
}
|
831 |
+
|
832 |
+
|
833 |
+
} else {
|
834 |
+
$data[$option_name] = array_fill(0, $count, "");
|
835 |
+
}
|
836 |
+
|
837 |
+
}
|
838 |
+
|
839 |
+
foreach ($tmp_files as $file) { // remove all temporary files created
|
840 |
+
unlink($file);
|
841 |
+
}
|
842 |
+
|
843 |
+
}
|
844 |
+
|
845 |
+
return $data;
|
846 |
+
}
|
847 |
+
|
848 |
+
|
849 |
+
function can_update_meta($meta_key, $import_options) {
|
850 |
+
|
851 |
+
//echo "<pre>";
|
852 |
+
//print_r($import_options['options']);
|
853 |
+
//echo "</pre>";
|
854 |
+
|
855 |
+
$import_options = $import_options['options'];
|
856 |
+
|
857 |
+
if ($import_options['update_all_data'] == 'yes') return true;
|
858 |
+
|
859 |
+
if ( ! $import_options['is_update_custom_fields'] ) return false;
|
860 |
+
|
861 |
+
if ($import_options['update_custom_fields_logic'] == "full_update") return true;
|
862 |
+
if ($import_options['update_custom_fields_logic'] == "only" and ! empty($import_options['custom_fields_list']) and is_array($import_options['custom_fields_list']) and in_array($meta_key, $import_options['custom_fields_list']) ) return true;
|
863 |
+
if ($import_options['update_custom_fields_logic'] == "all_except" and ( empty($import_options['custom_fields_list']) or ! in_array($meta_key, $import_options['custom_fields_list']) )) return true;
|
864 |
+
|
865 |
+
return false;
|
866 |
+
|
867 |
+
}
|
868 |
+
|
869 |
+
function can_update_image($import_options) {
|
870 |
+
|
871 |
+
$import_options = $import_options['options'];
|
872 |
+
|
873 |
+
if ($import_options['update_all_data'] == 'yes') return true;
|
874 |
+
|
875 |
+
if (!$import_options['is_update_images']) return false;
|
876 |
+
|
877 |
+
if ($import_options['is_update_images']) return true;
|
878 |
+
|
879 |
+
return false;
|
880 |
+
}
|
881 |
+
|
882 |
+
|
883 |
+
function admin_notice_ignore() {
|
884 |
+
if (isset($_GET[$this->slug.'_ignore']) && '0' == $_GET[$this->slug.'_ignore'] ) {
|
885 |
+
update_option($this->slug.'_ignore', 'true');
|
886 |
+
}
|
887 |
+
}
|
888 |
+
|
889 |
+
function display_admin_notice() {
|
890 |
+
|
891 |
+
|
892 |
+
if ($this->notice_text) {
|
893 |
+
$notice_text = $this->notice_text;
|
894 |
+
} else {
|
895 |
+
$notice_text = $this->name.' requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>.';
|
896 |
+
}
|
897 |
+
|
898 |
+
if (!get_option($this->slug.'_ignore')) {
|
899 |
+
|
900 |
+
?>
|
901 |
+
|
902 |
+
<div class="error">
|
903 |
+
<p><?php _e(
|
904 |
+
sprintf(
|
905 |
+
$notice_text.' | <a href="%1$s">Hide Notice</a>',
|
906 |
+
'?'.$this->slug.'_ignore=0'
|
907 |
+
),
|
908 |
+
'rapid_addon_'.$this->slug
|
909 |
+
); ?></p>
|
910 |
+
</div>
|
911 |
+
|
912 |
+
<?php
|
913 |
+
|
914 |
+
}
|
915 |
+
|
916 |
+
}
|
917 |
+
|
918 |
+
/*
|
919 |
+
*
|
920 |
+
* $conditions - array('themes' => array('Realia'), 'plugins' => array('plugin-directory/plugin-file.php', 'plugin-directory2/plugin-file.php'))
|
921 |
+
*
|
922 |
+
*/
|
923 |
+
function admin_notice($notice_text = '', $conditions = array()) {
|
924 |
+
|
925 |
+
$is_show_notice = false;
|
926 |
+
|
927 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
928 |
+
|
929 |
+
if ( ! is_plugin_active('wp-all-import-pro/wp-all-import-pro.php') and ! is_plugin_active('wp-all-import/plugin.php') ){
|
930 |
+
$is_show_notice = true;
|
931 |
+
}
|
932 |
+
|
933 |
+
// Supported Themes
|
934 |
+
if ( ! $is_show_notice and ! empty($conditions['themes']) ){
|
935 |
+
|
936 |
+
$themeInfo = wp_get_theme();
|
937 |
+
$currentTheme = $themeInfo->get('Name');
|
938 |
+
|
939 |
+
$is_show_notice = in_array($currentTheme, $conditions['themes']) ? false : true;
|
940 |
+
|
941 |
+
}
|
942 |
+
|
943 |
+
// Required Plugins
|
944 |
+
if ( ! $is_show_notice and ! empty($conditions['plugins']) ){
|
945 |
+
|
946 |
+
$requires_counter = 0;
|
947 |
+
foreach ($conditions['plugins'] as $plugin) {
|
948 |
+
if ( is_plugin_active($plugin) ) $requires_counter++;
|
949 |
+
}
|
950 |
+
|
951 |
+
if ($requires_counter != count($conditions['plugins'])){
|
952 |
+
$is_show_notice = true;
|
953 |
+
}
|
954 |
+
|
955 |
+
}
|
956 |
+
|
957 |
+
if ( $is_show_notice ){
|
958 |
+
|
959 |
+
if ( $notice_text != '' ) {
|
960 |
+
$this->notice_text = $notice_text;
|
961 |
+
}
|
962 |
+
|
963 |
+
add_action('admin_notices', array($this, 'display_admin_notice'));
|
964 |
+
}
|
965 |
+
|
966 |
+
}
|
967 |
+
|
968 |
+
function log( $m = false){
|
969 |
+
|
970 |
+
$m and $this->logger and call_user_func($this->logger, $m);
|
971 |
+
|
972 |
+
}
|
973 |
+
}
|
974 |
+
|
975 |
+
}
|
976 |
+
|
977 |
+
|
978 |
+
|
readme.txt
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Import Settings into WordPress SEO by Yoast ===
|
2 |
+
Contributors: soflyy, wpallimport
|
3 |
+
Tags: seo, import seo, search engine optimization, import search engine optimization, yoast, import yoast, yoast seo, yoast wordpress seo, import yoast wordpress seo
|
4 |
+
License: GPLv2 or later
|
5 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
6 |
+
Requires at least: 4.1.0
|
7 |
+
Tested up to: 4.2.2
|
8 |
+
Stable tag: 1.0.0
|
9 |
+
|
10 |
+
Easily import SEO settings from any XML or CSV file to Yoast WordPress SEO with the Yoast WordPress SEO Add-On for WP All Import.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
The Yoast WordPress SEO Add-On for [WP All Import](http://wordpress.org/plugins/wp-all-import "WordPress XML & CSV Import") makes it easy to bulk import your SEO setting to the Yoast WordPress SEO plugin in less than 10 minutes.
|
15 |
+
|
16 |
+
The left side shows all of the fields that you can import to and the right side displays the data from your XML/CSV file. Then you can simply drag & drop the data from your XML or CSV into the Yoast WordPress SEO fields to import them.
|
17 |
+
|
18 |
+
The importer is so intuitive it is almost like manually configuring Yoast WordPress SEO when adding/editing a post.
|
19 |
+
|
20 |
+
= Why you should use the Yoast WordPress SEO Add-On for WP All Import =
|
21 |
+
|
22 |
+
* Import new posts, pages, or custom post types and configure their SEO settings all in the same import.
|
23 |
+
|
24 |
+
* Update SEO settings for existing posts, pages, or custom post types already published on your site.
|
25 |
+
|
26 |
+
* Compatible with all other WP All Import add-ons.
|
27 |
+
|
28 |
+
* Complete support - configure all available SEO settings for your posts, including social media images.
|
29 |
+
|
30 |
+
= WP All Import Professional Edition =
|
31 |
+
|
32 |
+
The Yoast WordPress SEO Add-On for WP All Import is fully compatible with [the free version of WP All Import](http://wordpress.org/plugins/wp-all-import "WordPress XML & CSV Import").
|
33 |
+
|
34 |
+
However, [the professional edition of WP All Import](http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_medium=dot-org&utm_campaign=yoast-seo) includes premium support and adds the following features:
|
35 |
+
|
36 |
+
* Import files from a URL: Download and import files from external websites, even if they are password protected with HTTP authentication.
|
37 |
+
|
38 |
+
* Cron Job/Recurring Imports: WP All Import Pro can check periodically check a file for updates, and add, edit, delete, and update the your property listings.
|
39 |
+
|
40 |
+
* Custom PHP Functions: Pass your data through custom functions by using [my_function({data[1]})] in your import template. WP All Import will pass the value of {data[1]} through my_function and use whatever it returns.
|
41 |
+
|
42 |
+
* Access to premium technical support.
|
43 |
+
|
44 |
+
[Upgrade to the professional edition of WP All Import now.](http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_medium=dot-org&utm_campaign=yoast-seo)
|
45 |
+
|
46 |
+
= Developers: Create Your Own Add-On =
|
47 |
+
This Add-On was created using the [Rapid Add-On API](http://www.wpallimport.com/documentation/addon-dev/overview/) for WP All Import. We've made it really easy to write your own Add-On.
|
48 |
+
|
49 |
+
Don't have time? We'll write one for you.
|
50 |
+
|
51 |
+
[Read more about getting an Add-On made for your plugin or theme.](http://www.wpallimport.com/add-ons/#developers)
|
52 |
+
|
53 |
+
== Installation ==
|
54 |
+
|
55 |
+
First, install [WP All Import](http://wordpress.org/plugins/wp-all-import "WordPress XML & CSV Import").
|
56 |
+
|
57 |
+
Then install the Yoast WordPress SEO Add-On.
|
58 |
+
|
59 |
+
To install the Yoast WordPress SEO Add-On, either:
|
60 |
+
|
61 |
+
* Upload the plugin from the Plugins page in WordPress
|
62 |
+
|
63 |
+
* Unzip import-property-listings-into-realia.zip and upload the contents to /wp-content/plugins/, and then activate the plugin from the Plugins page in WordPress
|
64 |
+
|
65 |
+
The Yoast WordPress SEO Add-On will appear in the Step 3 of WP All Import.
|
66 |
+
|
67 |
+
== Changelog ==
|
68 |
+
|
69 |
+
= 1.0.0 =
|
70 |
+
* Initial release on WP.org.
|
71 |
+
|
72 |
+
== Support ==
|
73 |
+
|
74 |
+
We do not handle support in the WordPress.org community forums.
|
75 |
+
|
76 |
+
We do try to handle support for our free version users at the following e-mail address:
|
77 |
+
|
78 |
+
E-mail: support@wpallimport.com
|
79 |
+
|
80 |
+
Support for free version customers is not guaranteed and based on ability. For premium support, purchase [WP All Import Pro](http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_medium=dot-org&utm_campaign=yoast-seo).
|
yoast-addon.php
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
Plugin Name: WP All Import - Yoast WordPress SEO Add-On
|
5 |
+
Plugin URI: http://www.wpallimport.com/
|
6 |
+
Description: Import data into Yoast WordPress SEO with WP All Import.
|
7 |
+
Version: 1.0.1
|
8 |
+
Author: Soflyy
|
9 |
+
*/
|
10 |
+
|
11 |
+
include "rapid-addon.php";
|
12 |
+
|
13 |
+
$yoast_addon = new RapidAddon( 'Yoast WordPress SEO Add-On', 'yoast_addon' );
|
14 |
+
|
15 |
+
$yoast_addon->add_field( '_yoast_wpseo_focuskw', 'Focus Keyword', 'text', null, 'Pick the main keyword or keyphrase that this post/page is about.' );
|
16 |
+
|
17 |
+
$yoast_addon->add_field( '_yoast_wpseo_title', 'SEO Title', 'text', null, 'The SEO title defaults to what is generated based on this sites title template for this posttype.' );
|
18 |
+
|
19 |
+
$yoast_addon->add_field( '_yoast_wpseo_metadesc', 'Meta Description', 'text', null, 'The meta description will be limited to 156 chars. It is often shown as the black text under the title in a search result. For this to work it has to contain the keyword that was searched for.' );
|
20 |
+
|
21 |
+
$yoast_addon->add_options(
|
22 |
+
$yoast_addon->add_field( '_yoast_wpseo_opengraph-title', 'Facebook Title', 'text', null, "If you don't want to use the post title for sharing the post on Facebook but instead want another title there, import it here." ),
|
23 |
+
'Facebook Options',
|
24 |
+
array(
|
25 |
+
$yoast_addon->add_field( '_yoast_wpseo_opengraph-description', 'Description', 'text', null, "If you don't want to use the meta description for sharing the post on Facebook but want another description there, write it here." ),
|
26 |
+
$yoast_addon->add_field( '_yoast_wpseo_opengraph-image', 'Image', 'image', null, "If you want to override the image used on Facebook for this post, import one here. The recommended image size for Facebook is 1200 x 628px."),
|
27 |
+
)
|
28 |
+
);
|
29 |
+
|
30 |
+
$yoast_addon->add_options(
|
31 |
+
$yoast_addon->add_field( '_yoast_wpseo_twitter-title', 'Twitter Title', 'text', null, "If you don't want to use the post title for sharing the post on Twitter but instead want another title there, import it here." ),
|
32 |
+
'Twitter Options',
|
33 |
+
array(
|
34 |
+
$yoast_addon->add_field( '_yoast_wpseo_twitter-description', 'Description', 'text', null, "If you don't want to use the meta description for sharing the post on Twitter but want another description there, import it here." ),
|
35 |
+
$yoast_addon->add_field( '_yoast_wpseo_twitter-image', 'Image', 'image', null, "If you want to override the image used on Twitter for this post, import one here. The recommended image size for Twitter is 1024 x 512px."),
|
36 |
+
)
|
37 |
+
);
|
38 |
+
|
39 |
+
$yoast_addon->add_options(
|
40 |
+
null,
|
41 |
+
'Advanced SEO Options',
|
42 |
+
array(
|
43 |
+
$yoast_addon->add_field( '_yoast_wpseo_meta-robots-noindex', 'Meta Robots Index', 'radio',
|
44 |
+
array(
|
45 |
+
'' => 'default',
|
46 |
+
'2' => 'index',
|
47 |
+
'1' => 'noindex',
|
48 |
+
),
|
49 |
+
"This setting can be overwritten by Yoast WordPress SEO's sitewide privacy settings"
|
50 |
+
),
|
51 |
+
$yoast_addon->add_field( '_yoast_wpseo_meta-robots-nofollow', 'Meta Robots Nofollow', 'radio',
|
52 |
+
array(
|
53 |
+
'' => 'Follow',
|
54 |
+
'1' => 'Nofollow'
|
55 |
+
) ),
|
56 |
+
$yoast_addon->add_field( '_yoast_wpseo_meta-robots-adv', 'Meta Robots Advanced', 'radio',
|
57 |
+
array(
|
58 |
+
'' => 'default',
|
59 |
+
'none' => 'None',
|
60 |
+
'noodp' => 'NO ODP',
|
61 |
+
'noydir' => 'NO YDIR',
|
62 |
+
'noimageindex' => 'No Image Index',
|
63 |
+
'noarchive' => 'No Archive',
|
64 |
+
'nosnippet' => 'No Snippet'
|
65 |
+
),
|
66 |
+
'Advanced meta robots settings for this page.'
|
67 |
+
),
|
68 |
+
$yoast_addon->add_field( '_yoast_wpseo_sitemap-include', 'Include in Sitemap', 'radio',
|
69 |
+
array(
|
70 |
+
'' => 'Auto detect',
|
71 |
+
'always' => 'Always include',
|
72 |
+
'never' => 'Never include'
|
73 |
+
),
|
74 |
+
'Should this page be in the XML Sitemap at all times, regardless of Robots Meta settings?'
|
75 |
+
),
|
76 |
+
$yoast_addon->add_field( '_yoast_wpseo_sitemap-prio', 'Sitemap Priority', 'radio',
|
77 |
+
array(
|
78 |
+
'' => 'Automatic Prioritization',
|
79 |
+
'1' => '1 - Highest priority',
|
80 |
+
'0.9' => '0.9',
|
81 |
+
'0.8' => '0.8 - Default for first tier pages',
|
82 |
+
'0.7' => '0.7',
|
83 |
+
'0.6' => '0.6 - Default for second tier pages and posts',
|
84 |
+
'0.5' => '0.5 - Medium priority',
|
85 |
+
'0.4' => '0.4',
|
86 |
+
'0.3' => '0.3',
|
87 |
+
'0.2' => '0.2',
|
88 |
+
'0.1' => '0.1 - Lowest priority'
|
89 |
+
),
|
90 |
+
'The priority given to this page in the XML sitemap. '
|
91 |
+
),
|
92 |
+
$yoast_addon->add_field( '_yoast_wpseo_canonical', 'Canonical URL', 'text', null, 'The canonical URL that this page should point to, leave empty to default to permalink. Cross domain canonical supported too.' ),
|
93 |
+
$yoast_addon->add_field( '_yoast_wpseo_redirect', '301 Redirect', 'text', null, 'The URL that this page should redirect to.' )
|
94 |
+
|
95 |
+
)
|
96 |
+
);
|
97 |
+
|
98 |
+
// add twitter settings
|
99 |
+
|
100 |
+
$yoast_addon->set_import_function( 'yoast_seo_addon_import' );
|
101 |
+
|
102 |
+
$yoast_addon->admin_notice(
|
103 |
+
'The Yoast WordPress SEO Add-On requires WP All Import <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_medium=dot-org&utm_campaign=yoast" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>, and the <a href="https://yoast.com/wordpress/plugins/seo/">Yoast WordPress SEO</a> plugin.',
|
104 |
+
array(
|
105 |
+
"plugins" => array( "wordpress-seo/wp-seo.php" )
|
106 |
+
) );
|
107 |
+
|
108 |
+
$yoast_addon->run(
|
109 |
+
array(
|
110 |
+
"plugins" => array( "wordpress-seo/wp-seo.php" )
|
111 |
+
) );
|
112 |
+
|
113 |
+
function yoast_seo_addon_import( $post_id, $data, $import_options ) {
|
114 |
+
|
115 |
+
global $yoast_addon;
|
116 |
+
|
117 |
+
// all fields except for slider and image fields
|
118 |
+
$fields = array(
|
119 |
+
'_yoast_wpseo_focuskw',
|
120 |
+
'_yoast_wpseo_title',
|
121 |
+
'_yoast_wpseo_metadesc',
|
122 |
+
'_yoast_wpseo_meta-robots-noindex',
|
123 |
+
'_yoast_wpseo_meta-robots-nofollow',
|
124 |
+
'_yoast_wpseo_meta-robots-adv',
|
125 |
+
'_yoast_wpseo_sitemap-include',
|
126 |
+
'_yoast_wpseo_sitemap-prio',
|
127 |
+
'_yoast_wpseo_canonical',
|
128 |
+
'_yoast_wpseo_redirect',
|
129 |
+
'_yoast_wpseo_opengraph-title',
|
130 |
+
'_yoast_wpseo_opengraph-description',
|
131 |
+
'_yoast_wpseo_twitter-title',
|
132 |
+
'_yoast_wpseo_twitter-description'
|
133 |
+
|
134 |
+
);
|
135 |
+
|
136 |
+
// image fields
|
137 |
+
$image_fields = array(
|
138 |
+
'_yoast_wpseo_opengraph-image',
|
139 |
+
'_yoast_wpseo_twitter-image'
|
140 |
+
);
|
141 |
+
|
142 |
+
$fields = array_merge( $fields, $image_fields );
|
143 |
+
|
144 |
+
// update everything in fields arrays
|
145 |
+
foreach ( $fields as $field ) {
|
146 |
+
|
147 |
+
if ( $yoast_addon->can_update_meta( $field, $import_options ) ) {
|
148 |
+
|
149 |
+
if ( in_array( $field, $image_fields ) ) {
|
150 |
+
|
151 |
+
if ( $yoast_addon->can_update_image( $import_options ) ) {
|
152 |
+
|
153 |
+
$id = $data[$field]['attachment_id'];
|
154 |
+
|
155 |
+
$url = wp_get_attachment_url( $id );
|
156 |
+
|
157 |
+
update_post_meta( $post_id, $field, $url );
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
} else {
|
162 |
+
|
163 |
+
update_post_meta( $post_id, $field, $data[$field] );
|
164 |
+
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
}
|